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

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

Issue 1787803003: Improve used name relations and fields indexing. (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/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 3ad356b9c22a7af7477c96641cb81900c6004545..f111f85beb92552c0b4d52f2cfd32f0a2acb67d0 100644
--- a/pkg/analyzer/lib/src/summary/index_unit.dart
+++ b/pkg/analyzer/lib/src/summary/index_unit.dart
@@ -420,8 +420,7 @@ class _IndexContributor extends GeneralizingAstVisitor {
SimpleIdentifier fieldName = node.fieldName;
if (fieldName != null) {
Element element = fieldName.staticElement;
- recordRelation(
- element, IndexRelationKind.IS_REFERENCED_BY, fieldName, true);
+ recordRelation(element, IndexRelationKind.IS_WRITTEN_BY, fieldName, true);
}
node.expression?.accept(this);
}
@@ -544,12 +543,26 @@ class _IndexContributor extends GeneralizingAstVisitor {
// record qualified unresolved name reference
bool isQualified = _isQualified(node);
if (isQualified && element == null) {
- recordNameRelation(node, IndexRelationKind.IS_REFERENCED_BY);
+ bool inGetterContext = node.inGetterContext();
+ bool inSetterContext = node.inSetterContext();
+ IndexRelationKind kind;
+ if (inGetterContext && inSetterContext) {
+ kind = IndexRelationKind.IS_READ_WRITTEN_BY;
+ } else if (inGetterContext) {
+ kind = IndexRelationKind.IS_READ_BY;
+ } else {
+ kind = IndexRelationKind.IS_WRITTEN_BY;
+ }
+ recordNameRelation(node, kind);
}
// this.field parameter
if (element is FieldFormalParameterElement) {
- recordRelation(
- element.field, IndexRelationKind.IS_REFERENCED_BY, node, true);
+ AstNode parent = node.parent;
+ IndexRelationKind kind =
+ parent is FieldFormalParameter && parent.identifier == node
+ ? IndexRelationKind.IS_WRITTEN_BY
+ : IndexRelationKind.IS_REFERENCED_BY;
+ recordRelation(element.field, kind, node, true);
return;
}
// ignore a local reference to a parameter

Powered by Google App Engine
This is Rietveld 408576698