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

Side by Side Diff: pkg/code_transformers/lib/src/resolver_impl.dart

Issue 204033003: Updating code_transformers to not fail on syntax errors (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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/code_transformers/lib/src/entry_point.dart ('k') | pkg/code_transformers/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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library code_transformer.src.resolver_impl; 5 library code_transformer.src.resolver_impl;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'package:analyzer/analyzer.dart' show parseCompilationUnit; 8 import 'package:analyzer/analyzer.dart' show parseCompilationUnit;
9 import 'package:analyzer/src/generated/ast.dart'; 9 import 'package:analyzer/src/generated/ast.dart';
10 import 'package:analyzer/src/generated/element.dart'; 10 import 'package:analyzer/src/generated/element.dart';
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 282
283 /// The file contents. 283 /// The file contents.
284 String _contents; 284 String _contents;
285 285
286 _AssetBasedSource(this.assetId, this._resolver); 286 _AssetBasedSource(this.assetId, this._resolver);
287 287
288 /// Update the dependencies of this source. This parses [contents] but avoids 288 /// Update the dependencies of this source. This parses [contents] but avoids
289 /// any analyzer resolution. 289 /// any analyzer resolution.
290 void updateDependencies(String contents) { 290 void updateDependencies(String contents) {
291 if (contents == _contents) return; 291 if (contents == _contents) return;
292 var unit = parseCompilationUnit(contents); 292 var unit = parseCompilationUnit(contents, suppressErrors: true);
293 _dependentAssets = unit.directives 293 _dependentAssets = unit.directives
294 .where((d) => (d is ImportDirective || d is PartDirective || 294 .where((d) => (d is ImportDirective || d is PartDirective ||
295 d is ExportDirective)) 295 d is ExportDirective))
296 .map((d) => _resolve(assetId, d.uri.stringValue, _logger, 296 .map((d) => _resolve(assetId, d.uri.stringValue, _logger,
297 _getSpan(d, contents))) 297 _getSpan(d, contents)))
298 .where((id) => id != null).toSet(); 298 .where((id) => id != null).toSet();
299 } 299 }
300 300
301 /// Update the contents of this file with [contents]. 301 /// Update the contents of this file with [contents].
302 /// 302 ///
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 586
587 void apply(ChangeSet changeSet) { 587 void apply(ChangeSet changeSet) {
588 if (!source.updateContents(content)) return; 588 if (!source.updateContents(content)) return;
589 if (source._revision == 1 && source._contents != null) { 589 if (source._revision == 1 && source._contents != null) {
590 changeSet.addedSource(source); 590 changeSet.addedSource(source);
591 } else { 591 } else {
592 changeSet.changedSource(source); 592 changeSet.changedSource(source);
593 } 593 }
594 } 594 }
595 } 595 }
OLDNEW
« no previous file with comments | « pkg/code_transformers/lib/src/entry_point.dart ('k') | pkg/code_transformers/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698