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

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

Issue 17932005: New analyzer_experimental snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Disable resolver tests Created 7 years, 5 months 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
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
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 14
15 package com.google.dart.java2dart; 15 package com.google.dart.java2dart;
16 16
17 import com.google.common.collect.ImmutableMap; 17 import com.google.common.collect.ImmutableMap;
18 import com.google.common.collect.Lists; 18 import com.google.common.collect.Lists;
19 import com.google.common.collect.Maps; 19 import com.google.common.collect.Maps;
20 import com.google.common.collect.Sets; 20 import com.google.common.collect.Sets;
21 import com.google.common.io.Files;
21 import com.google.dart.engine.ast.ASTNode; 22 import com.google.dart.engine.ast.ASTNode;
22 import com.google.dart.engine.ast.ArgumentList; 23 import com.google.dart.engine.ast.ArgumentList;
23 import com.google.dart.engine.ast.Block; 24 import com.google.dart.engine.ast.Block;
24 import com.google.dart.engine.ast.BlockFunctionBody; 25 import com.google.dart.engine.ast.BlockFunctionBody;
25 import com.google.dart.engine.ast.ClassDeclaration; 26 import com.google.dart.engine.ast.ClassDeclaration;
26 import com.google.dart.engine.ast.ClassMember; 27 import com.google.dart.engine.ast.ClassMember;
27 import com.google.dart.engine.ast.CompilationUnit; 28 import com.google.dart.engine.ast.CompilationUnit;
28 import com.google.dart.engine.ast.CompilationUnitMember; 29 import com.google.dart.engine.ast.CompilationUnitMember;
29 import com.google.dart.engine.ast.ConstructorDeclaration; 30 import com.google.dart.engine.ast.ConstructorDeclaration;
30 import com.google.dart.engine.ast.Expression; 31 import com.google.dart.engine.ast.Expression;
(...skipping 26 matching lines...) Expand all
57 import static com.google.dart.java2dart.util.ASTFactory.blockFunctionBody; 58 import static com.google.dart.java2dart.util.ASTFactory.blockFunctionBody;
58 import static com.google.dart.java2dart.util.ASTFactory.compilationUnit; 59 import static com.google.dart.java2dart.util.ASTFactory.compilationUnit;
59 import static com.google.dart.java2dart.util.ASTFactory.constructorDeclaration; 60 import static com.google.dart.java2dart.util.ASTFactory.constructorDeclaration;
60 import static com.google.dart.java2dart.util.ASTFactory.expressionStatement; 61 import static com.google.dart.java2dart.util.ASTFactory.expressionStatement;
61 import static com.google.dart.java2dart.util.ASTFactory.formalParameterList; 62 import static com.google.dart.java2dart.util.ASTFactory.formalParameterList;
62 import static com.google.dart.java2dart.util.ASTFactory.identifier; 63 import static com.google.dart.java2dart.util.ASTFactory.identifier;
63 import static com.google.dart.java2dart.util.ASTFactory.propertyAccess; 64 import static com.google.dart.java2dart.util.ASTFactory.propertyAccess;
64 import static com.google.dart.java2dart.util.ASTFactory.thisExpression; 65 import static com.google.dart.java2dart.util.ASTFactory.thisExpression;
65 import static com.google.dart.java2dart.util.TokenFactory.token; 66 import static com.google.dart.java2dart.util.TokenFactory.token;
66 67
68 import org.apache.commons.io.Charsets;
67 import org.apache.commons.io.FileUtils; 69 import org.apache.commons.io.FileUtils;
68 import org.apache.commons.lang3.ArrayUtils; 70 import org.apache.commons.lang3.ArrayUtils;
69 import org.eclipse.core.runtime.Assert; 71 import org.eclipse.core.runtime.Assert;
70 import org.eclipse.jdt.core.JavaCore; 72 import org.eclipse.jdt.core.JavaCore;
71 import org.eclipse.jdt.core.dom.AST; 73 import org.eclipse.jdt.core.dom.AST;
72 import org.eclipse.jdt.core.dom.ASTParser; 74 import org.eclipse.jdt.core.dom.ASTParser;
73 import org.eclipse.jdt.core.dom.FileASTRequestor; 75 import org.eclipse.jdt.core.dom.FileASTRequestor;
74 import org.eclipse.jdt.core.dom.IBinding; 76 import org.eclipse.jdt.core.dom.IBinding;
75 import org.eclipse.jdt.core.dom.IMethodBinding; 77 import org.eclipse.jdt.core.dom.IMethodBinding;
76 import org.eclipse.jdt.core.dom.ITypeBinding; 78 import org.eclipse.jdt.core.dom.ITypeBinding;
(...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 parser.setCompilerOptions(ImmutableMap.of( 948 parser.setCompilerOptions(ImmutableMap.of(
947 JavaCore.COMPILER_SOURCE, 949 JavaCore.COMPILER_SOURCE,
948 JavaCore.VERSION_1_5, 950 JavaCore.VERSION_1_5,
949 JavaCore.COMPILER_DOC_COMMENT_SUPPORT, 951 JavaCore.COMPILER_DOC_COMMENT_SUPPORT,
950 JavaCore.ENABLED)); 952 JavaCore.ENABLED));
951 // do parse 953 // do parse
952 final Map<File, CompilationUnit> units = Maps.newLinkedHashMap(); 954 final Map<File, CompilationUnit> units = Maps.newLinkedHashMap();
953 parser.createASTs(paths, null, ArrayUtils.EMPTY_STRING_ARRAY, new FileASTReq uestor() { 955 parser.createASTs(paths, null, ArrayUtils.EMPTY_STRING_ARRAY, new FileASTReq uestor() {
954 @Override 956 @Override
955 public void acceptAST(String sourceFilePath, org.eclipse.jdt.core.dom.Comp ilationUnit javaUnit) { 957 public void acceptAST(String sourceFilePath, org.eclipse.jdt.core.dom.Comp ilationUnit javaUnit) {
956 File astFile = pathToFile.get(sourceFilePath); 958 try {
957 CompilationUnit dartUnit = SyntaxTranslator.translate(Context.this, java Unit); 959 File astFile = pathToFile.get(sourceFilePath);
958 units.put(astFile, dartUnit); 960 String javaSource = Files.toString(astFile, Charsets.UTF_8);
961 CompilationUnit dartUnit = SyntaxTranslator.translate(Context.this, ja vaUnit, javaSource);
962 units.put(astFile, dartUnit);
963 } catch (Throwable e) {
964 throw new Error(e);
965 }
959 } 966 }
960 }, 967 },
961 null); 968 null);
962 return units; 969 return units;
963 } 970 }
964 971
965 private void renameConstructors(CompilationUnit unit) { 972 private void renameConstructors(CompilationUnit unit) {
966 unit.accept(new RecursiveASTVisitor<Void>() { 973 unit.accept(new RecursiveASTVisitor<Void>() {
967 private final Set<String> memberNamesInClass = Sets.newHashSet(); 974 private final Set<String> memberNamesInClass = Sets.newHashSet();
968 private int numConstructors; 975 private int numConstructors;
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 } 1098 }
1092 } 1099 }
1093 } 1100 }
1094 } 1101 }
1095 } 1102 }
1096 } 1103 }
1097 } 1104 }
1098 }); 1105 });
1099 } 1106 }
1100 } 1107 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698