OLD | NEW |
---|---|
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:core' hide Resource; | 9 import 'dart:core' hide Resource; |
10 import 'dart:math' show max; | 10 import 'dart:math' show max; |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
544 Resource resource = resourceProvider.getResource(path); | 544 Resource resource = resourceProvider.getResource(path); |
545 if (resource is! File) { | 545 if (resource is! File) { |
546 return new ContextSourcePair(null, null); | 546 return new ContextSourcePair(null, null); |
547 } | 547 } |
548 File file = resource; | 548 File file = resource; |
549 { | 549 { |
550 AnalysisContext containingContext = getContainingContext(path); | 550 AnalysisContext containingContext = getContainingContext(path); |
551 if (containingContext != null) { | 551 if (containingContext != null) { |
552 Source source = | 552 Source source = |
553 ContextManagerImpl.createSourceInContext(containingContext, file); | 553 ContextManagerImpl.createSourceInContext(containingContext, file); |
554 return new ContextSourcePair(containingContext, source); | 554 return new ContextSourcePair(containingContext, source, |
555 contained: true); | |
555 } | 556 } |
556 } | 557 } |
557 // try to find a context that analysed the file | 558 // try to find a context that analysed the file |
558 for (AnalysisContext context in analysisContexts) { | 559 for (AnalysisContext context in analysisContexts) { |
559 Source source = ContextManagerImpl.createSourceInContext(context, file); | 560 Source source = ContextManagerImpl.createSourceInContext(context, file); |
560 SourceKind kind = context.getKindOf(source); | 561 SourceKind kind = context.getKindOf(source); |
561 if (kind != SourceKind.UNKNOWN) { | 562 if (kind != SourceKind.UNKNOWN) { |
562 return new ContextSourcePair(context, source); | 563 return new ContextSourcePair(context, source); |
563 } | 564 } |
564 } | 565 } |
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1255 } | 1256 } |
1256 return; | 1257 return; |
1257 } | 1258 } |
1258 // Update all contexts. | 1259 // Update all contexts. |
1259 bool anyContextUpdated = false; | 1260 bool anyContextUpdated = false; |
1260 for (InternalAnalysisContext context in analysisContexts) { | 1261 for (InternalAnalysisContext context in analysisContexts) { |
1261 List<Source> sources = context.getSourcesWithFullName(file); | 1262 List<Source> sources = context.getSourcesWithFullName(file); |
1262 sources.forEach((Source source) { | 1263 sources.forEach((Source source) { |
1263 anyContextUpdated = true; | 1264 anyContextUpdated = true; |
1264 if (context.handleContentsChanged( | 1265 if (context.handleContentsChanged( |
1265 source, oldContents, newContents, true)) { | 1266 source, oldContents, newContents, true, |
1267 explicit: contextSource.contained)) { | |
skybrian
2016/03/02 06:35:34
Oops, this check should probably be something like
| |
1266 schedulePerformAnalysisOperation(context); | 1268 schedulePerformAnalysisOperation(context); |
1267 } else { | 1269 } else { |
1268 // When the client sends any change for a source, we should resend | 1270 // When the client sends any change for a source, we should resend |
1269 // subscribed notifications, even if there were no changes in the | 1271 // subscribed notifications, even if there were no changes in the |
1270 // source contents. | 1272 // source contents. |
1271 // TODO(scheglov) consider checking if there are subscriptions. | 1273 // TODO(scheglov) consider checking if there are subscriptions. |
1272 if (AnalysisEngine.isDartFileName(file)) { | 1274 if (AnalysisEngine.isDartFileName(file)) { |
1273 List<CompilationUnit> dartUnits = | 1275 List<CompilationUnit> dartUnits = |
1274 context.ensureResolvedDartUnits(source); | 1276 context.ensureResolvedDartUnits(source); |
1275 if (dartUnits != null) { | 1277 if (dartUnits != null) { |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1433 */ | 1435 */ |
1434 final AnalysisContext context; | 1436 final AnalysisContext context; |
1435 | 1437 |
1436 /** | 1438 /** |
1437 * The source that corresponds to the file. | 1439 * The source that corresponds to the file. |
1438 * May be `null` if the file is not a regular file. | 1440 * May be `null` if the file is not a regular file. |
1439 * If the file cannot be found in the [context], then it has a `file` uri. | 1441 * If the file cannot be found in the [context], then it has a `file` uri. |
1440 */ | 1442 */ |
1441 final Source source; | 1443 final Source source; |
1442 | 1444 |
1443 ContextSourcePair(this.context, this.source); | 1445 /** |
1446 * If true, the source is contained within the directory associated | |
1447 * with the context. | |
1448 */ | |
1449 final bool contained; | |
1450 | |
1451 ContextSourcePair(this.context, this.source, {this.contained: false}); | |
1444 } | 1452 } |
1445 | 1453 |
1446 /** | 1454 /** |
1447 * A [PriorityChangeEvent] indicates the set the priority files has changed. | 1455 * A [PriorityChangeEvent] indicates the set the priority files has changed. |
1448 */ | 1456 */ |
1449 class PriorityChangeEvent { | 1457 class PriorityChangeEvent { |
1450 final Source firstSource; | 1458 final Source firstSource; |
1451 | 1459 |
1452 PriorityChangeEvent(this.firstSource); | 1460 PriorityChangeEvent(this.firstSource); |
1453 } | 1461 } |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1718 /** | 1726 /** |
1719 * The [PerformanceTag] for time spent in server request handlers. | 1727 * The [PerformanceTag] for time spent in server request handlers. |
1720 */ | 1728 */ |
1721 static PerformanceTag serverRequests = new PerformanceTag('serverRequests'); | 1729 static PerformanceTag serverRequests = new PerformanceTag('serverRequests'); |
1722 | 1730 |
1723 /** | 1731 /** |
1724 * The [PerformanceTag] for time spent in split store microtasks. | 1732 * The [PerformanceTag] for time spent in split store microtasks. |
1725 */ | 1733 */ |
1726 static PerformanceTag splitStore = new PerformanceTag('splitStore'); | 1734 static PerformanceTag splitStore = new PerformanceTag('splitStore'); |
1727 } | 1735 } |
OLD | NEW |