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

Unified Diff: pkg/analyzer/lib/src/generated/element_resolver.dart

Issue 704413005: Report HintCode.UNUSED_ELEMENT for classes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixes for review comments. Created 6 years, 1 month 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 | « pkg/analyzer/lib/src/generated/element.dart ('k') | pkg/analyzer/lib/src/generated/error.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/element_resolver.dart
diff --git a/pkg/analyzer/lib/src/generated/element_resolver.dart b/pkg/analyzer/lib/src/generated/element_resolver.dart
index e10f99b70b0a8ff1d4a7c9061c811dc863d33a05..886da2a2dc0ae5c91f62823b128ccbfba9802df8 100644
--- a/pkg/analyzer/lib/src/generated/element_resolver.dart
+++ b/pkg/analyzer/lib/src/generated/element_resolver.dart
@@ -1031,6 +1031,7 @@ class ElementResolver extends SimpleAstVisitor<Object> {
}
}
node.staticElement = element;
+ _markElementUsed(element);
if (node.inSetterContext() && node.inGetterContext() && enclosingClass != null) {
InterfaceType enclosingType = enclosingClass.type;
AuxiliaryElements auxiliaryElements = new AuxiliaryElements(_lookUpGetter(null, enclosingType, node.name), null);
@@ -1902,6 +1903,29 @@ class ElementResolver extends SimpleAstVisitor<Object> {
}
/**
+ * Marks [element] as used in its defining library.
+ */
+ void _markElementUsed(Element element) {
+ // only locally defined elements
+ if (element == null) {
+ return;
+ }
+ if (!identical(element.library, _definingLibrary)) {
+ return;
+ }
+ // convert members to base elements
+ if (element is Member) {
+ element = (element as Member).baseElement;
+ }
+ // ignore references to an element from itself
+ if (identical(element, _resolver.enclosingClass)) {
+ return;
+ }
+ // OK, the element is used
+ (element as ElementImpl).markUsed();
+ }
+
+ /**
* Given some class element, this method uses [subtypeManager] to find the set of all
* subtypes; the subtypes are then searched for a member (method, getter, or setter), that matches
* a passed
« no previous file with comments | « pkg/analyzer/lib/src/generated/element.dart ('k') | pkg/analyzer/lib/src/generated/error.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698