
committed by
Misko Hevery

parent
64ad74acbe
commit
5c25248582
@ -25,7 +25,7 @@ Future<String> createNgSetters(AssetReader reader, AssetId entryPoint) async {
|
||||
|
||||
// TODO(kegluneq): De-dupe from template_compiler/generator.dart.
|
||||
|
||||
/// Consumes the map generated by [_createBindMap] to codegen setters.
|
||||
/// Consumes the map generated by {@link _createBindMap} to codegen setters.
|
||||
List<String> _generateSetters(Map<String, String> bindMap) {
|
||||
var setters = [];
|
||||
// TODO(kegluneq): Include types for receivers. See #886.
|
||||
@ -41,7 +41,7 @@ List<String> _generateSetters(Map<String, String> bindMap) {
|
||||
return setters;
|
||||
}
|
||||
|
||||
/// Collapses all `bindProperties` in [ngDeps] into a map where the keys are
|
||||
/// Collapses all `bindProperties` in {@link ngDeps} into a map where the keys are
|
||||
/// the bind properties and the values are either the one and only type
|
||||
/// binding to that property or the empty string.
|
||||
Map<String, String> _createBindMap(NgDeps ngDeps) {
|
||||
|
@ -5,14 +5,14 @@ import 'dart:convert';
|
||||
|
||||
import 'package:barback/barback.dart';
|
||||
|
||||
/// A class that allows fetching code using [AssetId]s without all the
|
||||
/// additional baggage of a [Transform].
|
||||
/// A class that allows fetching code using {@link AssetId}s without all the
|
||||
/// additional baggage of a {@link Transform}.
|
||||
abstract class AssetReader {
|
||||
Future<String> readAsString(AssetId id, {Encoding encoding});
|
||||
Future<bool> hasInput(AssetId id);
|
||||
|
||||
/// Creates an [AssetReader] using the `transform`, which should be a
|
||||
/// [Transform] or [AggregateTransform].
|
||||
/// Creates an {@link AssetReader} using the `transform`, which should be a
|
||||
/// {@link Transform} or {@link AggregateTransform}.
|
||||
factory AssetReader.fromTransform(dynamic transform) =>
|
||||
new _TransformAssetReader(transform);
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import 'package:angular2/src/transform/common/logging.dart';
|
||||
import 'package:barback/barback.dart';
|
||||
import 'package:code_transformers/assets.dart';
|
||||
|
||||
/// Creates a mapping of [AssetId]s to the [ClassDeclaration]s which they
|
||||
/// Creates a mapping of {@link AssetId}s to the {@link ClassDeclaration}s which they
|
||||
/// define.
|
||||
Future<Map<AssetId, List<ClassDeclaration>>> createTypeMap(
|
||||
AssetReader reader, AssetId id) {
|
||||
|
@ -7,12 +7,12 @@ import 'package:source_span/source_span.dart';
|
||||
|
||||
BuildLogger _logger;
|
||||
|
||||
/// Prepares [logger] for use throughout the transformer.
|
||||
/// Prepares {@link logger} for use throughout the transformer.
|
||||
void init(Transform t) {
|
||||
_logger = new BuildLogger(t);
|
||||
}
|
||||
|
||||
/// Sets [logger] directly. Used for testing - in general use [init].
|
||||
/// Sets {@link logger} directly. Used for testing - in general use {@link init}.
|
||||
void setLogger(BuildLogger logger) {
|
||||
_logger = logger;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ class TransformerOptions {
|
||||
/// The path to the files where the application's calls to `bootstrap` are.
|
||||
final List<String> entryPoints;
|
||||
|
||||
/// The paths to the files where the application's [ReflectionCapabilities]
|
||||
/// The paths to the files where the application's {@link ReflectionCapabilities}
|
||||
/// are set.
|
||||
final List<String> reflectionEntryPoints;
|
||||
|
||||
|
@ -14,7 +14,7 @@ TransformerOptions parseBarbackSettings(BarbackSettings settings) {
|
||||
}
|
||||
|
||||
/// Cribbed from the polymer project.
|
||||
/// [https://github.com/dart-lang/polymer-dart]
|
||||
/// {@link https://github.com/dart-lang/polymer-dart}
|
||||
List<String> _readFileList(Map config, String paramName) {
|
||||
var value = config[paramName];
|
||||
if (value == null) return null;
|
||||
|
@ -13,8 +13,8 @@ import 'registered_type.dart';
|
||||
|
||||
export 'registered_type.dart';
|
||||
|
||||
/// A parser that reads `.ng_deps.dart` files (represented by [AssetId]s into
|
||||
/// easier to manage [NgDeps] files.
|
||||
/// A parser that reads `.ng_deps.dart` files (represented by {@link AssetId}s into
|
||||
/// easier to manage {@link NgDeps} files.
|
||||
class Parser {
|
||||
final AssetReader _reader;
|
||||
final _ParseNgDepsVisitor _visitor = new _ParseNgDepsVisitor();
|
||||
@ -28,7 +28,7 @@ class Parser {
|
||||
}
|
||||
|
||||
/// Parses only the `.ng_deps.dart` file represented by `id`.
|
||||
/// See also [parseRecursive].
|
||||
/// See also {@link parseRecursive}.
|
||||
Future<NgDeps> parse(AssetId id) async {
|
||||
if (!(await _reader.hasInput(id))) return null;
|
||||
var ngDeps = new NgDeps(await _reader.readAsString(id));
|
||||
@ -37,9 +37,9 @@ class Parser {
|
||||
return ngDeps;
|
||||
}
|
||||
|
||||
/// Parses the `.ng_deps.dart` file represented by [id] into an [NgDeps]
|
||||
/// object. All `.ng_deps.dart` files imported by [id] are then parsed. The
|
||||
/// results are added to [allDeps].
|
||||
/// Parses the `.ng_deps.dart` file represented by {@link id} into an {@link NgDeps}
|
||||
/// object. All `.ng_deps.dart` files imported by {@link id} are then parsed. The
|
||||
/// results are added to {@link allDeps}.
|
||||
Future<List<NgDeps>> _recurse(AssetId id,
|
||||
[List<NgDeps> allDeps, Set<AssetId> seen]) async {
|
||||
if (seen == null) seen = new Set<AssetId>();
|
||||
|
@ -5,7 +5,7 @@ import 'package:analyzer/src/generated/scanner.dart' show Keyword;
|
||||
/// Whether `name` is a valid property name.
|
||||
bool isValid(String name) => !Keyword.keywords.containsKey(name);
|
||||
|
||||
/// Prepares [name] to be emitted inside a string.
|
||||
/// Prepares `name` to be emitted inside a string.
|
||||
String sanitize(String name) => name.replaceAll('\$', '\\\$');
|
||||
|
||||
/// Get a string usable as a lazy invalid setter, that is, one which will
|
||||
|
@ -19,7 +19,7 @@ class RegisteredType {
|
||||
RegisteredType._(this.typeName, this.registerMethod, this.factoryFn,
|
||||
this.parameters, this.annotations);
|
||||
|
||||
/// Creates a [RegisteredType] given a [MethodInvocation] node representing
|
||||
/// Creates a {@link RegisteredType} given a {@link MethodInvocation} node representing
|
||||
/// a call to `registerType`.
|
||||
factory RegisteredType.fromMethodInvocation(MethodInvocation registerMethod) {
|
||||
var visitor = new _ParseRegisterTypeVisitor();
|
||||
|
@ -56,7 +56,7 @@ bool _isNotDartDirective(UriBasedDirective directive) {
|
||||
return !stringLiteralToString(directive.uri).startsWith('dart:');
|
||||
}
|
||||
|
||||
/// Maps each input [UriBasedDirective] to its associated `.ng_deps.dart`
|
||||
/// Maps each input {@link UriBasedDirective} to its associated `.ng_deps.dart`
|
||||
/// file, if it exists.
|
||||
Future<Map<UriBasedDirective, String>> _processNgImports(AssetReader reader,
|
||||
AssetId entryPoint, Iterable<UriBasedDirective> directives) {
|
||||
|
@ -11,7 +11,7 @@ import 'package:barback/barback.dart';
|
||||
import 'linker.dart';
|
||||
|
||||
/// Transformer responsible for processing .ng_deps.dart files created by
|
||||
/// [DirectiveProcessor] and ensuring that the generated calls to
|
||||
/// {@link DirectiveProcessor} and ensuring that the generated calls to
|
||||
/// `setupReflection` call the necessary `setupReflection` method in all
|
||||
/// dependencies.
|
||||
class DirectiveLinker extends Transformer {
|
||||
|
@ -19,7 +19,7 @@ import 'rewriter.dart';
|
||||
/// with @Component, @View, @Decorator, etc.
|
||||
///
|
||||
/// This transformer is the first phase in a two-phase transform. It should
|
||||
/// be followed by [DirectiveLinker].
|
||||
/// be followed by {@link DirectiveLinker}.
|
||||
class DirectiveProcessor extends Transformer {
|
||||
final TransformerOptions options;
|
||||
|
||||
|
@ -4,7 +4,7 @@ import 'package:analyzer/analyzer.dart';
|
||||
import 'package:analyzer/src/generated/java_core.dart';
|
||||
import 'package:angular2/src/transform/common/logging.dart';
|
||||
|
||||
/// `ToSourceVisitor` designed to accept [ConstructorDeclaration] nodes.
|
||||
/// `ToSourceVisitor` designed to accept {@link ConstructorDeclaration} nodes.
|
||||
class _CtorTransformVisitor extends ToSourceVisitor {
|
||||
bool _withParameterAnnotations = true;
|
||||
bool _withParameterTypes = true;
|
||||
@ -12,7 +12,7 @@ class _CtorTransformVisitor extends ToSourceVisitor {
|
||||
final PrintWriter writer;
|
||||
|
||||
/// Maps field names to their declared types. This is populated whenever
|
||||
/// the listener visits a [ConstructorDeclaration] node.
|
||||
/// the listener visits a {@link ConstructorDeclaration} node.
|
||||
final Map<String, TypeName> _fieldNameToType = {};
|
||||
|
||||
_CtorTransformVisitor(PrintWriter writer)
|
||||
@ -39,8 +39,8 @@ class _CtorTransformVisitor extends ToSourceVisitor {
|
||||
}
|
||||
}
|
||||
|
||||
/// If [_withParameterTypes] is true, this method outputs [node]'s type. If
|
||||
/// [_withParameterNames] is true, this method outputs [node]'s identifier.
|
||||
/// If `_withParameterTypes` is true, this method outputs `node`'s type. If
|
||||
/// `_withParameterNames` is true, this method outputs `node`'s identifier.
|
||||
Object _visitNormalFormalParameter(
|
||||
NodeList<Annotation> metadata, TypeName type, SimpleIdentifier name) {
|
||||
if (_withParameterAnnotations && metadata != null) {
|
||||
@ -144,7 +144,7 @@ class _CtorTransformVisitor extends ToSourceVisitor {
|
||||
}
|
||||
|
||||
/// ToSourceVisitor designed to print 'parameters' values for Angular2's
|
||||
/// [registerType] calls.
|
||||
/// `registerType` calls.
|
||||
class ParameterTransformVisitor extends _CtorTransformVisitor {
|
||||
ParameterTransformVisitor(PrintWriter writer) : super(writer) {
|
||||
_withParameterNames = false;
|
||||
@ -178,7 +178,7 @@ class ParameterTransformVisitor extends _CtorTransformVisitor {
|
||||
}
|
||||
|
||||
/// ToSourceVisitor designed to print 'factory' values for Angular2's
|
||||
/// [registerType] calls.
|
||||
/// `registerType` calls.
|
||||
class FactoryTransformVisitor extends _CtorTransformVisitor {
|
||||
FactoryTransformVisitor(PrintWriter writer) : super(writer) {
|
||||
_withParameterAnnotations = false;
|
||||
@ -200,8 +200,8 @@ class FactoryTransformVisitor extends _CtorTransformVisitor {
|
||||
}
|
||||
}
|
||||
|
||||
/// ToSourceVisitor designed to print a [ClassDeclaration] node as a
|
||||
/// 'annotations' value for Angular2's [registerType] calls.
|
||||
/// ToSourceVisitor designed to print a `ClassDeclaration` node as a
|
||||
/// 'annotations' value for Angular2's `registerType` calls.
|
||||
class AnnotationsTransformVisitor extends ToSourceVisitor {
|
||||
final PrintWriter writer;
|
||||
AnnotationsTransformVisitor(PrintWriter writer)
|
||||
|
@ -4,7 +4,7 @@ import 'package:analyzer/src/generated/ast.dart';
|
||||
import 'package:analyzer/src/generated/element.dart';
|
||||
import 'package:angular2/src/transform/common/names.dart';
|
||||
|
||||
/// An object that checks for [ReflectionCapabilities] syntactically, that is,
|
||||
/// An object that checks for {@link ReflectionCapabilities} syntactically, that is,
|
||||
/// without resolution information.
|
||||
class AstTester {
|
||||
const AstTester();
|
||||
@ -17,7 +17,7 @@ class AstTester {
|
||||
}
|
||||
}
|
||||
|
||||
/// An object that checks for [ReflectionCapabilities] using a fully resolved
|
||||
/// An object that checks for {@link ReflectionCapabilities} using a fully resolved
|
||||
/// Ast.
|
||||
class ResolvedTester implements AstTester {
|
||||
final ClassElement _forbiddenClass;
|
||||
|
@ -25,7 +25,7 @@ class Codegen {
|
||||
/// Angular2 reflection statically.
|
||||
///
|
||||
/// The code generated here should follow the example of code generated for
|
||||
/// an [ImportDirective] node.
|
||||
/// an {@link ImportDirective} node.
|
||||
String codegenImport() {
|
||||
var count = 0;
|
||||
return importUris
|
||||
@ -36,9 +36,9 @@ class Codegen {
|
||||
/// Generates code to call the method which sets up Angular2 reflection
|
||||
/// statically.
|
||||
///
|
||||
/// If [reflectorAssignment] is provided, it is expected to be the node
|
||||
/// representing the [ReflectionCapabilities] assignment, and we will
|
||||
/// attempt to parse the access of [reflector] from it so that [reflector] is
|
||||
/// If `reflectorAssignment` is provided, it is expected to be the node
|
||||
/// representing the {@link ReflectionCapabilities} assignment, and we will
|
||||
/// attempt to parse the access of `reflector` from it so that `reflector` is
|
||||
/// properly prefixed if necessary.
|
||||
String codegenSetupReflectionCall(
|
||||
{AssignmentExpression reflectorAssignment}) {
|
||||
@ -58,7 +58,7 @@ class Codegen {
|
||||
}
|
||||
}
|
||||
|
||||
/// A visitor whose job it is to find the access of [reflector].
|
||||
/// A visitor whose job it is to find the access of `reflector`.
|
||||
class _ReflectorVisitor extends Object with SimpleAstVisitor<Expression> {
|
||||
@override
|
||||
Expression visitAssignmentExpression(AssignmentExpression node) {
|
||||
|
@ -9,10 +9,10 @@ import 'codegen.dart';
|
||||
import 'rewriter.dart';
|
||||
|
||||
/// Finds the call to the Angular2 `ReflectionCapabilities` constructor
|
||||
/// in [reflectionEntryPoint] and replaces it with a call to
|
||||
/// `setupReflection` in [newEntryPoint].
|
||||
/// in `reflectionEntryPoint` and replaces it with a call to
|
||||
/// `setupReflection` in `newEntryPoint`.
|
||||
///
|
||||
/// This only searches the code in [reflectionEntryPoint], not `part`s,
|
||||
/// This only searches the code in `reflectionEntryPoint`, not `part`s,
|
||||
/// `import`s, `export`s, etc.
|
||||
Future<String> removeReflectionCapabilities(AssetReader reader,
|
||||
AssetId reflectionEntryPoint, Iterable<AssetId> newEntryPoints) async {
|
||||
|
@ -16,9 +16,9 @@ class Rewriter {
|
||||
: _tester = tester == null ? const AstTester() : tester;
|
||||
|
||||
/// Rewrites the provided code removing imports of the
|
||||
/// [ReflectionCapabilities] library and instantiations of
|
||||
/// [ReflectionCapabilities], as detected by the (potentially) provided
|
||||
/// [AstTester].
|
||||
/// {@link ReflectionCapabilities} library and instantiations of
|
||||
/// {@link ReflectionCapabilities}, as detected by the (potentially) provided
|
||||
/// {@link AstTester}.
|
||||
///
|
||||
/// To the extent possible, this method does not change line numbers or
|
||||
/// offsets in the provided code to facilitate debugging via source maps.
|
||||
@ -86,7 +86,7 @@ class Rewriter {
|
||||
}
|
||||
|
||||
/// Visitor responsible for rewriting the Angular 2 code which instantiates
|
||||
/// [ReflectionCapabilities] and removing its associated import.
|
||||
/// {@link ReflectionCapabilities} and removing its associated import.
|
||||
///
|
||||
/// This breaks our dependency on dart:mirrors, which enables smaller code
|
||||
/// size and better performance.
|
||||
|
@ -10,13 +10,13 @@ import 'package:barback/barback.dart';
|
||||
import 'remove_reflection_capabilities.dart';
|
||||
|
||||
/// Transformer responsible for removing the import and instantiation of
|
||||
/// [ReflectionCapabilities].
|
||||
/// {@link ReflectionCapabilities}.
|
||||
///
|
||||
/// The goal of this is to break the app's dependency on dart:mirrors.
|
||||
///
|
||||
/// This transformer assumes that [DirectiveProcessor] and [DirectiveLinker]
|
||||
/// This transformer assumes that {@link DirectiveProcessor} and {@link DirectiveLinker}
|
||||
/// have already been run and that a .ng_deps.dart file has been generated for
|
||||
/// [options.entryPoint]. The instantiation of [ReflectionCapabilities] is
|
||||
/// {@link options.entryPoint}. The instantiation of {@link ReflectionCapabilities} is
|
||||
/// replaced by calling `setupReflection` in that .ng_deps.dart file.
|
||||
class ReflectionRemover extends Transformer {
|
||||
final TransformerOptions options;
|
||||
|
@ -26,7 +26,7 @@ import 'recording_reflection_capabilities.dart';
|
||||
/// Angular 2 `View` annotations it declares to generate `getter`s,
|
||||
/// `setter`s, and `method`s that would otherwise be reflectively accessed.
|
||||
///
|
||||
/// This method assumes a [DomAdapter] has been registered.
|
||||
/// This method assumes a {@link DomAdapter} has been registered.
|
||||
Future<String> processTemplates(AssetReader reader, AssetId entryPoint) async {
|
||||
var parser = new Parser(reader);
|
||||
NgDeps ngDeps = await parser.parse(entryPoint);
|
||||
@ -163,7 +163,7 @@ class _TemplateExtractor {
|
||||
}
|
||||
|
||||
/// Visitor responsible for processing the `annotations` property of a
|
||||
/// [RegisterType] object and pulling out template text.
|
||||
/// {@link RegisterType} object and pulling out template text.
|
||||
class _TemplateExtractVisitor extends Object with RecursiveAstVisitor<Object> {
|
||||
final List<String> inlineValues = [];
|
||||
final List<String> urlValues = [];
|
||||
|
@ -12,9 +12,9 @@ import 'package:barback/barback.dart';
|
||||
|
||||
import 'generator.dart';
|
||||
|
||||
/// [Transformer] responsible for detecting and processing Angular 2 templates.
|
||||
/// {@link Transformer} responsible for detecting and processing Angular 2 templates.
|
||||
///
|
||||
/// [TemplateCompiler] uses the Angular 2 `Compiler` to process the templates,
|
||||
/// {@link TemplateCompiler} uses the Angular 2 `Compiler` to process the templates,
|
||||
/// extracting information about what reflection is necessary to render and
|
||||
/// use that template. It then generates code in place of those reflective
|
||||
/// accesses.
|
||||
|
Reference in New Issue
Block a user