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

Unified Diff: pkg/analysis_server/lib/src/analysis_server.dart

Issue 1044463005: Issue 23027. Try to make priority files analyzable. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analysis_server/test/domain_analysis_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/analysis_server.dart
diff --git a/pkg/analysis_server/lib/src/analysis_server.dart b/pkg/analysis_server/lib/src/analysis_server.dart
index fc1957cd7f3710d4afa6c054b38430fa0b40e142..80452d362abae73e4e338cc21e052a76feca0d97 100644
--- a/pkg/analysis_server/lib/src/analysis_server.dart
+++ b/pkg/analysis_server/lib/src/analysis_server.dart
@@ -463,6 +463,14 @@ class AnalysisServer {
return new ContextSourcePair(context, source);
}
}
+ // try to find a context for which the file is a priority source
+ for (InternalAnalysisContext context in folderMap.values) {
+ List<Source> sources = context.getSourcesWithFullName(path);
+ if (sources.isNotEmpty) {
+ Source source = sources.first;
+ return new ContextSourcePair(context, source);
+ }
+ }
// file-based source
Source fileSource = file != null ? file.createSource() : null;
return new ContextSourcePair(null, fileSource);
@@ -916,10 +924,27 @@ class AnalysisServer {
new HashMap<AnalysisContext, List<Source>>();
List<String> unanalyzed = new List<String>();
Source firstSource = null;
- files.forEach((file) {
+ files.forEach((String file) {
ContextSourcePair contextSource = getContextSourcePair(file);
AnalysisContext preferredContext = contextSource.context;
Source source = contextSource.source;
+ // Try to make the file analyzable.
+ // If it is not in any context yet, add it to the first one which
+ // could use it, e.g. imports its package, even if not the library.
+ if (preferredContext == null) {
+ Resource resource = resourceProvider.getResource(file);
+ if (resource is File && resource.exists) {
+ for (AnalysisContext context in folderMap.values) {
+ Uri uri = context.sourceFactory.restoreUri(source);
+ if (uri.scheme != 'file') {
+ preferredContext = context;
+ source = ContextManager.createSourceInContext(context, resource);
+ break;
+ }
+ }
+ }
+ }
+ // Fill the source map.
bool contextFound = false;
for (AnalysisContext context in folderMap.values) {
if (context == preferredContext ||
« no previous file with comments | « no previous file | pkg/analysis_server/test/domain_analysis_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698