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

Side by Side Diff: pkg/observe/lib/transformer.dart

Issue 186153005: New analzyer snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use meaningful name instead of '_' in predicate. Created 6 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/intl/pubspec.yaml ('k') | pkg/observe/pubspec.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /// Code transform for @observable. The core transformation is relatively 5 /// Code transform for @observable. The core transformation is relatively
6 /// straightforward, and essentially like an editor refactoring. 6 /// straightforward, and essentially like an editor refactoring.
7 library observe.transformer; 7 library observe.transformer;
8 8
9 import 'dart:async'; 9 import 'dart:async';
10 10
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 var token = scanner.tokenize(); 116 var token = scanner.tokenize();
117 var parser = new Parser(null, errorListener); 117 var parser = new Parser(null, errorListener);
118 return parser.parseCompilationUnit(token); 118 return parser.parseCompilationUnit(token);
119 } 119 }
120 120
121 class _ErrorCollector extends AnalysisErrorListener { 121 class _ErrorCollector extends AnalysisErrorListener {
122 final errors = <AnalysisError>[]; 122 final errors = <AnalysisError>[];
123 onError(error) => errors.add(error); 123 onError(error) => errors.add(error);
124 } 124 }
125 125
126 _getSpan(SourceFile file, ASTNode node) => file.span(node.offset, node.end); 126 _getSpan(SourceFile file, AstNode node) => file.span(node.offset, node.end);
127 127
128 /// True if the node has the `@observable` or `@published` annotation. 128 /// True if the node has the `@observable` or `@published` annotation.
129 // TODO(jmesserly): it is not good to be hard coding Polymer support here. 129 // TODO(jmesserly): it is not good to be hard coding Polymer support here.
130 bool _hasObservable(AnnotatedNode node) => 130 bool _hasObservable(AnnotatedNode node) =>
131 node.metadata.any(_isObservableAnnotation); 131 node.metadata.any(_isObservableAnnotation);
132 132
133 // TODO(jmesserly): this isn't correct if the annotation has been imported 133 // TODO(jmesserly): this isn't correct if the annotation has been imported
134 // with a prefix, or cases like that. We should technically be resolving, but 134 // with a prefix, or cases like that. We should technically be resolving, but
135 // that is expensive in analyzer, so it isn't feasible yet. 135 // that is expensive in analyzer, so it isn't feasible yet.
136 bool _isObservableAnnotation(Annotation node) => 136 bool _isObservableAnnotation(Annotation node) =>
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 } 275 }
276 } 276 }
277 277
278 SimpleIdentifier _getSimpleIdentifier(Identifier id) => 278 SimpleIdentifier _getSimpleIdentifier(Identifier id) =>
279 id is PrefixedIdentifier ? id.identifier : id; 279 id is PrefixedIdentifier ? id.identifier : id;
280 280
281 281
282 bool _hasKeyword(Token token, Keyword keyword) => 282 bool _hasKeyword(Token token, Keyword keyword) =>
283 token is KeywordToken && token.keyword == keyword; 283 token is KeywordToken && token.keyword == keyword;
284 284
285 String _getOriginalCode(TextEditTransaction code, ASTNode node) => 285 String _getOriginalCode(TextEditTransaction code, AstNode node) =>
286 code.original.substring(node.offset, node.end); 286 code.original.substring(node.offset, node.end);
287 287
288 void _fixConstructor(ConstructorDeclaration ctor, TextEditTransaction code, 288 void _fixConstructor(ConstructorDeclaration ctor, TextEditTransaction code,
289 Set<String> changedFields) { 289 Set<String> changedFields) {
290 290
291 // Fix normal initializers 291 // Fix normal initializers
292 for (var initializer in ctor.initializers) { 292 for (var initializer in ctor.initializers) {
293 if (initializer is ConstructorFieldInitializer) { 293 if (initializer is ConstructorFieldInitializer) {
294 var field = initializer.fieldName; 294 var field = initializer.fieldName;
295 if (changedFields.contains(field.name)) { 295 if (changedFields.contains(field.name)) {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 426
427 Token _findFieldSeperator(Token token) { 427 Token _findFieldSeperator(Token token) {
428 while (token != null) { 428 while (token != null) {
429 if (token.type == TokenType.COMMA || token.type == TokenType.SEMICOLON) { 429 if (token.type == TokenType.COMMA || token.type == TokenType.SEMICOLON) {
430 break; 430 break;
431 } 431 }
432 token = token.next; 432 token = token.next;
433 } 433 }
434 return token; 434 return token;
435 } 435 }
OLDNEW
« no previous file with comments | « pkg/intl/pubspec.yaml ('k') | pkg/observe/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698