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

Side by Side Diff: editor/util/plugins/com.google.dart.java2dart/src/com/google/dart/java2dart/Context.java

Issue 109853003: New analyzer snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixes for review comments. Created 7 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | editor/util/plugins/com.google.dart.java2dart/src/com/google/dart/java2dart/SyntaxTranslator.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 26 matching lines...) Expand all
37 import com.google.dart.engine.ast.MethodInvocation; 37 import com.google.dart.engine.ast.MethodInvocation;
38 import com.google.dart.engine.ast.NodeList; 38 import com.google.dart.engine.ast.NodeList;
39 import com.google.dart.engine.ast.RedirectingConstructorInvocation; 39 import com.google.dart.engine.ast.RedirectingConstructorInvocation;
40 import com.google.dart.engine.ast.SimpleIdentifier; 40 import com.google.dart.engine.ast.SimpleIdentifier;
41 import com.google.dart.engine.ast.SuperConstructorInvocation; 41 import com.google.dart.engine.ast.SuperConstructorInvocation;
42 import com.google.dart.engine.ast.ThisExpression; 42 import com.google.dart.engine.ast.ThisExpression;
43 import com.google.dart.engine.ast.VariableDeclaration; 43 import com.google.dart.engine.ast.VariableDeclaration;
44 import com.google.dart.engine.ast.VariableDeclarationList; 44 import com.google.dart.engine.ast.VariableDeclarationList;
45 import com.google.dart.engine.ast.visitor.GeneralizingASTVisitor; 45 import com.google.dart.engine.ast.visitor.GeneralizingASTVisitor;
46 import com.google.dart.engine.ast.visitor.RecursiveASTVisitor; 46 import com.google.dart.engine.ast.visitor.RecursiveASTVisitor;
47 import com.google.dart.engine.ast.visitor.UnifyingASTVisitor;
47 import com.google.dart.engine.scanner.Keyword; 48 import com.google.dart.engine.scanner.Keyword;
48 import com.google.dart.engine.scanner.KeywordToken; 49 import com.google.dart.engine.scanner.KeywordToken;
49 import com.google.dart.engine.scanner.TokenType; 50 import com.google.dart.engine.scanner.TokenType;
50 import com.google.dart.java2dart.processor.ConstructorSemanticProcessor; 51 import com.google.dart.java2dart.processor.ConstructorSemanticProcessor;
51 import com.google.dart.java2dart.processor.LocalVariablesSemanticProcessor; 52 import com.google.dart.java2dart.processor.LocalVariablesSemanticProcessor;
52 import com.google.dart.java2dart.util.Bindings; 53 import com.google.dart.java2dart.util.Bindings;
53 import com.google.dart.java2dart.util.JavaUtils; 54 import com.google.dart.java2dart.util.JavaUtils;
54 55
55 import static com.google.dart.java2dart.util.ASTFactory.assignmentExpression; 56 import static com.google.dart.java2dart.util.ASTFactory.assignmentExpression;
56 import static com.google.dart.java2dart.util.ASTFactory.block; 57 import static com.google.dart.java2dart.util.ASTFactory.block;
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 /** 208 /**
208 * @return {@code true} if the method with the given signature (which could be made getter or 209 * @return {@code true} if the method with the given signature (which could be made getter or
209 * setter) is allowed to be converted into getter/setter. 210 * setter) is allowed to be converted into getter/setter.
210 */ 211 */
211 public boolean canMakeProperty(SimpleIdentifier identifier) { 212 public boolean canMakeProperty(SimpleIdentifier identifier) {
212 IBinding binding = getNodeBinding(identifier); 213 IBinding binding = getNodeBinding(identifier);
213 String signature = JavaUtils.getJdtSignature(binding); 214 String signature = JavaUtils.getJdtSignature(binding);
214 return !notPropertySet.contains(signature); 215 return !notPropertySet.contains(signature);
215 } 216 }
216 217
218 /**
219 * Clears information about the given {@link ASTNode} and its children.
220 */
221 public void clearNodes(ASTNode node) {
222 if (node != null) {
223 node.accept(new UnifyingASTVisitor<Void>() {
224 @Override
225 public Void visitNode(ASTNode node) {
226 clearNode(node);
227 return super.visitNode(node);
228 }
229 });
230 }
231 }
232
217 public void ensureUniqueClassMemberNames(CompilationUnit unit) { 233 public void ensureUniqueClassMemberNames(CompilationUnit unit) {
218 unit.accept(new RecursiveASTVisitor<Void>() { 234 unit.accept(new RecursiveASTVisitor<Void>() {
219 private final Set<ClassMember> untouchableMethods = Sets.newHashSet(); 235 private final Set<ClassMember> untouchableMethods = Sets.newHashSet();
220 private final Map<String, ClassMember> usedClassMembers = Maps.newHashMap( ); 236 private final Map<String, ClassMember> usedClassMembers = Maps.newHashMap( );
221 private final Set<String> superNames = Sets.newHashSet(); 237 private final Set<String> superNames = Sets.newHashSet();
222 private final Map<String, List<IMethodBinding>> superMembers = Maps.newHas hMap(); 238 private final Map<String, List<IMethodBinding>> superMembers = Maps.newHas hMap();
223 239
224 @Override 240 @Override
225 public Void visitClassDeclaration(ClassDeclaration node) { 241 public Void visitClassDeclaration(ClassDeclaration node) {
226 untouchableMethods.clear(); 242 untouchableMethods.clear();
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 if (identifiers == null) { 501 if (identifiers == null) {
486 identifiers = Lists.newLinkedList(); 502 identifiers = Lists.newLinkedList();
487 bindingToIdentifiers.put(binding, identifiers); 503 bindingToIdentifiers.put(binding, identifiers);
488 } 504 }
489 identifiers.add(identifier); 505 identifiers.add(identifier);
490 } 506 }
491 // remember global name 507 // remember global name
492 usedNames.add(identifier.getName()); 508 usedNames.add(identifier.getName());
493 } 509 }
494 510
511 /**
512 * Removes recorded identifier reference.
513 */
514 public void removeReference(SimpleIdentifier identifier) {
515 IBinding binding = getNodeBinding(identifier);
516 List<SimpleIdentifier> identifiers = bindingToIdentifiers.get(binding);
517 if (identifiers != null) {
518 identifiers.remove(identifier);
519 }
520 }
521
495 public void renameConstructor(ConstructorDeclaration node, String name) { 522 public void renameConstructor(ConstructorDeclaration node, String name) {
496 IMethodBinding binding = constructorToBinding.get(node); 523 IMethodBinding binding = constructorToBinding.get(node);
497 // 524 //
498 SimpleIdentifier newIdentifier; 525 SimpleIdentifier newIdentifier;
499 if (name == null) { 526 if (name == null) {
500 newIdentifier = null; 527 newIdentifier = null;
501 } else { 528 } else {
502 newIdentifier = identifier(name); 529 newIdentifier = identifier(name);
503 } 530 }
504 // rename constructor 531 // rename constructor
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 nodeToTypeBinding.put(node, binding); 664 nodeToTypeBinding.put(node, binding);
638 } 665 }
639 666
640 /** 667 /**
641 * Remembers that given {@link ClassMember} was created for private Java eleme nt. 668 * Remembers that given {@link ClassMember} was created for private Java eleme nt.
642 */ 669 */
643 void putPrivateClassMember(ClassMember member) { 670 void putPrivateClassMember(ClassMember member) {
644 privateClassMembers.add(member); 671 privateClassMembers.add(member);
645 } 672 }
646 673
674 /**
675 * Clears information about the given {@link ASTNode}.
676 */
677 private void clearNode(ASTNode node) {
678 if (node instanceof SimpleIdentifier) {
679 removeReference((SimpleIdentifier) node);
680 }
681 nodeToBinding.remove(node);
682 nodeToTypeBinding.remove(node);
683 }
684
647 private void dontUseThisInFieldInitializers(CompilationUnit unit) { 685 private void dontUseThisInFieldInitializers(CompilationUnit unit) {
648 unit.accept(new RecursiveASTVisitor<Void>() { 686 unit.accept(new RecursiveASTVisitor<Void>() {
649 @Override 687 @Override
650 public Void visitClassDeclaration(ClassDeclaration node) { 688 public Void visitClassDeclaration(ClassDeclaration node) {
651 processClass(node); 689 processClass(node);
652 return super.visitClassDeclaration(node); 690 return super.visitClassDeclaration(node);
653 } 691 }
654 692
655 private void addAssignmentsToBlock(Block block, Map<SimpleIdentifier, Expr ession> initializers) { 693 private void addAssignmentsToBlock(Block block, Map<SimpleIdentifier, Expr ession> initializers) {
656 int index = 0; 694 int index = 0;
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 } 981 }
944 } 982 }
945 } 983 }
946 } 984 }
947 } 985 }
948 } 986 }
949 } 987 }
950 }); 988 });
951 } 989 }
952 } 990 }
OLDNEW
« no previous file with comments | « no previous file | editor/util/plugins/com.google.dart.java2dart/src/com/google/dart/java2dart/SyntaxTranslator.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698