infer nullity
This commit is contained in:
@@ -18,6 +18,7 @@ import java.util.*;
|
||||
* @author ignatov
|
||||
*/
|
||||
public class Converter {
|
||||
@NotNull
|
||||
private final static Set<String> NOT_NULL_ANNOTATIONS = new HashSet<String>() {
|
||||
{
|
||||
add("org.jetbrains.annotations.NotNull");
|
||||
@@ -29,10 +30,11 @@ public class Converter {
|
||||
@NotNull private static final Dispatcher ourDispatcher = new Dispatcher();
|
||||
@Nullable private static PsiType ourMethodReturnType = null;
|
||||
|
||||
public static void setClassIdentifiers(Set<String> identifiers) {
|
||||
public static void setClassIdentifiers(@NotNull Set<String> identifiers) {
|
||||
ourClassIdentifiers = identifiers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Set<String> getClassIdentifiers() {
|
||||
return new HashSet<String>(ourClassIdentifiers);
|
||||
}
|
||||
@@ -82,7 +84,8 @@ public class Converter {
|
||||
return new AnonymousClass(getMembers(anonymousClass));
|
||||
}
|
||||
|
||||
private static List<Member> getMembers(PsiClass psiClass) {
|
||||
@NotNull
|
||||
private static List<Member> getMembers(@NotNull PsiClass psiClass) {
|
||||
List<Member> members = new LinkedList<Member>();
|
||||
for (PsiElement e : psiClass.getChildren()) {
|
||||
if (e instanceof PsiMethod) members.add(methodToFunction((PsiMethod) e, true));
|
||||
@@ -224,7 +227,7 @@ public class Converter {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Initializer initializerToInitializer(PsiClassInitializer i) {
|
||||
private static Initializer initializerToInitializer(@NotNull PsiClassInitializer i) {
|
||||
return new Initializer(
|
||||
blockToBlock(i.getBody(), true),
|
||||
modifiersListToModifiersSet(i.getModifierList())
|
||||
@@ -345,7 +348,7 @@ public class Converter {
|
||||
);
|
||||
}
|
||||
|
||||
private static boolean isNotOpenMethod(final PsiMethod method) {
|
||||
private static boolean isNotOpenMethod(@NotNull final PsiMethod method) {
|
||||
if (method.getParent() instanceof PsiClass) {
|
||||
final PsiModifierList parentModifierList = ((PsiClass) method.getParent()).getModifierList();
|
||||
if ((parentModifierList != null && parentModifierList.hasExplicitModifier(Modifier.FINAL)) || ((PsiClass) method.getParent()).isEnum())
|
||||
@@ -454,6 +457,7 @@ public class Converter {
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Type typeToType(PsiType type, boolean notNull) {
|
||||
Type result = typeToType(type);
|
||||
if (notNull)
|
||||
@@ -516,7 +520,7 @@ public class Converter {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isReadOnly(PsiParameter parameter) {
|
||||
private static boolean isReadOnly(@NotNull PsiParameter parameter) {
|
||||
for (PsiReference r : (ReferencesSearch.search(parameter))) {
|
||||
if (r instanceof PsiExpression && PsiUtil.isAccessedForWriting((PsiExpression) r)) {
|
||||
return false;
|
||||
@@ -532,7 +536,7 @@ public class Converter {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Set<String> modifiersListToModifiersSet(PsiModifierList modifierList) {
|
||||
public static Set<String> modifiersListToModifiersSet(@Nullable PsiModifierList modifierList) {
|
||||
HashSet<String> modifiersSet = new HashSet<String>();
|
||||
if (modifierList != null) {
|
||||
if (modifierList.hasExplicitModifier(PsiModifier.ABSTRACT)) modifiersSet.add(Modifier.ABSTRACT);
|
||||
|
||||
@@ -25,7 +25,8 @@ public class ArrayInitializerExpression extends Expression {
|
||||
return AstUtil.lowerFirstCharacter(type.convertedToNotNull().toKotlin());
|
||||
}
|
||||
|
||||
private static String innerTypeStr(final Type type) {
|
||||
@NotNull
|
||||
private static String innerTypeStr(@NotNull final Type type) {
|
||||
return type.convertedToNotNull().toKotlin().replace("Array", "").toLowerCase();
|
||||
}
|
||||
|
||||
@@ -38,7 +39,7 @@ public class ArrayInitializerExpression extends Expression {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String explicitConvertIfNeeded(final Type type, @NotNull final Expression i) {
|
||||
private static String explicitConvertIfNeeded(@NotNull final Type type, @NotNull final Expression i) {
|
||||
Set<String> doubleOrFloatTypes = new HashSet<String>(
|
||||
Arrays.asList("double", "float", "java.lang.double", "java.lang.float")
|
||||
);
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.util.List;
|
||||
* @author ignatov
|
||||
*/
|
||||
public class Block extends Statement {
|
||||
@NotNull
|
||||
public final static Block EMPTY_BLOCK = new Block();
|
||||
|
||||
private List<Statement> myStatements;
|
||||
|
||||
@@ -13,7 +13,7 @@ public class CaseContainer extends Statement {
|
||||
private List<Statement> myCaseStatement;
|
||||
private Block myBlock;
|
||||
|
||||
public CaseContainer(final List<Statement> caseStatement, final List<Statement> statements) {
|
||||
public CaseContainer(final List<Statement> caseStatement, @NotNull final List<Statement> statements) {
|
||||
myCaseStatement = caseStatement;
|
||||
List<Statement> newStatements = new LinkedList<Statement>();
|
||||
for (Statement s : statements)
|
||||
|
||||
@@ -15,6 +15,7 @@ import static org.jetbrains.jet.j2k.util.AstUtil.*;
|
||||
* @author ignatov
|
||||
*/
|
||||
public class Class extends Member {
|
||||
@NotNull
|
||||
String TYPE = "class";
|
||||
final Identifier myName;
|
||||
private final List<Expression> myBaseClassParams;
|
||||
@@ -65,6 +66,7 @@ public class Class extends Member {
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
String typeParameterWhereToKotlin() {
|
||||
if (hasWhere()) {
|
||||
List<String> wheres = new LinkedList<String>();
|
||||
@@ -118,6 +120,7 @@ public class Class extends Member {
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
String typeParametersToKotlin() {
|
||||
return myTypeParameters.size() > 0 ? "<" + AstUtil.joinNodes(myTypeParameters, COMMA_WITH_SPACE) + ">" : EMPTY;
|
||||
}
|
||||
@@ -131,6 +134,7 @@ public class Class extends Member {
|
||||
return nodesToKotlin(myExtendsTypes);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
String implementTypesToKotlin() {
|
||||
List<String> allTypes = new LinkedList<String>() {
|
||||
{
|
||||
@@ -141,6 +145,7 @@ public class Class extends Member {
|
||||
return allTypes.size() == 0 ? EMPTY : SPACE + COLON + SPACE + join(allTypes, COMMA_WITH_SPACE);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
String modifiersToKotlin() {
|
||||
List<String> modifierList = new LinkedList<String>();
|
||||
|
||||
@@ -166,6 +171,7 @@ public class Class extends Member {
|
||||
return isAbstract();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
String bodyToKotlin() {
|
||||
return SPACE + "{" + N +
|
||||
primaryConstructorBodyToKotlin() + N +
|
||||
@@ -174,7 +180,8 @@ public class Class extends Member {
|
||||
"}";
|
||||
}
|
||||
|
||||
private static List<Member> getStatic(List<? extends Member> members) {
|
||||
@NotNull
|
||||
private static List<Member> getStatic(@NotNull List<? extends Member> members) {
|
||||
List<Member> result = new LinkedList<Member>();
|
||||
for (Member m : members)
|
||||
if (m.isStatic())
|
||||
@@ -182,7 +189,8 @@ public class Class extends Member {
|
||||
return result;
|
||||
}
|
||||
|
||||
private static List<Member> getNonStatic(List<? extends Member> members) {
|
||||
@NotNull
|
||||
private static List<Member> getNonStatic(@NotNull List<? extends Member> members) {
|
||||
List<Member> result = new LinkedList<Member>();
|
||||
for (Member m : members)
|
||||
if (!m.isStatic())
|
||||
@@ -190,6 +198,7 @@ public class Class extends Member {
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String classObjectToKotlin() {
|
||||
final List<Member> staticMembers = new LinkedList<Member>(secondaryConstructorsAsStaticInitFunction());
|
||||
staticMembers.addAll(getStatic(membersExceptConstructors()));
|
||||
|
||||
@@ -16,10 +16,12 @@ public class Constructor extends Function {
|
||||
myIsPrimary = isPrimary;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String primarySignatureToKotlin() {
|
||||
return "(" + myParams.toKotlin() + ")";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String primaryBodyToKotlin() {
|
||||
return myBlock.toKotlin();
|
||||
}
|
||||
|
||||
@@ -16,7 +16,8 @@ public class DeclarationStatement extends Statement {
|
||||
myElements = elements;
|
||||
}
|
||||
|
||||
private static List<String> toStringList(List<Element> elements) {
|
||||
@NotNull
|
||||
private static List<String> toStringList(@NotNull List<Element> elements) {
|
||||
List<String> result = new LinkedList<String>();
|
||||
for (Element e : elements) {
|
||||
if (e instanceof LocalVariable) {
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
* @author ignatov
|
||||
*/
|
||||
public abstract class Element extends Node {
|
||||
@NotNull
|
||||
public static final Element EMPTY_ELEMENT = new EmptyElement();
|
||||
|
||||
public boolean isEmpty() {
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.util.Set;
|
||||
* @author ignatov
|
||||
*/
|
||||
public class EnumConstant extends Field {
|
||||
public EnumConstant(Identifier identifier, Set<String> modifiers, Type type, Element params) {
|
||||
public EnumConstant(Identifier identifier, Set<String> modifiers, @NotNull Type type, Element params) {
|
||||
super(identifier, modifiers, type.convertedToNotNull(), params);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
* @author ignatov
|
||||
*/
|
||||
public abstract class Expression extends Statement {
|
||||
@NotNull
|
||||
public static final Expression EMPTY_EXPRESSION = new EmptyExpression();
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,6 +36,7 @@ public class Field extends Member {
|
||||
return myType;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
String modifiersToKotlin() {
|
||||
List<String> modifierList = new LinkedList<String>();
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ public class Function extends Member {
|
||||
return myBlock;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String typeParametersToKotlin() {
|
||||
return myTypeParameters.size() > 0 ? "<" + AstUtil.joinNodes(myTypeParameters, COMMA_WITH_SPACE) + ">" : EMPTY;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package org.jetbrains.jet.j2k.ast;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author ignatov
|
||||
*/
|
||||
public interface Identifier extends INode {
|
||||
@NotNull
|
||||
public static Identifier EMPTY_IDENTIFIER = new IdentifierImpl("");
|
||||
|
||||
public boolean isEmpty();
|
||||
|
||||
@@ -36,6 +36,7 @@ public class IdentifierImpl extends Expression implements Identifier {
|
||||
return myName.length() == 0;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String quote(String str) {
|
||||
return BACKTICK + str + BACKTICK;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.jetbrains.jet.j2k.ast;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@@ -8,6 +10,7 @@ import java.util.Set;
|
||||
public abstract class Member extends Node implements IMember {
|
||||
Set<String> myModifiers;
|
||||
|
||||
@NotNull
|
||||
String accessModifier() {
|
||||
for (String m : myModifiers)
|
||||
if (m.equals(Modifier.PUBLIC) || m.equals(Modifier.PROTECTED) || m.equals(Modifier.PRIVATE))
|
||||
|
||||
@@ -1,17 +1,29 @@
|
||||
package org.jetbrains.jet.j2k.ast;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author ignatov
|
||||
*/
|
||||
public abstract class Modifier {
|
||||
@NotNull
|
||||
public static final String PUBLIC = "public";
|
||||
@NotNull
|
||||
public static final String PROTECTED = "protected";
|
||||
@NotNull
|
||||
public static final String PRIVATE = "private";
|
||||
@NotNull
|
||||
public static final String INTERNAL = "internal";
|
||||
@NotNull
|
||||
public static final String STATIC = "static";
|
||||
@NotNull
|
||||
public static final String ABSTRACT = "abstract";
|
||||
@NotNull
|
||||
public static final String FINAL = "final";
|
||||
@NotNull
|
||||
public static final String OPEN = "open";
|
||||
@NotNull
|
||||
public static final String NOT_OPEN = "not open";
|
||||
@NotNull
|
||||
public static final String OVERRIDE = "override";
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ public class NewClassExpression extends Expression {
|
||||
private final List<Expression> myArguments;
|
||||
private Expression myQualifier;
|
||||
private List<String> myConversions;
|
||||
@Nullable
|
||||
private AnonymousClass myAnonymousClass = null;
|
||||
|
||||
public NewClassExpression(Element name, List<Expression> arguments) {
|
||||
|
||||
@@ -16,28 +16,45 @@ public abstract class Node implements INode {
|
||||
return Kind.UNDEFINED;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
final static Set<String> ONLY_KOTLIN_KEYWORDS = new HashSet<String>(Arrays.asList(
|
||||
"namespace", "as", "type", "val", "var", "fun", "is", "in", "object", "when", "trait", "This"
|
||||
));
|
||||
|
||||
@NotNull
|
||||
public final static Set<String> PRIMITIVE_TYPES = new HashSet<String>(Arrays.asList(
|
||||
"double", "float", "long", "int", "short", "byte", "boolean", "char"
|
||||
));
|
||||
|
||||
static final String N = System.getProperty("line.separator");
|
||||
@NotNull
|
||||
static final String N2 = N + N;
|
||||
@NotNull
|
||||
static final String SPACE = " ";
|
||||
@NotNull
|
||||
static final String EQUAL = "=";
|
||||
@NotNull
|
||||
static final String EMPTY = "";
|
||||
@NotNull
|
||||
static final String DOT = ".";
|
||||
@NotNull
|
||||
static final String QUESTDOT = "?.";
|
||||
@NotNull
|
||||
static final String COLON = ":";
|
||||
@NotNull
|
||||
static final String IN = "in";
|
||||
@NotNull
|
||||
static final String AT = "@";
|
||||
@NotNull
|
||||
static final String DOLLAR = "$";
|
||||
@NotNull
|
||||
static final String BACKTICK = "`";
|
||||
@NotNull
|
||||
static final String QUEST = "?";
|
||||
@NotNull
|
||||
static final String COMMA_WITH_SPACE = "," + SPACE;
|
||||
@NotNull
|
||||
static final String STAR = "*";
|
||||
@NotNull
|
||||
public static final String ZERO = "0";
|
||||
}
|
||||
@@ -9,7 +9,9 @@ import java.util.List;
|
||||
* @author ignatov
|
||||
*/
|
||||
public class ReferenceElement extends Element {
|
||||
@NotNull
|
||||
private final Identifier myReference;
|
||||
@NotNull
|
||||
private final List<Type> myTypes;
|
||||
|
||||
public ReferenceElement(@NotNull Identifier reference, @NotNull List<Type> types) {
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
* @author ignatov
|
||||
*/
|
||||
public abstract class Statement extends Element {
|
||||
@NotNull
|
||||
public static final Statement EMPTY_STATEMENT = new EmptyStatement();
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
* @author ignatov
|
||||
*/
|
||||
public abstract class Type extends Element {
|
||||
@NotNull
|
||||
public static final Type EMPTY_TYPE = new EmptyType();
|
||||
boolean myNullable = true;
|
||||
|
||||
@@ -15,6 +16,7 @@ public abstract class Type extends Element {
|
||||
return Kind.TYPE;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Type convertedToNotNull() {
|
||||
myNullable = false;
|
||||
return this;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.jetbrains.jet.j2k.util;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.j2k.ast.Expression;
|
||||
import org.jetbrains.jet.j2k.ast.INode;
|
||||
|
||||
@@ -15,7 +16,7 @@ public class AstUtil {
|
||||
private AstUtil() {
|
||||
}
|
||||
|
||||
private static String join(final String[] array, final String delimiter) {
|
||||
private static String join(@NotNull final String[] array, @Nullable final String delimiter) {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
boolean haveDelimiter = (delimiter != null);
|
||||
|
||||
@@ -29,30 +30,34 @@ public class AstUtil {
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
public static String joinNodes(final List<? extends INode> nodes, final String delimiter) {
|
||||
public static String joinNodes(@NotNull final List<? extends INode> nodes, final String delimiter) {
|
||||
return join(nodesToKotlin(nodes), delimiter);
|
||||
}
|
||||
|
||||
public static String join(final List<String> array, final String delimiter) {
|
||||
public static String join(@NotNull final List<String> array, final String delimiter) {
|
||||
return join(array.toArray(new String[array.size()]), delimiter);
|
||||
}
|
||||
|
||||
public static List<String> nodesToKotlin(List<? extends INode> nodes) {
|
||||
@NotNull
|
||||
public static List<String> nodesToKotlin(@NotNull List<? extends INode> nodes) {
|
||||
List<String> result = new LinkedList<String>();
|
||||
for (INode n : nodes)
|
||||
result.add(n.toKotlin());
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String upperFirstCharacter(String string) {
|
||||
@NotNull
|
||||
public static String upperFirstCharacter(@NotNull String string) {
|
||||
return string.substring(0, 1).toUpperCase() + string.substring(1);
|
||||
}
|
||||
|
||||
public static String lowerFirstCharacter(String string) {
|
||||
@NotNull
|
||||
public static String lowerFirstCharacter(@NotNull String string) {
|
||||
return string.substring(0, 1).toLowerCase() + string.substring(1);
|
||||
}
|
||||
|
||||
public static List<String> createListWithEmptyString(final List<Expression> arguments) {
|
||||
@NotNull
|
||||
public static List<String> createListWithEmptyString(@NotNull final List<Expression> arguments) {
|
||||
final List<String> conversions = new LinkedList<String>();
|
||||
//noinspection UnusedDeclaration
|
||||
for (Expression argument : arguments) conversions.add("");
|
||||
@@ -77,7 +82,7 @@ public class AstUtil {
|
||||
return "(" + f + ")" + s;
|
||||
}
|
||||
|
||||
public static <T> T getOrElse(Map<T, T> map, T e, T orElse) {
|
||||
public static <T> T getOrElse(@NotNull Map<T, T> map, T e, T orElse) {
|
||||
if (map.containsKey(e))
|
||||
return map.get(e);
|
||||
return orElse;
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.jetbrains.jet.j2k.visitors;
|
||||
|
||||
import com.intellij.psi.JavaRecursiveElementVisitor;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
@@ -16,12 +17,13 @@ public class ClassVisitor extends JavaRecursiveElementVisitor {
|
||||
myClassIdentifiers = new HashSet<String>();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Set<String> getClassIdentifiers() {
|
||||
return new HashSet<String>(myClassIdentifiers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitClass(PsiClass aClass) {
|
||||
public void visitClass(@NotNull PsiClass aClass) {
|
||||
myClassIdentifiers.add(aClass.getQualifiedName());
|
||||
super.visitClass(aClass);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.jetbrains.jet.j2k.visitors;
|
||||
|
||||
import com.intellij.psi.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.j2k.Converter;
|
||||
import org.jetbrains.jet.j2k.ast.*;
|
||||
|
||||
@@ -13,6 +14,7 @@ import static org.jetbrains.jet.j2k.Converter.*;
|
||||
* @author ignatov
|
||||
*/
|
||||
public class ElementVisitor extends JavaElementVisitor {
|
||||
@Nullable
|
||||
private Element myResult = Element.EMPTY_ELEMENT;
|
||||
|
||||
@NotNull
|
||||
@@ -21,7 +23,7 @@ public class ElementVisitor extends JavaElementVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitLocalVariable(PsiLocalVariable variable) {
|
||||
public void visitLocalVariable(@NotNull PsiLocalVariable variable) {
|
||||
super.visitLocalVariable(variable);
|
||||
|
||||
myResult = new LocalVariable(
|
||||
@@ -33,7 +35,7 @@ public class ElementVisitor extends JavaElementVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitExpressionList(PsiExpressionList list) {
|
||||
public void visitExpressionList(@NotNull PsiExpressionList list) {
|
||||
super.visitExpressionList(list);
|
||||
myResult = new ExpressionList(
|
||||
expressionsToExpressionList(list.getExpressions()),
|
||||
@@ -42,7 +44,7 @@ public class ElementVisitor extends JavaElementVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitReferenceElement(PsiJavaCodeReferenceElement reference) {
|
||||
public void visitReferenceElement(@NotNull PsiJavaCodeReferenceElement reference) {
|
||||
super.visitReferenceElement(reference);
|
||||
|
||||
final List<Type> types = typesToTypeList(reference.getTypeParameters());
|
||||
@@ -67,13 +69,13 @@ public class ElementVisitor extends JavaElementVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitTypeElement(PsiTypeElement type) {
|
||||
public void visitTypeElement(@NotNull PsiTypeElement type) {
|
||||
super.visitTypeElement(type);
|
||||
myResult = new TypeElement(typeToType(type.getType()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitTypeParameter(PsiTypeParameter classParameter) {
|
||||
public void visitTypeParameter(@NotNull PsiTypeParameter classParameter) {
|
||||
super.visitTypeParameter(classParameter);
|
||||
myResult = new TypeParameter(
|
||||
new IdentifierImpl(classParameter.getName()), // TODO
|
||||
@@ -82,7 +84,7 @@ public class ElementVisitor extends JavaElementVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitParameterList(PsiParameterList list) {
|
||||
public void visitParameterList(@NotNull PsiParameterList list) {
|
||||
super.visitParameterList(list);
|
||||
myResult = new ParameterList(
|
||||
parametersToParameterList(list.getParameters())
|
||||
|
||||
@@ -16,6 +16,7 @@ import static org.jetbrains.jet.j2k.Converter.*;
|
||||
* @author ignatov
|
||||
*/
|
||||
public class ExpressionVisitor extends StatementVisitor {
|
||||
@Nullable
|
||||
Expression myResult = Expression.EMPTY_EXPRESSION;
|
||||
|
||||
@Override
|
||||
@@ -30,7 +31,7 @@ public class ExpressionVisitor extends StatementVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitArrayAccessExpression(PsiArrayAccessExpression expression) {
|
||||
public void visitArrayAccessExpression(@NotNull PsiArrayAccessExpression expression) {
|
||||
super.visitArrayAccessExpression(expression);
|
||||
myResult = new ArrayAccessExpression(
|
||||
expressionToExpression(expression.getArrayExpression()),
|
||||
@@ -39,7 +40,7 @@ public class ExpressionVisitor extends StatementVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitArrayInitializerExpression(PsiArrayInitializerExpression expression) {
|
||||
public void visitArrayInitializerExpression(@NotNull PsiArrayInitializerExpression expression) {
|
||||
super.visitArrayInitializerExpression(expression);
|
||||
myResult = new ArrayInitializerExpression(
|
||||
typeToType(expression.getType()),
|
||||
@@ -48,7 +49,7 @@ public class ExpressionVisitor extends StatementVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitAssignmentExpression(PsiAssignmentExpression expression) {
|
||||
public void visitAssignmentExpression(@NotNull PsiAssignmentExpression expression) {
|
||||
super.visitAssignmentExpression(expression);
|
||||
|
||||
// TODO: simplify
|
||||
@@ -111,7 +112,7 @@ public class ExpressionVisitor extends StatementVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitBinaryExpression(PsiBinaryExpression expression) {
|
||||
public void visitBinaryExpression(@NotNull PsiBinaryExpression expression) {
|
||||
super.visitBinaryExpression(expression);
|
||||
|
||||
if (expression.getOperationSign().getTokenType() == JavaTokenType.GTGTGT)
|
||||
@@ -129,13 +130,13 @@ public class ExpressionVisitor extends StatementVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitClassObjectAccessExpression(PsiClassObjectAccessExpression expression) {
|
||||
public void visitClassObjectAccessExpression(@NotNull PsiClassObjectAccessExpression expression) {
|
||||
super.visitClassObjectAccessExpression(expression);
|
||||
myResult = new ClassObjectAccessExpression(elementToElement(expression.getOperand()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitConditionalExpression(PsiConditionalExpression expression) {
|
||||
public void visitConditionalExpression(@NotNull PsiConditionalExpression expression) {
|
||||
super.visitConditionalExpression(expression);
|
||||
myResult = new ParenthesizedExpression(
|
||||
new IfStatement(
|
||||
@@ -147,13 +148,13 @@ public class ExpressionVisitor extends StatementVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitExpressionList(PsiExpressionList list) {
|
||||
public void visitExpressionList(@NotNull PsiExpressionList list) {
|
||||
super.visitExpressionList(list);
|
||||
myResult = new ExpressionList(expressionsToExpressionList(list.getExpressions()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitInstanceOfExpression(PsiInstanceOfExpression expression) {
|
||||
public void visitInstanceOfExpression(@NotNull PsiInstanceOfExpression expression) {
|
||||
super.visitInstanceOfExpression(expression);
|
||||
myResult = new IsOperator(
|
||||
expressionToExpression(expression.getOperand()),
|
||||
@@ -161,7 +162,7 @@ public class ExpressionVisitor extends StatementVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitLiteralExpression(PsiLiteralExpression expression) {
|
||||
public void visitLiteralExpression(@NotNull PsiLiteralExpression expression) {
|
||||
super.visitLiteralExpression(expression);
|
||||
|
||||
final Object value = expression.getValue();
|
||||
@@ -286,7 +287,7 @@ public class ExpressionVisitor extends StatementVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitNewExpression(PsiNewExpression expression) {
|
||||
public void visitNewExpression(@NotNull PsiNewExpression expression) {
|
||||
super.visitNewExpression(expression);
|
||||
|
||||
if (expression.getArrayInitializer() != null) // new Foo[] {}
|
||||
@@ -343,7 +344,7 @@ public class ExpressionVisitor extends StatementVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitParenthesizedExpression(PsiParenthesizedExpression expression) {
|
||||
public void visitParenthesizedExpression(@NotNull PsiParenthesizedExpression expression) {
|
||||
super.visitParenthesizedExpression(expression);
|
||||
myResult = new ParenthesizedExpression(
|
||||
expressionToExpression(expression.getExpression())
|
||||
@@ -351,7 +352,7 @@ public class ExpressionVisitor extends StatementVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitPostfixExpression(PsiPostfixExpression expression) {
|
||||
public void visitPostfixExpression(@NotNull PsiPostfixExpression expression) {
|
||||
super.visitPostfixExpression(expression);
|
||||
myResult = new PostfixOperator(
|
||||
getOperatorString(expression.getOperationSign().getTokenType()),
|
||||
@@ -360,7 +361,7 @@ public class ExpressionVisitor extends StatementVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitPrefixExpression(PsiPrefixExpression expression) {
|
||||
public void visitPrefixExpression(@NotNull PsiPrefixExpression expression) {
|
||||
super.visitPrefixExpression(expression);
|
||||
if (expression.getOperationTokenType() == JavaTokenType.TILDE)
|
||||
myResult = new DummyMethodCallExpression(
|
||||
@@ -374,7 +375,7 @@ public class ExpressionVisitor extends StatementVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitReferenceExpression(PsiReferenceExpression expression) {
|
||||
public void visitReferenceExpression(@NotNull PsiReferenceExpression expression) {
|
||||
super.visitReferenceExpression(expression);
|
||||
|
||||
final boolean isFieldReference = isFieldReference(expression, getContainingClass(expression));
|
||||
@@ -448,7 +449,7 @@ public class ExpressionVisitor extends StatementVisitor {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isInsideSecondaryConstructor(PsiReferenceExpression expression) {
|
||||
private static boolean isInsideSecondaryConstructor(@NotNull PsiReferenceExpression expression) {
|
||||
PsiElement context = expression.getContext();
|
||||
while (context != null) {
|
||||
if (context instanceof PsiMethod && ((PsiMethod) context).isConstructor())
|
||||
@@ -458,7 +459,7 @@ public class ExpressionVisitor extends StatementVisitor {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isInsidePrimaryConstructor(PsiExpression expression) {
|
||||
private static boolean isInsidePrimaryConstructor(@NotNull PsiExpression expression) {
|
||||
PsiElement context = expression.getContext();
|
||||
while (context != null) {
|
||||
if (context instanceof PsiMethod && ((PsiMethod) context).isConstructor())
|
||||
@@ -479,7 +480,7 @@ public class ExpressionVisitor extends StatementVisitor {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static boolean isThisExpression(PsiReferenceExpression expression) {
|
||||
private static boolean isThisExpression(@NotNull PsiReferenceExpression expression) {
|
||||
for (PsiReference r : expression.getReferences())
|
||||
if (r.getCanonicalText().equals("this")) {
|
||||
final PsiElement res = r.resolve();
|
||||
@@ -490,7 +491,7 @@ public class ExpressionVisitor extends StatementVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitSuperExpression(PsiSuperExpression expression) {
|
||||
public void visitSuperExpression(@NotNull PsiSuperExpression expression) {
|
||||
super.visitSuperExpression(expression);
|
||||
final PsiJavaCodeReferenceElement qualifier = expression.getQualifier();
|
||||
myResult = new SuperExpression(
|
||||
@@ -501,7 +502,7 @@ public class ExpressionVisitor extends StatementVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitThisExpression(PsiThisExpression expression) {
|
||||
public void visitThisExpression(@NotNull PsiThisExpression expression) {
|
||||
super.visitThisExpression(expression);
|
||||
final PsiJavaCodeReferenceElement qualifier = expression.getQualifier();
|
||||
myResult = new ThisExpression(
|
||||
@@ -512,7 +513,7 @@ public class ExpressionVisitor extends StatementVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitTypeCastExpression(PsiTypeCastExpression expression) {
|
||||
public void visitTypeCastExpression(@NotNull PsiTypeCastExpression expression) {
|
||||
super.visitTypeCastExpression(expression);
|
||||
|
||||
final PsiTypeElement castType = expression.getCastType();
|
||||
@@ -525,7 +526,7 @@ public class ExpressionVisitor extends StatementVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitPolyadicExpression(PsiPolyadicExpression expression) {
|
||||
public void visitPolyadicExpression(@NotNull PsiPolyadicExpression expression) {
|
||||
super.visitPolyadicExpression(expression);
|
||||
myResult = new PolyadicExpression(
|
||||
expressionsToExpressionList(expression.getOperands()),
|
||||
|
||||
@@ -31,7 +31,7 @@ public class StatementVisitor extends ElementVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitAssertStatement(PsiAssertStatement statement) {
|
||||
public void visitAssertStatement(@NotNull PsiAssertStatement statement) {
|
||||
super.visitAssertStatement(statement);
|
||||
myResult = new AssertStatement(
|
||||
expressionToExpression(statement.getAssertCondition()),
|
||||
@@ -40,7 +40,7 @@ public class StatementVisitor extends ElementVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitBlockStatement(PsiBlockStatement statement) {
|
||||
public void visitBlockStatement(@NotNull PsiBlockStatement statement) {
|
||||
super.visitBlockStatement(statement);
|
||||
myResult = new Block(
|
||||
statementsToStatementList(statement.getCodeBlock().getStatements()),
|
||||
@@ -49,7 +49,7 @@ public class StatementVisitor extends ElementVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitBreakStatement(PsiBreakStatement statement) {
|
||||
public void visitBreakStatement(@NotNull PsiBreakStatement statement) {
|
||||
super.visitBreakStatement(statement);
|
||||
if (statement.getLabelIdentifier() == null)
|
||||
myResult = new BreakStatement();
|
||||
@@ -60,7 +60,7 @@ public class StatementVisitor extends ElementVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitContinueStatement(PsiContinueStatement statement) {
|
||||
public void visitContinueStatement(@NotNull PsiContinueStatement statement) {
|
||||
super.visitContinueStatement(statement);
|
||||
if (statement.getLabelIdentifier() == null)
|
||||
myResult = new ContinueStatement();
|
||||
@@ -71,7 +71,7 @@ public class StatementVisitor extends ElementVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitDeclarationStatement(PsiDeclarationStatement statement) {
|
||||
public void visitDeclarationStatement(@NotNull PsiDeclarationStatement statement) {
|
||||
super.visitDeclarationStatement(statement);
|
||||
myResult = new DeclarationStatement(
|
||||
elementsToElementList(statement.getDeclaredElements())
|
||||
@@ -79,7 +79,7 @@ public class StatementVisitor extends ElementVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitDoWhileStatement(PsiDoWhileStatement statement) {
|
||||
public void visitDoWhileStatement(@NotNull PsiDoWhileStatement statement) {
|
||||
super.visitDoWhileStatement(statement);
|
||||
myResult = new DoWhileStatement(
|
||||
expressionToExpression(statement.getCondition()),
|
||||
@@ -88,13 +88,13 @@ public class StatementVisitor extends ElementVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitExpressionStatement(PsiExpressionStatement statement) {
|
||||
public void visitExpressionStatement(@NotNull PsiExpressionStatement statement) {
|
||||
super.visitExpressionStatement(statement);
|
||||
myResult = expressionToExpression(statement.getExpression());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitExpressionListStatement(PsiExpressionListStatement statement) {
|
||||
public void visitExpressionListStatement(@NotNull PsiExpressionListStatement statement) {
|
||||
super.visitExpressionListStatement(statement);
|
||||
myResult =
|
||||
new ExpressionListStatement(expressionsToExpressionList(statement.getExpressionList().getExpressions()));
|
||||
@@ -151,7 +151,7 @@ public class StatementVisitor extends ElementVisitor {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isOnceWritableIterator(PsiLocalVariable firstChild) {
|
||||
private static boolean isOnceWritableIterator(@Nullable PsiLocalVariable firstChild) {
|
||||
int counter = 0;
|
||||
if (firstChild != null)
|
||||
for (PsiReference r : (ReferencesSearch.search(firstChild))) {
|
||||
@@ -164,7 +164,7 @@ public class StatementVisitor extends ElementVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitForeachStatement(PsiForeachStatement statement) {
|
||||
public void visitForeachStatement(@NotNull PsiForeachStatement statement) {
|
||||
super.visitForeachStatement(statement);
|
||||
myResult = new ForeachStatement(
|
||||
parameterToParameter(statement.getIterationParameter()),
|
||||
@@ -174,7 +174,7 @@ public class StatementVisitor extends ElementVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitIfStatement(PsiIfStatement statement) {
|
||||
public void visitIfStatement(@NotNull PsiIfStatement statement) {
|
||||
super.visitIfStatement(statement);
|
||||
myResult = new IfStatement(
|
||||
expressionToExpression(statement.getCondition()),
|
||||
@@ -184,7 +184,7 @@ public class StatementVisitor extends ElementVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitLabeledStatement(PsiLabeledStatement statement) {
|
||||
public void visitLabeledStatement(@NotNull PsiLabeledStatement statement) {
|
||||
super.visitLabeledStatement(statement);
|
||||
myResult = new LabelStatement(
|
||||
identifierToIdentifier(statement.getLabelIdentifier()),
|
||||
@@ -193,7 +193,7 @@ public class StatementVisitor extends ElementVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitSwitchLabelStatement(PsiSwitchLabelStatement statement) {
|
||||
public void visitSwitchLabelStatement(@NotNull PsiSwitchLabelStatement statement) {
|
||||
super.visitSwitchLabelStatement(statement);
|
||||
myResult = statement.isDefaultCase() ?
|
||||
new DefaultSwitchLabelStatement() :
|
||||
@@ -201,7 +201,7 @@ public class StatementVisitor extends ElementVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitSwitchStatement(PsiSwitchStatement statement) {
|
||||
public void visitSwitchStatement(@NotNull PsiSwitchStatement statement) {
|
||||
super.visitSwitchStatement(statement);
|
||||
myResult = new SwitchContainer(
|
||||
expressionToExpression(statement.getExpression()),
|
||||
@@ -253,6 +253,7 @@ public class StatementVisitor extends ElementVisitor {
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static List<PsiStatement> getAllToNextBreak(@NotNull final List<PsiStatement> allStatements, final int start) {
|
||||
List<PsiStatement> result = new LinkedList<PsiStatement>();
|
||||
for (int i = start; i < allStatements.size(); i++) {
|
||||
@@ -288,7 +289,7 @@ public class StatementVisitor extends ElementVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitSynchronizedStatement(PsiSynchronizedStatement statement) {
|
||||
public void visitSynchronizedStatement(@NotNull PsiSynchronizedStatement statement) {
|
||||
super.visitSynchronizedStatement(statement);
|
||||
myResult = new SynchronizedStatement(
|
||||
expressionToExpression(statement.getLockExpression()),
|
||||
@@ -297,7 +298,7 @@ public class StatementVisitor extends ElementVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitThrowStatement(PsiThrowStatement statement) {
|
||||
public void visitThrowStatement(@NotNull PsiThrowStatement statement) {
|
||||
super.visitThrowStatement(statement);
|
||||
myResult = new ThrowStatement(
|
||||
expressionToExpression(statement.getException())
|
||||
@@ -305,7 +306,7 @@ public class StatementVisitor extends ElementVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitTryStatement(PsiTryStatement statement) {
|
||||
public void visitTryStatement(@NotNull PsiTryStatement statement) {
|
||||
super.visitTryStatement(statement);
|
||||
|
||||
List<CatchStatement> catches = new LinkedList<CatchStatement>();
|
||||
@@ -324,7 +325,7 @@ public class StatementVisitor extends ElementVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitWhileStatement(PsiWhileStatement statement) {
|
||||
public void visitWhileStatement(@NotNull PsiWhileStatement statement) {
|
||||
super.visitWhileStatement(statement);
|
||||
myResult = new WhileStatement(
|
||||
expressionToExpression(statement.getCondition()),
|
||||
@@ -333,7 +334,7 @@ public class StatementVisitor extends ElementVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitReturnStatement(PsiReturnStatement statement) {
|
||||
public void visitReturnStatement(@NotNull PsiReturnStatement statement) {
|
||||
super.visitReturnStatement(statement);
|
||||
PsiExpression returnValue = statement.getReturnValue();
|
||||
String conversion = "";
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.jetbrains.jet.j2k.visitors;
|
||||
|
||||
import com.intellij.psi.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
@@ -9,24 +10,26 @@ import java.util.HashSet;
|
||||
* @author ignatov
|
||||
*/
|
||||
public class SuperVisitor extends JavaRecursiveElementVisitor {
|
||||
@NotNull
|
||||
private final HashSet<PsiExpressionList> myResolvedSuperCallParameters;
|
||||
|
||||
public SuperVisitor() {
|
||||
myResolvedSuperCallParameters = new HashSet<PsiExpressionList>();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public HashSet<PsiExpressionList> getResolvedSuperCallParameters() {
|
||||
return myResolvedSuperCallParameters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitMethodCallExpression(PsiMethodCallExpression expression) {
|
||||
public void visitMethodCallExpression(@NotNull PsiMethodCallExpression expression) {
|
||||
super.visitMethodCallExpression(expression);
|
||||
if (isSuper(expression.getMethodExpression()))
|
||||
myResolvedSuperCallParameters.add(expression.getArgumentList());
|
||||
}
|
||||
|
||||
static boolean isSuper(PsiReference r) {
|
||||
static boolean isSuper(@NotNull PsiReference r) {
|
||||
if (r.getCanonicalText().equals("super")) {
|
||||
final PsiElement baseConstructor = r.resolve();
|
||||
if (baseConstructor != null && baseConstructor instanceof PsiMethod && ((PsiMethod) baseConstructor).isConstructor()) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.jetbrains.jet.j2k.visitors;
|
||||
|
||||
import com.intellij.psi.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashSet;
|
||||
@@ -9,10 +10,11 @@ import java.util.HashSet;
|
||||
* @author ignatov
|
||||
*/
|
||||
public class ThisVisitor extends JavaRecursiveElementVisitor {
|
||||
@NotNull
|
||||
private final HashSet<PsiMethod> myResolvedConstructors = new HashSet<PsiMethod>();
|
||||
|
||||
@Override
|
||||
public void visitReferenceExpression(PsiReferenceExpression expression) {
|
||||
public void visitReferenceExpression(@NotNull PsiReferenceExpression expression) {
|
||||
for (PsiReference r : expression.getReferences())
|
||||
if (r.getCanonicalText().equals("this")) {
|
||||
final PsiElement res = r.resolve();
|
||||
|
||||
@@ -25,7 +25,7 @@ public class TypeVisitor extends PsiTypeVisitor<Type> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type visitPrimitiveType(PsiPrimitiveType primitiveType) {
|
||||
public Type visitPrimitiveType(@NotNull PsiPrimitiveType primitiveType) {
|
||||
final String name = primitiveType.getCanonicalText();
|
||||
final IdentifierImpl identifier = new IdentifierImpl(name);
|
||||
|
||||
@@ -39,14 +39,14 @@ public class TypeVisitor extends PsiTypeVisitor<Type> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type visitArrayType(PsiArrayType arrayType) {
|
||||
public Type visitArrayType(@NotNull PsiArrayType arrayType) {
|
||||
if (myResult == Type.EMPTY_TYPE)
|
||||
myResult = new ArrayType(typeToType(arrayType.getComponentType()));
|
||||
return super.visitArrayType(arrayType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type visitClassType(PsiClassType classType) {
|
||||
public Type visitClassType(@NotNull PsiClassType classType) {
|
||||
final IdentifierImpl identifier = constructClassTypeIdentifier(classType);
|
||||
final List<Type> resolvedClassTypeParams = createRawTypesForResolvedReference(classType);
|
||||
|
||||
@@ -128,7 +128,7 @@ public class TypeVisitor extends PsiTypeVisitor<Type> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type visitWildcardType(PsiWildcardType wildcardType) {
|
||||
public Type visitWildcardType(@NotNull PsiWildcardType wildcardType) {
|
||||
if (wildcardType.isExtends())
|
||||
myResult = new OutProjectionType(typeToType(wildcardType.getExtendsBound()));
|
||||
else if (wildcardType.isSuper())
|
||||
@@ -139,7 +139,7 @@ public class TypeVisitor extends PsiTypeVisitor<Type> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type visitEllipsisType(PsiEllipsisType ellipsisType) {
|
||||
public Type visitEllipsisType(@NotNull PsiEllipsisType ellipsisType) {
|
||||
myResult = new VarArg(typeToType(ellipsisType.getComponentType()));
|
||||
return super.visitEllipsisType(ellipsisType);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import junit.framework.Assert;
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.j2k.visitors.ClassVisitor;
|
||||
|
||||
import java.io.File;
|
||||
@@ -64,6 +65,7 @@ public class JavaToKotlinConverterTest extends LightDaemonAnalyzerTestCase {
|
||||
return myDataPath + File.separator + myName + ".jav";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return "testData";
|
||||
@@ -77,11 +79,13 @@ public class JavaToKotlinConverterTest extends LightDaemonAnalyzerTestCase {
|
||||
return jdkFromIdeaHome();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "test_" + myName;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Test suite() {
|
||||
TestSuite suite = new TestSuite();
|
||||
suite.addTest(TestCaseBuilder.suiteForDirectory(getTestDataPathBase(), "/ast", true, new TestCaseBuilder.NamedTestFactory() {
|
||||
@@ -143,7 +147,7 @@ public class JavaToKotlinConverterTest extends LightDaemonAnalyzerTestCase {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String prettify(String code) {
|
||||
private static String prettify(@Nullable String code) {
|
||||
if (code == null)
|
||||
return "";
|
||||
return code
|
||||
|
||||
@@ -16,6 +16,7 @@ import java.util.List;
|
||||
* @author ignatov
|
||||
*/
|
||||
abstract class TestCaseBuilder {
|
||||
@NotNull
|
||||
private static final FilenameFilter emptyFilter = new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File file, String name) {
|
||||
@@ -23,6 +24,7 @@ abstract class TestCaseBuilder {
|
||||
}
|
||||
};
|
||||
|
||||
@NotNull
|
||||
public static String getTestDataPathBase() {
|
||||
return "testData";
|
||||
}
|
||||
@@ -42,13 +44,13 @@ abstract class TestCaseBuilder {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static TestSuite suiteForDirectory(String baseDataDir, @NotNull final String dataPath, boolean recursive, final FilenameFilter filter, @NotNull NamedTestFactory factory) {
|
||||
private static TestSuite suiteForDirectory(String baseDataDir, @NotNull final String dataPath, boolean recursive, @NotNull final FilenameFilter filter, @NotNull NamedTestFactory factory) {
|
||||
TestSuite suite = new TestSuite(dataPath);
|
||||
final String extensionJava = ".jav";
|
||||
|
||||
final FilenameFilter extensionFilter = new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File dir, String name) {
|
||||
public boolean accept(File dir, @NotNull String name) {
|
||||
return name.endsWith(extensionJava);
|
||||
}
|
||||
};
|
||||
@@ -66,7 +68,7 @@ abstract class TestCaseBuilder {
|
||||
File dir = new File(baseDataDir + dataPath);
|
||||
FileFilter dirFilter = new FileFilter() {
|
||||
@Override
|
||||
public boolean accept(File pathname) {
|
||||
public boolean accept(@NotNull File pathname) {
|
||||
return pathname.isDirectory();
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user