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

Side by Side Diff: pkg/analysis_server/lib/src/analysis_server.dart

Issue 892493003: Fix incremental resolution of files referenced by multiple contexts. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove temporary testing code 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 | no next file » | 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 analysis.server; 5 library analysis.server;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:analysis_server/src/analysis_logger.dart'; 10 import 'package:analysis_server/src/analysis_logger.dart';
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 } 829 }
830 }); 830 });
831 // remember new subscriptions 831 // remember new subscriptions
832 this.analysisServices = subscriptions; 832 this.analysisServices = subscriptions;
833 } 833 }
834 834
835 /** 835 /**
836 * Set the priority files to the given [files]. 836 * Set the priority files to the given [files].
837 */ 837 */
838 void setPriorityFiles(String requestId, List<String> files) { 838 void setPriorityFiles(String requestId, List<String> files) {
839 // Note: when a file is a priority file, that information needs to be
840 // propagated to all contexts that analyze the file, so that all contexts
841 // will be able to do incremental resolution of the file. See
842 // dartbug.com/22209.
839 Map<AnalysisContext, List<Source>> sourceMap = 843 Map<AnalysisContext, List<Source>> sourceMap =
840 new HashMap<AnalysisContext, List<Source>>(); 844 new HashMap<AnalysisContext, List<Source>>();
841 List<String> unanalyzed = new List<String>(); 845 List<String> unanalyzed = new List<String>();
842 files.forEach((file) { 846 files.forEach((file) {
843 AnalysisContext analysisContext = getAnalysisContext(file); 847 AnalysisContext preferredContext = getAnalysisContext(file);
844 if (analysisContext == null) { 848 Source source = getSource(file);
849 bool contextFound = false;
850 for (AnalysisContext context in folderMap.values) {
851 if (context == preferredContext ||
852 context.getKindOf(source) != SourceKind.UNKNOWN) {
scheglov 2015/01/29 23:22:16 It seems that if analysis isn't complete yet, and
Paul Berry 2015/01/30 00:19:45 Aha, you're right! I'd forgotten that we'd change
853 sourceMap.putIfAbsent(context, () => <Source>[]).add(source);
854 contextFound = true;
855 }
856 }
857 if (!contextFound) {
845 unanalyzed.add(file); 858 unanalyzed.add(file);
846 } else {
847 List<Source> sourceList = sourceMap[analysisContext];
848 if (sourceList == null) {
849 sourceList = <Source>[];
850 sourceMap[analysisContext] = sourceList;
851 }
852 sourceList.add(getSource(file));
853 } 859 }
854 }); 860 });
855 if (unanalyzed.isNotEmpty) { 861 if (unanalyzed.isNotEmpty) {
856 StringBuffer buffer = new StringBuffer(); 862 StringBuffer buffer = new StringBuffer();
857 buffer.writeAll(unanalyzed, ', '); 863 buffer.writeAll(unanalyzed, ', ');
858 throw new RequestFailure( 864 throw new RequestFailure(
859 new Response.unanalyzedPriorityFiles(requestId, buffer.toString())); 865 new Response.unanalyzedPriorityFiles(requestId, buffer.toString()));
860 } 866 }
861 folderMap.forEach((Folder folder, AnalysisContext context) { 867 folderMap.forEach((Folder folder, AnalysisContext context) {
862 List<Source> sourceList = sourceMap[context]; 868 List<Source> sourceList = sourceMap[context];
863 if (sourceList == null) { 869 if (sourceList == null) {
864 sourceList = Source.EMPTY_ARRAY; 870 sourceList = Source.EMPTY_ARRAY;
865 } 871 }
866 context.analysisPriorityOrder = sourceList; 872 context.analysisPriorityOrder = sourceList;
873 // Schedule the context for analysis so that it has the opportunity to
874 // cache the AST's for the priority sources as soon as possible.
875 schedulePerformAnalysisOperation(context);
scheglov 2015/01/29 23:22:16 I'm not sure we need this. AFAIK we don't schedul
Paul Berry 2015/01/30 00:19:45 Hmm, I tried the CL without this line at first, an
scheglov 2015/01/30 00:25:49 You are right, _getNextAnalysisTaskForSource handl
867 }); 876 });
868 operationQueue.reschedule(); 877 operationQueue.reschedule();
869 Source firstSource = files.length > 0 ? getSource(files[0]) : null; 878 Source firstSource = files.length > 0 ? getSource(files[0]) : null;
870 _onPriorityChangeController.add(new PriorityChangeEvent(firstSource)); 879 _onPriorityChangeController.add(new PriorityChangeEvent(firstSource));
871 } 880 }
872 881
873 /** 882 /**
874 * Returns `true` if errors should be reported for [file] with the given 883 * Returns `true` if errors should be reported for [file] with the given
875 * absolute path. 884 * absolute path.
876 */ 885 */
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
1135 * [packageUriResolver]. 1144 * [packageUriResolver].
1136 */ 1145 */
1137 SourceFactory _createSourceFactory(UriResolver packageUriResolver) { 1146 SourceFactory _createSourceFactory(UriResolver packageUriResolver) {
1138 List<UriResolver> resolvers = <UriResolver>[ 1147 List<UriResolver> resolvers = <UriResolver>[
1139 new DartUriResolver(analysisServer.defaultSdk), 1148 new DartUriResolver(analysisServer.defaultSdk),
1140 new ResourceUriResolver(resourceProvider), 1149 new ResourceUriResolver(resourceProvider),
1141 packageUriResolver]; 1150 packageUriResolver];
1142 return new SourceFactory(resolvers); 1151 return new SourceFactory(resolvers);
1143 } 1152 }
1144 } 1153 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698