analysis_utils 0.0.9

  • Readme
  • Changelog
  • Example
  • Installing
  • 29

analysis_utils #

A library for facilitating the analysis of code integrating both dart:mirrors and analyzer packages (in the AST nodes facet)

Features #

So far the library supports:

  • Documentation blocks parsing
  • source_span's in-file source locations
  • Annotations analysis and instantiation
  • Class Analysis
    • Method analysis
    • Field analysis
    • Constructor analysis

Usage #

So far, the usage is ClassAnalysis oriented only:

import "package:analysis_utils/analysis.dart";

main(){
  ClassAnalysis typeAnalysis = new ClassAnalysis.fromType(Clazz);
  Clazz c = new Clazz();
  ClassAnalysis instanceAnalysis = new ClassAnalysis.fromInstance(c);
}

For more info you can see the example, test or documentation

Please file feature requests and bugs at the issue tracker.

Changelog #

0.0.9 #

  • Added metadata, sourceLocations and docs functionality and testings for TopLevelVars

0.0.8 #

  • Added capacity of statically analyze only with analyzer (mirrors free)

0.0.6 #

  • Mocosoft free: repo en Gitlab

0.0.5 #

  • Add Uri resolving capabilities
  • Separated the code attribute in a getter (for "lazy loading")

0.0.4 #

  • isPrivate to MethodAnalysis

0.0.3 #

  • Boludeces para que ande, desestimar...

0.0.2 #

  • Arreglo de links en el readme
  • Dejar presentable y en inglés el código de ejemplo

0.0.1 #

  • Initial version, created by Stagehand

example/analysis_utils_example.dart

import 'package:analysis_utils/analysis.dart';

/// The classic documentation
/// comment is supported
class ExampleClass extends ParentClass {
  /** Also
   * this
   * kind
   * of
   * documentation
   * is
   * supported
   */
  int field1;
  String field2;

  void method1() {
    print("method1 executed");
  }

  /// Greet `name`
  String method2(String name) => "Hello $name";

  ExampleClass(String param1, int param2, [this.field1]);

  ExampleClass.withField2(this.field2);
}

//custom annotation, ain't a documentation comment, shouldn't be parsed, so
class annon {
  final int n;
  final String text;
  const annon(this.n, [this.text]);
}

class ParentClass {
  @annon(1, "sorp")
  @annon(2)
  @annon(3, "longa")
  @annon(4)
  List<int> sorp = [];

  double var1 = 2.0, initVal = 723 + 123 / 2;
}

main() {
  ClassAnalysis clazz = new ClassAnalysis.fromType(ExampleClass);
  print("The class name is: ${clazz.name}");
  print("The fields are: " + clazz.fields.keys.join(", "));
  print("The initial value of 'initVal' field is:"
      " ${clazz.fields['initVal'].defaultValue}");
  print("The methods are: " + clazz.methods.keys.join(", "));
  print("The constructors are: " + clazz.constructors.keys.join(", "));
  print(
      "  The default constructor has ${clazz.constructors[""].parameters.length}"
      " parameters:\n${clazz.constructors[""].parameters.all.map((Parameter p) => p.name).join(", ")}");
  print("The documentation for method2 is: " + clazz.methods["method2"].docs);
  print("The inherintance preserves even the annotations from the parent"
      "class! (it has ${clazz.fields["sorp"].metadata.length} annotations)");
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  analysis_utils: ^0.0.9

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:analysis_utils/analysis.dart';
import 'package:analysis_utils/annotation.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
67
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
43
Overall:
Weighted score of the above. [more]
29
Learn more about scoring.

We analyzed this package on Dec 5, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.1
  • pana: 0.12.21

Platforms

Detected platforms: other

Platform components identified in package: io, isolate, mirrors.

Health suggestions

Fix lib/src/analysis.dart. (-28.17 points)

Analysis of lib/src/analysis.dart reported 66 hints, including:

line 29 col 19: Unnecessary new keyword.

line 39 col 7: DO use curly braces for all flow control structures.

line 41 col 34: Unnecessary new keyword.

line 49 col 7: DO use curly braces for all flow control structures.

line 51 col 34: Unnecessary new keyword.

Fix lib/src/expression_handler.dart. (-2.96 points)

Analysis of lib/src/expression_handler.dart reported 6 hints, including:

line 13 col 25: Unnecessary new keyword.

line 25 col 41: Unnecessary new keyword.

line 53 col 35: Unnecessary new keyword.

line 59 col 9: DO use curly braces for all flow control structures.

line 59 col 15: Unnecessary new keyword.

Fix lib/src/resolver.dart. (-2.48 points)

Analysis of lib/src/resolver.dart reported 5 hints:

line 9 col 30: DO use curly braces for all flow control structures.

line 11 col 11: Unnecessary new keyword.

line 26 col 23: Unnecessary new keyword.

line 35 col 15: Unnecessary new keyword.

line 41 col 13: Unnecessary new keyword.

Fix lib/src/annotations_instantiator.dart. (-1 points)

Analysis of lib/src/annotations_instantiator.dart reported 2 hints:

line 9 col 9: Unnecessary new keyword.

line 17 col 17: Unnecessary new keyword.

Maintenance issues and suggestions

Homepage URL doesn't exist. (-20 points)

At the time of the analysis the homepage field https://www.gitlab.com/Rodsevich/analysis_utils was unreachable.

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (analyzer).

Package is getting outdated. (-16.71 points)

The package was last published 60 weeks ago.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
analyzer >=0.32.1 <0.33.0 0.32.6 0.39.1
path ^1.6.2 1.6.4
source_span ^1.4.0 1.5.5
Transitive dependencies
args 1.5.2
async 2.4.0
charcode 1.1.2
collection 1.14.12
convert 2.1.1
crypto 2.1.3
csslib 0.16.1
front_end 0.1.4+2 0.1.29
glob 1.2.0
html 0.14.0+3
js 0.6.1+1
kernel 0.3.4+2 0.3.29
logging 0.11.3+2
meta 1.1.8
node_interop 1.0.3
node_io 1.0.1+2
package_config 1.1.0
pedantic 1.9.0
plugin 0.2.0+3
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
watcher 0.9.7+13
yaml 2.2.0
Dev dependencies
test >=1.0.0 <2.0.0