| 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 | 9 |
| 10 import 'package:analysis_server/src/analysis_logger.dart'; | 10 import 'package:analysis_server/src/analysis_logger.dart'; |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 * notify interested parties that the file has been (at least partially) | 312 * notify interested parties that the file has been (at least partially) |
| 313 * analyzed. | 313 * analyzed. |
| 314 */ | 314 */ |
| 315 void fileAnalyzed(ChangeNotice notice) { | 315 void fileAnalyzed(ChangeNotice notice) { |
| 316 if (contextDirectoryManager.isInAnalysisRoot(notice.source.fullName)) { | 316 if (contextDirectoryManager.isInAnalysisRoot(notice.source.fullName)) { |
| 317 _onFileAnalyzedController.add(notice); | 317 _onFileAnalyzedController.add(notice); |
| 318 } | 318 } |
| 319 } | 319 } |
| 320 | 320 |
| 321 /** | 321 /** |
| 322 * Return the [AnalysisContext] that is used to analyze the given [path]. | 322 * Return the preferred [AnalysisContext] for analyzing the given [path]. |
| 323 * Return `null` if there is no such context. | 323 * This will be the context that explicitly contains the path, if any such |
| 324 * context exists, otherwise it will be the first analysis context that |
| 325 * implicitly analyzes it. Return `null` if no context is analyzing the |
| 326 * path. |
| 324 */ | 327 */ |
| 325 AnalysisContext getAnalysisContext(String path) { | 328 AnalysisContext getAnalysisContext(String path) { |
| 326 // try to find a containing context | 329 // try to find a containing context |
| 327 for (Folder folder in folderMap.keys) { | 330 for (Folder folder in folderMap.keys) { |
| 328 if (folder.contains(path)) { | 331 if (folder.contains(path)) { |
| 329 return folderMap[folder]; | 332 return folderMap[folder]; |
| 330 } | 333 } |
| 331 } | 334 } |
| 332 // check if there is a context that analyzed this source | 335 // check if there is a context that analyzed this source |
| 333 return getAnalysisContextForSource(getSource(path)); | 336 return getAnalysisContextForSource(getSource(path)); |
| 334 } | 337 } |
| 335 | 338 |
| 336 /** | 339 /** |
| 337 * Return the [AnalysisContext] that is used to analyze the given [source]. | 340 * Return any [AnalysisContext] that is analyzing the given [source], either |
| 338 * Return `null` if there is no such context. | 341 * explicitly or implicitly. Return `null` if there is no such context. |
| 339 */ | 342 */ |
| 340 AnalysisContext getAnalysisContextForSource(Source source) { | 343 AnalysisContext getAnalysisContextForSource(Source source) { |
| 341 for (AnalysisContext context in folderMap.values) { | 344 for (AnalysisContext context in folderMap.values) { |
| 342 SourceKind kind = context.getKindOf(source); | 345 SourceKind kind = context.getKindOf(source); |
| 343 if (kind != SourceKind.UNKNOWN) { | 346 if (kind != SourceKind.UNKNOWN) { |
| 344 return context; | 347 return context; |
| 345 } | 348 } |
| 346 } | 349 } |
| 347 return null; | 350 return null; |
| 348 } | 351 } |
| (...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1132 * [packageUriResolver]. | 1135 * [packageUriResolver]. |
| 1133 */ | 1136 */ |
| 1134 SourceFactory _createSourceFactory(UriResolver packageUriResolver) { | 1137 SourceFactory _createSourceFactory(UriResolver packageUriResolver) { |
| 1135 List<UriResolver> resolvers = <UriResolver>[ | 1138 List<UriResolver> resolvers = <UriResolver>[ |
| 1136 new DartUriResolver(analysisServer.defaultSdk), | 1139 new DartUriResolver(analysisServer.defaultSdk), |
| 1137 new ResourceUriResolver(resourceProvider), | 1140 new ResourceUriResolver(resourceProvider), |
| 1138 packageUriResolver]; | 1141 packageUriResolver]; |
| 1139 return new SourceFactory(resolvers); | 1142 return new SourceFactory(resolvers); |
| 1140 } | 1143 } |
| 1141 } | 1144 } |
| OLD | NEW |