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

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

Issue 449583003: Fix for opening SDK sources. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 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
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 9
10 import 'package:analyzer/file_system/file_system.dart'; 10 import 'package:analyzer/file_system/file_system.dart';
(...skipping 11 matching lines...) Expand all
22 import 'package:analyzer/src/generated/ast.dart'; 22 import 'package:analyzer/src/generated/ast.dart';
23 import 'package:analyzer/src/generated/engine.dart'; 23 import 'package:analyzer/src/generated/engine.dart';
24 import 'package:analyzer/src/generated/source.dart'; 24 import 'package:analyzer/src/generated/source.dart';
25 import 'package:analyzer/src/generated/sdk.dart'; 25 import 'package:analyzer/src/generated/sdk.dart';
26 import 'package:analyzer/src/generated/source_io.dart'; 26 import 'package:analyzer/src/generated/source_io.dart';
27 import 'package:analyzer/src/generated/java_engine.dart'; 27 import 'package:analyzer/src/generated/java_engine.dart';
28 import 'package:analysis_services/constants.dart'; 28 import 'package:analysis_services/constants.dart';
29 import 'package:analysis_services/index/index.dart'; 29 import 'package:analysis_services/index/index.dart';
30 import 'package:analysis_services/search/search_engine.dart'; 30 import 'package:analysis_services/search/search_engine.dart';
31 import 'package:analyzer/src/generated/element.dart'; 31 import 'package:analyzer/src/generated/element.dart';
32 import 'package:path/path.dart';
32 33
33 34
34 class AnalysisServerContextDirectoryManager extends ContextDirectoryManager { 35 class AnalysisServerContextDirectoryManager extends ContextDirectoryManager {
35 final AnalysisServer analysisServer; 36 final AnalysisServer analysisServer;
36 37
37 /** 38 /**
38 * The default options used to create new analysis contexts. 39 * The default options used to create new analysis contexts.
39 */ 40 */
40 AnalysisOptionsImpl defaultOptions = new AnalysisOptionsImpl(); 41 AnalysisOptionsImpl defaultOptions = new AnalysisOptionsImpl();
41 42
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 }); 530 });
530 // remember new subscriptions 531 // remember new subscriptions
531 this.analysisServices = subscriptions; 532 this.analysisServices = subscriptions;
532 } 533 }
533 534
534 /** 535 /**
535 * Return the [AnalysisContext] that is used to analyze the given [path]. 536 * Return the [AnalysisContext] that is used to analyze the given [path].
536 * Return `null` if there is no such context. 537 * Return `null` if there is no such context.
537 */ 538 */
538 AnalysisContext getAnalysisContext(String path) { 539 AnalysisContext getAnalysisContext(String path) {
540 // try to find a containing context
539 for (Folder folder in folderMap.keys) { 541 for (Folder folder in folderMap.keys) {
540 if (path.startsWith(folder.path)) { 542 if (path.startsWith(folder.path)) {
541 return folderMap[folder]; 543 return folderMap[folder];
542 } 544 }
543 } 545 }
546 // check if there is a context that analyzed this source
547 {
548 Source source = getSource(path);
549 for (AnalysisContext context in folderMap.values) {
550 SourceKind kind = context.getKindOf(source);
551 if (kind != null) {
552 return context;
553 }
554 }
555 }
544 return null; 556 return null;
545 } 557 }
546 558
547 /** 559 /**
548 * Return the [Source] of the Dart file with the given [path]. 560 * Return the [Source] of the Dart file with the given [path].
549 */ 561 */
550 Source getSource(String path) { 562 Source getSource(String path) {
563 // try SDK
564 {
565 Uri uri = toUri(path);
566 Source sdkSource = defaultSdk.fromFileUri(uri);
567 if (sdkSource != null) {
568 return sdkSource;
569 }
570 }
571 // file-based source
551 File file = contextDirectoryManager.resourceProvider.getResource(path); 572 File file = contextDirectoryManager.resourceProvider.getResource(path);
552 return file.createSource(); 573 return file.createSource();
553 } 574 }
554 575
555 /** 576 /**
556 * Returns the [CompilationUnit] of the Dart file with the given [path] that 577 * Returns the [CompilationUnit] of the Dart file with the given [path] that
557 * should be used to resend notifications for already resolved unit. 578 * should be used to resend notifications for already resolved unit.
558 * Returns `null` if the file is not a part of any context, library has not 579 * Returns `null` if the file is not a part of any context, library has not
559 * been yet resolved, or any problem happened. 580 * been yet resolved, or any problem happened.
560 */ 581 */
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 /** 811 /**
791 * An enumeration of the services provided by the server domain. 812 * An enumeration of the services provided by the server domain.
792 */ 813 */
793 class ServerService extends Enum2<ServerService> { 814 class ServerService extends Enum2<ServerService> {
794 static const ServerService STATUS = const ServerService('STATUS', 0); 815 static const ServerService STATUS = const ServerService('STATUS', 0);
795 816
796 static const List<ServerService> VALUES = const [STATUS]; 817 static const List<ServerService> VALUES = const [STATUS];
797 818
798 const ServerService(String name, int ordinal) : super(name, ordinal); 819 const ServerService(String name, int ordinal) : super(name, ordinal);
799 } 820 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698