analysis_utils 0.0.9

  • Readme
  • Changelog
  • Example
  • Installing
  • 22

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]
75
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
0
Overall:
Weighted score of the above. [more]
22
Learn more about scoring.

We analyzed this package on Apr 8, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6

Health suggestions

Fix lib/src/analysis.dart. (-25 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

Make sure dartdoc successfully runs on your package's source files. (-10 points)

exitCode: 255 stdout: parsing /tmp/pub-dartlang-dartdocEXCDQP/pkg/lib/annotation.dart... parsing /tmp/pub-dartlang-dartdocEXCDQP/pkg/lib/analysis.dart... parsing /dart-sdk/lib/core/core.dart... parsing /dart-sdk/lib/collection/collection.dart... parsing /dart-sdk/lib/internal/internal.dart... parsing /dart-sdk/lib/async/async.dart... parsing /dart-sdk/lib/convert/convert.dart... parsing /dart-sdk/lib/typed_data/typed_data.dart... parsing /dart-sdk/lib/math/math.dart... parsing /tmp/pub-dartlang-dartdocEXCDQP/pkg/lib/src/annotations_instantiator.dart... parsing /dart-sdk/lib/mirrors/mirrors.dart... parsing /tmp/pub-cache-dirILNHZA/hosted/pub.dartlang.org/analyzer-0.32.6/lib/analyzer.dart... parsing /dart-sdk/lib/io/io.dart... parsing /dart-sdk/lib/developer/developer.dart... parsing /dart-sdk/lib/isolate/isolate.dart... parsing /dart-sdk/lib/_http/http.dart... parsing /tmp/pub-cache-dirILNHZA/hosted/pub.dartlang.org/analyzer-0.32.6/lib/dart/ast/ast.dart... parsing /tmp/pub-cache-dirILNHZA/hosted/pub.dartlang.org/analyzer-0.32.6/lib/dart/ast/syntactic_entity.dart... parsing /tmp/pub-cache-dirILNHZA/hosted/pub.dartlang.org/front_end-0.1.4+2/lib/src/base/syntactic_entity.dart... parsing /tmp/pub-cache-dirILNHZA/hosted/pub.dartlang.org/analyzer-0.32.6/lib/dart/ast/token.dart... [...] parsing /tmp/pub-cache-dirILNHZA/hosted/pub.dartlang.org/logging-0.11.4/lib/logging.dart... parsing /tmp/pub-cache-dirILNHZA/hosted/pub.dartlang.org/logging-0.11.4/lib/src/log_record.dart... parsing /tmp/pub-cache-dirILNHZA/hosted/pub.dartlang.org/logging-0.11.4/lib/src/level.dart... parsing /tmp/pub-cache-dirILNHZA/hosted/pub.dartlang.org/logging-0.11.4/lib/src/logger.dart... parsing /tmp/pub-cache-dirILNHZA/hosted/pub.dartlang.org/package_config-1.9.3/lib/src/packages_io_impl.dart... parsing /tmp/pub-cache-dirILNHZA/hosted/pub.dartlang.org/package_config-1.9.3/lib/src/util_io.dart... parsing /tmp/pub-cache-dirILNHZA/hosted/pub.dartlang.org/package_config-1.9.3/lib/src/discovery.dart... parsing /tmp/pub-cache-dirILNHZA/hosted/pub.dartlang.org/package_config-1.9.3/lib/src/package_config_io.dart... parsing /tmp/pub-cache-dirILNHZA/hosted/pub.dartlang.org/package_config-1.9.3/lib/src/package_config_impl.dart... parsing /tmp/pub-cache-dirILNHZA/hosted/pub.dartlang.org/package_config-1.9.3/lib/src/package_config.dart... parsing /tmp/pub-cache-dirILNHZA/hosted/pub.dartlang.org/package_config-1.9.3/lib/src/package_config_json.dart... parsing /tmp/pub-cache-dirILNHZA/hosted/pub.dartlang.org/package_config-1.9.3/lib/src/packages_file.dart... parsing /tmp/pub-cache-dirILNHZA/hosted/pub.dartlang.org/args-1.6.0/lib/src/help_command.dart... parsing /tmp/pub-cache-dirILNHZA/hosted/pub.dartlang.org/args-1.6.0/lib/src/usage_exception.dart... Initialized dartdoc with 694 libraries in 107.2 seconds documenting analysis_utils Generating docs for library analysis_utils.analysis from package:analysis_utils/annotation.dart... Generating docs for library analysis_utils.analysis from package:analysis_utils/analysis.dart... Validating docs... Documented 2 public libraries in 7.1 seconds stderr: Documenting analysis_utils... error: failed to write file at: analysis_utils.analysis/analysis_utils.analysis-library.html for symbol analysis_utils.analysis: (file:///tmp/pub-dartlang-dartdocEXCDQP/pkg/lib/analysis.dart:2:9) conflicting with file already generated by analysis_utils.analysis: (file:///tmp/pub-dartlang-dartdocEXCDQP/pkg/lib/annotation.dart:2:9) Dartdoc generates a path and filename to write to for each symbol. analysis_utils.analysis conflicts with another symbol in the generated path, and therefore can not be written out. Changing the name, library name, or class name (if appropriate) of one of the conflicting items can resolve the conflict. Alternatively, use the @nodoc tag in one symbol's documentation comments to hide it. warning: no canonical library found for analysis_utils.analysis.ClassAnalysis.analyzerDeclaration, not linking, from analysis_utils.analysis.ClassAnalysis.analyzerDeclaration: (file:///tmp/pub-dartlang-dartdocEXCDQP/pkg/lib/src/analysis.dart:207:5) warning: no canonical library found for analysis_utils.analysis.ClassAnalysis.docs, not linking, from analysis_utils.analysis.ClassAnalysis.docs: (file:///tmp/pub-dartlang-dartdocEXCDQP/pkg/lib/src/analysis.dart:202:10) warning: no canonical library found for analysis_utils.analysis.ClassAnalysis.hashCode, not linking, from analysis_utils.analysis.ClassAnalysis.hashCode: (file:///dart-sdk/lib/core/object.dart:94:20) warning: no canonical library found for analysis_utils.analysis.ClassAnalysis.location, not linking, from analysis_utils.analysis.ClassAnalysis.location: (file:///tmp/pub-dartlang-dartdocEXCDQP/pkg/lib/src/analysis.dart:203:14) warning: no canonical library found for analysis_utils.analysis.ClassAnalysis.metadata, not linking, from analysis_utils.analysis.ClassAnalysis.metadata: (file:///tmp/pub-dartlang-dartdocEXCDQP/pkg/lib/src/analysis.dart:204:26) warning: no canonical library found for analysis_utils.analysis.ClassAnalysis.mirror, not linking, from analysis_utils.analysis.ClassAnalysis.mirror: (file:///tmp/pub-dartlang-dartdocEXCDQP/pkg/lib/src/analysis.dart:206:5) warning: no canonical library found for analysis_utils.analysis.ClassAnalysis.name, not linking, from analysis_utils.analysis.ClassAnalysis.name: (file:///tmp/pub-dartlang-dartdocEXCDQP/pkg/lib/src/analysis.dart:201:10) warning: no canonical library found for analysis_utils.analysis.ClassAnalysis.runtimeType, not linking, from analysis_utils.analysis.ClassAnalysis.runtimeType: (file:///dart-sdk/lib/core/object.dart:116:21) warning: no canonical library found for analysis_utils.analysis.ClassAnalysis.source, not linking, from analysis_utils.analysis.ClassAnalysis.source: (file:///tmp/pub-dartlang-dartdocEXCDQP/pkg/lib/src/analysis.dart:205:18) warning: no canonical library found for analysis_utils.analysis.ClassAnalysis.noSuchMethod, not linking, from analysis_utils.analysis.ClassAnalysis.noSuchMethod: (file:///dart-sdk/lib/core/object.dart:111:20) warning: no canonical library found for analysis_utils.analysis.ClassAnalysis.toString, not linking, from analysis_utils.analysis.ClassAnalysis.toString: (file:///tmp/pub-dartlang-dartdocEXCDQP/pkg/lib/src/analysis.dart:247:10) warning: no canonical library found for analysis_utils.analysis.ClassAnalysis.==, not linking, from analysis_utils.analysis.ClassAnalysis.==: (file:///dart-sdk/lib/core/object.dart:62:26) warning: no canonical library found for analysis_utils.analysis.ConstructorAnalysis.container, not linking, from analysis_utils.analysis.ConstructorAnalysis.container: (file:///tmp/pub-dartlang-dartdocEXCDQP/pkg/lib/src/analysis.dart:477:17) warning: no canonical library found for analysis_utils.analysis.ConstructorAnalysis.namedParameters, not linking, from analysis_utils.analysis.ConstructorAnalysis.namedParameters: (file:///tmp/pub-dartlang-dartdocEXCDQP/pkg/lib/src/analysis.dart:636:22) warning: no canonical library found for analysis_utils.analysis.ConstructorAnalysis.optionalParameters, not linking, from analysis_utils.analysis.ConstructorAnalysis.optionalParameters: (file:///tmp/pub-dartlang-dartdocEXCDQP/pkg/lib/src/analysis.dart:642:23) warning: no canonical library found for analysis_utils.analysis.ConstructorAnalysis.ordinaryParameters, not linking, from analysis_utils.analysis.ConstructorAnalysis.ordinaryParameters: (file:///tmp/pub-dartlang-dartdocEXCDQP/pkg/lib/src/analysis.dart:645:23) warning: no canonical library found for analysis_utils.analysis.ConstructorAnalysis.parameters, not linking, from analysis_utils.analysis.ConstructorAnalysis.parameters: (file:///tmp/pub-dartlang-dartdocEXCDQP/pkg/lib/src/analysis.dart:632:22) warning: no canonical library found for analysis_utils.analysis.ConstructorAnalysis.positionalOptionalParameters, not linking, from analysis_utils.analysis.ConstructorAnalysis.positionalOptionalParameters: (file:///tmp/pub-dartlang-dartdocEXCDQP/pkg/lib/src/analysis.dart:653:23) warning: no canonical library found for analysis_utils.analysis.ConstructorAnalysis.positionalParameters, not linking, from analysis_utils.analysis.ConstructorAnalysis.positionalParameters: (file:///tmp/pub-dartlang-dartdocEXCDQP/pkg/lib/src/analysis.dart:649:23) warning: no canonical library found for analysis_utils.analysis.ConstructorAnalysis.requiredParameters, not linking, from analysis_utils.analysis.ConstructorAnalysis.requiredParameters: (file:///tmp/pub-dartlang-dartdocEXCDQP/pkg/lib/src/analysis.dart:639:23) warning: no canonical library found for analysis_utils.analysis.MetadataAnalysis.toString, not linking, from analysis_utils.analysis.MetadataAnalysis.toString: (file:///dart-sdk/lib/core/object.dart:99:19) warning: dartdoc generated a broken link to: analysis_utils.analysis/instanceFromAnnotation.html (from index.json) warning: dartdoc generated a broken link to: analysis_utils.analysis/instantiate.html (from index.json) found 23 warnings and 1 error Unhandled exception: dartdoc encountered 1 errors while processing. #0 Dartdoc.generateDocs (package:dartdoc/dartdoc.dart:202:7)

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. (-50.96 points)

The package was last published 78 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.6
path ^1.6.2 1.6.4
source_span ^1.4.0 1.7.0
Transitive dependencies
args 1.6.0
async 2.4.1
charcode 1.1.3
collection 1.14.12
convert 2.1.1
crypto 2.1.4
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.4
meta 1.1.8
node_interop 1.0.3
node_io 1.0.1+2
package_config 1.9.3
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+14
yaml 2.2.0
Dev dependencies
test >=1.0.0 <2.0.0