code_transformers 0.5.1+5

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • --

Code Transformers

This package exposes various tools to help in the creation and testing of barback transformers, as well as an interface for logging messages with constant ids for documentation purposes.

Messages and logging

This package exposes a BuildLogger class as well as Message, MessageTemplate, and MessageId classes. These work together to provide stable error messages with ids that can be referenced in documentation.

MessageId

A MessageId is a constant definition of a message in a package. These are used to group messages with the same id or link to sections in a document.

const myId = const MessageId('myPackage', 0);

These ids should typically never change or disappear throughout the entire lifetime of a package.

Message

A Message is a const object which has a MessageId and snippet.

const myMessage = const Message(myId, 'my message');

MessageTemplate

TODO(jakemac): Docs on this, see https://github.com/dart-lang/code-transformers/blob/master/lib/messages/messages.dart

BuildLogger

The BuildLogger class just wraps a normal TransformLogger to provide some additional functionality. You use it in the same way as a TransformLogger except that the log methods can accept a String or a Message. This should usually be created in the first step of your transformers apply function:

apply(Transform transform) {
  // If detailsUri is passed, then a link will be output with each log
  // message that follows this format
  // `$detailsUri#${msg.id.package}_${msg.id.id}`.
  var logger = new BuildLogger(transform, detailsUri: 'http://foo.com');
}

You can optionally dump out a file containing all the logs found in JSON format by calling the writeOutput method on the logger when you are done. The output file will have the same file path as the primary input of the transformer, with an extension matching this pattern ._buildLogs.$i. The i increments starting at 0 each time that logs are output (if multiple transformers run on the same file for instance). These can all be combined into a single file later on by calling the static combineLogFiles(Transform transform) function.

Testing Transformers

TODO(jakemac): Docs on this, see testPhases in https://github.com/dart-lang/code-transformers/blob/master/lib/tests.dart

Using the Analyzer in Transformers

This package exposes a Resolver class which helps out when using the analyzer in a transform.

TODO(jakemac): Docs on this, see https://github.com/dart-lang/code-transformers/blob/master/lib/src/resolver.dart

Barback AssetIds and Uris

This package also provides some helpers to convert AssetIds to and from Uris relative to a source asset.

TODO(jakemac): Docs on this, see uriToAssetId & assetIdToUri in https://github.com/dart-lang/code-transformers/blob/master/lib/assets.dart

0.5.1+5

  • Support the latest analyzer package.

0.5.1+4

  • Support the latest analyzer package.

0.5.1+3

  • Support the latest cli_util package.

0.5.1+2

  • Support the latest analyzer package.

0.5.1+1

  • Updated mock SDK sources to include FutureOr<T> (and fixed a syntax error)

0.5.1

  • Resolver has a new method which can check whether an Asset is a Dart library source

0.5.0+2

  • Resolver no longer returns a partial LibraryElement for assets which are not libraries

0.5.0+1

  • Stop using deprecated analyzer apis.

0.5.0

  • Always use a single Resolver instance. Fixes an issue where running with the 'build' package in file watching mode would treat some files as never changing.
  • Breaking Change: remove the useSharedSources argument to Resolvers ctor since sources are always shared.

0.4.2+4

  • Update to work with analyzer 0.29.x and transform_test 0.2.x

0.4.2+3

  • Update to work with analyzer 0.28.x.

0.4.2+2

  • Update to work with analyzer 0.23.x.

0.4.2+1

  • Contains a fix for the useSharedSources option that could result in null library elements when running on multiple entry points.

0.4.2

  • Use Strong Mode, fixes #38.

0.4.1

  • Added a fix for #24890.
    • All constants in all libraries will once again be resolved by default.
    • Added a new resolveAllLibraries option to Resolver#resolve and Resolvers#get. If false is passed then constants will not be resolved in non entry points. This saves significant time if constants are not needed.
  • Added a useSharedSources option to Resolvers. This gives a significant speed increase, but must be used carefully.
    • If used, then all Resolver instances created from the same Resolvers instance will share the same sources cache.
    • This should be generally safe to use if the Resolvers instance is created in the constructor of your Transformer.
    • This option should probably not be used with a static or shared Resolvers instance.

0.4.0

  • Remove dependency on test, and move all test related apis to a new transformer_test package which is now a dev dependency.

