OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012, the Dart project authors. | 2 * Copyright (c) 2012, 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 |
(...skipping 20 matching lines...) Expand all Loading... |
31 import com.google.dart.engine.ast.FieldDeclaration; | 31 import com.google.dart.engine.ast.FieldDeclaration; |
32 import com.google.dart.engine.ast.ForEachStatement; | 32 import com.google.dart.engine.ast.ForEachStatement; |
33 import com.google.dart.engine.ast.FormalParameter; | 33 import com.google.dart.engine.ast.FormalParameter; |
34 import com.google.dart.engine.ast.FormalParameterList; | 34 import com.google.dart.engine.ast.FormalParameterList; |
35 import com.google.dart.engine.ast.Identifier; | 35 import com.google.dart.engine.ast.Identifier; |
36 import com.google.dart.engine.ast.InstanceCreationExpression; | 36 import com.google.dart.engine.ast.InstanceCreationExpression; |
37 import com.google.dart.engine.ast.ListLiteral; | 37 import com.google.dart.engine.ast.ListLiteral; |
38 import com.google.dart.engine.ast.MethodDeclaration; | 38 import com.google.dart.engine.ast.MethodDeclaration; |
39 import com.google.dart.engine.ast.MethodInvocation; | 39 import com.google.dart.engine.ast.MethodInvocation; |
40 import com.google.dart.engine.ast.NodeList; | 40 import com.google.dart.engine.ast.NodeList; |
| 41 import com.google.dart.engine.ast.PropertyAccess; |
41 import com.google.dart.engine.ast.SimpleIdentifier; | 42 import com.google.dart.engine.ast.SimpleIdentifier; |
42 import com.google.dart.engine.ast.SuperConstructorInvocation; | 43 import com.google.dart.engine.ast.SuperConstructorInvocation; |
43 import com.google.dart.engine.ast.ThisExpression; | 44 import com.google.dart.engine.ast.ThisExpression; |
44 import com.google.dart.engine.ast.VariableDeclaration; | 45 import com.google.dart.engine.ast.VariableDeclaration; |
45 import com.google.dart.engine.ast.VariableDeclarationList; | 46 import com.google.dart.engine.ast.VariableDeclarationList; |
46 import com.google.dart.engine.ast.visitor.GeneralizingASTVisitor; | 47 import com.google.dart.engine.ast.visitor.GeneralizingASTVisitor; |
47 import com.google.dart.engine.ast.visitor.RecursiveASTVisitor; | 48 import com.google.dart.engine.ast.visitor.RecursiveASTVisitor; |
48 import com.google.dart.engine.scanner.Keyword; | 49 import com.google.dart.engine.scanner.Keyword; |
49 import com.google.dart.engine.scanner.KeywordToken; | 50 import com.google.dart.engine.scanner.KeywordToken; |
50 import com.google.dart.engine.scanner.TokenType; | 51 import com.google.dart.engine.scanner.TokenType; |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 methodNames = null; | 270 methodNames = null; |
270 try { | 271 try { |
271 return super.visitMethodDeclaration(node); | 272 return super.visitMethodDeclaration(node); |
272 } finally { | 273 } finally { |
273 methodNames = null; | 274 methodNames = null; |
274 } | 275 } |
275 } | 276 } |
276 | 277 |
277 @Override | 278 @Override |
278 public Void visitSimpleIdentifier(SimpleIdentifier node) { | 279 public Void visitSimpleIdentifier(SimpleIdentifier node) { |
279 hasNameReference |= node.getName().equals(currentVariableName); | 280 if (node.getName().equals(currentVariableName)) { |
280 return super.visitSimpleIdentifier(node); | 281 ASTNode parent = node.getParent(); |
| 282 // name() |
| 283 if (parent instanceof MethodInvocation) { |
| 284 MethodInvocation invocation = (MethodInvocation) parent; |
| 285 if (invocation.getMethodName() == node) { |
| 286 // name = target.name() |
| 287 if (invocation.getTarget() != null) { |
| 288 return null; |
| 289 } |
| 290 // name = name() |
| 291 hasNameReference = true; |
| 292 return null; |
| 293 } |
| 294 } |
| 295 // name = target.name |
| 296 if (parent instanceof PropertyAccess) { |
| 297 PropertyAccess propertyAccess = (PropertyAccess) parent; |
| 298 if (propertyAccess.getPropertyName() == node && propertyAccess.getTa
rget() != null) { |
| 299 return null; |
| 300 } |
| 301 } |
| 302 // name = name_whichWasGetMethod_butNowGetter |
| 303 { |
| 304 Object bindingObject = getNodeBinding(node); |
| 305 if (bindingObject instanceof IMethodBinding) { |
| 306 SyntaxTranslator.replaceNode(parent, node, propertyAccess(thisExpr
ession(), node)); |
| 307 return null; |
| 308 } |
| 309 } |
| 310 // OK, this is really conflict |
| 311 hasNameReference = true; |
| 312 } |
| 313 return null; |
281 } | 314 } |
282 | 315 |
283 @Override | 316 @Override |
284 public Void visitVariableDeclaration(VariableDeclaration node) { | 317 public Void visitVariableDeclaration(VariableDeclaration node) { |
285 String oldVariableName = currentVariableName; | 318 String oldVariableName = currentVariableName; |
286 try { | 319 try { |
287 currentVariableName = node.getName().getName(); | 320 currentVariableName = node.getName().getName(); |
288 hasNameReference = false; | 321 hasNameReference = false; |
289 Expression initializer = node.getInitializer(); | 322 Expression initializer = node.getInitializer(); |
290 if (initializer != null) { | 323 if (initializer != null) { |
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1039 } | 1072 } |
1040 } | 1073 } |
1041 } | 1074 } |
1042 } | 1075 } |
1043 } | 1076 } |
1044 } | 1077 } |
1045 } | 1078 } |
1046 }); | 1079 }); |
1047 } | 1080 } |
1048 } | 1081 } |
OLD | NEW |