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