Index: pkg/analysis_server/lib/src/domain_analysis.dart |
diff --git a/pkg/analysis_server/lib/src/domain_analysis.dart b/pkg/analysis_server/lib/src/domain_analysis.dart |
index 512a2a9ea4f9ebae08c25b8c5dd9e799a10607d6..2351ef6d4ab1580ea7e377e8d77371fe8f25b73d 100644 |
--- a/pkg/analysis_server/lib/src/domain_analysis.dart |
+++ b/pkg/analysis_server/lib/src/domain_analysis.dart |
@@ -21,9 +21,7 @@ import 'package:analysis_server/src/plugin/result_merger.dart'; |
import 'package:analysis_server/src/protocol/protocol_internal.dart'; |
import 'package:analysis_server/src/protocol_server.dart'; |
import 'package:analysis_server/src/services/dependencies/library_dependencies.dart'; |
-import 'package:analysis_server/src/services/dependencies/reachable_source_collector.dart'; |
import 'package:analyzer/dart/ast/ast.dart'; |
-import 'package:analyzer/dart/element/element.dart'; |
import 'package:analyzer/error/error.dart' as engine; |
import 'package:analyzer/exception/exception.dart'; |
import 'package:analyzer/file_system/file_system.dart'; |
@@ -66,44 +64,18 @@ class AnalysisDomainHandler extends AbstractRequestHandler { |
} |
} |
- if (server.options.enableNewAnalysisDriver) { |
- var result = await server.getAnalysisResult(file); |
+ AnalysisResult result = await server.getAnalysisResult(file); |
- if (server.onResultErrorSupplementor != null) { |
- if (result != null) { |
- await server.onResultErrorSupplementor(file, result.errors); |
- } else { |
- server.onNoAnalysisResult(file, send); |
- return; |
- } |
+ if (server.onResultErrorSupplementor != null) { |
+ if (result != null) { |
+ await server.onResultErrorSupplementor(file, result.errors); |
+ } else { |
+ server.onNoAnalysisResult(file, send); |
+ return; |
} |
- |
- send(result?.driver?.analysisOptions, result?.lineInfo, result?.errors); |
- return; |
} |
- Future<AnalysisDoneReason> completionFuture = |
- server.onFileAnalysisComplete(file); |
- if (completionFuture == null) { |
- server.sendResponse(new Response.getErrorsInvalidFile(request)); |
- } |
- completionFuture.then((AnalysisDoneReason reason) async { |
- switch (reason) { |
- case AnalysisDoneReason.COMPLETE: |
- engine.AnalysisErrorInfo errorInfo = server.getErrors(file); |
- if (errorInfo == null) { |
- server.sendResponse(new Response.getErrorsInvalidFile(request)); |
- } else { |
- engine.AnalysisContext context = server.getAnalysisContext(file); |
- send(context.analysisOptions, errorInfo.lineInfo, errorInfo.errors); |
- } |
- break; |
- case AnalysisDoneReason.CONTEXT_REMOVED: |
- // The active contexts have changed, so try again. |
- await getErrors(request); |
- break; |
- } |
- }); |
+ send(result?.driver?.analysisOptions, result?.lineInfo, result?.errors); |
} |
/** |
@@ -113,13 +85,8 @@ class AnalysisDomainHandler extends AbstractRequestHandler { |
var params = new AnalysisGetHoverParams.fromRequest(request); |
// Prepare the resolved units. |
- CompilationUnit unit; |
- if (server.options.enableNewAnalysisDriver) { |
- AnalysisResult result = await server.getAnalysisResult(params.file); |
- unit = result?.unit; |
- } else { |
- unit = await server.getResolvedCompilationUnit(params.file); |
- } |
+ AnalysisResult result = await server.getAnalysisResult(params.file); |
+ CompilationUnit unit = result?.unit; |
// Prepare the hovers. |
List<HoverInformation> hovers = <HoverInformation>[]; |
@@ -163,117 +130,80 @@ class AnalysisDomainHandler extends AbstractRequestHandler { |
int offset = params.offset; |
int length = params.length; |
- if (server.options.enableNewAnalysisDriver) { |
- AnalysisDriver driver = server.getAnalysisDriver(file); |
- if (driver == null) { |
- server.sendResponse(new Response.getNavigationInvalidFile(request)); |
- } else { |
- // |
- // Allow plugins to start computing navigation data. |
- // |
- plugin.AnalysisGetNavigationParams requestParams = |
- new plugin.AnalysisGetNavigationParams(file, offset, length); |
- Map<PluginInfo, Future<plugin.Response>> pluginFutures = server |
- .pluginManager |
- .broadcastRequest(requestParams, contextRoot: driver.contextRoot); |
- // |
- // Compute navigation data generated by server. |
- // |
- List<AnalysisNavigationParams> allResults = |
- <AnalysisNavigationParams>[]; |
- AnalysisResult result = await server.getAnalysisResult(file); |
- CompilationUnit unit = result?.unit; |
- if (unit != null && result.exists) { |
- NavigationCollectorImpl collector = new NavigationCollectorImpl(); |
- computeDartNavigation(collector, unit, offset, length); |
- collector.createRegions(); |
+ AnalysisDriver driver = server.getAnalysisDriver(file); |
+ if (driver == null) { |
+ server.sendResponse(new Response.getNavigationInvalidFile(request)); |
+ } else { |
+ // |
+ // Allow plugins to start computing navigation data. |
+ // |
+ plugin.AnalysisGetNavigationParams requestParams = |
+ new plugin.AnalysisGetNavigationParams(file, offset, length); |
+ Map<PluginInfo, Future<plugin.Response>> pluginFutures = server |
+ .pluginManager |
+ .broadcastRequest(requestParams, contextRoot: driver.contextRoot); |
+ // |
+ // Compute navigation data generated by server. |
+ // |
+ List<AnalysisNavigationParams> allResults = <AnalysisNavigationParams>[]; |
+ AnalysisResult result = await server.getAnalysisResult(file); |
+ CompilationUnit unit = result?.unit; |
+ if (unit != null && result.exists) { |
+ NavigationCollectorImpl collector = new NavigationCollectorImpl(); |
+ computeDartNavigation(collector, unit, offset, length); |
+ collector.createRegions(); |
+ allResults.add(new AnalysisNavigationParams( |
+ file, collector.regions, collector.targets, collector.files)); |
+ } |
+ // |
+ // Add the navigation data produced by plugins to the server-generated |
+ // navigation data. |
+ // |
+ if (pluginFutures != null) { |
+ List<plugin.Response> responses = await waitForResponses(pluginFutures, |
+ requestParameters: requestParams); |
+ for (plugin.Response response in responses) { |
+ plugin.AnalysisGetNavigationResult result = |
+ new plugin.AnalysisGetNavigationResult.fromResponse(response); |
allResults.add(new AnalysisNavigationParams( |
- file, collector.regions, collector.targets, collector.files)); |
- } |
- // |
- // Add the navigation data produced by plugins to the server-generated |
- // navigation data. |
- // |
- if (pluginFutures != null) { |
- List<plugin.Response> responses = await waitForResponses( |
- pluginFutures, |
- requestParameters: requestParams); |
- for (plugin.Response response in responses) { |
- plugin.AnalysisGetNavigationResult result = |
- new plugin.AnalysisGetNavigationResult.fromResponse(response); |
- allResults.add(new AnalysisNavigationParams( |
- file, result.regions, result.targets, result.files)); |
- } |
- } |
- // |
- // Return the result. |
- // |
- ResultMerger merger = new ResultMerger(); |
- AnalysisNavigationParams mergedResults = |
- merger.mergeNavigation(allResults); |
- if (mergedResults == null) { |
- server.sendResponse(new AnalysisGetNavigationResult( |
- <String>[], <NavigationTarget>[], <NavigationRegion>[]) |
- .toResponse(request.id)); |
- } else { |
- server.sendResponse(new AnalysisGetNavigationResult( |
- mergedResults.files, |
- mergedResults.targets, |
- mergedResults.regions) |
- .toResponse(request.id)); |
+ file, result.regions, result.targets, result.files)); |
} |
} |
- return; |
- } |
- |
- Future<AnalysisDoneReason> analysisFuture = |
- server.onFileAnalysisComplete(file); |
- if (analysisFuture == null) { |
- server.sendResponse(new Response.getNavigationInvalidFile(request)); |
- return; |
- } |
- analysisFuture.then((AnalysisDoneReason reason) async { |
- switch (reason) { |
- case AnalysisDoneReason.COMPLETE: |
- CompilationUnit unit = await server.getResolvedCompilationUnit(file); |
- if (unit == null) { |
- server.sendResponse(new Response.getNavigationInvalidFile(request)); |
- } else { |
- CompilationUnitElement unitElement = unit.element; |
- NavigationCollectorImpl collector = computeNavigation( |
- server, |
- unitElement.context, |
- unitElement.source, |
- params.offset, |
- params.length); |
- server.sendResponse(new AnalysisGetNavigationResult( |
- collector.files, collector.targets, collector.regions) |
- .toResponse(request.id)); |
- } |
- break; |
- case AnalysisDoneReason.CONTEXT_REMOVED: |
- // The active contexts have changed, so try again. |
- await getNavigation(request); |
- break; |
+ // |
+ // Return the result. |
+ // |
+ ResultMerger merger = new ResultMerger(); |
+ AnalysisNavigationParams mergedResults = |
+ merger.mergeNavigation(allResults); |
+ if (mergedResults == null) { |
+ server.sendResponse(new AnalysisGetNavigationResult( |
+ <String>[], <NavigationTarget>[], <NavigationRegion>[]) |
+ .toResponse(request.id)); |
+ } else { |
+ server.sendResponse(new AnalysisGetNavigationResult(mergedResults.files, |
+ mergedResults.targets, mergedResults.regions) |
+ .toResponse(request.id)); |
} |
- }); |
+ } |
} |
/** |
* Implement the `analysis.getReachableSources` request. |
*/ |
Response getReachableSources(Request request) { |
- AnalysisGetReachableSourcesParams params = |
- new AnalysisGetReachableSourcesParams.fromRequest(request); |
- ContextSourcePair pair = server.getContextSourcePair(params.file); |
- if (pair.context == null || pair.source == null) { |
- return new Response.getReachableSourcesInvalidFile(request); |
- } |
- Map<String, List<String>> sources = |
- new ReachableSourceCollector(pair.source, pair.context) |
- .collectSources(); |
- return new AnalysisGetReachableSourcesResult(sources) |
- .toResponse(request.id); |
+ return new Response.unsupportedFeature(request.id, |
+ 'Please contact the Dart analyzer team if you need this request.'); |
+// AnalysisGetReachableSourcesParams params = |
+// new AnalysisGetReachableSourcesParams.fromRequest(request); |
+// ContextSourcePair pair = server.getContextSourcePair(params.file); |
+// if (pair.context == null || pair.source == null) { |
+// return new Response.getReachableSourcesInvalidFile(request); |
+// } |
+// Map<String, List<String>> sources = |
+// new ReachableSourceCollector(pair.source, pair.context) |
+// .collectSources(); |
+// return new AnalysisGetReachableSourcesResult(sources) |
+// .toResponse(request.id); |
} |
@override |