OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013, the Dart project authors. | 2 * Copyright (c) 2013, the Dart project authors. |
3 * | 3 * |
4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except | 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except |
5 * in compliance with the License. You may obtain a copy of the License at | 5 * in compliance with the License. You may obtain a copy of the License at |
6 * | 6 * |
7 * http://www.eclipse.org/legal/epl-v10.html | 7 * http://www.eclipse.org/legal/epl-v10.html |
8 * | 8 * |
9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License | 9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License |
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express | 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express |
11 * or implied. See the License for the specific language governing permissions a
nd limitations under | 11 * or implied. See the License for the specific language governing permissions a
nd limitations under |
12 * the License. | 12 * the License. |
13 */ | 13 */ |
14 package com.google.dart.engine.internal.resolver; | 14 package com.google.dart.engine.internal.resolver; |
15 | 15 |
16 import com.google.dart.engine.ast.AstNode; | 16 import com.google.dart.engine.ast.AstNode; |
17 import com.google.dart.engine.ast.ConstructorName; | 17 import com.google.dart.engine.ast.ConstructorName; |
18 import com.google.dart.engine.ast.ExportDirective; | 18 import com.google.dart.engine.ast.ExportDirective; |
19 import com.google.dart.engine.ast.FunctionDeclaration; | 19 import com.google.dart.engine.ast.FunctionDeclaration; |
20 import com.google.dart.engine.ast.FunctionExpression; | 20 import com.google.dart.engine.ast.FunctionExpression; |
21 import com.google.dart.engine.ast.ImportDirective; | 21 import com.google.dart.engine.ast.ImportDirective; |
22 import com.google.dart.engine.ast.Label; | 22 import com.google.dart.engine.ast.Label; |
| 23 import com.google.dart.engine.ast.MethodDeclaration; |
23 import com.google.dart.engine.ast.MethodInvocation; | 24 import com.google.dart.engine.ast.MethodInvocation; |
24 import com.google.dart.engine.ast.PrefixedIdentifier; | 25 import com.google.dart.engine.ast.PrefixedIdentifier; |
25 import com.google.dart.engine.ast.PropertyAccess; | 26 import com.google.dart.engine.ast.PropertyAccess; |
26 import com.google.dart.engine.ast.SimpleIdentifier; | 27 import com.google.dart.engine.ast.SimpleIdentifier; |
27 import com.google.dart.engine.element.Element; | 28 import com.google.dart.engine.element.Element; |
28 import com.google.dart.engine.element.ElementKind; | 29 import com.google.dart.engine.element.ElementKind; |
29 import com.google.dart.engine.element.ExecutableElement; | 30 import com.google.dart.engine.element.ExecutableElement; |
30 import com.google.dart.engine.element.LibraryElement; | 31 import com.google.dart.engine.element.LibraryElement; |
31 import com.google.dart.engine.element.VariableElement; | 32 import com.google.dart.engine.element.VariableElement; |
32 import com.google.dart.engine.error.AnalysisErrorListener; | 33 import com.google.dart.engine.error.AnalysisErrorListener; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 return super.visitFunctionExpression(node); | 117 return super.visitFunctionExpression(node); |
117 } | 118 } |
118 } | 119 } |
119 | 120 |
120 @Override | 121 @Override |
121 public Void visitImportDirective(ImportDirective node) { | 122 public Void visitImportDirective(ImportDirective node) { |
122 return null; | 123 return null; |
123 } | 124 } |
124 | 125 |
125 @Override | 126 @Override |
| 127 public Void visitMethodDeclaration(MethodDeclaration node) { |
| 128 ExecutableElement outerFunction = enclosingFunction; |
| 129 try { |
| 130 enclosingFunction = node.getElement(); |
| 131 return super.visitMethodDeclaration(node); |
| 132 } finally { |
| 133 enclosingFunction = outerFunction; |
| 134 } |
| 135 } |
| 136 |
| 137 @Override |
126 public Void visitSimpleIdentifier(SimpleIdentifier node) { | 138 public Void visitSimpleIdentifier(SimpleIdentifier node) { |
127 // Ignore if already resolved - declaration or type. | 139 // Ignore if already resolved - declaration or type. |
128 if (node.getStaticElement() != null) { | 140 if (node.getStaticElement() != null) { |
129 return null; | 141 return null; |
130 } | 142 } |
131 // Ignore if qualified. | 143 // Ignore if qualified. |
132 AstNode parent = node.getParent(); | 144 AstNode parent = node.getParent(); |
133 if (parent instanceof PrefixedIdentifier | 145 if (parent instanceof PrefixedIdentifier |
134 && ((PrefixedIdentifier) parent).getIdentifier() == node) { | 146 && ((PrefixedIdentifier) parent).getIdentifier() == node) { |
135 return null; | 147 return null; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 // If we are in some closure, check if it is not the same as where varia
ble is declared. | 182 // If we are in some closure, check if it is not the same as where varia
ble is declared. |
171 if (enclosingFunction != null | 183 if (enclosingFunction != null |
172 && !ObjectUtilities.equals(element.getEnclosingElement(), enclosingF
unction)) { | 184 && !ObjectUtilities.equals(element.getEnclosingElement(), enclosingF
unction)) { |
173 parameterImpl.markPotentiallyMutatedInClosure(); | 185 parameterImpl.markPotentiallyMutatedInClosure(); |
174 } | 186 } |
175 } | 187 } |
176 } | 188 } |
177 return null; | 189 return null; |
178 } | 190 } |
179 } | 191 } |
OLD | NEW |