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

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

Issue 971833003: Optimize top-level element declarations search. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Tweaks for review comments Created 5 years, 10 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_contributor.dart
diff --git a/pkg/analysis_server/lib/src/services/index/index_contributor.dart b/pkg/analysis_server/lib/src/services/index/index_contributor.dart
index 463e8fd0be806874f9a2402af30fb7dd7fd581c9..1ba69987efe67ea4f76ea0b03bec528706e6ea57 100644
--- a/pkg/analysis_server/lib/src/services/index/index_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/index/index_contributor.dart
@@ -131,7 +131,7 @@ class _IndexContributor extends GeneralizingAstVisitor {
ClassElement element = node.element;
enterScope(element);
try {
- _recordElementDefinition(element);
+ _recordTopLevelElementDefinition(element);
{
ExtendsClause extendsClause = node.extendsClause;
if (extendsClause != null) {
@@ -175,7 +175,7 @@ class _IndexContributor extends GeneralizingAstVisitor {
ClassElement element = node.element;
enterScope(element);
try {
- _recordElementDefinition(element);
+ _recordTopLevelElementDefinition(element);
{
TypeName superclassNode = node.superclass;
if (superclassNode != null) {
@@ -286,7 +286,7 @@ class _IndexContributor extends GeneralizingAstVisitor {
ClassElement element = node.element;
enterScope(element);
try {
- _recordElementDefinition(element);
+ _recordTopLevelElementDefinition(element);
super.visitEnumDeclaration(node);
} finally {
_exitScope();
@@ -317,7 +317,7 @@ class _IndexContributor extends GeneralizingAstVisitor {
@override
visitFunctionDeclaration(FunctionDeclaration node) {
Element element = node.element;
- _recordElementDefinition(element);
+ _recordTopLevelElementDefinition(element);
enterScope(element);
try {
super.visitFunctionDeclaration(node);
@@ -329,7 +329,7 @@ class _IndexContributor extends GeneralizingAstVisitor {
@override
visitFunctionTypeAlias(FunctionTypeAlias node) {
Element element = node.element;
- _recordElementDefinition(element);
+ _recordTopLevelElementDefinition(element);
super.visitFunctionTypeAlias(node);
}
@@ -533,7 +533,7 @@ class _IndexContributor extends GeneralizingAstVisitor {
VariableDeclarationList variables = node.variables;
for (VariableDeclaration variableDeclaration in variables.variables) {
Element element = variableDeclaration.element;
- _recordElementDefinition(element);
+ _recordTopLevelElementDefinition(element);
}
super.visitTopLevelVariableDeclaration(node);
}
@@ -677,16 +677,6 @@ class _IndexContributor extends GeneralizingAstVisitor {
}
/**
- * Records the [Element] definition in the library and universe.
- */
- void _recordElementDefinition(Element element) {
- Location location = createLocation(element);
- Relationship relationship = IndexConstants.DEFINES;
- recordRelationship(_libraryElement, relationship, location);
- recordRelationship(UniverseElement.INSTANCE, relationship, location);
- }
-
- /**
* Records [ImportElement] reference if given [SimpleIdentifier] references some
* top-level element and not qualified with import prefix.
*/
@@ -784,6 +774,15 @@ class _IndexContributor extends GeneralizingAstVisitor {
}
/**
+ * Records the [Element] definition in the library and universe.
+ */
+ void _recordTopLevelElementDefinition(Element element) {
+ Location location = createLocation(element);
+ recordRelationship(_libraryElement, IndexConstants.DEFINES, location);
+ _store.recordTopDeclaration(element);
+ }
+
+ /**
* Creates a [Location] representing declaration of the [Element].
*/
static Location createLocation(Element element) {
« no previous file with comments | « pkg/analysis_server/lib/src/services/index/index.dart ('k') | pkg/analysis_server/lib/src/services/index/index_store.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698