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

Side by Side 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, 8 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/analysis_server/test/domain_analysis_test.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 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 import 'dart:math' show max; 9 import 'dart:math' show max;
10 10
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 // try to find a context that analysed the file 456 // try to find a context that analysed the file
457 for (AnalysisContext context in folderMap.values) { 457 for (AnalysisContext context in folderMap.values) {
458 Source source = file != null 458 Source source = file != null
459 ? ContextManager.createSourceInContext(context, file) 459 ? ContextManager.createSourceInContext(context, file)
460 : null; 460 : null;
461 SourceKind kind = context.getKindOf(source); 461 SourceKind kind = context.getKindOf(source);
462 if (kind != SourceKind.UNKNOWN) { 462 if (kind != SourceKind.UNKNOWN) {
463 return new ContextSourcePair(context, source); 463 return new ContextSourcePair(context, source);
464 } 464 }
465 } 465 }
466 // try to find a context for which the file is a priority source
467 for (InternalAnalysisContext context in folderMap.values) {
468 List<Source> sources = context.getSourcesWithFullName(path);
469 if (sources.isNotEmpty) {
470 Source source = sources.first;
471 return new ContextSourcePair(context, source);
472 }
473 }
466 // file-based source 474 // file-based source
467 Source fileSource = file != null ? file.createSource() : null; 475 Source fileSource = file != null ? file.createSource() : null;
468 return new ContextSourcePair(null, fileSource); 476 return new ContextSourcePair(null, fileSource);
469 } 477 }
470 478
471 /** 479 /**
472 * Returns [Element]s at the given [offset] of the given [file]. 480 * Returns [Element]s at the given [offset] of the given [file].
473 * 481 *
474 * May be empty if cannot be resolved, but not `null`. 482 * May be empty if cannot be resolved, but not `null`.
475 */ 483 */
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 */ 917 */
910 void setPriorityFiles(String requestId, List<String> files) { 918 void setPriorityFiles(String requestId, List<String> files) {
911 // Note: when a file is a priority file, that information needs to be 919 // Note: when a file is a priority file, that information needs to be
912 // propagated to all contexts that analyze the file, so that all contexts 920 // propagated to all contexts that analyze the file, so that all contexts
913 // will be able to do incremental resolution of the file. See 921 // will be able to do incremental resolution of the file. See
914 // dartbug.com/22209. 922 // dartbug.com/22209.
915 Map<AnalysisContext, List<Source>> sourceMap = 923 Map<AnalysisContext, List<Source>> sourceMap =
916 new HashMap<AnalysisContext, List<Source>>(); 924 new HashMap<AnalysisContext, List<Source>>();
917 List<String> unanalyzed = new List<String>(); 925 List<String> unanalyzed = new List<String>();
918 Source firstSource = null; 926 Source firstSource = null;
919 files.forEach((file) { 927 files.forEach((String file) {
920 ContextSourcePair contextSource = getContextSourcePair(file); 928 ContextSourcePair contextSource = getContextSourcePair(file);
921 AnalysisContext preferredContext = contextSource.context; 929 AnalysisContext preferredContext = contextSource.context;
922 Source source = contextSource.source; 930 Source source = contextSource.source;
931 // Try to make the file analyzable.
932 // If it is not in any context yet, add it to the first one which
933 // could use it, e.g. imports its package, even if not the library.
934 if (preferredContext == null) {
935 Resource resource = resourceProvider.getResource(file);
936 if (resource is File && resource.exists) {
937 for (AnalysisContext context in folderMap.values) {
938 Uri uri = context.sourceFactory.restoreUri(source);
939 if (uri.scheme != 'file') {
940 preferredContext = context;
941 source = ContextManager.createSourceInContext(context, resource);
942 break;
943 }
944 }
945 }
946 }
947 // Fill the source map.
923 bool contextFound = false; 948 bool contextFound = false;
924 for (AnalysisContext context in folderMap.values) { 949 for (AnalysisContext context in folderMap.values) {
925 if (context == preferredContext || 950 if (context == preferredContext ||
926 context.getKindOf(source) != SourceKind.UNKNOWN) { 951 context.getKindOf(source) != SourceKind.UNKNOWN) {
927 sourceMap.putIfAbsent(context, () => <Source>[]).add(source); 952 sourceMap.putIfAbsent(context, () => <Source>[]).add(source);
928 contextFound = true; 953 contextFound = true;
929 } 954 }
930 } 955 }
931 if (firstSource == null) { 956 if (firstSource == null) {
932 firstSource = source; 957 firstSource = source;
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
1447 /** 1472 /**
1448 * The [PerformanceTag] for time spent in server request handlers. 1473 * The [PerformanceTag] for time spent in server request handlers.
1449 */ 1474 */
1450 static PerformanceTag serverRequests = new PerformanceTag('serverRequests'); 1475 static PerformanceTag serverRequests = new PerformanceTag('serverRequests');
1451 1476
1452 /** 1477 /**
1453 * The [PerformanceTag] for time spent in split store microtasks. 1478 * The [PerformanceTag] for time spent in split store microtasks.
1454 */ 1479 */
1455 static PerformanceTag splitStore = new PerformanceTag('splitStore'); 1480 static PerformanceTag splitStore = new PerformanceTag('splitStore');
1456 } 1481 }
OLDNEW
« 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