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

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

Issue 1000203003: If the file belongs to any analysis root, check whether we're in it now. (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/operation/operation_analysis.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 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 386
387 /** 387 /**
388 * Return the [AnalysisContext]s that are being used to analyze the analysis 388 * Return the [AnalysisContext]s that are being used to analyze the analysis
389 * roots. 389 * roots.
390 */ 390 */
391 Iterable<AnalysisContext> getAnalysisContexts() { 391 Iterable<AnalysisContext> getAnalysisContexts() {
392 return folderMap.values; 392 return folderMap.values;
393 } 393 }
394 394
395 /** 395 /**
396 * Return the [AnalysisContext] that contains the given [path].
397 * Return `null` if no context contains the [path].
398 */
399 AnalysisContext getContainingContext(String path) {
400 Folder containingFolder = null;
401 AnalysisContext containingContext = null;
402 folderMap.forEach((Folder folder, AnalysisContext context) {
403 if (folder.isOrContains(path)) {
404 if (containingFolder == null ||
405 containingFolder.path.length < folder.path.length) {
406 containingFolder = folder;
407 containingContext = context;
408 }
409 }
410 });
411 return containingContext;
412 }
413
414 /**
396 * Return the primary [ContextSourcePair] representing the given [path]. 415 * Return the primary [ContextSourcePair] representing the given [path].
397 * 416 *
398 * The [AnalysisContext] of this pair will be the context that explicitly 417 * The [AnalysisContext] of this pair will be the context that explicitly
399 * contains the path, if any such context exists, otherwise it will be the 418 * contains the path, if any such context exists, otherwise it will be the
400 * first context that implicitly analyzes it. 419 * first context that implicitly analyzes it.
401 * 420 *
402 * If the [path] is not analyzed by any context, a [ContextSourcePair] with 421 * If the [path] is not analyzed by any context, a [ContextSourcePair] with
403 * `null` context and `file` [Source] is returned. 422 * `null` context and `file` [Source] is returned.
404 * 423 *
405 * If the [path] dosn't represent a file, `null` is returned as a [Source]. 424 * If the [path] dosn't represent a file, `null` is returned as a [Source].
406 * 425 *
407 * Does not return `null`. 426 * Does not return `null`.
408 */ 427 */
409 ContextSourcePair getContextSourcePair(String path) { 428 ContextSourcePair getContextSourcePair(String path) {
410 // try SDK 429 // try SDK
411 { 430 {
412 Uri uri = resourceProvider.pathContext.toUri(path); 431 Uri uri = resourceProvider.pathContext.toUri(path);
413 Source sdkSource = defaultSdk.fromFileUri(uri); 432 Source sdkSource = defaultSdk.fromFileUri(uri);
414 if (sdkSource != null) { 433 if (sdkSource != null) {
415 AnalysisContext anyContext = folderMap.values.first; 434 AnalysisContext anyContext = folderMap.values.first;
416 return new ContextSourcePair(anyContext, sdkSource); 435 return new ContextSourcePair(anyContext, sdkSource);
417 } 436 }
418 } 437 }
419 // try to find the deep-most containing context 438 // try to find the deep-most containing context
420 Resource resource = resourceProvider.getResource(path); 439 Resource resource = resourceProvider.getResource(path);
421 File file = resource is File ? resource : null; 440 File file = resource is File ? resource : null;
422 { 441 {
423 Folder containingFolder = null; 442 AnalysisContext containingContext = getContainingContext(path);
424 AnalysisContext containingContext = null;
425 folderMap.forEach((Folder folder, AnalysisContext context) {
426 if (folder.isOrContains(path)) {
427 if (containingFolder == null ||
428 containingFolder.path.length < folder.path.length) {
429 containingFolder = folder;
430 containingContext = context;
431 }
432 }
433 });
434 if (containingContext != null) { 443 if (containingContext != null) {
435 Source source = file != null 444 Source source = file != null
436 ? ContextManager.createSourceInContext(containingContext, file) 445 ? ContextManager.createSourceInContext(containingContext, file)
437 : null; 446 : null;
438 return new ContextSourcePair(containingContext, source); 447 return new ContextSourcePair(containingContext, source);
439 } 448 }
440 } 449 }
441 // try to find a context that analysed the file 450 // try to find a context that analysed the file
442 for (AnalysisContext context in folderMap.values) { 451 for (AnalysisContext context in folderMap.values) {
443 Source source = file != null 452 Source source = file != null
(...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after
1408 /** 1417 /**
1409 * The [PerformanceTag] for time spent in server request handlers. 1418 * The [PerformanceTag] for time spent in server request handlers.
1410 */ 1419 */
1411 static PerformanceTag serverRequests = new PerformanceTag('serverRequests'); 1420 static PerformanceTag serverRequests = new PerformanceTag('serverRequests');
1412 1421
1413 /** 1422 /**
1414 * The [PerformanceTag] for time spent in split store microtasks. 1423 * The [PerformanceTag] for time spent in split store microtasks.
1415 */ 1424 */
1416 static PerformanceTag splitStore = new PerformanceTag('splitStore'); 1425 static PerformanceTag splitStore = new PerformanceTag('splitStore');
1417 } 1426 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/operation/operation_analysis.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698