Movatterモバイル変換


[0]ホーム

URL:


Google Git
Sign in
chromium /external /github.com /dart-lang /code_transformers
Clone this repo:

Branches

Tags

More...
  1. 7e21686dartfmtby Kevin Moore· 7 years agomaster
  2. 80d133bdartfmtby Kevin Moore· 7 years ago
  3. 0dd1620Switch deprecated JSON to new json (#65)by Sam Rawlins· 7 years ago
  4. c5c71d6Fix Dart 2 runtime issue; type function better (#66)by Sam Rawlins· 7 years ago
  5. 4d29192Remove PATENTS fileby Kevin Moore· 7 years agov0.5.1+5

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 aBuildLogger class as well asMessage,MessageTemplate, andMessageId classes. These work together to provide stable error messages with ids that can be referenced in documentation.

MessageId

AMessageId 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

AMessage is a const object which has aMessageId andsnippet.

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

MessageTemplate

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

BuildLogger

TheBuildLogger class just wraps a normalTransformLogger to provide some additional functionality. You use it in the same way as aTransformLogger except that the log methods can accept aString or aMessage. This should usually be created in the first step of your transformersapply 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 thewriteOutput 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. Thei 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 staticcombineLogFiles(Transform transform) function.

Testing Transformers

TODO(jakemac): Docs on this, seetestPhases inhttps://github.com/dart-lang/code-transformers/blob/master/lib/tests.dart

Using the Analyzer in Transformers

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

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

Barback AssetIds and Uris

This package also provides some helpers to convertAssetIds to and fromUris relative to a source asset.

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


[8]ページ先頭

©2009-2025 Movatter.jp