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

Unified Diff: pkg/analyzer/lib/src/dart/analysis/referenced_names.dart

Issue 2961773002: Compute subtyped names. (Closed)
Patch Set: Created 3 years, 6 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/dart/analysis/referenced_names_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/dart/analysis/referenced_names.dart
diff --git a/pkg/analyzer/lib/src/dart/analysis/referenced_names.dart b/pkg/analyzer/lib/src/dart/analysis/referenced_names.dart
index 1d0ed187d05361484523b53c506a8885be1c5bba..4733e2fe98687f2fb88cb0c0462db70047980850 100644
--- a/pkg/analyzer/lib/src/dart/analysis/referenced_names.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/referenced_names.dart
@@ -15,6 +15,39 @@ Set<String> computeReferencedNames(CompilationUnit unit) {
}
/**
+ * Compute the set of names which are used in `extends`, `with` or `implements`
+ * clauses in the file. Import prefixes and type arguments are not included.
+ */
+Set<String> computeSubtypedNames(CompilationUnit unit) {
+ Set<String> subtypedNames = new Set<String>();
+
+ void _addSubtypedName(TypeName type) {
+ if (type != null) {
+ Identifier name = type.name;
+ if (name is SimpleIdentifier) {
+ subtypedNames.add(name.name);
+ } else if (name is PrefixedIdentifier) {
+ subtypedNames.add(name.identifier.name);
+ }
+ }
+ }
+
+ void _addSubtypedNames(List<TypeName> types) {
+ types?.forEach(_addSubtypedName);
+ }
+
+ for (CompilationUnitMember declaration in unit.declarations) {
+ if (declaration is ClassDeclaration) {
+ _addSubtypedName(declaration.extendsClause?.superclass);
+ _addSubtypedNames(declaration.withClause?.mixinTypes);
+ _addSubtypedNames(declaration.implementsClause?.interfaces);
+ }
+ }
+
+ return subtypedNames;
+}
+
+/**
* Chained set of local names, that hide corresponding external names.
*/
class _LocalNameScope {
« no previous file with comments | « no previous file | pkg/analyzer/test/src/dart/analysis/referenced_names_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698