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

Side by Side Diff: pkg/analyzer/lib/src/generated/engine.dart

Issue 753803002: Use a poor man's incremental parser to perform incremental resolution. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixes for review comments. Created 6 years 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 | « no previous file | pkg/analyzer/lib/src/generated/incremental_resolver.dart » ('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 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine; 8 library engine;
9 9
10 import "dart:math" as math; 10 import "dart:math" as math;
11 import 'dart:async'; 11 import 'dart:async';
12 import 'dart:collection'; 12 import 'dart:collection';
13 13
14 import 'package:analyzer/src/task/task_dart.dart'; 14 import 'package:analyzer/src/task/task_dart.dart';
15 15
16 import 'ast.dart'; 16 import 'ast.dart';
17 import 'constant.dart'; 17 import 'constant.dart';
18 import 'element.dart'; 18 import 'element.dart';
19 import 'error.dart'; 19 import 'error.dart';
20 import 'error_verifier.dart'; 20 import 'error_verifier.dart';
21 import 'html.dart' as ht; 21 import 'html.dart' as ht;
22 import 'incremental_scanner.dart'; 22 import 'incremental_scanner.dart';
23 import 'incremental_resolver.dart' show IncrementalResolver; 23 import 'incremental_resolver.dart' show IncrementalResolver,
24 poorMansIncrementalResolution;
24 import 'instrumentation.dart'; 25 import 'instrumentation.dart';
25 import 'java_core.dart'; 26 import 'java_core.dart';
26 import 'java_engine.dart'; 27 import 'java_engine.dart';
27 import 'parser.dart' show Parser, IncrementalParser; 28 import 'parser.dart' show Parser, IncrementalParser;
28 import 'resolver.dart'; 29 import 'resolver.dart';
29 import 'scanner.dart'; 30 import 'scanner.dart';
30 import 'sdk.dart' show DartSdk; 31 import 'sdk.dart' show DartSdk;
31 import 'source.dart'; 32 import 'source.dart';
32 import 'utilities_collection.dart'; 33 import 'utilities_collection.dart';
33 import 'utilities_general.dart'; 34 import 'utilities_general.dart';
(...skipping 2877 matching lines...) Expand 10 before | Expand all | Expand 10 after
2911 * @param source the source whose contents are being overridden 2912 * @param source the source whose contents are being overridden
2912 * @param contents the new contents of the source 2913 * @param contents the new contents of the source
2913 */ 2914 */
2914 bool _contentsChanged(Source source, String contents) { 2915 bool _contentsChanged(Source source, String contents) {
2915 bool changed = false; 2916 bool changed = false;
2916 String originalContents = _contentCache.setContents(source, contents); 2917 String originalContents = _contentCache.setContents(source, contents);
2917 if (contents != null) { 2918 if (contents != null) {
2918 if (contents != originalContents) { 2919 if (contents != originalContents) {
2919 _incrementalAnalysisCache = 2920 _incrementalAnalysisCache =
2920 IncrementalAnalysisCache.clear(_incrementalAnalysisCache, source); 2921 IncrementalAnalysisCache.clear(_incrementalAnalysisCache, source);
2921 _sourceChanged(source); 2922 if (!analysisOptions.incremental ||
2923 !_tryPoorMansIncrementalResolution(source, contents)) {
2924 _sourceChanged(source);
2925 }
2922 changed = true; 2926 changed = true;
2923 SourceEntry sourceEntry = _cache.get(source); 2927 SourceEntry sourceEntry = _cache.get(source);
2924 if (sourceEntry != null) { 2928 if (sourceEntry != null) {
2925 sourceEntry.modificationTime = 2929 sourceEntry.modificationTime =
2926 _contentCache.getModificationStamp(source); 2930 _contentCache.getModificationStamp(source);
2927 sourceEntry.setValue(SourceEntry.CONTENT, contents); 2931 sourceEntry.setValue(SourceEntry.CONTENT, contents);
2928 } 2932 }
2929 } 2933 }
2930 } else if (originalContents != null) { 2934 } else if (originalContents != null) {
2931 _incrementalAnalysisCache = 2935 _incrementalAnalysisCache =
(...skipping 1983 matching lines...) Expand 10 before | Expand all | Expand 10 after
4915 dartEntry.recordContentError( 4919 dartEntry.recordContentError(
4916 new CaughtException( 4920 new CaughtException(
4917 new AnalysisException("This source was marked as being deleted"), 4921 new AnalysisException("This source was marked as being deleted"),
4918 null)); 4922 null));
4919 } 4923 }
4920 _workManager.remove(source); 4924 _workManager.remove(source);
4921 _removeFromPriorityOrder(source); 4925 _removeFromPriorityOrder(source);
4922 } 4926 }
4923 4927
4924 /** 4928 /**
4929 * TODO(scheglov) A hackish, limited incremental resolution implementation.
4930 */
4931 bool _tryPoorMansIncrementalResolution(Source unitSource, String newCode) {
4932 List<Source> librarySources = getLibrariesContaining(unitSource);
4933 if (librarySources.length != 1) {
4934 return false;
4935 }
4936 CompilationUnit oldUnit =
4937 getResolvedCompilationUnit2(unitSource, librarySources[0]);
4938 bool success = poorMansIncrementalResolution(typeProvider, oldUnit, newCode) ;
4939 if (!success) {
4940 return false;
4941 }
4942 ChangeNoticeImpl notice = _getNotice(unitSource);
4943 notice.compilationUnit = oldUnit;
4944 // TODO(scheglov) apply updated errors
4945 {
4946 LineInfo lineInfo = getLineInfo(unitSource);
4947 DartEntry dartEntry = _cache.get(unitSource);
4948 notice.setErrors(dartEntry.allErrors, lineInfo);
4949 }
4950 return true;
4951 }
4952
4953 /**
4925 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock]. 4954 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
4926 * 4955 *
4927 * @param source the source that has been removed 4956 * @param source the source that has been removed
4928 */ 4957 */
4929 void _sourceRemoved(Source source) { 4958 void _sourceRemoved(Source source) {
4930 SourceEntry sourceEntry = _cache.get(source); 4959 SourceEntry sourceEntry = _cache.get(source);
4931 if (sourceEntry is HtmlEntry) { 4960 if (sourceEntry is HtmlEntry) {
4932 _invalidateAngularResolution(sourceEntry); 4961 _invalidateAngularResolution(sourceEntry);
4933 } else if (sourceEntry is DartEntry) { 4962 } else if (sourceEntry is DartEntry) {
4934 HashSet<Source> libraries = new HashSet<Source>(); 4963 HashSet<Source> libraries = new HashSet<Source>();
(...skipping 9898 matching lines...) Expand 10 before | Expand all | Expand 10 after
14833 14862
14834 @override 14863 @override
14835 Object visitPolymerTagDartElement(PolymerTagDartElement element) { 14864 Object visitPolymerTagDartElement(PolymerTagDartElement element) {
14836 if (element.name == PolymerHtmlUnitBuilder_this._elementName) { 14865 if (element.name == PolymerHtmlUnitBuilder_this._elementName) {
14837 throw new PolymerHtmlUnitBuilder_FoundTagDartElementError( 14866 throw new PolymerHtmlUnitBuilder_FoundTagDartElementError(
14838 element as PolymerTagDartElementImpl); 14867 element as PolymerTagDartElementImpl);
14839 } 14868 }
14840 return null; 14869 return null;
14841 } 14870 }
14842 } 14871 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/incremental_resolver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698