Chromium Code Reviews| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 public class Context { | 94 public class Context { |
| 95 /** | 95 /** |
| 96 * Information about constructor and its usages. | 96 * Information about constructor and its usages. |
| 97 */ | 97 */ |
| 98 public static class ConstructorDescription { | 98 public static class ConstructorDescription { |
| 99 final IMethodBinding binding; | 99 final IMethodBinding binding; |
| 100 public final List<RedirectingConstructorInvocation> redirectingInvocations = Lists.newArrayList(); | 100 public final List<RedirectingConstructorInvocation> redirectingInvocations = Lists.newArrayList(); |
| 101 public final List<SuperConstructorInvocation> superInvocations = Lists.newAr rayList(); | 101 public final List<SuperConstructorInvocation> superInvocations = Lists.newAr rayList(); |
| 102 public final List<InstanceCreationExpression> instanceCreations = Lists.newA rrayList(); | 102 public final List<InstanceCreationExpression> instanceCreations = Lists.newA rrayList(); |
| 103 public boolean isEnum; | 103 public boolean isEnum; |
| 104 public boolean insertEnclosingTypeRef; | |
| 104 String declName; | 105 String declName; |
| 105 | 106 |
| 106 public ConstructorDescription(IMethodBinding binding) { | 107 public ConstructorDescription(IMethodBinding binding) { |
| 107 this.binding = binding; | 108 this.binding = binding; |
| 108 } | 109 } |
| 109 } | 110 } |
| 110 | 111 |
| 111 private static final String[] JAVA_EXTENSION = {"java"}; | 112 private static final String[] JAVA_EXTENSION = {"java"}; |
| 112 private final List<File> classpathFiles = Lists.newArrayList(); | 113 private final List<File> classpathFiles = Lists.newArrayList(); |
| 113 private final List<File> sourceFolders = Lists.newArrayList(); | 114 private final List<File> sourceFolders = Lists.newArrayList(); |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 546 * @return the artificial {@link ClassDeclaration}created for Java creation of anonymous class | 547 * @return the artificial {@link ClassDeclaration}created for Java creation of anonymous class |
| 547 * declaration. | 548 * declaration. |
| 548 */ | 549 */ |
| 549 public ClassDeclaration getAnonymousDeclaration(InstanceCreationExpression cre ation) { | 550 public ClassDeclaration getAnonymousDeclaration(InstanceCreationExpression cre ation) { |
| 550 return anonymousDeclarations.get(creation); | 551 return anonymousDeclarations.get(creation); |
| 551 } | 552 } |
| 552 | 553 |
| 553 /** | 554 /** |
| 554 * @return the not <code>null</code> {@link ConstructorDescription}, may be ju st added. | 555 * @return the not <code>null</code> {@link ConstructorDescription}, may be ju st added. |
| 555 */ | 556 */ |
| 557 public ConstructorDescription getConstructorDescription(ConstructorDeclaration node) { | |
| 558 IMethodBinding binding = constructorToBinding.get(node); | |
| 559 return getConstructorDescription(binding); | |
| 560 } | |
| 561 | |
| 562 /** | |
| 563 * @return the not <code>null</code> {@link ConstructorDescription}, may be ju st added. | |
| 564 */ | |
| 556 public ConstructorDescription getConstructorDescription(IMethodBinding binding ) { | 565 public ConstructorDescription getConstructorDescription(IMethodBinding binding ) { |
| 557 ConstructorDescription description = bindingToConstructor.get(binding); | 566 ConstructorDescription description = bindingToConstructor.get(binding); |
| 558 if (description == null) { | 567 if (description == null) { |
| 559 description = new ConstructorDescription(binding); | 568 description = new ConstructorDescription(binding); |
| 560 bindingToConstructor.put(binding, description); | 569 bindingToConstructor.put(binding, description); |
| 561 } | 570 } |
| 562 return description; | 571 return description; |
| 563 } | 572 } |
| 564 | 573 |
| 565 public Map<File, List<CompilationUnitMember>> getFileToMembers() { | 574 public Map<File, List<CompilationUnitMember>> getFileToMembers() { |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 683 { | 692 { |
| 684 replaceInnerClassReferences(dartUniverse); | 693 replaceInnerClassReferences(dartUniverse); |
| 685 unwrapVarArgIfAlreadyArray(dartUniverse); | 694 unwrapVarArgIfAlreadyArray(dartUniverse); |
| 686 ensureFieldInitializers(dartUniverse); | 695 ensureFieldInitializers(dartUniverse); |
| 687 dontUseThisInFieldInitializers(dartUniverse); | 696 dontUseThisInFieldInitializers(dartUniverse); |
| 688 ensureUniqueClassMemberNames(dartUniverse); | 697 ensureUniqueClassMemberNames(dartUniverse); |
| 689 ensureNoVariableNameReferenceFromInitializer(dartUniverse); | 698 ensureNoVariableNameReferenceFromInitializer(dartUniverse); |
| 690 ensureMethodParameterDoesNotHide(dartUniverse); | 699 ensureMethodParameterDoesNotHide(dartUniverse); |
| 691 new ConstructorSemanticProcessor(this).process(dartUniverse); | 700 new ConstructorSemanticProcessor(this).process(dartUniverse); |
| 692 renameConstructors(dartUniverse); | 701 renameConstructors(dartUniverse); |
| 702 insertEnclosingTypeForInstanceCreationArguments(dartUniverse); | |
| 693 } | 703 } |
| 694 // done | 704 // done |
| 695 return dartUniverse; | 705 return dartUniverse; |
| 696 } | 706 } |
| 697 | 707 |
| 698 /** | 708 /** |
| 699 * @return the "technical" name for the top-level Dart class for Java anonymou s class. | 709 * @return the "technical" name for the top-level Dart class for Java anonymou s class. |
| 700 */ | 710 */ |
| 701 int generateTechnicalAnonymousClassIndex() { | 711 int generateTechnicalAnonymousClassIndex() { |
| 702 return technicalAnonymousClassIndex++; | 712 return technicalAnonymousClassIndex++; |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1011 } | 1021 } |
| 1012 memberNamesInClass.add(name); | 1022 memberNamesInClass.add(name); |
| 1013 // apply name | 1023 // apply name |
| 1014 renameConstructor(node, name); | 1024 renameConstructor(node, name); |
| 1015 // continue | 1025 // continue |
| 1016 return super.visitConstructorDeclaration(node); | 1026 return super.visitConstructorDeclaration(node); |
| 1017 } | 1027 } |
| 1018 }); | 1028 }); |
| 1019 } | 1029 } |
| 1020 | 1030 |
| 1031 // XXX | |
|
Brian Wilkerson
2013/08/07 20:31:29
Remove?
| |
| 1032 private void insertEnclosingTypeForInstanceCreationArguments(CompilationUnit u nit) { | |
| 1033 unit.accept(new RecursiveASTVisitor<Void>() { | |
| 1034 @Override | |
| 1035 public Void visitInstanceCreationExpression(InstanceCreationExpression nod e) { | |
| 1036 IMethodBinding binding = (IMethodBinding) getNodeBinding(node); | |
| 1037 ConstructorDescription constructorDescription = getConstructorDescriptio n(binding); | |
| 1038 if (constructorDescription.insertEnclosingTypeRef) { | |
| 1039 node.getArgumentList().getArguments().add(0, thisExpression()); | |
| 1040 } | |
| 1041 return super.visitInstanceCreationExpression(node); | |
| 1042 } | |
| 1043 }); | |
| 1044 } | |
| 1045 | |
| 1021 private void replaceInnerClassReferences(CompilationUnit unit) { | 1046 private void replaceInnerClassReferences(CompilationUnit unit) { |
| 1022 for (SimpleIdentifier identifier : innerClassNames) { | 1047 for (SimpleIdentifier identifier : innerClassNames) { |
| 1023 renameIdentifier(identifier, identifier.getName()); | 1048 renameIdentifier(identifier, identifier.getName()); |
| 1024 } | 1049 } |
| 1025 } | 1050 } |
| 1026 | 1051 |
| 1027 /** | 1052 /** |
| 1028 * Translate {@link #sourceFiles} into Dart AST in {@link #dartUnits}. | 1053 * Translate {@link #sourceFiles} into Dart AST in {@link #dartUnits}. |
| 1029 */ | 1054 */ |
| 1030 private void translateSyntax() throws Exception { | 1055 private void translateSyntax() throws Exception { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1089 } | 1114 } |
| 1090 } | 1115 } |
| 1091 } | 1116 } |
| 1092 } | 1117 } |
| 1093 } | 1118 } |
| 1094 } | 1119 } |
| 1095 } | 1120 } |
| 1096 }); | 1121 }); |
| 1097 } | 1122 } |
| 1098 } | 1123 } |
| OLD | NEW |