0.3.1

  • Update to analyzer >=0.27.0 <0.28.0.

0.3.0+1

  • Upgrade test to a real dependency.

0.3.0

  • Re-release 0.2.10 release as 0.3.0.

0.2.11

  • Revert 0.2.10 release, will be re-released as 0.3.0 since it is actually a breaking change.

0.2.10

  • Update to use the test package instead of the unittest package.

0.2.9+4

  • Republish 0.2.9+2 under new version.

0.2.9+3

  • Republish of 0.2.9 to ensure nobody gets 0.2.9+1 in the future.

0.2.9+2

  • Update to analyzer '>=0.26.0 <0.27.0'

0.2.9+1

  • Update to analyzer '<0.27.0'
  • This version will be reverted as it wasn't compatible with <0.26.0.

0.2.9

  • Update to analyzer <=0.26.0.

0.2.8

  • Add benchmarks.dart file which exposes a TransformerBenchmark. This can be used to implement simple benchmarks of transformer code.

0.2.7+2

  • Fix assetIdToUri on windows, 41

0.2.7+1

  • Fixes for missing overrides after upgrade to analzyer 0.24.0

0.2.7

  • Added default set of mockSdkSources and upgraded to analyzer 0.24.0

0.2.6

  • Added assetIdToUri to assets.dart.

0.2.5

  • Improvements to dartSdkDirectory so it has a better chance of success.
  • BuildLogger now accepts AggregateTransform or Transform. If passing in an AggregateTransform you must also pass in an AssetId to use as the primary input.

0.2.4

  • Added some basic string formatting options to testPhases to make it a bit less strict if desired.

0.2.3+2

  • Added logic to discover the location of the dart SDK when the dart binary is a symlink.

0.2.3

  • Added support for logging stable error messages from transformers.

0.2.2

  • Added two transformers, 'delete_file' and 'remove_sourcemap_comment'.

0.2.0+3

  • Raise the lower bound on the source_maps constraint to exclude incompatible versions.

0.2.0+2

  • Widen the constraint on source_maps.

0.2.0+1

  • Widen the constraint on barback.

0.2.0

  • Switch from source_maps' Span class to source_span's SourceSpan class.

Use this package as a library

1. Depend on it

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


dependencies:
  code_transformers: ^0.5.1+5

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:code_transformers/assets.dart';
import 'package:code_transformers/benchmarks.dart';
import 'package:code_transformers/messages/build_logger.dart';
import 'package:code_transformers/messages/messages.dart';
import 'package:code_transformers/resolver.dart';
  
Version Uploaded Documentation Archive
0.5.1+5 May 14, 2018 Go to the documentation of code_transformers 0.5.1+5 Download code_transformers 0.5.1+5 archive
0.5.1+4 Feb 2, 2018 Go to the documentation of code_transformers 0.5.1+4 Download code_transformers 0.5.1+4 archive
0.5.1+3 May 18, 2017 Go to the documentation of code_transformers 0.5.1+3 Download code_transformers 0.5.1+3 archive
0.5.1+2 May 3, 2017 Go to the documentation of code_transformers 0.5.1+2 Download code_transformers 0.5.1+2 archive
0.5.1 Jan 27, 2017 Go to the documentation of code_transformers 0.5.1 Download code_transformers 0.5.1 archive
0.5.0+2 Jan 10, 2017 Go to the documentation of code_transformers 0.5.0+2 Download code_transformers 0.5.0+2 archive
0.5.0+1 Nov 15, 2016 Go to the documentation of code_transformers 0.5.0+1 Download code_transformers 0.5.0+1 archive
0.5.0 Oct 17, 2016 Go to the documentation of code_transformers 0.5.0 Download code_transformers 0.5.0 archive
0.4.2+4 Oct 14, 2016 Go to the documentation of code_transformers 0.4.2+4 Download code_transformers 0.4.2+4 archive
0.4.2+3 Sep 1, 2016 Go to the documentation of code_transformers 0.4.2+3 Download code_transformers 0.4.2+3 archive

All 54 versions...

Popularity:
Describes how popular the package is relative to other packages. [more]
--
Health:
Code health derived from static analysis. [more]
--
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
--
Overall:
Weighted score of the above. [more]
--
Learn more about scoring.

This package is not analyzed, because it is discontinued.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.0.0 <2.0.0