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

Unified Diff: pkg/analysis_server/lib/src/computer/computer_highlights2.dart

Issue 1345943006: Report UNRESOLVED_INSTANCE_MEMBER_REFERENCE for dynamicVar.member references. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: more fixes Created 5 years, 3 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/analysis_server/test/analysis/notification_highlights_test2.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/computer/computer_highlights2.dart
diff --git a/pkg/analysis_server/lib/src/computer/computer_highlights2.dart b/pkg/analysis_server/lib/src/computer/computer_highlights2.dart
index 1a8b5a6eef54478d986f3aaea1753db00dc37c58..c847670466c56701a752f7ba3ee76424c462e919 100644
--- a/pkg/analysis_server/lib/src/computer/computer_highlights2.dart
+++ b/pkg/analysis_server/lib/src/computer/computer_highlights2.dart
@@ -96,6 +96,9 @@ class DartUnitHighlightsComputer2 {
if (_addIdentifierRegion_typeParameter(node)) {
return;
}
+ if (_addIdentifierRegion_unresolvedInstanceMemberReference(node)) {
+ return;
+ }
_addRegion_node(node, HighlightRegionType.IDENTIFIER_DEFAULT);
}
@@ -352,6 +355,38 @@ class DartUnitHighlightsComputer2 {
return _addRegion_node(node, HighlightRegionType.TYPE_PARAMETER);
}
+ bool _addIdentifierRegion_unresolvedInstanceMemberReference(
+ SimpleIdentifier node) {
+ // unresolved
+ Element element = node.bestElement;
+ if (element != null) {
+ return false;
+ }
+ // invoke / get / set
+ bool decorate = false;
+ AstNode parent = node.parent;
+ if (parent is MethodInvocation) {
+ Expression target = parent.realTarget;
+ if (parent.methodName == node &&
+ target != null &&
+ _isDynamicExpression(target)) {
+ decorate = true;
+ }
+ } else if (node.inGetterContext() || node.inSetterContext()) {
+ if (parent is PrefixedIdentifier) {
+ decorate = parent.identifier == node;
+ } else if (parent is PropertyAccess) {
+ decorate = parent.propertyName == node;
+ }
+ }
+ if (decorate) {
+ _addRegion_node(
+ node, HighlightRegionType.UNRESOLVED_INSTANCE_MEMBER_REFERENCE);
+ return true;
+ }
+ return false;
+ }
+
void _addRegion(int offset, int length, HighlightRegionType type) {
_regions.add(new HighlightRegion(type, offset, length));
}
@@ -384,6 +419,13 @@ class DartUnitHighlightsComputer2 {
int end = b.end;
_addRegion(offset, end - offset, type);
}
+
+ static bool _isDynamicExpression(Expression e) {
+ if (e is SimpleIdentifier && e.staticElement is PrefixElement) {
+ return false;
+ }
+ return e.bestType.isDynamic;
+ }
}
/**
« no previous file with comments | « no previous file | pkg/analysis_server/test/analysis/notification_highlights_test2.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698