| 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 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 | 613 |
| 614 /** | 614 /** |
| 615 * @return all references (actual references and declarations) | 615 * @return all references (actual references and declarations) |
| 616 */ | 616 */ |
| 617 public List<SimpleIdentifier> getReferences(SimpleIdentifier target) { | 617 public List<SimpleIdentifier> getReferences(SimpleIdentifier target) { |
| 618 Object binding = nodeToBinding.get(target); | 618 Object binding = nodeToBinding.get(target); |
| 619 List<SimpleIdentifier> references = bindingToIdentifiers.get(binding); | 619 List<SimpleIdentifier> references = bindingToIdentifiers.get(binding); |
| 620 return references != null ? references : Lists.<SimpleIdentifier> newArrayLi
st(); | 620 return references != null ? references : Lists.<SimpleIdentifier> newArrayLi
st(); |
| 621 } | 621 } |
| 622 | 622 |
| 623 /** |
| 624 * Remembers that "identifier" is reference to the given Java binding. |
| 625 */ |
| 626 public void putReference(SimpleIdentifier identifier, IBinding binding, String
bindingSignature) { |
| 627 if (binding != null) { |
| 628 signatureToBinding.put(bindingSignature, binding); |
| 629 identifierToName.put(identifier, identifier.getName()); |
| 630 // remember binding for reference |
| 631 nodeToBinding.put(identifier, binding); |
| 632 // add reference to binding |
| 633 List<SimpleIdentifier> identifiers = bindingToIdentifiers.get(binding); |
| 634 if (identifiers == null) { |
| 635 identifiers = Lists.newLinkedList(); |
| 636 bindingToIdentifiers.put(binding, identifiers); |
| 637 } |
| 638 identifiers.add(identifier); |
| 639 } |
| 640 // remember global name |
| 641 usedNames.add(identifier.getName()); |
| 642 } |
| 643 |
| 623 public void renameConstructor(ConstructorDeclaration node, String name) { | 644 public void renameConstructor(ConstructorDeclaration node, String name) { |
| 624 IMethodBinding binding = constructorToBinding.get(node); | 645 IMethodBinding binding = constructorToBinding.get(node); |
| 625 // | 646 // |
| 626 SimpleIdentifier newIdentifier; | 647 SimpleIdentifier newIdentifier; |
| 627 if (name == null) { | 648 if (name == null) { |
| 628 newIdentifier = null; | 649 newIdentifier = null; |
| 629 } else { | 650 } else { |
| 630 newIdentifier = identifier(name); | 651 newIdentifier = identifier(name); |
| 631 } | 652 } |
| 632 // rename constructor | 653 // rename constructor |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 nodeToTypeBinding.put(node, binding); | 787 nodeToTypeBinding.put(node, binding); |
| 767 } | 788 } |
| 768 | 789 |
| 769 /** | 790 /** |
| 770 * Remembers that given {@link ClassMember} was created for private Java eleme
nt. | 791 * Remembers that given {@link ClassMember} was created for private Java eleme
nt. |
| 771 */ | 792 */ |
| 772 void putPrivateClassMember(ClassMember member) { | 793 void putPrivateClassMember(ClassMember member) { |
| 773 privateClassMembers.add(member); | 794 privateClassMembers.add(member); |
| 774 } | 795 } |
| 775 | 796 |
| 776 /** | |
| 777 * Remembers that "identifier" is reference to the given Java binding. | |
| 778 */ | |
| 779 void putReference(SimpleIdentifier identifier, IBinding binding, String bindin
gSignature) { | |
| 780 if (binding != null) { | |
| 781 signatureToBinding.put(bindingSignature, binding); | |
| 782 identifierToName.put(identifier, identifier.getName()); | |
| 783 // remember binding for reference | |
| 784 nodeToBinding.put(identifier, binding); | |
| 785 // add reference to binding | |
| 786 List<SimpleIdentifier> identifiers = bindingToIdentifiers.get(binding); | |
| 787 if (identifiers == null) { | |
| 788 identifiers = Lists.newLinkedList(); | |
| 789 bindingToIdentifiers.put(binding, identifiers); | |
| 790 } | |
| 791 identifiers.add(identifier); | |
| 792 } | |
| 793 // remember global name | |
| 794 usedNames.add(identifier.getName()); | |
| 795 } | |
| 796 | |
| 797 private void dontUseThisInFieldInitializers(CompilationUnit unit) { | 797 private void dontUseThisInFieldInitializers(CompilationUnit unit) { |
| 798 unit.accept(new RecursiveASTVisitor<Void>() { | 798 unit.accept(new RecursiveASTVisitor<Void>() { |
| 799 @Override | 799 @Override |
| 800 public Void visitClassDeclaration(ClassDeclaration node) { | 800 public Void visitClassDeclaration(ClassDeclaration node) { |
| 801 processClass(node); | 801 processClass(node); |
| 802 return super.visitClassDeclaration(node); | 802 return super.visitClassDeclaration(node); |
| 803 } | 803 } |
| 804 | 804 |
| 805 private void addAssignmentsToBlock(Block block, Map<SimpleIdentifier, Expr
ession> initializers) { | 805 private void addAssignmentsToBlock(Block block, Map<SimpleIdentifier, Expr
ession> initializers) { |
| 806 int index = 0; | 806 int index = 0; |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1116 } | 1116 } |
| 1117 } | 1117 } |
| 1118 } | 1118 } |
| 1119 } | 1119 } |
| 1120 } | 1120 } |
| 1121 } | 1121 } |
| 1122 } | 1122 } |
| 1123 }); | 1123 }); |
| 1124 } | 1124 } |
| 1125 } | 1125 } |
| OLD | NEW |