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

Unified Diff: pkg/analyzer/lib/src/dart/element/builder.dart

Issue 2430513004: Get rid of _inFunction in ApiElementBuilder. (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/lib/src/generated/incremental_resolver.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/dart/element/builder.dart
diff --git a/pkg/analyzer/lib/src/dart/element/builder.dart b/pkg/analyzer/lib/src/dart/element/builder.dart
index 004991a7296387d01db4a36600a68d28be0f45d4..c450a8fa93f66478991563ac92442f6ff0937ca6 100644
--- a/pkg/analyzer/lib/src/dart/element/builder.dart
+++ b/pkg/analyzer/lib/src/dart/element/builder.dart
@@ -28,11 +28,6 @@ import 'package:analyzer/src/generated/utilities_dart.dart';
*/
class ApiElementBuilder extends _BaseElementBuilder {
/**
- * A flag indicating whether a variable declaration is within the body of a method or function.
- */
- bool _inFunction = false;
-
- /**
* A table mapping field names to field elements for the fields defined in the current class, or
* `null` if we are not in the scope of a class.
*/
@@ -47,13 +42,6 @@ class ApiElementBuilder extends _BaseElementBuilder {
CompilationUnitElementImpl compilationUnitElement)
: super(initialHolder, compilationUnitElement);
- /**
- * Prepares for incremental resolution of a function body.
- */
- void initForFunctionBodyIncrementalResolution() {
- _inFunction = true;
- }
-
@override
Object visitAnnotation(Annotation node) {
// Although it isn't valid to do so because closures are not constant
@@ -149,13 +137,7 @@ class ApiElementBuilder extends _BaseElementBuilder {
@override
Object visitConstructorDeclaration(ConstructorDeclaration node) {
ElementHolder holder = new ElementHolder();
- bool wasInFunction = _inFunction;
- _inFunction = true;
- try {
- _visitChildren(holder, node);
- } finally {
- _inFunction = wasInFunction;
- }
+ _visitChildren(holder, node);
FunctionBody body = node.body;
SimpleIdentifier constructorName = node.name;
ConstructorElementImpl element =
@@ -281,16 +263,10 @@ class ApiElementBuilder extends _BaseElementBuilder {
FunctionExpression expression = node.functionExpression;
if (expression != null) {
ElementHolder holder = new ElementHolder();
- bool wasInFunction = _inFunction;
- _inFunction = true;
- try {
- _visitChildren(holder, node);
- } finally {
- _inFunction = wasInFunction;
- }
+ _visitChildren(holder, node);
FunctionBody body = expression.body;
Token property = node.propertyKeyword;
- if (property == null || _inFunction) {
+ if (property == null) {
SimpleIdentifier functionName = node.name;
FunctionElementImpl element =
new FunctionElementImpl.forNode(functionName);
@@ -311,13 +287,6 @@ class ApiElementBuilder extends _BaseElementBuilder {
if (body.isGenerator) {
element.generator = true;
}
- if (_inFunction) {
- Block enclosingBlock = node.getAncestor((node) => node is Block);
- if (enclosingBlock != null) {
- element.setVisibleRange(
- enclosingBlock.offset, enclosingBlock.length);
- }
- }
if (node.returnType == null) {
element.hasImplicitReturnType = true;
}
@@ -412,13 +381,7 @@ class ApiElementBuilder extends _BaseElementBuilder {
return super.visitFunctionExpression(node);
}
ElementHolder holder = new ElementHolder();
- bool wasInFunction = _inFunction;
- _inFunction = true;
- try {
- _visitChildren(holder, node);
- } finally {
- _inFunction = wasInFunction;
- }
+ _visitChildren(holder, node);
FunctionBody body = node.body;
FunctionElementImpl element =
new FunctionElementImpl.forOffset(node.beginToken.offset);
@@ -434,12 +397,6 @@ class ApiElementBuilder extends _BaseElementBuilder {
if (body.isGenerator) {
element.generator = true;
}
- if (_inFunction) {
- Block enclosingBlock = node.getAncestor((node) => node is Block);
- if (enclosingBlock != null) {
- element.setVisibleRange(enclosingBlock.offset, enclosingBlock.length);
- }
- }
element.type = new FunctionTypeImpl(element);
element.hasImplicitReturnType = true;
_currentHolder.addFunction(element);
@@ -490,13 +447,7 @@ class ApiElementBuilder extends _BaseElementBuilder {
Object visitMethodDeclaration(MethodDeclaration node) {
try {
ElementHolder holder = new ElementHolder();
- bool wasInFunction = _inFunction;
- _inFunction = true;
- try {
- _visitChildren(holder, node);
- } finally {
- _inFunction = wasInFunction;
- }
+ _visitChildren(holder, node);
bool isStatic = node.isStatic;
Token property = node.propertyKeyword;
FunctionBody body = node.body;
@@ -726,10 +677,8 @@ class ApiElementBuilder extends _BaseElementBuilder {
}
/**
- * Build the table mapping field names to field elements for the fields defined in the current
- * class.
- *
- * @param fields the field elements defined in the current class
+ * Build the table mapping field names to field elements for the [fields]
+ * defined in the current class.
*/
void _buildFieldMap(List<FieldElement> fields) {
_fieldMap = new HashMap<String, FieldElement>();
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/incremental_resolver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698