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

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

Issue 2669353002: Stop using Element.computeNode() in refactorings and fixes. (Closed)
Patch Set: documentation comments Created 3 years, 10 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
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:core'; 9 import 'dart:core';
10 import 'dart:io' as io; 10 import 'dart:io' as io;
(...skipping 19 matching lines...) Expand all
30 import 'package:analyzer/dart/ast/ast.dart'; 30 import 'package:analyzer/dart/ast/ast.dart';
31 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; 31 import 'package:analyzer/dart/ast/standard_resolution_map.dart';
32 import 'package:analyzer/dart/element/element.dart'; 32 import 'package:analyzer/dart/element/element.dart';
33 import 'package:analyzer/exception/exception.dart'; 33 import 'package:analyzer/exception/exception.dart';
34 import 'package:analyzer/file_system/file_system.dart'; 34 import 'package:analyzer/file_system/file_system.dart';
35 import 'package:analyzer/file_system/physical_file_system.dart'; 35 import 'package:analyzer/file_system/physical_file_system.dart';
36 import 'package:analyzer/instrumentation/instrumentation.dart'; 36 import 'package:analyzer/instrumentation/instrumentation.dart';
37 import 'package:analyzer/plugin/resolver_provider.dart'; 37 import 'package:analyzer/plugin/resolver_provider.dart';
38 import 'package:analyzer/source/pub_package_map_provider.dart'; 38 import 'package:analyzer/source/pub_package_map_provider.dart';
39 import 'package:analyzer/src/context/builder.dart'; 39 import 'package:analyzer/src/context/builder.dart';
40 import 'package:analyzer/src/dart/analysis/ast_provider_context.dart';
41 import 'package:analyzer/src/dart/analysis/ast_provider_driver.dart';
40 import 'package:analyzer/src/dart/analysis/byte_store.dart'; 42 import 'package:analyzer/src/dart/analysis/byte_store.dart';
41 import 'package:analyzer/src/dart/analysis/driver.dart' as nd; 43 import 'package:analyzer/src/dart/analysis/driver.dart' as nd;
42 import 'package:analyzer/src/dart/analysis/file_byte_store.dart'; 44 import 'package:analyzer/src/dart/analysis/file_byte_store.dart';
43 import 'package:analyzer/src/dart/analysis/file_state.dart' as nd; 45 import 'package:analyzer/src/dart/analysis/file_state.dart' as nd;
44 import 'package:analyzer/src/dart/analysis/status.dart' as nd; 46 import 'package:analyzer/src/dart/analysis/status.dart' as nd;
45 import 'package:analyzer/src/dart/ast/utilities.dart'; 47 import 'package:analyzer/src/dart/ast/utilities.dart';
48 import 'package:analyzer/src/dart/element/ast_provider.dart';
46 import 'package:analyzer/src/generated/engine.dart'; 49 import 'package:analyzer/src/generated/engine.dart';
47 import 'package:analyzer/src/generated/sdk.dart'; 50 import 'package:analyzer/src/generated/sdk.dart';
48 import 'package:analyzer/src/generated/source.dart'; 51 import 'package:analyzer/src/generated/source.dart';
49 import 'package:analyzer/src/generated/source_io.dart'; 52 import 'package:analyzer/src/generated/source_io.dart';
50 import 'package:analyzer/src/generated/utilities_general.dart'; 53 import 'package:analyzer/src/generated/utilities_general.dart';
51 import 'package:analyzer/src/summary/pub_summary.dart'; 54 import 'package:analyzer/src/summary/pub_summary.dart';
52 import 'package:analyzer/src/task/dart.dart'; 55 import 'package:analyzer/src/task/dart.dart';
53 import 'package:analyzer/src/util/glob.dart'; 56 import 'package:analyzer/src/util/glob.dart';
54 import 'package:analyzer/task/dart.dart'; 57 import 'package:analyzer/task/dart.dart';
55 import 'package:plugin/plugin.dart'; 58 import 'package:plugin/plugin.dart';
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 try { 630 try {
628 nd.AnalysisDriver driver = getAnalysisDriver(path); 631 nd.AnalysisDriver driver = getAnalysisDriver(path);
629 return await driver?.getResult(path); 632 return await driver?.getResult(path);
630 } catch (e) { 633 } catch (e) {
631 // Ignore the exception. 634 // Ignore the exception.
632 // We don't want to log the same exception again and again. 635 // We don't want to log the same exception again and again.
633 return null; 636 return null;
634 } 637 }
635 } 638 }
636 639
640 /**
641 * Return the [AstProvider] for the given [path].
642 */
643 AstProvider getAstProvider(String path) {
644 if (options.enableNewAnalysisDriver) {
645 var analysisDriver = getAnalysisDriver(path);
646 return new AstProviderForDriver(analysisDriver);
647 } else {
648 var analysisContext = getAnalysisContext(path);
649 return new AstProviderForContext(analysisContext);
650 }
651 }
652
637 CompilationUnitElement getCompilationUnitElement(String file) { 653 CompilationUnitElement getCompilationUnitElement(String file) {
638 ContextSourcePair pair = getContextSourcePair(file); 654 ContextSourcePair pair = getContextSourcePair(file);
639 if (pair == null) { 655 if (pair == null) {
640 return null; 656 return null;
641 } 657 }
642 // prepare AnalysisContext and Source 658 // prepare AnalysisContext and Source
643 AnalysisContext context = pair.context; 659 AnalysisContext context = pair.context;
644 Source unitSource = pair.source; 660 Source unitSource = pair.source;
645 if (context == null || unitSource == null) { 661 if (context == null || unitSource == null) {
646 return null; 662 return null;
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 unit = result?.unit; 830 unit = result?.unit;
815 } else { 831 } else {
816 unit = await getResolvedCompilationUnit(file); 832 unit = await getResolvedCompilationUnit(file);
817 } 833 }
818 if (unit != null) { 834 if (unit != null) {
819 return new NodeLocator(offset).searchWithin(unit); 835 return new NodeLocator(offset).searchWithin(unit);
820 } 836 }
821 return null; 837 return null;
822 } 838 }
823 839
840 // TODO(brianwilkerson) Add the following method after 'prioritySources' has
841 // been added to InternalAnalysisContext.
842 // /**
843 // * Return a list containing the full names of all of the sources that are
844 // * priority sources.
845 // */
846 // List<String> getPriorityFiles() {
847 // List<String> priorityFiles = new List<String>();
848 // folderMap.values.forEach((ContextDirectory directory) {
849 // InternalAnalysisContext context = directory.context;
850 // context.prioritySources.forEach((Source source) {
851 // priorityFiles.add(source.fullName);
852 // });
853 // });
854 // return priorityFiles;
855 // }
856
824 /** 857 /**
825 * Return a [Future] that completes with the resolved [CompilationUnit] for 858 * Return a [Future] that completes with the resolved [CompilationUnit] for
826 * the Dart file with the given [path], or with `null` if the file is not a 859 * the Dart file with the given [path], or with `null` if the file is not a
827 * Dart file or cannot be resolved. 860 * Dart file or cannot be resolved.
828 */ 861 */
829 Future<CompilationUnit> getResolvedCompilationUnit(String path) async { 862 Future<CompilationUnit> getResolvedCompilationUnit(String path) async {
830 if (options.enableNewAnalysisDriver) { 863 if (options.enableNewAnalysisDriver) {
831 nd.AnalysisResult result = await getAnalysisResult(path); 864 nd.AnalysisResult result = await getAnalysisResult(path);
832 return result?.unit; 865 return result?.unit;
833 } 866 }
834 ContextSourcePair contextSource = getContextSourcePair(path); 867 ContextSourcePair contextSource = getContextSourcePair(path);
835 AnalysisContext context = contextSource.context; 868 AnalysisContext context = contextSource.context;
836 if (context == null) { 869 if (context == null) {
837 return null; 870 return null;
838 } 871 }
839 return runWithActiveContext(context, () { 872 return runWithActiveContext(context, () {
840 Source unitSource = contextSource.source; 873 Source unitSource = contextSource.source;
841 List<Source> librarySources = context.getLibrariesContaining(unitSource); 874 List<Source> librarySources = context.getLibrariesContaining(unitSource);
842 for (Source librarySource in librarySources) { 875 for (Source librarySource in librarySources) {
843 return context.resolveCompilationUnit2(unitSource, librarySource); 876 return context.resolveCompilationUnit2(unitSource, librarySource);
844 } 877 }
845 return null; 878 return null;
846 }); 879 });
847 } 880 }
848 881
849 // TODO(brianwilkerson) Add the following method after 'prioritySources' has
850 // been added to InternalAnalysisContext.
851 // /**
852 // * Return a list containing the full names of all of the sources that are
853 // * priority sources.
854 // */
855 // List<String> getPriorityFiles() {
856 // List<String> priorityFiles = new List<String>();
857 // folderMap.values.forEach((ContextDirectory directory) {
858 // InternalAnalysisContext context = directory.context;
859 // context.prioritySources.forEach((Source source) {
860 // priorityFiles.add(source.fullName);
861 // });
862 // });
863 // return priorityFiles;
864 // }
865
866 /** 882 /**
867 * Handle a [request] that was read from the communication channel. 883 * Handle a [request] that was read from the communication channel.
868 */ 884 */
869 void handleRequest(Request request) { 885 void handleRequest(Request request) {
870 _performance.logRequest(request); 886 _performance.logRequest(request);
871 runZoned(() { 887 runZoned(() {
872 ServerPerformanceStatistics.serverRequests.makeCurrentWhile(() { 888 ServerPerformanceStatistics.serverRequests.makeCurrentWhile(() {
873 int count = handlers.length; 889 int count = handlers.length;
874 for (int i = 0; i < count; i++) { 890 for (int i = 0; i < count; i++) {
875 try { 891 try {
(...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after
2111 /** 2127 /**
2112 * The [PerformanceTag] for time spent in server request handlers. 2128 * The [PerformanceTag] for time spent in server request handlers.
2113 */ 2129 */
2114 static PerformanceTag serverRequests = new PerformanceTag('serverRequests'); 2130 static PerformanceTag serverRequests = new PerformanceTag('serverRequests');
2115 2131
2116 /** 2132 /**
2117 * The [PerformanceTag] for time spent in split store microtasks. 2133 * The [PerformanceTag] for time spent in split store microtasks.
2118 */ 2134 */
2119 static PerformanceTag splitStore = new PerformanceTag('splitStore'); 2135 static PerformanceTag splitStore = new PerformanceTag('splitStore');
2120 } 2136 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/plugin/edit/fix/fix_dart.dart ('k') | pkg/analysis_server/lib/src/edit/edit_domain.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698