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

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

Issue 2525693002: Use single unit/node/element. (Closed)
Patch Set: Created 4 years, 1 month 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 domain.analysis; 5 library domain.analysis;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:core'; 8 import 'dart:core';
9 9
10 import 'package:analysis_server/plugin/analysis/analysis_domain.dart'; 10 import 'package:analysis_server/plugin/analysis/analysis_domain.dart';
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 return Response.DELAYED_RESPONSE; 83 return Response.DELAYED_RESPONSE;
84 } 84 }
85 85
86 /** 86 /**
87 * Implement the `analysis.getHover` request. 87 * Implement the `analysis.getHover` request.
88 */ 88 */
89 Future<Null> getHover(Request request) async { 89 Future<Null> getHover(Request request) async {
90 var params = new AnalysisGetHoverParams.fromRequest(request); 90 var params = new AnalysisGetHoverParams.fromRequest(request);
91 91
92 // Prepare the resolved units. 92 // Prepare the resolved units.
93 List<CompilationUnit> units; 93 CompilationUnit unit;
94 if (server.options.enableNewAnalysisDriver) { 94 if (server.options.enableNewAnalysisDriver) {
95 AnalysisResult result = await server.getAnalysisResult(params.file); 95 AnalysisResult result = await server.getAnalysisResult(params.file);
96 units = result != null ? [result.unit] : null; 96 unit = result?.unit;
97 } else { 97 } else {
98 units = server.getResolvedCompilationUnits(params.file); 98 unit = server.getResolvedCompilationUnit(params.file);
99 } 99 }
100 100
101 // Prepare the hovers. 101 // Prepare the hovers.
102 List<HoverInformation> hovers = <HoverInformation>[]; 102 List<HoverInformation> hovers = <HoverInformation>[];
103 for (CompilationUnit unit in units) { 103 if (unit != null) {
104 HoverInformation hoverInformation = 104 HoverInformation hoverInformation =
105 new DartUnitHoverComputer(unit, params.offset).compute(); 105 new DartUnitHoverComputer(unit, params.offset).compute();
106 if (hoverInformation != null) { 106 if (hoverInformation != null) {
107 hovers.add(hoverInformation); 107 hovers.add(hoverInformation);
108 } 108 }
109 } 109 }
110 110
111 // Send the response. 111 // Send the response.
112 server.sendResponse( 112 server.sendResponse(
113 new AnalysisGetHoverResult(hovers).toResponse(request.id)); 113 new AnalysisGetHoverResult(hovers).toResponse(request.id));
(...skipping 26 matching lines...) Expand all
140 var params = new AnalysisGetNavigationParams.fromRequest(request); 140 var params = new AnalysisGetNavigationParams.fromRequest(request);
141 String file = params.file; 141 String file = params.file;
142 Future<AnalysisDoneReason> analysisFuture = 142 Future<AnalysisDoneReason> analysisFuture =
143 server.onFileAnalysisComplete(file); 143 server.onFileAnalysisComplete(file);
144 if (analysisFuture == null) { 144 if (analysisFuture == null) {
145 return new Response.getNavigationInvalidFile(request); 145 return new Response.getNavigationInvalidFile(request);
146 } 146 }
147 analysisFuture.then((AnalysisDoneReason reason) { 147 analysisFuture.then((AnalysisDoneReason reason) {
148 switch (reason) { 148 switch (reason) {
149 case AnalysisDoneReason.COMPLETE: 149 case AnalysisDoneReason.COMPLETE:
150 List<CompilationUnit> units = 150 CompilationUnit unit = server.getResolvedCompilationUnit(file);
151 server.getResolvedCompilationUnits(file); 151 if (unit == null) {
152 if (units.isEmpty) {
153 server.sendResponse(new Response.getNavigationInvalidFile(request)); 152 server.sendResponse(new Response.getNavigationInvalidFile(request));
154 } else { 153 } else {
155 CompilationUnitElement unitElement = units.first.element; 154 CompilationUnitElement unitElement = unit.element;
156 NavigationCollectorImpl collector = computeNavigation( 155 NavigationCollectorImpl collector = computeNavigation(
157 server, 156 server,
158 unitElement.context, 157 unitElement.context,
159 unitElement.source, 158 unitElement.source,
160 params.offset, 159 params.offset,
161 params.length); 160 params.length);
162 server.sendResponse(new AnalysisGetNavigationResult( 161 server.sendResponse(new AnalysisGetNavigationResult(
163 collector.files, collector.targets, collector.regions) 162 collector.files, collector.targets, collector.regions)
164 .toResponse(request.id)); 163 .toResponse(request.id));
165 } 164 }
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 context.onResultChanged(descriptor).listen((result) { 413 context.onResultChanged(descriptor).listen((result) {
415 StreamController<engine.ResultChangedEvent> controller = 414 StreamController<engine.ResultChangedEvent> controller =
416 controllers[result.descriptor]; 415 controllers[result.descriptor];
417 if (controller != null) { 416 if (controller != null) {
418 controller.add(result); 417 controller.add(result);
419 } 418 }
420 }); 419 });
421 } 420 }
422 } 421 }
423 } 422 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/analysis_server.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