Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Unified Diff: third_party/pkg/angular/lib/tools/source_metadata_extractor.dart

Issue 180843004: Revert revision 33053 (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/pkg/angular/lib/tools/source_metadata_extractor.dart
===================================================================
--- third_party/pkg/angular/lib/tools/source_metadata_extractor.dart (revision 33054)
+++ third_party/pkg/angular/lib/tools/source_metadata_extractor.dart (working copy)
@@ -4,6 +4,7 @@
import 'package:angular/tools/source_crawler.dart';
import 'package:angular/tools/common.dart';
+import 'package:angular/utils.dart';
const String _COMPONENT = '-component';
const String _DIRECTIVE = '-directive';
@@ -19,15 +20,16 @@
};
class SourceMetadataExtractor {
+ SourceCrawler sourceCrawler;
DirectiveMetadataCollectingVisitor metadataVisitor;
- SourceMetadataExtractor([ this.metadataVisitor ]) {
+ SourceMetadataExtractor(this.sourceCrawler, [ this.metadataVisitor ]) {
if (metadataVisitor == null) {
metadataVisitor = new DirectiveMetadataCollectingVisitor();
}
}
- List<DirectiveInfo> gatherDirectiveInfo(root, SourceCrawler sourceCrawler) {
+ List<DirectiveInfo> gatherDirectiveInfo(root) {
sourceCrawler.crawl(root, metadataVisitor);
List<DirectiveInfo> directives = <DirectiveInfo>[];
@@ -40,13 +42,13 @@
.firstWhere((specPrefix) => mappingSpec.startsWith(specPrefix),
orElse: () => throw '$mappingSpec no matching spec');
if (spec != '@') {
- dirInfo.expressionAttrs.add(attrName);
+ dirInfo.expressionAttrs.add(snakecase(attrName));
}
if (mappingSpec.length == 1) { // Shorthand. Remove.
// TODO(pavelgj): Figure out if short-hand LHS should be expanded
// and added to the expressions list.
if (attrName != '.') {
- dirInfo.expressions.add(attrName);
+ dirInfo.expressions.add(_maybeCamelCase(attrName));
}
} else {
mappingSpec = mappingSpec.substring(spec.length);
@@ -58,6 +60,7 @@
});
meta.exportExpressionAttrs.forEach((attr) {
+ attr = snakecase(attr);
if (!dirInfo.expressionAttrs.contains(attr)) {
dirInfo.expressionAttrs.add(attr);
}
@@ -71,7 +74,7 @@
// No explicit selector specified on the directive, compute one.
- var className = meta.className;
+ var className = snakecase(meta.className);
if (dirInfo.selector == null) {
if (meta.type == COMPONENT) {
if (className.endsWith(_COMPONENT)) {
@@ -90,7 +93,8 @@
dirInfo.selector = className.
substring(0, className.length - _DIRECTIVE.length);
} else {
- throw "Directive name '$className' must have a \$selector field.";
+ throw "Directive name '$className' must end with $_DIRECTIVE, "
+ "$_ATTR_DIRECTIVE, $_COMPONENT or have a \$selector field.";
}
}
}
@@ -114,6 +118,8 @@
}
}
+String _maybeCamelCase(String s) => (s.indexOf('-') > -1) ? camelcase(s) : s;
+
class DirectiveMetadataCollectingVisitor {
List<DirectiveMetadata> metadata = <DirectiveMetadata>[];
« no previous file with comments | « third_party/pkg/angular/lib/tools/selector.dart ('k') | third_party/pkg/angular/lib/tools/template_cache_generator.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698