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

Unified Diff: pkg/analyzer/lib/src/summary/index_unit.dart

Issue 1755433002: Record only qualified unresolved name usages. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/index_unit_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/summary/index_unit.dart
diff --git a/pkg/analyzer/lib/src/summary/index_unit.dart b/pkg/analyzer/lib/src/summary/index_unit.dart
index 0fa4ec868a1d9fdb3feb0f1cd718750d37624030..49929e18e1fae56f70fdac918101562e5f327efb 100644
--- a/pkg/analyzer/lib/src/summary/index_unit.dart
+++ b/pkg/analyzer/lib/src/summary/index_unit.dart
@@ -280,7 +280,7 @@ class _IndexContributor extends GeneralizingAstVisitor {
*/
void recordNameRelation(SimpleIdentifier node, IndexRelationKind kind) {
if (node != null) {
- assembler.addNameRelation(node.name, kind, node.offset, node.length);
+ assembler.addNameRelation(node.name, kind, node.offset);
}
}
@@ -438,15 +438,18 @@ class _IndexContributor extends GeneralizingAstVisitor {
@override
visitMethodInvocation(MethodInvocation node) {
SimpleIdentifier name = node.methodName;
- // record name invocation
- recordNameRelation(name, IndexRelationKind.IS_INVOKED_BY);
- // element invocation
Element element = name.bestElement;
+ // qualified unresolved name invocation
+ bool isQualified = node.realTarget != null;
+ if (isQualified && element == null) {
+ recordNameRelation(name, IndexRelationKind.IS_INVOKED_BY);
+ }
+ // element invocation
if (element is MethodElement ||
element is PropertyAccessorElement ||
element is FunctionElement ||
element is VariableElement) {
- IndexRelationKind kind = node.realTarget != null
+ IndexRelationKind kind = isQualified
? IndexRelationKind.IS_INVOKED_QUALIFIED_BY
: IndexRelationKind.IS_INVOKED_BY;
recordRelation(element, kind, name);
@@ -500,15 +503,18 @@ class _IndexContributor extends GeneralizingAstVisitor {
recordDefinedElement(element);
return;
}
- // record name reference
- recordNameRelation(node, IndexRelationKind.IS_REFERENCED_BY);
+ // record qualified unresolved name reference
+ bool isQualified = node.isQualified;
+ if (isQualified && element == null) {
+ recordNameRelation(node, IndexRelationKind.IS_REFERENCED_BY);
+ }
// this.field parameter
if (element is FieldFormalParameterElement) {
recordRelation(element.field, IndexRelationKind.IS_REFERENCED_BY, node);
return;
}
// record specific relations
- IndexRelationKind kind = node.isQualified
+ IndexRelationKind kind = isQualified
? IndexRelationKind.IS_REFERENCED_QUALIFIED_BY
: IndexRelationKind.IS_REFERENCED_BY;
recordRelation(element, kind, node);
@@ -581,9 +587,8 @@ class _NameRelationInfo {
final int nameId;
final IndexRelationKind kind;
final int offset;
- final int length;
- _NameRelationInfo(this.nameId, this.kind, this.offset, this.length);
+ _NameRelationInfo(this.nameId, this.kind, this.offset);
}
/**
@@ -616,10 +621,9 @@ class _UnitIndexAssembler {
} on StateError {}
}
- void addNameRelation(
- String name, IndexRelationKind kind, int offset, int length) {
+ void addNameRelation(String name, IndexRelationKind kind, int offset) {
int nameId = pkg._getStringId(name);
- nameRelations.add(new _NameRelationInfo(nameId, kind, offset, length));
+ nameRelations.add(new _NameRelationInfo(nameId, kind, offset));
}
/**
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/index_unit_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698