This commit is contained in:
Sergey Ignatov
2011-10-31 20:39:07 +04:00
parent 48bd6cf017
commit ef3abfd10d
22 changed files with 55 additions and 61 deletions
+1 -1
View File
@@ -36,7 +36,7 @@ public class Converter {
return result; return result;
} }
public static Class classToClass(PsiClass psiClass) { private static Class classToClass(PsiClass psiClass) {
final List<Function> methods = methodsToFunctionList(psiClass.getMethods(), true); final List<Function> methods = methodsToFunctionList(psiClass.getMethods(), true);
final List<Class> innerClasses = classesToClassList(psiClass.getAllInnerClasses()); final List<Class> innerClasses = classesToClassList(psiClass.getAllInnerClasses());
@@ -6,15 +6,9 @@ import org.jetbrains.annotations.NotNull;
* @author ignatov * @author ignatov
*/ */
public class AssignmentExpression extends Expression { public class AssignmentExpression extends Expression {
private Expression myLeft; private final Expression myLeft;
private Expression myRight; private final Expression myRight;
private String myOp; private final String myOp;
public AssignmentExpression(Expression left, Expression right) {
myLeft = left;
myRight = right;
myOp = EQUAL;
}
public AssignmentExpression(Expression left, Expression right, String op) { public AssignmentExpression(Expression left, Expression right, String op) {
myLeft = left; myLeft = left;
@@ -6,9 +6,9 @@ import org.jetbrains.annotations.NotNull;
* @author ignatov * @author ignatov
*/ */
public class BinaryExpression extends Expression { public class BinaryExpression extends Expression {
private Expression myLeft; private final Expression myLeft;
private Expression myRight; private final Expression myRight;
private String myOp; private final String myOp;
public BinaryExpression(Expression left, Expression right, String op) { public BinaryExpression(Expression left, Expression right, String op) {
myLeft = left; myLeft = left;
+6 -6
View File
@@ -10,11 +10,11 @@ import java.util.List;
* @author ignatov * @author ignatov
*/ */
public class Class extends Node { public class Class extends Node {
protected String TYPE = "class"; String TYPE = "class";
protected Identifier myName; final Identifier myName;
protected List<Class> myInnerClasses; final List<Class> myInnerClasses;
protected List<Function> myMethods; final List<Function> myMethods;
protected List<Field> myFields; final List<Field> myFields;
public Class(Identifier name, List<Class> innerClasses, List<Function> methods, List<Field> fields) { public Class(Identifier name, List<Class> innerClasses, List<Function> methods, List<Field> fields) {
myName = name; myName = name;
@@ -24,7 +24,7 @@ public class Class extends Node {
} }
@NotNull @NotNull
protected List<Function> methodsExceptConstructors() { List<Function> methodsExceptConstructors() {
final LinkedList<Function> result = new LinkedList<Function>(); final LinkedList<Function> result = new LinkedList<Function>();
for (Function m : myMethods) for (Function m : myMethods)
if (m.getKind() != Kind.CONSTRUCTOR) if (m.getKind() != Kind.CONSTRUCTOR)
+1 -1
View File
@@ -6,7 +6,7 @@ import org.jetbrains.annotations.NotNull;
* @author ignatov * @author ignatov
*/ */
public class ClassType extends Type { public class ClassType extends Type {
private Identifier myType; private final Identifier myType;
public ClassType(Identifier type) { public ClassType(Identifier type) {
myType = type; myType = type;
@@ -10,7 +10,7 @@ import java.util.List;
* @author ignatov * @author ignatov
*/ */
public class DeclarationStatement extends Statement { public class DeclarationStatement extends Statement {
private List<Element> myElements; private final List<Element> myElements;
public DeclarationStatement(List<Element> elements) { public DeclarationStatement(List<Element> elements) {
myElements = elements; myElements = elements;
@@ -6,9 +6,9 @@ import org.jetbrains.annotations.NotNull;
* @author ignatov * @author ignatov
*/ */
public class DummyMethodCallExpression extends Expression { public class DummyMethodCallExpression extends Expression {
private Expression myWho; private final Expression myWho;
private String myMethodName; private final String myMethodName;
private Expression myWhat; private final Expression myWhat;
public DummyMethodCallExpression(Expression who, String methodName, Expression what) { public DummyMethodCallExpression(Expression who, String methodName, Expression what) {
myWho = who; myWho = who;
@@ -9,7 +9,7 @@ import java.util.List;
* @author ignatov * @author ignatov
*/ */
public class ExpressionList extends Expression { public class ExpressionList extends Expression {
private List<Expression> myExpressions; private final List<Expression> myExpressions;
private List<Type> myTypes; // TODO: add types to toKotlin private List<Type> myTypes; // TODO: add types to toKotlin
public ExpressionList(List<Expression> expressions, List<Type> types) { public ExpressionList(List<Expression> expressions, List<Type> types) {
@@ -9,7 +9,7 @@ import java.util.List;
* @author ignatov * @author ignatov
*/ */
public class ExpressionListStatement extends Expression { public class ExpressionListStatement extends Expression {
private List<Expression> myExpressions; private final List<Expression> myExpressions;
public ExpressionListStatement(List<Expression> expressions) { public ExpressionListStatement(List<Expression> expressions) {
myExpressions = expressions; myExpressions = expressions;
+3 -3
View File
@@ -6,9 +6,9 @@ import org.jetbrains.annotations.NotNull;
* @author ignatov * @author ignatov
*/ */
public class Field extends Node { public class Field extends Node {
protected Identifier myIdentifier; final Identifier myIdentifier;
protected Type myType; private final Type myType;
protected Element myInitializer; final Element myInitializer;
public Field(Identifier identifier, Type type, Element initializer) { public Field(Identifier identifier, Type type, Element initializer) {
myIdentifier = identifier; myIdentifier = identifier;
+3 -3
View File
@@ -9,9 +9,9 @@ import java.util.List;
* @author ignatov * @author ignatov
*/ */
public class File extends Node { public class File extends Node {
private String myPackageName; private final String myPackageName;
private List<Import> myImports; private final List<Import> myImports;
private List<Class> myClasses; private final List<Class> myClasses;
public File(String packageName, List<Import> imports, List<Class> classes) { public File(String packageName, List<Import> imports, List<Class> classes) {
myPackageName = packageName; myPackageName = packageName;
+4 -4
View File
@@ -6,10 +6,10 @@ import org.jetbrains.annotations.NotNull;
* @author ignatov * @author ignatov
*/ */
public class Function extends Node { public class Function extends Node {
private Identifier myName; private final Identifier myName;
private Type myType; private final Type myType;
protected Element myParams; final Element myParams;
private Block myBlock; private final Block myBlock;
public Function(Identifier name, Type type, Element params, Block block) { public Function(Identifier name, Type type, Element params, Block block) {
myName = name; myName = name;
+1 -1
View File
@@ -6,7 +6,7 @@ import org.jetbrains.annotations.NotNull;
* @author ignatov * @author ignatov
*/ */
public class Import extends Node { public class Import extends Node {
private String myName; private final String myName;
public Import(String name) { public Import(String name) {
myName = name; myName = name;
@@ -6,7 +6,7 @@ import org.jetbrains.annotations.NotNull;
* @author ignatov * @author ignatov
*/ */
public class LiteralExpression extends Expression { public class LiteralExpression extends Expression {
private Identifier myIdentifier; private final Identifier myIdentifier;
public LiteralExpression(Identifier identifier) { public LiteralExpression(Identifier identifier) {
myIdentifier = identifier; myIdentifier = identifier;
@@ -6,9 +6,9 @@ import org.jetbrains.annotations.NotNull;
* @author ignatov * @author ignatov
*/ */
public class LocalVariable extends Expression { public class LocalVariable extends Expression {
private Identifier myIdentifier; private final Identifier myIdentifier;
private Type myType; private final Type myType;
private Expression myInitializer; private final Expression myInitializer;
public LocalVariable(Identifier identifier, Type type, Expression initializer) { public LocalVariable(Identifier identifier, Type type, Expression initializer) {
myIdentifier = identifier; myIdentifier = identifier;
@@ -6,8 +6,8 @@ import org.jetbrains.annotations.NotNull;
* @author ignatov * @author ignatov
*/ */
public class MethodCallExpression extends Expression { public class MethodCallExpression extends Expression {
private Expression myMethodCall; private final Expression myMethodCall;
private Element myParamList; private final Element myParamList;
public MethodCallExpression(Expression methodCall, Element paramList) { public MethodCallExpression(Expression methodCall, Element paramList) {
myMethodCall = methodCall; myMethodCall = methodCall;
+2 -2
View File
@@ -6,8 +6,8 @@ import org.jetbrains.annotations.NotNull;
* @author ignatov * @author ignatov
*/ */
public class Parameter extends Expression { public class Parameter extends Expression {
private IdentifierImpl myIdentifier; private final IdentifierImpl myIdentifier;
private Type myType; private final Type myType;
public Parameter(IdentifierImpl identifier, Type type) { public Parameter(IdentifierImpl identifier, Type type) {
myIdentifier = identifier; myIdentifier = identifier;
@@ -9,7 +9,7 @@ import java.util.List;
* @author ignatov * @author ignatov
*/ */
public class ParameterList extends Expression { public class ParameterList extends Expression {
private List<Parameter> myParameters; private final List<Parameter> myParameters;
public ParameterList(List<Parameter> parameters) { public ParameterList(List<Parameter> parameters) {
myParameters = parameters; myParameters = parameters;
@@ -6,7 +6,7 @@ import org.jetbrains.annotations.NotNull;
* @author ignatov * @author ignatov
*/ */
public class PrimitiveType extends Type { public class PrimitiveType extends Type {
private Identifier myType; private final Identifier myType;
public PrimitiveType(Identifier type) { public PrimitiveType(Identifier type) {
myType = type; myType = type;
@@ -6,7 +6,7 @@ import org.jetbrains.annotations.NotNull;
* @author ignatov * @author ignatov
*/ */
public class ReturnStatement extends Statement { public class ReturnStatement extends Statement {
private Expression myExpression; private final Expression myExpression;
public ReturnStatement(Expression expression) { public ReturnStatement(Expression expression) {
myExpression = expression; myExpression = expression;
+1 -1
View File
@@ -6,7 +6,7 @@ import org.jetbrains.annotations.NotNull;
* @author ignatov * @author ignatov
*/ */
public abstract class Statement extends Element { public abstract class Statement extends Element {
public static Statement EMPTY_STATEMENT = new EmptyStatement(); public static final Statement EMPTY_STATEMENT = new EmptyStatement();
/** /**
* @author ignatov * @author ignatov
+12 -12
View File
@@ -22,14 +22,14 @@ import java.util.List;
*/ */
public abstract class JetTestCaseBase extends LightDaemonAnalyzerTestCase { public abstract class JetTestCaseBase extends LightDaemonAnalyzerTestCase {
private boolean checkInfos = false; private boolean checkInfos = false;
private String dataPath; private final String dataPath;
protected final String name; private final String name;
protected JetTestCaseBase() { protected JetTestCaseBase() {
this("", ""); this("", "");
} }
public JetTestCaseBase(String dataPath, String name) { private JetTestCaseBase(String dataPath, String name) {
this.dataPath = dataPath; this.dataPath = dataPath;
this.name = name; this.name = name;
} }
@@ -39,7 +39,7 @@ public abstract class JetTestCaseBase extends LightDaemonAnalyzerTestCase {
return this; return this;
} }
public static Sdk jdkFromIdeaHome() { private static Sdk jdkFromIdeaHome() {
return new JavaSdkImpl().createJdk("JDK", "compiler/testData/mockJDK-1.7/jre", true); return new JavaSdkImpl().createJdk("JDK", "compiler/testData/mockJDK-1.7/jre", true);
} }
@@ -48,11 +48,11 @@ public abstract class JetTestCaseBase extends LightDaemonAnalyzerTestCase {
return getTestDataPathBase(); return getTestDataPathBase();
} }
public static String getTestDataPathBase() { private static String getTestDataPathBase() {
return getHomeDirectory() + "/compiler/testData"; return getHomeDirectory() + "/compiler/testData";
} }
public static String getHomeDirectory() { private static String getHomeDirectory() {
return new File(PathManager.getResourceRoot(JetTestCaseBase.class, "/org/jetbrains/jet/JetTestCaseBase.class")).getParentFile().getParentFile().getParent(); return new File(PathManager.getResourceRoot(JetTestCaseBase.class, "/org/jetbrains/jet/JetTestCaseBase.class")).getParentFile().getParentFile().getParent();
} }
@@ -80,7 +80,7 @@ public abstract class JetTestCaseBase extends LightDaemonAnalyzerTestCase {
return dataPath; return dataPath;
} }
protected void configureFromText(String text) throws IOException { void configureFromText(String text) throws IOException {
configureFromFileText("test.java", text); configureFromFileText("test.java", text);
} }
@@ -101,12 +101,12 @@ public abstract class JetTestCaseBase extends LightDaemonAnalyzerTestCase {
return toSingleLine(classToKotlin(text)); return toSingleLine(classToKotlin(text));
} }
protected String fileToKotlin(String text) throws IOException { String fileToKotlin(String text) throws IOException {
configureFromText(text); configureFromText(text);
return prettify(Converter.fileToFile((PsiJavaFile) myFile).toKotlin()); return prettify(Converter.fileToFile((PsiJavaFile) myFile).toKotlin());
} }
protected String methodToKotlin(String text) throws IOException { String methodToKotlin(String text) throws IOException {
String result = classToKotlin("class C {" + text + "}") String result = classToKotlin("class C {" + text + "}")
.replaceAll("class C \\{", ""); .replaceAll("class C \\{", "");
result = result.substring(0, result.lastIndexOf("}")); result = result.substring(0, result.lastIndexOf("}"));
@@ -144,7 +144,7 @@ public abstract class JetTestCaseBase extends LightDaemonAnalyzerTestCase {
} }
@NotNull @NotNull
public static TestSuite suiteForDirectory(String baseDataDir, @NotNull final String dataPath, boolean recursive, @NotNull NamedTestFactory factory) { private static TestSuite suiteForDirectory(String baseDataDir, @NotNull final String dataPath, boolean recursive, @NotNull NamedTestFactory factory) {
TestSuite suite = new TestSuite(dataPath); TestSuite suite = new TestSuite(dataPath);
final String extension = ".jet"; final String extension = ".jet";
FilenameFilter extensionFilter = new FilenameFilter() { FilenameFilter extensionFilter = new FilenameFilter() {
@@ -180,7 +180,7 @@ public abstract class JetTestCaseBase extends LightDaemonAnalyzerTestCase {
} }
@NotNull @NotNull
protected static String prettify(String code) { private static String prettify(String code) {
if (code == null) if (code == null)
return ""; return "";
return code return code
@@ -194,7 +194,7 @@ public abstract class JetTestCaseBase extends LightDaemonAnalyzerTestCase {
} }
@NotNull @NotNull
protected static String toSingleLine(String string) { static String toSingleLine(String string) {
return prettify(string.replaceAll("\n", " ")); return prettify(string.replaceAll("\n", " "));
} }
} }