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

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

Issue 901713004: Invalidate hints instead of computing them in the incremental resolver. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Invalidate hints for included parts too Created 5 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 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;
(...skipping 2235 matching lines...) Expand 10 before | Expand all | Expand 10 after
2246 _sourceChanged(source); 2246 _sourceChanged(source);
2247 } 2247 }
2248 } 2248 }
2249 if (notify && changed) { 2249 if (notify && changed) {
2250 _onSourcesChangedController.add( 2250 _onSourcesChangedController.add(
2251 new SourcesChangedEvent.changedContent(source, newContents)); 2251 new SourcesChangedEvent.changedContent(source, newContents));
2252 } 2252 }
2253 return changed; 2253 return changed;
2254 } 2254 }
2255 2255
2256 /**
2257 * Invalidates hints in the given [librarySource] and included parts.
2258 */
2259 void invalidateLibraryHints(Source librarySource) {
2260 SourceEntry sourceEntry = _cache.get(librarySource);
2261 if (sourceEntry is! DartEntry) {
2262 return;
2263 }
2264 DartEntry dartEntry = sourceEntry;
2265 // Prepare sources to invalidate hints in.
2266 List<Source> sources = <Source>[librarySource];
2267 sources.addAll(dartEntry.getValue(DartEntry.INCLUDED_PARTS));
2268 // Invalidate hints.
2269 for (Source source in sources) {
2270 DartEntry dartEntry = _cache.get(source);
2271 if (dartEntry.getStateInLibrary(DartEntry.HINTS, librarySource) ==
2272 CacheState.VALID) {
2273 dartEntry.setStateInLibrary(
2274 DartEntry.HINTS,
2275 librarySource,
2276 CacheState.INVALID);
2277 }
2278 }
2279 }
2280
2256 @override 2281 @override
2257 bool isClientLibrary(Source librarySource) { 2282 bool isClientLibrary(Source librarySource) {
2258 SourceEntry sourceEntry = _getReadableSourceEntry(librarySource); 2283 SourceEntry sourceEntry = _getReadableSourceEntry(librarySource);
2259 if (sourceEntry is DartEntry) { 2284 if (sourceEntry is DartEntry) {
2260 DartEntry dartEntry = sourceEntry; 2285 DartEntry dartEntry = sourceEntry;
2261 return dartEntry.getValue(DartEntry.IS_CLIENT) && 2286 return dartEntry.getValue(DartEntry.IS_CLIENT) &&
2262 dartEntry.getValue(DartEntry.IS_LAUNCHABLE); 2287 dartEntry.getValue(DartEntry.IS_LAUNCHABLE);
2263 } 2288 }
2264 return false; 2289 return false;
2265 } 2290 }
(...skipping 2797 matching lines...) Expand 10 before | Expand all | Expand 10 after
5063 List<Source> librarySources = getLibrariesContaining(unitSource); 5088 List<Source> librarySources = getLibrariesContaining(unitSource);
5064 if (librarySources.length != 1) { 5089 if (librarySources.length != 1) {
5065 return false; 5090 return false;
5066 } 5091 }
5067 Source librarySource = librarySources[0]; 5092 Source librarySource = librarySources[0];
5068 // prepare the library element 5093 // prepare the library element
5069 LibraryElement libraryElement = getLibraryElement(librarySource); 5094 LibraryElement libraryElement = getLibraryElement(librarySource);
5070 if (libraryElement == null) { 5095 if (libraryElement == null) {
5071 return false; 5096 return false;
5072 } 5097 }
5073 // prepare the existing library units
5074 Map<Source, CompilationUnit> units = <Source, CompilationUnit>{};
5075 for (CompilationUnitElement unitElement in libraryElement.units) {
5076 Source unitSource = unitElement.source;
5077 CompilationUnit unit =
5078 getResolvedCompilationUnit2(unitSource, librarySource);
5079 if (unit == null) {
5080 return false;
5081 }
5082 units[unitSource] = unit;
5083 }
5084 // prepare the existing unit 5098 // prepare the existing unit
5085 CompilationUnit oldUnit = units[unitSource]; 5099 CompilationUnit oldUnit =
5100 getResolvedCompilationUnit2(unitSource, librarySource);
5086 if (oldUnit == null) { 5101 if (oldUnit == null) {
5087 return false; 5102 return false;
5088 } 5103 }
5089 // do resolution 5104 // do resolution
5090 Stopwatch perfCounter = new Stopwatch()..start(); 5105 Stopwatch perfCounter = new Stopwatch()..start();
5091 PoorMansIncrementalResolver resolver = new PoorMansIncrementalResolver( 5106 PoorMansIncrementalResolver resolver = new PoorMansIncrementalResolver(
5092 typeProvider, 5107 typeProvider,
5093 units,
5094 unitSource, 5108 unitSource,
5095 dartEntry, 5109 dartEntry,
5110 oldUnit,
5096 analysisOptions.incrementalApi); 5111 analysisOptions.incrementalApi);
5097 bool success = resolver.resolve(newCode); 5112 bool success = resolver.resolve(newCode);
5098 AnalysisEngine.instance.instrumentationService.logPerformance( 5113 AnalysisEngine.instance.instrumentationService.logPerformance(
5099 AnalysisPerformanceKind.INCREMENTAL, 5114 AnalysisPerformanceKind.INCREMENTAL,
5100 perfCounter, 5115 perfCounter,
5101 'success=$success,context_id=$_id,code_length=${newCode.length}'); 5116 'success=$success,context_id=$_id,code_length=${newCode.length}');
5102 if (!success) { 5117 if (!success) {
5103 return false; 5118 return false;
5104 } 5119 }
5105 // if validation, remember the result, but throw it away 5120 // if validation, remember the result, but throw it away
5106 if (analysisOptions.incrementalValidation) { 5121 if (analysisOptions.incrementalValidation) {
5107 incrementalResolutionValidation_lastUnitSource = oldUnit.element.source; 5122 incrementalResolutionValidation_lastUnitSource = oldUnit.element.source;
5108 incrementalResolutionValidation_lastLibrarySource = 5123 incrementalResolutionValidation_lastLibrarySource =
5109 oldUnit.element.library.source; 5124 oldUnit.element.library.source;
5110 incrementalResolutionValidation_lastUnit = oldUnit; 5125 incrementalResolutionValidation_lastUnit = oldUnit;
5111 return false; 5126 return false;
5112 } 5127 }
5113 // prepare notices 5128 // prepare notice
5114 units.forEach((Source source, CompilationUnit unit) { 5129 {
5115 DartEntry dartEntry = _cache.get(source); 5130 LineInfo lineInfo = getLineInfo(unitSource);
5116 LineInfo lineInfo = getLineInfo(source); 5131 ChangeNoticeImpl notice = _getNotice(unitSource);
5117 ChangeNoticeImpl notice = _getNotice(source); 5132 notice.resolvedDartUnit = oldUnit;
5118 notice.resolvedDartUnit = unit;
5119 notice.setErrors(dartEntry.allErrors, lineInfo); 5133 notice.setErrors(dartEntry.allErrors, lineInfo);
5120 }); 5134 }
5121 // OK 5135 // OK
5122 return true; 5136 return true;
5123 } 5137 }
5124 5138
5125 /** 5139 /**
5126 * Check the cache for any invalid entries (entries whose modification time do es not match the 5140 * Check the cache for any invalid entries (entries whose modification time do es not match the
5127 * modification time of the source associated with the entry). Invalid entries will be marked as 5141 * modification time of the source associated with the entry). Invalid entries will be marked as
5128 * invalid so that the source will be re-analyzed. 5142 * invalid so that the source will be re-analyzed.
5129 * 5143 *
5130 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock]. 5144 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
(...skipping 4502 matching lines...) Expand 10 before | Expand all | Expand 10 after
9633 cache.offset, 9647 cache.offset,
9634 cache.offset + cache.oldLength); 9648 cache.offset + cache.oldLength);
9635 // Update the resolution 9649 // Update the resolution
9636 TypeProvider typeProvider = this.typeProvider; 9650 TypeProvider typeProvider = this.typeProvider;
9637 if (_updatedUnit != null && typeProvider != null) { 9651 if (_updatedUnit != null && typeProvider != null) {
9638 CompilationUnitElement element = _updatedUnit.element; 9652 CompilationUnitElement element = _updatedUnit.element;
9639 if (element != null) { 9653 if (element != null) {
9640 LibraryElement library = element.library; 9654 LibraryElement library = element.library;
9641 if (library != null) { 9655 if (library != null) {
9642 IncrementalResolver resolver = new IncrementalResolver( 9656 IncrementalResolver resolver = new IncrementalResolver(
9643 <Source, CompilationUnit>{},
9644 element, 9657 element,
9645 cache.offset, 9658 cache.offset,
9646 cache.oldLength, 9659 cache.oldLength,
9647 cache.newLength); 9660 cache.newLength);
9648 resolver.resolve(parser.updatedNode); 9661 resolver.resolve(parser.updatedNode);
9649 } 9662 }
9650 } 9663 }
9651 } 9664 }
9652 } 9665 }
9653 } 9666 }
(...skipping 2701 matching lines...) Expand 10 before | Expand all | Expand 10 after
12355 if (element.id == _id) { 12368 if (element.id == _id) {
12356 result = element; 12369 result = element;
12357 throw new _ElementByIdFinderException(); 12370 throw new _ElementByIdFinderException();
12358 } 12371 }
12359 super.visitElement(element); 12372 super.visitElement(element);
12360 } 12373 }
12361 } 12374 }
12362 12375
12363 class _ElementByIdFinderException { 12376 class _ElementByIdFinderException {
12364 } 12377 }
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