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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 eda11af60e4dd4e74c2208356a998195e0e7654c..431155ada5e23db6eb0303927603ea319914d394 100644
--- a/pkg/analysis_server/lib/src/domain_analysis.dart
+++ b/pkg/analysis_server/lib/src/domain_analysis.dart
@@ -90,17 +90,17 @@ class AnalysisDomainHandler implements RequestHandler {
var params = new AnalysisGetHoverParams.fromRequest(request);
// Prepare the resolved units.
- List<CompilationUnit> units;
+ CompilationUnit unit;
if (server.options.enableNewAnalysisDriver) {
AnalysisResult result = await server.getAnalysisResult(params.file);
- units = result != null ? [result.unit] : null;
+ unit = result?.unit;
} else {
- units = server.getResolvedCompilationUnits(params.file);
+ unit = server.getResolvedCompilationUnit(params.file);
}
// Prepare the hovers.
List<HoverInformation> hovers = <HoverInformation>[];
- for (CompilationUnit unit in units) {
+ if (unit != null) {
HoverInformation hoverInformation =
new DartUnitHoverComputer(unit, params.offset).compute();
if (hoverInformation != null) {
@@ -147,12 +147,11 @@ class AnalysisDomainHandler implements RequestHandler {
analysisFuture.then((AnalysisDoneReason reason) {
switch (reason) {
case AnalysisDoneReason.COMPLETE:
- List<CompilationUnit> units =
- server.getResolvedCompilationUnits(file);
- if (units.isEmpty) {
+ CompilationUnit unit = server.getResolvedCompilationUnit(file);
+ if (unit == null) {
server.sendResponse(new Response.getNavigationInvalidFile(request));
} else {
- CompilationUnitElement unitElement = units.first.element;
+ CompilationUnitElement unitElement = unit.element;
NavigationCollectorImpl collector = computeNavigation(
server,
unitElement.context,
« 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