Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
922da62 chore(browser_tree): fix formatting
- Loading branch information
1 parent
e70c4f3
commit 760fc7a
Showing
22 changed files
with
770 additions
and
452 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
Tue Dec 1 21:54:43 UTC 2015 | ||
3e364b0d41154e637cbcea12f929e578781a61af | ||
Tue Dec 1 21:58:14 UTC 2015 | ||
922da62720599f003f4b04edeeca478429407b01 |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
library angular2.src.core.angular_entrypoint; | ||
|
||
/** | ||
* Marks a function or method as an Angular 2 entrypoint. Only necessary in Dart code. | ||
* | ||
* The optional `name` parameter will be reflected in logs when the entry point is processed. | ||
* | ||
* See [the wiki][] for detailed documentation. | ||
* [the wiki]: https://github.com/angular/angular/wiki/Angular-2-Dart-Transformer#entry_points | ||
* | ||
* ## Example | ||
* | ||
* ``` | ||
* @AngularEntrypoint("name-for-debug") | ||
* void main() { | ||
* bootstrap(MyComponent); | ||
* } | ||
*/ | ||
class AngularEntrypoint { | ||
final String name; | ||
const AngularEntrypoint([this.name]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
lib/src/transform/reflection_remover/entrypoint_matcher.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
library angular2.transform.reflection_remover.entrypoint_matcher; | ||
|
||
import 'package:analyzer/analyzer.dart'; | ||
import 'package:barback/barback.dart'; | ||
|
||
import 'package:angular2/src/transform/common/annotation_matcher.dart'; | ||
import 'package:angular2/src/transform/common/naive_eval.dart'; | ||
|
||
/// Determines if a [FunctionDeclaration] or [MethodDeclaration] is an | ||
/// `AngularEntrypoint`. | ||
class EntrypointMatcher { | ||
final AssetId _assetId; | ||
final AnnotationMatcher _annotationMatcher; | ||
|
||
EntrypointMatcher(this._assetId, this._annotationMatcher) { | ||
if (_assetId == null) { | ||
throw new ArgumentError.notNull('AssetId'); | ||
} | ||
if (_annotationMatcher == null) { | ||
throw new ArgumentError.notNull('AnnotationMatcher'); | ||
} | ||
} | ||
|
||
bool isEntrypoint(AnnotatedNode node) { | ||
if (node == null || | ||
(node is! FunctionDeclaration && node is! MethodDeclaration)) { | ||
return false; | ||
} | ||
return node.metadata | ||
.any((a) => _annotationMatcher.isEntrypoint(a, _assetId)); | ||
} | ||
|
||
/// Gets the name assigned to the `AngularEntrypoint`. | ||
/// | ||
/// This method assumes the name is the first argument to `AngularEntrypoint`; | ||
String getName(AnnotatedNode node) { | ||
final annotation = node.metadata.firstWhere( | ||
(a) => _annotationMatcher.isEntrypoint(a, _assetId), | ||
orElse: () => null); | ||
if (annotation == null) return null; | ||
if (annotation.arguments == null || | ||
annotation.arguments.arguments == null || | ||
annotation.arguments.arguments.isEmpty) { | ||
return _defaultEntrypointName; | ||
} | ||
final entryPointName = naiveEval(annotation.arguments.arguments.first); | ||
if (entryPointName == NOT_A_CONSTANT) { | ||
throw new ArgumentError( | ||
'Could not evaluate "${node}" as parameter to @AngularEntrypoint'); | ||
} | ||
if (entryPointName is! String) { | ||
throw new ArgumentError('Unexpected type "${entryPointName.runtimeType}" ' | ||
'as first parameter to @AngularEntrypoint'); | ||
} | ||
return entryPointName; | ||
} | ||
} | ||
|
||
const _defaultEntrypointName = "(no name provided)"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
test/transform/reflection_remover/abstract_method_annotation_files/index.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
library web_foo; | ||
|
||
import 'package:angular2/bootstrap.dart'; | ||
|
||
abstract class TestBootstrapper { | ||
@AngularEntrypoint() | ||
void testBootstrap(); | ||
} |
Oops, something went wrong.