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

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

Issue 1829463002: Issue 26063. Index declarations in even partically analyzed units. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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 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 5e866bc35c164c01e3dd6fcb6cfa510177f2c438..bf5e47da65e6c3a2a4af6120eed2ea7e83a322fa 100644
--- a/pkg/analysis_server/lib/src/services/index/index.dart
+++ b/pkg/analysis_server/lib/src/services/index/index.dart
@@ -77,10 +77,21 @@ class Index {
}
/**
+ * Index declarations in the given partially resolved [unit].
+ */
+ void indexDeclarations(CompilationUnit unit) {
+ if (unit?.element?.library == null) {
+ return;
+ }
+ AnalysisContext context = unit.element.context;
+ _getContextIndex(context).indexDeclarations(unit);
+ }
+
+ /**
* Index the given fully resolved [unit].
*/
void indexUnit(CompilationUnit unit) {
- if (unit == null || unit.element == null) {
+ if (unit?.element?.library == null) {
return;
}
AnalysisContext context = unit.element.context;
@@ -256,18 +267,21 @@ class _ContextIndex {
}
/**
+ * Index declarations in the given partially resolved [unit].
+ */
+ void indexDeclarations(CompilationUnit unit) {
+ PackageIndexAssembler assembler = new PackageIndexAssembler();
+ assembler.indexDeclarations(unit);
+ _putUnitIndexBuilder(unit, assembler);
+ }
+
+ /**
* Index the given fully resolved [unit].
*/
void indexUnit(CompilationUnit unit) {
- // Index the unit.
PackageIndexAssembler assembler = new PackageIndexAssembler();
- assembler.index(unit);
- PackageIndexBuilder indexBuilder = assembler.assemble();
- // Put the index into the map.
- List<int> indexBytes = indexBuilder.toBuffer();
- PackageIndex index = new PackageIndex.fromBuffer(indexBytes);
- String key = _getUnitKeyForElement(unit.element);
- indexMap[key] = index;
+ assembler.indexUnit(unit);
+ _putUnitIndexBuilder(unit, assembler);
}
/**
@@ -300,6 +314,16 @@ class _ContextIndex {
}
return locations;
}
+
+ void _putUnitIndexBuilder(
+ CompilationUnit unit, PackageIndexAssembler assembler) {
+ PackageIndexBuilder indexBuilder = assembler.assemble();
+ // Put the index into the map.
+ List<int> indexBytes = indexBuilder.toBuffer();
+ PackageIndex index = new PackageIndex.fromBuffer(indexBytes);
+ String key = _getUnitKeyForElement(unit.element);
+ indexMap[key] = index;
+ }
}
/**
« no previous file with comments | « pkg/analysis_server/lib/src/analysis_server.dart ('k') | pkg/analysis_server/test/services/index/index_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698