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

Unified Diff: pkg/observe/lib/transformer.dart

Issue 335943003: merge to trunk all changes from 36817 until 37378 under the packages: polymer, (Closed) Base URL: http://dart.googlecode.com/svn/trunk/dart/
Patch Set: Created 6 years, 6 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
« no previous file with comments | « pkg/observe/lib/src/path_observer.dart ('k') | pkg/observe/pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/observe/lib/transformer.dart
===================================================================
--- pkg/observe/lib/transformer.dart (revision 37373)
+++ pkg/observe/lib/transformer.dart (working copy)
@@ -8,6 +8,7 @@
import 'dart:async';
+import 'package:analyzer/analyzer.dart';
import 'package:analyzer/src/generated/ast.dart';
import 'package:analyzer/src/generated/error.dart';
import 'package:analyzer/src/generated/parser.dart';
@@ -84,7 +85,7 @@
TextEditTransaction _transformCompilationUnit(
String inputCode, SourceFile sourceFile, TransformLogger logger) {
- var unit = _parseCompilationUnit(inputCode);
+ var unit = parseCompilationUnit(inputCode, suppressErrors: true);
var code = new TextEditTransaction(inputCode, sourceFile);
for (var directive in unit.directives) {
if (directive is LibraryDirective && _hasObservable(directive)) {
@@ -109,21 +110,6 @@
return code;
}
-/// Parse [code] using analyzer.
-CompilationUnit _parseCompilationUnit(String code) {
- var errorListener = new _ErrorCollector();
- var reader = new CharSequenceReader(code);
- var scanner = new Scanner(null, reader, errorListener);
- var token = scanner.tokenize();
- var parser = new Parser(null, errorListener);
- return parser.parseCompilationUnit(token);
-}
-
-class _ErrorCollector extends AnalysisErrorListener {
- final errors = <AnalysisError>[];
- onError(error) => errors.add(error);
-}
-
_getSpan(SourceFile file, AstNode node) => file.span(node.offset, node.end);
/// True if the node has the `@observable` or `@published` annotation.
@@ -143,7 +129,7 @@
bool _isAnnotationContant(Annotation m, String name) =>
m.name.name == name && m.constructorName == null && m.arguments == null;
-bool _isAnnotationType(Annotation m, String name) => m.name == name;
+bool _isAnnotationType(Annotation m, String name) => m.name.name == name;
void _transformClass(ClassDeclaration cls, TextEditTransaction code,
SourceFile file, TransformLogger logger) {
« no previous file with comments | « pkg/observe/lib/src/path_observer.dart ('k') | pkg/observe/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698