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

Unified Diff: pkg/analysis_server/lib/src/services/index/index.dart

Issue 2551023005: Prepare for decoupling analyzer ASTs from element model. (Closed)
Patch Set: Address review comments Created 4 years 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
Index: pkg/analysis_server/lib/src/services/index/index.dart
diff --git a/pkg/analysis_server/lib/src/services/index/index.dart b/pkg/analysis_server/lib/src/services/index/index.dart
index dcf8ea38a604ea41f47683af670d896085e81616..8d79ac6d201ea8603e07b8aa1a77a3f7a802412f 100644
--- a/pkg/analysis_server/lib/src/services/index/index.dart
+++ b/pkg/analysis_server/lib/src/services/index/index.dart
@@ -6,6 +6,7 @@ import 'dart:async';
import 'package:analysis_server/src/services/index/index_unit.dart';
import 'package:analyzer/dart/ast/ast.dart';
+import 'package:analyzer/dart/ast/standard_resolution_map.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/src/generated/engine.dart' show AnalysisContext;
import 'package:analyzer/src/generated/source.dart';
@@ -80,10 +81,15 @@ class Index {
* Index declarations in the given partially resolved [unit].
*/
void indexDeclarations(CompilationUnit unit) {
- if (unit?.element?.library == null) {
+ if (unit == null) {
return;
}
- AnalysisContext context = unit.element.context;
+ CompilationUnitElement compilationUnitElement =
+ resolutionMap.elementForCompilationUnit(unit);
+ if (compilationUnitElement?.library == null) {
+ return;
+ }
+ AnalysisContext context = compilationUnitElement.context;
_getContextIndex(context).indexDeclarations(unit);
}
@@ -91,10 +97,15 @@ class Index {
* Index the given fully resolved [unit].
*/
void indexUnit(CompilationUnit unit) {
- if (unit?.element?.library == null) {
+ if (unit == null) {
+ return;
+ }
+ CompilationUnitElement compilationUnitElement =
+ resolutionMap.elementForCompilationUnit(unit);
+ if (compilationUnitElement?.library == null) {
return;
}
- AnalysisContext context = unit.element.context;
+ AnalysisContext context = compilationUnitElement.context;
_getContextIndex(context).indexUnit(unit);
}

Powered by Google App Engine
This is Rietveld 408576698