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

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

Issue 2428233002: Add TypeResolverMode and implement 'api' in TypeResolverVisitor. (Closed)
Patch Set: Created 4 years, 2 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/generated/resolver_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/resolver.dart
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
index d9dd238ffc742a17039405ce7c3886eab33f51dd..bc4ef3e88d071c65df450d4e9c4b300ae57a15f5 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -9379,6 +9379,27 @@ class TypeProviderImpl extends TypeProviderBase {
}
/**
+ * Modes in which [TypeResolverVisitor] works.
+ */
+enum TypeResolverMode {
+ /**
+ * Resolve all names types of all nodes.
+ */
+ everything,
+
+ /**
+ * Resolve only type names outside of function bodies, variable initializers,
+ * and parameter default values.
+ */
+ api,
+
+ /**
+ * Resolve only type names that would be skipped during [api].
+ */
+ local
+}
+
+/**
* Instances of the class `TypeResolverVisitor` are used to resolve the types associated with
* the elements in the element model. This includes the types of superclasses, mixins, interfaces,
* fields, methods, parameters, and local variables. As a side-effect, this also finishes building
@@ -9415,6 +9436,8 @@ class TypeResolverVisitor extends ScopedVisitor {
*/
TypeNameResolver _typeNameResolver;
+ final TypeResolverMode mode;
+
/**
* Initialize a newly created visitor to resolve the nodes in an AST node.
*
@@ -9432,7 +9455,7 @@ class TypeResolverVisitor extends ScopedVisitor {
*/
TypeResolverVisitor(LibraryElement definingLibrary, Source source,
TypeProvider typeProvider, AnalysisErrorListener errorListener,
- {Scope nameScope})
+ {Scope nameScope, this.mode: TypeResolverMode.everything})
: super(definingLibrary, source, typeProvider, errorListener,
nameScope: nameScope) {
_dynamicType = typeProvider.dynamicType;
@@ -9473,6 +9496,14 @@ class TypeResolverVisitor extends ScopedVisitor {
}
@override
+ Object visitBlockFunctionBody(BlockFunctionBody node) {
+ if (mode == TypeResolverMode.api) {
+ return null;
+ }
+ return super.visitBlockFunctionBody(node);
+ }
+
+ @override
Object visitCatchClause(CatchClause node) {
super.visitCatchClause(node);
SimpleIdentifier exception = node.exceptionParameter;
@@ -9631,6 +9662,14 @@ class TypeResolverVisitor extends ScopedVisitor {
}
@override
+ Object visitExpressionFunctionBody(ExpressionFunctionBody node) {
+ if (mode == TypeResolverMode.api) {
+ return null;
+ }
+ return super.visitExpressionFunctionBody(node);
+ }
+
+ @override
Object visitFieldFormalParameter(FieldFormalParameter node) {
super.visitFieldFormalParameter(node);
Element element = node.identifier.staticElement;
@@ -9742,6 +9781,23 @@ class TypeResolverVisitor extends ScopedVisitor {
}
@override
+ Object visitNode(AstNode node) {
+ // In API mode we need to ignore:
+ // - default values of parameters;
+ // - initializers of top-level variables.
+ if (mode == TypeResolverMode.api) {
+ if (node is DefaultFormalParameter) {
+ node.parameter.accept(this);
+ return null;
+ }
+ if (node is VariableDeclaration) {
+ return null;
+ }
+ }
+ return super.visitNode(node);
+ }
+
+ @override
Object visitSimpleFormalParameter(SimpleFormalParameter node) {
super.visitSimpleFormalParameter(node);
DartType declaredType;
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698