diff --git a/j2k.ipr b/j2k.ipr new file mode 100644 index 00000000000..bd51640eb1b --- /dev/null +++ b/j2k.ipr @@ -0,0 +1,655 @@ + + + + + + + + $PROJECT_DIR$/out/artifacts/j2k_jar + + + + + + + + + $PROJECT_DIR$/out/artifacts/java2kotlin_jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + kotlin + nullable + ushr + + + + + + + + + + http://www.w3.org/1999/xhtml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/META-INF/MANIFEST.MF b/src/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..84f4c3093d1 --- /dev/null +++ b/src/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: org.jetbrains.jet.j2k.JavaToKotlinCli + diff --git a/src/org/jetbrains/jet/j2k/Converter.java b/src/org/jetbrains/jet/j2k/Converter.java new file mode 100644 index 00000000000..e5d952e5ada --- /dev/null +++ b/src/org/jetbrains/jet/j2k/Converter.java @@ -0,0 +1,823 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k; + +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; +import com.intellij.psi.*; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.j2k.ast.*; +import org.jetbrains.jet.j2k.ast.Class; +import org.jetbrains.jet.j2k.ast.Enum; +import org.jetbrains.jet.j2k.util.AstUtil; +import org.jetbrains.jet.j2k.visitors.*; +import org.jetbrains.jet.lang.types.expressions.OperatorConventions; + +import java.util.*; + +import static org.jetbrains.jet.j2k.ConverterUtil.countWritingAccesses; +import static org.jetbrains.jet.j2k.ConverterUtil.createMainFunction; +import static org.jetbrains.jet.j2k.visitors.TypeVisitor.*; +import static org.jetbrains.jet.lang.types.expressions.OperatorConventions.*; + +/** + * @author ignatov + */ +public class Converter { + @NotNull + public static final Set NOT_NULL_ANNOTATIONS = ImmutableSet.of( + "org.jetbrains.annotations.NotNull", + "com.sun.istack.internal.NotNull", + "javax.annotation.Nonnull" + ); + + @NotNull + private Set classIdentifiers = Sets.newHashSet(); + + @NotNull + private final Dispatcher dispatcher = new Dispatcher(this); + + @Nullable + private PsiType methodReturnType = null; + + @NotNull + private final Set flags = Sets.newHashSet(); + + public Converter() { + } + + public boolean addFlag(@NotNull J2KConverterFlags flag) { + return flags.add(flag); + } + + public boolean hasFlag(@NotNull J2KConverterFlags flag) { + return flags.contains(flag); + } + + public void setClassIdentifiers(@NotNull Set identifiers) { + classIdentifiers = identifiers; + } + + @NotNull + public Set getClassIdentifiers() { + return Collections.unmodifiableSet(classIdentifiers); + } + + @Nullable + public PsiType getMethodReturnType() { + return methodReturnType; + } + + public void clearClassIdentifiers() { + classIdentifiers.clear(); + } + + @NotNull + public String elementToKotlin(@NotNull PsiElement element) { + if (element instanceof PsiJavaFile) { + return fileToFile((PsiJavaFile) element).toKotlin(); + } + + if (element instanceof PsiClass) { + return classToClass((PsiClass) element).toKotlin(); + } + + if (element instanceof PsiMethod) { + return methodToFunction((PsiMethod) element).toKotlin(); + } + + if (element instanceof PsiField) { + PsiField field = (PsiField) element; + return fieldToField(field, field.getContainingClass()).toKotlin(); + } + + if (element instanceof PsiStatement) { + return statementToStatement((PsiStatement) element).toKotlin(); + } + + if (element instanceof PsiExpression) { + return expressionToExpression((PsiExpression) element).toKotlin(); + } + + return ""; + } + + @NotNull + public File fileToFile(@NotNull PsiJavaFile javaFile) { + return fileToFile(javaFile, Collections.emptyList()); + } + + @NotNull + public File fileToFileWithCompatibilityImport(@NotNull PsiJavaFile javaFile) { + return fileToFile(javaFile, Collections.singletonList("kotlin.compatibility.*")); + } + + @NotNull + private File fileToFile(PsiJavaFile javaFile, List additionalImports) { + final PsiImportList importList = javaFile.getImportList(); + List imports = importList == null + ? Collections.emptyList() + : importsToImportList(importList.getAllImportStatements()); + for (String i : additionalImports) + imports.add(new Import(i)); + return new File(quoteKeywords(javaFile.getPackageName()), imports, classesToClassList(javaFile.getClasses()), createMainFunction(javaFile)); + } + + @NotNull + private static String quoteKeywords(@NotNull String packageName) { + List result = new LinkedList(); + for (String part : packageName.split("\\.")) + result.add(new IdentifierImpl(part).toKotlin()); + return AstUtil.join(result, "."); + } + + @NotNull + private List classesToClassList(@NotNull PsiClass[] classes) { + List result = new LinkedList(); + for (PsiClass t : classes) result.add(classToClass(t)); + return result; + } + + @NotNull + public AnonymousClass anonymousClassToAnonymousClass(@NotNull PsiAnonymousClass anonymousClass) { + return new AnonymousClass(this, getMembers(anonymousClass)); + } + + @NotNull + private List getMembers(@NotNull PsiClass psiClass) { + List members = new LinkedList(); + for (PsiElement e : psiClass.getChildren()) { + if (e instanceof PsiMethod) { + members.add(methodToFunction((PsiMethod) e, true)); + } + else if (e instanceof PsiField) { + members.add(fieldToField((PsiField) e, psiClass)); + } + else if (e instanceof PsiClass) { + members.add(classToClass((PsiClass) e)); + } + else if (e instanceof PsiClassInitializer) { + members.add(initializerToInitializer((PsiClassInitializer) e)); + } + else if (e instanceof PsiMember) System.out.println(e.getClass() + " " + e.getText()); + } + return members; + } + + @NotNull + private static List getFinalOrWithEmptyInitializer(@NotNull List fields) { + List result = new LinkedList(); + for (Field f : fields) + if (f.isVal() || f.getInitializer().toKotlin().isEmpty()) { + result.add(f); + } + return result; + } + + @NotNull + private static List createParametersFromFields(@NotNull List fields) { + List result = new LinkedList(); + for (Field f : fields) + result.add(new Parameter(new IdentifierImpl("_" + f.getIdentifier().getName()), f.getType())); + return result; + } + + @NotNull + private static List createInitStatementsFromFields(@NotNull List fields) { + List result = new LinkedList(); + for (Field f : fields) { + final String identifierToKotlin = f.getIdentifier().toKotlin(); + result.add(new DummyStringExpression(identifierToKotlin + " = " + "_" + identifierToKotlin)); + } + return result; + } + + @NotNull + private static String createPrimaryConstructorInvocation(@NotNull String s, @NotNull List fields, @NotNull Map initializers) { + List result = new LinkedList(); + for (Field f : fields) { + final String id = f.getIdentifier().toKotlin(); + result.add(initializers.get(id)); + } + return s + "(" + AstUtil.join(result, ", ") + ")"; + } + + @NotNull + private Class classToClass(@NotNull PsiClass psiClass) { + final Set modifiers = modifiersListToModifiersSet(psiClass.getModifierList()); + final List fields = fieldsToFieldList(psiClass.getFields(), psiClass); + final List typeParameters = elementsToElementList(psiClass.getTypeParameters()); + final List implementsTypes = typesToNotNullableTypeList(psiClass.getImplementsListTypes()); + final List extendsTypes = typesToNotNullableTypeList(psiClass.getExtendsListTypes()); + final IdentifierImpl name = new IdentifierImpl(psiClass.getName()); + final List baseClassParams = new LinkedList(); + + List members = getMembers(psiClass); + + // we try to find super() call and generate class declaration like that: class A(name: String, i : Int) : Base(name) + final SuperVisitor visitor = new SuperVisitor(); + psiClass.accept(visitor); + final HashSet resolvedSuperCallParameters = visitor.getResolvedSuperCallParameters(); + if (resolvedSuperCallParameters.size() == 1) { + baseClassParams.addAll( + expressionsToExpressionList( + resolvedSuperCallParameters.toArray(new PsiExpressionList[1])[0].getExpressions() + ) + ); + } + + // we create primary constructor from all non final fields and fields without initializers + if (!psiClass.isEnum() && !psiClass.isInterface() && psiClass.getConstructors().length > 1 && getPrimaryConstructorForThisCase(psiClass) == null) { + final List finalOrWithEmptyInitializer = getFinalOrWithEmptyInitializer(fields); + final Map initializers = new HashMap(); + + for (final Member m : members) { + // and modify secondaries + if (m.getKind() == INode.Kind.CONSTRUCTOR) { + Function f = (Function) m; + if (!((Constructor) f).isPrimary()) { + for (Field fo : finalOrWithEmptyInitializer) { + String init = getDefaultInitializer(fo); + initializers.put(fo.getIdentifier().toKotlin(), init); + } + + final List newStatements = new LinkedList(); + + for (Statement s : f.getBlock().getStatements()) { + boolean isRemoved = false; + + if (s.getKind() == INode.Kind.ASSIGNMENT_EXPRESSION) { + final AssignmentExpression assignmentExpression = (AssignmentExpression) s; + if (assignmentExpression.getLeft().getKind() == INode.Kind.CALL_CHAIN) { + for (Field fo : finalOrWithEmptyInitializer) { + final String id = fo.getIdentifier().toKotlin(); + if (((CallChainExpression) assignmentExpression.getLeft()).getIdentifier().toKotlin().endsWith("." + id)) { + initializers.put(id, assignmentExpression.getRight().toKotlin()); + isRemoved = true; + } + } + } + } + if (!isRemoved) { + newStatements.add(s); + } + } + + newStatements.add( + 0, + new DummyStringExpression( + "val __ = " + createPrimaryConstructorInvocation( + name.toKotlin(), + finalOrWithEmptyInitializer, + initializers))); + + f.setBlock(new Block(newStatements)); + } + } + } + + members.add( + new Constructor( + Identifier.EMPTY_IDENTIFIER, + Collections.emptySet(), + new ClassType(name), + Collections.emptyList(), + new ParameterList(createParametersFromFields(finalOrWithEmptyInitializer)), + new Block(createInitStatementsFromFields(finalOrWithEmptyInitializer)), + true + ) + ); + } + + if (psiClass.isInterface()) { + return new Trait(this, name, modifiers, typeParameters, extendsTypes, Collections.emptyList(), implementsTypes, members); + } + if (psiClass.isEnum()) { + return new Enum(this, name, modifiers, typeParameters, Collections.emptyList(), Collections.emptyList(), implementsTypes, members); + } + return new Class(this, name, modifiers, typeParameters, extendsTypes, baseClassParams, implementsTypes, members); + } + + @NotNull + private Initializer initializerToInitializer(@NotNull PsiClassInitializer i) { + return new Initializer( + blockToBlock(i.getBody(), true), + modifiersListToModifiersSet(i.getModifierList()) + ); + } + + @NotNull + public static String getDefaultInitializer(@NotNull Field f) { + if (f.getType().isNullable()) { + return "null"; + } + else { + final String typeToKotlin = f.getType().toKotlin(); + if (typeToKotlin.equals("Boolean")) return "false"; + if (typeToKotlin.equals("Char")) return "' '"; + if (typeToKotlin.equals("Double")) return "0." + OperatorConventions.DOUBLE + "()"; + if (typeToKotlin.equals("Float")) return "0." + OperatorConventions.FLOAT + "()"; + return "0"; + } + } + + @NotNull + private List fieldsToFieldList(@NotNull PsiField[] fields, PsiClass psiClass) { + List result = new LinkedList(); + for (PsiField f : fields) result.add(fieldToField(f, psiClass)); + return result; + } + + @NotNull + private Field fieldToField(@NotNull PsiField field, PsiClass psiClass) { + Set modifiers = modifiersListToModifiersSet(field.getModifierList()); + if (field instanceof PsiEnumConstant) // TODO: remove instanceof + { + return new EnumConstant( + new IdentifierImpl(field.getName()), // TODO + modifiers, + typeToType(field.getType()), + elementToElement(((PsiEnumConstant) field).getArgumentList()) + ); + } + return new Field( + new IdentifierImpl(field.getName()), // TODO + modifiers, + typeToType(field.getType()), + createSureCallOnlyForChain(field.getInitializer(), field.getType()), // TODO: add modifiers + countWritingAccesses(field, psiClass) + ); + } + + @Nullable + private static PsiMethod getPrimaryConstructorForThisCase(@NotNull PsiClass psiClass) { + ThisVisitor tv = new ThisVisitor(); + psiClass.accept(tv); + return tv.getPrimaryConstructor(); + } + + public static boolean isConstructorPrimary(@NotNull PsiMethod constructor) { + if (constructor.getParent() instanceof PsiClass) { + final PsiClass parent = (PsiClass) constructor.getParent(); + if (parent.getConstructors().length == 1) { + return true; + } + else { + PsiMethod c = getPrimaryConstructorForThisCase(parent); // TODO: move up to classToClass() method + if (c != null && c.hashCode() == constructor.hashCode()) { + return true; + } + } + } + return false; + } + + @NotNull + private static List removeEmpty(@NotNull List statements) { + List result = new LinkedList(); + for (Statement s : statements) + if (s != Statement.EMPTY_STATEMENT && s != Expression.EMPTY_EXPRESSION) { + result.add(s); + } + return result; + } + + @NotNull + private Function methodToFunction(@NotNull PsiMethod method) { + return methodToFunction(method, true); + } + + @NotNull + private Function methodToFunction(@NotNull PsiMethod method, boolean notEmpty) { + if (isOverrideObjectDirect(method)) { + dispatcher.setExpressionVisitor(new ExpressionVisitorForDirectObjectInheritors(this)); + } + else { + dispatcher.setExpressionVisitor(new ExpressionVisitor(this)); + } + + methodReturnType = method.getReturnType(); + + final IdentifierImpl identifier = new IdentifierImpl(method.getName()); + final Type returnType = typeToType(method.getReturnType(), ConverterUtil.isAnnotatedAsNotNull(method.getModifierList())); + final Block body = hasFlag(J2KConverterFlags.SKIP_BODIES) + ? Block.EMPTY_BLOCK + : blockToBlock(method.getBody(), notEmpty); // #TODO + final Element params = createFunctionParameters(method); + final List typeParameters = elementsToElementList(method.getTypeParameters()); + + final Set modifiers = modifiersListToModifiersSet(method.getModifierList()); + if (isOverrideAnyMethodExceptMethodsFromObject(method)) { + modifiers.add(Modifier.OVERRIDE); + } + if (method.getParent() instanceof PsiClass && ((PsiClass) method.getParent()).isInterface()) { + modifiers.remove(Modifier.ABSTRACT); + } + if (isNotOpenMethod(method)) { + modifiers.add(Modifier.NOT_OPEN); + } + + if (method.isConstructor()) { // TODO: simplify + boolean isPrimary = isConstructorPrimary(method); + return new Constructor( + identifier, + modifiers, + returnType, + typeParameters, + params, + new Block(removeEmpty(body.getStatements()), false), + isPrimary + ); + } + return new Function( + identifier, + modifiers, + returnType, + typeParameters, + params, + body + ); + } + + @NotNull + private ParameterList createFunctionParameters(@NotNull PsiMethod method) { + List result = new LinkedList(); + for (PsiParameter parameter : method.getParameterList().getParameters()) { + result.add(new Parameter( + new IdentifierImpl(parameter.getName()), + typeToType(parameter.getType(), ConverterUtil.isAnnotatedAsNotNull(parameter.getModifierList())), + ConverterUtil.isReadOnly(parameter, method.getBody()) + )); + } + return new ParameterList(result); + } + + 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()) { + return true; + } + } + return false; + } + + private boolean isOverrideAnyMethodExceptMethodsFromObject(@NotNull PsiMethod method) { + boolean counter = normalCase(method); + if (counter) { + return true; + } + if (isInheritFromObject(method)) { + return caseForObject(method); + } + return false; + } + + private boolean caseForObject(@NotNull PsiMethod method) { + PsiClass containing = method.getContainingClass(); + if (containing != null) { + for (PsiClassType s : containing.getSuperTypes()) { + String canonicalText = s.getCanonicalText(); + if (!canonicalText.equals(JAVA_LANG_OBJECT) && !getClassIdentifiers().contains(canonicalText)) { + return true; + } + } + } + return false; + } + + private static boolean normalCase(@NotNull PsiMethod method) { + int counter = 0; + for (HierarchicalMethodSignature s : method.getHierarchicalMethodSignature().getSuperSignatures()) { + PsiClass containingClass = s.getMethod().getContainingClass(); + String qualifiedName = containingClass != null ? containingClass.getQualifiedName() : ""; + if (qualifiedName != null && !qualifiedName.equals(JAVA_LANG_OBJECT)) { + counter++; + } + } + return counter > 0; + } + + private static boolean isInheritFromObject(@NotNull PsiMethod method) { + List superSignatures = method.getHierarchicalMethodSignature().getSuperSignatures(); + for (HierarchicalMethodSignature s : superSignatures) { + PsiClass containingClass = s.getMethod().getContainingClass(); + String qualifiedName = containingClass != null ? containingClass.getQualifiedName() : ""; + if (qualifiedName != null && qualifiedName.equals(JAVA_LANG_OBJECT)) { + return true; + } + } + return false; + } + + private static boolean isOverrideObjectDirect(@NotNull final PsiMethod method) { + List superSignatures = method.getHierarchicalMethodSignature().getSuperSignatures(); + if (superSignatures.size() == 1) { + final PsiClass containingClass = superSignatures.get(0).getMethod().getContainingClass(); + final String qualifiedName = containingClass != null ? containingClass.getQualifiedName() : ""; + if (qualifiedName != null && qualifiedName.equals(JAVA_LANG_OBJECT)) { + return true; + } + } + return false; + } + + @NotNull + public Block blockToBlock(@Nullable PsiCodeBlock block, boolean notEmpty) { + if (block == null) return Block.EMPTY_BLOCK; + return new Block(statementsToStatementList(block.getStatements()), notEmpty); + } + + @NotNull + public Block blockToBlock(@Nullable PsiCodeBlock block) { + return blockToBlock(block, true); + } + + @NotNull + public List statementsToStatementList(@NotNull PsiStatement[] statements) { + List result = new LinkedList(); + for (PsiStatement t : statements) result.add(statementToStatement(t)); + return result; + } + + @NotNull + public List statementsToStatementList(@NotNull List statements) { + List result = new LinkedList(); + for (PsiStatement t : statements) result.add(statementToStatement(t)); + return result; + } + + @NotNull + public Statement statementToStatement(@Nullable PsiStatement s) { + if (s == null) return Statement.EMPTY_STATEMENT; + final StatementVisitor statementVisitor = new StatementVisitor(this); + s.accept(statementVisitor); + return statementVisitor.getResult(); + } + + @NotNull + public List expressionsToExpressionList(@NotNull PsiExpression[] expressions) { + List result = new LinkedList(); + for (PsiExpression e : expressions) result.add(expressionToExpression(e)); + return result; + } + + @NotNull + public Expression expressionToExpression(@Nullable PsiExpression e) { + if (e == null) return Expression.EMPTY_EXPRESSION; + final ExpressionVisitor expressionVisitor = dispatcher.getExpressionVisitor(); + e.accept(expressionVisitor); + return expressionVisitor.getResult(); + } + + @NotNull + public Element elementToElement(@Nullable PsiElement e) { + if (e == null) return Element.EMPTY_ELEMENT; + final ElementVisitor elementVisitor = new ElementVisitor(this); + e.accept(elementVisitor); + return elementVisitor.getResult(); + } + + @NotNull + public List elementsToElementList(@NotNull PsiElement[] elements) { + List result = new LinkedList(); + for (PsiElement e : elements) result.add(elementToElement(e)); + return result; + } + + @NotNull + public Type typeToType(@Nullable PsiType type) { + if (type == null) return Type.EMPTY_TYPE; + TypeVisitor typeVisitor = new TypeVisitor(this); + type.accept(typeVisitor); + return typeVisitor.getResult(); + } + + @NotNull + public List typesToTypeList(@NotNull PsiType[] types) { + List result = new LinkedList(); + for (PsiType t : types) result.add(typeToType(t)); + return result; + } + + @NotNull + public Type typeToType(PsiType type, boolean notNull) { + Type result = typeToType(type); + if (notNull) { + result.convertedToNotNull(); + } + return result; + } + + @NotNull + private List typesToNotNullableTypeList(@NotNull PsiType[] types) { + List result = new LinkedList(typesToTypeList(types)); + for (Type p : result) p.convertedToNotNull(); + return result; + } + + @NotNull + private static List importsToImportList(@NotNull PsiImportStatementBase[] imports) { + List result = new LinkedList(); + for (PsiImportStatementBase i : imports) { + Import anImport = importToImport(i); + String name = anImport.getName(); + if (!name.isEmpty() && !NOT_NULL_ANNOTATIONS.contains(name)) { + result.add(anImport); + } + } + return result; + } + + @NotNull + private static Import importToImport(@NotNull PsiImportStatementBase i) { + final PsiJavaCodeReferenceElement reference = i.getImportReference(); + if (reference != null) { + return new Import(quoteKeywords(reference.getQualifiedName()) + (i.isOnDemand() ? ".*" : "")); + } + return new Import(""); + } + + @NotNull + public List parametersToParameterList(@NotNull PsiParameter[] parameters) { + List result = new LinkedList(); + for (PsiParameter t : parameters) result.add(parameterToParameter(t)); + return result; + } + + @NotNull + public Parameter parameterToParameter(@NotNull PsiParameter parameter) { + return new Parameter( + new IdentifierImpl(parameter.getName()), + typeToType(parameter.getType(), ConverterUtil.isAnnotatedAsNotNull(parameter.getModifierList())) + ); + } + + @NotNull + public static Identifier identifierToIdentifier(@Nullable PsiIdentifier identifier) { + if (identifier == null) return Identifier.EMPTY_IDENTIFIER; + return new IdentifierImpl(identifier.getText()); + } + + @NotNull + public static Set modifiersListToModifiersSet(@Nullable PsiModifierList modifierList) { + HashSet modifiersSet = new HashSet(); + if (modifierList != null) { + if (modifierList.hasExplicitModifier(PsiModifier.ABSTRACT)) modifiersSet.add(Modifier.ABSTRACT); + if (modifierList.hasModifierProperty(PsiModifier.FINAL)) modifiersSet.add(Modifier.FINAL); + if (modifierList.hasModifierProperty(PsiModifier.STATIC)) modifiersSet.add(Modifier.STATIC); + if (modifierList.hasExplicitModifier(PsiModifier.PUBLIC)) modifiersSet.add(Modifier.PUBLIC); + if (modifierList.hasExplicitModifier(PsiModifier.PROTECTED)) modifiersSet.add(Modifier.PROTECTED); + if (modifierList.hasExplicitModifier(PsiModifier.PACKAGE_LOCAL)) modifiersSet.add(Modifier.INTERNAL); + if (modifierList.hasExplicitModifier(PsiModifier.PRIVATE)) modifiersSet.add(Modifier.PRIVATE); + } + return modifiersSet; + } + + @NotNull + public List createConversions(@NotNull PsiCallExpression expression) { + PsiExpressionList argumentList = expression.getArgumentList(); + PsiExpression[] arguments = argumentList != null ? argumentList.getExpressions() : new PsiExpression[]{}; + List conversions = new LinkedList(); + //noinspection UnusedDeclaration + for (final PsiExpression a : arguments) { + conversions.add(""); + } + + PsiMethod resolve = expression.resolveMethod(); + if (resolve != null) { + List expectedTypes = new LinkedList(); + List actualTypes = new LinkedList(); + + for (PsiParameter p : resolve.getParameterList().getParameters()) + expectedTypes.add(p.getType()); + + for (PsiExpression e : arguments) + actualTypes.add(e.getType()); + + if (conversions.size() == actualTypes.size() && actualTypes.size() == expectedTypes.size()) { + for (int i = 0; i < actualTypes.size(); i++) + conversions.set(i, createConversionForExpression(arguments[i], expectedTypes.get(i))); + } + } + return conversions; + } + + @NotNull + public List createConversions(@NotNull PsiPolyadicExpression expression, PsiType expectedType) { + PsiExpression[] arguments = expression.getOperands(); + int length = arguments.length; + List conversions = new LinkedList(); + + List expectedTypes = Collections.nCopies(length, expectedType); + List actualTypes = new LinkedList(); + + for (PsiExpression e : arguments) + actualTypes.add(e.getType()); + + assert actualTypes.size() == expectedTypes.size() : "The type list must have the same length"; + + for (int i = 0; i < actualTypes.size(); i++) + conversions.add(i, createConversionForExpression(arguments[i], expectedTypes.get(i))); + + return conversions; + } + + @NotNull + private String createConversionForExpression(@Nullable PsiExpression expression, @NotNull PsiType expectedType) { + String conversion = ""; + if (expression != null) { + PsiType actualType = expression.getType(); + boolean isPrimitiveTypeOrNull = actualType == null || Node.PRIMITIVE_TYPES.contains(actualType.getCanonicalText()); + boolean isRef = (expression instanceof PsiReferenceExpression && ((PsiReferenceExpression) expression).isQualified() || expression instanceof PsiMethodCallExpression); + boolean containsQuestDot = expressionToExpression(expression).toKotlin().contains("?."); + + if (isPrimitiveTypeOrNull && isRef && containsQuestDot) { + conversion += ".sure()"; + } + + if (actualType != null) { + if (isConversionNeeded(actualType, expectedType)) { + conversion += getPrimitiveTypeConversion(expectedType.getCanonicalText()); + } + } + } + return conversion; + } + + private static boolean isConversionNeeded(@Nullable final PsiType actual, @Nullable final PsiType expected) { + if (actual == null || expected == null) { + return false; + } + Map typeMap = new HashMap(); + typeMap.put(JAVA_LANG_BYTE, "byte"); + typeMap.put(JAVA_LANG_SHORT, "short"); + typeMap.put(JAVA_LANG_INTEGER, "int"); + typeMap.put(JAVA_LANG_LONG, "long"); + typeMap.put(JAVA_LANG_FLOAT, "float"); + typeMap.put(JAVA_LANG_DOUBLE, "double"); + typeMap.put(JAVA_LANG_CHARACTER, "char"); + String expectedStr = expected.getCanonicalText(); + String actualStr = actual.getCanonicalText(); + boolean o1 = AstUtil.getOrElse(typeMap, actualStr, "").equals(expectedStr); + boolean o2 = AstUtil.getOrElse(typeMap, expectedStr, "").equals(actualStr); + return !actualStr.equals(expectedStr) && (!(o1 ^ o2)); + } + + @NotNull + private static String getPrimitiveTypeConversion(@NotNull String type) { + Map conversions = new HashMap(); + conversions.put("byte", BYTE); + conversions.put("short", SHORT); + conversions.put("int", INT); + conversions.put("long", LONG); + conversions.put("float", FLOAT); + conversions.put("double", DOUBLE); + conversions.put("char", CHAR); + + conversions.put(JAVA_LANG_BYTE, BYTE); + conversions.put(JAVA_LANG_SHORT, SHORT); + conversions.put(JAVA_LANG_INTEGER, INT); + conversions.put(JAVA_LANG_LONG, LONG); + conversions.put(JAVA_LANG_FLOAT, FLOAT); + conversions.put(JAVA_LANG_DOUBLE, DOUBLE); + conversions.put(JAVA_LANG_CHARACTER, CHAR); + + if (conversions.containsKey(type)) { + return "." + conversions.get(type) + "()"; + } + return ""; + } + +// @NotNull +// private static String applyConversion(Expression expression, String conversion) { +// if (conversion.isEmpty()) +// return expression.toKotlin(); +// return "(" + expression.toKotlin() + ")" + conversion; +// } + + @NotNull + public SureCallChainExpression createSureCallOnlyForChain(@Nullable PsiExpression expression, @NotNull PsiType type) { + String conversion = (expression != null && (expression instanceof PsiReferenceExpression || expression instanceof PsiMethodCallExpression)) + ? + createConversionForExpression(expression, type) + : ""; + return new SureCallChainExpression(expressionToExpression(expression), conversion); + } + +} diff --git a/src/org/jetbrains/jet/j2k/ConverterUtil.java b/src/org/jetbrains/jet/j2k/ConverterUtil.java new file mode 100644 index 00000000000..d4f536c78d8 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ConverterUtil.java @@ -0,0 +1,134 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k; + +import com.intellij.openapi.util.Pair; +import com.intellij.psi.*; +import com.intellij.psi.util.PsiUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.text.MessageFormat; +import java.util.LinkedList; +import java.util.List; + +import static org.jetbrains.jet.j2k.Converter.NOT_NULL_ANNOTATIONS; + +/** + * @author ignatov + */ +public class ConverterUtil { + private ConverterUtil() { + } + + @NotNull + public static String createMainFunction(@NotNull PsiFile file) { + List> classNamesWithMains = new LinkedList>(); + + for (PsiClass c : ((PsiJavaFile) file).getClasses()) { + PsiMethod main = findMainMethod(c); + if (main != null) { + classNamesWithMains.add(new Pair(c.getName(), main)); + } + } + if (classNamesWithMains.size() > 0) { + String className = classNamesWithMains.get(0).getFirst(); + return MessageFormat.format("fun main(args : Array?) = {0}.main(args)", className); + } + return ""; + } + + @Nullable + private static PsiMethod findMainMethod(@NotNull PsiClass aClass) { + if (isMainClass(aClass)) { + final PsiMethod[] mainMethods = aClass.findMethodsByName("main", false); + return findMainMethod(mainMethods); + } + return null; + } + + @Nullable + private static PsiMethod findMainMethod(@NotNull PsiMethod[] mainMethods) { + for (PsiMethod mainMethod : mainMethods) { + if (isMainMethod(mainMethod)) return mainMethod; + } + return null; + } + + private static boolean isMainClass(@NotNull PsiClass psiClass) { + if (psiClass instanceof PsiAnonymousClass) return false; + if (psiClass.isInterface()) return false; + return psiClass.getContainingClass() == null || psiClass.hasModifierProperty(PsiModifier.STATIC); + } + + public static boolean isMainMethod(@Nullable PsiMethod method) { + if (method == null || method.getContainingClass() == null) return false; + if (PsiType.VOID != method.getReturnType()) return false; + if (!method.hasModifierProperty(PsiModifier.STATIC)) return false; + if (!method.hasModifierProperty(PsiModifier.PUBLIC)) return false; + final PsiParameter[] parameters = method.getParameterList().getParameters(); + if (parameters.length != 1) return false; + final PsiType type = parameters[0].getType(); + if (!(type instanceof PsiArrayType)) return false; + final PsiType componentType = ((PsiArrayType) type).getComponentType(); + return componentType.equalsToText("java.lang.String"); + } + + public static int countWritingAccesses(@Nullable PsiElement element, @Nullable PsiElement container) { + int counter = 0; + if (container != null) { + ReferenceCollector visitor = new ReferenceCollector(); + container.accept(visitor); + for (PsiReferenceExpression e : visitor.getCollectedReferences()) + if (e.isReferenceTo(element) && PsiUtil.isAccessedForWriting(e)) { + counter++; + } + } + return counter; + } + + static boolean isReadOnly(PsiElement element, PsiElement container) { + return countWritingAccesses(element, container) == 0; + } + + public static boolean isAnnotatedAsNotNull(@Nullable PsiModifierList modifierList) { + if (modifierList != null) { + PsiAnnotation[] annotations = modifierList.getAnnotations(); + for (PsiAnnotation a : annotations) { + String qualifiedName = a.getQualifiedName(); + if (qualifiedName != null && NOT_NULL_ANNOTATIONS.contains(qualifiedName)) { + return true; + } + } + } + return false; + } + + static class ReferenceCollector extends JavaRecursiveElementVisitor { + public List getCollectedReferences() { + return myCollectedReferences; + } + + private List myCollectedReferences = new LinkedList(); + + @Override + public void visitReferenceExpression(PsiReferenceExpression expression) { + super.visitReferenceExpression(expression); + myCollectedReferences.add(expression); + } + } +} diff --git a/src/org/jetbrains/jet/j2k/J2KConverterFlags.java b/src/org/jetbrains/jet/j2k/J2KConverterFlags.java new file mode 100644 index 00000000000..8a812ac664b --- /dev/null +++ b/src/org/jetbrains/jet/j2k/J2KConverterFlags.java @@ -0,0 +1,26 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k; + +/** + * @author abreslav + */ +public enum J2KConverterFlags { + FULLY_QUALIFIED_TYPE_NAMES, + SKIP_BODIES, + SKIP_NON_PUBLIC_MEMBERS +} diff --git a/src/org/jetbrains/jet/j2k/JavaToKotlinCli.java b/src/org/jetbrains/jet/j2k/JavaToKotlinCli.java new file mode 100644 index 00000000000..f65d30a9b31 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/JavaToKotlinCli.java @@ -0,0 +1,147 @@ +//package org.jetbrains.jet.j2k; +// +//import com.intellij.psi.PsiFile; +//import com.intellij.psi.PsiJavaFile; +//import org.apache.commons.cli.*; +//import org.jetbrains.annotations.NotNull; +//import org.jetbrains.annotations.Nullable; +// +//import java.io.File; +//import java.io.FileNotFoundException; +//import java.io.IOException; +//import java.util.ArrayList; +//import java.util.Arrays; +//import java.util.List; +//import java.util.logging.Logger; +//import java.util.regex.Pattern; +// +//import static org.apache.commons.io.FileUtils.readFileToString; +//import static org.apache.commons.io.FileUtils.writeStringToFile; +// +///** +// * @author ignatov +// */ +//@SuppressWarnings({"CallToPrintStackTrace", "UseOfSystemOutOrSystemErr"}) +//public class JavaToKotlinCli { +// private static final Logger myLogger = Logger.getAnonymousLogger(); +// +// private JavaToKotlinCli() { +// } +// +// public static void main(String[] args) { +// CommandLineParser parser = new BasicParser(); +// Options options = new Options() +// .addOption("h", "help", false, "Print usage information") +// .addOption("f", "from", true, "Directory with Java sources") +// .addOption("t", "to", true, "Directory with Kotlin sources") +// .addOption("p", "public-only", false, "Only public and protected members") +// .addOption("fqn", "fqn", false, "Full qualified names") +// .addOption("d", "declarations-only", false, "Declarations only") +// ; +// +// try { +// CommandLine commandLine = parser.parse(options, args); +// +// if (commandLine.hasOption("help")) +// showHelpAndExit(); +// +// if (commandLine.hasOption("from") && commandLine.hasOption("to")) { +// String from = commandLine.getOptionValue("from"); +// String to = commandLine.getOptionValue("to"); +// +// for (Option o : commandLine.getOptions()) { +// Converter.addFlag(o.getLongOpt()); +// } +// +// if (!from.isEmpty() && !to.isEmpty()) +// convertSourceTree(from, to); +// else +// showHelpAndExit(); +// } else +// showHelpAndExit(); +// } catch (ParseException e) { +// e.printStackTrace(); +// } +// } +// +// @SuppressWarnings("ResultOfMethodCallIgnored") +// private static void convertSourceTree(String javaPath, String kotlinPath) { +// try { +// File javaDir = new File(javaPath); +// File kotlinDir = new File(kotlinPath); +// +// if (kotlinDir.exists()) +// kotlinDir.delete(); +// +// if (!kotlinDir.exists() && !kotlinDir.mkdir()) +// myLogger.warning("Creation failed: " + kotlinDir.getAbsolutePath()); +// +// for (File f : getJavaFiles(javaDir.getAbsolutePath())) { +// String relative = javaDir.toURI().relativize(f.toURI()).getPath().replace(".java", ".kt"); +// File file = new File(kotlinPath, relative); +// +// if (file.exists()) +// file.delete(); +// +// if (f.isDirectory()) +// if (!file.exists() && !file.mkdir()) +// myLogger.warning("Creation failed: " + file.getAbsolutePath()); +// +// if (f.isFile()) { +// writeStringToFile(file, fileToKotlin(f)); +// } +// } +// } catch (FileNotFoundException e) { +// e.printStackTrace(); +// } catch (IOException e) { +// e.printStackTrace(); +// } +// } +// +// @NotNull +// private static String fileToKotlin(File f) throws IOException { +// final String javaCode = readJavaFileToString(f); +// return generateKotlinCode(JavaToKotlinTranslator.createFile(JavaToKotlinTranslator.setUpJavaCoreEnvironment(), javaCode)); +// } +// +// @NotNull +// private static String generateKotlinCode(@Nullable PsiFile file) { +// if (file != null && file instanceof PsiJavaFile) { +// JavaToKotlinTranslator.setClassIdentifiers(file); +// return JavaToKotlinTranslator.prettify(Converter.fileToFile((PsiJavaFile) file).toKotlin()); +// } +// return ""; +// } +// +// @NotNull +// private static String readJavaFileToString(@NotNull File javaFile) throws IOException { +// return Pattern.compile("\\s*/\\*.*\\*/", Pattern.DOTALL).matcher(readFileToString(javaFile)).replaceAll(""); +// } +// +// private static void showHelpAndExit() { +// System.err.println("Usage: java -jar java2kotlin.jar -f -t "); +// System.exit(1); +// } +// +// static public List getJavaFiles(String startDirName) throws FileNotFoundException { +// return getJavaFiles(new File(startDirName)); +// } +// +// private static List getJavaFiles(File start) throws FileNotFoundException { +// List result = new ArrayList(); +// +// if (start.isFile()) +// return Arrays.asList(start); +// +// for (File file : Arrays.asList(start.listFiles())) { +// if ((file.isFile() && file.getName().endsWith(".java")) || file.isDirectory()) +// result.add(file); +// +// if (file.isDirectory()) { +// List deeperList = getJavaFiles(file); +// result.addAll(deeperList); +// } +// } +// return result; +// } +//} \ No newline at end of file diff --git a/src/org/jetbrains/jet/j2k/JavaToKotlinTranslator.java b/src/org/jetbrains/jet/j2k/JavaToKotlinTranslator.java new file mode 100644 index 00000000000..c5c95a11a6b --- /dev/null +++ b/src/org/jetbrains/jet/j2k/JavaToKotlinTranslator.java @@ -0,0 +1,231 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.jet.j2k; + +import com.intellij.core.JavaCoreEnvironment; +import com.intellij.lang.java.JavaLanguage; +import com.intellij.openapi.Disposable; +import com.intellij.openapi.util.text.StringUtil; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiFile; +import com.intellij.psi.PsiFileFactory; +import com.intellij.psi.PsiJavaFile; +import com.intellij.util.Function; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.j2k.visitors.ClassVisitor; + +import java.io.File; +import java.io.IOException; +import java.io.PrintStream; +import java.net.URL; +import java.net.URLClassLoader; + +/** + * @author ignatov + */ +public class JavaToKotlinTranslator { + private JavaToKotlinTranslator() { + } + + private static final Converter CONVERTER = new Converter(); + + @Nullable + private static PsiFile createFile(@NotNull String text) { + JavaCoreEnvironment javaCoreEnvironment = setUpJavaCoreEnvironment(); + return PsiFileFactory.getInstance(javaCoreEnvironment.getProject()).createFileFromText( + "test.java", JavaLanguage.INSTANCE, text + ); + } + + @Nullable + static PsiFile createFile(@NotNull JavaCoreEnvironment javaCoreEnvironment, @NotNull String text) { + return PsiFileFactory.getInstance(javaCoreEnvironment.getProject()).createFileFromText( + "test.java", JavaLanguage.INSTANCE, text + ); + } + + @NotNull + static JavaCoreEnvironment setUpJavaCoreEnvironment() { + JavaCoreEnvironment javaCoreEnvironment = new JavaCoreEnvironment(new Disposable() { + @Override + public void dispose() { + } + }); + + javaCoreEnvironment.addToClasspath(findRtJar()); + File annotations = findAnnotations(); + if (annotations != null && annotations.exists()) { + javaCoreEnvironment.addToClasspath(annotations); + } + return javaCoreEnvironment; + } + + @NotNull + static String prettify(@Nullable String code) { + if (code == null) { + return ""; + } + return code + .trim() + .replaceAll("\r\n", "\n") + .replaceAll(" \n", "\n") + .replaceAll("\n ", "\n") + .replaceAll("\n+", "\n") + .replaceAll(" +", " ") + .trim() + ; + } + + @Nullable + private static File findRtJar() { + String javaHome = System.getenv("JAVA_HOME"); + File rtJar; + if (javaHome == null) { + rtJar = findActiveRtJar(true); + + if (rtJar == null) { + throw new SetupJavaCoreEnvironmentException("JAVA_HOME environment variable needs to be defined"); + } + } + else { + rtJar = findRtJar(javaHome); + } + + if (rtJar == null || !rtJar.exists()) { + rtJar = findActiveRtJar(true); + + if ((rtJar == null || !rtJar.exists())) { + throw new SetupJavaCoreEnvironmentException("No rt.jar found under JAVA_HOME=" + javaHome); + } + } + return rtJar; + } + + @Nullable + private static File findRtJar(String javaHome) { + File rtJar = new File(javaHome, "jre/lib/rt.jar"); + if (rtJar.exists()) { + return rtJar; + } + + File classesJar = new File(new File(javaHome).getParentFile().getAbsolutePath(), "Classes/classes.jar"); + if (classesJar.exists()) { + return classesJar; + } + return null; + } + + @Nullable + private static File findAnnotations() { + ClassLoader classLoader = JavaToKotlinTranslator.class.getClassLoader(); + while (classLoader != null) { + if (classLoader instanceof URLClassLoader) { + URLClassLoader loader = (URLClassLoader) classLoader; + for (URL url : loader.getURLs()) + if ("file".equals(url.getProtocol()) && url.getFile().endsWith("/annotations.jar")) { + return new File(url.getFile()); + } + } + classLoader = classLoader.getParent(); + } + return null; + } + + @Nullable + private static File findActiveRtJar(boolean failOnError) { + ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader(); + if (systemClassLoader instanceof URLClassLoader) { + URLClassLoader loader = (URLClassLoader) systemClassLoader; + for (URL url : loader.getURLs()) { + if ("file".equals(url.getProtocol())) { + if (url.getFile().endsWith("/lib/rt.jar")) { + return new File(url.getFile()); + } + if (url.getFile().endsWith("/Classes/classes.jar")) { + return new File(url.getFile()).getAbsoluteFile(); + } + } + } + if (failOnError) { + throw new SetupJavaCoreEnvironmentException("Could not find rt.jar in system class loader: " + StringUtil.join(loader.getURLs(), new Function() { + @NotNull + @Override + public String fun(@NotNull URL url) { + return url.toString() + "\n"; + } + }, ", ")); + } + } + else if (failOnError) { + throw new SetupJavaCoreEnvironmentException("System class loader is not an URLClassLoader: " + systemClassLoader); + } + return null; + } + + static void setClassIdentifiers(@NotNull Converter converter, @NotNull PsiElement psiFile) { + ClassVisitor c = new ClassVisitor(); + psiFile.accept(c); + converter.clearClassIdentifiers(); + converter.setClassIdentifiers(c.getClassIdentifiers()); + } + + @NotNull + static String generateKotlinCode(@NotNull String javaCode) { + PsiFile file = createFile(javaCode); + if (file != null && file instanceof PsiJavaFile) { + setClassIdentifiers(CONVERTER, file); + return prettify(CONVERTER.fileToFile((PsiJavaFile) file).toKotlin()); + } + return ""; + } + + @NotNull + static String generateKotlinCodeWithCompatibilityImport(@NotNull String javaCode) { + PsiFile file = createFile(javaCode); + if (file != null && file instanceof PsiJavaFile) { + setClassIdentifiers(CONVERTER, file); + return prettify(CONVERTER.fileToFileWithCompatibilityImport((PsiJavaFile) file).toKotlin()); + } + return ""; + } + + public static void main(@NotNull String[] args) throws IOException { + //noinspection UseOfSystemOutOrSystemErr + final PrintStream out = System.out; + if (args.length == 1) { + String kotlinCode = ""; + try { + kotlinCode = generateKotlinCode(args[0]); + } catch (Exception e) { + out.println("EXCEPTION: " + e.getMessage()); + } + if (kotlinCode.isEmpty()) { + out.println("EXCEPTION: generated code is empty."); + } + else { + out.println(kotlinCode); + } + } + else { + out.println("EXCEPTION: wrong number of arguments (should be 1)."); + } + } + + public static String translateToKotlin(String code) { + return generateKotlinCode(code); + } +} diff --git a/src/org/jetbrains/jet/j2k/SetupJavaCoreEnvironmentException.java b/src/org/jetbrains/jet/j2k/SetupJavaCoreEnvironmentException.java new file mode 100644 index 00000000000..af20ad4d7fd --- /dev/null +++ b/src/org/jetbrains/jet/j2k/SetupJavaCoreEnvironmentException.java @@ -0,0 +1,25 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k; + +/** + * @author ignatov + */ +public class SetupJavaCoreEnvironmentException extends RuntimeException { + public SetupJavaCoreEnvironmentException(String s) { + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/AnonymousClass.java b/src/org/jetbrains/jet/j2k/ast/AnonymousClass.java new file mode 100644 index 00000000000..8a547b26aab --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/AnonymousClass.java @@ -0,0 +1,46 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.j2k.Converter; + +import java.util.Collections; +import java.util.List; + +/** + * @author ignatov + */ +public class AnonymousClass extends Class { + public AnonymousClass(Converter converter, List members) { + super(converter, + new IdentifierImpl("anonClass"), + Collections.emptySet(), + Collections.emptyList(), + Collections.emptyList(), + Collections.emptyList(), + Collections.emptyList(), + getMembers(members, converter) + ); + } + + @NotNull + @Override + public String toKotlin() { + return bodyToKotlin(); + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/ArrayAccessExpression.kt b/src/org/jetbrains/jet/j2k/ast/ArrayAccessExpression.kt new file mode 100644 index 00000000000..ae5913a512a --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/ArrayAccessExpression.kt @@ -0,0 +1,7 @@ +package org.jetbrains.jet.j2k.ast + +public open class ArrayAccessExpression(val expression : Expression, val index : Expression) : Expression() { + public override fun toKotlin() : String { + return expression.toKotlin() + "[" + index.toKotlin() + "]" + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/ArrayInitializerExpression.kt b/src/org/jetbrains/jet/j2k/ast/ArrayInitializerExpression.kt new file mode 100644 index 00000000000..bc0b6ed98a5 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/ArrayInitializerExpression.kt @@ -0,0 +1,62 @@ +package org.jetbrains.jet.j2k.ast + +import org.jetbrains.jet.j2k.util.AstUtil +import org.jetbrains.jet.lang.types.expressions.OperatorConventions +import java.util.* + +public open class ArrayInitializerExpression(val `type` : Type, val initializers : List) : Expression() { + public override fun toKotlin() : String { + return createArrayFunction() + "(" + createInitializers() + ")" + } + + private fun createInitializers(): String { + return initializers.map { explicitConvertIfNeeded(it) }.makeString(", ") + } + + private fun createArrayFunction() : String { + var sType : String? = innerTypeStr() + if (Node.PRIMITIVE_TYPES.contains(sType)) + { + return sType + "Array" + } + + return AstUtil.lowerFirstCharacter(`type`.convertedToNotNull().toKotlin()) + } + + private fun innerTypeStr() : String { + return `type`.convertedToNotNull().toKotlin().replace("Array", "").toLowerCase() + } + + private fun explicitConvertIfNeeded(i : Expression) : String { + val doubleOrFloatTypes = hashSet("double", "float", "java.lang.double", "java.lang.float") + val afterReplace : String = innerTypeStr().replace(">", "").replace("<", "").replace("?", "") + if (doubleOrFloatTypes.contains(afterReplace)) + { + if (i.getKind() == INode.Kind.LITERAL) + { + if (i.toKotlin().contains(".")) + { + return i.toKotlin() + } + + return i.toKotlin() + ".0" + } + + return "(" + i.toKotlin() + ")" + getConversion(afterReplace) + } + + return i.toKotlin() + } + + class object { + private open fun getConversion(afterReplace : String) : String { + if (afterReplace.contains("double").sure()) + return "." + OperatorConventions.DOUBLE + "()" + + if (afterReplace.contains("float").sure()) + return "." + OperatorConventions.FLOAT + "()" + + return "" + } + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/ArrayType.java b/src/org/jetbrains/jet/j2k/ast/ArrayType.java new file mode 100644 index 00000000000..6c651bd39aa --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/ArrayType.java @@ -0,0 +1,49 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +/** + * @author ignatov + */ +public class ArrayType extends Type { + private final Type myType; + + public ArrayType(Type type) { + myType = type; + } + + public Type getInnerType() { + return myType; + } + + @NotNull + @Override + public Kind getKind() { + return Kind.ARRAY_TYPE; + } + + @NotNull + @Override + public String toKotlin() { + if (PRIMITIVE_TYPES.contains(myType.toKotlin().toLowerCase())) { + return myType.toKotlin() + "Array" + isNullableStr(); // returns IntArray, BooleanArray, etc. + } + return "Array" + "<" + myType.toKotlin() + ">" + isNullableStr(); + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/ArrayWithoutInitializationExpression.kt b/src/org/jetbrains/jet/j2k/ast/ArrayWithoutInitializationExpression.kt new file mode 100644 index 00000000000..db384ab56b9 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/ArrayWithoutInitializationExpression.kt @@ -0,0 +1,48 @@ +package org.jetbrains.jet.j2k.ast + +import org.jetbrains.jet.j2k.util.AstUtil +import java.util.List + +public open class ArrayWithoutInitializationExpression(val `type` : Type, val expressions : List) : Expression() { + public override fun toKotlin() : String { + if (`type`.getKind() == INode.Kind.ARRAY_TYPE) + { + return constructInnerType(`type` as ArrayType, expressions) + } + + return getConstructorName(`type`) + } + + private fun constructInnerType(hostType : ArrayType, expressions: List) : String { + if (expressions.size() == 1) + { + return oneDim(hostType, expressions[0]) + } + + var innerType : Type? = hostType.getInnerType() + if (expressions.size() > 1 && innerType?.getKind() == INode.Kind.ARRAY_TYPE) + { + return oneDim(hostType, expressions[0], "{" + constructInnerType(innerType as ArrayType, expressions.subList(1, expressions.size())) + "}") + } + + return getConstructorName(hostType) + } + + class object { + private open fun oneDim(`type` : Type, size : Expression) : String { + return oneDim(`type`, size, "") + } + + private open fun oneDim(`type` : Type, size : Expression, init : String) : String { + var commaWithInit : String? = (if (init.isEmpty()) + "" + else + ", " + init) + return getConstructorName(`type`) + "(" + size.toKotlin() + commaWithInit + ")" + } + + private open fun getConstructorName(`type` : Type) : String { + return AstUtil.replaceLastQuest(`type`.toKotlin()) + } + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/AssertStatement.kt b/src/org/jetbrains/jet/j2k/ast/AssertStatement.kt new file mode 100644 index 00000000000..bc6df0f6986 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/AssertStatement.kt @@ -0,0 +1,12 @@ +package org.jetbrains.jet.j2k.ast + + +public open class AssertStatement(val condition : Expression, val detail : Expression) : Statement() { + public override fun toKotlin() : String { + var detail : String? = (if (detail != Expression.EMPTY_EXPRESSION) + "(" + detail.toKotlin() + ")" + else + "") + return "assert" + detail + " {" + condition.toKotlin() + "}" + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/AssignmentExpression.kt b/src/org/jetbrains/jet/j2k/ast/AssignmentExpression.kt new file mode 100644 index 00000000000..62edeb5b35b --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/AssignmentExpression.kt @@ -0,0 +1,12 @@ +package org.jetbrains.jet.j2k.ast + + +public open class AssignmentExpression(val left : Expression, val right : Expression, val op : String) : Expression() { + public override fun toKotlin() : String { + return left.toKotlin() + " "+ op + " "+ right.toKotlin() + } + + public override fun getKind() : INode.Kind { + return INode.Kind.ASSIGNMENT_EXPRESSION + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/BinaryExpression.java b/src/org/jetbrains/jet/j2k/ast/BinaryExpression.java new file mode 100644 index 00000000000..42c7f8773cf --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/BinaryExpression.java @@ -0,0 +1,51 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.j2k.util.AstUtil; + +import java.util.Arrays; +import java.util.List; + +/** + * @author ignatov + */ +public class BinaryExpression extends Expression { + private final Expression myLeft; + private final Expression myRight; + private final String myOp; + private final List myConversions; + + public BinaryExpression(Expression left, Expression right, String op) { + this(left, right, op, Arrays.asList("", "")); + } + + public BinaryExpression(Expression left, Expression right, String op, List conversions) { + myLeft = left; + myRight = right; + myOp = op; + myConversions = conversions; + } + + @NotNull + @Override + public String toKotlin() { + List expressionsWithConversions = AstUtil.applyConversions(AstUtil.nodesToKotlin(Arrays.asList(myLeft, myRight)), myConversions); + return AstUtil.join(expressionsWithConversions, SPACE + myOp + SPACE); + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/Block.java b/src/org/jetbrains/jet/j2k/ast/Block.java new file mode 100644 index 00000000000..1aeb1172d9f --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/Block.java @@ -0,0 +1,68 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.j2k.util.AstUtil; + +import java.util.LinkedList; +import java.util.List; + +/** + * @author ignatov + */ +public class Block extends Statement { + @NotNull + public final static Block EMPTY_BLOCK = new Block(); + + private List myStatements; + private boolean myNotEmpty = false; + + private Block() { + myStatements = new LinkedList(); + } + + public Block(List statements) { + myStatements = new LinkedList(); + myStatements = statements; + } + + public Block(List statements, boolean notEmpty) { + myStatements = new LinkedList(); + myStatements = statements; + myNotEmpty = notEmpty; + } + + public boolean isEmpty() { + return !myNotEmpty && myStatements.size() == 0; + } + + public List getStatements() { + return myStatements; + } + + @NotNull + @Override + public String toKotlin() { + if (!isEmpty()) { + return "{" + N + + AstUtil.joinNodes(myStatements, N) + N + + "}"; + } + return EMPTY; + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/BreakStatement.java b/src/org/jetbrains/jet/j2k/ast/BreakStatement.java new file mode 100644 index 00000000000..c07b2fc6db8 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/BreakStatement.java @@ -0,0 +1,48 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +/** + * @author ignatov + */ +public class BreakStatement extends Statement { + private Identifier myLabel = Identifier.EMPTY_IDENTIFIER; + + public BreakStatement(Identifier label) { + myLabel = label; + } + + public BreakStatement() { + } + + @NotNull + @Override + public Kind getKind() { + return Kind.BREAK; + } + + @NotNull + @Override + public String toKotlin() { + if (myLabel.isEmpty()) { + return "break"; + } + return "break" + AT + myLabel.toKotlin(); + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/CallChainExpression.java b/src/org/jetbrains/jet/j2k/ast/CallChainExpression.java new file mode 100644 index 00000000000..bd9fca6e9ba --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/CallChainExpression.java @@ -0,0 +1,61 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +/** + * @author ignatov + */ +public class CallChainExpression extends Expression { + private final Expression myExpression; + private final Expression myIdentifier; + + public Expression getIdentifier() { + return myIdentifier; + } + + @NotNull + @Override + public Kind getKind() { + return Kind.CALL_CHAIN; + } + + public CallChainExpression(Expression expression, Expression identifier) { + myExpression = expression; + myIdentifier = identifier; + } + + @Override + public boolean isNullable() { + return myIdentifier.isNullable(); + } + + @NotNull + @Override + public String toKotlin() { + if (!myExpression.isEmpty()) { + if (myExpression.isNullable()) { + return myExpression.toKotlin() + QUESTDOT + myIdentifier.toKotlin(); + } + else { + return myExpression.toKotlin() + DOT + myIdentifier.toKotlin(); + } + } + return myIdentifier.toKotlin(); + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/CaseContainer.java b/src/org/jetbrains/jet/j2k/ast/CaseContainer.java new file mode 100644 index 00000000000..4e58dabaf24 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/CaseContainer.java @@ -0,0 +1,47 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.j2k.util.AstUtil; + +import java.util.LinkedList; +import java.util.List; + +/** + * @author ignatov + */ +public class CaseContainer extends Statement { + private final List myCaseStatement; + private final Block myBlock; + + public CaseContainer(final List caseStatement, @NotNull final List statements) { + myCaseStatement = caseStatement; + List newStatements = new LinkedList(); + for (Statement s : statements) + if (s.getKind() != Kind.BREAK && s.getKind() != Kind.CONTINUE) { + newStatements.add(s); + } + myBlock = new Block(newStatements); + } + + @NotNull + @Override + public String toKotlin() { + return AstUtil.joinNodes(myCaseStatement, COMMA_WITH_SPACE) + SPACE + "->" + SPACE + myBlock.toKotlin(); + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/CatchStatement.java b/src/org/jetbrains/jet/j2k/ast/CatchStatement.java new file mode 100644 index 00000000000..044d4808b6e --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/CatchStatement.java @@ -0,0 +1,38 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +/** + * @author ignatov + */ +public class CatchStatement extends Statement { + private final Parameter myVariable; + private final Block myBlock; + + public CatchStatement(Parameter variable, Block block) { + myVariable = variable; + myBlock = block; + } + + @NotNull + @Override + public String toKotlin() { + return "catch" + SPACE + "(" + myVariable.toKotlin() + ")" + SPACE + myBlock.toKotlin(); + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/Class.java b/src/org/jetbrains/jet/j2k/ast/Class.java new file mode 100644 index 00000000000..af7b37e3cf6 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/Class.java @@ -0,0 +1,269 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.j2k.Converter; +import org.jetbrains.jet.j2k.J2KConverterFlags; +import org.jetbrains.jet.j2k.util.AstUtil; + +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; + +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 myBaseClassParams; + private final List myMembers; + private final List myTypeParameters; + private final List myExtendsTypes; + private final List myImplementsTypes; + + public Class(Converter converter, Identifier name, Set modifiers, List typeParameters, List extendsTypes, + List baseClassParams, List implementsTypes, List members) { + myName = name; + myBaseClassParams = baseClassParams; + myModifiers = modifiers; + myTypeParameters = typeParameters; + myExtendsTypes = extendsTypes; + myImplementsTypes = implementsTypes; + myMembers = getMembers(members, converter); + } + + /*package*/ static List getMembers(List members, Converter converter) { + List withoutPrivate = new LinkedList(); + if (converter.hasFlag(J2KConverterFlags.SKIP_NON_PUBLIC_MEMBERS)) { + for (Member m : members) { + if (m.accessModifier().equals("public") || m.accessModifier().equals("protected")) { + withoutPrivate.add(m); + } + } + } + else { + withoutPrivate = members; + } + return withoutPrivate; + } + + + @Nullable + private Constructor getPrimaryConstructor() { + for (Member m : myMembers) + if (m.getKind() == Kind.CONSTRUCTOR) { + if (((Constructor) m).isPrimary()) { + return (Constructor) m; + } + } + return null; + } + + String primaryConstructorSignatureToKotlin() { + Constructor maybeConstructor = getPrimaryConstructor(); + if (maybeConstructor != null) { + return maybeConstructor.primarySignatureToKotlin(); + } + return "(" + ")"; + } + + String primaryConstructorBodyToKotlin() { + Constructor maybeConstructor = getPrimaryConstructor(); + if (maybeConstructor != null && !maybeConstructor.getBlock().isEmpty()) { + return maybeConstructor.primaryBodyToKotlin(); + } + return EMPTY; + } + + private boolean hasWhere() { + for (Element t : myTypeParameters) + if (t instanceof TypeParameter && ((TypeParameter) t).hasWhere()) { + return true; + } + return false; + } + + @NotNull + String typeParameterWhereToKotlin() { + if (hasWhere()) { + List wheres = new LinkedList(); + for (Element t : myTypeParameters) + if (t instanceof TypeParameter) { + wheres.add(((TypeParameter) t).getWhereToKotlin()); + } + return SPACE + "where" + SPACE + join(wheres, COMMA_WITH_SPACE) + SPACE; + } + return EMPTY; + } + + @NotNull + LinkedList membersExceptConstructors() { + final LinkedList result = new LinkedList(); + for (Member m : myMembers) + if (m.getKind() != Kind.CONSTRUCTOR) { + result.add(m); + } + return result; + } + + @NotNull + List secondaryConstructorsAsStaticInitFunction() { + final LinkedList result = new LinkedList(); + for (Member m : myMembers) + if (m.getKind() == Kind.CONSTRUCTOR && !((Constructor) m).isPrimary()) { + Function f = (Function) m; + Set modifiers = new HashSet(m.myModifiers); + modifiers.add(Modifier.STATIC); + + final List statements = f.getBlock().getStatements(); + statements.add(new ReturnStatement(new IdentifierImpl("__"))); // TODO: move to one place, find other __ usages + final Block block = new Block(statements); + + final List typeParameters = new LinkedList(); + if (f.getTypeParameters().size() == 0) { + typeParameters.addAll(myTypeParameters); + } + else { + typeParameters.addAll(myTypeParameters); + typeParameters.addAll(f.getTypeParameters()); + } + + result.add(new Function( + new IdentifierImpl("init"), + modifiers, + new ClassType(myName, typeParameters, false), + typeParameters, + f.getParams(), + block + )); + } + return result; + } + + @NotNull + String typeParametersToKotlin() { + return myTypeParameters.size() > 0 ? "<" + AstUtil.joinNodes(myTypeParameters, COMMA_WITH_SPACE) + ">" : EMPTY; + } + + List baseClassSignatureWithParams() { + if (TYPE.equals("class") && myExtendsTypes.size() == 1) { + LinkedList result = new LinkedList(); + result.add(myExtendsTypes.get(0).toKotlin() + "(" + joinNodes(myBaseClassParams, COMMA_WITH_SPACE) + ")"); + return result; + } + else { + return nodesToKotlin(myExtendsTypes); + } + } + + @NotNull + String implementTypesToKotlin() { + List allTypes = new LinkedList() { + { + addAll(baseClassSignatureWithParams()); + addAll(nodesToKotlin(myImplementsTypes)); + } + }; + return allTypes.size() == 0 ? EMPTY : SPACE + COLON + SPACE + join(allTypes, COMMA_WITH_SPACE); + } + + @NotNull + String modifiersToKotlin() { + List modifierList = new LinkedList(); + + modifierList.add(accessModifier()); + + if (needAbstractModifier()) { + modifierList.add(Modifier.ABSTRACT); + } + + if (needOpenModifier()) { + modifierList.add(Modifier.OPEN); + } + + if (modifierList.size() > 0) { + return join(modifierList, SPACE) + SPACE; + } + + return EMPTY; + } + + boolean needOpenModifier() { + return !myModifiers.contains(Modifier.FINAL) && !myModifiers.contains(Modifier.ABSTRACT); + } + + boolean needAbstractModifier() { + return isAbstract(); + } + + @NotNull + String bodyToKotlin() { + return SPACE + "{" + N + + AstUtil.joinNodes(getNonStatic(membersExceptConstructors()), N) + N + + primaryConstructorBodyToKotlin() + N + + classObjectToKotlin() + N + + "}"; + } + + @NotNull + private static List getStatic(@NotNull List members) { + List result = new LinkedList(); + for (Member m : members) + if (m.isStatic()) { + result.add(m); + } + return result; + } + + @NotNull + private static List getNonStatic(@NotNull List members) { + List result = new LinkedList(); + for (Member m : members) + if (!m.isStatic()) { + result.add(m); + } + return result; + } + + @NotNull + private String classObjectToKotlin() { + final List staticMembers = new LinkedList(secondaryConstructorsAsStaticInitFunction()); + staticMembers.addAll(getStatic(membersExceptConstructors())); + if (staticMembers.size() > 0) { + return "class" + SPACE + "object" + SPACE + "{" + N + + AstUtil.joinNodes(staticMembers, N) + N + + "}"; + } + return EMPTY; + } + + @NotNull + @Override + public String toKotlin() { + return modifiersToKotlin() + TYPE + SPACE + myName.toKotlin() + typeParametersToKotlin() + primaryConstructorSignatureToKotlin() + + implementTypesToKotlin() + + typeParameterWhereToKotlin() + + bodyToKotlin(); + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/ClassObjectAccessExpression.java b/src/org/jetbrains/jet/j2k/ast/ClassObjectAccessExpression.java new file mode 100644 index 00000000000..78aefcb3f3e --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/ClassObjectAccessExpression.java @@ -0,0 +1,36 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +/** + * @author ignatov + */ +public class ClassObjectAccessExpression extends Expression { + private final Element myTypeElement; + + public ClassObjectAccessExpression(Element typeElement) { + myTypeElement = typeElement; + } + + @NotNull + @Override + public String toKotlin() { + return "getJavaClass" + "<" + myTypeElement.toKotlin() + ">"; + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/ClassType.java b/src/org/jetbrains/jet/j2k/ast/ClassType.java new file mode 100644 index 00000000000..860c73cf0e3 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/ClassType.java @@ -0,0 +1,57 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.j2k.util.AstUtil; + +import java.util.Collections; +import java.util.List; + +/** + * @author ignatov + */ +public class ClassType extends Type { + private final Identifier myType; + private final List myParameters; + + public ClassType(Identifier type, List parameters, boolean nullable) { + myType = type; + myParameters = parameters; + myNullable = nullable; + } + + public ClassType(Identifier type, List parameters) { + myType = type; + myParameters = parameters; + } + + public ClassType(Identifier type) { + myType = type; + myNullable = false; + myParameters = Collections.emptyList(); + } + + @NotNull + @Override + public String toKotlin() { + String params = myParameters.size() == 0 + ? EMPTY + : "<" + AstUtil.joinNodes(myParameters, COMMA_WITH_SPACE) + ">"; + return myType.toKotlin() + params + isNullableStr(); + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/Constructor.java b/src/org/jetbrains/jet/j2k/ast/Constructor.java new file mode 100644 index 00000000000..e0a3d4b8628 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/Constructor.java @@ -0,0 +1,54 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +import java.util.List; +import java.util.Set; + +/** + * @author ignatov + */ +public class Constructor extends Function { + private final boolean myIsPrimary; + + public Constructor(Identifier identifier, Set modifiers, Type type, List typeParameters, Element params, Block block, boolean isPrimary) { + super(identifier, modifiers, type, typeParameters, params, block); + myIsPrimary = isPrimary; + } + + @NotNull + public String primarySignatureToKotlin() { + return "(" + myParams.toKotlin() + ")"; + } + + @NotNull + public String primaryBodyToKotlin() { + return myBlock.toKotlin(); + } + + public boolean isPrimary() { + return myIsPrimary; + } + + @NotNull + @Override + public Kind getKind() { + return Kind.CONSTRUCTOR; + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/ContinueStatement.java b/src/org/jetbrains/jet/j2k/ast/ContinueStatement.java new file mode 100644 index 00000000000..1defbd27651 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/ContinueStatement.java @@ -0,0 +1,48 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +/** + * @author ignatov + */ +public class ContinueStatement extends Statement { + private Identifier myLabel = Identifier.EMPTY_IDENTIFIER; + + public ContinueStatement(Identifier label) { + myLabel = label; + } + + public ContinueStatement() { + } + + @NotNull + @Override + public Kind getKind() { + return Kind.CONTINUE; + } + + @NotNull + @Override + public String toKotlin() { + if (myLabel.isEmpty()) { + return "continue"; + } + return "continue" + AT + myLabel.toKotlin(); + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/DeclarationStatement.java b/src/org/jetbrains/jet/j2k/ast/DeclarationStatement.java new file mode 100644 index 00000000000..165babb208c --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/DeclarationStatement.java @@ -0,0 +1,56 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.j2k.util.AstUtil; + +import java.util.LinkedList; +import java.util.List; + +/** + * @author ignatov + */ +public class DeclarationStatement extends Statement { + private final List myElements; + + public DeclarationStatement(List elements) { + myElements = elements; + } + + @NotNull + private static List toStringList(@NotNull List elements) { + List result = new LinkedList(); + for (Element e : elements) { + if (e instanceof LocalVariable) { + LocalVariable v = (LocalVariable) e; + + final String varKeyword = v.hasModifier(Modifier.FINAL) ? "val" : "var"; + result.add( + varKeyword + SPACE + e.toKotlin() + ); + } + } + return result; + } + + @NotNull + @Override + public String toKotlin() { + return AstUtil.join(toStringList(myElements), N); + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/DefaultSwitchLabelStatement.java b/src/org/jetbrains/jet/j2k/ast/DefaultSwitchLabelStatement.java new file mode 100644 index 00000000000..a7d71d772cd --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/DefaultSwitchLabelStatement.java @@ -0,0 +1,30 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +/** + * @author ignatov + */ +public class DefaultSwitchLabelStatement extends Statement { + @NotNull + @Override + public String toKotlin() { + return "else"; + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/DoWhileStatement.java b/src/org/jetbrains/jet/j2k/ast/DoWhileStatement.java new file mode 100644 index 00000000000..9592d8c8883 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/DoWhileStatement.java @@ -0,0 +1,36 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +/** + * @author ignatov + */ +public class DoWhileStatement extends WhileStatement { + public DoWhileStatement(Expression condition, Statement statement) { + super(condition, statement); + } + + @NotNull + @Override + public String toKotlin() { + return "do" + N + + myStatement.toKotlin() + N + + "while" + SPACE + "(" + myCondition.toKotlin() + ")"; + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/DummyMethodCallExpression.java b/src/org/jetbrains/jet/j2k/ast/DummyMethodCallExpression.java new file mode 100644 index 00000000000..afada0ea95a --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/DummyMethodCallExpression.java @@ -0,0 +1,40 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +/** + * @author ignatov + */ +public class DummyMethodCallExpression extends Expression { + private final Element myWho; + private final String myMethodName; + private final Element myWhat; + + public DummyMethodCallExpression(Element who, String methodName, Element what) { + myWho = who; + myMethodName = methodName; + myWhat = what; + } + + @NotNull + @Override + public String toKotlin() { + return myWho.toKotlin() + DOT + myMethodName + "(" + myWhat.toKotlin() + ")"; + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/DummyStringExpression.java b/src/org/jetbrains/jet/j2k/ast/DummyStringExpression.java new file mode 100644 index 00000000000..d8456d9033c --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/DummyStringExpression.java @@ -0,0 +1,36 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +/** + * @author ignatov + */ +public class DummyStringExpression extends Expression { + private final String myString; + + public DummyStringExpression(String string) { + myString = string; + } + + @NotNull + @Override + public String toKotlin() { + return myString; + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/Element.java b/src/org/jetbrains/jet/j2k/ast/Element.java new file mode 100644 index 00000000000..18047306a23 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/Element.java @@ -0,0 +1,47 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +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() { + return false; + } + + /** + * @author ignatov + */ + private static class EmptyElement extends Element { + @NotNull + @Override + public String toKotlin() { + return EMPTY; + } + + @Override + public boolean isEmpty() { + return true; + } + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/Enum.java b/src/org/jetbrains/jet/j2k/ast/Enum.java new file mode 100644 index 00000000000..2310a273db0 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/Enum.java @@ -0,0 +1,56 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.j2k.Converter; +import org.jetbrains.jet.j2k.util.AstUtil; + +import java.util.List; +import java.util.Set; + +/** + * @author ignatov + */ +public class Enum extends Class { + public Enum(Converter converter, Identifier name, Set modifiers, List typeParameters, List extendsTypes, + List baseClassParams, List implementsTypes, List members) { + super(converter, name, modifiers, typeParameters, extendsTypes, baseClassParams, implementsTypes, getMembers(members, converter)); + } + + String primaryConstructorSignatureToKotlin() { + String s = super.primaryConstructorSignatureToKotlin(); + return s.equals("()") ? EMPTY : s; + } + + @Override + boolean needOpenModifier() { + return false; + } + + @NotNull + @Override + public String toKotlin() { + return modifiersToKotlin() + "enum class" + SPACE + myName.toKotlin() + primaryConstructorSignatureToKotlin() + + typeParametersToKotlin() + implementTypesToKotlin() + SPACE + "{" + N + + AstUtil.joinNodes(membersExceptConstructors(), N) + N + + primaryConstructorBodyToKotlin() + N + + "public fun name() : String { return \"\" }" + N + // TODO : remove hack + "public fun order() : Int { return 0 }" + N + + "}"; + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/EnumConstant.java b/src/org/jetbrains/jet/j2k/ast/EnumConstant.java new file mode 100644 index 00000000000..990a56501a0 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/EnumConstant.java @@ -0,0 +1,39 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +import java.util.Set; + +/** + * @author ignatov + */ +public class EnumConstant extends Field { + public EnumConstant(Identifier identifier, Set modifiers, @NotNull Type type, Element params) { + super(identifier, modifiers, type.convertedToNotNull(), params, 0); + } + + @NotNull + @Override + public String toKotlin() { + if (myInitializer.toKotlin().isEmpty()) { + return myIdentifier.toKotlin(); + } + return myIdentifier.toKotlin() + SPACE + COLON + SPACE + myType.toKotlin() + "(" + myInitializer.toKotlin() + ")"; + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/Expression.java b/src/org/jetbrains/jet/j2k/ast/Expression.java new file mode 100644 index 00000000000..28c9a6143f0 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/Expression.java @@ -0,0 +1,47 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +/** + * @author ignatov + */ +public abstract class Expression extends Statement { + @NotNull + public static final Expression EMPTY_EXPRESSION = new EmptyExpression(); + + /** + * @author ignatov + */ + private static class EmptyExpression extends Expression { + @NotNull + @Override + public String toKotlin() { + return EMPTY; + } + + @Override + public boolean isEmpty() { + return true; + } + } + + boolean isNullable() { + return false; + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/ExpressionList.java b/src/org/jetbrains/jet/j2k/ast/ExpressionList.java new file mode 100644 index 00000000000..5d26a57c56c --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/ExpressionList.java @@ -0,0 +1,43 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.j2k.util.AstUtil; + +import java.util.List; + +/** + * @author ignatov + */ +public class ExpressionList extends Expression { + private final List myExpressions; + + public ExpressionList(List expressions, List types) { + myExpressions = expressions; + } + + public ExpressionList(List expressions) { + myExpressions = expressions; + } + + @NotNull + @Override + public String toKotlin() { + return AstUtil.joinNodes(myExpressions, COMMA_WITH_SPACE); + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/ExpressionListStatement.java b/src/org/jetbrains/jet/j2k/ast/ExpressionListStatement.java new file mode 100644 index 00000000000..810dbd14f6b --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/ExpressionListStatement.java @@ -0,0 +1,39 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.j2k.util.AstUtil; + +import java.util.List; + +/** + * @author ignatov + */ +public class ExpressionListStatement extends Expression { + private final List myExpressions; + + public ExpressionListStatement(List expressions) { + myExpressions = expressions; + } + + @NotNull + @Override + public String toKotlin() { + return AstUtil.joinNodes(myExpressions, N); + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/Field.java b/src/org/jetbrains/jet/j2k/ast/Field.java new file mode 100644 index 00000000000..4e35538fd3d --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/Field.java @@ -0,0 +1,98 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.j2k.util.AstUtil; + +import java.util.LinkedList; +import java.util.List; +import java.util.Set; + +import static org.jetbrains.jet.j2k.Converter.getDefaultInitializer; + +/** + * @author ignatov + */ +public class Field extends Member { + final Identifier myIdentifier; + private final int myWritingAccesses; + final Type myType; + final Element myInitializer; + + public Field(Identifier identifier, Set modifiers, Type type, Element initializer, int writingAccesses) { + myIdentifier = identifier; + myWritingAccesses = writingAccesses; + myModifiers = modifiers; + myType = type; + myInitializer = initializer; + } + + public Element getInitializer() { + return myInitializer; + } + + public Identifier getIdentifier() { + return myIdentifier; + } + + public Type getType() { + return myType; + } + + @NotNull + String modifiersToKotlin() { + List modifierList = new LinkedList(); + + if (isAbstract()) { + modifierList.add(Modifier.ABSTRACT); + } + + modifierList.add(accessModifier()); + + modifierList.add(isVal() ? "val" : "var"); + + if (modifierList.size() > 0) { + return AstUtil.join(modifierList, SPACE) + SPACE; + } + + return EMPTY; + } + + public boolean isVal() { + return myModifiers.contains(Modifier.FINAL); + } + + @Override + public boolean isStatic() { + return myModifiers.contains(Modifier.STATIC); + } + + @NotNull + @Override + public String toKotlin() { + final String declaration = modifiersToKotlin() + myIdentifier.toKotlin() + SPACE + COLON + SPACE + myType.toKotlin(); + + if (myInitializer.isEmpty()) { + return declaration + (isVal() && !isStatic() && myWritingAccesses == 1 + ? EMPTY + : SPACE + EQUAL + SPACE + getDefaultInitializer(this)); + } + + return declaration + SPACE + EQUAL + SPACE + myInitializer.toKotlin(); + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/File.java b/src/org/jetbrains/jet/j2k/ast/File.java new file mode 100644 index 00000000000..eb1be6a22ef --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/File.java @@ -0,0 +1,50 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.j2k.util.AstUtil; + +import java.util.List; + +/** + * @author ignatov + */ +public class File extends Node { + private final String myPackageName; + private final List myImports; + private final List myClasses; + private final String myMainFunction; + + public File(String packageName, List imports, List classes, String mainFunction) { + myPackageName = packageName; + myImports = imports; + myClasses = classes; + myMainFunction = mainFunction; + } + + @NotNull + @Override + public String toKotlin() { + final String common = AstUtil.joinNodes(myImports, N) + N2 + AstUtil.joinNodes(myClasses, N) + N + myMainFunction; + if (myPackageName.isEmpty()) { + return common; + } + return "package" + SPACE + myPackageName + N + + common; + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/ForeachStatement.java b/src/org/jetbrains/jet/j2k/ast/ForeachStatement.java new file mode 100644 index 00000000000..431dcf4168e --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/ForeachStatement.java @@ -0,0 +1,41 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +/** + * @author ignatov + */ +public class ForeachStatement extends Statement { + private final Parameter myVariable; + private final Expression myExpression; + private final Statement myStatement; + + public ForeachStatement(Parameter variable, Expression expression, Statement statement) { + myVariable = variable; + myExpression = expression; + myStatement = statement; + } + + @NotNull + @Override + public String toKotlin() { + return "for" + SPACE + "(" + myVariable.toKotlin() + SPACE + IN + SPACE + myExpression.toKotlin() + ")" + N + + myStatement.toKotlin(); + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/ForeachWithRangeStatement.java b/src/org/jetbrains/jet/j2k/ast/ForeachWithRangeStatement.java new file mode 100644 index 00000000000..ed9a5712a3a --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/ForeachWithRangeStatement.java @@ -0,0 +1,45 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +/** + * @author ignatov + */ +public class ForeachWithRangeStatement extends Statement { + private final Expression myStart; + private final IdentifierImpl myIdentifier; + private final Expression myEnd; + private final Statement myBody; + + public ForeachWithRangeStatement(IdentifierImpl identifier, Expression start, Expression end, Statement body) { + myStart = start; + myIdentifier = identifier; + myEnd = end; + myBody = body; + } + + @NotNull + @Override + public String toKotlin() { + return "for" + SPACE + "(" + + myIdentifier.toKotlin() + SPACE + "in" + SPACE + myStart.toKotlin() + ".." + myEnd.toKotlin() + + ")" + SPACE + + myBody.toKotlin(); + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/Function.java b/src/org/jetbrains/jet/j2k/ast/Function.java new file mode 100644 index 00000000000..0844e177a9d --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/Function.java @@ -0,0 +1,127 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.j2k.util.AstUtil; + +import java.util.LinkedList; +import java.util.List; +import java.util.Set; + +/** + * @author ignatov + */ +public class Function extends Member { + private final Identifier myName; + private final Type myType; + private final List myTypeParameters; + final Element myParams; + + // TODO: maybe remove it? + public void setBlock(Block block) { + myBlock = block; + } + + Block myBlock; + + public Function(Identifier name, Set modifiers, Type type, List typeParameters, Element params, Block block) { + myName = name; + myModifiers = modifiers; + myType = type; + myTypeParameters = typeParameters; + myParams = params; + myBlock = block; + } + + public List getTypeParameters() { + return myTypeParameters; + } + + public Element getParams() { + return myParams; + } + + public Block getBlock() { + return myBlock; + } + + @NotNull + private String typeParametersToKotlin() { + return myTypeParameters.size() > 0 ? "<" + AstUtil.joinNodes(myTypeParameters, COMMA_WITH_SPACE) + ">" : EMPTY; + } + + private boolean hasWhere() { + for (Element t : myTypeParameters) + if (t instanceof TypeParameter && ((TypeParameter) t).hasWhere()) { + return true; + } + return false; + } + + private String typeParameterWhereToKotlin() { + if (hasWhere()) { + List wheres = new LinkedList(); + for (Element t : myTypeParameters) + if (t instanceof TypeParameter) { + wheres.add(((TypeParameter) t).getWhereToKotlin()); + } + return SPACE + "where" + SPACE + AstUtil.join(wheres, COMMA_WITH_SPACE) + SPACE; + } + return EMPTY; + } + + String modifiersToKotlin() { + List modifierList = new LinkedList(); + + String accessModifier = accessModifier(); + if (!accessModifier.isEmpty()) { + modifierList.add(accessModifier); + } + + if (isAbstract()) { + modifierList.add(Modifier.ABSTRACT); + } + + if (myModifiers.contains(Modifier.OVERRIDE)) { + modifierList.add(Modifier.OVERRIDE); + } + + if (!myModifiers.contains(Modifier.ABSTRACT) && !myModifiers.contains(Modifier.OVERRIDE) && !myModifiers.contains(Modifier.FINAL)) { + modifierList.add(Modifier.OPEN); + } + + if (myModifiers.contains(Modifier.NOT_OPEN)) { + modifierList.remove(Modifier.OPEN); + } + + if (modifierList.size() > 0) { + return AstUtil.join(modifierList, SPACE) + SPACE; + } + + return EMPTY; + } + + @NotNull + @Override + public String toKotlin() { + return modifiersToKotlin() + "fun" + SPACE + myName.toKotlin() + typeParametersToKotlin() + "(" + myParams.toKotlin() + ")" + SPACE + COLON + + SPACE + myType.toKotlin() + SPACE + + typeParameterWhereToKotlin() + + myBlock.toKotlin(); + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/IMember.java b/src/org/jetbrains/jet/j2k/ast/IMember.java new file mode 100644 index 00000000000..3e0bdf5e7fb --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/IMember.java @@ -0,0 +1,26 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +/** + * @author ignatov + */ +public interface IMember extends INode { + boolean isStatic(); + + boolean isAbstract(); +} diff --git a/src/org/jetbrains/jet/j2k/ast/INode.java b/src/org/jetbrains/jet/j2k/ast/INode.java new file mode 100644 index 00000000000..aa60b6ed1bb --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/INode.java @@ -0,0 +1,34 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +/** + * @author ignatov + */ +public interface INode { + @NotNull + String toKotlin(); + + @NotNull + Kind getKind(); + + enum Kind { + UNDEFINED, TYPE, CONSTRUCTOR, BREAK, CONTINUE, VARARG, TRAIT, ASSIGNMENT_EXPRESSION, CALL_CHAIN, LITERAL, ARRAY_TYPE, + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/Identifier.java b/src/org/jetbrains/jet/j2k/ast/Identifier.java new file mode 100644 index 00000000000..f94be742be2 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/Identifier.java @@ -0,0 +1,31 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +/** + * @author ignatov + */ +public interface Identifier extends INode { + @NotNull + Identifier EMPTY_IDENTIFIER = new IdentifierImpl(""); + + boolean isEmpty(); + + String getName(); +} diff --git a/src/org/jetbrains/jet/j2k/ast/IdentifierImpl.java b/src/org/jetbrains/jet/j2k/ast/IdentifierImpl.java new file mode 100644 index 00000000000..fd543f23f91 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/IdentifierImpl.java @@ -0,0 +1,76 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +/** + * @author ignatov + */ +public class IdentifierImpl extends Expression implements Identifier { + private final String myName; + private boolean myIsNullable = true; + private boolean myQuotingNeeded = true; + + public IdentifierImpl(String name) { + myName = name; + } + + public IdentifierImpl(String name, boolean isNullable) { + myName = name; + myIsNullable = isNullable; + } + + public IdentifierImpl(String name, boolean isNullable, boolean quotingNeeded) { + myName = name; + myIsNullable = isNullable; + myQuotingNeeded = quotingNeeded; + } + + @Override + public boolean isEmpty() { + return myName.length() == 0; + } + + @Override + public String getName() { + return myName; + } + + @NotNull + private static String quote(String str) { + return BACKTICK + str + BACKTICK; + } + + @Override + public boolean isNullable() { + return myIsNullable; + } + + private String ifNeedQuote() { + if (myQuotingNeeded && (ONLY_KOTLIN_KEYWORDS.contains(myName) || myName.contains("$"))) { + return quote(myName); + } + return myName; + } + + @NotNull + @Override + public String toKotlin() { + return ifNeedQuote(); + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/IfStatement.java b/src/org/jetbrains/jet/j2k/ast/IfStatement.java new file mode 100644 index 00000000000..1efa8311a56 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/IfStatement.java @@ -0,0 +1,48 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +/** + * @author ignatov + */ +public class IfStatement extends Expression { + private final Expression myCondition; + private final Statement myThenStatement; + private final Statement myElseStatement; + + public IfStatement(Expression condition, Statement thenStatement, Statement elseStatement) { + myCondition = condition; + myThenStatement = thenStatement; + myElseStatement = elseStatement; + } + + @NotNull + @Override + public String toKotlin() { + String result = "if" + SPACE + "(" + myCondition.toKotlin() + ")" + N + myThenStatement.toKotlin() + N; + + if (myElseStatement != Statement.EMPTY_STATEMENT) { + return result + + "else" + N + + myElseStatement.toKotlin(); + } + + return result; + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/Import.java b/src/org/jetbrains/jet/j2k/ast/Import.java new file mode 100644 index 00000000000..4d81911c01d --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/Import.java @@ -0,0 +1,40 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +/** + * @author ignatov + */ +public class Import extends Node { + private final String myName; + + public String getName() { + return myName; + } + + public Import(String name) { + myName = name; + } + + @NotNull + @Override + public String toKotlin() { + return "import" + SPACE + myName; + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/InProjectionType.java b/src/org/jetbrains/jet/j2k/ast/InProjectionType.java new file mode 100644 index 00000000000..9849ee47d58 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/InProjectionType.java @@ -0,0 +1,36 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +/** + * @author ignatov + */ +public class InProjectionType extends Type { + private final Type myBound; + + public InProjectionType(Type bound) { + myBound = bound; + } + + @NotNull + @Override + public String toKotlin() { + return "in" + SPACE + myBound.toKotlin(); + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/Initializer.java b/src/org/jetbrains/jet/j2k/ast/Initializer.java new file mode 100644 index 00000000000..056f8424d09 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/Initializer.java @@ -0,0 +1,39 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +import java.util.Set; + +/** + * @author ignatov + */ +public class Initializer extends Member { + private final Block myBlock; + + public Initializer(Block block, Set modifiers) { + myBlock = block; + myModifiers = modifiers; + } + + @NotNull + @Override + public String toKotlin() { + return myBlock.toKotlin(); + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/IsOperator.java b/src/org/jetbrains/jet/j2k/ast/IsOperator.java new file mode 100644 index 00000000000..79262f14871 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/IsOperator.java @@ -0,0 +1,38 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +/** + * @author ignatov + */ +public class IsOperator extends Expression { + private final Expression myExpression; + private final Element myTypeElement; + + public IsOperator(Expression expression, Element typeElement) { + myExpression = expression; + myTypeElement = typeElement; + } + + @NotNull + @Override + public String toKotlin() { + return "(" + myExpression.toKotlin() + SPACE + "is" + SPACE + myTypeElement.toKotlin() + ")"; + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/LabelStatement.java b/src/org/jetbrains/jet/j2k/ast/LabelStatement.java new file mode 100644 index 00000000000..0d0c7ebdfa9 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/LabelStatement.java @@ -0,0 +1,38 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +/** + * @author ignatov + */ +public class LabelStatement extends Statement { + private final Identifier myName; + private final Statement myStatement; + + public LabelStatement(Identifier name, Statement statement) { + myName = name; + myStatement = statement; + } + + @NotNull + @Override + public String toKotlin() { + return AT + myName.toKotlin() + SPACE + myStatement.toKotlin(); + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/LiteralExpression.java b/src/org/jetbrains/jet/j2k/ast/LiteralExpression.java new file mode 100644 index 00000000000..06162ae412b --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/LiteralExpression.java @@ -0,0 +1,42 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +/** + * @author ignatov + */ +public class LiteralExpression extends Expression { + private final Identifier myIdentifier; + + public LiteralExpression(Identifier identifier) { + myIdentifier = identifier; + } + + @NotNull + @Override + public Kind getKind() { + return Kind.LITERAL; + } + + @NotNull + @Override + public String toKotlin() { + return myIdentifier.toKotlin(); + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/LocalVariable.java b/src/org/jetbrains/jet/j2k/ast/LocalVariable.java new file mode 100644 index 00000000000..6d3d411ba13 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/LocalVariable.java @@ -0,0 +1,53 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +import java.util.Set; + +/** + * @author ignatov + */ +public class LocalVariable extends Expression { + private final Identifier myIdentifier; + private final Set myModifiersSet; + private final Type myType; + private final Expression myInitializer; + + public LocalVariable(Identifier identifier, Set modifiersSet, Type type, Expression initializer) { + myIdentifier = identifier; + myModifiersSet = modifiersSet; + myType = type; + myInitializer = initializer; + } + + public boolean hasModifier(String modifier) { + return myModifiersSet.contains(modifier); + } + + @NotNull + @Override + public String toKotlin() { + if (myInitializer.isEmpty()) { + return myIdentifier.toKotlin() + SPACE + COLON + SPACE + myType.toKotlin(); + } + + return myIdentifier.toKotlin() + SPACE + COLON + SPACE + myType.toKotlin() + SPACE + + EQUAL + SPACE + myInitializer.toKotlin(); + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/Member.java b/src/org/jetbrains/jet/j2k/ast/Member.java new file mode 100644 index 00000000000..dca9a33cf2f --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/Member.java @@ -0,0 +1,47 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +import java.util.Set; + +/** + * @author ignatov + */ +public abstract class Member extends Node implements IMember { + Set myModifiers; + + @NotNull + String accessModifier() { + for (String m : myModifiers) + if (m.equals(Modifier.PUBLIC) || m.equals(Modifier.PROTECTED) || m.equals(Modifier.PRIVATE)) { + return m; + } + return EMPTY; // package local converted to internal, but we use internal by default + } + + @Override + public boolean isAbstract() { + return myModifiers.contains(Modifier.ABSTRACT); + } + + @Override + public boolean isStatic() { + return myModifiers.contains(Modifier.STATIC); + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/MethodCallExpression.java b/src/org/jetbrains/jet/j2k/ast/MethodCallExpression.java new file mode 100644 index 00000000000..481b8fad792 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/MethodCallExpression.java @@ -0,0 +1,60 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.j2k.util.AstUtil; + +import java.util.List; + +/** + * @author ignatov + */ +public class MethodCallExpression extends Expression { + private final Expression myMethodCall; + private final List myArguments; + private final List myConversions; + private final boolean myIsResultNullable; + private final List myTypeParameters; + + public MethodCallExpression(Expression methodCall, List arguments, List typeParameters) { + this(methodCall, arguments, AstUtil.createListWithEmptyString(arguments), false, typeParameters); + } + + public MethodCallExpression(Expression methodCall, List arguments, List conversions, boolean nullable, List typeParameters) { + myMethodCall = methodCall; + myArguments = arguments; + myConversions = conversions; + myIsResultNullable = nullable; + myTypeParameters = typeParameters; + } + + @Override + public boolean isNullable() { + return myIsResultNullable; + } + + @NotNull + @Override + public String toKotlin() { + String typeParamsToKotlin = myTypeParameters.size() > 0 + ? "<" + AstUtil.joinNodes(myTypeParameters, COMMA_WITH_SPACE) + ">" + : EMPTY; + List applyConversions = AstUtil.applyConversions(AstUtil.nodesToKotlin(myArguments), myConversions); + return myMethodCall.toKotlin() + typeParamsToKotlin + "(" + AstUtil.join(applyConversions, COMMA_WITH_SPACE) + ")"; + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/Modifier.java b/src/org/jetbrains/jet/j2k/ast/Modifier.java new file mode 100644 index 00000000000..9e666fe5090 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/Modifier.java @@ -0,0 +1,45 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +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"; +} diff --git a/src/org/jetbrains/jet/j2k/ast/NewClassExpression.java b/src/org/jetbrains/jet/j2k/ast/NewClassExpression.java new file mode 100644 index 00000000000..7bbf906dff0 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/NewClassExpression.java @@ -0,0 +1,63 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.j2k.util.AstUtil; + +import java.util.List; + +/** + * @author ignatov + */ +public class NewClassExpression extends Expression { + private final Element myName; + private final List myArguments; + private Expression myQualifier; + private List myConversions; + @Nullable + private AnonymousClass myAnonymousClass = null; + + private NewClassExpression(Element name, List arguments) { + myName = name; + myQualifier = EMPTY_EXPRESSION; + myArguments = arguments; + myConversions = AstUtil.createListWithEmptyString(arguments); + } + + public NewClassExpression(@NotNull Expression qualifier, @NotNull Element name, @NotNull List arguments, + @NotNull List conversions, @Nullable AnonymousClass anonymousClass) { + this(name, arguments); + myQualifier = qualifier; + myConversions = conversions; + myAnonymousClass = anonymousClass; + } + + @NotNull + @Override + public String toKotlin() { + final String callOperator = myQualifier.isNullable() ? QUESTDOT : DOT; + final String qualifier = myQualifier.isEmpty() ? EMPTY : myQualifier.toKotlin() + callOperator; + List applyConversions = AstUtil.applyConversions(AstUtil.nodesToKotlin(myArguments), myConversions); + String appliedArguments = AstUtil.join(applyConversions, COMMA_WITH_SPACE); + return myAnonymousClass != null ? + "object" + SPACE + ":" + SPACE + qualifier + myName.toKotlin() + "(" + appliedArguments + ")" + myAnonymousClass.toKotlin() + : + qualifier + myName.toKotlin() + "(" + appliedArguments + ")"; + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/Node.java b/src/org/jetbrains/jet/j2k/ast/Node.java new file mode 100644 index 00000000000..e1d580d6cd7 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/Node.java @@ -0,0 +1,74 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +/** + * @author ignatov + */ +public abstract class Node implements INode { + @NotNull + @Override + public Kind getKind() { + return Kind.UNDEFINED; + } + + @NotNull + final static Set ONLY_KOTLIN_KEYWORDS = new HashSet(Arrays.asList( + "package", "as", "type", "val", "var", "fun", "is", "in", "object", "when", "trait", "This" + )); + + @NotNull + public final static Set PRIMITIVE_TYPES = new HashSet(Arrays.asList( + "double", "float", "long", "int", "short", "byte", "boolean", "char" + )); + + static final String N = "\n"; + @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 BACKTICK = "`"; + @NotNull + static final String QUEST = "?"; + @NotNull + public static final String COMMA_WITH_SPACE = "," + SPACE; + @NotNull + static final String STAR = "*"; + @NotNull + protected static final String ZERO = "0"; +} diff --git a/src/org/jetbrains/jet/j2k/ast/OutProjectionType.java b/src/org/jetbrains/jet/j2k/ast/OutProjectionType.java new file mode 100644 index 00000000000..0d91c4b9e5d --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/OutProjectionType.java @@ -0,0 +1,36 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +/** + * @author ignatov + */ +public class OutProjectionType extends Type { + private final Type myBound; + + public OutProjectionType(Type bound) { + myBound = bound; + } + + @NotNull + @Override + public String toKotlin() { + return "out" + SPACE + myBound.toKotlin(); + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/Parameter.java b/src/org/jetbrains/jet/j2k/ast/Parameter.java new file mode 100644 index 00000000000..b20caf83fd0 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/Parameter.java @@ -0,0 +1,47 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +/** + * @author ignatov + */ +public class Parameter extends Expression { + private final Identifier myIdentifier; + private final Type myType; + private boolean myReadOnly; + + public Parameter(Identifier identifier, Type type) { + myIdentifier = identifier; + myType = type; + myReadOnly = true; + } + + public Parameter(IdentifierImpl identifier, Type type, boolean readOnly) { + this(identifier, type); + myReadOnly = readOnly; + } + + @NotNull + @Override + public String toKotlin() { + String vararg = myType.getKind() == Kind.VARARG ? "vararg" + SPACE : EMPTY; + String var = myReadOnly ? EMPTY : "var" + SPACE; + return vararg + var + myIdentifier.toKotlin() + SPACE + COLON + SPACE + myType.toKotlin(); + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/ParameterList.java b/src/org/jetbrains/jet/j2k/ast/ParameterList.java new file mode 100644 index 00000000000..7f26c4414eb --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/ParameterList.java @@ -0,0 +1,39 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.j2k.util.AstUtil; + +import java.util.List; + +/** + * @author ignatov + */ +public class ParameterList extends Expression { + private final List myParameters; + + public ParameterList(List parameters) { + myParameters = parameters; + } + + @NotNull + @Override + public String toKotlin() { + return AstUtil.joinNodes(myParameters, COMMA_WITH_SPACE); + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/ParenthesizedExpression.java b/src/org/jetbrains/jet/j2k/ast/ParenthesizedExpression.java new file mode 100644 index 00000000000..4f73f4ee719 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/ParenthesizedExpression.java @@ -0,0 +1,36 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +/** + * @author ignatov + */ +public class ParenthesizedExpression extends Expression { + private final Expression myExpression; + + public ParenthesizedExpression(Expression expression) { + myExpression = expression; + } + + @NotNull + @Override + public String toKotlin() { + return "(" + myExpression.toKotlin() + ")"; + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/PolyadicExpression.java b/src/org/jetbrains/jet/j2k/ast/PolyadicExpression.java new file mode 100644 index 00000000000..1523ed864c7 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/PolyadicExpression.java @@ -0,0 +1,45 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.j2k.util.AstUtil; + +import java.util.List; + +/** + * @author ignatov + */ +public class PolyadicExpression extends Expression { + private final List myExpressions; + private final String myToken; + private final List myConversions; + + public PolyadicExpression(List expressions, String token, List conversions) { + super(); + myExpressions = expressions; + myToken = token; + myConversions = conversions; + } + + @NotNull + @Override + public String toKotlin() { + List expressionsWithConversions = AstUtil.applyConversions(AstUtil.nodesToKotlin(myExpressions), myConversions); + return AstUtil.join(expressionsWithConversions, SPACE + myToken + SPACE); + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/PostfixOperator.java b/src/org/jetbrains/jet/j2k/ast/PostfixOperator.java new file mode 100644 index 00000000000..3b6eafdefac --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/PostfixOperator.java @@ -0,0 +1,38 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +/** + * @author ignatov + */ +public class PostfixOperator extends Expression { + private final String myOp; + private final Expression myExpression; + + public PostfixOperator(String op, Expression expression) { + myOp = op; + myExpression = expression; + } + + @NotNull + @Override + public String toKotlin() { + return myExpression.toKotlin() + myOp; + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/PrefixOperator.java b/src/org/jetbrains/jet/j2k/ast/PrefixOperator.java new file mode 100644 index 00000000000..28b4c92cff9 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/PrefixOperator.java @@ -0,0 +1,38 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +/** + * @author ignatov + */ +public class PrefixOperator extends Expression { + private final String myOp; + private final Expression myExpression; + + public PrefixOperator(String op, Expression expression) { + myOp = op; + myExpression = expression; + } + + @NotNull + @Override + public String toKotlin() { + return myOp + myExpression.toKotlin(); + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/PrimitiveType.java b/src/org/jetbrains/jet/j2k/ast/PrimitiveType.java new file mode 100644 index 00000000000..63ff3f900f9 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/PrimitiveType.java @@ -0,0 +1,41 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +/** + * @author ignatov + */ +public class PrimitiveType extends Type { + private final Identifier myType; + + public PrimitiveType(Identifier type) { + myType = type; + } + + @Override + public boolean isNullable() { + return false; + } + + @NotNull + @Override + public String toKotlin() { + return myType.toKotlin(); + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/ReferenceElement.java b/src/org/jetbrains/jet/j2k/ast/ReferenceElement.java new file mode 100644 index 00000000000..eb2cff5d92d --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/ReferenceElement.java @@ -0,0 +1,44 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.j2k.util.AstUtil; + +import java.util.List; + +/** + * @author ignatov + */ +public class ReferenceElement extends Element { + @NotNull + private final Identifier myReference; + @NotNull + private final List myTypes; + + public ReferenceElement(@NotNull Identifier reference, @NotNull List types) { + myReference = reference; + myTypes = types; + } + + @NotNull + @Override + public String toKotlin() { + String typesIfNeeded = myTypes.size() > 0 ? "<" + AstUtil.joinNodes(myTypes, COMMA_WITH_SPACE) + ">" : EMPTY; + return myReference.toKotlin() + typesIfNeeded; + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/ReturnStatement.java b/src/org/jetbrains/jet/j2k/ast/ReturnStatement.java new file mode 100644 index 00000000000..1a266668bd2 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/ReturnStatement.java @@ -0,0 +1,43 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.j2k.util.AstUtil; + +/** + * @author ignatov + */ +public class ReturnStatement extends Statement { + private final Expression myExpression; + private String myConversion = EMPTY; + + public ReturnStatement(Expression expression) { + myExpression = expression; + } + + public ReturnStatement(final Expression expression, final String conversion) { + this(expression); + myConversion = conversion; + } + + @NotNull + @Override + public String toKotlin() { + return "return" + SPACE + AstUtil.applyConversionForOneItem(myExpression.toKotlin(), myConversion); + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/StarProjectionType.java b/src/org/jetbrains/jet/j2k/ast/StarProjectionType.java new file mode 100644 index 00000000000..02c16ac4568 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/StarProjectionType.java @@ -0,0 +1,37 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +/** + * @author ignatov + */ +public class StarProjectionType extends Type { + @NotNull + @Override + public String toKotlin() { + G g = new G(""); + G g2 = new G(""); + return STAR; + } +} + +class G { + public G(T t) { + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/Statement.java b/src/org/jetbrains/jet/j2k/ast/Statement.java new file mode 100644 index 00000000000..90db4244f26 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/Statement.java @@ -0,0 +1,38 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +/** + * @author ignatov + */ +public abstract class Statement extends Element { + @NotNull + public static final Statement EMPTY_STATEMENT = new EmptyStatement(); + + /** + * @author ignatov + */ + private static class EmptyStatement extends Statement { + @NotNull + @Override + public String toKotlin() { + return EMPTY; + } + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/SuperExpression.java b/src/org/jetbrains/jet/j2k/ast/SuperExpression.java new file mode 100644 index 00000000000..7c9f974a573 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/SuperExpression.java @@ -0,0 +1,39 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +/** + * @author ignatov + */ +public class SuperExpression extends Expression { + private final Identifier myIdentifier; + + public SuperExpression(Identifier identifier) { + myIdentifier = identifier; + } + + @NotNull + @Override + public String toKotlin() { + if (myIdentifier.isEmpty()) { + return "super"; + } + return "super" + AT + myIdentifier.toKotlin(); + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/SureCallChainExpression.java b/src/org/jetbrains/jet/j2k/ast/SureCallChainExpression.java new file mode 100644 index 00000000000..76c29eb272f --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/SureCallChainExpression.java @@ -0,0 +1,43 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +/** + * @author ignatov + */ +public class SureCallChainExpression extends Expression { + private final Expression myExpression; + private final String myConversion; + + public SureCallChainExpression(Expression expression, String conversion) { + myExpression = expression; + myConversion = conversion; + } + + @Override + public boolean isEmpty() { + return myExpression.isEmpty(); + } + + @NotNull + @Override + public String toKotlin() { + return myExpression.toKotlin() + myConversion; + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/SwitchContainer.java b/src/org/jetbrains/jet/j2k/ast/SwitchContainer.java new file mode 100644 index 00000000000..49f41aac5fc --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/SwitchContainer.java @@ -0,0 +1,43 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.j2k.util.AstUtil; + +import java.util.List; + +/** + * @author ignatov + */ +public class SwitchContainer extends Statement { + private final Expression myExpression; + private final List myCaseContainers; + + public SwitchContainer(final Expression expression, final List caseContainers) { + myExpression = expression; + myCaseContainers = caseContainers; + } + + @NotNull + @Override + public String toKotlin() { + return "when" + SPACE + "(" + myExpression.toKotlin() + ")" + SPACE + "{" + N + + AstUtil.joinNodes(myCaseContainers, N) + N + + "}"; + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/SwitchLabelStatement.java b/src/org/jetbrains/jet/j2k/ast/SwitchLabelStatement.java new file mode 100644 index 00000000000..adec84ff6be --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/SwitchLabelStatement.java @@ -0,0 +1,36 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +/** + * @author ignatov + */ +public class SwitchLabelStatement extends Statement { + private final Expression myExpression; + + public SwitchLabelStatement(final Expression expression) { + myExpression = expression; + } + + @NotNull + @Override + public String toKotlin() { + return myExpression.toKotlin(); + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/SynchronizedStatement.java b/src/org/jetbrains/jet/j2k/ast/SynchronizedStatement.java new file mode 100644 index 00000000000..a635853a2db --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/SynchronizedStatement.java @@ -0,0 +1,38 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +/** + * @author ignatov + */ +public class SynchronizedStatement extends Statement { + private final Expression myExpression; + private final Block myBlock; + + public SynchronizedStatement(Expression expression, Block block) { + myExpression = expression; + myBlock = block; + } + + @NotNull + @Override + public String toKotlin() { + return "synchronized" + SPACE + "(" + myExpression.toKotlin() + ")" + SPACE + myBlock.toKotlin(); + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/ThisExpression.java b/src/org/jetbrains/jet/j2k/ast/ThisExpression.java new file mode 100644 index 00000000000..b7bb054a91f --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/ThisExpression.java @@ -0,0 +1,39 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +/** + * @author ignatov + */ +public class ThisExpression extends Expression { + private final Identifier myIdentifier; + + public ThisExpression(Identifier identifier) { + myIdentifier = identifier; + } + + @NotNull + @Override + public String toKotlin() { + if (myIdentifier.isEmpty()) { + return "this"; + } + return "this" + AT + myIdentifier.toKotlin(); + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/ThrowStatement.java b/src/org/jetbrains/jet/j2k/ast/ThrowStatement.java new file mode 100644 index 00000000000..f0b0cbf1a99 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/ThrowStatement.java @@ -0,0 +1,36 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +/** + * @author ignatov + */ +public class ThrowStatement extends Expression { + private final Expression myExpression; + + public ThrowStatement(Expression expression) { + myExpression = expression; + } + + @NotNull + @Override + public String toKotlin() { + return "throw" + SPACE + myExpression.toKotlin(); + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/Trait.java b/src/org/jetbrains/jet/j2k/ast/Trait.java new file mode 100644 index 00000000000..ecaffa79427 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/Trait.java @@ -0,0 +1,42 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.jet.j2k.Converter; + +import java.util.List; +import java.util.Set; + +/** + * @author ignatov + */ +public class Trait extends Class { + public Trait(Converter converter, Identifier name, Set modifiers, List typeParameters, List extendsTypes, + List baseClassParams, List implementsTypes, List members) { + super(converter, name, modifiers, typeParameters, extendsTypes, baseClassParams, implementsTypes, getMembers(members, converter)); + TYPE = "trait"; + } + + @Override + String primaryConstructorSignatureToKotlin() { + return EMPTY; + } + + boolean needOpenModifier() { + return false; + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/TryStatement.java b/src/org/jetbrains/jet/j2k/ast/TryStatement.java new file mode 100644 index 00000000000..7bc3ba4bc93 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/TryStatement.java @@ -0,0 +1,46 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.j2k.util.AstUtil; + +import java.util.List; + +/** + * @author ignatov + */ +public class TryStatement extends Statement { + private final Block myBlock; + private final List myCatches; + private final Block myFinallyBlock; + + public TryStatement(Block block, List catches, Block finallyBlock) { + myBlock = block; + myCatches = catches; + myFinallyBlock = finallyBlock; + } + + @NotNull + @Override + public String toKotlin() { + return "try" + N + + myBlock.toKotlin() + N + + AstUtil.joinNodes(myCatches, N) + N + + (myFinallyBlock.isEmpty() ? EMPTY : "finally" + N + myFinallyBlock.toKotlin()); + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/Type.java b/src/org/jetbrains/jet/j2k/ast/Type.java new file mode 100644 index 00000000000..b58d92fdc2e --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/Type.java @@ -0,0 +1,64 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +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; + + @NotNull + @Override + public Kind getKind() { + return Kind.TYPE; + } + + @NotNull + public Type convertedToNotNull() { + myNullable = false; + return this; + } + + public boolean isNullable() { + return myNullable; + } + + String isNullableStr() { + return isNullable() ? QUEST : EMPTY; + } + + /** + * @author ignatov + */ + private static class EmptyType extends Type { + @NotNull + @Override + public String toKotlin() { + return "UNRESOLVED_TYPE"; + } + + @Override + public boolean isNullable() { + return false; + } + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/TypeCastExpression.java b/src/org/jetbrains/jet/j2k/ast/TypeCastExpression.java new file mode 100644 index 00000000000..ca0981c3f85 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/TypeCastExpression.java @@ -0,0 +1,38 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +/** + * @author ignatov + */ +public class TypeCastExpression extends Expression { + private final Type myType; + private final Expression myExpression; + + public TypeCastExpression(Type type, Expression expression) { + myType = type; + myExpression = expression; + } + + @NotNull + @Override + public String toKotlin() { + return "(" + myExpression.toKotlin() + SPACE + "as" + SPACE + myType.toKotlin() + ")"; + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/TypeElement.java b/src/org/jetbrains/jet/j2k/ast/TypeElement.java new file mode 100644 index 00000000000..1985b864db5 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/TypeElement.java @@ -0,0 +1,36 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +/** + * @author ignatov + */ +public class TypeElement extends Element { + private final Type myType; + + public TypeElement(Type type) { + myType = type; + } + + @NotNull + @Override + public String toKotlin() { + return myType.toKotlin(); + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/TypeParameter.java b/src/org/jetbrains/jet/j2k/ast/TypeParameter.java new file mode 100644 index 00000000000..d45bfe60f50 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/TypeParameter.java @@ -0,0 +1,55 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +/** + * @author ignatov + */ +public class TypeParameter extends Element { + private final Identifier myName; + private final List myExtendsTypes; + + public TypeParameter(Identifier name, List extendsTypes) { + myName = name; + myExtendsTypes = extendsTypes; + } + + public boolean hasWhere() { + return myExtendsTypes.size() > 1; + } + + @NotNull + public String getWhereToKotlin() { + if (hasWhere()) { + return myName.toKotlin() + SPACE + COLON + SPACE + myExtendsTypes.get(1).toKotlin(); + } + return EMPTY; + } + + @NotNull + @Override + public String toKotlin() { + if (myExtendsTypes.size() > 0) { + return myName.toKotlin() + SPACE + COLON + SPACE + myExtendsTypes.get(0).toKotlin(); + } + return myName.toKotlin(); + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/VarArg.java b/src/org/jetbrains/jet/j2k/ast/VarArg.java new file mode 100644 index 00000000000..8571738285e --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/VarArg.java @@ -0,0 +1,42 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +/** + * @author ignatov + */ +public class VarArg extends Type { + private final Type myType; + + public VarArg(Type type) { + myType = type; + } + + @NotNull + @Override + public Kind getKind() { + return Kind.VARARG; + } + + @NotNull + @Override + public String toKotlin() { + return myType.toKotlin(); + } +} diff --git a/src/org/jetbrains/jet/j2k/ast/WhileStatement.java b/src/org/jetbrains/jet/j2k/ast/WhileStatement.java new file mode 100644 index 00000000000..9ee87e671cb --- /dev/null +++ b/src/org/jetbrains/jet/j2k/ast/WhileStatement.java @@ -0,0 +1,39 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.ast; + +import org.jetbrains.annotations.NotNull; + +/** + * @author ignatov + */ +public class WhileStatement extends Statement { + final Expression myCondition; + final Statement myStatement; + + public WhileStatement(Expression condition, Statement statement) { + myCondition = condition; + myStatement = statement; + } + + @NotNull + @Override + public String toKotlin() { + return "while" + SPACE + "(" + myCondition.toKotlin() + ")" + N + + myStatement.toKotlin(); + } +} diff --git a/src/org/jetbrains/jet/j2k/util/AstUtil.java b/src/org/jetbrains/jet/j2k/util/AstUtil.java new file mode 100644 index 00000000000..bdc3cb6037e --- /dev/null +++ b/src/org/jetbrains/jet/j2k/util/AstUtil.java @@ -0,0 +1,118 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.util; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.j2k.ast.INode; + +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +/** + * @author ignatov + */ +public class AstUtil { + private AstUtil() { + } + + private static String join(@NotNull final String[] array, @Nullable final String delimiter) { + StringBuilder buffer = new StringBuilder(); + boolean haveDelimiter = (delimiter != null); + + for (int i = 0; i < array.length; i++) { + buffer.append(array[i]); + + if (haveDelimiter && (i + 1) < array.length) { + buffer.append(delimiter); + } + } + + return buffer.toString(); + } + + public static String joinNodes(@NotNull final List nodes, final String delimiter) { + return join(nodesToKotlin(nodes), delimiter); + } + + public static String join(@NotNull final List array, final String delimiter) { + return join(array.toArray(new String[array.size()]), delimiter); + } + + @NotNull + public static List nodesToKotlin(@NotNull List nodes) { + List result = new LinkedList(); + for (INode n : nodes) + result.add(n.toKotlin()); + return result; + } + + @NotNull + public static String upperFirstCharacter(@NotNull String string) { + return string.substring(0, 1).toUpperCase() + string.substring(1); + } + + @NotNull + public static String lowerFirstCharacter(@NotNull String string) { + return string.substring(0, 1).toLowerCase() + string.substring(1); + } + + @NotNull + public static List createListWithEmptyString(@NotNull final List arguments) { + final List conversions = new LinkedList(); + //noinspection UnusedDeclaration + for (T argument : arguments) conversions.add(""); + return conversions; + } + + @NotNull + public static List applyConversions(@NotNull List first, @NotNull List second) { + List result = new LinkedList(); + assert first.size() == second.size() : "Lists must have the same size."; + for (int i = 0; i < first.size(); i++) { + result.add(applyConversionForOneItem(first.get(i), second.get(i))); + } + return result; + } + + @NotNull + public static String applyConversionForOneItem(@NotNull String f, @NotNull String s) { + if (s.isEmpty()) { + return f; + } + else { + return "(" + f + ")" + s; + } + } + + @NotNull + public static T getOrElse(@NotNull Map map, @NotNull T e, @NotNull T orElse) { + if (map.containsKey(e)) { + return map.get(e); + } + return orElse; + } + + @NotNull + public static String replaceLastQuest(@NotNull String str) { + if (str.endsWith("?")) { + return str.substring(0, str.length() - 1); + } + return str; + } +} diff --git a/src/org/jetbrains/jet/j2k/visitors/ClassVisitor.java b/src/org/jetbrains/jet/j2k/visitors/ClassVisitor.java new file mode 100644 index 00000000000..49816e40dd1 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/visitors/ClassVisitor.java @@ -0,0 +1,46 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +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; + +/** + * @author ignatov + */ +public class ClassVisitor extends JavaRecursiveElementVisitor { + private final Set myClassIdentifiers; + + public ClassVisitor() { + myClassIdentifiers = new HashSet(); + } + + @NotNull + public Set getClassIdentifiers() { + return new HashSet(myClassIdentifiers); + } + + @Override + public void visitClass(@NotNull PsiClass aClass) { + myClassIdentifiers.add(aClass.getQualifiedName()); + super.visitClass(aClass); + } +} diff --git a/src/org/jetbrains/jet/j2k/visitors/Dispatcher.java b/src/org/jetbrains/jet/j2k/visitors/Dispatcher.java new file mode 100644 index 00000000000..063c5e81daf --- /dev/null +++ b/src/org/jetbrains/jet/j2k/visitors/Dispatcher.java @@ -0,0 +1,39 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.visitors; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.j2k.Converter; + +/** + * @author ignatov + */ +public class Dispatcher { + private ExpressionVisitor myExpressionVisitor; + + public void setExpressionVisitor(final ExpressionVisitor expressionVisitor) { + this.myExpressionVisitor = expressionVisitor; + } + + public Dispatcher(@NotNull Converter converter) { + myExpressionVisitor = new ExpressionVisitor(converter); + } + + public ExpressionVisitor getExpressionVisitor() { + return myExpressionVisitor; + } +} diff --git a/src/org/jetbrains/jet/j2k/visitors/ElementVisitor.java b/src/org/jetbrains/jet/j2k/visitors/ElementVisitor.java new file mode 100644 index 00000000000..5ba41a3f703 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/visitors/ElementVisitor.java @@ -0,0 +1,123 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.visitors; + +import com.intellij.psi.*; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.j2k.Converter; +import org.jetbrains.jet.j2k.ast.*; + +import java.util.List; + +import static org.jetbrains.jet.j2k.Converter.modifiersListToModifiersSet; +import static org.jetbrains.jet.j2k.ConverterUtil.isAnnotatedAsNotNull; + +/** + * @author ignatov + */ +public class ElementVisitor extends JavaElementVisitor implements J2KVisitor { + + private final Converter myConverter; + + @NotNull + private Element myResult = Element.EMPTY_ELEMENT; + + public ElementVisitor(@NotNull Converter converter) { + this.myConverter = converter; + } + + @Override + @NotNull + public Converter getConverter() { + return myConverter; + } + + @NotNull + public Element getResult() { + return myResult; + } + + @Override + public void visitLocalVariable(@NotNull PsiLocalVariable variable) { + super.visitLocalVariable(variable); + + myResult = new LocalVariable( + new IdentifierImpl(variable.getName()), // TODO + modifiersListToModifiersSet(variable.getModifierList()), + getConverter().typeToType(variable.getType(), isAnnotatedAsNotNull(variable.getModifierList())), + getConverter().createSureCallOnlyForChain(variable.getInitializer(), variable.getType()) + ); + } + + @Override + public void visitExpressionList(@NotNull PsiExpressionList list) { + super.visitExpressionList(list); + myResult = new ExpressionList( + getConverter().expressionsToExpressionList(list.getExpressions()), + getConverter().typesToTypeList(list.getExpressionTypes()) + ); + } + + @Override + public void visitReferenceElement(@NotNull PsiJavaCodeReferenceElement reference) { + super.visitReferenceElement(reference); + + final List types = getConverter().typesToTypeList(reference.getTypeParameters()); + if (!reference.isQualified()) { + myResult = new ReferenceElement( + new IdentifierImpl(reference.getReferenceName()), + types + ); + } + else { + String result = new IdentifierImpl(reference.getReferenceName()).toKotlin(); + PsiElement qualifier = reference.getQualifier(); + while (qualifier != null) { + final PsiJavaCodeReferenceElement p = (PsiJavaCodeReferenceElement) qualifier; + result = new IdentifierImpl(p.getReferenceName()).toKotlin() + "." + result; // TODO: maybe need to replace by safe call? + qualifier = p.getQualifier(); + } + myResult = new ReferenceElement( + new IdentifierImpl(result), + types + ); + } + } + + @Override + public void visitTypeElement(@NotNull PsiTypeElement type) { + super.visitTypeElement(type); + myResult = new TypeElement(getConverter().typeToType(type.getType())); + } + + @Override + public void visitTypeParameter(@NotNull PsiTypeParameter classParameter) { + super.visitTypeParameter(classParameter); + myResult = new TypeParameter( + new IdentifierImpl(classParameter.getName()), // TODO + getConverter().typesToTypeList(classParameter.getExtendsListTypes()) + ); + } + + @Override + public void visitParameterList(@NotNull PsiParameterList list) { + super.visitParameterList(list); + myResult = new ParameterList( + getConverter().parametersToParameterList(list.getParameters()) + ); + } +} diff --git a/src/org/jetbrains/jet/j2k/visitors/ExpressionVisitor.java b/src/org/jetbrains/jet/j2k/visitors/ExpressionVisitor.java new file mode 100644 index 00000000000..588ce347b1d --- /dev/null +++ b/src/org/jetbrains/jet/j2k/visitors/ExpressionVisitor.java @@ -0,0 +1,506 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.visitors; + +import com.intellij.psi.*; +import com.intellij.psi.tree.IElementType; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.j2k.Converter; +import org.jetbrains.jet.j2k.ast.*; +import org.jetbrains.jet.lang.types.expressions.OperatorConventions; + +import java.util.Collections; +import java.util.List; + +import static org.jetbrains.jet.j2k.Converter.isConstructorPrimary; +import static org.jetbrains.jet.j2k.visitors.TypeVisitor.*; + +/** + * @author ignatov + */ +public class ExpressionVisitor extends StatementVisitor { + @NotNull + Expression myResult = Expression.EMPTY_EXPRESSION; + + public ExpressionVisitor(@NotNull Converter converter) { + super(converter); + } + + @Override + public void visitExpression(final PsiExpression expression) { + myResult = Expression.EMPTY_EXPRESSION; + } + + @NotNull + @Override + public Expression getResult() { + return myResult; + } + + @Override + public void visitArrayAccessExpression(@NotNull PsiArrayAccessExpression expression) { + super.visitArrayAccessExpression(expression); + myResult = new ArrayAccessExpression( + getConverter().expressionToExpression(expression.getArrayExpression()), + getConverter().expressionToExpression(expression.getIndexExpression()) + ); + } + + @Override + public void visitArrayInitializerExpression(@NotNull PsiArrayInitializerExpression expression) { + super.visitArrayInitializerExpression(expression); + myResult = new ArrayInitializerExpression( + getConverter().typeToType(expression.getType()), + getConverter().expressionsToExpressionList(expression.getInitializers()) + ); + } + + @Override + public void visitAssignmentExpression(@NotNull PsiAssignmentExpression expression) { + super.visitAssignmentExpression(expression); + + // TODO: simplify + + final IElementType tokenType = expression.getOperationSign().getTokenType(); + + String secondOp = ""; + if (tokenType == JavaTokenType.GTGTEQ) secondOp = "shr"; + if (tokenType == JavaTokenType.LTLTEQ) secondOp = "shl"; + if (tokenType == JavaTokenType.XOREQ) secondOp = "xor"; + if (tokenType == JavaTokenType.ANDEQ) secondOp = "and"; + if (tokenType == JavaTokenType.OREQ) secondOp = "or"; + if (tokenType == JavaTokenType.GTGTGTEQ) secondOp = "ushr"; + + if (!secondOp.isEmpty()) // if not Kotlin operators + { + myResult = new AssignmentExpression( + getConverter().expressionToExpression(expression.getLExpression()), + new BinaryExpression( + getConverter().expressionToExpression(expression.getLExpression()), + getConverter().expressionToExpression(expression.getRExpression()), + secondOp + ), + "=" + ); + } + else { + myResult = new AssignmentExpression( + getConverter().expressionToExpression(expression.getLExpression()), + getConverter().expressionToExpression(expression.getRExpression()), + expression.getOperationSign().getText() // TODO + ); + } + } + + @NotNull + private static String getOperatorString(@NotNull IElementType tokenType) { + if (tokenType == JavaTokenType.PLUS) return "+"; + if (tokenType == JavaTokenType.MINUS) return "-"; + if (tokenType == JavaTokenType.ASTERISK) return "*"; + if (tokenType == JavaTokenType.DIV) return "/"; + if (tokenType == JavaTokenType.PERC) return "%"; + if (tokenType == JavaTokenType.GTGT) return "shr"; + if (tokenType == JavaTokenType.LTLT) return "shl"; + if (tokenType == JavaTokenType.XOR) return "xor"; + if (tokenType == JavaTokenType.AND) return "and"; + if (tokenType == JavaTokenType.OR) return "or"; + if (tokenType == JavaTokenType.GTGTGT) return "ushr"; + if (tokenType == JavaTokenType.GT) return ">"; + if (tokenType == JavaTokenType.LT) return "<"; + if (tokenType == JavaTokenType.GE) return ">="; + if (tokenType == JavaTokenType.LE) return "<="; + if (tokenType == JavaTokenType.EQEQ) return "=="; + if (tokenType == JavaTokenType.NE) return "!="; + if (tokenType == JavaTokenType.ANDAND) return "&&"; + if (tokenType == JavaTokenType.OROR) return "||"; + if (tokenType == JavaTokenType.PLUSPLUS) return "++"; + if (tokenType == JavaTokenType.MINUSMINUS) return "--"; + if (tokenType == JavaTokenType.EXCL) return "!"; + + System.out.println("UNSUPPORTED TOKEN TYPE: " + tokenType.toString()); + return ""; + } + + @Override + public void visitBinaryExpression(@NotNull PsiBinaryExpression expression) { + super.visitBinaryExpression(expression); + + if (expression.getOperationSign().getTokenType() == JavaTokenType.GTGTGT) { + myResult = new DummyMethodCallExpression( + getConverter().expressionToExpression(expression.getLOperand()), + "ushr", + getConverter().expressionToExpression(expression.getROperand())); + } + else { + myResult = + new BinaryExpression( + getConverter().expressionToExpression(expression.getLOperand()), + getConverter().expressionToExpression(expression.getROperand()), + getOperatorString(expression.getOperationSign().getTokenType()), + getConverter().createConversions(expression, PsiType.BOOLEAN) + ); + } + } + + @Override + public void visitClassObjectAccessExpression(@NotNull PsiClassObjectAccessExpression expression) { + super.visitClassObjectAccessExpression(expression); + myResult = new ClassObjectAccessExpression(getConverter().elementToElement(expression.getOperand())); + } + + @Override + public void visitConditionalExpression(@NotNull PsiConditionalExpression expression) { + super.visitConditionalExpression(expression); + PsiExpression condition = expression.getCondition(); + PsiType type = condition.getType(); + Expression e = type != null ? + getConverter().createSureCallOnlyForChain(condition, type) : + getConverter().expressionToExpression(condition); + myResult = new ParenthesizedExpression( + new IfStatement( + e, + getConverter().expressionToExpression(expression.getThenExpression()), + getConverter().expressionToExpression(expression.getElseExpression()) + ) + ); + } + + @Override + public void visitExpressionList(@NotNull PsiExpressionList list) { + super.visitExpressionList(list); + myResult = new ExpressionList(getConverter().expressionsToExpressionList(list.getExpressions())); + } + + @Override + public void visitInstanceOfExpression(@NotNull PsiInstanceOfExpression expression) { + super.visitInstanceOfExpression(expression); + myResult = new IsOperator( + getConverter().expressionToExpression(expression.getOperand()), + getConverter().elementToElement(expression.getCheckType())); + } + + @Override + public void visitLiteralExpression(@NotNull PsiLiteralExpression expression) { + super.visitLiteralExpression(expression); + + final Object value = expression.getValue(); + String text = expression.getText(); + boolean isQuotingNeeded = true; + + final PsiType type = expression.getType(); + if (type != null) { + String canonicalTypeStr = type.getCanonicalText(); + if (canonicalTypeStr.equals("double") || canonicalTypeStr.equals(JAVA_LANG_DOUBLE)) { + text = text.replace("D", "").replace("d", ""); + } + if (canonicalTypeStr.equals("float") || canonicalTypeStr.equals(JAVA_LANG_FLOAT)) { + text = text.replace("F", "").replace("f", "") + "." + OperatorConventions.FLOAT + "()"; + } + if (canonicalTypeStr.equals("long") || canonicalTypeStr.equals(JAVA_LANG_LONG)) { + text = text.replace("L", "").replace("l", ""); + } + if (canonicalTypeStr.equals("int") || canonicalTypeStr.equals(JAVA_LANG_INTEGER)) // need for hex support + { + text = value != null ? value.toString() : text; + } + + if (canonicalTypeStr.equals(JAVA_LANG_STRING)) { + isQuotingNeeded = false; + } + if (canonicalTypeStr.equals("char") || canonicalTypeStr.equals(JAVA_LANG_CHARACTER)) { + isQuotingNeeded = false; + } + } + myResult = new LiteralExpression(new IdentifierImpl(text, false, isQuotingNeeded)); + } + + @Override + public void visitMethodCallExpression(@NotNull PsiMethodCallExpression expression) { + super.visitMethodCallExpression(expression); + if (!SuperVisitor.isSuper(expression.getMethodExpression()) || !isInsidePrimaryConstructor(expression)) { + myResult = // TODO: not resolved + new MethodCallExpression( + getConverter().expressionToExpression(expression.getMethodExpression()), + getConverter().expressionsToExpressionList(expression.getArgumentList().getExpressions()), + getConverter().createConversions(expression), + getConverter().typeToType(expression.getType()).isNullable(), + getConverter().typesToTypeList(expression.getTypeArguments()) + ); + } + } + + @Override + public void visitCallExpression(PsiCallExpression callExpression) { + super.visitCallExpression(callExpression); + } + + @Override + public void visitNewExpression(@NotNull PsiNewExpression expression) { + super.visitNewExpression(expression); + if (expression.getArrayInitializer() != null) // new Foo[] {Foo(1), Foo(2)} + { + myResult = createNewEmptyArray(expression); + } + else if (expression.getArrayDimensions().length > 0) { // new Foo[5] + myResult = createNewEmptyArrayWithoutInitialization(expression); + } + else { // new Class(): common case + myResult = createNewClassExpression(expression); + } + } + + @NotNull + private Expression createNewClassExpression(@NotNull PsiNewExpression expression) { + final PsiAnonymousClass anonymousClass = expression.getAnonymousClass(); + final PsiMethod constructor = expression.resolveMethod(); + PsiJavaCodeReferenceElement classReference = expression.getClassOrAnonymousClassReference(); + final boolean isNotConvertedClass = classReference != null && !getConverter().getClassIdentifiers().contains(classReference.getQualifiedName()); + PsiExpressionList argumentList = expression.getArgumentList(); + PsiExpression[] arguments = argumentList != null ? argumentList.getExpressions() : new PsiExpression[]{}; + if (constructor == null || isConstructorPrimary(constructor) || isNotConvertedClass) { + return new NewClassExpression( + getConverter().expressionToExpression(expression.getQualifier()), + getConverter().elementToElement(classReference), + getConverter().expressionsToExpressionList(arguments), + getConverter().createConversions(expression), + anonymousClass != null ? getConverter().anonymousClassToAnonymousClass(anonymousClass) : null + ); + } + // is constructor secondary + final PsiJavaCodeReferenceElement reference = expression.getClassReference(); + final List typeParameters = reference != null + ? getConverter().typesToTypeList(reference.getTypeParameters()) + : Collections.emptyList(); + return new CallChainExpression( + new IdentifierImpl(constructor.getName(), false), + new MethodCallExpression( + new IdentifierImpl("init"), + getConverter().expressionsToExpressionList(arguments), + typeParameters)); + } + + @NotNull + private Expression createNewEmptyArrayWithoutInitialization(@NotNull PsiNewExpression expression) { + return new ArrayWithoutInitializationExpression( + getConverter().typeToType(expression.getType(), true), + getConverter().expressionsToExpressionList(expression.getArrayDimensions()) + ); + } + + @NotNull + private Expression createNewEmptyArray(@NotNull PsiNewExpression expression) { + return getConverter().expressionToExpression(expression.getArrayInitializer()); + } + + @Override + public void visitParenthesizedExpression(@NotNull PsiParenthesizedExpression expression) { + super.visitParenthesizedExpression(expression); + myResult = new ParenthesizedExpression( + getConverter().expressionToExpression(expression.getExpression()) + ); + } + + @Override + public void visitPostfixExpression(@NotNull PsiPostfixExpression expression) { + super.visitPostfixExpression(expression); + myResult = new PostfixOperator( + getOperatorString(expression.getOperationSign().getTokenType()), + getConverter().expressionToExpression(expression.getOperand()) + ); + } + + @Override + public void visitPrefixExpression(@NotNull PsiPrefixExpression expression) { + super.visitPrefixExpression(expression); + if (expression.getOperationTokenType() == JavaTokenType.TILDE) { + myResult = new DummyMethodCallExpression( + new ParenthesizedExpression(getConverter().expressionToExpression(expression.getOperand())), "inv", Expression.EMPTY_EXPRESSION + ); + } + else { + myResult = new PrefixOperator( + getOperatorString(expression.getOperationSign().getTokenType()), + getConverter().expressionToExpression(expression.getOperand()) + ); + } + } + + @Override + public void visitReferenceExpression(@NotNull PsiReferenceExpression expression) { + super.visitReferenceExpression(expression); + + final boolean isFieldReference = isFieldReference(expression, getContainingClass(expression)); + final boolean insideSecondaryConstructor = isInsideSecondaryConstructor(expression); + final boolean hasReceiver = isFieldReference && insideSecondaryConstructor; + final boolean isThis = isThisExpression(expression); + final boolean isNullable = getConverter().typeToType(expression.getType()).isNullable(); + final String className = getClassNameWithConstructor(expression); + + Expression identifier = new IdentifierImpl(expression.getReferenceName(), isNullable); + + final String __ = "__"; + if (hasReceiver) { + identifier = new CallChainExpression(new IdentifierImpl(__, false), new IdentifierImpl(expression.getReferenceName(), isNullable)); + } + else if (insideSecondaryConstructor && isThis) { + identifier = new IdentifierImpl("val __ = " + className); // TODO: hack + } + + myResult = new CallChainExpression( + getConverter().expressionToExpression(expression.getQualifierExpression()), + identifier // TODO: if type exists so identifier is nullable + ); + } + + @NotNull + private static String getClassNameWithConstructor(@NotNull PsiReferenceExpression expression) { + PsiElement context = expression.getContext(); + while (context != null) { + if (context instanceof PsiMethod && ((PsiMethod) context).isConstructor()) { + final PsiClass containingClass = ((PsiMethod) context).getContainingClass(); + if (containingClass != null) { + final PsiIdentifier identifier = containingClass.getNameIdentifier(); + if (identifier != null) { + return identifier.getText(); + } + } + } + context = context.getContext(); + } + return ""; + } + + @NotNull + static String getClassName(@NotNull PsiExpression expression) { + PsiElement context = expression.getContext(); + while (context != null) { + if (context instanceof PsiClass) { + final PsiClass containingClass = (PsiClass) context; + final PsiIdentifier identifier = containingClass.getNameIdentifier(); + if (identifier != null) { + return identifier.getText(); + } + } + context = context.getContext(); + } + return ""; + } + + private static boolean isFieldReference(@NotNull PsiReferenceExpression expression, PsiClass currentClass) { + final PsiReference reference = expression.getReference(); + if (reference != null) { + final PsiElement resolvedReference = reference.resolve(); + if (resolvedReference != null) { + if (resolvedReference instanceof PsiField) { + return ((PsiField) resolvedReference).getContainingClass() == currentClass; + } + } + } + return false; + } + + private static boolean isInsideSecondaryConstructor(@NotNull PsiReferenceExpression expression) { + PsiElement context = expression.getContext(); + while (context != null) { + if (context instanceof PsiMethod && ((PsiMethod) context).isConstructor()) { + return !isConstructorPrimary((PsiMethod) context); + } + context = context.getContext(); + } + return false; + } + + private static boolean isInsidePrimaryConstructor(@NotNull PsiExpression expression) { + PsiElement context = expression.getContext(); + while (context != null) { + if (context instanceof PsiMethod && ((PsiMethod) context).isConstructor()) { + return isConstructorPrimary((PsiMethod) context); + } + context = context.getContext(); + } + return false; + } + + @Nullable + private static PsiClass getContainingClass(@NotNull PsiExpression expression) { + PsiElement context = expression.getContext(); + while (context != null) { + if (context instanceof PsiMethod && ((PsiMethod) context).isConstructor()) { + return ((PsiMethod) context).getContainingClass(); + } + context = context.getContext(); + } + return null; + } + + private static boolean isThisExpression(@NotNull PsiReferenceExpression expression) { + for (PsiReference r : expression.getReferences()) + if (r.getCanonicalText().equals("this")) { + final PsiElement res = r.resolve(); + if (res != null && res instanceof PsiMethod && ((PsiMethod) res).isConstructor()) { + return true; + } + } + return false; + } + + @Override + public void visitSuperExpression(@NotNull PsiSuperExpression expression) { + super.visitSuperExpression(expression); + final PsiJavaCodeReferenceElement qualifier = expression.getQualifier(); + myResult = new SuperExpression( + qualifier != null ? + new IdentifierImpl(qualifier.getQualifiedName()) : + Identifier.EMPTY_IDENTIFIER + ); + } + + @Override + public void visitThisExpression(@NotNull PsiThisExpression expression) { + super.visitThisExpression(expression); + final PsiJavaCodeReferenceElement qualifier = expression.getQualifier(); + myResult = new ThisExpression( + qualifier != null ? + new IdentifierImpl(qualifier.getQualifiedName()) : + Identifier.EMPTY_IDENTIFIER + ); + } + + @Override + public void visitTypeCastExpression(@NotNull PsiTypeCastExpression expression) { + super.visitTypeCastExpression(expression); + + final PsiTypeElement castType = expression.getCastType(); + if (castType != null) { + myResult = new TypeCastExpression( + getConverter().typeToType(castType.getType()), + getConverter().expressionToExpression(expression.getOperand()) + ); + } + } + + @Override + public void visitPolyadicExpression(@NotNull PsiPolyadicExpression expression) { + super.visitPolyadicExpression(expression); + myResult = new PolyadicExpression( + getConverter().expressionsToExpressionList(expression.getOperands()), + getOperatorString(expression.getOperationTokenType()), + getConverter().createConversions(expression, PsiType.BOOLEAN) + ); + } +} diff --git a/src/org/jetbrains/jet/j2k/visitors/ExpressionVisitorForDirectObjectInheritors.java b/src/org/jetbrains/jet/j2k/visitors/ExpressionVisitorForDirectObjectInheritors.java new file mode 100644 index 00000000000..e78d1b948a1 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/visitors/ExpressionVisitorForDirectObjectInheritors.java @@ -0,0 +1,70 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.visitors; + +import com.intellij.psi.*; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.j2k.Converter; +import org.jetbrains.jet.j2k.ast.DummyMethodCallExpression; +import org.jetbrains.jet.j2k.ast.DummyStringExpression; +import org.jetbrains.jet.j2k.ast.IdentifierImpl; + +import static org.jetbrains.jet.j2k.visitors.TypeVisitor.JAVA_LANG_OBJECT; + +/** + * @author ignatov + */ +public class ExpressionVisitorForDirectObjectInheritors extends ExpressionVisitor { + public ExpressionVisitorForDirectObjectInheritors(@NotNull Converter converter) { + super(converter); + } + + @Override + public void visitMethodCallExpression(@NotNull final PsiMethodCallExpression expression) { + if (superMethodInvocation(expression.getMethodExpression(), "hashCode")) { + myResult = new DummyMethodCallExpression(new IdentifierImpl("System"), "identityHashCode", new IdentifierImpl("this")); + } + else if (superMethodInvocation(expression.getMethodExpression(), "equals")) { + myResult = new DummyMethodCallExpression(new IdentifierImpl("this"), "identityEquals", getConverter().elementToElement(expression.getArgumentList())); + } + else if (superMethodInvocation(expression.getMethodExpression(), "toString")) { + myResult = new DummyStringExpression(String.format("getJavaClass<%s>.getName() + '@' + Integer.toHexString(hashCode())", getClassName(expression.getMethodExpression()))); + } + else { + super.visitMethodCallExpression(expression); + } + } + + @Override + public void visitReferenceExpression(@NotNull final PsiReferenceExpression expression) { + super.visitReferenceExpression(expression); + } + + private static boolean superMethodInvocation(@NotNull final PsiReferenceExpression expression, final String methodName) { + String referenceName = expression.getReferenceName(); + PsiExpression qualifierExpression = expression.getQualifierExpression(); + if (referenceName != null && referenceName.equals(methodName)) { + if (qualifierExpression instanceof PsiSuperExpression) { + PsiType type = qualifierExpression.getType(); + if (type != null && type.getCanonicalText().equals(JAVA_LANG_OBJECT)) { + return true; + } + } + } + return false; + } +} diff --git a/src/org/jetbrains/jet/j2k/visitors/J2KVisitor.java b/src/org/jetbrains/jet/j2k/visitors/J2KVisitor.java new file mode 100644 index 00000000000..7be1fe9504a --- /dev/null +++ b/src/org/jetbrains/jet/j2k/visitors/J2KVisitor.java @@ -0,0 +1,28 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.visitors; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.j2k.Converter; + +/** + * @author abreslav + */ +public interface J2KVisitor { + @NotNull + Converter getConverter(); +} diff --git a/src/org/jetbrains/jet/j2k/visitors/StatementVisitor.java b/src/org/jetbrains/jet/j2k/visitors/StatementVisitor.java new file mode 100644 index 00000000000..1cb4d33093b --- /dev/null +++ b/src/org/jetbrains/jet/j2k/visitors/StatementVisitor.java @@ -0,0 +1,396 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.visitors; + +import com.intellij.psi.*; +import com.intellij.psi.tree.IElementType; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.j2k.Converter; +import org.jetbrains.jet.j2k.ast.*; + +import java.util.Arrays; +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; + +import static org.jetbrains.jet.j2k.Converter.identifierToIdentifier; +import static org.jetbrains.jet.j2k.ConverterUtil.countWritingAccesses; + +/** + * @author ignatov + */ +public class StatementVisitor extends ElementVisitor { + private Statement myResult = Statement.EMPTY_STATEMENT; + + public StatementVisitor(@NotNull Converter converter) { + super(converter); + } + + @NotNull + @Override + public Statement getResult() { + return myResult; + } + + @Override + public void visitAssertStatement(@NotNull PsiAssertStatement statement) { + super.visitAssertStatement(statement); + myResult = new AssertStatement( + getConverter().expressionToExpression(statement.getAssertCondition()), + getConverter().expressionToExpression(statement.getAssertDescription()) + ); + } + + @Override + public void visitBlockStatement(@NotNull PsiBlockStatement statement) { + super.visitBlockStatement(statement); + myResult = new Block( + getConverter().statementsToStatementList(statement.getCodeBlock().getStatements()), + true + ); + } + + @Override + public void visitBreakStatement(@NotNull PsiBreakStatement statement) { + super.visitBreakStatement(statement); + if (statement.getLabelIdentifier() == null) { + myResult = new BreakStatement(); + } + else { + myResult = new BreakStatement( + identifierToIdentifier(statement.getLabelIdentifier()) + ); + } + } + + @Override + public void visitContinueStatement(@NotNull PsiContinueStatement statement) { + super.visitContinueStatement(statement); + if (statement.getLabelIdentifier() == null) { + myResult = new ContinueStatement(); + } + else { + myResult = new ContinueStatement( + identifierToIdentifier(statement.getLabelIdentifier()) + ); + } + } + + @Override + public void visitDeclarationStatement(@NotNull PsiDeclarationStatement statement) { + super.visitDeclarationStatement(statement); + myResult = new DeclarationStatement( + getConverter().elementsToElementList(statement.getDeclaredElements()) + ); + } + + @Override + public void visitDoWhileStatement(@NotNull PsiDoWhileStatement statement) { + super.visitDoWhileStatement(statement); + PsiExpression condition = statement.getCondition(); + @SuppressWarnings("ConstantConditions") + Expression expression = condition != null && condition.getType() != null ? + getConverter().createSureCallOnlyForChain(condition, condition.getType()) : + getConverter().expressionToExpression(condition); + myResult = new DoWhileStatement( + expression, + getConverter().statementToStatement(statement.getBody()) + ); + } + + @Override + public void visitExpressionStatement(@NotNull PsiExpressionStatement statement) { + super.visitExpressionStatement(statement); + myResult = getConverter().expressionToExpression(statement.getExpression()); + } + + @Override + public void visitExpressionListStatement(@NotNull PsiExpressionListStatement statement) { + super.visitExpressionListStatement(statement); + myResult = + new ExpressionListStatement(getConverter().expressionsToExpressionList(statement.getExpressionList().getExpressions())); + } + + @Override + public void visitForStatement(@NotNull PsiForStatement statement) { + super.visitForStatement(statement); + + final PsiStatement initialization = statement.getInitialization(); + final PsiStatement update = statement.getUpdate(); + final PsiExpression condition = statement.getCondition(); + final PsiStatement body = statement.getBody(); + + final PsiLocalVariable firstChild = initialization != null && initialization.getFirstChild() instanceof PsiLocalVariable + ? + (PsiLocalVariable) initialization.getFirstChild() + : null; + + int bodyWriteCount = countWritingAccesses(firstChild, body); + int conditionWriteCount = countWritingAccesses(firstChild, condition); + int updateWriteCount = countWritingAccesses(firstChild, update); + boolean onceWritableIterator = updateWriteCount == 1 && bodyWriteCount + conditionWriteCount == 0; + + final IElementType operationTokenType = condition != null && condition instanceof PsiBinaryExpression ? + ((PsiBinaryExpression) condition).getOperationTokenType() : null; + if ( + initialization != null && + initialization instanceof PsiDeclarationStatement + && initialization.getFirstChild() == initialization.getLastChild() + && condition != null + && update != null + && update.getChildren().length == 1 + && isPlusPlusExpression(update.getChildren()[0]) + && operationTokenType != null + && (operationTokenType == JavaTokenType.LT || operationTokenType == JavaTokenType.LE) + && initialization.getFirstChild() != null + && initialization.getFirstChild() instanceof PsiLocalVariable + && firstChild != null + && firstChild.getNameIdentifier() != null + && onceWritableIterator + ) { + final Expression end = getConverter().expressionToExpression(((PsiBinaryExpression) condition).getROperand()); + final Expression endExpression = operationTokenType == JavaTokenType.LT ? + new BinaryExpression(end, new IdentifierImpl("1"), "-") : + end; + myResult = new ForeachWithRangeStatement( + new IdentifierImpl(firstChild.getName()), + getConverter().expressionToExpression(firstChild.getInitializer()), + endExpression, + getConverter().statementToStatement(body) + ); + } + else { // common case: while loop instead of for loop + List forStatements = new LinkedList(); + forStatements.add(getConverter().statementToStatement(initialization)); + forStatements.add(new WhileStatement( + getConverter().expressionToExpression(condition), + new Block( + Arrays.asList(getConverter().statementToStatement(body), + new Block(Arrays.asList(getConverter().statementToStatement(update))))))); + myResult = new Block(forStatements); + } + } + + private static boolean isPlusPlusExpression(@NotNull PsiElement psiElement) { + return (psiElement instanceof PsiPostfixExpression && ((PsiPostfixExpression) psiElement).getOperationTokenType() == JavaTokenType.PLUSPLUS) + || (psiElement instanceof PsiPrefixExpression && ((PsiPrefixExpression) psiElement).getOperationTokenType() == JavaTokenType.PLUSPLUS); + } + + @Override + public void visitForeachStatement(@NotNull PsiForeachStatement statement) { + super.visitForeachStatement(statement); + myResult = new ForeachStatement( + getConverter().parameterToParameter(statement.getIterationParameter()), + getConverter().expressionToExpression(statement.getIteratedValue()), + getConverter().statementToStatement(statement.getBody()) + ); + } + + @Override + public void visitIfStatement(@NotNull PsiIfStatement statement) { + super.visitIfStatement(statement); + PsiExpression condition = statement.getCondition(); + @SuppressWarnings("ConstantConditions") + Expression expression = condition != null && condition.getType() != null ? + getConverter().createSureCallOnlyForChain(condition, condition.getType()) : + getConverter().expressionToExpression(condition); + myResult = new IfStatement( + expression, + getConverter().statementToStatement(statement.getThenBranch()), + getConverter().statementToStatement(statement.getElseBranch()) + ); + } + + @Override + public void visitLabeledStatement(@NotNull PsiLabeledStatement statement) { + super.visitLabeledStatement(statement); + myResult = new LabelStatement( + identifierToIdentifier(statement.getLabelIdentifier()), + getConverter().statementToStatement(statement.getStatement()) + ); + } + + @Override + public void visitSwitchLabelStatement(@NotNull PsiSwitchLabelStatement statement) { + super.visitSwitchLabelStatement(statement); + myResult = statement.isDefaultCase() ? + new DefaultSwitchLabelStatement() : + new SwitchLabelStatement(getConverter().expressionToExpression(statement.getCaseValue())); + } + + @Override + public void visitSwitchStatement(@NotNull PsiSwitchStatement statement) { + super.visitSwitchStatement(statement); + myResult = new SwitchContainer( + getConverter().expressionToExpression(statement.getExpression()), + switchBodyToCases(statement.getBody()) + ); + } + + @NotNull + private List switchBodyToCases(@Nullable final PsiCodeBlock body) { + final List> cases = splitToCases(body); + final List allSwitchStatements = body != null + ? Arrays.asList(body.getStatements()) + : Collections.emptyList(); + + List result = new LinkedList(); + List pendingLabels = new LinkedList(); + int i = 0; + for (List ls : cases) { + assert ls.size() > 0; + PsiStatement label = ls.get(0); + assert label instanceof PsiSwitchLabelStatement; + + assert allSwitchStatements.get(i) == label : "not a right index"; + + if (ls.size() > 1) { + pendingLabels.add(getConverter().statementToStatement(label)); + List slice = ls.subList(1, ls.size()); + + if (!containsBreak(slice)) { + List statements = getConverter().statementsToStatementList(slice); + statements.addAll( + getConverter().statementsToStatementList(getAllToNextBreak(allSwitchStatements, i + ls.size())) + ); + result.add(new CaseContainer(pendingLabels, statements)); + pendingLabels = new LinkedList(); + } + else { + result.add(new CaseContainer(pendingLabels, getConverter().statementsToStatementList(slice))); + pendingLabels = new LinkedList(); + } + } + else // ls.size() == 1 + { + pendingLabels.add(getConverter().statementToStatement(label)); + } + i += ls.size(); + } + return result; + } + + private static boolean containsBreak(@NotNull final List slice) { + for (PsiStatement s : slice) + if (s instanceof PsiBreakStatement) { + return true; + } + return false; + } + + @NotNull + private static List getAllToNextBreak(@NotNull final List allStatements, final int start) { + List result = new LinkedList(); + for (int i = start; i < allStatements.size(); i++) { + PsiStatement s = allStatements.get(i); + if (s instanceof PsiBreakStatement || s instanceof PsiReturnStatement) { + return result; + } + if (!(s instanceof PsiSwitchLabelStatement)) { + result.add(s); + } + } + return result; + } + + @NotNull + private static List> splitToCases(@Nullable final PsiCodeBlock body) { + List> cases = new LinkedList>(); + List currentCaseStatements = new LinkedList(); + boolean isFirst = true; + if (body != null) { + for (PsiStatement s : body.getStatements()) { + if (s instanceof PsiSwitchLabelStatement) { + if (isFirst) { + isFirst = false; + } + else { + cases.add(currentCaseStatements); + currentCaseStatements = new LinkedList(); + } + } + currentCaseStatements.add(s); + } + cases.add(currentCaseStatements); + } + return cases; + } + + @Override + public void visitSynchronizedStatement(@NotNull PsiSynchronizedStatement statement) { + super.visitSynchronizedStatement(statement); + myResult = new SynchronizedStatement( + getConverter().expressionToExpression(statement.getLockExpression()), + getConverter().blockToBlock(statement.getBody()) + ); + } + + @Override + public void visitThrowStatement(@NotNull PsiThrowStatement statement) { + super.visitThrowStatement(statement); + myResult = new ThrowStatement( + getConverter().expressionToExpression(statement.getException()) + ); + } + + @Override + public void visitTryStatement(@NotNull PsiTryStatement statement) { + super.visitTryStatement(statement); + + List catches = new LinkedList(); + for (int i = 0; i < statement.getCatchBlocks().length; i++) { + catches.add(new CatchStatement( + getConverter().parameterToParameter(statement.getCatchBlockParameters()[i]), + getConverter().blockToBlock(statement.getCatchBlocks()[i], true) + )); + } + + myResult = new TryStatement( + getConverter().blockToBlock(statement.getTryBlock(), true), + catches, + getConverter().blockToBlock(statement.getFinallyBlock(), true) + ); + } + + @Override + public void visitWhileStatement(@NotNull PsiWhileStatement statement) { + super.visitWhileStatement(statement); + PsiExpression condition = statement.getCondition(); + @SuppressWarnings("ConstantConditions") + Expression expression = condition != null && condition.getType() != null ? + getConverter().createSureCallOnlyForChain(condition, condition.getType()) : + getConverter().expressionToExpression(condition); + myResult = new WhileStatement( + expression, + getConverter().statementToStatement(statement.getBody()) + ); + } + + @Override + public void visitReturnStatement(@NotNull PsiReturnStatement statement) { + super.visitReturnStatement(statement); + PsiExpression returnValue = statement.getReturnValue(); + PsiType methodReturnType = getConverter().getMethodReturnType(); + Expression expression = returnValue != null && methodReturnType != null ? + getConverter().createSureCallOnlyForChain(returnValue, methodReturnType) : + getConverter().expressionToExpression(returnValue); + myResult = new ReturnStatement( + expression + ); + } +} diff --git a/src/org/jetbrains/jet/j2k/visitors/SuperVisitor.java b/src/org/jetbrains/jet/j2k/visitors/SuperVisitor.java new file mode 100644 index 00000000000..1e72832b2f4 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/visitors/SuperVisitor.java @@ -0,0 +1,58 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.visitors; + +import com.intellij.psi.*; +import org.jetbrains.annotations.NotNull; + +import java.util.HashSet; + + +/** + * @author ignatov + */ +public class SuperVisitor extends JavaRecursiveElementVisitor { + @NotNull + private final HashSet myResolvedSuperCallParameters; + + public SuperVisitor() { + myResolvedSuperCallParameters = new HashSet(); + } + + @NotNull + public HashSet getResolvedSuperCallParameters() { + return myResolvedSuperCallParameters; + } + + @Override + public void visitMethodCallExpression(@NotNull PsiMethodCallExpression expression) { + super.visitMethodCallExpression(expression); + if (isSuper(expression.getMethodExpression())) { + myResolvedSuperCallParameters.add(expression.getArgumentList()); + } + } + + 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()) { + return true; + } + } + return false; + } +} diff --git a/src/org/jetbrains/jet/j2k/visitors/ThisVisitor.java b/src/org/jetbrains/jet/j2k/visitors/ThisVisitor.java new file mode 100644 index 00000000000..65954a86087 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/visitors/ThisVisitor.java @@ -0,0 +1,56 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.visitors; + +import com.google.common.collect.Sets; +import com.intellij.psi.*; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Set; + +/** + * @author ignatov + */ +public class ThisVisitor extends JavaRecursiveElementVisitor { + @NotNull + private final Set myResolvedConstructors = Sets.newLinkedHashSet(); + + @Override + public void visitReferenceExpression(@NotNull PsiReferenceExpression expression) { + for (PsiReference r : expression.getReferences()) + if (r.getCanonicalText().equals("this")) { + final PsiElement res = r.resolve(); + if (res != null && res instanceof PsiMethod && ((PsiMethod) res).isConstructor()) { + myResolvedConstructors.add((PsiMethod) res); + } + } + } + + @Nullable + public PsiMethod getPrimaryConstructor() { + if (myResolvedConstructors.size() > 0) { + PsiMethod first = myResolvedConstructors.toArray(new PsiMethod[myResolvedConstructors.size()])[0]; + for (PsiMethod m : myResolvedConstructors) + if (m.hashCode() != first.hashCode()) { + return null; + } + return first; + } + return null; + } +} diff --git a/src/org/jetbrains/jet/j2k/visitors/TypeVisitor.java b/src/org/jetbrains/jet/j2k/visitors/TypeVisitor.java new file mode 100644 index 00000000000..fd2d8d348e5 --- /dev/null +++ b/src/org/jetbrains/jet/j2k/visitors/TypeVisitor.java @@ -0,0 +1,218 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k.visitors; + +import com.intellij.psi.*; +import com.intellij.psi.impl.source.PsiClassReferenceType; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.j2k.Converter; +import org.jetbrains.jet.j2k.J2KConverterFlags; +import org.jetbrains.jet.j2k.ast.*; +import org.jetbrains.jet.j2k.util.AstUtil; +import org.jetbrains.jet.lang.types.lang.JetStandardClasses; + +import java.util.LinkedList; +import java.util.List; + +/** + * @author ignatov + */ +public class TypeVisitor extends PsiTypeVisitor implements J2KVisitor { + public static final String JAVA_LANG_BYTE = "java.lang.Byte"; + public static final String JAVA_LANG_CHARACTER = "java.lang.Character"; + public static final String JAVA_LANG_DOUBLE = "java.lang.Double"; + public static final String JAVA_LANG_FLOAT = "java.lang.Float"; + public static final String JAVA_LANG_INTEGER = "java.lang.Integer"; + public static final String JAVA_LANG_LONG = "java.lang.Long"; + public static final String JAVA_LANG_SHORT = "java.lang.Short"; + private static final String JAVA_LANG_BOOLEAN = "java.lang.Boolean"; + public static final String JAVA_LANG_OBJECT = "java.lang.Object"; + public static final String JAVA_LANG_STRING = "java.lang.String"; + private static final String JAVA_LANG_ITERABLE = "java.lang.Iterable"; + private static final String JAVA_UTIL_ITERATOR = "java.util.Iterator"; + private final Converter myConverter; + private Type myResult = Type.EMPTY_TYPE; + + public TypeVisitor(@NotNull Converter myConverter) { + this.myConverter = myConverter; + } + + @NotNull + public Type getResult() { + return myResult; + } + + @Override + public Type visitPrimitiveType(@NotNull PsiPrimitiveType primitiveType) { + final String name = primitiveType.getCanonicalText(); + final IdentifierImpl identifier = new IdentifierImpl(name); + + if (name.equals("void")) { + myResult = new PrimitiveType(new IdentifierImpl(JetStandardClasses.UNIT_ALIAS)); + } + else if (Node.PRIMITIVE_TYPES.contains(name)) { + myResult = new PrimitiveType(new IdentifierImpl(AstUtil.upperFirstCharacter(name))); + } + else { + myResult = new PrimitiveType(identifier); + } + return super.visitPrimitiveType(primitiveType); + } + + @Override + public Type visitArrayType(@NotNull PsiArrayType arrayType) { + if (myResult == Type.EMPTY_TYPE) { + myResult = new ArrayType(getConverter().typeToType(arrayType.getComponentType())); + } + return super.visitArrayType(arrayType); + } + + @Override + public Type visitClassType(@NotNull PsiClassType classType) { + final IdentifierImpl identifier = constructClassTypeIdentifier(classType); + final List resolvedClassTypeParams = createRawTypesForResolvedReference(classType); + + if (classType.getParameterCount() == 0 && resolvedClassTypeParams.size() > 0) { + myResult = new ClassType(identifier, resolvedClassTypeParams); + } + else { + myResult = new ClassType(identifier, getConverter().typesToTypeList(classType.getParameters())); + } + return super.visitClassType(classType); + } + + @NotNull + private IdentifierImpl constructClassTypeIdentifier(@NotNull PsiClassType classType) { + final PsiClass psiClass = classType.resolve(); + if (psiClass != null) { + String qualifiedName = psiClass.getQualifiedName(); + if (qualifiedName != null) { + if (!qualifiedName.equals("java.lang.Object") && getConverter().hasFlag(J2KConverterFlags.FULLY_QUALIFIED_TYPE_NAMES)) { + return new IdentifierImpl(qualifiedName); + } + if (qualifiedName.equals(JAVA_LANG_ITERABLE)) { + return new IdentifierImpl(JAVA_LANG_ITERABLE); + } + if (qualifiedName.equals(JAVA_UTIL_ITERATOR)) { + return new IdentifierImpl(JAVA_UTIL_ITERATOR); + } + } + } + final String classTypeName = createQualifiedName(classType); + + if (classTypeName.isEmpty()) { + return new IdentifierImpl(getClassTypeName(classType)); + } + + return new IdentifierImpl(classTypeName); + } + + @NotNull + private static String createQualifiedName(@NotNull PsiClassType classType) { + String classTypeName = ""; + if (classType instanceof PsiClassReferenceType) { + final PsiJavaCodeReferenceElement reference = ((PsiClassReferenceType) classType).getReference(); + if (reference.isQualified()) { + String result = new IdentifierImpl(reference.getReferenceName()).toKotlin(); + PsiElement qualifier = reference.getQualifier(); + while (qualifier != null) { + final PsiJavaCodeReferenceElement p = (PsiJavaCodeReferenceElement) qualifier; + result = new IdentifierImpl(p.getReferenceName()).toKotlin() + "." + result; // TODO: maybe need to replace by safe call? + qualifier = p.getQualifier(); + } + classTypeName = result; + } + } + return classTypeName; + } + + @NotNull + private List createRawTypesForResolvedReference(@NotNull PsiClassType classType) { + final List typeParams = new LinkedList(); + if (classType instanceof PsiClassReferenceType) { + final PsiJavaCodeReferenceElement reference = ((PsiClassReferenceType) classType).getReference(); + final PsiElement resolve = reference.resolve(); + if (resolve != null) { + if (resolve instanceof PsiClass) + //noinspection UnusedDeclaration + { + for (PsiTypeParameter p : ((PsiClass) resolve).getTypeParameters()) { + Type boundType = p.getSuperTypes().length > 0 ? + new ClassType(new IdentifierImpl(getClassTypeName(p.getSuperTypes()[0])), getConverter().typesToTypeList(p.getSuperTypes()[0].getParameters()), true) + : + new StarProjectionType(); + + typeParams.add(boundType); + } + } + } + } + return typeParams; + } + + @NotNull + private static String getClassTypeName(@NotNull PsiClassType classType) { + String canonicalTypeStr = classType.getCanonicalText(); + if (canonicalTypeStr.equals(JAVA_LANG_OBJECT)) return "Any"; + if (canonicalTypeStr.equals(JAVA_LANG_BYTE)) return "Byte"; + if (canonicalTypeStr.equals(JAVA_LANG_CHARACTER)) return "Char"; + if (canonicalTypeStr.equals(JAVA_LANG_DOUBLE)) return "Double"; + if (canonicalTypeStr.equals(JAVA_LANG_FLOAT)) return "Float"; + if (canonicalTypeStr.equals(JAVA_LANG_INTEGER)) return "Int"; + if (canonicalTypeStr.equals(JAVA_LANG_LONG)) return "Long"; + if (canonicalTypeStr.equals(JAVA_LANG_SHORT)) return "Short"; + if (canonicalTypeStr.equals(JAVA_LANG_BOOLEAN)) return "Boolean"; + return classType.getClassName() != null ? classType.getClassName() : classType.getCanonicalText(); + } + + @Override + public Type visitWildcardType(@NotNull PsiWildcardType wildcardType) { + if (wildcardType.isExtends()) { + myResult = new OutProjectionType(getConverter().typeToType(wildcardType.getExtendsBound())); + } + else if (wildcardType.isSuper()) { + myResult = new InProjectionType(getConverter().typeToType(wildcardType.getSuperBound())); + } + else { + myResult = new StarProjectionType(); + } + return super.visitWildcardType(wildcardType); + } + + @Override + public Type visitEllipsisType(@NotNull PsiEllipsisType ellipsisType) { + myResult = new VarArg(getConverter().typeToType(ellipsisType.getComponentType())); + return super.visitEllipsisType(ellipsisType); + } + + @Override + public Type visitCapturedWildcardType(PsiCapturedWildcardType capturedWildcardType) { + return super.visitCapturedWildcardType(capturedWildcardType); + } + + @Override + public Type visitDisjunctionType(PsiDisjunctionType disjunctionType) { + return super.visitDisjunctionType(disjunctionType); + } + + @NotNull + @Override + public Converter getConverter() { + return myConverter; + } +} + diff --git a/tests/test/org/jetbrains/jet/j2k/StandaloneJavaToKotlinConverterTest.java b/tests/test/org/jetbrains/jet/j2k/StandaloneJavaToKotlinConverterTest.java new file mode 100644 index 00000000000..18c95e68be8 --- /dev/null +++ b/tests/test/org/jetbrains/jet/j2k/StandaloneJavaToKotlinConverterTest.java @@ -0,0 +1,175 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k; + +import com.intellij.core.JavaCoreEnvironment; +import com.intellij.openapi.util.io.FileUtil; +import com.intellij.psi.PsiFile; +import com.intellij.psi.PsiJavaFile; +import junit.framework.Assert; +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.io.File; +import java.io.IOException; + +/** + * @author ignatov + */ +public class StandaloneJavaToKotlinConverterTest extends TestCase { + private final String myDataPath; + private final String myName; + @NotNull + private final static JavaCoreEnvironment myJavaCoreEnvironment = JavaToKotlinTranslator.setUpJavaCoreEnvironment(); + + public StandaloneJavaToKotlinConverterTest(String dataPath, String name) { + myDataPath = dataPath; + myName = name; + } + + @Override + protected void runTest() throws Throwable { + Converter converter = new Converter(); + String javaPath = "tests/testData/" + getTestFilePath(); + String kotlinPath = javaPath.replace(".jav", ".kt"); + + final File kotlinFile = new File(kotlinPath); + if (!kotlinFile.exists()) { + FileUtil.writeToFile(kotlinFile, ""); + } + final String expected = FileUtil.loadFile(kotlinFile); + final File javaFile = new File(javaPath); + final String javaCode = FileUtil.loadFile(javaFile); + + String actual = ""; + String parentFileName = javaFile.getParentFile().getName(); + if (parentFileName.equals("expression")) { + actual = expressionToKotlin(converter, javaCode); + } + else if (parentFileName.equals("statement")) { + actual = statementToKotlin(converter, javaCode); + } + else if (parentFileName.equals("method")) { + actual = methodToKotlin(converter, javaCode); + } + else if (parentFileName.equals("class")) { + actual = fileToKotlin(converter, javaCode); + } + else if (parentFileName.equals("file")) { + actual = fileToKotlin(converter, javaCode); + } + else if (parentFileName.equals("comp")) actual = fileToFileWithCompatibilityImport(javaCode); + + assert !actual.isEmpty() : "Specify what is it: file, class, method, statement or expression: " + javaPath + " parent: " + parentFileName; + + final File tmp = new File(kotlinPath + ".tmp"); + if (!expected.equals(actual)) FileUtil.writeToFile(tmp, actual); + if (expected.equals(actual) && tmp.exists()) //noinspection ResultOfMethodCallIgnored + { + tmp.delete(); + } + + Assert.assertEquals(expected, actual); + } + + @NotNull + String getTestFilePath() { + return myDataPath + "/" + myName + ".jav"; + } + + + @NotNull + @Override + public String getName() { + return "test_" + myName; + } + + @NotNull + public static Test suite() { + TestSuite suite = new TestSuite(); +// suite.addTest(new StandaloneJavaToKotlinConverterTest("ast/class/file", "kt-639")); + suite.addTest(TestCaseBuilder.suiteForDirectory("tests/testData", "/ast", new TestCaseBuilder.NamedTestFactory() { + @NotNull + @Override + public Test createTest(@NotNull String dataPath, @NotNull String name) { + return new StandaloneJavaToKotlinConverterTest(dataPath, name); + } + })); + return suite; + } + + @NotNull + private static String fileToFileWithCompatibilityImport(@NotNull String text) { + return JavaToKotlinTranslator.generateKotlinCodeWithCompatibilityImport(text); + } + + @NotNull + private String fileToKotlin(Converter converter, @NotNull String text) { + return generateKotlinCode(converter, JavaToKotlinTranslator.createFile(myJavaCoreEnvironment, text)); + } + + @NotNull + private static String generateKotlinCode(@NotNull Converter converter, @Nullable PsiFile file) { + if (file != null && file instanceof PsiJavaFile) { + JavaToKotlinTranslator.setClassIdentifiers(converter, file); + return prettify(converter.elementToKotlin(file)); + } + return ""; + } + + @NotNull + private String methodToKotlin(Converter converter, String text) throws IOException { + String result = fileToKotlin(converter, "final class C {" + text + "}") + .replaceAll("class C\\(\\) \\{", ""); + result = result.substring(0, result.lastIndexOf("}")); + return prettify(result); + } + + @NotNull + private String statementToKotlin(Converter converter, String text) throws Exception { + String result = methodToKotlin(converter, "void main() {" + text + "}"); + int pos = result.lastIndexOf("}"); + result = result.substring(0, pos).replaceFirst("fun main\\(\\) : Unit \\{", ""); + return prettify(result); + } + + @NotNull + private String expressionToKotlin(Converter converter, String code) throws Exception { + String result = statementToKotlin(converter, "Object o =" + code + "}"); + result = result.replaceFirst("var o : Any\\? =", ""); + return prettify(result); + } + + @NotNull + private static String prettify(@Nullable String code) { + if (code == null) { + return ""; + } + return code + .trim() + .replaceAll("\r\n", "\n") + .replaceAll(" \n", "\n") + .replaceAll("\n ", "\n") + .replaceAll("\n+", "\n") + .replaceAll(" +", " ") + .trim() + ; + } +} diff --git a/tests/test/org/jetbrains/jet/j2k/TestCaseBuilder.java b/tests/test/org/jetbrains/jet/j2k/TestCaseBuilder.java new file mode 100644 index 00000000000..a184d149e55 --- /dev/null +++ b/tests/test/org/jetbrains/jet/j2k/TestCaseBuilder.java @@ -0,0 +1,110 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.j2k; + +import com.intellij.openapi.application.PathManager; +import junit.framework.Test; +import junit.framework.TestSuite; +import org.jetbrains.annotations.NotNull; + +import java.io.File; +import java.io.FileFilter; +import java.io.FilenameFilter; +import java.util.Arrays; +import java.util.Collections; +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) { + return true; + } + }; + + @NotNull + public static String getTestDataPathBase() { + return "testData"; + } + + public static String getHomeDirectory() { + return new File(PathManager.getResourceRoot(TestCaseBuilder.class, "/org/jetbrains/jet/TestCaseBuilder.class")).getParentFile().getParentFile().getParent(); + } + + public interface NamedTestFactory { + @NotNull + Test createTest(@NotNull String dataPath, @NotNull String name); + } + + @NotNull + public static TestSuite suiteForDirectory(String baseDataDir, @NotNull final String dataPath, @NotNull NamedTestFactory factory) { + return suiteForDirectory(baseDataDir, dataPath, true, emptyFilter, factory); + } + + @NotNull + 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, @NotNull String name) { + return name.endsWith(extensionJava); + } + }; + FilenameFilter resultFilter; + if (filter != emptyFilter) { + resultFilter = new FilenameFilter() { + @Override + public boolean accept(File file, String s) { + return extensionFilter.accept(file, s) && filter.accept(file, s); + } + }; + } + else { + resultFilter = extensionFilter; + } + File dir = new File(baseDataDir + dataPath); + FileFilter dirFilter = new FileFilter() { + @Override + public boolean accept(@NotNull File pathname) { + return pathname.isDirectory(); + } + }; + if (recursive) { + File[] files = dir.listFiles(dirFilter); + assert files != null : dir; + List subdirs = Arrays.asList(files); + Collections.sort(subdirs); + for (File subdir : subdirs) { + suite.addTest(suiteForDirectory(baseDataDir, dataPath + "/" + subdir.getName(), recursive, filter, factory)); + } + } + List files = Arrays.asList(dir.listFiles(resultFilter)); + Collections.sort(files); + for (File file : files) { + String fileName = file.getName(); + assert fileName != null; + suite.addTest(factory.createTest(dataPath, fileName.substring(0, fileName.length() - extensionJava.length()))); + } + return suite; + } +} diff --git a/tests/testData/ast/annotations/file/jetbrainsNotNull.jav b/tests/testData/ast/annotations/file/jetbrainsNotNull.jav new file mode 100644 index 00000000000..152fdd7b545 --- /dev/null +++ b/tests/testData/ast/annotations/file/jetbrainsNotNull.jav @@ -0,0 +1,29 @@ +package test; + +import org.jetbrains.annotations.NotNull; + +public class Test { + @NotNull String myStr = "String2"; + + public Test(@NotNull String str) { + myStr = str; + } + + public void sout(@NotNull String str) { + System.out.println(str); + } + + @NotNull + public String dummy(@NotNull String str) { + return str; + } + + public void test() { + sout("String"); + @NotNull String test = "String2"; + sout(test); + sout(dummy(test)); + + new Test(test); + } +} \ No newline at end of file diff --git a/tests/testData/ast/annotations/file/jetbrainsNotNull.kt b/tests/testData/ast/annotations/file/jetbrainsNotNull.kt new file mode 100644 index 00000000000..2dd54ccb75c --- /dev/null +++ b/tests/testData/ast/annotations/file/jetbrainsNotNull.kt @@ -0,0 +1,20 @@ +package test +public open class Test(str : String) { +var myStr : String? = "String2" +public open fun sout(str : String) : Unit { +System.out?.println(str) +} +public open fun dummy(str : String) : String { +return str +} +public open fun test() : Unit { +sout("String") +var test : String = "String2" +sout(test) +sout(dummy(test)) +Test(test) +} +{ +myStr = str +} +} \ No newline at end of file diff --git a/tests/testData/ast/annotations/file/jetbrainsNotNull.kt.tmp b/tests/testData/ast/annotations/file/jetbrainsNotNull.kt.tmp new file mode 100644 index 00000000000..5bedd02bc8b --- /dev/null +++ b/tests/testData/ast/annotations/file/jetbrainsNotNull.kt.tmp @@ -0,0 +1,20 @@ +package test +public open class Test(str : String?) { +var myStr : String? = "String2" +public open fun sout(str : String?) : Unit { +System.out?.println(str) +} +public open fun dummy(str : String?) : String? { +return str +} +public open fun test() : Unit { +sout("String") +var test : String? = "String2" +sout(test) +sout(dummy(test)) +Test(test) +} +{ +myStr = str +} +} \ No newline at end of file diff --git a/tests/testData/ast/anonymousBlock/file/oneAnonBlock.jav b/tests/testData/ast/anonymousBlock/file/oneAnonBlock.jav new file mode 100644 index 00000000000..fba735a5ff0 --- /dev/null +++ b/tests/testData/ast/anonymousBlock/file/oneAnonBlock.jav @@ -0,0 +1,6 @@ +class Test { + String str; + { + str = "Ola"; + } +} \ No newline at end of file diff --git a/tests/testData/ast/anonymousBlock/file/oneAnonBlock.kt b/tests/testData/ast/anonymousBlock/file/oneAnonBlock.kt new file mode 100644 index 00000000000..db7bd511f4e --- /dev/null +++ b/tests/testData/ast/anonymousBlock/file/oneAnonBlock.kt @@ -0,0 +1,6 @@ +open class Test() { +var str : String? = null +{ +str = "Ola" +} +} \ No newline at end of file diff --git a/tests/testData/ast/anonymousBlock/file/oneStaticAnonBlock.jav b/tests/testData/ast/anonymousBlock/file/oneStaticAnonBlock.jav new file mode 100644 index 00000000000..c86774f1642 --- /dev/null +++ b/tests/testData/ast/anonymousBlock/file/oneStaticAnonBlock.jav @@ -0,0 +1,6 @@ +class Test { + String str; + static { + str = "Ola"; + } +} \ No newline at end of file diff --git a/tests/testData/ast/anonymousBlock/file/oneStaticAnonBlock.kt b/tests/testData/ast/anonymousBlock/file/oneStaticAnonBlock.kt new file mode 100644 index 00000000000..667290b27c9 --- /dev/null +++ b/tests/testData/ast/anonymousBlock/file/oneStaticAnonBlock.kt @@ -0,0 +1,8 @@ +open class Test() { +var str : String? = null +class object { +{ +str = "Ola" +} +} +} \ No newline at end of file diff --git a/tests/testData/ast/arrayAccessExpression/expression/expressionIndex.jav b/tests/testData/ast/arrayAccessExpression/expression/expressionIndex.jav new file mode 100644 index 00000000000..7a99230c2f6 --- /dev/null +++ b/tests/testData/ast/arrayAccessExpression/expression/expressionIndex.jav @@ -0,0 +1 @@ +myArray[myLibrary.calculateIndex(100)] \ No newline at end of file diff --git a/tests/testData/ast/arrayAccessExpression/expression/expressionIndex.kt b/tests/testData/ast/arrayAccessExpression/expression/expressionIndex.kt new file mode 100644 index 00000000000..7a99230c2f6 --- /dev/null +++ b/tests/testData/ast/arrayAccessExpression/expression/expressionIndex.kt @@ -0,0 +1 @@ +myArray[myLibrary.calculateIndex(100)] \ No newline at end of file diff --git a/tests/testData/ast/arrayAccessExpression/expression/intIndex.jav b/tests/testData/ast/arrayAccessExpression/expression/intIndex.jav new file mode 100644 index 00000000000..8a7de5e4e73 --- /dev/null +++ b/tests/testData/ast/arrayAccessExpression/expression/intIndex.jav @@ -0,0 +1 @@ +myArray[10] \ No newline at end of file diff --git a/tests/testData/ast/arrayAccessExpression/expression/intIndex.kt b/tests/testData/ast/arrayAccessExpression/expression/intIndex.kt new file mode 100644 index 00000000000..8a7de5e4e73 --- /dev/null +++ b/tests/testData/ast/arrayAccessExpression/expression/intIndex.kt @@ -0,0 +1 @@ +myArray[10] \ No newline at end of file diff --git a/tests/testData/ast/arrayAccessExpression/expression/variableIndex.jav b/tests/testData/ast/arrayAccessExpression/expression/variableIndex.jav new file mode 100644 index 00000000000..2a40dae7f3b --- /dev/null +++ b/tests/testData/ast/arrayAccessExpression/expression/variableIndex.jav @@ -0,0 +1 @@ +myArray[i] \ No newline at end of file diff --git a/tests/testData/ast/arrayAccessExpression/expression/variableIndex.kt b/tests/testData/ast/arrayAccessExpression/expression/variableIndex.kt new file mode 100644 index 00000000000..2a40dae7f3b --- /dev/null +++ b/tests/testData/ast/arrayAccessExpression/expression/variableIndex.kt @@ -0,0 +1 @@ +myArray[i] \ No newline at end of file diff --git a/tests/testData/ast/arrayInitializerExpression/expression/newInt.jav b/tests/testData/ast/arrayInitializerExpression/expression/newInt.jav new file mode 100644 index 00000000000..0d3fb727286 --- /dev/null +++ b/tests/testData/ast/arrayInitializerExpression/expression/newInt.jav @@ -0,0 +1 @@ +new int[] {1, 2, 3}; \ No newline at end of file diff --git a/tests/testData/ast/arrayInitializerExpression/expression/newInt.kt b/tests/testData/ast/arrayInitializerExpression/expression/newInt.kt new file mode 100644 index 00000000000..6cfae9942ea --- /dev/null +++ b/tests/testData/ast/arrayInitializerExpression/expression/newInt.kt @@ -0,0 +1 @@ +intArray(1, 2, 3) \ No newline at end of file diff --git a/tests/testData/ast/arrayInitializerExpression/statement/doubleArray.jav b/tests/testData/ast/arrayInitializerExpression/statement/doubleArray.jav new file mode 100644 index 00000000000..44f26cb4a79 --- /dev/null +++ b/tests/testData/ast/arrayInitializerExpression/statement/doubleArray.jav @@ -0,0 +1 @@ +double[] a = new double[]{1.0, 2, 3} \ No newline at end of file diff --git a/tests/testData/ast/arrayInitializerExpression/statement/doubleArray.kt b/tests/testData/ast/arrayInitializerExpression/statement/doubleArray.kt new file mode 100644 index 00000000000..c2d0ab03352 --- /dev/null +++ b/tests/testData/ast/arrayInitializerExpression/statement/doubleArray.kt @@ -0,0 +1 @@ +var a : DoubleArray? = doubleArray(1.0, 2.0, 3.0) \ No newline at end of file diff --git a/tests/testData/ast/arrayInitializerExpression/statement/doubleArrayWithVariables.jav b/tests/testData/ast/arrayInitializerExpression/statement/doubleArrayWithVariables.jav new file mode 100644 index 00000000000..58d0ca95d05 --- /dev/null +++ b/tests/testData/ast/arrayInitializerExpression/statement/doubleArrayWithVariables.jav @@ -0,0 +1,2 @@ +double a = 0, b = 0, c = 0; +double ds[] = {a, b, c}; \ No newline at end of file diff --git a/tests/testData/ast/arrayInitializerExpression/statement/doubleArrayWithVariables.kt b/tests/testData/ast/arrayInitializerExpression/statement/doubleArrayWithVariables.kt new file mode 100644 index 00000000000..ad8267238f2 --- /dev/null +++ b/tests/testData/ast/arrayInitializerExpression/statement/doubleArrayWithVariables.kt @@ -0,0 +1,4 @@ +var a : Double = 0 +var b : Double = 0 +var c : Double = 0 +var ds : DoubleArray? = doubleArray((a).toDouble(), (b).toDouble(), (c).toDouble()) \ No newline at end of file diff --git a/tests/testData/ast/arrayInitializerExpression/statement/floatArray.jav b/tests/testData/ast/arrayInitializerExpression/statement/floatArray.jav new file mode 100644 index 00000000000..36d2afa3425 --- /dev/null +++ b/tests/testData/ast/arrayInitializerExpression/statement/floatArray.jav @@ -0,0 +1 @@ +float[] a = new float[]{1, 2, 3.0} \ No newline at end of file diff --git a/tests/testData/ast/arrayInitializerExpression/statement/floatArray.kt b/tests/testData/ast/arrayInitializerExpression/statement/floatArray.kt new file mode 100644 index 00000000000..b824bd21e48 --- /dev/null +++ b/tests/testData/ast/arrayInitializerExpression/statement/floatArray.kt @@ -0,0 +1 @@ +var a : FloatArray? = floatArray(1.0, 2.0, 3.0) \ No newline at end of file diff --git a/tests/testData/ast/arrayInitializerExpression/statement/javaLangDoubleArray.jav b/tests/testData/ast/arrayInitializerExpression/statement/javaLangDoubleArray.jav new file mode 100644 index 00000000000..3ebd4af38bd --- /dev/null +++ b/tests/testData/ast/arrayInitializerExpression/statement/javaLangDoubleArray.jav @@ -0,0 +1 @@ +java.lang.Double[] a = new java.lang.Double[]{1, 2, 3}; \ No newline at end of file diff --git a/tests/testData/ast/arrayInitializerExpression/statement/javaLangDoubleArray.kt b/tests/testData/ast/arrayInitializerExpression/statement/javaLangDoubleArray.kt new file mode 100644 index 00000000000..c3a5bb91fd6 --- /dev/null +++ b/tests/testData/ast/arrayInitializerExpression/statement/javaLangDoubleArray.kt @@ -0,0 +1 @@ +var a : Array? = array(1.0, 2.0, 3.0) \ No newline at end of file diff --git a/tests/testData/ast/arrayInitializerExpression/statement/javaLangFloatArray.jav b/tests/testData/ast/arrayInitializerExpression/statement/javaLangFloatArray.jav new file mode 100644 index 00000000000..b53b4dc9aec --- /dev/null +++ b/tests/testData/ast/arrayInitializerExpression/statement/javaLangFloatArray.jav @@ -0,0 +1 @@ +java.lang.Float[] a = new java.lang.Float[]{1, 2, 3}; \ No newline at end of file diff --git a/tests/testData/ast/arrayInitializerExpression/statement/javaLangFloatArray.kt b/tests/testData/ast/arrayInitializerExpression/statement/javaLangFloatArray.kt new file mode 100644 index 00000000000..d31d26a7c74 --- /dev/null +++ b/tests/testData/ast/arrayInitializerExpression/statement/javaLangFloatArray.kt @@ -0,0 +1 @@ +var a : Array? = array(1.0, 2.0, 3.0) \ No newline at end of file diff --git a/tests/testData/ast/arrayInitializerExpression/statement/newByte.jav b/tests/testData/ast/arrayInitializerExpression/statement/newByte.jav new file mode 100644 index 00000000000..5a6e85cdfe1 --- /dev/null +++ b/tests/testData/ast/arrayInitializerExpression/statement/newByte.jav @@ -0,0 +1 @@ +byte[] a = new byte[] {1, 2, 3}; \ No newline at end of file diff --git a/tests/testData/ast/arrayInitializerExpression/statement/newByte.kt b/tests/testData/ast/arrayInitializerExpression/statement/newByte.kt new file mode 100644 index 00000000000..2f0ce90f341 --- /dev/null +++ b/tests/testData/ast/arrayInitializerExpression/statement/newByte.kt @@ -0,0 +1 @@ +var a : ByteArray? = byteArray(1, 2, 3) \ No newline at end of file diff --git a/tests/testData/ast/arrayInitializerExpression/statement/oneDim.jav b/tests/testData/ast/arrayInitializerExpression/statement/oneDim.jav new file mode 100644 index 00000000000..9e498af66a6 --- /dev/null +++ b/tests/testData/ast/arrayInitializerExpression/statement/oneDim.jav @@ -0,0 +1 @@ +int[] a = {1, 2, 3}; \ No newline at end of file diff --git a/tests/testData/ast/arrayInitializerExpression/statement/oneDim.kt b/tests/testData/ast/arrayInitializerExpression/statement/oneDim.kt new file mode 100644 index 00000000000..19b3af3f5c4 --- /dev/null +++ b/tests/testData/ast/arrayInitializerExpression/statement/oneDim.kt @@ -0,0 +1 @@ +var a : IntArray? = intArray(1, 2, 3) \ No newline at end of file diff --git a/tests/testData/ast/arrayInitializerExpression/statement/oneDimWithVariables.jav b/tests/testData/ast/arrayInitializerExpression/statement/oneDimWithVariables.jav new file mode 100644 index 00000000000..185a7d5aaf8 --- /dev/null +++ b/tests/testData/ast/arrayInitializerExpression/statement/oneDimWithVariables.jav @@ -0,0 +1,2 @@ +int a = 0, b = 0, c = 0; +int is[] = {a, b, c}; \ No newline at end of file diff --git a/tests/testData/ast/arrayInitializerExpression/statement/oneDimWithVariables.kt b/tests/testData/ast/arrayInitializerExpression/statement/oneDimWithVariables.kt new file mode 100644 index 00000000000..8b7378486d8 --- /dev/null +++ b/tests/testData/ast/arrayInitializerExpression/statement/oneDimWithVariables.kt @@ -0,0 +1,4 @@ +var a : Int = 0 +var b : Int = 0 +var c : Int = 0 +var `is` : IntArray? = intArray(a, b, c) \ No newline at end of file diff --git a/tests/testData/ast/arrayInitializerExpression/statement/twoDim.jav b/tests/testData/ast/arrayInitializerExpression/statement/twoDim.jav new file mode 100644 index 00000000000..f895393aad5 --- /dev/null +++ b/tests/testData/ast/arrayInitializerExpression/statement/twoDim.jav @@ -0,0 +1 @@ +int[][] a = { {1, 2, 3}, {4, 5, 6}, {7, 8, 9} }; \ No newline at end of file diff --git a/tests/testData/ast/arrayInitializerExpression/statement/twoDim.kt b/tests/testData/ast/arrayInitializerExpression/statement/twoDim.kt new file mode 100644 index 00000000000..4ccc886bd71 --- /dev/null +++ b/tests/testData/ast/arrayInitializerExpression/statement/twoDim.kt @@ -0,0 +1 @@ +var a : Array? = array(intArray(1, 2, 3), intArray(4, 5, 6), intArray(7, 8, 9)) \ No newline at end of file diff --git a/tests/testData/ast/arrayType/method/methodArrayArgs.jav b/tests/testData/ast/arrayType/method/methodArrayArgs.jav new file mode 100644 index 00000000000..c5c5768faf4 --- /dev/null +++ b/tests/testData/ast/arrayType/method/methodArrayArgs.jav @@ -0,0 +1 @@ +void fromArrayToCollection(Foo[] a) {} \ No newline at end of file diff --git a/tests/testData/ast/arrayType/method/methodArrayArgs.kt b/tests/testData/ast/arrayType/method/methodArrayArgs.kt new file mode 100644 index 00000000000..01360f90482 --- /dev/null +++ b/tests/testData/ast/arrayType/method/methodArrayArgs.kt @@ -0,0 +1,2 @@ +fun fromArrayToCollection(a : Array?) : Unit { +} \ No newline at end of file diff --git a/tests/testData/ast/arrayType/statement/arrayInitializationStatement.jav b/tests/testData/ast/arrayType/statement/arrayInitializationStatement.jav new file mode 100644 index 00000000000..781bcb6a731 --- /dev/null +++ b/tests/testData/ast/arrayType/statement/arrayInitializationStatement.jav @@ -0,0 +1 @@ +int [][] d2 = new int[][]{}; \ No newline at end of file diff --git a/tests/testData/ast/arrayType/statement/arrayInitializationStatement.kt b/tests/testData/ast/arrayType/statement/arrayInitializationStatement.kt new file mode 100644 index 00000000000..146484f79d7 --- /dev/null +++ b/tests/testData/ast/arrayType/statement/arrayInitializationStatement.kt @@ -0,0 +1 @@ +var d2 : Array? = array() \ No newline at end of file diff --git a/tests/testData/ast/arrayType/statement/arrayInitializationStatementWithDimension.jav b/tests/testData/ast/arrayType/statement/arrayInitializationStatementWithDimension.jav new file mode 100644 index 00000000000..01c957d5dfe --- /dev/null +++ b/tests/testData/ast/arrayType/statement/arrayInitializationStatementWithDimension.jav @@ -0,0 +1 @@ +int [][] d2 = new int[5][]; \ No newline at end of file diff --git a/tests/testData/ast/arrayType/statement/arrayInitializationStatementWithDimension.kt b/tests/testData/ast/arrayType/statement/arrayInitializationStatementWithDimension.kt new file mode 100644 index 00000000000..ea4fcc7e35e --- /dev/null +++ b/tests/testData/ast/arrayType/statement/arrayInitializationStatementWithDimension.kt @@ -0,0 +1 @@ +var d2 : Array? = Array(5) \ No newline at end of file diff --git a/tests/testData/ast/arrayType/statement/arrayInitializationStatementWithDimension3d.jav b/tests/testData/ast/arrayType/statement/arrayInitializationStatementWithDimension3d.jav new file mode 100644 index 00000000000..abe20f1ec57 --- /dev/null +++ b/tests/testData/ast/arrayType/statement/arrayInitializationStatementWithDimension3d.jav @@ -0,0 +1 @@ +int [][][] d3 = new int[5][5][]; \ No newline at end of file diff --git a/tests/testData/ast/arrayType/statement/arrayInitializationStatementWithDimension3d.kt b/tests/testData/ast/arrayType/statement/arrayInitializationStatementWithDimension3d.kt new file mode 100644 index 00000000000..95be479049e --- /dev/null +++ b/tests/testData/ast/arrayType/statement/arrayInitializationStatementWithDimension3d.kt @@ -0,0 +1 @@ +var d3 : Array?>? = Array?>(5, {Array(5)}) \ No newline at end of file diff --git a/tests/testData/ast/arrayType/statement/arrayInitializationStatementWithDimensionExplicit.jav b/tests/testData/ast/arrayType/statement/arrayInitializationStatementWithDimensionExplicit.jav new file mode 100644 index 00000000000..fe4a268f124 --- /dev/null +++ b/tests/testData/ast/arrayType/statement/arrayInitializationStatementWithDimensionExplicit.jav @@ -0,0 +1 @@ +int [][] d2 = new int[5][5]; \ No newline at end of file diff --git a/tests/testData/ast/arrayType/statement/arrayInitializationStatementWithDimensionExplicit.kt b/tests/testData/ast/arrayType/statement/arrayInitializationStatementWithDimensionExplicit.kt new file mode 100644 index 00000000000..32ac4491c66 --- /dev/null +++ b/tests/testData/ast/arrayType/statement/arrayInitializationStatementWithDimensionExplicit.kt @@ -0,0 +1 @@ +var d2 : Array? = Array(5, {IntArray(5)}) \ No newline at end of file diff --git a/tests/testData/ast/arrayType/statement/d2StringEmptyArray.jav b/tests/testData/ast/arrayType/statement/d2StringEmptyArray.jav new file mode 100644 index 00000000000..d49028c3fe0 --- /dev/null +++ b/tests/testData/ast/arrayType/statement/d2StringEmptyArray.jav @@ -0,0 +1 @@ +String [][] ss = new String[5][5]; \ No newline at end of file diff --git a/tests/testData/ast/arrayType/statement/d2StringEmptyArray.kt b/tests/testData/ast/arrayType/statement/d2StringEmptyArray.kt new file mode 100644 index 00000000000..a4786c4ecb1 --- /dev/null +++ b/tests/testData/ast/arrayType/statement/d2StringEmptyArray.kt @@ -0,0 +1 @@ +var ss : Array?>? = Array?>(5, {Array(5)}) \ No newline at end of file diff --git a/tests/testData/ast/arrayType/statement/d3StringEmptyArray.jav b/tests/testData/ast/arrayType/statement/d3StringEmptyArray.jav new file mode 100644 index 00000000000..498743daff6 --- /dev/null +++ b/tests/testData/ast/arrayType/statement/d3StringEmptyArray.jav @@ -0,0 +1 @@ +String [][][] sss = new String[5][5][5]; \ No newline at end of file diff --git a/tests/testData/ast/arrayType/statement/d3StringEmptyArray.kt b/tests/testData/ast/arrayType/statement/d3StringEmptyArray.kt new file mode 100644 index 00000000000..7e3bd1cb471 --- /dev/null +++ b/tests/testData/ast/arrayType/statement/d3StringEmptyArray.kt @@ -0,0 +1 @@ +var sss : Array?>?>? = Array?>?>(5, {Array?>(5, {Array(5)})}) \ No newline at end of file diff --git a/tests/testData/ast/arrayType/statement/longArray.jav b/tests/testData/ast/arrayType/statement/longArray.jav new file mode 100644 index 00000000000..8ba3eb35a5c --- /dev/null +++ b/tests/testData/ast/arrayType/statement/longArray.jav @@ -0,0 +1 @@ +long[] a = new long[]{1, 2, 3} \ No newline at end of file diff --git a/tests/testData/ast/arrayType/statement/longArray.kt b/tests/testData/ast/arrayType/statement/longArray.kt new file mode 100644 index 00000000000..25e13c35f13 --- /dev/null +++ b/tests/testData/ast/arrayType/statement/longArray.kt @@ -0,0 +1 @@ +var a : LongArray? = longArray(1, 2, 3) \ No newline at end of file diff --git a/tests/testData/ast/arrayType/statement/newIntArray.jav b/tests/testData/ast/arrayType/statement/newIntArray.jav new file mode 100644 index 00000000000..8c66b71c91f --- /dev/null +++ b/tests/testData/ast/arrayType/statement/newIntArray.jav @@ -0,0 +1 @@ +int[] a = new int[]{1, 2, 3} \ No newline at end of file diff --git a/tests/testData/ast/arrayType/statement/newIntArray.kt b/tests/testData/ast/arrayType/statement/newIntArray.kt new file mode 100644 index 00000000000..19b3af3f5c4 --- /dev/null +++ b/tests/testData/ast/arrayType/statement/newIntArray.kt @@ -0,0 +1 @@ +var a : IntArray? = intArray(1, 2, 3) \ No newline at end of file diff --git a/tests/testData/ast/arrayType/statement/newStringArray.jav b/tests/testData/ast/arrayType/statement/newStringArray.jav new file mode 100644 index 00000000000..371c13bfa2d --- /dev/null +++ b/tests/testData/ast/arrayType/statement/newStringArray.jav @@ -0,0 +1 @@ +String[] a = new String[]{"abc"} \ No newline at end of file diff --git a/tests/testData/ast/arrayType/statement/newStringArray.kt b/tests/testData/ast/arrayType/statement/newStringArray.kt new file mode 100644 index 00000000000..8e2ed9e854c --- /dev/null +++ b/tests/testData/ast/arrayType/statement/newStringArray.kt @@ -0,0 +1 @@ +var a : Array? = array("abc") \ No newline at end of file diff --git a/tests/testData/ast/assertStatement/statement/onlyCondition.jav b/tests/testData/ast/assertStatement/statement/onlyCondition.jav new file mode 100644 index 00000000000..7ac44744fe6 --- /dev/null +++ b/tests/testData/ast/assertStatement/statement/onlyCondition.jav @@ -0,0 +1 @@ +assert boolMethod(); \ No newline at end of file diff --git a/tests/testData/ast/assertStatement/statement/onlyCondition.kt b/tests/testData/ast/assertStatement/statement/onlyCondition.kt new file mode 100644 index 00000000000..e148b562e0c --- /dev/null +++ b/tests/testData/ast/assertStatement/statement/onlyCondition.kt @@ -0,0 +1 @@ +assert {boolMethod()} \ No newline at end of file diff --git a/tests/testData/ast/assertStatement/statement/onlyConditionWithBraces.jav b/tests/testData/ast/assertStatement/statement/onlyConditionWithBraces.jav new file mode 100644 index 00000000000..b1c738d82a9 --- /dev/null +++ b/tests/testData/ast/assertStatement/statement/onlyConditionWithBraces.jav @@ -0,0 +1 @@ +assert(boolMethod()); \ No newline at end of file diff --git a/tests/testData/ast/assertStatement/statement/onlyConditionWithBraces.kt b/tests/testData/ast/assertStatement/statement/onlyConditionWithBraces.kt new file mode 100644 index 00000000000..dda5f1e1170 --- /dev/null +++ b/tests/testData/ast/assertStatement/statement/onlyConditionWithBraces.kt @@ -0,0 +1 @@ +assert {(boolMethod())} \ No newline at end of file diff --git a/tests/testData/ast/assertStatement/statement/withStringDetail.jav b/tests/testData/ast/assertStatement/statement/withStringDetail.jav new file mode 100644 index 00000000000..aad7600e036 --- /dev/null +++ b/tests/testData/ast/assertStatement/statement/withStringDetail.jav @@ -0,0 +1 @@ +assert true : "string details"; \ No newline at end of file diff --git a/tests/testData/ast/assertStatement/statement/withStringDetail.kt b/tests/testData/ast/assertStatement/statement/withStringDetail.kt new file mode 100644 index 00000000000..9fa45aa19e7 --- /dev/null +++ b/tests/testData/ast/assertStatement/statement/withStringDetail.kt @@ -0,0 +1 @@ +assert("string details") {true} \ No newline at end of file diff --git a/tests/testData/ast/assignmentExpression/expression/and.jav b/tests/testData/ast/assignmentExpression/expression/and.jav new file mode 100644 index 00000000000..d345703fc8e --- /dev/null +++ b/tests/testData/ast/assignmentExpression/expression/and.jav @@ -0,0 +1 @@ +x &= 2 \ No newline at end of file diff --git a/tests/testData/ast/assignmentExpression/expression/and.kt b/tests/testData/ast/assignmentExpression/expression/and.kt new file mode 100644 index 00000000000..dc3b47760da --- /dev/null +++ b/tests/testData/ast/assignmentExpression/expression/and.kt @@ -0,0 +1 @@ +x = x and 2 \ No newline at end of file diff --git a/tests/testData/ast/assignmentExpression/expression/assignment.jav b/tests/testData/ast/assignmentExpression/expression/assignment.jav new file mode 100644 index 00000000000..1ddfb7dc8e4 --- /dev/null +++ b/tests/testData/ast/assignmentExpression/expression/assignment.jav @@ -0,0 +1 @@ +x = 2 \ No newline at end of file diff --git a/tests/testData/ast/assignmentExpression/expression/assignment.kt b/tests/testData/ast/assignmentExpression/expression/assignment.kt new file mode 100644 index 00000000000..1ddfb7dc8e4 --- /dev/null +++ b/tests/testData/ast/assignmentExpression/expression/assignment.kt @@ -0,0 +1 @@ +x = 2 \ No newline at end of file diff --git a/tests/testData/ast/assignmentExpression/expression/divideAssign.jav b/tests/testData/ast/assignmentExpression/expression/divideAssign.jav new file mode 100644 index 00000000000..e63372a6277 --- /dev/null +++ b/tests/testData/ast/assignmentExpression/expression/divideAssign.jav @@ -0,0 +1 @@ +x /= 2 \ No newline at end of file diff --git a/tests/testData/ast/assignmentExpression/expression/divideAssign.kt b/tests/testData/ast/assignmentExpression/expression/divideAssign.kt new file mode 100644 index 00000000000..e63372a6277 --- /dev/null +++ b/tests/testData/ast/assignmentExpression/expression/divideAssign.kt @@ -0,0 +1 @@ +x /= 2 \ No newline at end of file diff --git a/tests/testData/ast/assignmentExpression/expression/minusAssign.jav b/tests/testData/ast/assignmentExpression/expression/minusAssign.jav new file mode 100644 index 00000000000..58f87ee4a6c --- /dev/null +++ b/tests/testData/ast/assignmentExpression/expression/minusAssign.jav @@ -0,0 +1 @@ +x -= 2 \ No newline at end of file diff --git a/tests/testData/ast/assignmentExpression/expression/minusAssign.kt b/tests/testData/ast/assignmentExpression/expression/minusAssign.kt new file mode 100644 index 00000000000..58f87ee4a6c --- /dev/null +++ b/tests/testData/ast/assignmentExpression/expression/minusAssign.kt @@ -0,0 +1 @@ +x -= 2 \ No newline at end of file diff --git a/tests/testData/ast/assignmentExpression/expression/multiplyAssign.jav b/tests/testData/ast/assignmentExpression/expression/multiplyAssign.jav new file mode 100644 index 00000000000..ddea70541b0 --- /dev/null +++ b/tests/testData/ast/assignmentExpression/expression/multiplyAssign.jav @@ -0,0 +1 @@ +x *= 2 \ No newline at end of file diff --git a/tests/testData/ast/assignmentExpression/expression/multiplyAssign.kt b/tests/testData/ast/assignmentExpression/expression/multiplyAssign.kt new file mode 100644 index 00000000000..ddea70541b0 --- /dev/null +++ b/tests/testData/ast/assignmentExpression/expression/multiplyAssign.kt @@ -0,0 +1 @@ +x *= 2 \ No newline at end of file diff --git a/tests/testData/ast/assignmentExpression/expression/or.jav b/tests/testData/ast/assignmentExpression/expression/or.jav new file mode 100644 index 00000000000..07b425b9cc5 --- /dev/null +++ b/tests/testData/ast/assignmentExpression/expression/or.jav @@ -0,0 +1 @@ +x |= 2 \ No newline at end of file diff --git a/tests/testData/ast/assignmentExpression/expression/or.kt b/tests/testData/ast/assignmentExpression/expression/or.kt new file mode 100644 index 00000000000..776a84a8989 --- /dev/null +++ b/tests/testData/ast/assignmentExpression/expression/or.kt @@ -0,0 +1 @@ +x = x or 2 \ No newline at end of file diff --git a/tests/testData/ast/assignmentExpression/expression/plusAssign.jav b/tests/testData/ast/assignmentExpression/expression/plusAssign.jav new file mode 100644 index 00000000000..2448227cb69 --- /dev/null +++ b/tests/testData/ast/assignmentExpression/expression/plusAssign.jav @@ -0,0 +1 @@ +x += 2 \ No newline at end of file diff --git a/tests/testData/ast/assignmentExpression/expression/plusAssign.kt b/tests/testData/ast/assignmentExpression/expression/plusAssign.kt new file mode 100644 index 00000000000..2448227cb69 --- /dev/null +++ b/tests/testData/ast/assignmentExpression/expression/plusAssign.kt @@ -0,0 +1 @@ +x += 2 \ No newline at end of file diff --git a/tests/testData/ast/assignmentExpression/expression/reminder.jav b/tests/testData/ast/assignmentExpression/expression/reminder.jav new file mode 100644 index 00000000000..b6fe73d0db1 --- /dev/null +++ b/tests/testData/ast/assignmentExpression/expression/reminder.jav @@ -0,0 +1 @@ +x %= 2 \ No newline at end of file diff --git a/tests/testData/ast/assignmentExpression/expression/reminder.kt b/tests/testData/ast/assignmentExpression/expression/reminder.kt new file mode 100644 index 00000000000..b6fe73d0db1 --- /dev/null +++ b/tests/testData/ast/assignmentExpression/expression/reminder.kt @@ -0,0 +1 @@ +x %= 2 \ No newline at end of file diff --git a/tests/testData/ast/assignmentExpression/expression/shiftLeft.jav b/tests/testData/ast/assignmentExpression/expression/shiftLeft.jav new file mode 100644 index 00000000000..1b5eb34ba7e --- /dev/null +++ b/tests/testData/ast/assignmentExpression/expression/shiftLeft.jav @@ -0,0 +1 @@ +x <<= 2 \ No newline at end of file diff --git a/tests/testData/ast/assignmentExpression/expression/shiftLeft.kt b/tests/testData/ast/assignmentExpression/expression/shiftLeft.kt new file mode 100644 index 00000000000..bc26f965e4d --- /dev/null +++ b/tests/testData/ast/assignmentExpression/expression/shiftLeft.kt @@ -0,0 +1 @@ +x = x shl 2 \ No newline at end of file diff --git a/tests/testData/ast/assignmentExpression/expression/shiftRight.jav b/tests/testData/ast/assignmentExpression/expression/shiftRight.jav new file mode 100644 index 00000000000..ac7c546b4cb --- /dev/null +++ b/tests/testData/ast/assignmentExpression/expression/shiftRight.jav @@ -0,0 +1 @@ +x >>= 2 \ No newline at end of file diff --git a/tests/testData/ast/assignmentExpression/expression/shiftRight.kt b/tests/testData/ast/assignmentExpression/expression/shiftRight.kt new file mode 100644 index 00000000000..a731104d2f6 --- /dev/null +++ b/tests/testData/ast/assignmentExpression/expression/shiftRight.kt @@ -0,0 +1 @@ +x = x shr 2 \ No newline at end of file diff --git a/tests/testData/ast/assignmentExpression/expression/unsignedRightShift.jav b/tests/testData/ast/assignmentExpression/expression/unsignedRightShift.jav new file mode 100644 index 00000000000..80750c37495 --- /dev/null +++ b/tests/testData/ast/assignmentExpression/expression/unsignedRightShift.jav @@ -0,0 +1 @@ +x >>>= 2 \ No newline at end of file diff --git a/tests/testData/ast/assignmentExpression/expression/unsignedRightShift.kt b/tests/testData/ast/assignmentExpression/expression/unsignedRightShift.kt new file mode 100644 index 00000000000..2450029bd56 --- /dev/null +++ b/tests/testData/ast/assignmentExpression/expression/unsignedRightShift.kt @@ -0,0 +1 @@ +x = x ushr 2 \ No newline at end of file diff --git a/tests/testData/ast/assignmentExpression/expression/xor.jav b/tests/testData/ast/assignmentExpression/expression/xor.jav new file mode 100644 index 00000000000..2f6e418eb5d --- /dev/null +++ b/tests/testData/ast/assignmentExpression/expression/xor.jav @@ -0,0 +1 @@ +x ^= 2 \ No newline at end of file diff --git a/tests/testData/ast/assignmentExpression/expression/xor.kt b/tests/testData/ast/assignmentExpression/expression/xor.kt new file mode 100644 index 00000000000..381ed467f3d --- /dev/null +++ b/tests/testData/ast/assignmentExpression/expression/xor.kt @@ -0,0 +1 @@ +x = x xor 2 \ No newline at end of file diff --git a/tests/testData/ast/assignmentExpression/statement/simpleAssignment.jav b/tests/testData/ast/assignmentExpression/statement/simpleAssignment.jav new file mode 100644 index 00000000000..5cb450aa538 --- /dev/null +++ b/tests/testData/ast/assignmentExpression/statement/simpleAssignment.jav @@ -0,0 +1 @@ +i = 1; \ No newline at end of file diff --git a/tests/testData/ast/assignmentExpression/statement/simpleAssignment.kt b/tests/testData/ast/assignmentExpression/statement/simpleAssignment.kt new file mode 100644 index 00000000000..88de072edc6 --- /dev/null +++ b/tests/testData/ast/assignmentExpression/statement/simpleAssignment.kt @@ -0,0 +1 @@ +i = 1 \ No newline at end of file diff --git a/tests/testData/ast/binaryExpression/expression/and.jav b/tests/testData/ast/binaryExpression/expression/and.jav new file mode 100644 index 00000000000..8c519f1a5d3 --- /dev/null +++ b/tests/testData/ast/binaryExpression/expression/and.jav @@ -0,0 +1 @@ +x & 2 \ No newline at end of file diff --git a/tests/testData/ast/binaryExpression/expression/and.kt b/tests/testData/ast/binaryExpression/expression/and.kt new file mode 100644 index 00000000000..cbf463b36ea --- /dev/null +++ b/tests/testData/ast/binaryExpression/expression/and.kt @@ -0,0 +1 @@ +x and 2 \ No newline at end of file diff --git a/tests/testData/ast/binaryExpression/expression/conditionalAnd.jav b/tests/testData/ast/binaryExpression/expression/conditionalAnd.jav new file mode 100644 index 00000000000..5aa60340840 --- /dev/null +++ b/tests/testData/ast/binaryExpression/expression/conditionalAnd.jav @@ -0,0 +1 @@ +true && false \ No newline at end of file diff --git a/tests/testData/ast/binaryExpression/expression/conditionalAnd.kt b/tests/testData/ast/binaryExpression/expression/conditionalAnd.kt new file mode 100644 index 00000000000..5aa60340840 --- /dev/null +++ b/tests/testData/ast/binaryExpression/expression/conditionalAnd.kt @@ -0,0 +1 @@ +true && false \ No newline at end of file diff --git a/tests/testData/ast/binaryExpression/expression/conditionalOr.jav b/tests/testData/ast/binaryExpression/expression/conditionalOr.jav new file mode 100644 index 00000000000..64634c472bc --- /dev/null +++ b/tests/testData/ast/binaryExpression/expression/conditionalOr.jav @@ -0,0 +1 @@ +true || false \ No newline at end of file diff --git a/tests/testData/ast/binaryExpression/expression/conditionalOr.kt b/tests/testData/ast/binaryExpression/expression/conditionalOr.kt new file mode 100644 index 00000000000..64634c472bc --- /dev/null +++ b/tests/testData/ast/binaryExpression/expression/conditionalOr.kt @@ -0,0 +1 @@ +true || false \ No newline at end of file diff --git a/tests/testData/ast/binaryExpression/expression/divide.jav b/tests/testData/ast/binaryExpression/expression/divide.jav new file mode 100644 index 00000000000..0e0b5d58618 --- /dev/null +++ b/tests/testData/ast/binaryExpression/expression/divide.jav @@ -0,0 +1 @@ +1 / 2 \ No newline at end of file diff --git a/tests/testData/ast/binaryExpression/expression/divide.kt b/tests/testData/ast/binaryExpression/expression/divide.kt new file mode 100644 index 00000000000..0e0b5d58618 --- /dev/null +++ b/tests/testData/ast/binaryExpression/expression/divide.kt @@ -0,0 +1 @@ +1 / 2 \ No newline at end of file diff --git a/tests/testData/ast/binaryExpression/expression/greaterThan.jav b/tests/testData/ast/binaryExpression/expression/greaterThan.jav new file mode 100644 index 00000000000..2774817e788 --- /dev/null +++ b/tests/testData/ast/binaryExpression/expression/greaterThan.jav @@ -0,0 +1 @@ +1 > 2 \ No newline at end of file diff --git a/tests/testData/ast/binaryExpression/expression/greaterThan.kt b/tests/testData/ast/binaryExpression/expression/greaterThan.kt new file mode 100644 index 00000000000..2774817e788 --- /dev/null +++ b/tests/testData/ast/binaryExpression/expression/greaterThan.kt @@ -0,0 +1 @@ +1 > 2 \ No newline at end of file diff --git a/tests/testData/ast/binaryExpression/expression/greaterThanEqual.jav b/tests/testData/ast/binaryExpression/expression/greaterThanEqual.jav new file mode 100644 index 00000000000..6993045c7a2 --- /dev/null +++ b/tests/testData/ast/binaryExpression/expression/greaterThanEqual.jav @@ -0,0 +1 @@ +1 >= 2 \ No newline at end of file diff --git a/tests/testData/ast/binaryExpression/expression/greaterThanEqual.kt b/tests/testData/ast/binaryExpression/expression/greaterThanEqual.kt new file mode 100644 index 00000000000..6993045c7a2 --- /dev/null +++ b/tests/testData/ast/binaryExpression/expression/greaterThanEqual.kt @@ -0,0 +1 @@ +1 >= 2 \ No newline at end of file diff --git a/tests/testData/ast/binaryExpression/expression/lessThan.jav b/tests/testData/ast/binaryExpression/expression/lessThan.jav new file mode 100644 index 00000000000..535e996ad9b --- /dev/null +++ b/tests/testData/ast/binaryExpression/expression/lessThan.jav @@ -0,0 +1 @@ +1 < 2 \ No newline at end of file diff --git a/tests/testData/ast/binaryExpression/expression/lessThan.kt b/tests/testData/ast/binaryExpression/expression/lessThan.kt new file mode 100644 index 00000000000..535e996ad9b --- /dev/null +++ b/tests/testData/ast/binaryExpression/expression/lessThan.kt @@ -0,0 +1 @@ +1 < 2 \ No newline at end of file diff --git a/tests/testData/ast/binaryExpression/expression/lessThanEqual.jav b/tests/testData/ast/binaryExpression/expression/lessThanEqual.jav new file mode 100644 index 00000000000..5e9475f92bf --- /dev/null +++ b/tests/testData/ast/binaryExpression/expression/lessThanEqual.jav @@ -0,0 +1 @@ +1 <= 2 \ No newline at end of file diff --git a/tests/testData/ast/binaryExpression/expression/lessThanEqual.kt b/tests/testData/ast/binaryExpression/expression/lessThanEqual.kt new file mode 100644 index 00000000000..5e9475f92bf --- /dev/null +++ b/tests/testData/ast/binaryExpression/expression/lessThanEqual.kt @@ -0,0 +1 @@ +1 <= 2 \ No newline at end of file diff --git a/tests/testData/ast/binaryExpression/expression/minus.jav b/tests/testData/ast/binaryExpression/expression/minus.jav new file mode 100644 index 00000000000..7ec0a893aef --- /dev/null +++ b/tests/testData/ast/binaryExpression/expression/minus.jav @@ -0,0 +1 @@ +1 - 2 \ No newline at end of file diff --git a/tests/testData/ast/binaryExpression/expression/minus.kt b/tests/testData/ast/binaryExpression/expression/minus.kt new file mode 100644 index 00000000000..7ec0a893aef --- /dev/null +++ b/tests/testData/ast/binaryExpression/expression/minus.kt @@ -0,0 +1 @@ +1 - 2 \ No newline at end of file diff --git a/tests/testData/ast/binaryExpression/expression/multiply.jav b/tests/testData/ast/binaryExpression/expression/multiply.jav new file mode 100644 index 00000000000..a48dfec9fa5 --- /dev/null +++ b/tests/testData/ast/binaryExpression/expression/multiply.jav @@ -0,0 +1 @@ +1 * 2 \ No newline at end of file diff --git a/tests/testData/ast/binaryExpression/expression/multiply.kt b/tests/testData/ast/binaryExpression/expression/multiply.kt new file mode 100644 index 00000000000..a48dfec9fa5 --- /dev/null +++ b/tests/testData/ast/binaryExpression/expression/multiply.kt @@ -0,0 +1 @@ +1 * 2 \ No newline at end of file diff --git a/tests/testData/ast/binaryExpression/expression/or.jav b/tests/testData/ast/binaryExpression/expression/or.jav new file mode 100644 index 00000000000..27e32efa3d5 --- /dev/null +++ b/tests/testData/ast/binaryExpression/expression/or.jav @@ -0,0 +1 @@ +x | 2 \ No newline at end of file diff --git a/tests/testData/ast/binaryExpression/expression/or.kt b/tests/testData/ast/binaryExpression/expression/or.kt new file mode 100644 index 00000000000..ccad705935d --- /dev/null +++ b/tests/testData/ast/binaryExpression/expression/or.kt @@ -0,0 +1 @@ +x or 2 \ No newline at end of file diff --git a/tests/testData/ast/binaryExpression/expression/plus.jav b/tests/testData/ast/binaryExpression/expression/plus.jav new file mode 100644 index 00000000000..193df0b550b --- /dev/null +++ b/tests/testData/ast/binaryExpression/expression/plus.jav @@ -0,0 +1 @@ +1 + 2 \ No newline at end of file diff --git a/tests/testData/ast/binaryExpression/expression/plus.kt b/tests/testData/ast/binaryExpression/expression/plus.kt new file mode 100644 index 00000000000..193df0b550b --- /dev/null +++ b/tests/testData/ast/binaryExpression/expression/plus.kt @@ -0,0 +1 @@ +1 + 2 \ No newline at end of file diff --git a/tests/testData/ast/binaryExpression/expression/remainder.jav b/tests/testData/ast/binaryExpression/expression/remainder.jav new file mode 100644 index 00000000000..049211394d2 --- /dev/null +++ b/tests/testData/ast/binaryExpression/expression/remainder.jav @@ -0,0 +1 @@ +1 % 2 \ No newline at end of file diff --git a/tests/testData/ast/binaryExpression/expression/remainder.kt b/tests/testData/ast/binaryExpression/expression/remainder.kt new file mode 100644 index 00000000000..049211394d2 --- /dev/null +++ b/tests/testData/ast/binaryExpression/expression/remainder.kt @@ -0,0 +1 @@ +1 % 2 \ No newline at end of file diff --git a/tests/testData/ast/binaryExpression/expression/shiftLeft.jav b/tests/testData/ast/binaryExpression/expression/shiftLeft.jav new file mode 100644 index 00000000000..0fc7ee16109 --- /dev/null +++ b/tests/testData/ast/binaryExpression/expression/shiftLeft.jav @@ -0,0 +1 @@ +x << 2 \ No newline at end of file diff --git a/tests/testData/ast/binaryExpression/expression/shiftLeft.kt b/tests/testData/ast/binaryExpression/expression/shiftLeft.kt new file mode 100644 index 00000000000..face9a53255 --- /dev/null +++ b/tests/testData/ast/binaryExpression/expression/shiftLeft.kt @@ -0,0 +1 @@ +x shl 2 \ No newline at end of file diff --git a/tests/testData/ast/binaryExpression/expression/shiftRight.jav b/tests/testData/ast/binaryExpression/expression/shiftRight.jav new file mode 100644 index 00000000000..452d459f0be --- /dev/null +++ b/tests/testData/ast/binaryExpression/expression/shiftRight.jav @@ -0,0 +1 @@ +x >> 2 \ No newline at end of file diff --git a/tests/testData/ast/binaryExpression/expression/shiftRight.kt b/tests/testData/ast/binaryExpression/expression/shiftRight.kt new file mode 100644 index 00000000000..771795abe88 --- /dev/null +++ b/tests/testData/ast/binaryExpression/expression/shiftRight.kt @@ -0,0 +1 @@ +x shr 2 \ No newline at end of file diff --git a/tests/testData/ast/binaryExpression/expression/unsignedRightShift.jav b/tests/testData/ast/binaryExpression/expression/unsignedRightShift.jav new file mode 100644 index 00000000000..43c9914d750 --- /dev/null +++ b/tests/testData/ast/binaryExpression/expression/unsignedRightShift.jav @@ -0,0 +1 @@ +x >>> 2 \ No newline at end of file diff --git a/tests/testData/ast/binaryExpression/expression/unsignedRightShift.kt b/tests/testData/ast/binaryExpression/expression/unsignedRightShift.kt new file mode 100644 index 00000000000..8b8c1f89e58 --- /dev/null +++ b/tests/testData/ast/binaryExpression/expression/unsignedRightShift.kt @@ -0,0 +1 @@ +x.ushr(2) \ No newline at end of file diff --git a/tests/testData/ast/binaryExpression/expression/xor.jav b/tests/testData/ast/binaryExpression/expression/xor.jav new file mode 100644 index 00000000000..09b544bdf1e --- /dev/null +++ b/tests/testData/ast/binaryExpression/expression/xor.jav @@ -0,0 +1 @@ +x ^ 2 \ No newline at end of file diff --git a/tests/testData/ast/binaryExpression/expression/xor.kt b/tests/testData/ast/binaryExpression/expression/xor.kt new file mode 100644 index 00000000000..b8ad1650a31 --- /dev/null +++ b/tests/testData/ast/binaryExpression/expression/xor.kt @@ -0,0 +1 @@ +x xor 2 \ No newline at end of file diff --git a/tests/testData/ast/boxedType/file/kt-671.jav b/tests/testData/ast/boxedType/file/kt-671.jav new file mode 100644 index 00000000000..520765b7b08 --- /dev/null +++ b/tests/testData/ast/boxedType/file/kt-671.jav @@ -0,0 +1,8 @@ +package demo; + +class Test { + void test() { + Integer i = Integer.valueOf(100); + Short s = Short.valueOf(100); + } +} \ No newline at end of file diff --git a/tests/testData/ast/boxedType/file/kt-671.kt b/tests/testData/ast/boxedType/file/kt-671.kt new file mode 100644 index 00000000000..2e152c13152 --- /dev/null +++ b/tests/testData/ast/boxedType/file/kt-671.kt @@ -0,0 +1,7 @@ +package demo +open class Test() { +open fun test() : Unit { +var i : Int? = Integer.valueOf(100) +var s : Short? = Short.valueOf(100) +} +} \ No newline at end of file diff --git a/tests/testData/ast/boxedType/statement/boolean.jav b/tests/testData/ast/boxedType/statement/boolean.jav new file mode 100644 index 00000000000..ccd666e6ee8 --- /dev/null +++ b/tests/testData/ast/boxedType/statement/boolean.jav @@ -0,0 +1 @@ +Boolean i = 10; \ No newline at end of file diff --git a/tests/testData/ast/boxedType/statement/boolean.kt b/tests/testData/ast/boxedType/statement/boolean.kt new file mode 100644 index 00000000000..a04aa401cb4 --- /dev/null +++ b/tests/testData/ast/boxedType/statement/boolean.kt @@ -0,0 +1 @@ +var i : Boolean? = 10 \ No newline at end of file diff --git a/tests/testData/ast/boxedType/statement/byte.jav b/tests/testData/ast/boxedType/statement/byte.jav new file mode 100644 index 00000000000..14a750b548b --- /dev/null +++ b/tests/testData/ast/boxedType/statement/byte.jav @@ -0,0 +1 @@ +Byte i = 10; \ No newline at end of file diff --git a/tests/testData/ast/boxedType/statement/byte.kt b/tests/testData/ast/boxedType/statement/byte.kt new file mode 100644 index 00000000000..c44367fae64 --- /dev/null +++ b/tests/testData/ast/boxedType/statement/byte.kt @@ -0,0 +1 @@ +var i : Byte? = 10 \ No newline at end of file diff --git a/tests/testData/ast/boxedType/statement/character.jav b/tests/testData/ast/boxedType/statement/character.jav new file mode 100644 index 00000000000..611a419cc54 --- /dev/null +++ b/tests/testData/ast/boxedType/statement/character.jav @@ -0,0 +1 @@ +Character i = 10; \ No newline at end of file diff --git a/tests/testData/ast/boxedType/statement/character.kt b/tests/testData/ast/boxedType/statement/character.kt new file mode 100644 index 00000000000..66c64a43830 --- /dev/null +++ b/tests/testData/ast/boxedType/statement/character.kt @@ -0,0 +1 @@ +var i : Char? = 10 \ No newline at end of file diff --git a/tests/testData/ast/boxedType/statement/double.jav b/tests/testData/ast/boxedType/statement/double.jav new file mode 100644 index 00000000000..691af6d77f6 --- /dev/null +++ b/tests/testData/ast/boxedType/statement/double.jav @@ -0,0 +1 @@ +Double i = 10; \ No newline at end of file diff --git a/tests/testData/ast/boxedType/statement/double.kt b/tests/testData/ast/boxedType/statement/double.kt new file mode 100644 index 00000000000..ad23a49855d --- /dev/null +++ b/tests/testData/ast/boxedType/statement/double.kt @@ -0,0 +1 @@ +var i : Double? = 10 \ No newline at end of file diff --git a/tests/testData/ast/boxedType/statement/float.jav b/tests/testData/ast/boxedType/statement/float.jav new file mode 100644 index 00000000000..c283bbbe5fa --- /dev/null +++ b/tests/testData/ast/boxedType/statement/float.jav @@ -0,0 +1 @@ +Float i = 10; \ No newline at end of file diff --git a/tests/testData/ast/boxedType/statement/float.kt b/tests/testData/ast/boxedType/statement/float.kt new file mode 100644 index 00000000000..72df9c19575 --- /dev/null +++ b/tests/testData/ast/boxedType/statement/float.kt @@ -0,0 +1 @@ +var i : Float? = 10 \ No newline at end of file diff --git a/tests/testData/ast/boxedType/statement/integer.jav b/tests/testData/ast/boxedType/statement/integer.jav new file mode 100644 index 00000000000..ce81c24fe40 --- /dev/null +++ b/tests/testData/ast/boxedType/statement/integer.jav @@ -0,0 +1 @@ +Integer i = 10; \ No newline at end of file diff --git a/tests/testData/ast/boxedType/statement/integer.kt b/tests/testData/ast/boxedType/statement/integer.kt new file mode 100644 index 00000000000..eb490098482 --- /dev/null +++ b/tests/testData/ast/boxedType/statement/integer.kt @@ -0,0 +1 @@ +var i : Int? = 10 \ No newline at end of file diff --git a/tests/testData/ast/boxedType/statement/long.jav b/tests/testData/ast/boxedType/statement/long.jav new file mode 100644 index 00000000000..9ca58295d8a --- /dev/null +++ b/tests/testData/ast/boxedType/statement/long.jav @@ -0,0 +1 @@ +Long i = 10; \ No newline at end of file diff --git a/tests/testData/ast/boxedType/statement/long.kt b/tests/testData/ast/boxedType/statement/long.kt new file mode 100644 index 00000000000..aa1584ac634 --- /dev/null +++ b/tests/testData/ast/boxedType/statement/long.kt @@ -0,0 +1 @@ +var i : Long? = 10 \ No newline at end of file diff --git a/tests/testData/ast/boxedType/statement/object.jav b/tests/testData/ast/boxedType/statement/object.jav new file mode 100644 index 00000000000..ca135870cd6 --- /dev/null +++ b/tests/testData/ast/boxedType/statement/object.jav @@ -0,0 +1 @@ +Object i = 10; \ No newline at end of file diff --git a/tests/testData/ast/boxedType/statement/object.kt b/tests/testData/ast/boxedType/statement/object.kt new file mode 100644 index 00000000000..611c618a389 --- /dev/null +++ b/tests/testData/ast/boxedType/statement/object.kt @@ -0,0 +1 @@ +var i : Any? = 10 \ No newline at end of file diff --git a/tests/testData/ast/boxedType/statement/short.jav b/tests/testData/ast/boxedType/statement/short.jav new file mode 100644 index 00000000000..1364e5c8dbb --- /dev/null +++ b/tests/testData/ast/boxedType/statement/short.jav @@ -0,0 +1 @@ +Short i = 10; \ No newline at end of file diff --git a/tests/testData/ast/boxedType/statement/short.kt b/tests/testData/ast/boxedType/statement/short.kt new file mode 100644 index 00000000000..8daff77deb3 --- /dev/null +++ b/tests/testData/ast/boxedType/statement/short.kt @@ -0,0 +1 @@ +var i : Short? = 10 \ No newline at end of file diff --git a/tests/testData/ast/breakStatement/statement/breakWithLabel.jav b/tests/testData/ast/breakStatement/statement/breakWithLabel.jav new file mode 100644 index 00000000000..b2375dc68b4 --- /dev/null +++ b/tests/testData/ast/breakStatement/statement/breakWithLabel.jav @@ -0,0 +1 @@ +break label; \ No newline at end of file diff --git a/tests/testData/ast/breakStatement/statement/breakWithLabel.kt b/tests/testData/ast/breakStatement/statement/breakWithLabel.kt new file mode 100644 index 00000000000..02d8620a138 --- /dev/null +++ b/tests/testData/ast/breakStatement/statement/breakWithLabel.kt @@ -0,0 +1 @@ +break@label \ No newline at end of file diff --git a/tests/testData/ast/breakStatement/statement/breakWithoutLabel.jav b/tests/testData/ast/breakStatement/statement/breakWithoutLabel.jav new file mode 100644 index 00000000000..8cb76cf02d7 --- /dev/null +++ b/tests/testData/ast/breakStatement/statement/breakWithoutLabel.jav @@ -0,0 +1 @@ +break; \ No newline at end of file diff --git a/tests/testData/ast/breakStatement/statement/breakWithoutLabel.kt b/tests/testData/ast/breakStatement/statement/breakWithoutLabel.kt new file mode 100644 index 00000000000..5da70343a46 --- /dev/null +++ b/tests/testData/ast/breakStatement/statement/breakWithoutLabel.kt @@ -0,0 +1 @@ +break \ No newline at end of file diff --git a/tests/testData/ast/callChainExpression/file/libraryFieldCall.jav b/tests/testData/ast/callChainExpression/file/libraryFieldCall.jav new file mode 100644 index 00000000000..2278e35a1bc --- /dev/null +++ b/tests/testData/ast/callChainExpression/file/libraryFieldCall.jav @@ -0,0 +1,9 @@ +class Library { + final static java.io.PrintStream ourOut; +} + +class User { + void main() { + Library.ourOut.print(); + } +} \ No newline at end of file diff --git a/tests/testData/ast/callChainExpression/file/libraryFieldCall.kt b/tests/testData/ast/callChainExpression/file/libraryFieldCall.kt new file mode 100644 index 00000000000..378eea1a63c --- /dev/null +++ b/tests/testData/ast/callChainExpression/file/libraryFieldCall.kt @@ -0,0 +1,10 @@ +open class Library() { +class object { +val ourOut : java.io.PrintStream? = null +} +} +open class User() { +open fun main() : Unit { +Library.ourOut?.print() +} +} \ No newline at end of file diff --git a/tests/testData/ast/callChainExpression/file/libraryMethodCall.jav b/tests/testData/ast/callChainExpression/file/libraryMethodCall.jav new file mode 100644 index 00000000000..265696edc72 --- /dev/null +++ b/tests/testData/ast/callChainExpression/file/libraryMethodCall.jav @@ -0,0 +1,12 @@ +class Library { + static void call() {} + + static String getString() { return ""; } +} + +class User { + void main() { + Library.call(); + Library.getString().isEmpty(); + } +} \ No newline at end of file diff --git a/tests/testData/ast/callChainExpression/file/libraryMethodCall.kt b/tests/testData/ast/callChainExpression/file/libraryMethodCall.kt new file mode 100644 index 00000000000..5aee1de5bf7 --- /dev/null +++ b/tests/testData/ast/callChainExpression/file/libraryMethodCall.kt @@ -0,0 +1,15 @@ +open class Library() { +class object { +open fun call() : Unit { +} +open fun getString() : String? { +return "" +} +} +} +open class User() { +open fun main() : Unit { +Library.call() +Library.getString()?.isEmpty() +} +} \ No newline at end of file diff --git a/tests/testData/ast/callChainExpression/file/libraryMethodCallFromInstance.jav b/tests/testData/ast/callChainExpression/file/libraryMethodCallFromInstance.jav new file mode 100644 index 00000000000..3a22446070d --- /dev/null +++ b/tests/testData/ast/callChainExpression/file/libraryMethodCallFromInstance.jav @@ -0,0 +1,16 @@ +class Library { + void call() {} + + String getString() { return ""; } +} + +class User { + void main() { + Library lib = new Library(); + lib.call(); + lib.getString().isEmpty(); + + new Library().call(); + new Library().getString().isEmpty(); + } +} \ No newline at end of file diff --git a/tests/testData/ast/callChainExpression/file/libraryMethodCallFromInstance.kt b/tests/testData/ast/callChainExpression/file/libraryMethodCallFromInstance.kt new file mode 100644 index 00000000000..74d51867f1a --- /dev/null +++ b/tests/testData/ast/callChainExpression/file/libraryMethodCallFromInstance.kt @@ -0,0 +1,16 @@ +open class Library() { +open fun call() : Unit { +} +open fun getString() : String? { +return "" +} +} +open class User() { +open fun main() : Unit { +var lib : Library? = Library() +lib?.call() +lib?.getString()?.isEmpty() +Library().call() +Library().getString()?.isEmpty() +} +} \ No newline at end of file diff --git a/tests/testData/ast/callChainExpression/file/libraryStringFieldCall.jav b/tests/testData/ast/callChainExpression/file/libraryStringFieldCall.jav new file mode 100644 index 00000000000..67d826da1d9 --- /dev/null +++ b/tests/testData/ast/callChainExpression/file/libraryStringFieldCall.jav @@ -0,0 +1,9 @@ +class Library { + final public String myString; +} + +class User { + void main() { + Library.myString.isEmpty(); + } +} \ No newline at end of file diff --git a/tests/testData/ast/callChainExpression/file/libraryStringFieldCall.kt b/tests/testData/ast/callChainExpression/file/libraryStringFieldCall.kt new file mode 100644 index 00000000000..cb6a3f85868 --- /dev/null +++ b/tests/testData/ast/callChainExpression/file/libraryStringFieldCall.kt @@ -0,0 +1,8 @@ +open class Library() { +public val myString : String? = null +} +open class User() { +open fun main() : Unit { +Library.myString?.isEmpty() +} +} \ No newline at end of file diff --git a/tests/testData/ast/callChainExpression/statement/sout.jav b/tests/testData/ast/callChainExpression/statement/sout.jav new file mode 100644 index 00000000000..a16cbe89562 --- /dev/null +++ b/tests/testData/ast/callChainExpression/statement/sout.jav @@ -0,0 +1 @@ +System.out.println("Hello, world"); \ No newline at end of file diff --git a/tests/testData/ast/callChainExpression/statement/sout.kt b/tests/testData/ast/callChainExpression/statement/sout.kt new file mode 100644 index 00000000000..183416fbb5f --- /dev/null +++ b/tests/testData/ast/callChainExpression/statement/sout.kt @@ -0,0 +1 @@ +System.out?.println("Hello, world") \ No newline at end of file diff --git a/tests/testData/ast/class/class/abstractClass.jav b/tests/testData/ast/class/class/abstractClass.jav new file mode 100644 index 00000000000..0ff487db135 --- /dev/null +++ b/tests/testData/ast/class/class/abstractClass.jav @@ -0,0 +1,7 @@ +abstract class A { + abstract void callme(); + + void callmetoo() { + print("This is a concrete method."); + } +} \ No newline at end of file diff --git a/tests/testData/ast/class/class/abstractClass.kt b/tests/testData/ast/class/class/abstractClass.kt new file mode 100644 index 00000000000..316e303dd1e --- /dev/null +++ b/tests/testData/ast/class/class/abstractClass.kt @@ -0,0 +1,6 @@ +abstract class A() { +abstract fun callme() : Unit +open fun callmetoo() : Unit { +print("This is a concrete method.") +} +} \ No newline at end of file diff --git a/tests/testData/ast/class/class/abstractClassShape.jav b/tests/testData/ast/class/class/abstractClassShape.jav new file mode 100644 index 00000000000..a6b01569bbb --- /dev/null +++ b/tests/testData/ast/class/class/abstractClassShape.jav @@ -0,0 +1,12 @@ +abstract class Shape { + public String color; + public Shape() { + } + public void setColor(String c) { + color = c; + } + public String getColor() { + return color; + } + public abstract double area(); +} \ No newline at end of file diff --git a/tests/testData/ast/class/class/abstractClassShape.kt b/tests/testData/ast/class/class/abstractClassShape.kt new file mode 100644 index 00000000000..99ff0d782d2 --- /dev/null +++ b/tests/testData/ast/class/class/abstractClassShape.kt @@ -0,0 +1,10 @@ +abstract class Shape() { +public var color : String? = null +public open fun setColor(c : String?) : Unit { +color = c +} +public open fun getColor() : String? { +return color +} +public abstract fun area() : Double +} \ No newline at end of file diff --git a/tests/testData/ast/class/class/class.jav b/tests/testData/ast/class/class/class.jav new file mode 100644 index 00000000000..183c3f5b3be --- /dev/null +++ b/tests/testData/ast/class/class/class.jav @@ -0,0 +1 @@ +class Test {} \ No newline at end of file diff --git a/tests/testData/ast/class/class/class.kt b/tests/testData/ast/class/class/class.kt new file mode 100644 index 00000000000..12074d8ca63 --- /dev/null +++ b/tests/testData/ast/class/class/class.kt @@ -0,0 +1,2 @@ +open class Test() { +} \ No newline at end of file diff --git a/tests/testData/ast/class/class/classWithEmptyMethods.jav b/tests/testData/ast/class/class/classWithEmptyMethods.jav new file mode 100644 index 00000000000..49ec763ae8f --- /dev/null +++ b/tests/testData/ast/class/class/classWithEmptyMethods.jav @@ -0,0 +1 @@ +final class T {void main() {}int i() {}String s() {}} \ No newline at end of file diff --git a/tests/testData/ast/class/class/classWithEmptyMethods.kt b/tests/testData/ast/class/class/classWithEmptyMethods.kt new file mode 100644 index 00000000000..8d93d9edbee --- /dev/null +++ b/tests/testData/ast/class/class/classWithEmptyMethods.kt @@ -0,0 +1,8 @@ +class T() { +fun main() : Unit { +} +fun i() : Int { +} +fun s() : String? { +} +} \ No newline at end of file diff --git a/tests/testData/ast/class/class/classWithFields.jav b/tests/testData/ast/class/class/classWithFields.jav new file mode 100644 index 00000000000..c7059937021 --- /dev/null +++ b/tests/testData/ast/class/class/classWithFields.jav @@ -0,0 +1 @@ +final class T {String a = "abc";int b = 10;} \ No newline at end of file diff --git a/tests/testData/ast/class/class/classWithFields.kt b/tests/testData/ast/class/class/classWithFields.kt new file mode 100644 index 00000000000..bc30d1369fb --- /dev/null +++ b/tests/testData/ast/class/class/classWithFields.kt @@ -0,0 +1,4 @@ +class T() { +var a : String? = "abc" +var b : Int = 10 +} \ No newline at end of file diff --git a/tests/testData/ast/class/class/classWithMultiplyFields.jav b/tests/testData/ast/class/class/classWithMultiplyFields.jav new file mode 100644 index 00000000000..6fd5e1a9865 --- /dev/null +++ b/tests/testData/ast/class/class/classWithMultiplyFields.jav @@ -0,0 +1 @@ +final class T {String a, b, c = "abc";} \ No newline at end of file diff --git a/tests/testData/ast/class/class/classWithMultiplyFields.kt b/tests/testData/ast/class/class/classWithMultiplyFields.kt new file mode 100644 index 00000000000..f5c6b484de9 --- /dev/null +++ b/tests/testData/ast/class/class/classWithMultiplyFields.kt @@ -0,0 +1,5 @@ +class T() { +var a : String? = null +var b : String? = null +var c : String? = "abc" +} \ No newline at end of file diff --git a/tests/testData/ast/class/class/emptyClass.jav b/tests/testData/ast/class/class/emptyClass.jav new file mode 100644 index 00000000000..151119ab6a7 --- /dev/null +++ b/tests/testData/ast/class/class/emptyClass.jav @@ -0,0 +1 @@ +final class A {} \ No newline at end of file diff --git a/tests/testData/ast/class/class/emptyClass.kt b/tests/testData/ast/class/class/emptyClass.kt new file mode 100644 index 00000000000..aa34bb7310a --- /dev/null +++ b/tests/testData/ast/class/class/emptyClass.kt @@ -0,0 +1,2 @@ +class A() { +} \ No newline at end of file diff --git a/tests/testData/ast/class/class/extendsOneClassAndImplementsOneInterface.jav b/tests/testData/ast/class/class/extendsOneClassAndImplementsOneInterface.jav new file mode 100644 index 00000000000..b306e379a44 --- /dev/null +++ b/tests/testData/ast/class/class/extendsOneClassAndImplementsOneInterface.jav @@ -0,0 +1 @@ +final class A extends Base implements I {} \ No newline at end of file diff --git a/tests/testData/ast/class/class/extendsOneClassAndImplementsOneInterface.kt b/tests/testData/ast/class/class/extendsOneClassAndImplementsOneInterface.kt new file mode 100644 index 00000000000..116ab42039f --- /dev/null +++ b/tests/testData/ast/class/class/extendsOneClassAndImplementsOneInterface.kt @@ -0,0 +1,2 @@ +class A() : Base(), I { +} \ No newline at end of file diff --git a/tests/testData/ast/class/class/extendsOneClassAndImplementsSeveralInterfaces.jav b/tests/testData/ast/class/class/extendsOneClassAndImplementsSeveralInterfaces.jav new file mode 100644 index 00000000000..dd454cafdb7 --- /dev/null +++ b/tests/testData/ast/class/class/extendsOneClassAndImplementsSeveralInterfaces.jav @@ -0,0 +1 @@ +final class A extends Base implements I0, I1, I2 {} \ No newline at end of file diff --git a/tests/testData/ast/class/class/extendsOneClassAndImplementsSeveralInterfaces.kt b/tests/testData/ast/class/class/extendsOneClassAndImplementsSeveralInterfaces.kt new file mode 100644 index 00000000000..33d88bf434b --- /dev/null +++ b/tests/testData/ast/class/class/extendsOneClassAndImplementsSeveralInterfaces.kt @@ -0,0 +1,2 @@ +class A() : Base(), I0, I1, I2 { +} \ No newline at end of file diff --git a/tests/testData/ast/class/class/finalClass.jav b/tests/testData/ast/class/class/finalClass.jav new file mode 100644 index 00000000000..5071bba9931 --- /dev/null +++ b/tests/testData/ast/class/class/finalClass.jav @@ -0,0 +1 @@ +final class Test {} \ No newline at end of file diff --git a/tests/testData/ast/class/class/finalClass.kt b/tests/testData/ast/class/class/finalClass.kt new file mode 100644 index 00000000000..e11f4f0f7dc --- /dev/null +++ b/tests/testData/ast/class/class/finalClass.kt @@ -0,0 +1,2 @@ +class Test() { +} \ No newline at end of file diff --git a/tests/testData/ast/class/class/genericClass.jav b/tests/testData/ast/class/class/genericClass.jav new file mode 100644 index 00000000000..b18123be7cb --- /dev/null +++ b/tests/testData/ast/class/class/genericClass.jav @@ -0,0 +1 @@ +final class Entry {} \ No newline at end of file diff --git a/tests/testData/ast/class/class/genericClass.kt b/tests/testData/ast/class/class/genericClass.kt new file mode 100644 index 00000000000..72cf1720284 --- /dev/null +++ b/tests/testData/ast/class/class/genericClass.kt @@ -0,0 +1,2 @@ +class Entry() { +} \ No newline at end of file diff --git a/tests/testData/ast/class/class/innerEmptyClass.jav b/tests/testData/ast/class/class/innerEmptyClass.jav new file mode 100644 index 00000000000..3053641622a --- /dev/null +++ b/tests/testData/ast/class/class/innerEmptyClass.jav @@ -0,0 +1 @@ +final class A { inner final class B {} } \ No newline at end of file diff --git a/tests/testData/ast/class/class/innerEmptyClass.kt b/tests/testData/ast/class/class/innerEmptyClass.kt new file mode 100644 index 00000000000..1ead720d6e0 --- /dev/null +++ b/tests/testData/ast/class/class/innerEmptyClass.kt @@ -0,0 +1,4 @@ +class A() { +class B() { +} +} \ No newline at end of file diff --git a/tests/testData/ast/class/class/innerStaticClass.jav b/tests/testData/ast/class/class/innerStaticClass.jav new file mode 100644 index 00000000000..d0885630764 --- /dev/null +++ b/tests/testData/ast/class/class/innerStaticClass.jav @@ -0,0 +1 @@ +final class S { static class Inner {} } \ No newline at end of file diff --git a/tests/testData/ast/class/class/innerStaticClass.kt b/tests/testData/ast/class/class/innerStaticClass.kt new file mode 100644 index 00000000000..7749f9ee5be --- /dev/null +++ b/tests/testData/ast/class/class/innerStaticClass.kt @@ -0,0 +1,6 @@ +class S() { +class object { +open class Inner() { +} +} +} \ No newline at end of file diff --git a/tests/testData/ast/class/class/internalClass.jav b/tests/testData/ast/class/class/internalClass.jav new file mode 100644 index 00000000000..183c3f5b3be --- /dev/null +++ b/tests/testData/ast/class/class/internalClass.jav @@ -0,0 +1 @@ +class Test {} \ No newline at end of file diff --git a/tests/testData/ast/class/class/internalClass.kt b/tests/testData/ast/class/class/internalClass.kt new file mode 100644 index 00000000000..12074d8ca63 --- /dev/null +++ b/tests/testData/ast/class/class/internalClass.kt @@ -0,0 +1,2 @@ +open class Test() { +} \ No newline at end of file diff --git a/tests/testData/ast/class/class/oneStaticFieldOneNonStatic.jav b/tests/testData/ast/class/class/oneStaticFieldOneNonStatic.jav new file mode 100644 index 00000000000..0e0b14688a4 --- /dev/null +++ b/tests/testData/ast/class/class/oneStaticFieldOneNonStatic.jav @@ -0,0 +1 @@ +final class S { boolean sB() { return true; } static int myI = 10; } \ No newline at end of file diff --git a/tests/testData/ast/class/class/oneStaticFieldOneNonStatic.kt b/tests/testData/ast/class/class/oneStaticFieldOneNonStatic.kt new file mode 100644 index 00000000000..2862633ce5f --- /dev/null +++ b/tests/testData/ast/class/class/oneStaticFieldOneNonStatic.kt @@ -0,0 +1,8 @@ +class S() { +fun sB() : Boolean { +return true +} +class object { +var myI : Int = 10 +} +} \ No newline at end of file diff --git a/tests/testData/ast/class/class/oneStaticMethod.jav b/tests/testData/ast/class/class/oneStaticMethod.jav new file mode 100644 index 00000000000..98884d114b7 --- /dev/null +++ b/tests/testData/ast/class/class/oneStaticMethod.jav @@ -0,0 +1 @@ +final class S { static boolean staticF() { return true; } } \ No newline at end of file diff --git a/tests/testData/ast/class/class/oneStaticMethod.kt b/tests/testData/ast/class/class/oneStaticMethod.kt new file mode 100644 index 00000000000..8a46f08d3df --- /dev/null +++ b/tests/testData/ast/class/class/oneStaticMethod.kt @@ -0,0 +1,7 @@ +class S() { +class object { +fun staticF() : Boolean { +return true +} +} +} \ No newline at end of file diff --git a/tests/testData/ast/class/class/oneStaticMethodOneNonStatic.jav b/tests/testData/ast/class/class/oneStaticMethodOneNonStatic.jav new file mode 100644 index 00000000000..4c6915861c5 --- /dev/null +++ b/tests/testData/ast/class/class/oneStaticMethodOneNonStatic.jav @@ -0,0 +1 @@ +final class S { boolean sB() { return true; } static int sI() { return 1; } } \ No newline at end of file diff --git a/tests/testData/ast/class/class/oneStaticMethodOneNonStatic.kt b/tests/testData/ast/class/class/oneStaticMethodOneNonStatic.kt new file mode 100644 index 00000000000..ae38a2df074 --- /dev/null +++ b/tests/testData/ast/class/class/oneStaticMethodOneNonStatic.kt @@ -0,0 +1,10 @@ +class S() { +fun sB() : Boolean { +return true +} +class object { +fun sI() : Int { +return 1 +} +} +} \ No newline at end of file diff --git a/tests/testData/ast/class/class/pivateClass.jav b/tests/testData/ast/class/class/pivateClass.jav new file mode 100644 index 00000000000..91cc7a0e937 --- /dev/null +++ b/tests/testData/ast/class/class/pivateClass.jav @@ -0,0 +1 @@ +private class Test {} \ No newline at end of file diff --git a/tests/testData/ast/class/class/pivateClass.kt b/tests/testData/ast/class/class/pivateClass.kt new file mode 100644 index 00000000000..59b49aed430 --- /dev/null +++ b/tests/testData/ast/class/class/pivateClass.kt @@ -0,0 +1,2 @@ +private open class Test() { +} \ No newline at end of file diff --git a/tests/testData/ast/class/class/protectedClass.jav b/tests/testData/ast/class/class/protectedClass.jav new file mode 100644 index 00000000000..d27e53f5081 --- /dev/null +++ b/tests/testData/ast/class/class/protectedClass.jav @@ -0,0 +1 @@ +protected class Test {} \ No newline at end of file diff --git a/tests/testData/ast/class/class/protectedClass.kt b/tests/testData/ast/class/class/protectedClass.kt new file mode 100644 index 00000000000..bedde57bda8 --- /dev/null +++ b/tests/testData/ast/class/class/protectedClass.kt @@ -0,0 +1,2 @@ +protected open class Test() { +} \ No newline at end of file diff --git a/tests/testData/ast/class/class/publicClass.jav b/tests/testData/ast/class/class/publicClass.jav new file mode 100644 index 00000000000..099aac22fd3 --- /dev/null +++ b/tests/testData/ast/class/class/publicClass.jav @@ -0,0 +1 @@ +public class Test {} \ No newline at end of file diff --git a/tests/testData/ast/class/class/publicClass.kt b/tests/testData/ast/class/class/publicClass.kt new file mode 100644 index 00000000000..89eb3715737 --- /dev/null +++ b/tests/testData/ast/class/class/publicClass.kt @@ -0,0 +1,2 @@ +public open class Test() { +} \ No newline at end of file diff --git a/tests/testData/ast/class/class/simpleInheritance.jav b/tests/testData/ast/class/class/simpleInheritance.jav new file mode 100644 index 00000000000..01916ab4d7b --- /dev/null +++ b/tests/testData/ast/class/class/simpleInheritance.jav @@ -0,0 +1 @@ +final class A extends Base {} \ No newline at end of file diff --git a/tests/testData/ast/class/class/simpleInheritance.kt b/tests/testData/ast/class/class/simpleInheritance.kt new file mode 100644 index 00000000000..7d43469a9e0 --- /dev/null +++ b/tests/testData/ast/class/class/simpleInheritance.kt @@ -0,0 +1,2 @@ +class A() : Base() { +} \ No newline at end of file diff --git a/tests/testData/ast/class/class/twoStaticMethod.jav b/tests/testData/ast/class/class/twoStaticMethod.jav new file mode 100644 index 00000000000..b69b1398e17 --- /dev/null +++ b/tests/testData/ast/class/class/twoStaticMethod.jav @@ -0,0 +1 @@ +final class S { static boolean sB() { return true; } static int sI() { return 1; } } \ No newline at end of file diff --git a/tests/testData/ast/class/class/twoStaticMethod.kt b/tests/testData/ast/class/class/twoStaticMethod.kt new file mode 100644 index 00000000000..58f12c41e16 --- /dev/null +++ b/tests/testData/ast/class/class/twoStaticMethod.kt @@ -0,0 +1,10 @@ +class S() { +class object { +fun sB() : Boolean { +return true +} +fun sI() : Int { +return 1 +} +} +} \ No newline at end of file diff --git a/tests/testData/ast/class/file/kt-639.jav b/tests/testData/ast/class/file/kt-639.jav new file mode 100644 index 00000000000..102ae0c907b --- /dev/null +++ b/tests/testData/ast/class/file/kt-639.jav @@ -0,0 +1,18 @@ +package demo; + +import java.util.HashMap; + +class Test { + Test() { } + Test(String s) { } +} + +class User { + void main() { + HashMap m = new HashMap(1); + HashMap m2 = new HashMap(10); + + Test t1 = new Test(); + Test t2 = new Test(""); + } +} \ No newline at end of file diff --git a/tests/testData/ast/class/file/kt-639.kt b/tests/testData/ast/class/file/kt-639.kt new file mode 100644 index 00000000000..ab80d9cfefd --- /dev/null +++ b/tests/testData/ast/class/file/kt-639.kt @@ -0,0 +1,22 @@ +package demo +import java.util.HashMap +open class Test() { +class object { +open fun init() : Test { +val __ = Test() +return __ +} +open fun init(s : String?) : Test { +val __ = Test() +return __ +} +} +} +open class User() { +open fun main() : Unit { +var m : HashMap? = HashMap(1) +var m2 : HashMap? = HashMap(10) +var t1 : Test? = Test.init() +var t2 : Test? = Test.init("") +} +} \ No newline at end of file diff --git a/tests/testData/ast/class/file/privateInit.jav b/tests/testData/ast/class/file/privateInit.jav new file mode 100644 index 00000000000..5a65a0cc32b --- /dev/null +++ b/tests/testData/ast/class/file/privateInit.jav @@ -0,0 +1,4 @@ +public class MyClass { + private void init(int arg1, int arg2, int arg3) { + } +} \ No newline at end of file diff --git a/tests/testData/ast/class/file/privateInit.kt b/tests/testData/ast/class/file/privateInit.kt new file mode 100644 index 00000000000..2107adcf8d7 --- /dev/null +++ b/tests/testData/ast/class/file/privateInit.kt @@ -0,0 +1,4 @@ +public open class MyClass() { +private open fun init(arg1 : Int, arg2 : Int, arg3 : Int) : Unit { +} +} \ No newline at end of file diff --git a/tests/testData/ast/classExpression/expression/objectClass.jav b/tests/testData/ast/classExpression/expression/objectClass.jav new file mode 100644 index 00000000000..b5c1a920fca --- /dev/null +++ b/tests/testData/ast/classExpression/expression/objectClass.jav @@ -0,0 +1 @@ +Object.class \ No newline at end of file diff --git a/tests/testData/ast/classExpression/expression/objectClass.kt b/tests/testData/ast/classExpression/expression/objectClass.kt new file mode 100644 index 00000000000..4674988b0c1 --- /dev/null +++ b/tests/testData/ast/classExpression/expression/objectClass.kt @@ -0,0 +1 @@ +getJavaClass \ No newline at end of file diff --git a/tests/testData/ast/classExpression/expression/stringClass.jav b/tests/testData/ast/classExpression/expression/stringClass.jav new file mode 100644 index 00000000000..025387a83e8 --- /dev/null +++ b/tests/testData/ast/classExpression/expression/stringClass.jav @@ -0,0 +1 @@ +String.class \ No newline at end of file diff --git a/tests/testData/ast/classExpression/expression/stringClass.kt b/tests/testData/ast/classExpression/expression/stringClass.kt new file mode 100644 index 00000000000..894282ca52d --- /dev/null +++ b/tests/testData/ast/classExpression/expression/stringClass.kt @@ -0,0 +1 @@ +getJavaClass \ No newline at end of file diff --git a/tests/testData/ast/classExpression/statement/complexExample.jav b/tests/testData/ast/classExpression/statement/complexExample.jav new file mode 100644 index 00000000000..a74d8698493 --- /dev/null +++ b/tests/testData/ast/classExpression/statement/complexExample.jav @@ -0,0 +1 @@ +Class[] constrArgTypes = new Class[]{String[].class, String.class}; \ No newline at end of file diff --git a/tests/testData/ast/classExpression/statement/complexExample.kt b/tests/testData/ast/classExpression/statement/complexExample.kt new file mode 100644 index 00000000000..d05f082bcc6 --- /dev/null +++ b/tests/testData/ast/classExpression/statement/complexExample.kt @@ -0,0 +1 @@ +var constrArgTypes : Array?>? = array?>(getJavaClass?>, getJavaClass) \ No newline at end of file diff --git a/tests/testData/ast/conditionalExpression/expression/simpleConditionalExpression.jav b/tests/testData/ast/conditionalExpression/expression/simpleConditionalExpression.jav new file mode 100644 index 00000000000..3e742448544 --- /dev/null +++ b/tests/testData/ast/conditionalExpression/expression/simpleConditionalExpression.jav @@ -0,0 +1 @@ +a.isEmpty() ? 0 : 1 \ No newline at end of file diff --git a/tests/testData/ast/conditionalExpression/expression/simpleConditionalExpression.kt b/tests/testData/ast/conditionalExpression/expression/simpleConditionalExpression.kt new file mode 100644 index 00000000000..a29106ae10b --- /dev/null +++ b/tests/testData/ast/conditionalExpression/expression/simpleConditionalExpression.kt @@ -0,0 +1,4 @@ +(if (a.isEmpty()) +0 +else +1) \ No newline at end of file diff --git a/tests/testData/ast/constructors/file/allCallsPrimary.jav b/tests/testData/ast/constructors/file/allCallsPrimary.jav new file mode 100644 index 00000000000..997b50c969c --- /dev/null +++ b/tests/testData/ast/constructors/file/allCallsPrimary.jav @@ -0,0 +1,20 @@ +class C { + C(int arg1, int arg2, int arg3) { + } + + C(int arg1, int arg2) { + this(arg1, arg2, 0); + } + + C(int arg1) { + this(arg1, 0, 0); + } +} + +public class User { + public static void main() { + C c1 = new C(100, 100, 100); + C c2 = new C(100, 100); + C c3 = new C(100); + } +} \ No newline at end of file diff --git a/tests/testData/ast/constructors/file/allCallsPrimary.kt b/tests/testData/ast/constructors/file/allCallsPrimary.kt new file mode 100644 index 00000000000..4f4c919d74e --- /dev/null +++ b/tests/testData/ast/constructors/file/allCallsPrimary.kt @@ -0,0 +1,21 @@ +open class C(arg1 : Int, arg2 : Int, arg3 : Int) { +class object { +open fun init(arg1 : Int, arg2 : Int) : C { +val __ = C(arg1, arg2, 0) +return __ +} +open fun init(arg1 : Int) : C { +val __ = C(arg1, 0, 0) +return __ +} +} +} +public open class User() { +class object { +public open fun main() : Unit { +var c1 : C? = C(100, 100, 100) +var c2 : C? = C.init(100, 100) +var c3 : C? = C.init(100) +} +} +} \ No newline at end of file diff --git a/tests/testData/ast/constructors/file/allCallsPrimary2.jav b/tests/testData/ast/constructors/file/allCallsPrimary2.jav new file mode 100644 index 00000000000..45b045051bc --- /dev/null +++ b/tests/testData/ast/constructors/file/allCallsPrimary2.jav @@ -0,0 +1,31 @@ +class C { + final int myArg1; + int myArg2; + int myArg3; + + C(int arg1, int arg2, int arg3) { + this(arg1); + myArg2 = arg2; + myArg3 = arg3; + } + + C(int arg1, int arg2) { + this(arg1); + myArg2 = arg2; + myArg3 = 0; + } + + C(int arg1) { + myArg1 = arg1; + myArg2 = 0; + myArg3 = 0; + } +} + +public class User { + public static void main() { + C c1 = new C(100, 100, 100); + C c2 = new C(100, 100); + C c3 = new C(100); + } +} \ No newline at end of file diff --git a/tests/testData/ast/constructors/file/allCallsPrimary2.kt b/tests/testData/ast/constructors/file/allCallsPrimary2.kt new file mode 100644 index 00000000000..187238d0ca0 --- /dev/null +++ b/tests/testData/ast/constructors/file/allCallsPrimary2.kt @@ -0,0 +1,33 @@ +open class C(arg1 : Int) { +val myArg1 : Int +var myArg2 : Int = 0 +var myArg3 : Int = 0 +{ +myArg1 = arg1 +myArg2 = 0 +myArg3 = 0 +} +class object { +open fun init(arg1 : Int, arg2 : Int, arg3 : Int) : C { +val __ = C(arg1) +__.myArg2 = arg2 +__.myArg3 = arg3 +return __ +} +open fun init(arg1 : Int, arg2 : Int) : C { +val __ = C(arg1) +__.myArg2 = arg2 +__.myArg3 = 0 +return __ +} +} +} +public open class User() { +class object { +public open fun main() : Unit { +var c1 : C? = C.init(100, 100, 100) +var c2 : C? = C.init(100, 100) +var c3 : C? = C(100) +} +} +} \ No newline at end of file diff --git a/tests/testData/ast/constructors/file/customerBuilder.jav b/tests/testData/ast/constructors/file/customerBuilder.jav new file mode 100644 index 00000000000..4f99ad3c63d --- /dev/null +++ b/tests/testData/ast/constructors/file/customerBuilder.jav @@ -0,0 +1,54 @@ +package org.test.customer + +class Customer { + public final String _firstName; + public final String _lastName; + + Customer(String first, String last) { + doSmthBefore(); + _firstName = first; + _lastName = last; + doSmthAfter(); + } + + public String getFirstName() { + return _firstName; + } + + public String getLastName() { + return _lastName; + } + + private void doSmthBefore() {} + private void doSmthAfter() {} +} + +class CustomerBuilder { + public String _firstName = "Homer"; + public String _lastName = "Simpson"; + + public CustomerBuilder WithFirstName(String firstName) { + _firstName = firstName; + return this; + } + + public CustomerBuilder WithLastName(String lastName) { + _lastName = lastName; + return this; + } + + public Customer Build() { + return new Customer(_firstName, _lastName); + } +} + +public class User { + public static void main(Array[String] args) { + Customer customer = new CustomerBuilder() + .WithFirstName("Homer") + .WithLastName("Simpson") + .Build(); + System.out.println(customer.getFirstName()); + System.out.println(customer.getLastName()); + } +} \ No newline at end of file diff --git a/tests/testData/ast/constructors/file/customerBuilder.kt b/tests/testData/ast/constructors/file/customerBuilder.kt new file mode 100644 index 00000000000..5c196ab65ee --- /dev/null +++ b/tests/testData/ast/constructors/file/customerBuilder.kt @@ -0,0 +1,45 @@ +package org.test.customer +open class Customer(first : String?, last : String?) { +public val _firstName : String? +public val _lastName : String? +public open fun getFirstName() : String? { +return _firstName +} +public open fun getLastName() : String? { +return _lastName +} +private open fun doSmthBefore() : Unit { +} +private open fun doSmthAfter() : Unit { +} +{ +doSmthBefore() +_firstName = first +_lastName = last +doSmthAfter() +} +} +open class CustomerBuilder() { +public var _firstName : String? = "Homer" +public var _lastName : String? = "Simpson" +public open fun WithFirstName(firstName : String?) : CustomerBuilder? { +_firstName = firstName +return this +} +public open fun WithLastName(lastName : String?) : CustomerBuilder? { +_lastName = lastName +return this +} +public open fun Build() : Customer? { +return Customer(_firstName, _lastName) +} +} +public open class User() { +class object { +public open fun main() : Unit { +var customer : Customer? = CustomerBuilder().WithFirstName("Homer")?.WithLastName("Simpson")?.Build() +System.out?.println(customer?.getFirstName()) +System.out?.println(customer?.getLastName()) +} +} +} \ No newline at end of file diff --git a/tests/testData/ast/constructors/file/genericIdentifier.jav b/tests/testData/ast/constructors/file/genericIdentifier.jav new file mode 100644 index 00000000000..c77f997a1c6 --- /dev/null +++ b/tests/testData/ast/constructors/file/genericIdentifier.jav @@ -0,0 +1,33 @@ +public class Identifier { + private final T myName; + private boolean myHasDollar; + private boolean myNullable = true; + + public Identifier(T name) { + myName = name; + } + + public Identifier(T name, boolean isNullable) { + myName = name; + myNullable = isNullable; + } + + public Identifier(T name, boolean hasDollar, boolean isNullable) { + myName = name; + myHasDollar = hasDollar; + myNullable = isNullable; + } + + @Override + public T getName() { + return myName; + } +} + +public class User { + public static void main() { + Identifier i1 = new Identifier("name", false, true); + Identifier i2 = new Identifier("name", false); + Identifier i3 = new Identifier("name"); + } +} \ No newline at end of file diff --git a/tests/testData/ast/constructors/file/genericIdentifier.kt b/tests/testData/ast/constructors/file/genericIdentifier.kt new file mode 100644 index 00000000000..9b26b23022d --- /dev/null +++ b/tests/testData/ast/constructors/file/genericIdentifier.kt @@ -0,0 +1,37 @@ +public open class Identifier(_myName : T?, _myHasDollar : Boolean) { +private val myName : T? = null +private var myHasDollar : Boolean = false +private var myNullable : Boolean = true +public open fun getName() : T? { +return myName +} +{ +myName = _myName +myHasDollar = _myHasDollar +} +class object { +public open fun init(name : T?) : Identifier { +val __ = Identifier(name, false) +return __ +} +public open fun init(name : T?, isNullable : Boolean) : Identifier { +val __ = Identifier(name, false) +__.myNullable = isNullable +return __ +} +public open fun init(name : T?, hasDollar : Boolean, isNullable : Boolean) : Identifier { +val __ = Identifier(name, hasDollar) +__.myNullable = isNullable +return __ +} +} +} +public open class User() { +class object { +public open fun main() : Unit { +var i1 : Identifier<*>? = Identifier.init("name", false, true) +var i2 : Identifier? = Identifier.init("name", false) +var i3 : Identifier? = Identifier.init("name") +} +} +} \ No newline at end of file diff --git a/tests/testData/ast/constructors/file/identifier.jav b/tests/testData/ast/constructors/file/identifier.jav new file mode 100644 index 00000000000..929628643c8 --- /dev/null +++ b/tests/testData/ast/constructors/file/identifier.jav @@ -0,0 +1,33 @@ +public class Identifier { + private final String myName; + private boolean myHasDollar; + private boolean myNullable = true; + + public Identifier(String name) { + myName = name; + } + + public Identifier(String name, boolean isNullable) { + myName = name; + myNullable = isNullable; + } + + public Identifier(String name, boolean hasDollar, boolean isNullable) { + myName = name; + myHasDollar = hasDollar; + myNullable = isNullable; + } + + @Override + public String getName() { + return myName; + } +} + +public class User { + public static void main() { + Identifier i1 = new Identifier("name", false, true); + Identifier i2 = new Identifier("name", false); + Identifier i3 = new Identifier("name"); + } +} \ No newline at end of file diff --git a/tests/testData/ast/constructors/file/identifier.kt b/tests/testData/ast/constructors/file/identifier.kt new file mode 100644 index 00000000000..906e1bc0acd --- /dev/null +++ b/tests/testData/ast/constructors/file/identifier.kt @@ -0,0 +1,37 @@ +public open class Identifier(_myName : String?, _myHasDollar : Boolean) { +private val myName : String? = null +private var myHasDollar : Boolean = false +private var myNullable : Boolean = true +public open fun getName() : String? { +return myName +} +{ +myName = _myName +myHasDollar = _myHasDollar +} +class object { +public open fun init(name : String?) : Identifier { +val __ = Identifier(name, false) +return __ +} +public open fun init(name : String?, isNullable : Boolean) : Identifier { +val __ = Identifier(name, false) +__.myNullable = isNullable +return __ +} +public open fun init(name : String?, hasDollar : Boolean, isNullable : Boolean) : Identifier { +val __ = Identifier(name, hasDollar) +__.myNullable = isNullable +return __ +} +} +} +public open class User() { +class object { +public open fun main() : Unit { +var i1 : Identifier? = Identifier.init("name", false, true) +var i2 : Identifier? = Identifier.init("name", false) +var i3 : Identifier? = Identifier.init("name") +} +} +} \ No newline at end of file diff --git a/tests/testData/ast/constructors/file/withManyDefaultParams.jav b/tests/testData/ast/constructors/file/withManyDefaultParams.jav new file mode 100644 index 00000000000..c8d04543b0b --- /dev/null +++ b/tests/testData/ast/constructors/file/withManyDefaultParams.jav @@ -0,0 +1,24 @@ +public class Test { + private final String myName; + private boolean a; + private double b; + private float c; + private long d; + private int e; + private short f; + private char g; + + public Test() {} + + public Test(String name) { + myName = foo(name); + } + + static String foo(String n) {return "";} +} + +public class User { + public static void main() { + Test t = new Test("name"); + } +} \ No newline at end of file diff --git a/tests/testData/ast/constructors/file/withManyDefaultParams.kt b/tests/testData/ast/constructors/file/withManyDefaultParams.kt new file mode 100644 index 00000000000..ca261d80a42 --- /dev/null +++ b/tests/testData/ast/constructors/file/withManyDefaultParams.kt @@ -0,0 +1,40 @@ +public open class Test(_myName : String?, _a : Boolean, _b : Double, _c : Float, _d : Long, _e : Int, _f : Short, _g : Char) { +private val myName : String? +private var a : Boolean = false +private var b : Double = 0.toDouble() +private var c : Float = 0.toFloat() +private var d : Long = 0 +private var e : Int = 0 +private var f : Short = 0 +private var g : Char = ' ' +{ +myName = _myName +a = _a +b = _b +c = _c +d = _d +e = _e +f = _f +g = _g +} +class object { +public open fun init() : Test { +val __ = Test(null, false, 0.toDouble(), 0.toFloat(), 0, 0, 0, ' ') +return __ +} +public open fun init(name : String?) : Test { +val __ = Test(foo(name), false, 0.toDouble(), 0.toFloat(), 0, 0, 0, ' ') +return __ +} +open fun foo(n : String?) : String? { +return "" +} +} +} +public open class User() { +class object { +public open fun main() : Unit { +var t : Test? = Test.init("name") +} +} +} \ No newline at end of file diff --git a/tests/testData/ast/continueStatement/statement/continueWithLabel.jav b/tests/testData/ast/continueStatement/statement/continueWithLabel.jav new file mode 100644 index 00000000000..aa7bbb7cd89 --- /dev/null +++ b/tests/testData/ast/continueStatement/statement/continueWithLabel.jav @@ -0,0 +1 @@ +continue label; \ No newline at end of file diff --git a/tests/testData/ast/continueStatement/statement/continueWithLabel.kt b/tests/testData/ast/continueStatement/statement/continueWithLabel.kt new file mode 100644 index 00000000000..9dc6020680e --- /dev/null +++ b/tests/testData/ast/continueStatement/statement/continueWithLabel.kt @@ -0,0 +1 @@ +continue@label \ No newline at end of file diff --git a/tests/testData/ast/continueStatement/statement/continueWithoutLabel.jav b/tests/testData/ast/continueStatement/statement/continueWithoutLabel.jav new file mode 100644 index 00000000000..45127c0ad12 --- /dev/null +++ b/tests/testData/ast/continueStatement/statement/continueWithoutLabel.jav @@ -0,0 +1 @@ +continue; \ No newline at end of file diff --git a/tests/testData/ast/continueStatement/statement/continueWithoutLabel.kt b/tests/testData/ast/continueStatement/statement/continueWithoutLabel.kt new file mode 100644 index 00000000000..b2960313c53 --- /dev/null +++ b/tests/testData/ast/continueStatement/statement/continueWithoutLabel.kt @@ -0,0 +1 @@ +continue \ No newline at end of file diff --git a/tests/testData/ast/declarationStatement/statement/multiplyFinalIntDeclaration.jav b/tests/testData/ast/declarationStatement/statement/multiplyFinalIntDeclaration.jav new file mode 100644 index 00000000000..42d4cea5522 --- /dev/null +++ b/tests/testData/ast/declarationStatement/statement/multiplyFinalIntDeclaration.jav @@ -0,0 +1 @@ +final int k, l, m; \ No newline at end of file diff --git a/tests/testData/ast/declarationStatement/statement/multiplyFinalIntDeclaration.kt b/tests/testData/ast/declarationStatement/statement/multiplyFinalIntDeclaration.kt new file mode 100644 index 00000000000..31534f1744c --- /dev/null +++ b/tests/testData/ast/declarationStatement/statement/multiplyFinalIntDeclaration.kt @@ -0,0 +1,3 @@ +val k : Int +val l : Int +val m : Int \ No newline at end of file diff --git a/tests/testData/ast/declarationStatement/statement/multiplyIntDeclaration.jav b/tests/testData/ast/declarationStatement/statement/multiplyIntDeclaration.jav new file mode 100644 index 00000000000..219f057f8f0 --- /dev/null +++ b/tests/testData/ast/declarationStatement/statement/multiplyIntDeclaration.jav @@ -0,0 +1 @@ +int k, l, m; \ No newline at end of file diff --git a/tests/testData/ast/declarationStatement/statement/multiplyIntDeclaration.kt b/tests/testData/ast/declarationStatement/statement/multiplyIntDeclaration.kt new file mode 100644 index 00000000000..573f5bf7bb1 --- /dev/null +++ b/tests/testData/ast/declarationStatement/statement/multiplyIntDeclaration.kt @@ -0,0 +1,3 @@ +var k : Int +var l : Int +var m : Int \ No newline at end of file diff --git a/tests/testData/ast/declarationStatement/statement/singleFinalIntDeclaration.jav b/tests/testData/ast/declarationStatement/statement/singleFinalIntDeclaration.jav new file mode 100644 index 00000000000..79db42cfc1c --- /dev/null +++ b/tests/testData/ast/declarationStatement/statement/singleFinalIntDeclaration.jav @@ -0,0 +1 @@ +final int s; \ No newline at end of file diff --git a/tests/testData/ast/declarationStatement/statement/singleFinalIntDeclaration.kt b/tests/testData/ast/declarationStatement/statement/singleFinalIntDeclaration.kt new file mode 100644 index 00000000000..0ff0482bb0f --- /dev/null +++ b/tests/testData/ast/declarationStatement/statement/singleFinalIntDeclaration.kt @@ -0,0 +1 @@ +val s : Int \ No newline at end of file diff --git a/tests/testData/ast/declarationStatement/statement/singleFinalStringDeclaration.jav b/tests/testData/ast/declarationStatement/statement/singleFinalStringDeclaration.jav new file mode 100644 index 00000000000..0d5e93f00ff --- /dev/null +++ b/tests/testData/ast/declarationStatement/statement/singleFinalStringDeclaration.jav @@ -0,0 +1 @@ +final String s; \ No newline at end of file diff --git a/tests/testData/ast/declarationStatement/statement/singleFinalStringDeclaration.kt b/tests/testData/ast/declarationStatement/statement/singleFinalStringDeclaration.kt new file mode 100644 index 00000000000..734800a644c --- /dev/null +++ b/tests/testData/ast/declarationStatement/statement/singleFinalStringDeclaration.kt @@ -0,0 +1 @@ +val s : String? \ No newline at end of file diff --git a/tests/testData/ast/declarationStatement/statement/singleIntDeclaration.jav b/tests/testData/ast/declarationStatement/statement/singleIntDeclaration.jav new file mode 100644 index 00000000000..ee7cd0becae --- /dev/null +++ b/tests/testData/ast/declarationStatement/statement/singleIntDeclaration.jav @@ -0,0 +1 @@ +int s; \ No newline at end of file diff --git a/tests/testData/ast/declarationStatement/statement/singleIntDeclaration.kt b/tests/testData/ast/declarationStatement/statement/singleIntDeclaration.kt new file mode 100644 index 00000000000..3639cd90f4a --- /dev/null +++ b/tests/testData/ast/declarationStatement/statement/singleIntDeclaration.kt @@ -0,0 +1 @@ +var s : Int \ No newline at end of file diff --git a/tests/testData/ast/declarationStatement/statement/singleStringDeclaration.jav b/tests/testData/ast/declarationStatement/statement/singleStringDeclaration.jav new file mode 100644 index 00000000000..8f1adbb52a5 --- /dev/null +++ b/tests/testData/ast/declarationStatement/statement/singleStringDeclaration.jav @@ -0,0 +1 @@ +String s; \ No newline at end of file diff --git a/tests/testData/ast/declarationStatement/statement/singleStringDeclaration.kt b/tests/testData/ast/declarationStatement/statement/singleStringDeclaration.kt new file mode 100644 index 00000000000..4bdd5d14ca2 --- /dev/null +++ b/tests/testData/ast/declarationStatement/statement/singleStringDeclaration.kt @@ -0,0 +1 @@ +var s : String? \ No newline at end of file diff --git a/tests/testData/ast/doWhileStatement/statement/whileWithBlock.jav b/tests/testData/ast/doWhileStatement/statement/whileWithBlock.jav new file mode 100644 index 00000000000..48a9639a646 --- /dev/null +++ b/tests/testData/ast/doWhileStatement/statement/whileWithBlock.jav @@ -0,0 +1 @@ +do {int i = 1; i = i + 1;} while (a > b) \ No newline at end of file diff --git a/tests/testData/ast/doWhileStatement/statement/whileWithBlock.kt b/tests/testData/ast/doWhileStatement/statement/whileWithBlock.kt new file mode 100644 index 00000000000..56e9500dc79 --- /dev/null +++ b/tests/testData/ast/doWhileStatement/statement/whileWithBlock.kt @@ -0,0 +1,6 @@ +do +{ +var i : Int = 1 +i = i + 1 +} +while (a > b) \ No newline at end of file diff --git a/tests/testData/ast/doWhileStatement/statement/whileWithEmptyBlock.jav b/tests/testData/ast/doWhileStatement/statement/whileWithEmptyBlock.jav new file mode 100644 index 00000000000..b57bb051009 --- /dev/null +++ b/tests/testData/ast/doWhileStatement/statement/whileWithEmptyBlock.jav @@ -0,0 +1 @@ +do {} while (true) \ No newline at end of file diff --git a/tests/testData/ast/doWhileStatement/statement/whileWithEmptyBlock.kt b/tests/testData/ast/doWhileStatement/statement/whileWithEmptyBlock.kt new file mode 100644 index 00000000000..ab26ce3b053 --- /dev/null +++ b/tests/testData/ast/doWhileStatement/statement/whileWithEmptyBlock.kt @@ -0,0 +1,4 @@ +do +{ +} +while (true) \ No newline at end of file diff --git a/tests/testData/ast/doWhileStatement/statement/whileWithExpression.jav b/tests/testData/ast/doWhileStatement/statement/whileWithExpression.jav new file mode 100644 index 00000000000..e724468b028 --- /dev/null +++ b/tests/testData/ast/doWhileStatement/statement/whileWithExpression.jav @@ -0,0 +1 @@ +do i = i + 1; while (true) \ No newline at end of file diff --git a/tests/testData/ast/doWhileStatement/statement/whileWithExpression.kt b/tests/testData/ast/doWhileStatement/statement/whileWithExpression.kt new file mode 100644 index 00000000000..9ca3d8863a0 --- /dev/null +++ b/tests/testData/ast/doWhileStatement/statement/whileWithExpression.kt @@ -0,0 +1,3 @@ +do +i = i + 1 +while (true) \ No newline at end of file diff --git a/tests/testData/ast/doWhileStatement/statement/whileWithReturn.jav b/tests/testData/ast/doWhileStatement/statement/whileWithReturn.jav new file mode 100644 index 00000000000..6ca0c6cd1b2 --- /dev/null +++ b/tests/testData/ast/doWhileStatement/statement/whileWithReturn.jav @@ -0,0 +1 @@ +do return 1; while (true) \ No newline at end of file diff --git a/tests/testData/ast/doWhileStatement/statement/whileWithReturn.kt b/tests/testData/ast/doWhileStatement/statement/whileWithReturn.kt new file mode 100644 index 00000000000..89f8a80610c --- /dev/null +++ b/tests/testData/ast/doWhileStatement/statement/whileWithReturn.kt @@ -0,0 +1,3 @@ +do +return 1 +while (true) \ No newline at end of file diff --git a/tests/testData/ast/enum/class/colorEnum.jav b/tests/testData/ast/enum/class/colorEnum.jav new file mode 100644 index 00000000000..d59c8198ccd --- /dev/null +++ b/tests/testData/ast/enum/class/colorEnum.jav @@ -0,0 +1,16 @@ +package demo; + +enum MyEnum { + RED(10), + BLUE(20); + + private final int color; + + private MyEnum(int _color) { + color = _color; + } + + public int getColor() { + return color; + } +} \ No newline at end of file diff --git a/tests/testData/ast/enum/class/colorEnum.kt b/tests/testData/ast/enum/class/colorEnum.kt new file mode 100644 index 00000000000..d346ce8c70d --- /dev/null +++ b/tests/testData/ast/enum/class/colorEnum.kt @@ -0,0 +1,14 @@ +package demo +enum class MyEnum(_color : Int) { +RED : MyEnum(10) +BLUE : MyEnum(20) +private val color : Int +public fun getColor() : Int { +return color +} +{ +color = _color +} +public fun name() : String { return "" } +public fun order() : Int { return 0 } +} \ No newline at end of file diff --git a/tests/testData/ast/enum/class/emptyEnum.jav b/tests/testData/ast/enum/class/emptyEnum.jav new file mode 100644 index 00000000000..6374d13e5e5 --- /dev/null +++ b/tests/testData/ast/enum/class/emptyEnum.jav @@ -0,0 +1 @@ +enum A {} \ No newline at end of file diff --git a/tests/testData/ast/enum/class/emptyEnum.kt b/tests/testData/ast/enum/class/emptyEnum.kt new file mode 100644 index 00000000000..99bbbb0917f --- /dev/null +++ b/tests/testData/ast/enum/class/emptyEnum.kt @@ -0,0 +1,4 @@ +enum class A { +public fun name() : String { return "" } +public fun order() : Int { return 0 } +} \ No newline at end of file diff --git a/tests/testData/ast/enum/class/enumImplementsOneInterface.jav b/tests/testData/ast/enum/class/enumImplementsOneInterface.jav new file mode 100644 index 00000000000..c2e20825bfe --- /dev/null +++ b/tests/testData/ast/enum/class/enumImplementsOneInterface.jav @@ -0,0 +1 @@ +enum A implements I {} \ No newline at end of file diff --git a/tests/testData/ast/enum/class/enumImplementsOneInterface.kt b/tests/testData/ast/enum/class/enumImplementsOneInterface.kt new file mode 100644 index 00000000000..89b0d80fcd1 --- /dev/null +++ b/tests/testData/ast/enum/class/enumImplementsOneInterface.kt @@ -0,0 +1,4 @@ +enum class A : I { +public fun name() : String { return "" } +public fun order() : Int { return 0 } +} \ No newline at end of file diff --git a/tests/testData/ast/enum/class/enumImplementsSeveralInterfaces.jav b/tests/testData/ast/enum/class/enumImplementsSeveralInterfaces.jav new file mode 100644 index 00000000000..0334953a275 --- /dev/null +++ b/tests/testData/ast/enum/class/enumImplementsSeveralInterfaces.jav @@ -0,0 +1 @@ +enum A implements I0, I1, I2 {} \ No newline at end of file diff --git a/tests/testData/ast/enum/class/enumImplementsSeveralInterfaces.kt b/tests/testData/ast/enum/class/enumImplementsSeveralInterfaces.kt new file mode 100644 index 00000000000..c0d3ac08963 --- /dev/null +++ b/tests/testData/ast/enum/class/enumImplementsSeveralInterfaces.kt @@ -0,0 +1,4 @@ +enum class A : I0, I1, I2 { +public fun name() : String { return "" } +public fun order() : Int { return 0 } +} \ No newline at end of file diff --git a/tests/testData/ast/enum/class/enumWithNameField.jav b/tests/testData/ast/enum/class/enumWithNameField.jav new file mode 100644 index 00000000000..30f259ecb0f --- /dev/null +++ b/tests/testData/ast/enum/class/enumWithNameField.jav @@ -0,0 +1 @@ +enum E { I; private String name; } \ No newline at end of file diff --git a/tests/testData/ast/enum/class/enumWithNameField.kt b/tests/testData/ast/enum/class/enumWithNameField.kt new file mode 100644 index 00000000000..b817dbec220 --- /dev/null +++ b/tests/testData/ast/enum/class/enumWithNameField.kt @@ -0,0 +1,6 @@ +enum class E { +I +private var name : String? = null +public fun name() : String { return "" } +public fun order() : Int { return 0 } +} \ No newline at end of file diff --git a/tests/testData/ast/enum/class/fieldsWithPrimaryPrivateConstructor.jav b/tests/testData/ast/enum/class/fieldsWithPrimaryPrivateConstructor.jav new file mode 100644 index 00000000000..210e6919883 --- /dev/null +++ b/tests/testData/ast/enum/class/fieldsWithPrimaryPrivateConstructor.jav @@ -0,0 +1,12 @@ +enum Color { + WHITE(21), BLACK(22), RED(23), YELLOW(24), BLUE(25); + + private int code; + + private Color(int c) { + code = c; + } + + public int getCode() { + return code; + } \ No newline at end of file diff --git a/tests/testData/ast/enum/class/fieldsWithPrimaryPrivateConstructor.kt b/tests/testData/ast/enum/class/fieldsWithPrimaryPrivateConstructor.kt new file mode 100644 index 00000000000..d7474d3ff80 --- /dev/null +++ b/tests/testData/ast/enum/class/fieldsWithPrimaryPrivateConstructor.kt @@ -0,0 +1,16 @@ +enum class Color(c : Int) { +WHITE : Color(21) +BLACK : Color(22) +RED : Color(23) +YELLOW : Color(24) +BLUE : Color(25) +private var code : Int = 0 +public fun getCode() : Int { +return code +} +{ +code = c +} +public fun name() : String { return "" } +public fun order() : Int { return 0 } +} \ No newline at end of file diff --git a/tests/testData/ast/enum/class/internalEnum.jav b/tests/testData/ast/enum/class/internalEnum.jav new file mode 100644 index 00000000000..5ac159fa355 --- /dev/null +++ b/tests/testData/ast/enum/class/internalEnum.jav @@ -0,0 +1 @@ +enum Test {} \ No newline at end of file diff --git a/tests/testData/ast/enum/class/internalEnum.kt b/tests/testData/ast/enum/class/internalEnum.kt new file mode 100644 index 00000000000..d1aa8f75084 --- /dev/null +++ b/tests/testData/ast/enum/class/internalEnum.kt @@ -0,0 +1,4 @@ +enum class Test { +public fun name() : String { return "" } +public fun order() : Int { return 0 } +} \ No newline at end of file diff --git a/tests/testData/ast/enum/class/overrideToString.jav b/tests/testData/ast/enum/class/overrideToString.jav new file mode 100644 index 00000000000..e2aae14da6c --- /dev/null +++ b/tests/testData/ast/enum/class/overrideToString.jav @@ -0,0 +1 @@ +enum Color { WHITE, BLACK, RED, YELLOW, BLUE;@Override String toString() { return "COLOR";}} \ No newline at end of file diff --git a/tests/testData/ast/enum/class/overrideToString.kt b/tests/testData/ast/enum/class/overrideToString.kt new file mode 100644 index 00000000000..59c036f47f4 --- /dev/null +++ b/tests/testData/ast/enum/class/overrideToString.kt @@ -0,0 +1,12 @@ +enum class Color { +WHITE +BLACK +RED +YELLOW +BLUE +override fun toString() : String? { +return "COLOR" +} +public fun name() : String { return "" } +public fun order() : Int { return 0 } +} \ No newline at end of file diff --git a/tests/testData/ast/enum/class/primaryPrivateConstructor.jav b/tests/testData/ast/enum/class/primaryPrivateConstructor.jav new file mode 100644 index 00000000000..7dad6bb265e --- /dev/null +++ b/tests/testData/ast/enum/class/primaryPrivateConstructor.jav @@ -0,0 +1,12 @@ +package demo; + +enum Color { + private int code; + + private Color(int c) { + code = c; + } + + public int getCode() { + return code; + } \ No newline at end of file diff --git a/tests/testData/ast/enum/class/primaryPrivateConstructor.kt b/tests/testData/ast/enum/class/primaryPrivateConstructor.kt new file mode 100644 index 00000000000..9842b0d00b4 --- /dev/null +++ b/tests/testData/ast/enum/class/primaryPrivateConstructor.kt @@ -0,0 +1,12 @@ +package demo +enum class Color(c : Int) { +private var code : Int = 0 +public fun getCode() : Int { +return code +} +{ +code = c +} +public fun name() : String { return "" } +public fun order() : Int { return 0 } +} \ No newline at end of file diff --git a/tests/testData/ast/enum/class/privateEnum.jav b/tests/testData/ast/enum/class/privateEnum.jav new file mode 100644 index 00000000000..963b14059d8 --- /dev/null +++ b/tests/testData/ast/enum/class/privateEnum.jav @@ -0,0 +1 @@ +private enum Test {} \ No newline at end of file diff --git a/tests/testData/ast/enum/class/privateEnum.kt b/tests/testData/ast/enum/class/privateEnum.kt new file mode 100644 index 00000000000..dbc90decc7b --- /dev/null +++ b/tests/testData/ast/enum/class/privateEnum.kt @@ -0,0 +1,4 @@ +private enum class Test { +public fun name() : String { return "" } +public fun order() : Int { return 0 } +} \ No newline at end of file diff --git a/tests/testData/ast/enum/class/protectedEnum.jav b/tests/testData/ast/enum/class/protectedEnum.jav new file mode 100644 index 00000000000..1361563477c --- /dev/null +++ b/tests/testData/ast/enum/class/protectedEnum.jav @@ -0,0 +1 @@ +protected enum Test {} \ No newline at end of file diff --git a/tests/testData/ast/enum/class/protectedEnum.kt b/tests/testData/ast/enum/class/protectedEnum.kt new file mode 100644 index 00000000000..e09280af16c --- /dev/null +++ b/tests/testData/ast/enum/class/protectedEnum.kt @@ -0,0 +1,4 @@ +protected enum class Test { +public fun name() : String { return "" } +public fun order() : Int { return 0 } +} \ No newline at end of file diff --git a/tests/testData/ast/enum/class/publicEnum.jav b/tests/testData/ast/enum/class/publicEnum.jav new file mode 100644 index 00000000000..23365fc3853 --- /dev/null +++ b/tests/testData/ast/enum/class/publicEnum.jav @@ -0,0 +1 @@ +public enum Test {} \ No newline at end of file diff --git a/tests/testData/ast/enum/class/publicEnum.kt b/tests/testData/ast/enum/class/publicEnum.kt new file mode 100644 index 00000000000..6a05d60c6cf --- /dev/null +++ b/tests/testData/ast/enum/class/publicEnum.kt @@ -0,0 +1,4 @@ +public enum class Test { +public fun name() : String { return "" } +public fun order() : Int { return 0 } +} \ No newline at end of file diff --git a/tests/testData/ast/enum/class/runnableImplementation.jav b/tests/testData/ast/enum/class/runnableImplementation.jav new file mode 100644 index 00000000000..5db856671ca --- /dev/null +++ b/tests/testData/ast/enum/class/runnableImplementation.jav @@ -0,0 +1,8 @@ +enum Color implements Runnable { + WHITE, BLACK, RED, YELLOW, BLUE; + + public void run() { + System.out.println("name()=" + name() + + ", toString()=" + toString()); + } +} \ No newline at end of file diff --git a/tests/testData/ast/enum/class/runnableImplementation.kt b/tests/testData/ast/enum/class/runnableImplementation.kt new file mode 100644 index 00000000000..467e73bc48a --- /dev/null +++ b/tests/testData/ast/enum/class/runnableImplementation.kt @@ -0,0 +1,12 @@ +enum class Color : Runnable { +WHITE +BLACK +RED +YELLOW +BLUE +public override fun run() : Unit { +System.out?.println("name()=" + name() + ", toString()=" + toString()) +} +public fun name() : String { return "" } +public fun order() : Int { return 0 } +} \ No newline at end of file diff --git a/tests/testData/ast/enum/class/typeSafeEnum.jav b/tests/testData/ast/enum/class/typeSafeEnum.jav new file mode 100644 index 00000000000..1ecc70526e4 --- /dev/null +++ b/tests/testData/ast/enum/class/typeSafeEnum.jav @@ -0,0 +1 @@ +enum Coin { PENNY, NICKEL, DIME, QUARTER; } \ No newline at end of file diff --git a/tests/testData/ast/enum/class/typeSafeEnum.kt b/tests/testData/ast/enum/class/typeSafeEnum.kt new file mode 100644 index 00000000000..e4728074b75 --- /dev/null +++ b/tests/testData/ast/enum/class/typeSafeEnum.kt @@ -0,0 +1,8 @@ +enum class Coin { +PENNY +NICKEL +DIME +QUARTER +public fun name() : String { return "" } +public fun order() : Int { return 0 } +} \ No newline at end of file diff --git a/tests/testData/ast/field/file/classChildExtendsBase.jav b/tests/testData/ast/field/file/classChildExtendsBase.jav new file mode 100644 index 00000000000..94d40fbfea4 --- /dev/null +++ b/tests/testData/ast/field/file/classChildExtendsBase.jav @@ -0,0 +1,7 @@ +class Base { + private String myFirst; +} + +class Child extends Base { + private String mySecond; +} \ No newline at end of file diff --git a/tests/testData/ast/field/file/classChildExtendsBase.kt b/tests/testData/ast/field/file/classChildExtendsBase.kt new file mode 100644 index 00000000000..11589309492 --- /dev/null +++ b/tests/testData/ast/field/file/classChildExtendsBase.kt @@ -0,0 +1,6 @@ +open class Base() { +private var myFirst : String? = null +} +open class Child() : Base() { +private var mySecond : String? = null +} \ No newline at end of file diff --git a/tests/testData/ast/field/file/internalField.jav b/tests/testData/ast/field/file/internalField.jav new file mode 100644 index 00000000000..3c3f6a6f633 --- /dev/null +++ b/tests/testData/ast/field/file/internalField.jav @@ -0,0 +1,3 @@ +class C { +Foo f; +} \ No newline at end of file diff --git a/tests/testData/ast/field/file/internalField.kt b/tests/testData/ast/field/file/internalField.kt new file mode 100644 index 00000000000..28fb8db799b --- /dev/null +++ b/tests/testData/ast/field/file/internalField.kt @@ -0,0 +1,3 @@ +open class C() { +var f : Foo? = null +} \ No newline at end of file diff --git a/tests/testData/ast/field/file/privateField.jav b/tests/testData/ast/field/file/privateField.jav new file mode 100644 index 00000000000..958031a23b4 --- /dev/null +++ b/tests/testData/ast/field/file/privateField.jav @@ -0,0 +1,3 @@ +class C { +private Foo f; +} diff --git a/tests/testData/ast/field/file/privateField.kt b/tests/testData/ast/field/file/privateField.kt new file mode 100644 index 00000000000..29c0b479266 --- /dev/null +++ b/tests/testData/ast/field/file/privateField.kt @@ -0,0 +1,3 @@ +open class C() { +private var f : Foo? = null +} \ No newline at end of file diff --git a/tests/testData/ast/field/file/protectedField.jav b/tests/testData/ast/field/file/protectedField.jav new file mode 100644 index 00000000000..100199e107f --- /dev/null +++ b/tests/testData/ast/field/file/protectedField.jav @@ -0,0 +1,3 @@ +class C { +protected Foo f; +} \ No newline at end of file diff --git a/tests/testData/ast/field/file/protectedField.kt b/tests/testData/ast/field/file/protectedField.kt new file mode 100644 index 00000000000..922f359b70f --- /dev/null +++ b/tests/testData/ast/field/file/protectedField.kt @@ -0,0 +1,3 @@ +open class C() { +protected var f : Foo? = null +} \ No newline at end of file diff --git a/tests/testData/ast/field/file/publicField.jav b/tests/testData/ast/field/file/publicField.jav new file mode 100644 index 00000000000..1944ff6914a --- /dev/null +++ b/tests/testData/ast/field/file/publicField.jav @@ -0,0 +1,3 @@ +class C { +public Foo f; +} \ No newline at end of file diff --git a/tests/testData/ast/field/file/publicField.kt b/tests/testData/ast/field/file/publicField.kt new file mode 100644 index 00000000000..1ccfa12a0ae --- /dev/null +++ b/tests/testData/ast/field/file/publicField.kt @@ -0,0 +1,3 @@ +open class C() { +public var f : Foo? = null +} \ No newline at end of file diff --git a/tests/testData/ast/field/file/valWithInit.jav b/tests/testData/ast/field/file/valWithInit.jav new file mode 100644 index 00000000000..4e007d357ce --- /dev/null +++ b/tests/testData/ast/field/file/valWithInit.jav @@ -0,0 +1,3 @@ +class C { +final Foo f = new Foo(1, 2); +} \ No newline at end of file diff --git a/tests/testData/ast/field/file/valWithInit.kt b/tests/testData/ast/field/file/valWithInit.kt new file mode 100644 index 00000000000..bff6b253608 --- /dev/null +++ b/tests/testData/ast/field/file/valWithInit.kt @@ -0,0 +1,3 @@ +open class C() { +val f : Foo? = Foo(1, 2) +} \ No newline at end of file diff --git a/tests/testData/ast/field/file/varWithInit.jav b/tests/testData/ast/field/file/varWithInit.jav new file mode 100644 index 00000000000..07f05b3bc3f --- /dev/null +++ b/tests/testData/ast/field/file/varWithInit.jav @@ -0,0 +1,3 @@ +class C { +Foo f = new Foo(1, 2); +} \ No newline at end of file diff --git a/tests/testData/ast/field/file/varWithInit.kt b/tests/testData/ast/field/file/varWithInit.kt new file mode 100644 index 00000000000..c30af4b2a15 --- /dev/null +++ b/tests/testData/ast/field/file/varWithInit.kt @@ -0,0 +1,3 @@ +open class C() { +var f : Foo? = Foo(1, 2) +} \ No newline at end of file diff --git a/tests/testData/ast/field/file/varWithoutInit.jav b/tests/testData/ast/field/file/varWithoutInit.jav new file mode 100644 index 00000000000..3c3f6a6f633 --- /dev/null +++ b/tests/testData/ast/field/file/varWithoutInit.jav @@ -0,0 +1,3 @@ +class C { +Foo f; +} \ No newline at end of file diff --git a/tests/testData/ast/field/file/varWithoutInit.kt b/tests/testData/ast/field/file/varWithoutInit.kt new file mode 100644 index 00000000000..28fb8db799b --- /dev/null +++ b/tests/testData/ast/field/file/varWithoutInit.kt @@ -0,0 +1,3 @@ +open class C() { +var f : Foo? = null +} \ No newline at end of file diff --git a/tests/testData/ast/file/comp/intNullability.jav b/tests/testData/ast/file/comp/intNullability.jav new file mode 100644 index 00000000000..328d9cb6ee2 --- /dev/null +++ b/tests/testData/ast/file/comp/intNullability.jav @@ -0,0 +1,9 @@ +package demo; + +class Test { + void test() { + Integer i = 10; + Integer j = 10; + System.out.println(i + j); + } +} \ No newline at end of file diff --git a/tests/testData/ast/file/comp/intNullability.kt b/tests/testData/ast/file/comp/intNullability.kt new file mode 100644 index 00000000000..4e81114caea --- /dev/null +++ b/tests/testData/ast/file/comp/intNullability.kt @@ -0,0 +1,9 @@ +package demo +import kotlin.compatibility.* +open class Test() { +open fun test() : Unit { +var i : Int? = 10 +var j : Int? = 10 +System.out?.println(i + j) +} +} \ No newline at end of file diff --git a/tests/testData/ast/file/file/packageWithClass.jav b/tests/testData/ast/file/file/packageWithClass.jav new file mode 100644 index 00000000000..3524ce7525c --- /dev/null +++ b/tests/testData/ast/file/file/packageWithClass.jav @@ -0,0 +1 @@ +package test; final class C {} \ No newline at end of file diff --git a/tests/testData/ast/file/file/packageWithClass.kt b/tests/testData/ast/file/file/packageWithClass.kt new file mode 100644 index 00000000000..c8dc0cae797 --- /dev/null +++ b/tests/testData/ast/file/file/packageWithClass.kt @@ -0,0 +1,3 @@ +package test +class C() { +} \ No newline at end of file diff --git a/tests/testData/ast/file/file/packageWithClasses.jav b/tests/testData/ast/file/file/packageWithClasses.jav new file mode 100644 index 00000000000..d0964b8ccb5 --- /dev/null +++ b/tests/testData/ast/file/file/packageWithClasses.jav @@ -0,0 +1 @@ +final class A {} final class B {} \ No newline at end of file diff --git a/tests/testData/ast/file/file/packageWithClasses.kt b/tests/testData/ast/file/file/packageWithClasses.kt new file mode 100644 index 00000000000..6e17362fd12 --- /dev/null +++ b/tests/testData/ast/file/file/packageWithClasses.kt @@ -0,0 +1,4 @@ +class A() { +} +class B() { +} \ No newline at end of file diff --git a/tests/testData/ast/file/file/packageWithImports.jav b/tests/testData/ast/file/file/packageWithImports.jav new file mode 100644 index 00000000000..94a969cfe93 --- /dev/null +++ b/tests/testData/ast/file/file/packageWithImports.jav @@ -0,0 +1 @@ +package test;import ast;import ast2; \ No newline at end of file diff --git a/tests/testData/ast/file/file/packageWithImports.kt b/tests/testData/ast/file/file/packageWithImports.kt new file mode 100644 index 00000000000..574db38b2fc --- /dev/null +++ b/tests/testData/ast/file/file/packageWithImports.kt @@ -0,0 +1,3 @@ +package test +import ast +import ast2 \ No newline at end of file diff --git a/tests/testData/ast/file/file/packageWithMixedImports.jav b/tests/testData/ast/file/file/packageWithMixedImports.jav new file mode 100644 index 00000000000..6296e224258 --- /dev/null +++ b/tests/testData/ast/file/file/packageWithMixedImports.jav @@ -0,0 +1 @@ +package test;import static ast;import ast2; \ No newline at end of file diff --git a/tests/testData/ast/file/file/packageWithMixedImports.kt b/tests/testData/ast/file/file/packageWithMixedImports.kt new file mode 100644 index 00000000000..574db38b2fc --- /dev/null +++ b/tests/testData/ast/file/file/packageWithMixedImports.kt @@ -0,0 +1,3 @@ +package test +import ast +import ast2 \ No newline at end of file diff --git a/tests/testData/ast/file/file/packageWithOpenClass.jav b/tests/testData/ast/file/file/packageWithOpenClass.jav new file mode 100644 index 00000000000..821bbec2b3d --- /dev/null +++ b/tests/testData/ast/file/file/packageWithOpenClass.jav @@ -0,0 +1 @@ +package test; class C {} \ No newline at end of file diff --git a/tests/testData/ast/file/file/packageWithOpenClass.kt b/tests/testData/ast/file/file/packageWithOpenClass.kt new file mode 100644 index 00000000000..0258fc072fb --- /dev/null +++ b/tests/testData/ast/file/file/packageWithOpenClass.kt @@ -0,0 +1,3 @@ +package test +open class C() { +} \ No newline at end of file diff --git a/tests/testData/ast/file/file/packageWithStaticImports.jav b/tests/testData/ast/file/file/packageWithStaticImports.jav new file mode 100644 index 00000000000..0d1bea3ba5a --- /dev/null +++ b/tests/testData/ast/file/file/packageWithStaticImports.jav @@ -0,0 +1 @@ +package test;import static ast;import static ast2; \ No newline at end of file diff --git a/tests/testData/ast/file/file/packageWithStaticImports.kt b/tests/testData/ast/file/file/packageWithStaticImports.kt new file mode 100644 index 00000000000..574db38b2fc --- /dev/null +++ b/tests/testData/ast/file/file/packageWithStaticImports.kt @@ -0,0 +1,3 @@ +package test +import ast +import ast2 \ No newline at end of file diff --git a/tests/testData/ast/for/statement/commonCaseForTest.jav b/tests/testData/ast/for/statement/commonCaseForTest.jav new file mode 100644 index 00000000000..0ea98e4b45f --- /dev/null +++ b/tests/testData/ast/for/statement/commonCaseForTest.jav @@ -0,0 +1 @@ +for (init(); condition(); update()) body(); \ No newline at end of file diff --git a/tests/testData/ast/for/statement/commonCaseForTest.kt b/tests/testData/ast/for/statement/commonCaseForTest.kt new file mode 100644 index 00000000000..329aa8c5572 --- /dev/null +++ b/tests/testData/ast/for/statement/commonCaseForTest.kt @@ -0,0 +1,10 @@ +{ +init() +while (condition()) +{ +body() +{ +update() +} +} +} \ No newline at end of file diff --git a/tests/testData/ast/for/statement/forRangeWithLE.jav b/tests/testData/ast/for/statement/forRangeWithLE.jav new file mode 100644 index 00000000000..a0069d48943 --- /dev/null +++ b/tests/testData/ast/for/statement/forRangeWithLE.jav @@ -0,0 +1,2 @@ +int[] array = new int[10]; +for (int i = 0; i <= 10; i++) {array[i] = i;} \ No newline at end of file diff --git a/tests/testData/ast/for/statement/forRangeWithLE.kt b/tests/testData/ast/for/statement/forRangeWithLE.kt new file mode 100644 index 00000000000..5bd70a50082 --- /dev/null +++ b/tests/testData/ast/for/statement/forRangeWithLE.kt @@ -0,0 +1,4 @@ +var array : IntArray? = IntArray(10) +for (i in 0..10) { +array[i] = i +} \ No newline at end of file diff --git a/tests/testData/ast/for/statement/forRangeWithLT.jav b/tests/testData/ast/for/statement/forRangeWithLT.jav new file mode 100644 index 00000000000..19b24cf03fb --- /dev/null +++ b/tests/testData/ast/for/statement/forRangeWithLT.jav @@ -0,0 +1,2 @@ +int[] array = new int[10]; +for (int i = 0; i < 10; i++) {array[i] = i;} \ No newline at end of file diff --git a/tests/testData/ast/for/statement/forRangeWithLT.kt b/tests/testData/ast/for/statement/forRangeWithLT.kt new file mode 100644 index 00000000000..9026bd5ce21 --- /dev/null +++ b/tests/testData/ast/for/statement/forRangeWithLT.kt @@ -0,0 +1,4 @@ +var array : IntArray? = IntArray(10) +for (i in 0..10 - 1) { +array[i] = i +} \ No newline at end of file diff --git a/tests/testData/ast/for/statement/forWithBlock.jav b/tests/testData/ast/for/statement/forWithBlock.jav new file mode 100644 index 00000000000..19b24cf03fb --- /dev/null +++ b/tests/testData/ast/for/statement/forWithBlock.jav @@ -0,0 +1,2 @@ +int[] array = new int[10]; +for (int i = 0; i < 10; i++) {array[i] = i;} \ No newline at end of file diff --git a/tests/testData/ast/for/statement/forWithBlock.kt b/tests/testData/ast/for/statement/forWithBlock.kt new file mode 100644 index 00000000000..9026bd5ce21 --- /dev/null +++ b/tests/testData/ast/for/statement/forWithBlock.kt @@ -0,0 +1,4 @@ +var array : IntArray? = IntArray(10) +for (i in 0..10 - 1) { +array[i] = i +} \ No newline at end of file diff --git a/tests/testData/ast/for/statement/forWithBlockAndDoubleUpdate.jav b/tests/testData/ast/for/statement/forWithBlockAndDoubleUpdate.jav new file mode 100644 index 00000000000..6c7c9e0e210 --- /dev/null +++ b/tests/testData/ast/for/statement/forWithBlockAndDoubleUpdate.jav @@ -0,0 +1 @@ +for (int i = 0; i < 0; j++, i++) {int i = 1; i++;} \ No newline at end of file diff --git a/tests/testData/ast/for/statement/forWithBlockAndDoubleUpdate.kt b/tests/testData/ast/for/statement/forWithBlockAndDoubleUpdate.kt new file mode 100644 index 00000000000..e8c068d22a0 --- /dev/null +++ b/tests/testData/ast/for/statement/forWithBlockAndDoubleUpdate.kt @@ -0,0 +1,14 @@ +{ +var i : Int = 0 +while (i < 0) +{ +{ +var i : Int = 1 +i++ +} +{ +j++ +i++ +} +} +} \ No newline at end of file diff --git a/tests/testData/ast/for/statement/forWithEmptyBlock.jav b/tests/testData/ast/for/statement/forWithEmptyBlock.jav new file mode 100644 index 00000000000..35fa13bac7b --- /dev/null +++ b/tests/testData/ast/for/statement/forWithEmptyBlock.jav @@ -0,0 +1 @@ +for (int i = 0; i < 0; j++, i++) {} \ No newline at end of file diff --git a/tests/testData/ast/for/statement/forWithEmptyBlock.kt b/tests/testData/ast/for/statement/forWithEmptyBlock.kt new file mode 100644 index 00000000000..a3110901bdf --- /dev/null +++ b/tests/testData/ast/for/statement/forWithEmptyBlock.kt @@ -0,0 +1,12 @@ +{ +var i : Int = 0 +while (i < 0) +{ +{ +} +{ +j++ +i++ +} +} +} \ No newline at end of file diff --git a/tests/testData/ast/for/statement/forWithExpression.jav b/tests/testData/ast/for/statement/forWithExpression.jav new file mode 100644 index 00000000000..fc006f06703 --- /dev/null +++ b/tests/testData/ast/for/statement/forWithExpression.jav @@ -0,0 +1 @@ +for (int i = 0; i < 0; i++) t++; \ No newline at end of file diff --git a/tests/testData/ast/for/statement/forWithExpression.kt b/tests/testData/ast/for/statement/forWithExpression.kt new file mode 100644 index 00000000000..be1826e8d8a --- /dev/null +++ b/tests/testData/ast/for/statement/forWithExpression.kt @@ -0,0 +1 @@ +for (i in 0..0 - 1) t++ \ No newline at end of file diff --git a/tests/testData/ast/for/statement/forWithReturn.jav b/tests/testData/ast/for/statement/forWithReturn.jav new file mode 100644 index 00000000000..9a439dfe876 --- /dev/null +++ b/tests/testData/ast/for/statement/forWithReturn.jav @@ -0,0 +1 @@ +for (int i = 0; i < 0; j++, i++) return i; \ No newline at end of file diff --git a/tests/testData/ast/for/statement/forWithReturn.kt b/tests/testData/ast/for/statement/forWithReturn.kt new file mode 100644 index 00000000000..14780c27b21 --- /dev/null +++ b/tests/testData/ast/for/statement/forWithReturn.kt @@ -0,0 +1,11 @@ +{ +var i : Int = 0 +while (i < 0) +{ +return i +{ +j++ +i++ +} +} +} \ No newline at end of file diff --git a/tests/testData/ast/foreachStatement/statement/enhancedForWithBlock.jav b/tests/testData/ast/foreachStatement/statement/enhancedForWithBlock.jav new file mode 100644 index 00000000000..8657e2d8f9c --- /dev/null +++ b/tests/testData/ast/foreachStatement/statement/enhancedForWithBlock.jav @@ -0,0 +1 @@ +for (Node n : list) {int i = 1; i++;} \ No newline at end of file diff --git a/tests/testData/ast/foreachStatement/statement/enhancedForWithBlock.kt b/tests/testData/ast/foreachStatement/statement/enhancedForWithBlock.kt new file mode 100644 index 00000000000..e0ff78334cf --- /dev/null +++ b/tests/testData/ast/foreachStatement/statement/enhancedForWithBlock.kt @@ -0,0 +1,5 @@ +for (n : Node? in list) +{ +var i : Int = 1 +i++ +} \ No newline at end of file diff --git a/tests/testData/ast/foreachStatement/statement/enhancedForWithEmptyBlock.jav b/tests/testData/ast/foreachStatement/statement/enhancedForWithEmptyBlock.jav new file mode 100644 index 00000000000..225aecfb59c --- /dev/null +++ b/tests/testData/ast/foreachStatement/statement/enhancedForWithEmptyBlock.jav @@ -0,0 +1 @@ +for (Node n : list) {} \ No newline at end of file diff --git a/tests/testData/ast/foreachStatement/statement/enhancedForWithEmptyBlock.kt b/tests/testData/ast/foreachStatement/statement/enhancedForWithEmptyBlock.kt new file mode 100644 index 00000000000..945006d2dd9 --- /dev/null +++ b/tests/testData/ast/foreachStatement/statement/enhancedForWithEmptyBlock.kt @@ -0,0 +1,3 @@ +for (n : Node? in list) +{ +} \ No newline at end of file diff --git a/tests/testData/ast/foreachStatement/statement/enhancedForWithExpression.jav b/tests/testData/ast/foreachStatement/statement/enhancedForWithExpression.jav new file mode 100644 index 00000000000..22e30e2879e --- /dev/null +++ b/tests/testData/ast/foreachStatement/statement/enhancedForWithExpression.jav @@ -0,0 +1 @@ +for (Node n : list) i++; \ No newline at end of file diff --git a/tests/testData/ast/foreachStatement/statement/enhancedForWithExpression.kt b/tests/testData/ast/foreachStatement/statement/enhancedForWithExpression.kt new file mode 100644 index 00000000000..6e3ea34d942 --- /dev/null +++ b/tests/testData/ast/foreachStatement/statement/enhancedForWithExpression.kt @@ -0,0 +1,2 @@ +for (n : Node? in list) +i++ \ No newline at end of file diff --git a/tests/testData/ast/foreachStatement/statement/enhancedForWithReturn.jav b/tests/testData/ast/foreachStatement/statement/enhancedForWithReturn.jav new file mode 100644 index 00000000000..59409790376 --- /dev/null +++ b/tests/testData/ast/foreachStatement/statement/enhancedForWithReturn.jav @@ -0,0 +1 @@ +for (Node n : list) return n; \ No newline at end of file diff --git a/tests/testData/ast/foreachStatement/statement/enhancedForWithReturn.kt b/tests/testData/ast/foreachStatement/statement/enhancedForWithReturn.kt new file mode 100644 index 00000000000..143f7767a85 --- /dev/null +++ b/tests/testData/ast/foreachStatement/statement/enhancedForWithReturn.kt @@ -0,0 +1,2 @@ +for (n : Node? in list) +return n \ No newline at end of file diff --git a/tests/testData/ast/function/file/extendsBaseWhichExtendsObject.jav b/tests/testData/ast/function/file/extendsBaseWhichExtendsObject.jav new file mode 100644 index 00000000000..b72fd76ec71 --- /dev/null +++ b/tests/testData/ast/function/file/extendsBaseWhichExtendsObject.jav @@ -0,0 +1,55 @@ +package test; + +class Test extends Base { + @Override + public int hashCode() { + return super.hashCode(); + } + + @Override + public boolean equals(Object o) { + return super.equals(o); + } + + @Override + protected Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + @Override + public String toString() { + return super.toString(); + } + + @Override + protected void finalize() throws Throwable { + super.finalize(); + } +} + +class Base { + @Override + public int hashCode() { + return super.hashCode(); + } + + @Override + public boolean equals(Object o) { + return super.equals(o); + } + + @Override + protected Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + @Override + public String toString() { + return super.toString(); + } + + @Override + protected void finalize() throws Throwable { + super.finalize(); + } +} \ No newline at end of file diff --git a/tests/testData/ast/function/file/extendsBaseWhichExtendsObject.kt b/tests/testData/ast/function/file/extendsBaseWhichExtendsObject.kt new file mode 100644 index 00000000000..284cd37ffcd --- /dev/null +++ b/tests/testData/ast/function/file/extendsBaseWhichExtendsObject.kt @@ -0,0 +1,35 @@ +package test +open class Test() : Base() { +public override fun hashCode() : Int { +return super.hashCode() +} +public override fun equals(o : Any?) : Boolean { +return super.equals(o) +} +protected override fun clone() : Any? { +return super.clone() +} +public override fun toString() : String? { +return super.toString() +} +protected override fun finalize() : Unit { +super.finalize() +} +} +open class Base() { +public open fun hashCode() : Int { +return System.identityHashCode(this) +} +public open fun equals(o : Any?) : Boolean { +return this.identityEquals(o) +} +protected open fun clone() : Any? { +return super.clone() +} +public open fun toString() : String? { +return getJavaClass.getName() + '@' + Integer.toHexString(hashCode()) +} +protected open fun finalize() : Unit { +super.finalize() +} +} \ No newline at end of file diff --git a/tests/testData/ast/function/file/functionInFinalClass.jav b/tests/testData/ast/function/file/functionInFinalClass.jav new file mode 100644 index 00000000000..e8417401a9a --- /dev/null +++ b/tests/testData/ast/function/file/functionInFinalClass.jav @@ -0,0 +1,5 @@ +package demo; + +final class Final { + void test() {} +} \ No newline at end of file diff --git a/tests/testData/ast/function/file/functionInFinalClass.kt b/tests/testData/ast/function/file/functionInFinalClass.kt new file mode 100644 index 00000000000..5546a9ff4ab --- /dev/null +++ b/tests/testData/ast/function/file/functionInFinalClass.kt @@ -0,0 +1,5 @@ +package demo +class Final() { +fun test() : Unit { +} +} \ No newline at end of file diff --git a/tests/testData/ast/function/file/override.jav b/tests/testData/ast/function/file/override.jav new file mode 100644 index 00000000000..63a319a053c --- /dev/null +++ b/tests/testData/ast/function/file/override.jav @@ -0,0 +1 @@ +class A {void a() {}} final class B extends A {void a() {}} \ No newline at end of file diff --git a/tests/testData/ast/function/file/override.kt b/tests/testData/ast/function/file/override.kt new file mode 100644 index 00000000000..775e07afd6a --- /dev/null +++ b/tests/testData/ast/function/file/override.kt @@ -0,0 +1,8 @@ +open class A() { +open fun a() : Unit { +} +} +class B() : A() { +override fun a() : Unit { +} +} \ No newline at end of file diff --git a/tests/testData/ast/function/file/overrideAndOpen.jav b/tests/testData/ast/function/file/overrideAndOpen.jav new file mode 100644 index 00000000000..bda1a410cff --- /dev/null +++ b/tests/testData/ast/function/file/overrideAndOpen.jav @@ -0,0 +1,11 @@ +class A { + void foo() {} +} + +class B extends A { + void foo() {} +} + +class C extends B { + void foo() {} +} \ No newline at end of file diff --git a/tests/testData/ast/function/file/overrideAndOpen.kt b/tests/testData/ast/function/file/overrideAndOpen.kt new file mode 100644 index 00000000000..a4335071798 --- /dev/null +++ b/tests/testData/ast/function/file/overrideAndOpen.kt @@ -0,0 +1,12 @@ +open class A() { +open fun foo() : Unit { +} +} +open class B() : A() { +override fun foo() : Unit { +} +} +open class C() : B() { +override fun foo() : Unit { +} +} \ No newline at end of file diff --git a/tests/testData/ast/function/file/overrideObject.jav b/tests/testData/ast/function/file/overrideObject.jav new file mode 100644 index 00000000000..0538508c9b8 --- /dev/null +++ b/tests/testData/ast/function/file/overrideObject.jav @@ -0,0 +1,28 @@ +package test; + +class Test { + @Override + public int hashCode() { + return super.hashCode(); + } + + @Override + public boolean equals(Object o) { + return super.equals(o); + } + + @Override + protected Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + @Override + public String toString() { + return super.toString(); + } + + @Override + protected void finalize() throws Throwable { + super.finalize(); + } +} \ No newline at end of file diff --git a/tests/testData/ast/function/file/overrideObject.kt b/tests/testData/ast/function/file/overrideObject.kt new file mode 100644 index 00000000000..f7301f7b196 --- /dev/null +++ b/tests/testData/ast/function/file/overrideObject.kt @@ -0,0 +1,18 @@ +package test +open class Test() { +public open fun hashCode() : Int { +return System.identityHashCode(this) +} +public open fun equals(o : Any?) : Boolean { +return this.identityEquals(o) +} +protected open fun clone() : Any? { +return super.clone() +} +public open fun toString() : String? { +return getJavaClass.getName() + '@' + Integer.toHexString(hashCode()) +} +protected open fun finalize() : Unit { +super.finalize() +} +} \ No newline at end of file diff --git a/tests/testData/ast/function/file/varVararg.jav b/tests/testData/ast/function/file/varVararg.jav new file mode 100644 index 00000000000..bba8ce2db90 --- /dev/null +++ b/tests/testData/ast/function/file/varVararg.jav @@ -0,0 +1,7 @@ +package demo; + +class Test { + void test(Object ... args) { + args = new Integer[] {1, 2, 3}; + } +} \ No newline at end of file diff --git a/tests/testData/ast/function/file/varVararg.kt b/tests/testData/ast/function/file/varVararg.kt new file mode 100644 index 00000000000..c3cfa02dc73 --- /dev/null +++ b/tests/testData/ast/function/file/varVararg.kt @@ -0,0 +1,6 @@ +package demo +open class Test() { +open fun test(vararg var args : Any?) : Unit { +args = array(1, 2, 3) +} +} \ No newline at end of file diff --git a/tests/testData/ast/function/file/writableParameter.jav b/tests/testData/ast/function/file/writableParameter.jav new file mode 100644 index 00000000000..c2ed3cf10d4 --- /dev/null +++ b/tests/testData/ast/function/file/writableParameter.jav @@ -0,0 +1,8 @@ +package demo; + +class Test { + int test(int i) { + i = 10; + return i + 20; + } +} \ No newline at end of file diff --git a/tests/testData/ast/function/file/writableParameter.kt b/tests/testData/ast/function/file/writableParameter.kt new file mode 100644 index 00000000000..388363d3a75 --- /dev/null +++ b/tests/testData/ast/function/file/writableParameter.kt @@ -0,0 +1,7 @@ +package demo +open class Test() { +open fun test(var i : Int) : Int { +i = 10 +return i + 20 +} +} \ No newline at end of file diff --git a/tests/testData/ast/function/method/abstractMethod.jav b/tests/testData/ast/function/method/abstractMethod.jav new file mode 100644 index 00000000000..03a2e8270c8 --- /dev/null +++ b/tests/testData/ast/function/method/abstractMethod.jav @@ -0,0 +1 @@ +abstract int getNoofGears(); \ No newline at end of file diff --git a/tests/testData/ast/function/method/abstractMethod.kt b/tests/testData/ast/function/method/abstractMethod.kt new file mode 100644 index 00000000000..8163dfad9bb --- /dev/null +++ b/tests/testData/ast/function/method/abstractMethod.kt @@ -0,0 +1 @@ +abstract fun getNoofGears() : Int \ No newline at end of file diff --git a/tests/testData/ast/function/method/classGenericParam.jav b/tests/testData/ast/function/method/classGenericParam.jav new file mode 100644 index 00000000000..ec2f1534b58 --- /dev/null +++ b/tests/testData/ast/function/method/classGenericParam.jav @@ -0,0 +1 @@ +T getT() {} \ No newline at end of file diff --git a/tests/testData/ast/function/method/classGenericParam.kt b/tests/testData/ast/function/method/classGenericParam.kt new file mode 100644 index 00000000000..cb91ad7b095 --- /dev/null +++ b/tests/testData/ast/function/method/classGenericParam.kt @@ -0,0 +1,2 @@ +fun getT() : T? { +} \ No newline at end of file diff --git a/tests/testData/ast/function/method/emptyVoidMethod.jav b/tests/testData/ast/function/method/emptyVoidMethod.jav new file mode 100644 index 00000000000..05a37e98348 --- /dev/null +++ b/tests/testData/ast/function/method/emptyVoidMethod.jav @@ -0,0 +1 @@ +void main() {} \ No newline at end of file diff --git a/tests/testData/ast/function/method/emptyVoidMethod.kt b/tests/testData/ast/function/method/emptyVoidMethod.kt new file mode 100644 index 00000000000..db28ea9ebcb --- /dev/null +++ b/tests/testData/ast/function/method/emptyVoidMethod.kt @@ -0,0 +1,2 @@ +fun main() : Unit { +} \ No newline at end of file diff --git a/tests/testData/ast/function/method/final.jav b/tests/testData/ast/function/method/final.jav new file mode 100644 index 00000000000..8a49597af12 --- /dev/null +++ b/tests/testData/ast/function/method/final.jav @@ -0,0 +1 @@ +final String getString() { return ""; } \ No newline at end of file diff --git a/tests/testData/ast/function/method/final.kt b/tests/testData/ast/function/method/final.kt new file mode 100644 index 00000000000..3ed88375ea7 --- /dev/null +++ b/tests/testData/ast/function/method/final.kt @@ -0,0 +1,3 @@ +fun getString() : String? { +return "" +} \ No newline at end of file diff --git a/tests/testData/ast/function/method/internal.jav b/tests/testData/ast/function/method/internal.jav new file mode 100644 index 00000000000..48b8cb32a8b --- /dev/null +++ b/tests/testData/ast/function/method/internal.jav @@ -0,0 +1 @@ +void test() {} \ No newline at end of file diff --git a/tests/testData/ast/function/method/internal.kt b/tests/testData/ast/function/method/internal.kt new file mode 100644 index 00000000000..a0118c99e7f --- /dev/null +++ b/tests/testData/ast/function/method/internal.kt @@ -0,0 +1,2 @@ +fun test() : Unit { +} \ No newline at end of file diff --git a/tests/testData/ast/function/method/main.jav b/tests/testData/ast/function/method/main.jav new file mode 100644 index 00000000000..a03c0afe12f --- /dev/null +++ b/tests/testData/ast/function/method/main.jav @@ -0,0 +1 @@ +public static void main(String[] args) {} \ No newline at end of file diff --git a/tests/testData/ast/function/method/main.kt b/tests/testData/ast/function/method/main.kt new file mode 100644 index 00000000000..1ed23f6e5ae --- /dev/null +++ b/tests/testData/ast/function/method/main.kt @@ -0,0 +1,4 @@ +class object { +public fun main(args : Array?) : Unit { +} +} \ No newline at end of file diff --git a/tests/testData/ast/function/method/methodClassType.jav b/tests/testData/ast/function/method/methodClassType.jav new file mode 100644 index 00000000000..ad93979b6fc --- /dev/null +++ b/tests/testData/ast/function/method/methodClassType.jav @@ -0,0 +1 @@ +String main() {} \ No newline at end of file diff --git a/tests/testData/ast/function/method/methodClassType.kt b/tests/testData/ast/function/method/methodClassType.kt new file mode 100644 index 00000000000..d3a97e16a3f --- /dev/null +++ b/tests/testData/ast/function/method/methodClassType.kt @@ -0,0 +1,2 @@ +fun main() : String? { +} \ No newline at end of file diff --git a/tests/testData/ast/function/method/methodPrimitiveType.jav b/tests/testData/ast/function/method/methodPrimitiveType.jav new file mode 100644 index 00000000000..c272dabaeb6 --- /dev/null +++ b/tests/testData/ast/function/method/methodPrimitiveType.jav @@ -0,0 +1 @@ +int main() {} \ No newline at end of file diff --git a/tests/testData/ast/function/method/methodPrimitiveType.kt b/tests/testData/ast/function/method/methodPrimitiveType.kt new file mode 100644 index 00000000000..dc03fed3cd9 --- /dev/null +++ b/tests/testData/ast/function/method/methodPrimitiveType.kt @@ -0,0 +1,2 @@ +fun main() : Int { +} \ No newline at end of file diff --git a/tests/testData/ast/function/method/methodPrimitiveType2.jav b/tests/testData/ast/function/method/methodPrimitiveType2.jav new file mode 100644 index 00000000000..0539f74aaef --- /dev/null +++ b/tests/testData/ast/function/method/methodPrimitiveType2.jav @@ -0,0 +1 @@ +boolean main() {} \ No newline at end of file diff --git a/tests/testData/ast/function/method/methodPrimitiveType2.kt b/tests/testData/ast/function/method/methodPrimitiveType2.kt new file mode 100644 index 00000000000..b4df54adcaf --- /dev/null +++ b/tests/testData/ast/function/method/methodPrimitiveType2.kt @@ -0,0 +1,2 @@ +fun main() : Boolean { +} \ No newline at end of file diff --git a/tests/testData/ast/function/method/methodWithReturnStatement.jav b/tests/testData/ast/function/method/methodWithReturnStatement.jav new file mode 100644 index 00000000000..1b02cbaa290 --- /dev/null +++ b/tests/testData/ast/function/method/methodWithReturnStatement.jav @@ -0,0 +1 @@ +boolean isTrue() { return true; } \ No newline at end of file diff --git a/tests/testData/ast/function/method/methodWithReturnStatement.kt b/tests/testData/ast/function/method/methodWithReturnStatement.kt new file mode 100644 index 00000000000..40fc1144ad3 --- /dev/null +++ b/tests/testData/ast/function/method/methodWithReturnStatement.kt @@ -0,0 +1,3 @@ +fun isTrue() : Boolean { +return true +} \ No newline at end of file diff --git a/tests/testData/ast/function/method/open.jav b/tests/testData/ast/function/method/open.jav new file mode 100644 index 00000000000..6db748fef42 --- /dev/null +++ b/tests/testData/ast/function/method/open.jav @@ -0,0 +1 @@ +String getString() { return ""; } \ No newline at end of file diff --git a/tests/testData/ast/function/method/open.kt b/tests/testData/ast/function/method/open.kt new file mode 100644 index 00000000000..3ed88375ea7 --- /dev/null +++ b/tests/testData/ast/function/method/open.kt @@ -0,0 +1,3 @@ +fun getString() : String? { +return "" +} \ No newline at end of file diff --git a/tests/testData/ast/function/method/ownGenericParam.jav b/tests/testData/ast/function/method/ownGenericParam.jav new file mode 100644 index 00000000000..3b651cfda09 --- /dev/null +++ b/tests/testData/ast/function/method/ownGenericParam.jav @@ -0,0 +1 @@ + void putU(U u) {} \ No newline at end of file diff --git a/tests/testData/ast/function/method/ownGenericParam.kt b/tests/testData/ast/function/method/ownGenericParam.kt new file mode 100644 index 00000000000..51205bef614 --- /dev/null +++ b/tests/testData/ast/function/method/ownGenericParam.kt @@ -0,0 +1,2 @@ +fun putU(u : U?) : Unit { +} \ No newline at end of file diff --git a/tests/testData/ast/function/method/ownSeveralGenericParams.jav b/tests/testData/ast/function/method/ownSeveralGenericParams.jav new file mode 100644 index 00000000000..3af41393000 --- /dev/null +++ b/tests/testData/ast/function/method/ownSeveralGenericParams.jav @@ -0,0 +1 @@ + void putUVW(U u, V v, W w) {} \ No newline at end of file diff --git a/tests/testData/ast/function/method/ownSeveralGenericParams.kt b/tests/testData/ast/function/method/ownSeveralGenericParams.kt new file mode 100644 index 00000000000..b9dd3c684e1 --- /dev/null +++ b/tests/testData/ast/function/method/ownSeveralGenericParams.kt @@ -0,0 +1,2 @@ +fun putUVW(u : U?, v : V?, w : W?) : Unit { +} \ No newline at end of file diff --git a/tests/testData/ast/function/method/private.jav b/tests/testData/ast/function/method/private.jav new file mode 100644 index 00000000000..823fbd1e89e --- /dev/null +++ b/tests/testData/ast/function/method/private.jav @@ -0,0 +1 @@ +private void test() {} \ No newline at end of file diff --git a/tests/testData/ast/function/method/private.kt b/tests/testData/ast/function/method/private.kt new file mode 100644 index 00000000000..be8571b7f24 --- /dev/null +++ b/tests/testData/ast/function/method/private.kt @@ -0,0 +1,2 @@ +private fun test() : Unit { +} \ No newline at end of file diff --git a/tests/testData/ast/function/method/protected.jav b/tests/testData/ast/function/method/protected.jav new file mode 100644 index 00000000000..ab7575a6ed6 --- /dev/null +++ b/tests/testData/ast/function/method/protected.jav @@ -0,0 +1 @@ +protected void test() {} \ No newline at end of file diff --git a/tests/testData/ast/function/method/protected.kt b/tests/testData/ast/function/method/protected.kt new file mode 100644 index 00000000000..3cf7e568df7 --- /dev/null +++ b/tests/testData/ast/function/method/protected.kt @@ -0,0 +1,2 @@ +protected fun test() : Unit { +} \ No newline at end of file diff --git a/tests/testData/ast/function/method/public.jav b/tests/testData/ast/function/method/public.jav new file mode 100644 index 00000000000..db620e22298 --- /dev/null +++ b/tests/testData/ast/function/method/public.jav @@ -0,0 +1 @@ +public void test() {} \ No newline at end of file diff --git a/tests/testData/ast/function/method/public.kt b/tests/testData/ast/function/method/public.kt new file mode 100644 index 00000000000..166c7ec8136 --- /dev/null +++ b/tests/testData/ast/function/method/public.kt @@ -0,0 +1,2 @@ +public fun test() : Unit { +} \ No newline at end of file diff --git a/tests/testData/ast/identifier/expression/withDollar.jav b/tests/testData/ast/identifier/expression/withDollar.jav new file mode 100644 index 00000000000..49ceb94e5b8 --- /dev/null +++ b/tests/testData/ast/identifier/expression/withDollar.jav @@ -0,0 +1 @@ +$$$$$ \ No newline at end of file diff --git a/tests/testData/ast/identifier/expression/withDollar.kt b/tests/testData/ast/identifier/expression/withDollar.kt new file mode 100644 index 00000000000..47ac2104db8 --- /dev/null +++ b/tests/testData/ast/identifier/expression/withDollar.kt @@ -0,0 +1 @@ +`$$$$$` \ No newline at end of file diff --git a/tests/testData/ast/identifier/file/finalFieldReference.jav b/tests/testData/ast/identifier/file/finalFieldReference.jav new file mode 100644 index 00000000000..f5d31f19d64 --- /dev/null +++ b/tests/testData/ast/identifier/file/finalFieldReference.jav @@ -0,0 +1,13 @@ +class $$$$$ {} + +class $ {} + +class $$ extends $ { + final $$$$$ $$$; + + public $$($$$$$ $$$$) { + $$$ = $$$$; + } + + public $$$$$ $$$$$$() {return $$$;} +} \ No newline at end of file diff --git a/tests/testData/ast/identifier/file/finalFieldReference.kt b/tests/testData/ast/identifier/file/finalFieldReference.kt new file mode 100644 index 00000000000..d015ea5ef32 --- /dev/null +++ b/tests/testData/ast/identifier/file/finalFieldReference.kt @@ -0,0 +1,13 @@ +open class `$$$$$`() { +} +open class `$`() { +} +open class `$$`(`$$$$` : `$$$$$`?) : `$`() { +val `$$$` : `$$$$$`? +public open fun `$$$$$$`() : `$$$$$`? { +return `$$$` +} +{ +`$$$` = `$$$$` +} +} \ No newline at end of file diff --git a/tests/testData/ast/identifier/statement/keywords.jav b/tests/testData/ast/identifier/statement/keywords.jav new file mode 100644 index 00000000000..02a6d77d21a --- /dev/null +++ b/tests/testData/ast/identifier/statement/keywords.jav @@ -0,0 +1 @@ +int as, type, val, var, fun, is, in, object, when, trait, This; \ No newline at end of file diff --git a/tests/testData/ast/identifier/statement/keywords.kt b/tests/testData/ast/identifier/statement/keywords.kt new file mode 100644 index 00000000000..9d4b718fafe --- /dev/null +++ b/tests/testData/ast/identifier/statement/keywords.kt @@ -0,0 +1,11 @@ +var `as` : Int +var `type` : Int +var `val` : Int +var `var` : Int +var `fun` : Int +var `is` : Int +var `in` : Int +var `object` : Int +var `when` : Int +var `trait` : Int +var `This` : Int \ No newline at end of file diff --git a/tests/testData/ast/ifStatement/statement/ifStatementWithEmptyBlocks.jav b/tests/testData/ast/ifStatement/statement/ifStatementWithEmptyBlocks.jav new file mode 100644 index 00000000000..3690c79ad62 --- /dev/null +++ b/tests/testData/ast/ifStatement/statement/ifStatementWithEmptyBlocks.jav @@ -0,0 +1 @@ +if (1 > 0) {} else {} \ No newline at end of file diff --git a/tests/testData/ast/ifStatement/statement/ifStatementWithEmptyBlocks.kt b/tests/testData/ast/ifStatement/statement/ifStatementWithEmptyBlocks.kt new file mode 100644 index 00000000000..b48926727df --- /dev/null +++ b/tests/testData/ast/ifStatement/statement/ifStatementWithEmptyBlocks.kt @@ -0,0 +1,6 @@ +if (1 > 0) +{ +} +else +{ +} \ No newline at end of file diff --git a/tests/testData/ast/ifStatement/statement/ifStatementWithMultilineBlocks.jav b/tests/testData/ast/ifStatement/statement/ifStatementWithMultilineBlocks.jav new file mode 100644 index 00000000000..5546ee07bcf --- /dev/null +++ b/tests/testData/ast/ifStatement/statement/ifStatementWithMultilineBlocks.jav @@ -0,0 +1 @@ +if (1 > 0) {int n = 1; return n;} else {return 0;} \ No newline at end of file diff --git a/tests/testData/ast/ifStatement/statement/ifStatementWithMultilineBlocks.kt b/tests/testData/ast/ifStatement/statement/ifStatementWithMultilineBlocks.kt new file mode 100644 index 00000000000..27ae7424666 --- /dev/null +++ b/tests/testData/ast/ifStatement/statement/ifStatementWithMultilineBlocks.kt @@ -0,0 +1,9 @@ +if (1 > 0) +{ +var n : Int = 1 +return n +} +else +{ +return 0 +} \ No newline at end of file diff --git a/tests/testData/ast/ifStatement/statement/ifStatementWithOneLineBlocks.jav b/tests/testData/ast/ifStatement/statement/ifStatementWithOneLineBlocks.jav new file mode 100644 index 00000000000..c772469d2d2 --- /dev/null +++ b/tests/testData/ast/ifStatement/statement/ifStatementWithOneLineBlocks.jav @@ -0,0 +1 @@ +if (true) return 1; else return 0; \ No newline at end of file diff --git a/tests/testData/ast/ifStatement/statement/ifStatementWithOneLineBlocks.kt b/tests/testData/ast/ifStatement/statement/ifStatementWithOneLineBlocks.kt new file mode 100644 index 00000000000..057d6294846 --- /dev/null +++ b/tests/testData/ast/ifStatement/statement/ifStatementWithOneLineBlocks.kt @@ -0,0 +1,4 @@ +if (true) +return 1 +else +return 0 \ No newline at end of file diff --git a/tests/testData/ast/ifStatement/statement/ifStatementWithoutElse.jav b/tests/testData/ast/ifStatement/statement/ifStatementWithoutElse.jav new file mode 100644 index 00000000000..d4814fbe107 --- /dev/null +++ b/tests/testData/ast/ifStatement/statement/ifStatementWithoutElse.jav @@ -0,0 +1 @@ +if (1 > 0) {int n = 1; return n;} \ No newline at end of file diff --git a/tests/testData/ast/ifStatement/statement/ifStatementWithoutElse.kt b/tests/testData/ast/ifStatement/statement/ifStatementWithoutElse.kt new file mode 100644 index 00000000000..6dcf6d7b346 --- /dev/null +++ b/tests/testData/ast/ifStatement/statement/ifStatementWithoutElse.kt @@ -0,0 +1,5 @@ +if (1 > 0) +{ +var n : Int = 1 +return n +} \ No newline at end of file diff --git a/tests/testData/ast/importStatement/file/importWithKeywords.jav b/tests/testData/ast/importStatement/file/importWithKeywords.jav new file mode 100644 index 00000000000..5b4e73fec5a --- /dev/null +++ b/tests/testData/ast/importStatement/file/importWithKeywords.jav @@ -0,0 +1,5 @@ +package test; + +import as.type.val.var.fun.is.in.object.when.trait.This; + +class Test {} diff --git a/tests/testData/ast/importStatement/file/importWithKeywords.kt b/tests/testData/ast/importStatement/file/importWithKeywords.kt new file mode 100644 index 00000000000..7eda4b24938 --- /dev/null +++ b/tests/testData/ast/importStatement/file/importWithKeywords.kt @@ -0,0 +1,4 @@ +package test +import `as`.`type`.`val`.`var`.`fun`.`is`.`in`.`object`.`when`.`trait`.`This` +open class Test() { +} \ No newline at end of file diff --git a/tests/testData/ast/importStatement/file/importWithStar.jav b/tests/testData/ast/importStatement/file/importWithStar.jav new file mode 100644 index 00000000000..abbec8d10d3 --- /dev/null +++ b/tests/testData/ast/importStatement/file/importWithStar.jav @@ -0,0 +1,5 @@ +package org.jetbrains.jet.j2k; + +import org.jetbrains.annotations.*; + +public class Converter {} \ No newline at end of file diff --git a/tests/testData/ast/importStatement/file/importWithStar.kt b/tests/testData/ast/importStatement/file/importWithStar.kt new file mode 100644 index 00000000000..6727a6e8fcb --- /dev/null +++ b/tests/testData/ast/importStatement/file/importWithStar.kt @@ -0,0 +1,4 @@ +package org.jetbrains.jet.j2k +import org.jetbrains.annotations.* +public open class Converter() { +} \ No newline at end of file diff --git a/tests/testData/ast/importStatement/file/simpleImport.jav b/tests/testData/ast/importStatement/file/simpleImport.jav new file mode 100644 index 00000000000..a2daf0cd933 --- /dev/null +++ b/tests/testData/ast/importStatement/file/simpleImport.jav @@ -0,0 +1,5 @@ +package org.jetbrains.jet.j2k; + +import org.jetbrains.annotations.NotNull; + +public class Converter {} \ No newline at end of file diff --git a/tests/testData/ast/importStatement/file/simpleImport.kt b/tests/testData/ast/importStatement/file/simpleImport.kt new file mode 100644 index 00000000000..21028179d15 --- /dev/null +++ b/tests/testData/ast/importStatement/file/simpleImport.kt @@ -0,0 +1,3 @@ +package org.jetbrains.jet.j2k +public open class Converter() { +} \ No newline at end of file diff --git a/tests/testData/ast/inProjectionType/method/methodParams.jav b/tests/testData/ast/inProjectionType/method/methodParams.jav new file mode 100644 index 00000000000..63b9ff6d6b7 --- /dev/null +++ b/tests/testData/ast/inProjectionType/method/methodParams.jav @@ -0,0 +1 @@ +void popAll(Collection dst) {} \ No newline at end of file diff --git a/tests/testData/ast/inProjectionType/method/methodParams.kt b/tests/testData/ast/inProjectionType/method/methodParams.kt new file mode 100644 index 00000000000..9e225d237c2 --- /dev/null +++ b/tests/testData/ast/inProjectionType/method/methodParams.kt @@ -0,0 +1,2 @@ +fun popAll(dst : Collection?) : Unit { +} \ No newline at end of file diff --git a/tests/testData/ast/inheritance/file/classOneExtendsBaseGeneric.jav b/tests/testData/ast/inheritance/file/classOneExtendsBaseGeneric.jav new file mode 100644 index 00000000000..0abe463c9ae --- /dev/null +++ b/tests/testData/ast/inheritance/file/classOneExtendsBaseGeneric.jav @@ -0,0 +1,12 @@ +class Base { + Base(T name) { } +} + +class One extends Base { + private K mySecond; + + One(T name, K second) { + super(name) + mySecond = second; + } +} \ No newline at end of file diff --git a/tests/testData/ast/inheritance/file/classOneExtendsBaseGeneric.kt b/tests/testData/ast/inheritance/file/classOneExtendsBaseGeneric.kt new file mode 100644 index 00000000000..2d413b3fca1 --- /dev/null +++ b/tests/testData/ast/inheritance/file/classOneExtendsBaseGeneric.kt @@ -0,0 +1,8 @@ +open class Base(name : T?) { +} +open class One(name : T?, second : K?) : Base(name) { +private var mySecond : K? = null +{ +mySecond = second +} +} \ No newline at end of file diff --git a/tests/testData/ast/inheritance/file/classOneExtendsBaseWithOneParam.jav b/tests/testData/ast/inheritance/file/classOneExtendsBaseWithOneParam.jav new file mode 100644 index 00000000000..9e7190d29fa --- /dev/null +++ b/tests/testData/ast/inheritance/file/classOneExtendsBaseWithOneParam.jav @@ -0,0 +1,9 @@ +class Base { + Base(String name) {} +} + +class One extends Base { + One(String name, String second) { + super(name) + } +} \ No newline at end of file diff --git a/tests/testData/ast/inheritance/file/classOneExtendsBaseWithOneParam.kt b/tests/testData/ast/inheritance/file/classOneExtendsBaseWithOneParam.kt new file mode 100644 index 00000000000..56b9315c50b --- /dev/null +++ b/tests/testData/ast/inheritance/file/classOneExtendsBaseWithOneParam.kt @@ -0,0 +1,4 @@ +open class Base(name : String?) { +} +open class One(name : String?, second : String?) : Base(name) { +} \ No newline at end of file diff --git a/tests/testData/ast/inheritance/file/classOneExtendsBaseWithZeroParams.jav b/tests/testData/ast/inheritance/file/classOneExtendsBaseWithZeroParams.jav new file mode 100644 index 00000000000..2a89c5bd6e0 --- /dev/null +++ b/tests/testData/ast/inheritance/file/classOneExtendsBaseWithZeroParams.jav @@ -0,0 +1,3 @@ +class Base {} + +class One extends Base {} \ No newline at end of file diff --git a/tests/testData/ast/inheritance/file/classOneExtendsBaseWithZeroParams.kt b/tests/testData/ast/inheritance/file/classOneExtendsBaseWithZeroParams.kt new file mode 100644 index 00000000000..2b63632703e --- /dev/null +++ b/tests/testData/ast/inheritance/file/classOneExtendsBaseWithZeroParams.kt @@ -0,0 +1,4 @@ +open class Base() { +} +open class One() : Base() { +} \ No newline at end of file diff --git a/tests/testData/ast/inheritance/file/classOneExtendsBaseWithZeroParamsNonEmptyConstructor.jav b/tests/testData/ast/inheritance/file/classOneExtendsBaseWithZeroParamsNonEmptyConstructor.jav new file mode 100644 index 00000000000..94f530c95a1 --- /dev/null +++ b/tests/testData/ast/inheritance/file/classOneExtendsBaseWithZeroParamsNonEmptyConstructor.jav @@ -0,0 +1,13 @@ +class Base { + Base(String name) { + } +} + +class One extends Base { + private String mySecond; + + One(String name, String second) { + super(name); + mySecond = second; + } +} \ No newline at end of file diff --git a/tests/testData/ast/inheritance/file/classOneExtendsBaseWithZeroParamsNonEmptyConstructor.kt b/tests/testData/ast/inheritance/file/classOneExtendsBaseWithZeroParamsNonEmptyConstructor.kt new file mode 100644 index 00000000000..a1f95b2666f --- /dev/null +++ b/tests/testData/ast/inheritance/file/classOneExtendsBaseWithZeroParamsNonEmptyConstructor.kt @@ -0,0 +1,8 @@ +open class Base(name : String?) { +} +open class One(name : String?, second : String?) : Base(name) { +private var mySecond : String? = null +{ +mySecond = second +} +} \ No newline at end of file diff --git a/tests/testData/ast/isOperator/expression/complicatedExpression.jav b/tests/testData/ast/isOperator/expression/complicatedExpression.jav new file mode 100644 index 00000000000..8840a8af77b --- /dev/null +++ b/tests/testData/ast/isOperator/expression/complicatedExpression.jav @@ -0,0 +1 @@ +c.getType().getName() instanceof String \ No newline at end of file diff --git a/tests/testData/ast/isOperator/expression/complicatedExpression.kt b/tests/testData/ast/isOperator/expression/complicatedExpression.kt new file mode 100644 index 00000000000..3105c369fbe --- /dev/null +++ b/tests/testData/ast/isOperator/expression/complicatedExpression.kt @@ -0,0 +1 @@ +(c.getType().getName() is String?) \ No newline at end of file diff --git a/tests/testData/ast/isOperator/expression/simpleReference.jav b/tests/testData/ast/isOperator/expression/simpleReference.jav new file mode 100644 index 00000000000..2cd30e5adf2 --- /dev/null +++ b/tests/testData/ast/isOperator/expression/simpleReference.jav @@ -0,0 +1 @@ +a instanceof String \ No newline at end of file diff --git a/tests/testData/ast/isOperator/expression/simpleReference.kt b/tests/testData/ast/isOperator/expression/simpleReference.kt new file mode 100644 index 00000000000..544cd7f6728 --- /dev/null +++ b/tests/testData/ast/isOperator/expression/simpleReference.kt @@ -0,0 +1 @@ +(a is String?) \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-1016.jav b/tests/testData/ast/issues/file/kt-1016.jav new file mode 100644 index 00000000000..2e7b3a85644 --- /dev/null +++ b/tests/testData/ast/issues/file/kt-1016.jav @@ -0,0 +1,8 @@ +package demo; + +class C { + private final int i; + public C(int i) { + this.i = i; + } +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-1016.kt b/tests/testData/ast/issues/file/kt-1016.kt new file mode 100644 index 00000000000..07cad7e659a --- /dev/null +++ b/tests/testData/ast/issues/file/kt-1016.kt @@ -0,0 +1,7 @@ +package demo +open class C(i : Int) { +private val i : Int +{ +this.i = i +} +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-1048.jav b/tests/testData/ast/issues/file/kt-1048.jav new file mode 100644 index 00000000000..0b198292616 --- /dev/null +++ b/tests/testData/ast/issues/file/kt-1048.jav @@ -0,0 +1,18 @@ +import java.util.HashMap; + +class G { + public G(T t) { + } +} + +public class Java { + void test() { + HashMap m = new HashMap(); + m.put(1, 1); + } + void test2() { + HashMap m = new HashMap(); + G g = new G(""); + G g2 = new G(""); + } +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-1048.kt b/tests/testData/ast/issues/file/kt-1048.kt new file mode 100644 index 00000000000..27544583cf0 --- /dev/null +++ b/tests/testData/ast/issues/file/kt-1048.kt @@ -0,0 +1,14 @@ +import java.util.HashMap +open class G(t : T?) { +} +public open class Java() { +open fun test() : Unit { +var m : HashMap? = HashMap() +m?.put(1, 1) +} +open fun test2() : Unit { +var m : HashMap<*, *>? = HashMap() +var g : G? = G("") +var g2 : G? = G("") +} +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-1074.jav b/tests/testData/ast/issues/file/kt-1074.jav new file mode 100644 index 00000000000..4579da0addc --- /dev/null +++ b/tests/testData/ast/issues/file/kt-1074.jav @@ -0,0 +1,13 @@ +package demo; + +class Test { + static void subListRangeCheck(int fromIndex, int toIndex, int size) { + if (fromIndex < 0) + throw new IndexOutOfBoundsException("fromIndex = " + fromIndex); + if (toIndex > size) + throw new IndexOutOfBoundsException("toIndex = " + toIndex); + if (fromIndex > toIndex) + throw new IllegalArgumentException("fromIndex(" + fromIndex + + ") > toIndex(" + toIndex + ")"); + } +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-1074.kt b/tests/testData/ast/issues/file/kt-1074.kt new file mode 100644 index 00000000000..ee08f5c2856 --- /dev/null +++ b/tests/testData/ast/issues/file/kt-1074.kt @@ -0,0 +1,13 @@ +package demo +open class Test() { +class object { +open fun subListRangeCheck(fromIndex : Int, toIndex : Int, size : Int) : Unit { +if (fromIndex < 0) +throw IndexOutOfBoundsException("fromIndex = " + fromIndex) +if (toIndex > size) +throw IndexOutOfBoundsException("toIndex = " + toIndex) +if (fromIndex > toIndex) +throw IllegalArgumentException("fromIndex(" + fromIndex + ") > toIndex(" + toIndex + ")") +} +} +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-543-boxed.jav b/tests/testData/ast/issues/file/kt-543-boxed.jav new file mode 100644 index 00000000000..e1f28f04faa --- /dev/null +++ b/tests/testData/ast/issues/file/kt-543-boxed.jav @@ -0,0 +1,13 @@ +package demo; + +class Test { + void putInt(Integer i) {} + + void test() { + byte b = 10; + putInt(b); + + Byte b2 = 10; + putInt(b2); + } +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-543-boxed.kt b/tests/testData/ast/issues/file/kt-543-boxed.kt new file mode 100644 index 00000000000..17671fb7213 --- /dev/null +++ b/tests/testData/ast/issues/file/kt-543-boxed.kt @@ -0,0 +1,11 @@ +package demo +open class Test() { +open fun putInt(i : Int?) : Unit { +} +open fun test() : Unit { +var b : Byte = 10 +putInt((b).toInt()) +var b2 : Byte? = 10 +putInt((b2).toInt()) +} +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-543-mixed.jav b/tests/testData/ast/issues/file/kt-543-mixed.jav new file mode 100644 index 00000000000..1193a5403bb --- /dev/null +++ b/tests/testData/ast/issues/file/kt-543-mixed.jav @@ -0,0 +1,10 @@ +package demo; + +class Test { + void putInt(Integer i) {} + + void test() { + int i = 10; + putInt(i); + } +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-543-mixed.kt b/tests/testData/ast/issues/file/kt-543-mixed.kt new file mode 100644 index 00000000000..b3e646c16a9 --- /dev/null +++ b/tests/testData/ast/issues/file/kt-543-mixed.kt @@ -0,0 +1,9 @@ +package demo +open class Test() { +open fun putInt(i : Int?) : Unit { +} +open fun test() : Unit { +var i : Int = 10 +putInt(i) +} +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-543.jav b/tests/testData/ast/issues/file/kt-543.jav new file mode 100644 index 00000000000..c5e0e602076 --- /dev/null +++ b/tests/testData/ast/issues/file/kt-543.jav @@ -0,0 +1,10 @@ +package demo; + +class Test { + void putInt(int i) {} + + void test() { + byte b = 10; + putInt(b); + } +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-543.kt b/tests/testData/ast/issues/file/kt-543.kt new file mode 100644 index 00000000000..380d97ae2f2 --- /dev/null +++ b/tests/testData/ast/issues/file/kt-543.kt @@ -0,0 +1,9 @@ +package demo +open class Test() { +open fun putInt(i : Int) : Unit { +} +open fun test() : Unit { +var b : Byte = 10 +putInt((b).toInt()) +} +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-638.jav b/tests/testData/ast/issues/file/kt-638.jav new file mode 100644 index 00000000000..8a5b22477da --- /dev/null +++ b/tests/testData/ast/issues/file/kt-638.jav @@ -0,0 +1,33 @@ +public class Identifier { + private final T myName; + private boolean myHasDollar; + private boolean myNullable = true; + + public Identifier(T name) { + myName = name; + } + + public Identifier(T name, boolean isNullable) { + myName = name; + myNullable = isNullable; + } + + public Identifier(T name, boolean hasDollar, boolean isNullable) { + myName = name; + myHasDollar = hasDollar; + myNullable = isNullable; + } + + @Override + public T getName() { + return myName; + } +} + +public class User { + public static void main(String[] args) { + Identifier i1 = new Identifier("name", false, true); + Identifier i2 = new Identifier("name", false); + Identifier i3 = new Identifier("name"); + } +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-638.kt b/tests/testData/ast/issues/file/kt-638.kt new file mode 100644 index 00000000000..7983c393681 --- /dev/null +++ b/tests/testData/ast/issues/file/kt-638.kt @@ -0,0 +1,38 @@ +public open class Identifier(_myName : T?, _myHasDollar : Boolean) { +private val myName : T? = null +private var myHasDollar : Boolean = false +private var myNullable : Boolean = true +public open fun getName() : T? { +return myName +} +{ +myName = _myName +myHasDollar = _myHasDollar +} +class object { +public open fun init(name : T?) : Identifier { +val __ = Identifier(name, false) +return __ +} +public open fun init(name : T?, isNullable : Boolean) : Identifier { +val __ = Identifier(name, false) +__.myNullable = isNullable +return __ +} +public open fun init(name : T?, hasDollar : Boolean, isNullable : Boolean) : Identifier { +val __ = Identifier(name, hasDollar) +__.myNullable = isNullable +return __ +} +} +} +public open class User() { +class object { +public open fun main(args : Array?) : Unit { +var i1 : Identifier<*>? = Identifier.init("name", false, true) +var i2 : Identifier? = Identifier.init("name", false) +var i3 : Identifier? = Identifier.init("name") +} +} +} +fun main(args : Array?) = User.main(args) \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-696.jav b/tests/testData/ast/issues/file/kt-696.jav new file mode 100644 index 00000000000..2a03b39aa53 --- /dev/null +++ b/tests/testData/ast/issues/file/kt-696.jav @@ -0,0 +1,35 @@ +package test; + +class Base { + @Override + public int hashCode() { + return super.hashCode(); + } + + @Override + public boolean equals(Object o) { + return super.equals(o); + } + + @Override + public String toString() { + return super.toString(); + } +} + +class Child extends Base { + @Override + public int hashCode() { + return super.hashCode(); + } + + @Override + public boolean equals(Object o) { + return super.equals(o); + } + + @Override + public String toString() { + return super.toString(); + } +} diff --git a/tests/testData/ast/issues/file/kt-696.kt b/tests/testData/ast/issues/file/kt-696.kt new file mode 100644 index 00000000000..eac7522715b --- /dev/null +++ b/tests/testData/ast/issues/file/kt-696.kt @@ -0,0 +1,23 @@ +package test +open class Base() { +public open fun hashCode() : Int { +return System.identityHashCode(this) +} +public open fun equals(o : Any?) : Boolean { +return this.identityEquals(o) +} +public open fun toString() : String? { +return getJavaClass.getName() + '@' + Integer.toHexString(hashCode()) +} +} +open class Child() : Base() { +public override fun hashCode() : Int { +return super.hashCode() +} +public override fun equals(o : Any?) : Boolean { +return super.equals(o) +} +public override fun toString() : String? { +return super.toString() +} +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-792-mixed.jav b/tests/testData/ast/issues/file/kt-792-mixed.jav new file mode 100644 index 00000000000..95fdbca8c1c --- /dev/null +++ b/tests/testData/ast/issues/file/kt-792-mixed.jav @@ -0,0 +1,11 @@ +package demo; + +class Test { + Test(Integer i) { + } + + void test() { + int i = 10; + new Test(i); + } +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-792-mixed.kt b/tests/testData/ast/issues/file/kt-792-mixed.kt new file mode 100644 index 00000000000..eac219d8c6f --- /dev/null +++ b/tests/testData/ast/issues/file/kt-792-mixed.kt @@ -0,0 +1,7 @@ +package demo +open class Test(i : Int?) { +open fun test() : Unit { +var i : Int = 10 +Test(i) +} +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-792.jav b/tests/testData/ast/issues/file/kt-792.jav new file mode 100644 index 00000000000..9c1d1cf00d9 --- /dev/null +++ b/tests/testData/ast/issues/file/kt-792.jav @@ -0,0 +1,11 @@ +package demo; + +class Test { + Test(int i) { + } + + void test() { + byte b = 10; + new Test(b); + } +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-792.kt b/tests/testData/ast/issues/file/kt-792.kt new file mode 100644 index 00000000000..18ec9156bcd --- /dev/null +++ b/tests/testData/ast/issues/file/kt-792.kt @@ -0,0 +1,7 @@ +package demo +open class Test(i : Int) { +open fun test() : Unit { +var b : Byte = 10 +Test((b).toInt()) +} +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-794-mixed.jav b/tests/testData/ast/issues/file/kt-794-mixed.jav new file mode 100644 index 00000000000..d64b41aa5a8 --- /dev/null +++ b/tests/testData/ast/issues/file/kt-794-mixed.jav @@ -0,0 +1,11 @@ +package demo; + +class Test { + Integer getInteger(Integer i) { + return i; + } + + void test() { + int i = getInteger(10); + } +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-794-mixed.kt b/tests/testData/ast/issues/file/kt-794-mixed.kt new file mode 100644 index 00000000000..f2224f10a3b --- /dev/null +++ b/tests/testData/ast/issues/file/kt-794-mixed.kt @@ -0,0 +1,9 @@ +package demo +open class Test() { +open fun getInteger(i : Int?) : Int? { +return i +} +open fun test() : Unit { +var i : Int = getInteger(10) +} +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-794.jav b/tests/testData/ast/issues/file/kt-794.jav new file mode 100644 index 00000000000..5458bce32ca --- /dev/null +++ b/tests/testData/ast/issues/file/kt-794.jav @@ -0,0 +1,6 @@ +class Test { + int getInt() { + byte b = 10; + return b; + } +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-794.kt b/tests/testData/ast/issues/file/kt-794.kt new file mode 100644 index 00000000000..61f9cc80f03 --- /dev/null +++ b/tests/testData/ast/issues/file/kt-794.kt @@ -0,0 +1,6 @@ +open class Test() { +open fun getInt() : Int { +var b : Byte = 10 +return b.toInt() +} +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-809-string.jav b/tests/testData/ast/issues/file/kt-809-string.jav new file mode 100644 index 00000000000..5e60a8c8552 --- /dev/null +++ b/tests/testData/ast/issues/file/kt-809-string.jav @@ -0,0 +1,21 @@ +package demo; + +class Container { + String myString = "1"; +} + +class One { + static Container myContainer = new Container(); +} + +class StringContainer { + StringContainer(String s) {} +} + +class Test { + void putString(String s) { } + void test() { + putString(One.myContainer.myString); + new StringContainer(One.myContainer.myString); + } +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-809-string.kt b/tests/testData/ast/issues/file/kt-809-string.kt new file mode 100644 index 00000000000..00b343142e4 --- /dev/null +++ b/tests/testData/ast/issues/file/kt-809-string.kt @@ -0,0 +1,19 @@ +package demo +open class Container() { +var myString : String? = "1" +} +open class One() { +class object { +var myContainer : Container? = Container() +} +} +open class StringContainer(s : String?) { +} +open class Test() { +open fun putString(s : String?) : Unit { +} +open fun test() : Unit { +putString(One.myContainer?.myString) +StringContainer(One.myContainer?.myString) +} +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-809.jav b/tests/testData/ast/issues/file/kt-809.jav new file mode 100644 index 00000000000..b2cc8015ee9 --- /dev/null +++ b/tests/testData/ast/issues/file/kt-809.jav @@ -0,0 +1,21 @@ +package demo; + +class Container { + int myInt = 1; +} + +class One { + static Container myContainer = new Container(); +} + +class IntContainer { + IntContainer(int i) {} +} + +class Test { + void putInt(int i) { } + void test() { + putInt(One.myContainer.myInt); + new IntContainer(One.myContainer.myInt); + } +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-809.kt b/tests/testData/ast/issues/file/kt-809.kt new file mode 100644 index 00000000000..c1b65a57a35 --- /dev/null +++ b/tests/testData/ast/issues/file/kt-809.kt @@ -0,0 +1,19 @@ +package demo +open class Container() { +var myInt : Int = 1 +} +open class One() { +class object { +var myContainer : Container? = Container() +} +} +open class IntContainer(i : Int) { +} +open class Test() { +open fun putInt(i : Int) : Unit { +} +open fun test() : Unit { +putInt((One.myContainer?.myInt).sure()) +IntContainer((One.myContainer?.myInt).sure()) +} +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-820-field.jav b/tests/testData/ast/issues/file/kt-820-field.jav new file mode 100644 index 00000000000..ca2c1588ef7 --- /dev/null +++ b/tests/testData/ast/issues/file/kt-820-field.jav @@ -0,0 +1,13 @@ +package demo; + +class Container { + int myInt = 1; +} + +class One { + static Container myContainer = new Container(); +} + +class Test { + byte b = One.myContainer.myInt; +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-820-field.kt b/tests/testData/ast/issues/file/kt-820-field.kt new file mode 100644 index 00000000000..9d7eef3e755 --- /dev/null +++ b/tests/testData/ast/issues/file/kt-820-field.kt @@ -0,0 +1,12 @@ +package demo +open class Container() { +var myInt : Int = 1 +} +open class One() { +class object { +var myContainer : Container? = Container() +} +} +open class Test() { +var b : Byte = One.myContainer?.myInt.sure().toByte() +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-820-string.jav b/tests/testData/ast/issues/file/kt-820-string.jav new file mode 100644 index 00000000000..9bc81004c38 --- /dev/null +++ b/tests/testData/ast/issues/file/kt-820-string.jav @@ -0,0 +1,6 @@ +class Test { + public static String toFileSystemSafeName(String name) { + int size = name.length(); + return name; + } +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-820-string.kt b/tests/testData/ast/issues/file/kt-820-string.kt new file mode 100644 index 00000000000..6435b2931fc --- /dev/null +++ b/tests/testData/ast/issues/file/kt-820-string.kt @@ -0,0 +1,8 @@ +open class Test() { +class object { +public open fun toFileSystemSafeName(name : String?) : String? { +var size : Int = name?.length().sure() +return name +} +} +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-820.jav b/tests/testData/ast/issues/file/kt-820.jav new file mode 100644 index 00000000000..20ac0acdb97 --- /dev/null +++ b/tests/testData/ast/issues/file/kt-820.jav @@ -0,0 +1,15 @@ +package demo; + +class Container { + int myInt = 1; +} + +class One { + static Container myContainer = new Container(); +} + +class Test { + void test() { + byte b = One.myContainer.myInt; + } +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-820.kt b/tests/testData/ast/issues/file/kt-820.kt new file mode 100644 index 00000000000..00e4569f962 --- /dev/null +++ b/tests/testData/ast/issues/file/kt-820.kt @@ -0,0 +1,14 @@ +package demo +open class Container() { +var myInt : Int = 1 +} +open class One() { +class object { +var myContainer : Container? = Container() +} +} +open class Test() { +open fun test() : Unit { +var b : Byte = One.myContainer?.myInt.sure().toByte() +} +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-824-isDir.jav b/tests/testData/ast/issues/file/kt-824-isDir.jav new file mode 100644 index 00000000000..3429c9be45f --- /dev/null +++ b/tests/testData/ast/issues/file/kt-824-isDir.jav @@ -0,0 +1,18 @@ +package test; +import java.io.File; + +/** + * User: ignatov + */ +public class Test { + public static boolean isDir(File parent) { + if (parent == null || !parent.exists()) { + return false; + } + boolean result = true; + if (parent.isDirectory()) { + return true; + } else + return false; + } +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-824-isDir.kt b/tests/testData/ast/issues/file/kt-824-isDir.kt new file mode 100644 index 00000000000..602192f2868 --- /dev/null +++ b/tests/testData/ast/issues/file/kt-824-isDir.kt @@ -0,0 +1,19 @@ +package test +import java.io.File +public open class Test() { +class object { +public open fun isDir(parent : File?) : Boolean { +if (parent == null || !parent?.exists()) +{ +return false +} +var result : Boolean = true +if (parent?.isDirectory().sure()) +{ +return true +} +else +return false +} +} +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-824.jav b/tests/testData/ast/issues/file/kt-824.jav new file mode 100644 index 00000000000..4e0a95754fd --- /dev/null +++ b/tests/testData/ast/issues/file/kt-824.jav @@ -0,0 +1,25 @@ +package demo; + +class Container { + boolean myBoolean = true; +} + +class One { + static Container myContainer = new Container(); +} + +class Test { + void test() { + if (One.myContainer.myBoolean) + System.out.println("Ok"); + + String s = One.myContainer.myBoolean ? "YES" : "NO"; + + while (One.myContainer.myBoolean) + System.out.println("Ok"); + + do { + System.out.println("Ok"); + } while (One.myContainer.myBoolean) + } +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-824.kt b/tests/testData/ast/issues/file/kt-824.kt new file mode 100644 index 00000000000..a0e38dbf3e7 --- /dev/null +++ b/tests/testData/ast/issues/file/kt-824.kt @@ -0,0 +1,26 @@ +package demo +open class Container() { +var myBoolean : Boolean = true +} +open class One() { +class object { +var myContainer : Container? = Container() +} +} +open class Test() { +open fun test() : Unit { +if (One.myContainer?.myBoolean.sure()) +System.out?.println("Ok") +var s : String? = (if (One.myContainer?.myBoolean.sure()) +"YES" +else +"NO") +while (One.myContainer?.myBoolean.sure()) +System.out?.println("Ok") +do +{ +System.out?.println("Ok") +} +while (One.myContainer?.myBoolean.sure()) +} +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-828.jav b/tests/testData/ast/issues/file/kt-828.jav new file mode 100644 index 00000000000..682975f22e0 --- /dev/null +++ b/tests/testData/ast/issues/file/kt-828.jav @@ -0,0 +1,15 @@ +class Test { + void test() { + boolean res = true; + res &= false; + res |= false; + res ^= false; + System.out.println(true & false); + System.out.println(true | false); + System.out.println(true ^ false); + System.out.println(!true); + + System.out.println(true && false); + System.out.println(true || false); + } +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-828.kt b/tests/testData/ast/issues/file/kt-828.kt new file mode 100644 index 00000000000..62ec4f7e4f1 --- /dev/null +++ b/tests/testData/ast/issues/file/kt-828.kt @@ -0,0 +1,14 @@ +open class Test() { +open fun test() : Unit { +var res : Boolean = true +res = res and false +res = res or false +res = res xor false +System.out?.println(true and false) +System.out?.println(true or false) +System.out?.println(true xor false) +System.out?.println(!true) +System.out?.println(true && false) +System.out?.println(true || false) +} +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-836.jav b/tests/testData/ast/issues/file/kt-836.jav new file mode 100644 index 00000000000..99d0b460e3a --- /dev/null +++ b/tests/testData/ast/issues/file/kt-836.jav @@ -0,0 +1,30 @@ +package com.voltvoodoo.saplo4j.model; + +import java.io.Serializable; + +public class Language implements Serializable { + protected String code; + + public Language(String code) { + this.code = code; + } + + public String toString() { + return this.code; + } +} + + +class Base { + void test() {} + String toString() { + return "BASE"; + } +} + +class Child extends Base { + void test() {} + String toString() { + return "Child"; + } +} diff --git a/tests/testData/ast/issues/file/kt-836.kt b/tests/testData/ast/issues/file/kt-836.kt new file mode 100644 index 00000000000..2a1ba4c5786 --- /dev/null +++ b/tests/testData/ast/issues/file/kt-836.kt @@ -0,0 +1,25 @@ +package com.voltvoodoo.saplo4j.model +import java.io.Serializable +public open class Language(code : String?) : Serializable { +protected var code : String? = null +public override fun toString() : String? { +return this.code +} +{ +this.code = code +} +} +open class Base() { +open fun test() : Unit { +} +open fun toString() : String? { +return "BASE" +} +} +open class Child() : Base() { +override fun test() : Unit { +} +override fun toString() : String? { +return "Child" +} +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-837.jav b/tests/testData/ast/issues/file/kt-837.jav new file mode 100644 index 00000000000..c1f41afeccf --- /dev/null +++ b/tests/testData/ast/issues/file/kt-837.jav @@ -0,0 +1,19 @@ +package com.voltvoodoo.saplo4j.model; + +import java.io.Serializable; + +public class Language implements Serializable { + public static Language ENGLISH = new Language("en"); + public static Language SWEDISH = new Language("sv"); + + protected String code; + private static final long serialVersionUID = -2442762969929206780L; + + public Language(String code) { + this.code = code; + } + + public boolean equals(Language other) { + return other.toString().equals(this.toString()); + } +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-837.kt b/tests/testData/ast/issues/file/kt-837.kt new file mode 100644 index 00000000000..af3b65fe3be --- /dev/null +++ b/tests/testData/ast/issues/file/kt-837.kt @@ -0,0 +1,16 @@ +package com.voltvoodoo.saplo4j.model +import java.io.Serializable +public open class Language(code : String?) : Serializable { +protected var code : String? = null +public open fun equals(other : Language?) : Boolean { +return other?.toString()?.equals(this.toString()).sure() +} +{ +this.code = code +} +class object { +public var ENGLISH : Language? = Language("en") +public var SWEDISH : Language? = Language("sv") +private val serialVersionUID : Long = -2442762969929206780 +} +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-852.jav b/tests/testData/ast/issues/file/kt-852.jav new file mode 100644 index 00000000000..b9abf40fe36 --- /dev/null +++ b/tests/testData/ast/issues/file/kt-852.jav @@ -0,0 +1,16 @@ +package demo; + +class Test { + String test() { + String s1 = ""; + String s2 = ""; + String s3 = ""; + if (s1.isEmpty() && s2.isEmpty()) + return "OK"; + + if (s1.isEmpty() && s2.isEmpty() && s3.isEmpty()) + return "OOOK"; + + return ""; + } +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-852.kt b/tests/testData/ast/issues/file/kt-852.kt new file mode 100644 index 00000000000..67038cd5c1a --- /dev/null +++ b/tests/testData/ast/issues/file/kt-852.kt @@ -0,0 +1,13 @@ +package demo +open class Test() { +open fun test() : String? { +var s1 : String? = "" +var s2 : String? = "" +var s3 : String? = "" +if ((s1?.isEmpty()).sure() && (s2?.isEmpty()).sure()) +return "OK" +if ((s1?.isEmpty()).sure() && (s2?.isEmpty()).sure() && (s3?.isEmpty()).sure()) +return "OOOK" +return "" +} +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-871.jav b/tests/testData/ast/issues/file/kt-871.jav new file mode 100644 index 00000000000..b49b8041fc5 --- /dev/null +++ b/tests/testData/ast/issues/file/kt-871.jav @@ -0,0 +1,7 @@ +package demo; + +class Program { + public static void main(String[] args) { + System.out.println("Halo!"); + } +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-871.kt b/tests/testData/ast/issues/file/kt-871.kt new file mode 100644 index 00000000000..6af74ed4561 --- /dev/null +++ b/tests/testData/ast/issues/file/kt-871.kt @@ -0,0 +1,9 @@ +package demo +open class Program() { +class object { +public open fun main(args : Array?) : Unit { +System.out?.println("Halo!") +} +} +} +fun main(args : Array?) = Program.main(args) \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-879.jav b/tests/testData/ast/issues/file/kt-879.jav new file mode 100644 index 00000000000..bd55559a3d8 --- /dev/null +++ b/tests/testData/ast/issues/file/kt-879.jav @@ -0,0 +1,16 @@ +class Test { + public static int getInt(int i) { + switch (i) { + case 0: + return 0; + case 1: + return 1; + case 2: + return 2; + case 3: + return 3; + default: + return -1; + } + } +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-879.kt b/tests/testData/ast/issues/file/kt-879.kt new file mode 100644 index 00000000000..2fb5abe82a5 --- /dev/null +++ b/tests/testData/ast/issues/file/kt-879.kt @@ -0,0 +1,23 @@ +open class Test() { +class object { +public open fun getInt(i : Int) : Int { +when (i) { +0 -> { +return 0 +} +1 -> { +return 1 +} +2 -> { +return 2 +} +3 -> { +return 3 +} +else -> { +return -1 +} +} +} +} +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-893.jav b/tests/testData/ast/issues/file/kt-893.jav new file mode 100644 index 00000000000..8637f952b7e --- /dev/null +++ b/tests/testData/ast/issues/file/kt-893.jav @@ -0,0 +1,9 @@ +package demo; + +class Test { + void test() { + for(int i = 0; i < 10; ++i) { + System.out.println(i) + } + } +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-893.kt b/tests/testData/ast/issues/file/kt-893.kt new file mode 100644 index 00000000000..1c1c545a9a5 --- /dev/null +++ b/tests/testData/ast/issues/file/kt-893.kt @@ -0,0 +1,8 @@ +package demo +open class Test() { +open fun test() : Unit { +for (i in 0..10 - 1) { +System.out?.println(i) +} +} +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-963.jav b/tests/testData/ast/issues/file/kt-963.jav new file mode 100644 index 00000000000..9e2cbb3e114 --- /dev/null +++ b/tests/testData/ast/issues/file/kt-963.jav @@ -0,0 +1,8 @@ +package demo; + +class C { + public C(int a) { + abc = a * 2; + } + int abc = 0; +} \ No newline at end of file diff --git a/tests/testData/ast/issues/file/kt-963.kt b/tests/testData/ast/issues/file/kt-963.kt new file mode 100644 index 00000000000..d921cbb041a --- /dev/null +++ b/tests/testData/ast/issues/file/kt-963.kt @@ -0,0 +1,7 @@ +package demo +open class C(a : Int) { +var abc : Int = 0 +{ +abc = a * 2 +} +} \ No newline at end of file diff --git a/tests/testData/ast/kotlinExclusion/file/kt-656.jav b/tests/testData/ast/kotlinExclusion/file/kt-656.jav new file mode 100644 index 00000000000..1c05dc9b7be --- /dev/null +++ b/tests/testData/ast/kotlinExclusion/file/kt-656.jav @@ -0,0 +1,27 @@ +package demo; + +import java.util.Iterator; + +class Test implements Iterable { + @Override + public Iterator iterator() { + return null; + } + + public Iterator push(Iterator i) { + Iterator j = i; + return j; + } +} + +class FullTest implements java.lang.Iterable { + @Override + public java.util.Iterator iterator() { + return null; + } + + public java.util.Iterator push(java.util.Iterator i) { + java.util.Iterator j = i; + return j; + } +} \ No newline at end of file diff --git a/tests/testData/ast/kotlinExclusion/file/kt-656.kt b/tests/testData/ast/kotlinExclusion/file/kt-656.kt new file mode 100644 index 00000000000..41730ccc3c6 --- /dev/null +++ b/tests/testData/ast/kotlinExclusion/file/kt-656.kt @@ -0,0 +1,20 @@ +package demo +import java.util.Iterator +open class Test() : java.lang.Iterable { +public override fun iterator() : java.util.Iterator? { +return null +} +public open fun push(i : java.util.Iterator?) : java.util.Iterator? { +var j : java.util.Iterator? = i +return j +} +} +open class FullTest() : java.lang.Iterable { +public override fun iterator() : java.util.Iterator? { +return null +} +public open fun push(i : java.util.Iterator?) : java.util.Iterator? { +var j : java.util.Iterator? = i +return j +} +} \ No newline at end of file diff --git a/tests/testData/ast/labelStatement/statement/complicatedExampleFromJavaTutorial.jav b/tests/testData/ast/labelStatement/statement/complicatedExampleFromJavaTutorial.jav new file mode 100644 index 00000000000..5c8ac99dd07 --- /dev/null +++ b/tests/testData/ast/labelStatement/statement/complicatedExampleFromJavaTutorial.jav @@ -0,0 +1 @@ + test: for (int i = 0; i <= max; i++) { int n = substring.length(); int j = i; int k = 0; while (n-- != 0) { if (searchMe.charAt(j++) != substring.charAt(k++)) { continue test; } } foundIt = true; break test; } System.out.println(foundIt ? "Found it" : "Didn't find it"); }} \ No newline at end of file diff --git a/tests/testData/ast/labelStatement/statement/complicatedExampleFromJavaTutorial.kt b/tests/testData/ast/labelStatement/statement/complicatedExampleFromJavaTutorial.kt new file mode 100644 index 00000000000..a2e5946c884 --- /dev/null +++ b/tests/testData/ast/labelStatement/statement/complicatedExampleFromJavaTutorial.kt @@ -0,0 +1,18 @@ +@test for (i in 0..max) { +var n : Int = substring.length() +var j : Int = i +var k : Int = 0 +while (n-- != 0) +{ +if (searchMe.charAt(j++) != substring.charAt(k++)) +{ +continue@test +} +} +foundIt = true +break@test +} +System.out?.println((if (foundIt) +"Found it" +else +"Didn't find it")) \ No newline at end of file diff --git a/tests/testData/ast/literalExpression/file/char.jav b/tests/testData/ast/literalExpression/file/char.jav new file mode 100644 index 00000000000..653706393b2 --- /dev/null +++ b/tests/testData/ast/literalExpression/file/char.jav @@ -0,0 +1,6 @@ +class Test { + void test() { + char c1 = 'c'; + Character c2 = 'C'; + } +} \ No newline at end of file diff --git a/tests/testData/ast/literalExpression/file/char.kt b/tests/testData/ast/literalExpression/file/char.kt new file mode 100644 index 00000000000..681dfca3a2a --- /dev/null +++ b/tests/testData/ast/literalExpression/file/char.kt @@ -0,0 +1,6 @@ +open class Test() { +open fun test() : Unit { +var c1 : Char = 'c' +var c2 : Char? = 'C' +} +} \ No newline at end of file diff --git a/tests/testData/ast/literalExpression/file/dollarInsideString.jav b/tests/testData/ast/literalExpression/file/dollarInsideString.jav new file mode 100644 index 00000000000..51039d40d25 --- /dev/null +++ b/tests/testData/ast/literalExpression/file/dollarInsideString.jav @@ -0,0 +1,14 @@ +package demo; + +class Test { + void test() { + String name = "$$$$"; + name = name.replaceAll("\\$[0-9]+", "\\$") + + char c = '$'; + System.out.println(c); + + Character C = '$'; + System.out.println(C); + } +} \ No newline at end of file diff --git a/tests/testData/ast/literalExpression/file/dollarInsideString.kt b/tests/testData/ast/literalExpression/file/dollarInsideString.kt new file mode 100644 index 00000000000..643aab84188 --- /dev/null +++ b/tests/testData/ast/literalExpression/file/dollarInsideString.kt @@ -0,0 +1,11 @@ +package demo +open class Test() { +open fun test() : Unit { +var name : String? = "$$$$" +name = name?.replaceAll("\\$[0-9]+", "\\$") +var c : Char = '$' +System.out?.println(c) +var C : Char? = '$' +System.out?.println(C) +} +} \ No newline at end of file diff --git a/tests/testData/ast/literalExpression/file/endsWithDFL.jav b/tests/testData/ast/literalExpression/file/endsWithDFL.jav new file mode 100644 index 00000000000..4b4450d3303 --- /dev/null +++ b/tests/testData/ast/literalExpression/file/endsWithDFL.jav @@ -0,0 +1,21 @@ +class Test { + void test() { + long l1 = 10L; + double d1 = 10.0D; + float f1 = 10.0F; + + long l2 = 10l; + double d2 = 10.0d; + float f2 = 10.0f; + } + + void testBoxed() { + Long l1 = 10L; + Double d1 = 10.0D; + Float f1 = 10.0F; + + Long l2 = 10l; + Double d2 = 10.0d; + Float f2 = 10.0f; + } +} \ No newline at end of file diff --git a/tests/testData/ast/literalExpression/file/endsWithDFL.kt b/tests/testData/ast/literalExpression/file/endsWithDFL.kt new file mode 100644 index 00000000000..21a178c18ce --- /dev/null +++ b/tests/testData/ast/literalExpression/file/endsWithDFL.kt @@ -0,0 +1,18 @@ +open class Test() { +open fun test() : Unit { +var l1 : Long = 10 +var d1 : Double = 10.0 +var f1 : Float = 10.0.toFloat() +var l2 : Long = 10 +var d2 : Double = 10.0 +var f2 : Float = 10.0.toFloat() +} +open fun testBoxed() : Unit { +var l1 : Long? = 10 +var d1 : Double? = 10.0 +var f1 : Float? = 10.0.toFloat() +var l2 : Long? = 10 +var d2 : Double? = 10.0 +var f2 : Float? = 10.0.toFloat() +} +} \ No newline at end of file diff --git a/tests/testData/ast/literalExpression/file/hex.jav b/tests/testData/ast/literalExpression/file/hex.jav new file mode 100644 index 00000000000..285af379ea2 --- /dev/null +++ b/tests/testData/ast/literalExpression/file/hex.jav @@ -0,0 +1,6 @@ +class Test { + void test() { + int i1 = 0x21; + Int i2 = 0x33; + } +} \ No newline at end of file diff --git a/tests/testData/ast/literalExpression/file/hex.kt b/tests/testData/ast/literalExpression/file/hex.kt new file mode 100644 index 00000000000..71c7898650f --- /dev/null +++ b/tests/testData/ast/literalExpression/file/hex.kt @@ -0,0 +1,6 @@ +open class Test() { +open fun test() : Unit { +var i1 : Int = 33 +var i2 : Int? = 51 +} +} \ No newline at end of file diff --git a/tests/testData/ast/literalExpression/file/octal.jav b/tests/testData/ast/literalExpression/file/octal.jav new file mode 100644 index 00000000000..900549670fb --- /dev/null +++ b/tests/testData/ast/literalExpression/file/octal.jav @@ -0,0 +1,6 @@ +class Test { + void test() { + int i1 = 045; + Int i2 = 032; + } +} \ No newline at end of file diff --git a/tests/testData/ast/literalExpression/file/octal.kt b/tests/testData/ast/literalExpression/file/octal.kt new file mode 100644 index 00000000000..78f7d81ce13 --- /dev/null +++ b/tests/testData/ast/literalExpression/file/octal.kt @@ -0,0 +1,6 @@ +open class Test() { +open fun test() : Unit { +var i1 : Int = 37 +var i2 : Int? = 26 +} +} \ No newline at end of file diff --git a/tests/testData/ast/literalExpression/file/trueOrFalse.jav b/tests/testData/ast/literalExpression/file/trueOrFalse.jav new file mode 100644 index 00000000000..2b6495e3427 --- /dev/null +++ b/tests/testData/ast/literalExpression/file/trueOrFalse.jav @@ -0,0 +1,9 @@ +class Test { + void test() { + boolean t1 = true; + Boolean t2 = true; + + boolean f1 = false; + Boolean f2 = false; + } +} \ No newline at end of file diff --git a/tests/testData/ast/literalExpression/file/trueOrFalse.kt b/tests/testData/ast/literalExpression/file/trueOrFalse.kt new file mode 100644 index 00000000000..58ab3c7464c --- /dev/null +++ b/tests/testData/ast/literalExpression/file/trueOrFalse.kt @@ -0,0 +1,8 @@ +open class Test() { +open fun test() : Unit { +var t1 : Boolean = true +var t2 : Boolean? = true +var f1 : Boolean = false +var f2 : Boolean? = false +} +} \ No newline at end of file diff --git a/tests/testData/ast/localVariable/statement/object.jav b/tests/testData/ast/localVariable/statement/object.jav new file mode 100644 index 00000000000..c9cd10a31fd --- /dev/null +++ b/tests/testData/ast/localVariable/statement/object.jav @@ -0,0 +1 @@ +int i; \ No newline at end of file diff --git a/tests/testData/ast/localVariable/statement/object.kt b/tests/testData/ast/localVariable/statement/object.kt new file mode 100644 index 00000000000..03ab5111a88 --- /dev/null +++ b/tests/testData/ast/localVariable/statement/object.kt @@ -0,0 +1 @@ +var i : Int \ No newline at end of file diff --git a/tests/testData/ast/methodCallExpression/file/genericMethod.jav b/tests/testData/ast/methodCallExpression/file/genericMethod.jav new file mode 100644 index 00000000000..952645f5f09 --- /dev/null +++ b/tests/testData/ast/methodCallExpression/file/genericMethod.jav @@ -0,0 +1,12 @@ +package demo; + +class Map { + void put(K k, V v) {} +} + +class U { + void test() { + Map m = new Map(); + m.put("10", 10); + } +} \ No newline at end of file diff --git a/tests/testData/ast/methodCallExpression/file/genericMethod.kt b/tests/testData/ast/methodCallExpression/file/genericMethod.kt new file mode 100644 index 00000000000..47c2f73a646 --- /dev/null +++ b/tests/testData/ast/methodCallExpression/file/genericMethod.kt @@ -0,0 +1,11 @@ +package demo +open class Map() { +open fun put(k : K?, v : V?) : Unit { +} +} +open class U() { +open fun test() : Unit { +var m : Map? = Map() +m?.put("10", 10) +} +} \ No newline at end of file diff --git a/tests/testData/ast/methodCallExpression/statement/callWithKeywords.jav b/tests/testData/ast/methodCallExpression/statement/callWithKeywords.jav new file mode 100644 index 00000000000..db350dda8fc --- /dev/null +++ b/tests/testData/ast/methodCallExpression/statement/callWithKeywords.jav @@ -0,0 +1 @@ +when(open, trait); \ No newline at end of file diff --git a/tests/testData/ast/methodCallExpression/statement/callWithKeywords.kt b/tests/testData/ast/methodCallExpression/statement/callWithKeywords.kt new file mode 100644 index 00000000000..489e2d97b10 --- /dev/null +++ b/tests/testData/ast/methodCallExpression/statement/callWithKeywords.kt @@ -0,0 +1 @@ +`when`(open, `trait`) \ No newline at end of file diff --git a/tests/testData/ast/methodCallExpression/statement/emptyCall.jav b/tests/testData/ast/methodCallExpression/statement/emptyCall.jav new file mode 100644 index 00000000000..9c6af147cda --- /dev/null +++ b/tests/testData/ast/methodCallExpression/statement/emptyCall.jav @@ -0,0 +1 @@ +methodCall(); \ No newline at end of file diff --git a/tests/testData/ast/methodCallExpression/statement/emptyCall.kt b/tests/testData/ast/methodCallExpression/statement/emptyCall.kt new file mode 100644 index 00000000000..60d495be000 --- /dev/null +++ b/tests/testData/ast/methodCallExpression/statement/emptyCall.kt @@ -0,0 +1 @@ +methodCall() \ No newline at end of file diff --git a/tests/testData/ast/methodCallExpression/statement/simpleCall.jav b/tests/testData/ast/methodCallExpression/statement/simpleCall.jav new file mode 100644 index 00000000000..0e52b457e69 --- /dev/null +++ b/tests/testData/ast/methodCallExpression/statement/simpleCall.jav @@ -0,0 +1 @@ +method(param1, param2); \ No newline at end of file diff --git a/tests/testData/ast/methodCallExpression/statement/simpleCall.kt b/tests/testData/ast/methodCallExpression/statement/simpleCall.kt new file mode 100644 index 00000000000..43ea8339772 --- /dev/null +++ b/tests/testData/ast/methodCallExpression/statement/simpleCall.kt @@ -0,0 +1 @@ +method(param1, param2) \ No newline at end of file diff --git a/tests/testData/ast/newClassExpression/expression/classWithParam.jav b/tests/testData/ast/newClassExpression/expression/classWithParam.jav new file mode 100644 index 00000000000..44849d3495c --- /dev/null +++ b/tests/testData/ast/newClassExpression/expression/classWithParam.jav @@ -0,0 +1 @@ +new Foo(param); \ No newline at end of file diff --git a/tests/testData/ast/newClassExpression/expression/classWithParam.kt b/tests/testData/ast/newClassExpression/expression/classWithParam.kt new file mode 100644 index 00000000000..9d29e159e31 --- /dev/null +++ b/tests/testData/ast/newClassExpression/expression/classWithParam.kt @@ -0,0 +1 @@ +Foo(param) \ No newline at end of file diff --git a/tests/testData/ast/newClassExpression/expression/classWithParams.jav b/tests/testData/ast/newClassExpression/expression/classWithParams.jav new file mode 100644 index 00000000000..2461539a170 --- /dev/null +++ b/tests/testData/ast/newClassExpression/expression/classWithParams.jav @@ -0,0 +1 @@ +new Foo(param1, param2); \ No newline at end of file diff --git a/tests/testData/ast/newClassExpression/expression/classWithParams.kt b/tests/testData/ast/newClassExpression/expression/classWithParams.kt new file mode 100644 index 00000000000..e10fb436db2 --- /dev/null +++ b/tests/testData/ast/newClassExpression/expression/classWithParams.kt @@ -0,0 +1 @@ +Foo(param1, param2) \ No newline at end of file diff --git a/tests/testData/ast/newClassExpression/expression/classWithoutBody.jav b/tests/testData/ast/newClassExpression/expression/classWithoutBody.jav new file mode 100644 index 00000000000..acad3c2ee3f --- /dev/null +++ b/tests/testData/ast/newClassExpression/expression/classWithoutBody.jav @@ -0,0 +1 @@ +new Foo(); \ No newline at end of file diff --git a/tests/testData/ast/newClassExpression/expression/classWithoutBody.kt b/tests/testData/ast/newClassExpression/expression/classWithoutBody.kt new file mode 100644 index 00000000000..17f280dc444 --- /dev/null +++ b/tests/testData/ast/newClassExpression/expression/classWithoutBody.kt @@ -0,0 +1 @@ +Foo() \ No newline at end of file diff --git a/tests/testData/ast/newClassExpression/expression/newClassWithAnonymousScope.jav b/tests/testData/ast/newClassExpression/expression/newClassWithAnonymousScope.jav new file mode 100644 index 00000000000..fd947e43a0c --- /dev/null +++ b/tests/testData/ast/newClassExpression/expression/newClassWithAnonymousScope.jav @@ -0,0 +1,6 @@ +new Runnable() { + @Override + public void run() { + System.out.println("Run"); + } +}; \ No newline at end of file diff --git a/tests/testData/ast/newClassExpression/expression/newClassWithAnonymousScope.kt b/tests/testData/ast/newClassExpression/expression/newClassWithAnonymousScope.kt new file mode 100644 index 00000000000..1d1d845045a --- /dev/null +++ b/tests/testData/ast/newClassExpression/expression/newClassWithAnonymousScope.kt @@ -0,0 +1,5 @@ +object : Runnable() { +public override fun run() : Unit { +System.out?.println("Run") +} +} \ No newline at end of file diff --git a/tests/testData/ast/newClassExpression/file/fullQualifiedName.jav b/tests/testData/ast/newClassExpression/file/fullQualifiedName.jav new file mode 100644 index 00000000000..de1ff2bd28c --- /dev/null +++ b/tests/testData/ast/newClassExpression/file/fullQualifiedName.jav @@ -0,0 +1,9 @@ +package test; + +import java.util.List; + +class User { + void main() { + List list = new java.util.LinkedList(); + } +} \ No newline at end of file diff --git a/tests/testData/ast/newClassExpression/file/fullQualifiedName.kt b/tests/testData/ast/newClassExpression/file/fullQualifiedName.kt new file mode 100644 index 00000000000..76f45175c6e --- /dev/null +++ b/tests/testData/ast/newClassExpression/file/fullQualifiedName.kt @@ -0,0 +1,7 @@ +package test +import java.util.List +open class User() { +open fun main() : Unit { +var list : List? = java.util.LinkedList() +} +} \ No newline at end of file diff --git a/tests/testData/ast/newClassExpression/file/fullQualifiedName2.jav b/tests/testData/ast/newClassExpression/file/fullQualifiedName2.jav new file mode 100644 index 00000000000..e8ef97b8b9e --- /dev/null +++ b/tests/testData/ast/newClassExpression/file/fullQualifiedName2.jav @@ -0,0 +1,7 @@ +package test; + +class User { + void main() { + java.util.List list = new java.util.LinkedList(); + } +} \ No newline at end of file diff --git a/tests/testData/ast/newClassExpression/file/fullQualifiedName2.kt b/tests/testData/ast/newClassExpression/file/fullQualifiedName2.kt new file mode 100644 index 00000000000..08358dcfd43 --- /dev/null +++ b/tests/testData/ast/newClassExpression/file/fullQualifiedName2.kt @@ -0,0 +1,6 @@ +package test +open class User() { +open fun main() : Unit { +var list : java.util.List? = java.util.LinkedList() +} +} \ No newline at end of file diff --git a/tests/testData/ast/newClassExpression/file/genericClassInvocation.jav b/tests/testData/ast/newClassExpression/file/genericClassInvocation.jav new file mode 100644 index 00000000000..a74e92a8bc5 --- /dev/null +++ b/tests/testData/ast/newClassExpression/file/genericClassInvocation.jav @@ -0,0 +1,8 @@ +import java.util.List; +import java.util.LinkedList; + +class User { + void main() { + List list = new LinkedList(); + } +} \ No newline at end of file diff --git a/tests/testData/ast/newClassExpression/file/genericClassInvocation.kt b/tests/testData/ast/newClassExpression/file/genericClassInvocation.kt new file mode 100644 index 00000000000..613584ee471 --- /dev/null +++ b/tests/testData/ast/newClassExpression/file/genericClassInvocation.kt @@ -0,0 +1,7 @@ +import java.util.List +import java.util.LinkedList +open class User() { +open fun main() : Unit { +var list : List? = LinkedList() +} +} \ No newline at end of file diff --git a/tests/testData/ast/newClassExpression/file/newClassByFullName.jav b/tests/testData/ast/newClassExpression/file/newClassByFullName.jav new file mode 100644 index 00000000000..486db1bec93 --- /dev/null +++ b/tests/testData/ast/newClassExpression/file/newClassByFullName.jav @@ -0,0 +1,10 @@ +package org.test + +class Library {} +} + +class User { + void main() { + Library lib = new Library(); + } +} \ No newline at end of file diff --git a/tests/testData/ast/newClassExpression/file/newClassByFullName.kt b/tests/testData/ast/newClassExpression/file/newClassByFullName.kt new file mode 100644 index 00000000000..49208751d9d --- /dev/null +++ b/tests/testData/ast/newClassExpression/file/newClassByFullName.kt @@ -0,0 +1,8 @@ +package org.test +open class Library() { +} +open class User() { +open fun main() : Unit { +var lib : Library? = Library() +} +} \ No newline at end of file diff --git a/tests/testData/ast/newClassExpression/file/newInnerClass.jav b/tests/testData/ast/newClassExpression/file/newInnerClass.jav new file mode 100644 index 00000000000..1f4cdf9f589 --- /dev/null +++ b/tests/testData/ast/newClassExpression/file/newInnerClass.jav @@ -0,0 +1,13 @@ +package org.test; + +class OuterClass { + class InnerClass { + } +} + +class User { + void main() { + OuterClass outerObject = new OuterClass(); + OuterClass.InnerClass innerObject = outerObject.new InnerClass(); + } +} \ No newline at end of file diff --git a/tests/testData/ast/newClassExpression/file/newInnerClass.kt b/tests/testData/ast/newClassExpression/file/newInnerClass.kt new file mode 100644 index 00000000000..1b563c85428 --- /dev/null +++ b/tests/testData/ast/newClassExpression/file/newInnerClass.kt @@ -0,0 +1,11 @@ +package org.test +open class OuterClass() { +open class InnerClass() { +} +} +open class User() { +open fun main() : Unit { +var outerObject : OuterClass? = OuterClass() +var innerObject : OuterClass.InnerClass? = outerObject?.InnerClass() +} +} \ No newline at end of file diff --git a/tests/testData/ast/newClassExpression/file/newListAndNewMember.jav b/tests/testData/ast/newClassExpression/file/newListAndNewMember.jav new file mode 100644 index 00000000000..8ed2bad7297 --- /dev/null +++ b/tests/testData/ast/newClassExpression/file/newListAndNewMember.jav @@ -0,0 +1,13 @@ +package org.test; + +import java.util.List; +import java.util.LinkedList; + +class Member {} + +class User { + void main() { + List members = new LinkedList(); + members.add(new Member()); + } +} \ No newline at end of file diff --git a/tests/testData/ast/newClassExpression/file/newListAndNewMember.kt b/tests/testData/ast/newClassExpression/file/newListAndNewMember.kt new file mode 100644 index 00000000000..a81e9efb3ec --- /dev/null +++ b/tests/testData/ast/newClassExpression/file/newListAndNewMember.kt @@ -0,0 +1,11 @@ +package org.test +import java.util.List +import java.util.LinkedList +open class Member() { +} +open class User() { +open fun main() : Unit { +var members : List? = LinkedList() +members?.add(Member()) +} +} \ No newline at end of file diff --git a/tests/testData/ast/newClassExpression/file/newStaticInnerClass.jav b/tests/testData/ast/newClassExpression/file/newStaticInnerClass.jav new file mode 100644 index 00000000000..0465c7498aa --- /dev/null +++ b/tests/testData/ast/newClassExpression/file/newStaticInnerClass.jav @@ -0,0 +1,11 @@ +package demo; + +class Foo { + static class Bar {} +} + +class User { + void main() { + Foo.Bar boo = new Foo.Bar(); + } +} \ No newline at end of file diff --git a/tests/testData/ast/newClassExpression/file/newStaticInnerClass.kt b/tests/testData/ast/newClassExpression/file/newStaticInnerClass.kt new file mode 100644 index 00000000000..89d4f149311 --- /dev/null +++ b/tests/testData/ast/newClassExpression/file/newStaticInnerClass.kt @@ -0,0 +1,12 @@ +package demo +open class Foo() { +class object { +open class Bar() { +} +} +} +open class User() { +open fun main() : Unit { +var boo : Foo.Bar? = Foo.Bar() +} +} \ No newline at end of file diff --git a/tests/testData/ast/objectLiteral/file/MyFrame.jav b/tests/testData/ast/objectLiteral/file/MyFrame.jav new file mode 100644 index 00000000000..28e0dbef4de --- /dev/null +++ b/tests/testData/ast/objectLiteral/file/MyFrame.jav @@ -0,0 +1,24 @@ +package demo; + +class WindowAdapter { + public void windowClosing () { + } +} + +public final class Client extends Frame { + Client() { + WindowAdapter a = new WindowAdapter() { + @Override + public void windowClosing () { + } + } + + addWindowListener(a); + + addWindowListener(new WindowAdapter() { + @Override + public void windowClosing () { + } + }); + } +} \ No newline at end of file diff --git a/tests/testData/ast/objectLiteral/file/MyFrame.kt b/tests/testData/ast/objectLiteral/file/MyFrame.kt new file mode 100644 index 00000000000..f8544462e3e --- /dev/null +++ b/tests/testData/ast/objectLiteral/file/MyFrame.kt @@ -0,0 +1,18 @@ +package demo +open class WindowAdapter() { +public open fun windowClosing() : Unit { +} +} +public class Client() : Frame() { +{ +var a : WindowAdapter? = object : WindowAdapter() { +public override fun windowClosing() : Unit { +} +} +addWindowListener(a) +addWindowListener(object : WindowAdapter() { +public override fun windowClosing() : Unit { +} +}) +} +} \ No newline at end of file diff --git a/tests/testData/ast/outProjectionType/method/methodParams.jav b/tests/testData/ast/outProjectionType/method/methodParams.jav new file mode 100644 index 00000000000..ac87941ea87 --- /dev/null +++ b/tests/testData/ast/outProjectionType/method/methodParams.jav @@ -0,0 +1 @@ +void pushAll(Collection src) {} \ No newline at end of file diff --git a/tests/testData/ast/outProjectionType/method/methodParams.kt b/tests/testData/ast/outProjectionType/method/methodParams.kt new file mode 100644 index 00000000000..bd4fb48a56b --- /dev/null +++ b/tests/testData/ast/outProjectionType/method/methodParams.kt @@ -0,0 +1,2 @@ +fun pushAll(src : Collection?) : Unit { +} \ No newline at end of file diff --git a/tests/testData/ast/packageStatement/file/orgJetbrainsJetJ2kIn.jav b/tests/testData/ast/packageStatement/file/orgJetbrainsJetJ2kIn.jav new file mode 100644 index 00000000000..7b8f669aba1 --- /dev/null +++ b/tests/testData/ast/packageStatement/file/orgJetbrainsJetJ2kIn.jav @@ -0,0 +1,6 @@ +package org.jetbrains.jet.j2k.in; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class Converter {} \ No newline at end of file diff --git a/tests/testData/ast/packageStatement/file/orgJetbrainsJetJ2kIn.kt b/tests/testData/ast/packageStatement/file/orgJetbrainsJetJ2kIn.kt new file mode 100644 index 00000000000..6577e7b6c8d --- /dev/null +++ b/tests/testData/ast/packageStatement/file/orgJetbrainsJetJ2kIn.kt @@ -0,0 +1,4 @@ +package org.jetbrains.jet.j2k.`in` +import org.jetbrains.annotations.Nullable +public open class Converter() { +} \ No newline at end of file diff --git a/tests/testData/ast/parenthesizedExpression/expression/parenthesized.jav b/tests/testData/ast/parenthesizedExpression/expression/parenthesized.jav new file mode 100644 index 00000000000..0a911375668 --- /dev/null +++ b/tests/testData/ast/parenthesizedExpression/expression/parenthesized.jav @@ -0,0 +1 @@ +(1 + 2) \ No newline at end of file diff --git a/tests/testData/ast/parenthesizedExpression/expression/parenthesized.kt b/tests/testData/ast/parenthesizedExpression/expression/parenthesized.kt new file mode 100644 index 00000000000..0a911375668 --- /dev/null +++ b/tests/testData/ast/parenthesizedExpression/expression/parenthesized.kt @@ -0,0 +1 @@ +(1 + 2) \ No newline at end of file diff --git a/tests/testData/ast/parenthesizedExpression/expression/parenthesized2.jav b/tests/testData/ast/parenthesizedExpression/expression/parenthesized2.jav new file mode 100644 index 00000000000..01d3d19b7d8 --- /dev/null +++ b/tests/testData/ast/parenthesizedExpression/expression/parenthesized2.jav @@ -0,0 +1 @@ +(str.toString() + "abc") \ No newline at end of file diff --git a/tests/testData/ast/parenthesizedExpression/expression/parenthesized2.kt b/tests/testData/ast/parenthesizedExpression/expression/parenthesized2.kt new file mode 100644 index 00000000000..01d3d19b7d8 --- /dev/null +++ b/tests/testData/ast/parenthesizedExpression/expression/parenthesized2.kt @@ -0,0 +1 @@ +(str.toString() + "abc") \ No newline at end of file diff --git a/tests/testData/ast/polyadicExpression/expression/divide.jav b/tests/testData/ast/polyadicExpression/expression/divide.jav new file mode 100644 index 00000000000..6005ff02b5d --- /dev/null +++ b/tests/testData/ast/polyadicExpression/expression/divide.jav @@ -0,0 +1 @@ +1 / 2 / 3 \ No newline at end of file diff --git a/tests/testData/ast/polyadicExpression/expression/divide.kt b/tests/testData/ast/polyadicExpression/expression/divide.kt new file mode 100644 index 00000000000..6005ff02b5d --- /dev/null +++ b/tests/testData/ast/polyadicExpression/expression/divide.kt @@ -0,0 +1 @@ +1 / 2 / 3 \ No newline at end of file diff --git a/tests/testData/ast/polyadicExpression/expression/minus.jav b/tests/testData/ast/polyadicExpression/expression/minus.jav new file mode 100644 index 00000000000..35002f64d1e --- /dev/null +++ b/tests/testData/ast/polyadicExpression/expression/minus.jav @@ -0,0 +1 @@ +1 - 2 - 3 \ No newline at end of file diff --git a/tests/testData/ast/polyadicExpression/expression/minus.kt b/tests/testData/ast/polyadicExpression/expression/minus.kt new file mode 100644 index 00000000000..35002f64d1e --- /dev/null +++ b/tests/testData/ast/polyadicExpression/expression/minus.kt @@ -0,0 +1 @@ +1 - 2 - 3 \ No newline at end of file diff --git a/tests/testData/ast/polyadicExpression/expression/multiply.jav b/tests/testData/ast/polyadicExpression/expression/multiply.jav new file mode 100644 index 00000000000..89ddea79483 --- /dev/null +++ b/tests/testData/ast/polyadicExpression/expression/multiply.jav @@ -0,0 +1 @@ +1 * 2 * 3 \ No newline at end of file diff --git a/tests/testData/ast/polyadicExpression/expression/multiply.kt b/tests/testData/ast/polyadicExpression/expression/multiply.kt new file mode 100644 index 00000000000..89ddea79483 --- /dev/null +++ b/tests/testData/ast/polyadicExpression/expression/multiply.kt @@ -0,0 +1 @@ +1 * 2 * 3 \ No newline at end of file diff --git a/tests/testData/ast/polyadicExpression/expression/plus.jav b/tests/testData/ast/polyadicExpression/expression/plus.jav new file mode 100644 index 00000000000..8a2a3c5ef6f --- /dev/null +++ b/tests/testData/ast/polyadicExpression/expression/plus.jav @@ -0,0 +1 @@ +1 + 2 + 3 \ No newline at end of file diff --git a/tests/testData/ast/polyadicExpression/expression/plus.kt b/tests/testData/ast/polyadicExpression/expression/plus.kt new file mode 100644 index 00000000000..8a2a3c5ef6f --- /dev/null +++ b/tests/testData/ast/polyadicExpression/expression/plus.kt @@ -0,0 +1 @@ +1 + 2 + 3 \ No newline at end of file diff --git a/tests/testData/ast/polyadicExpression/expression/remainder.jav b/tests/testData/ast/polyadicExpression/expression/remainder.jav new file mode 100644 index 00000000000..2e120c0cd68 --- /dev/null +++ b/tests/testData/ast/polyadicExpression/expression/remainder.jav @@ -0,0 +1 @@ +1 % 2 % 3 \ No newline at end of file diff --git a/tests/testData/ast/polyadicExpression/expression/remainder.kt b/tests/testData/ast/polyadicExpression/expression/remainder.kt new file mode 100644 index 00000000000..2e120c0cd68 --- /dev/null +++ b/tests/testData/ast/polyadicExpression/expression/remainder.kt @@ -0,0 +1 @@ +1 % 2 % 3 \ No newline at end of file diff --git a/tests/testData/ast/polyadicExpression/expression/unassignedShiftRight.jav b/tests/testData/ast/polyadicExpression/expression/unassignedShiftRight.jav new file mode 100644 index 00000000000..c9745ec8062 --- /dev/null +++ b/tests/testData/ast/polyadicExpression/expression/unassignedShiftRight.jav @@ -0,0 +1 @@ +1 >>> 2 >>> 3 \ No newline at end of file diff --git a/tests/testData/ast/polyadicExpression/expression/unassignedShiftRight.kt b/tests/testData/ast/polyadicExpression/expression/unassignedShiftRight.kt new file mode 100644 index 00000000000..83d192a6a77 --- /dev/null +++ b/tests/testData/ast/polyadicExpression/expression/unassignedShiftRight.kt @@ -0,0 +1 @@ +1 ushr 2 ushr 3 \ No newline at end of file diff --git a/tests/testData/ast/postfixOperator/statement/decrement.jav b/tests/testData/ast/postfixOperator/statement/decrement.jav new file mode 100644 index 00000000000..47b6f21c63d --- /dev/null +++ b/tests/testData/ast/postfixOperator/statement/decrement.jav @@ -0,0 +1 @@ +i--; \ No newline at end of file diff --git a/tests/testData/ast/postfixOperator/statement/decrement.kt b/tests/testData/ast/postfixOperator/statement/decrement.kt new file mode 100644 index 00000000000..b45bc7f1686 --- /dev/null +++ b/tests/testData/ast/postfixOperator/statement/decrement.kt @@ -0,0 +1 @@ +i-- \ No newline at end of file diff --git a/tests/testData/ast/postfixOperator/statement/increment.jav b/tests/testData/ast/postfixOperator/statement/increment.jav new file mode 100644 index 00000000000..689efdaa358 --- /dev/null +++ b/tests/testData/ast/postfixOperator/statement/increment.jav @@ -0,0 +1 @@ +i++; \ No newline at end of file diff --git a/tests/testData/ast/postfixOperator/statement/increment.kt b/tests/testData/ast/postfixOperator/statement/increment.kt new file mode 100644 index 00000000000..f47eebed94d --- /dev/null +++ b/tests/testData/ast/postfixOperator/statement/increment.kt @@ -0,0 +1 @@ +i++ \ No newline at end of file diff --git a/tests/testData/ast/prefixOperator/statement/decrement.jav b/tests/testData/ast/prefixOperator/statement/decrement.jav new file mode 100644 index 00000000000..10724ba55da --- /dev/null +++ b/tests/testData/ast/prefixOperator/statement/decrement.jav @@ -0,0 +1 @@ +--i; \ No newline at end of file diff --git a/tests/testData/ast/prefixOperator/statement/decrement.kt b/tests/testData/ast/prefixOperator/statement/decrement.kt new file mode 100644 index 00000000000..33b7049c8ba --- /dev/null +++ b/tests/testData/ast/prefixOperator/statement/decrement.kt @@ -0,0 +1 @@ +--i \ No newline at end of file diff --git a/tests/testData/ast/prefixOperator/statement/excl.jav b/tests/testData/ast/prefixOperator/statement/excl.jav new file mode 100644 index 00000000000..93e541d4332 --- /dev/null +++ b/tests/testData/ast/prefixOperator/statement/excl.jav @@ -0,0 +1,2 @@ +boolean i = true; +boolean j = !i; \ No newline at end of file diff --git a/tests/testData/ast/prefixOperator/statement/excl.kt b/tests/testData/ast/prefixOperator/statement/excl.kt new file mode 100644 index 00000000000..adf3dc99d50 --- /dev/null +++ b/tests/testData/ast/prefixOperator/statement/excl.kt @@ -0,0 +1,2 @@ +var i : Boolean = true +var j : Boolean = !i \ No newline at end of file diff --git a/tests/testData/ast/prefixOperator/statement/increment.jav b/tests/testData/ast/prefixOperator/statement/increment.jav new file mode 100644 index 00000000000..97ad097f1e2 --- /dev/null +++ b/tests/testData/ast/prefixOperator/statement/increment.jav @@ -0,0 +1 @@ +++i; \ No newline at end of file diff --git a/tests/testData/ast/prefixOperator/statement/increment.kt b/tests/testData/ast/prefixOperator/statement/increment.kt new file mode 100644 index 00000000000..de36816d982 --- /dev/null +++ b/tests/testData/ast/prefixOperator/statement/increment.kt @@ -0,0 +1 @@ +++i \ No newline at end of file diff --git a/tests/testData/ast/prefixOperator/statement/kt-667.jav b/tests/testData/ast/prefixOperator/statement/kt-667.jav new file mode 100644 index 00000000000..eb1dc5658a7 --- /dev/null +++ b/tests/testData/ast/prefixOperator/statement/kt-667.jav @@ -0,0 +1,2 @@ +int i = ~10; +int j = ~(i * 100); \ No newline at end of file diff --git a/tests/testData/ast/prefixOperator/statement/kt-667.kt b/tests/testData/ast/prefixOperator/statement/kt-667.kt new file mode 100644 index 00000000000..df5a51082e3 --- /dev/null +++ b/tests/testData/ast/prefixOperator/statement/kt-667.kt @@ -0,0 +1,2 @@ +var i : Int = (10).inv() +var j : Int = ((i * 100)).inv() \ No newline at end of file diff --git a/tests/testData/ast/prefixOperator/statement/tilde.jav b/tests/testData/ast/prefixOperator/statement/tilde.jav new file mode 100644 index 00000000000..354a6ddb01b --- /dev/null +++ b/tests/testData/ast/prefixOperator/statement/tilde.jav @@ -0,0 +1,2 @@ +int i = 10; +int j = ~10; \ No newline at end of file diff --git a/tests/testData/ast/prefixOperator/statement/tilde.kt b/tests/testData/ast/prefixOperator/statement/tilde.kt new file mode 100644 index 00000000000..f3b7ac754e1 --- /dev/null +++ b/tests/testData/ast/prefixOperator/statement/tilde.kt @@ -0,0 +1,2 @@ +var i : Int = 10 +var j : Int = (10).inv() \ No newline at end of file diff --git a/tests/testData/ast/rawGenerics/file/kt-540-map.jav b/tests/testData/ast/rawGenerics/file/kt-540-map.jav new file mode 100644 index 00000000000..539c842981f --- /dev/null +++ b/tests/testData/ast/rawGenerics/file/kt-540-map.jav @@ -0,0 +1,11 @@ +package demo; + +import java.util.HashMap; + +class Test { + void main() { + HashMap commonMap = new HashMap(); + HashMap rawMap = new HashMap(); + HashMap superRawMap = new HashMap(); + } +} diff --git a/tests/testData/ast/rawGenerics/file/kt-540-map.kt b/tests/testData/ast/rawGenerics/file/kt-540-map.kt new file mode 100644 index 00000000000..51784d9a76d --- /dev/null +++ b/tests/testData/ast/rawGenerics/file/kt-540-map.kt @@ -0,0 +1,9 @@ +package demo +import java.util.HashMap +open class Test() { +open fun main() : Unit { +var commonMap : HashMap? = HashMap() +var rawMap : HashMap? = HashMap() +var superRawMap : HashMap? = HashMap() +} +} \ No newline at end of file diff --git a/tests/testData/ast/rawGenerics/file/kt-540-rawGenericClass.jav b/tests/testData/ast/rawGenerics/file/kt-540-rawGenericClass.jav new file mode 100644 index 00000000000..28e9ae350cc --- /dev/null +++ b/tests/testData/ast/rawGenerics/file/kt-540-rawGenericClass.jav @@ -0,0 +1,15 @@ +package demo; + +class Collection { + Collection(E e) { + System.out.println(e); + } +} + +class Test { + void main() { + Collection raw1 = new Collection(1); + Collection raw2 = new Collection(1); + Collection raw3 = new Collection("1"); + } +} \ No newline at end of file diff --git a/tests/testData/ast/rawGenerics/file/kt-540-rawGenericClass.kt b/tests/testData/ast/rawGenerics/file/kt-540-rawGenericClass.kt new file mode 100644 index 00000000000..22e2f6d8328 --- /dev/null +++ b/tests/testData/ast/rawGenerics/file/kt-540-rawGenericClass.kt @@ -0,0 +1,13 @@ +package demo +open class Collection(e : E?) { +{ +System.out?.println(e) +} +} +open class Test() { +open fun main() : Unit { +var raw1 : Collection? = Collection(1) +var raw2 : Collection? = Collection(1) +var raw3 : Collection? = Collection("1") +} +} \ No newline at end of file diff --git a/tests/testData/ast/rawGenerics/file/kt-540.jav b/tests/testData/ast/rawGenerics/file/kt-540.jav new file mode 100644 index 00000000000..6327874eab3 --- /dev/null +++ b/tests/testData/ast/rawGenerics/file/kt-540.jav @@ -0,0 +1,12 @@ +package demo; + +import java.util.List; +import java.util.LinkedList; + +class Test { + void main() { + List common = new LinkedList(); + List raw = new LinkedList(); + List superRaw = new LinkedList(); + } +} \ No newline at end of file diff --git a/tests/testData/ast/rawGenerics/file/kt-540.kt b/tests/testData/ast/rawGenerics/file/kt-540.kt new file mode 100644 index 00000000000..e5bc789c601 --- /dev/null +++ b/tests/testData/ast/rawGenerics/file/kt-540.kt @@ -0,0 +1,10 @@ +package demo +import java.util.List +import java.util.LinkedList +open class Test() { +open fun main() : Unit { +var common : List? = LinkedList() +var raw : List? = LinkedList() +var superRaw : List? = LinkedList() +} +} \ No newline at end of file diff --git a/tests/testData/ast/rawGenerics/file/rawGenericMethod.jav b/tests/testData/ast/rawGenerics/file/rawGenericMethod.jav new file mode 100644 index 00000000000..1303b4a305a --- /dev/null +++ b/tests/testData/ast/rawGenerics/file/rawGenericMethod.jav @@ -0,0 +1,14 @@ +package demo; + +class TestT { + void getT() { } +} + +class U { + void main() { + TestT t = new TestT(); + t.getT(); + t.getT(); + t.getT(); + } +} \ No newline at end of file diff --git a/tests/testData/ast/rawGenerics/file/rawGenericMethod.kt b/tests/testData/ast/rawGenerics/file/rawGenericMethod.kt new file mode 100644 index 00000000000..15ca4c5ac6f --- /dev/null +++ b/tests/testData/ast/rawGenerics/file/rawGenericMethod.kt @@ -0,0 +1,13 @@ +package demo +open class TestT() { +open fun getT() : Unit { +} +} +open class U() { +open fun main() : Unit { +var t : TestT? = TestT() +t?.getT() +t?.getT() +t?.getT() +} +} \ No newline at end of file diff --git a/tests/testData/ast/returnStatement/statement/returnChar.jav b/tests/testData/ast/returnStatement/statement/returnChar.jav new file mode 100644 index 00000000000..d693916818c --- /dev/null +++ b/tests/testData/ast/returnStatement/statement/returnChar.jav @@ -0,0 +1 @@ +return 'c'; \ No newline at end of file diff --git a/tests/testData/ast/returnStatement/statement/returnChar.kt b/tests/testData/ast/returnStatement/statement/returnChar.kt new file mode 100644 index 00000000000..b6284fba897 --- /dev/null +++ b/tests/testData/ast/returnStatement/statement/returnChar.kt @@ -0,0 +1 @@ +return 'c' \ No newline at end of file diff --git a/tests/testData/ast/returnStatement/statement/returnLiteral.jav b/tests/testData/ast/returnStatement/statement/returnLiteral.jav new file mode 100644 index 00000000000..5acac407ebf --- /dev/null +++ b/tests/testData/ast/returnStatement/statement/returnLiteral.jav @@ -0,0 +1 @@ +return true; \ No newline at end of file diff --git a/tests/testData/ast/returnStatement/statement/returnLiteral.kt b/tests/testData/ast/returnStatement/statement/returnLiteral.kt new file mode 100644 index 00000000000..2a925639120 --- /dev/null +++ b/tests/testData/ast/returnStatement/statement/returnLiteral.kt @@ -0,0 +1 @@ +return true \ No newline at end of file diff --git a/tests/testData/ast/returnStatement/statement/returnNumber.jav b/tests/testData/ast/returnStatement/statement/returnNumber.jav new file mode 100644 index 00000000000..eb224e0951e --- /dev/null +++ b/tests/testData/ast/returnStatement/statement/returnNumber.jav @@ -0,0 +1 @@ +return 1; \ No newline at end of file diff --git a/tests/testData/ast/returnStatement/statement/returnNumber.kt b/tests/testData/ast/returnStatement/statement/returnNumber.kt new file mode 100644 index 00000000000..5efef616fdb --- /dev/null +++ b/tests/testData/ast/returnStatement/statement/returnNumber.kt @@ -0,0 +1 @@ +return 1 \ No newline at end of file diff --git a/tests/testData/ast/returnStatement/statement/returnString.jav b/tests/testData/ast/returnStatement/statement/returnString.jav new file mode 100644 index 00000000000..b98a6ce7734 --- /dev/null +++ b/tests/testData/ast/returnStatement/statement/returnString.jav @@ -0,0 +1 @@ +return "str"; \ No newline at end of file diff --git a/tests/testData/ast/returnStatement/statement/returnString.kt b/tests/testData/ast/returnStatement/statement/returnString.kt new file mode 100644 index 00000000000..f831e0baf83 --- /dev/null +++ b/tests/testData/ast/returnStatement/statement/returnString.kt @@ -0,0 +1 @@ +return "str" \ No newline at end of file diff --git a/tests/testData/ast/starProjectionType/method/methodParams.jav b/tests/testData/ast/starProjectionType/method/methodParams.jav new file mode 100644 index 00000000000..18d4217e0d9 --- /dev/null +++ b/tests/testData/ast/starProjectionType/method/methodParams.jav @@ -0,0 +1 @@ +void wtf(Collection w) {} \ No newline at end of file diff --git a/tests/testData/ast/starProjectionType/method/methodParams.kt b/tests/testData/ast/starProjectionType/method/methodParams.kt new file mode 100644 index 00000000000..41a86faf443 --- /dev/null +++ b/tests/testData/ast/starProjectionType/method/methodParams.kt @@ -0,0 +1,2 @@ +fun wtf(w : Collection<*>?) : Unit { +} \ No newline at end of file diff --git a/tests/testData/ast/superExpression/class/classAextendsB.jav b/tests/testData/ast/superExpression/class/classAextendsB.jav new file mode 100644 index 00000000000..6f07978fe79 --- /dev/null +++ b/tests/testData/ast/superExpression/class/classAextendsB.jav @@ -0,0 +1,12 @@ +class B { + B(int i) {} + int call() {return 1;} +} + +class A extends B { + A() { + super(10); + } + + int call() { return super.call(); } +} \ No newline at end of file diff --git a/tests/testData/ast/superExpression/class/classAextendsB.kt b/tests/testData/ast/superExpression/class/classAextendsB.kt new file mode 100644 index 00000000000..b89ebce366d --- /dev/null +++ b/tests/testData/ast/superExpression/class/classAextendsB.kt @@ -0,0 +1,10 @@ +open class B(i : Int) { +open fun call() : Int { +return 1 +} +} +open class A() : B(10) { +override fun call() : Int { +return super.call() +} +} \ No newline at end of file diff --git a/tests/testData/ast/superExpression/file/classAdotSuperFoo.jav b/tests/testData/ast/superExpression/file/classAdotSuperFoo.jav new file mode 100644 index 00000000000..f53906b2c67 --- /dev/null +++ b/tests/testData/ast/superExpression/file/classAdotSuperFoo.jav @@ -0,0 +1,11 @@ +class Base { + void foo(); +} + +class A extends Base { + class C { + void test() { + A.super.foo(); + } + } +} \ No newline at end of file diff --git a/tests/testData/ast/superExpression/file/classAdotSuperFoo.kt b/tests/testData/ast/superExpression/file/classAdotSuperFoo.kt new file mode 100644 index 00000000000..5ce2249b587 --- /dev/null +++ b/tests/testData/ast/superExpression/file/classAdotSuperFoo.kt @@ -0,0 +1,10 @@ +open class Base() { +open fun foo() : Unit +} +open class A() : Base() { +open class C() { +open fun test() : Unit { +super@A.foo() +} +} +} \ No newline at end of file diff --git a/tests/testData/ast/superExpression/statement/superStatement.jav b/tests/testData/ast/superExpression/statement/superStatement.jav new file mode 100644 index 00000000000..4b2f79a6823 --- /dev/null +++ b/tests/testData/ast/superExpression/statement/superStatement.jav @@ -0,0 +1 @@ +super.call(); \ No newline at end of file diff --git a/tests/testData/ast/superExpression/statement/superStatement.kt b/tests/testData/ast/superExpression/statement/superStatement.kt new file mode 100644 index 00000000000..a0ea37bcc63 --- /dev/null +++ b/tests/testData/ast/superExpression/statement/superStatement.kt @@ -0,0 +1 @@ +super.call() \ No newline at end of file diff --git a/tests/testData/ast/switch/file/comlicatedFallDown.jav b/tests/testData/ast/switch/file/comlicatedFallDown.jav new file mode 100644 index 00000000000..7bede23f75c --- /dev/null +++ b/tests/testData/ast/switch/file/comlicatedFallDown.jav @@ -0,0 +1,32 @@ +package demo; + +public class SwitchDemo { + public static void print(Object o) { + System.out.println(o); + } + + public static void test(int i) { + String monthString = ""; + switch (i) { + case 1: print(1); + case 2: print(2); + case 3: print(3); + case 4: print(4); + case 5: print(5); break; + case 6: print(6); + case 7: print(7); + case 8: print(8); + case 9: print(9); + case 10: print(10); + case 11: print(11); + case 12: monthString = "December"; break; + default: monthString = "Invalid month"; break; + } + System.out.println(monthString); + } + + public static void main(String[] args) { + for (int i = 1; i <=12 ; i++) + test(i); + } +} \ No newline at end of file diff --git a/tests/testData/ast/switch/file/comlicatedFallDown.kt b/tests/testData/ast/switch/file/comlicatedFallDown.kt new file mode 100644 index 00000000000..888c5d181c8 --- /dev/null +++ b/tests/testData/ast/switch/file/comlicatedFallDown.kt @@ -0,0 +1,88 @@ +package demo +public open class SwitchDemo() { +class object { +public open fun print(o : Any?) : Unit { +System.out?.println(o) +} +public open fun test(i : Int) : Unit { +var monthString : String? = "" +when (i) { +1 -> { +print(1) +print(2) +print(3) +print(4) +print(5) +} +2 -> { +print(2) +print(3) +print(4) +print(5) +} +3 -> { +print(3) +print(4) +print(5) +} +4 -> { +print(4) +print(5) +} +5 -> { +print(5) +} +6 -> { +print(6) +print(7) +print(8) +print(9) +print(10) +print(11) +monthString = "December" +} +7 -> { +print(7) +print(8) +print(9) +print(10) +print(11) +monthString = "December" +} +8 -> { +print(8) +print(9) +print(10) +print(11) +monthString = "December" +} +9 -> { +print(9) +print(10) +print(11) +monthString = "December" +} +10 -> { +print(10) +print(11) +monthString = "December" +} +11 -> { +print(11) +monthString = "December" +} +12 -> { +monthString = "December" +} +else -> { +monthString = "Invalid month" +} +} +System.out?.println(monthString) +} +public open fun main(args : Array?) : Unit { +for (i in 1..12) test(i) +} +} +} +fun main(args : Array?) = SwitchDemo.main(args) \ No newline at end of file diff --git a/tests/testData/ast/switch/file/fallDown.jav b/tests/testData/ast/switch/file/fallDown.jav new file mode 100644 index 00000000000..a6e4c557a72 --- /dev/null +++ b/tests/testData/ast/switch/file/fallDown.jav @@ -0,0 +1,24 @@ +package switch_demo; + +public class SwitchDemo { + public static void main(String[] args) { + int month = 8; + String monthString; + switch (month) { + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + case 10: + case 11: + case 12: monthString = "December"; break; + default: monthString = "Invalid month"; break; + } + System.out.println(monthString); + } +} \ No newline at end of file diff --git a/tests/testData/ast/switch/file/fallDown.kt b/tests/testData/ast/switch/file/fallDown.kt new file mode 100644 index 00000000000..64c48e85d5e --- /dev/null +++ b/tests/testData/ast/switch/file/fallDown.kt @@ -0,0 +1,19 @@ +package switch_demo +public open class SwitchDemo() { +class object { +public open fun main(args : Array?) : Unit { +var month : Int = 8 +var monthString : String? +when (month) { +1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 -> { +monthString = "December" +} +else -> { +monthString = "Invalid month" +} +} +System.out?.println(monthString) +} +} +} +fun main(args : Array?) = SwitchDemo.main(args) \ No newline at end of file diff --git a/tests/testData/ast/switch/file/kt-539.jav b/tests/testData/ast/switch/file/kt-539.jav new file mode 100644 index 00000000000..890eaa836e2 --- /dev/null +++ b/tests/testData/ast/switch/file/kt-539.jav @@ -0,0 +1,25 @@ +package switch_demo; + +public class SwitchDemo { + public static void main(String[] args) { + + int month = 8; + String monthString; + switch (month) { + case 1: monthString = "January"; break; + case 2: monthString = "February"; break; + case 3: monthString = "March"; break; + case 4: monthString = "April"; break; + case 5: monthString = "May"; break; + case 6: monthString = "June"; break; + case 7: monthString = "July"; break; + case 8: monthString = "August"; break; + case 9: monthString = "September"; break; + case 10: monthString = "October"; break; + case 11: monthString = "November"; break; + case 12: monthString = "December"; break; + default: monthString = "Invalid month"; break; + } + System.out.println(monthString); + } +} \ No newline at end of file diff --git a/tests/testData/ast/switch/file/kt-539.kt b/tests/testData/ast/switch/file/kt-539.kt new file mode 100644 index 00000000000..b7c37eaf387 --- /dev/null +++ b/tests/testData/ast/switch/file/kt-539.kt @@ -0,0 +1,52 @@ +package switch_demo +public open class SwitchDemo() { +class object { +public open fun main(args : Array?) : Unit { +var month : Int = 8 +var monthString : String? +when (month) { +1 -> { +monthString = "January" +} +2 -> { +monthString = "February" +} +3 -> { +monthString = "March" +} +4 -> { +monthString = "April" +} +5 -> { +monthString = "May" +} +6 -> { +monthString = "June" +} +7 -> { +monthString = "July" +} +8 -> { +monthString = "August" +} +9 -> { +monthString = "September" +} +10 -> { +monthString = "October" +} +11 -> { +monthString = "November" +} +12 -> { +monthString = "December" +} +else -> { +monthString = "Invalid month" +} +} +System.out?.println(monthString) +} +} +} +fun main(args : Array?) = SwitchDemo.main(args) \ No newline at end of file diff --git a/tests/testData/ast/synchronizedStatement/statement/singleLineExample.jav b/tests/testData/ast/synchronizedStatement/statement/singleLineExample.jav new file mode 100644 index 00000000000..4c4b01beee5 --- /dev/null +++ b/tests/testData/ast/synchronizedStatement/statement/singleLineExample.jav @@ -0,0 +1 @@ +synchronized (s) { doSomething(s); } \ No newline at end of file diff --git a/tests/testData/ast/synchronizedStatement/statement/singleLineExample.kt b/tests/testData/ast/synchronizedStatement/statement/singleLineExample.kt new file mode 100644 index 00000000000..f8c00c2d9cd --- /dev/null +++ b/tests/testData/ast/synchronizedStatement/statement/singleLineExample.kt @@ -0,0 +1,3 @@ +synchronized (s) { +doSomething(s) +} \ No newline at end of file diff --git a/tests/testData/ast/thisExpression/file/classAdotThisFoo.jav b/tests/testData/ast/thisExpression/file/classAdotThisFoo.jav new file mode 100644 index 00000000000..6449695eb81 --- /dev/null +++ b/tests/testData/ast/thisExpression/file/classAdotThisFoo.jav @@ -0,0 +1,11 @@ +class Base { + void foo() {} +} + +class A extends Base { + class C { + void test() { + A.this.foo(); + } + } +} \ No newline at end of file diff --git a/tests/testData/ast/thisExpression/file/classAdotThisFoo.kt b/tests/testData/ast/thisExpression/file/classAdotThisFoo.kt new file mode 100644 index 00000000000..4956f6eaad0 --- /dev/null +++ b/tests/testData/ast/thisExpression/file/classAdotThisFoo.kt @@ -0,0 +1,11 @@ +open class Base() { +open fun foo() : Unit { +} +} +open class A() : Base() { +open class C() { +open fun test() : Unit { +this@A.foo() +} +} +} \ No newline at end of file diff --git a/tests/testData/ast/thisExpression/statement/thisStatement.jav b/tests/testData/ast/thisExpression/statement/thisStatement.jav new file mode 100644 index 00000000000..4b2f79a6823 --- /dev/null +++ b/tests/testData/ast/thisExpression/statement/thisStatement.jav @@ -0,0 +1 @@ +super.call(); \ No newline at end of file diff --git a/tests/testData/ast/thisExpression/statement/thisStatement.kt b/tests/testData/ast/thisExpression/statement/thisStatement.kt new file mode 100644 index 00000000000..a0ea37bcc63 --- /dev/null +++ b/tests/testData/ast/thisExpression/statement/thisStatement.kt @@ -0,0 +1 @@ +super.call() \ No newline at end of file diff --git a/tests/testData/ast/throwStatement/statement/simpleThrowStatement.jav b/tests/testData/ast/throwStatement/statement/simpleThrowStatement.jav new file mode 100644 index 00000000000..2d879427e7c --- /dev/null +++ b/tests/testData/ast/throwStatement/statement/simpleThrowStatement.jav @@ -0,0 +1 @@ +throw exception; \ No newline at end of file diff --git a/tests/testData/ast/throwStatement/statement/simpleThrowStatement.kt b/tests/testData/ast/throwStatement/statement/simpleThrowStatement.kt new file mode 100644 index 00000000000..0894cfeda14 --- /dev/null +++ b/tests/testData/ast/throwStatement/statement/simpleThrowStatement.kt @@ -0,0 +1 @@ +throw exception \ No newline at end of file diff --git a/tests/testData/ast/trait/class/abstactInterface.jav b/tests/testData/ast/trait/class/abstactInterface.jav new file mode 100644 index 00000000000..17b89868943 --- /dev/null +++ b/tests/testData/ast/trait/class/abstactInterface.jav @@ -0,0 +1 @@ +abstract interface I {} \ No newline at end of file diff --git a/tests/testData/ast/trait/class/abstactInterface.kt b/tests/testData/ast/trait/class/abstactInterface.kt new file mode 100644 index 00000000000..dba106cf0f2 --- /dev/null +++ b/tests/testData/ast/trait/class/abstactInterface.kt @@ -0,0 +1,2 @@ +abstract trait I { +} \ No newline at end of file diff --git a/tests/testData/ast/trait/class/emptyInterface.jav b/tests/testData/ast/trait/class/emptyInterface.jav new file mode 100644 index 00000000000..0bdb5912e9b --- /dev/null +++ b/tests/testData/ast/trait/class/emptyInterface.jav @@ -0,0 +1 @@ +interface A {} \ No newline at end of file diff --git a/tests/testData/ast/trait/class/emptyInterface.kt b/tests/testData/ast/trait/class/emptyInterface.kt new file mode 100644 index 00000000000..549f15fa37a --- /dev/null +++ b/tests/testData/ast/trait/class/emptyInterface.kt @@ -0,0 +1,2 @@ +trait A { +} \ No newline at end of file diff --git a/tests/testData/ast/trait/class/extendsOneClassAndImplementsSeveralInterfaces.jav b/tests/testData/ast/trait/class/extendsOneClassAndImplementsSeveralInterfaces.jav new file mode 100644 index 00000000000..f0434f0b324 --- /dev/null +++ b/tests/testData/ast/trait/class/extendsOneClassAndImplementsSeveralInterfaces.jav @@ -0,0 +1 @@ +interface A extends I0, I1, I2 {} \ No newline at end of file diff --git a/tests/testData/ast/trait/class/extendsOneClassAndImplementsSeveralInterfaces.kt b/tests/testData/ast/trait/class/extendsOneClassAndImplementsSeveralInterfaces.kt new file mode 100644 index 00000000000..aba2655ddea --- /dev/null +++ b/tests/testData/ast/trait/class/extendsOneClassAndImplementsSeveralInterfaces.kt @@ -0,0 +1,2 @@ +trait A : I0, I1, I2 { +} \ No newline at end of file diff --git a/tests/testData/ast/trait/class/extendsOneInterface.jav b/tests/testData/ast/trait/class/extendsOneInterface.jav new file mode 100644 index 00000000000..fdd7b33cb4b --- /dev/null +++ b/tests/testData/ast/trait/class/extendsOneInterface.jav @@ -0,0 +1 @@ +interface A extends I {} \ No newline at end of file diff --git a/tests/testData/ast/trait/class/extendsOneInterface.kt b/tests/testData/ast/trait/class/extendsOneInterface.kt new file mode 100644 index 00000000000..eebabe79c39 --- /dev/null +++ b/tests/testData/ast/trait/class/extendsOneInterface.kt @@ -0,0 +1,2 @@ +trait A : I { +} \ No newline at end of file diff --git a/tests/testData/ast/trait/class/interfaceWithFields.jav b/tests/testData/ast/trait/class/interfaceWithFields.jav new file mode 100644 index 00000000000..5fdf82bfa6c --- /dev/null +++ b/tests/testData/ast/trait/class/interfaceWithFields.jav @@ -0,0 +1 @@ +interface INode {String IN = "in";String AT = "@";String COMMA_WITH_SPACE = COMMA + SPACE;} \ No newline at end of file diff --git a/tests/testData/ast/trait/class/interfaceWithFields.kt b/tests/testData/ast/trait/class/interfaceWithFields.kt new file mode 100644 index 00000000000..457c9848296 --- /dev/null +++ b/tests/testData/ast/trait/class/interfaceWithFields.kt @@ -0,0 +1,7 @@ +trait INode { +class object { +val IN : String? = "in" +val AT : String? = "@" +val COMMA_WITH_SPACE : String? = COMMA + SPACE +} +} \ No newline at end of file diff --git a/tests/testData/ast/trait/class/interfaceWithMethodDeclaration.jav b/tests/testData/ast/trait/class/interfaceWithMethodDeclaration.jav new file mode 100644 index 00000000000..4023476a76e --- /dev/null +++ b/tests/testData/ast/trait/class/interfaceWithMethodDeclaration.jav @@ -0,0 +1 @@ +interface INode {Tag getTag();String toKotlin();} \ No newline at end of file diff --git a/tests/testData/ast/trait/class/interfaceWithMethodDeclaration.kt b/tests/testData/ast/trait/class/interfaceWithMethodDeclaration.kt new file mode 100644 index 00000000000..560cab9d45a --- /dev/null +++ b/tests/testData/ast/trait/class/interfaceWithMethodDeclaration.kt @@ -0,0 +1,4 @@ +trait INode { +open fun getTag() : Tag? +open fun toKotlin() : String? +} \ No newline at end of file diff --git a/tests/testData/ast/trait/class/interfaceWithStaticFields.jav b/tests/testData/ast/trait/class/interfaceWithStaticFields.jav new file mode 100644 index 00000000000..831ea008a23 --- /dev/null +++ b/tests/testData/ast/trait/class/interfaceWithStaticFields.jav @@ -0,0 +1 @@ +public interface INode { public static final String IN = "in"; public static final String AT = "@"; public static final String COMMA_WITH_SPACE = COMMA + SPACE;} \ No newline at end of file diff --git a/tests/testData/ast/trait/class/interfaceWithStaticFields.kt b/tests/testData/ast/trait/class/interfaceWithStaticFields.kt new file mode 100644 index 00000000000..11e87d7db5d --- /dev/null +++ b/tests/testData/ast/trait/class/interfaceWithStaticFields.kt @@ -0,0 +1,7 @@ +public trait INode { +class object { +public val IN : String? = "in" +public val AT : String? = "@" +public val COMMA_WITH_SPACE : String? = COMMA + SPACE +} +} \ No newline at end of file diff --git a/tests/testData/ast/trait/class/internalInterface.jav b/tests/testData/ast/trait/class/internalInterface.jav new file mode 100644 index 00000000000..6afccc2f169 --- /dev/null +++ b/tests/testData/ast/trait/class/internalInterface.jav @@ -0,0 +1 @@ +interface Test {} \ No newline at end of file diff --git a/tests/testData/ast/trait/class/internalInterface.kt b/tests/testData/ast/trait/class/internalInterface.kt new file mode 100644 index 00000000000..d13645c059f --- /dev/null +++ b/tests/testData/ast/trait/class/internalInterface.kt @@ -0,0 +1,2 @@ +trait Test { +} \ No newline at end of file diff --git a/tests/testData/ast/trait/class/privateInterface.jav b/tests/testData/ast/trait/class/privateInterface.jav new file mode 100644 index 00000000000..cf33d97c99c --- /dev/null +++ b/tests/testData/ast/trait/class/privateInterface.jav @@ -0,0 +1 @@ +private interface Test {} \ No newline at end of file diff --git a/tests/testData/ast/trait/class/privateInterface.kt b/tests/testData/ast/trait/class/privateInterface.kt new file mode 100644 index 00000000000..37018e058af --- /dev/null +++ b/tests/testData/ast/trait/class/privateInterface.kt @@ -0,0 +1,2 @@ +private trait Test { +} \ No newline at end of file diff --git a/tests/testData/ast/trait/class/protectedInterface.jav b/tests/testData/ast/trait/class/protectedInterface.jav new file mode 100644 index 00000000000..e91d5694021 --- /dev/null +++ b/tests/testData/ast/trait/class/protectedInterface.jav @@ -0,0 +1 @@ +protected interface Test {} \ No newline at end of file diff --git a/tests/testData/ast/trait/class/protectedInterface.kt b/tests/testData/ast/trait/class/protectedInterface.kt new file mode 100644 index 00000000000..3a62403e685 --- /dev/null +++ b/tests/testData/ast/trait/class/protectedInterface.kt @@ -0,0 +1,2 @@ +protected trait Test { +} \ No newline at end of file diff --git a/tests/testData/ast/trait/class/publicInterface.jav b/tests/testData/ast/trait/class/publicInterface.jav new file mode 100644 index 00000000000..19c4ff3a675 --- /dev/null +++ b/tests/testData/ast/trait/class/publicInterface.jav @@ -0,0 +1 @@ +public interface Test {} \ No newline at end of file diff --git a/tests/testData/ast/trait/class/publicInterface.kt b/tests/testData/ast/trait/class/publicInterface.kt new file mode 100644 index 00000000000..bb4bd3f780f --- /dev/null +++ b/tests/testData/ast/trait/class/publicInterface.kt @@ -0,0 +1,2 @@ +public trait Test { +} \ No newline at end of file diff --git a/tests/testData/ast/tryStatement/statement/commonCaseForTryStatement.jav b/tests/testData/ast/tryStatement/statement/commonCaseForTryStatement.jav new file mode 100644 index 00000000000..ba4d634d21b --- /dev/null +++ b/tests/testData/ast/tryStatement/statement/commonCaseForTryStatement.jav @@ -0,0 +1 @@ +try { callMethod(params);} catch (Exception e) { println(1);} catch (IOException e) { println(0);} finally { println(3);} \ No newline at end of file diff --git a/tests/testData/ast/tryStatement/statement/commonCaseForTryStatement.kt b/tests/testData/ast/tryStatement/statement/commonCaseForTryStatement.kt new file mode 100644 index 00000000000..f76a797ebda --- /dev/null +++ b/tests/testData/ast/tryStatement/statement/commonCaseForTryStatement.kt @@ -0,0 +1,14 @@ +try +{ +callMethod(params) +} +catch (e : Exception?) { +println(1) +} +catch (e : IOException?) { +println(0) +} +finally +{ +println(3) +} \ No newline at end of file diff --git a/tests/testData/ast/tryStatement/statement/emptyTryWithTwoCatchesWithEmptyFinally.jav b/tests/testData/ast/tryStatement/statement/emptyTryWithTwoCatchesWithEmptyFinally.jav new file mode 100644 index 00000000000..f334b56c36a --- /dev/null +++ b/tests/testData/ast/tryStatement/statement/emptyTryWithTwoCatchesWithEmptyFinally.jav @@ -0,0 +1 @@ +try {} catch (Exception e) { println(1);} catch (IOException e) { println(0);} finally {} \ No newline at end of file diff --git a/tests/testData/ast/tryStatement/statement/emptyTryWithTwoCatchesWithEmptyFinally.kt b/tests/testData/ast/tryStatement/statement/emptyTryWithTwoCatchesWithEmptyFinally.kt new file mode 100644 index 00000000000..5415a28f50f --- /dev/null +++ b/tests/testData/ast/tryStatement/statement/emptyTryWithTwoCatchesWithEmptyFinally.kt @@ -0,0 +1,12 @@ +try +{ +} +catch (e : Exception?) { +println(1) +} +catch (e : IOException?) { +println(0) +} +finally +{ +} \ No newline at end of file diff --git a/tests/testData/ast/tryStatement/statement/emptyTryWithTwoCatchesWithFinally.jav b/tests/testData/ast/tryStatement/statement/emptyTryWithTwoCatchesWithFinally.jav new file mode 100644 index 00000000000..9658c4120c2 --- /dev/null +++ b/tests/testData/ast/tryStatement/statement/emptyTryWithTwoCatchesWithFinally.jav @@ -0,0 +1 @@ +try {} catch (Exception e) { println(1);} catch (IOException e) { println(0);} finally { println(3);} \ No newline at end of file diff --git a/tests/testData/ast/tryStatement/statement/emptyTryWithTwoCatchesWithFinally.kt b/tests/testData/ast/tryStatement/statement/emptyTryWithTwoCatchesWithFinally.kt new file mode 100644 index 00000000000..4da4b18ca9a --- /dev/null +++ b/tests/testData/ast/tryStatement/statement/emptyTryWithTwoCatchesWithFinally.kt @@ -0,0 +1,13 @@ +try +{ +} +catch (e : Exception?) { +println(1) +} +catch (e : IOException?) { +println(0) +} +finally +{ +println(3) +} \ No newline at end of file diff --git a/tests/testData/ast/tryStatement/statement/emptyTryWithTwoCatchesWithoutFinally.jav b/tests/testData/ast/tryStatement/statement/emptyTryWithTwoCatchesWithoutFinally.jav new file mode 100644 index 00000000000..5e85a85b378 --- /dev/null +++ b/tests/testData/ast/tryStatement/statement/emptyTryWithTwoCatchesWithoutFinally.jav @@ -0,0 +1 @@ +try {} catch (Exception e) { println(1);} catch (IOException e) { println(0);} \ No newline at end of file diff --git a/tests/testData/ast/tryStatement/statement/emptyTryWithTwoCatchesWithoutFinally.kt b/tests/testData/ast/tryStatement/statement/emptyTryWithTwoCatchesWithoutFinally.kt new file mode 100644 index 00000000000..04545c66873 --- /dev/null +++ b/tests/testData/ast/tryStatement/statement/emptyTryWithTwoCatchesWithoutFinally.kt @@ -0,0 +1,9 @@ +try +{ +} +catch (e : Exception?) { +println(1) +} +catch (e : IOException?) { +println(0) +} \ No newline at end of file diff --git a/tests/testData/ast/typeCastExpression/expression/extendsWildcardCast.jav b/tests/testData/ast/typeCastExpression/expression/extendsWildcardCast.jav new file mode 100644 index 00000000000..c19f94da6e8 --- /dev/null +++ b/tests/testData/ast/typeCastExpression/expression/extendsWildcardCast.jav @@ -0,0 +1 @@ +(List)list \ No newline at end of file diff --git a/tests/testData/ast/typeCastExpression/expression/extendsWildcardCast.kt b/tests/testData/ast/typeCastExpression/expression/extendsWildcardCast.kt new file mode 100644 index 00000000000..05db17e423f --- /dev/null +++ b/tests/testData/ast/typeCastExpression/expression/extendsWildcardCast.kt @@ -0,0 +1 @@ +(list as List?) \ No newline at end of file diff --git a/tests/testData/ast/typeCastExpression/expression/fooCast.jav b/tests/testData/ast/typeCastExpression/expression/fooCast.jav new file mode 100644 index 00000000000..8edd243486a --- /dev/null +++ b/tests/testData/ast/typeCastExpression/expression/fooCast.jav @@ -0,0 +1 @@ +(Foo)t \ No newline at end of file diff --git a/tests/testData/ast/typeCastExpression/expression/fooCast.kt b/tests/testData/ast/typeCastExpression/expression/fooCast.kt new file mode 100644 index 00000000000..109689e1240 --- /dev/null +++ b/tests/testData/ast/typeCastExpression/expression/fooCast.kt @@ -0,0 +1 @@ +(t as Foo?) \ No newline at end of file diff --git a/tests/testData/ast/typeCastExpression/expression/intCast.jav b/tests/testData/ast/typeCastExpression/expression/intCast.jav new file mode 100644 index 00000000000..c000fb4d468 --- /dev/null +++ b/tests/testData/ast/typeCastExpression/expression/intCast.jav @@ -0,0 +1 @@ +(int)t \ No newline at end of file diff --git a/tests/testData/ast/typeCastExpression/expression/intCast.kt b/tests/testData/ast/typeCastExpression/expression/intCast.kt new file mode 100644 index 00000000000..28dc4fc3816 --- /dev/null +++ b/tests/testData/ast/typeCastExpression/expression/intCast.kt @@ -0,0 +1 @@ +(t as Int) \ No newline at end of file diff --git a/tests/testData/ast/typeCastExpression/expression/primitiveType.jav b/tests/testData/ast/typeCastExpression/expression/primitiveType.jav new file mode 100644 index 00000000000..a9cc54cd6b8 --- /dev/null +++ b/tests/testData/ast/typeCastExpression/expression/primitiveType.jav @@ -0,0 +1 @@ +(int)100.00; \ No newline at end of file diff --git a/tests/testData/ast/typeCastExpression/expression/primitiveType.kt b/tests/testData/ast/typeCastExpression/expression/primitiveType.kt new file mode 100644 index 00000000000..ad9dd5d2a7b --- /dev/null +++ b/tests/testData/ast/typeCastExpression/expression/primitiveType.kt @@ -0,0 +1 @@ +(100.00 as Int) \ No newline at end of file diff --git a/tests/testData/ast/typeCastExpression/expression/simpleGenericCast.jav b/tests/testData/ast/typeCastExpression/expression/simpleGenericCast.jav new file mode 100644 index 00000000000..cdfdd30aea4 --- /dev/null +++ b/tests/testData/ast/typeCastExpression/expression/simpleGenericCast.jav @@ -0,0 +1 @@ +(List)list \ No newline at end of file diff --git a/tests/testData/ast/typeCastExpression/expression/simpleGenericCast.kt b/tests/testData/ast/typeCastExpression/expression/simpleGenericCast.kt new file mode 100644 index 00000000000..c48c5d7637d --- /dev/null +++ b/tests/testData/ast/typeCastExpression/expression/simpleGenericCast.kt @@ -0,0 +1 @@ +(list as List?) \ No newline at end of file diff --git a/tests/testData/ast/typeCastExpression/expression/stringCast.jav b/tests/testData/ast/typeCastExpression/expression/stringCast.jav new file mode 100644 index 00000000000..b4cf91cf340 --- /dev/null +++ b/tests/testData/ast/typeCastExpression/expression/stringCast.jav @@ -0,0 +1 @@ +(String)t \ No newline at end of file diff --git a/tests/testData/ast/typeCastExpression/expression/stringCast.kt b/tests/testData/ast/typeCastExpression/expression/stringCast.kt new file mode 100644 index 00000000000..a2020f03831 --- /dev/null +++ b/tests/testData/ast/typeCastExpression/expression/stringCast.kt @@ -0,0 +1 @@ +(t as String?) \ No newline at end of file diff --git a/tests/testData/ast/typeCastExpression/expression/superWildcardCast.jav b/tests/testData/ast/typeCastExpression/expression/superWildcardCast.jav new file mode 100644 index 00000000000..c197fc42e15 --- /dev/null +++ b/tests/testData/ast/typeCastExpression/expression/superWildcardCast.jav @@ -0,0 +1 @@ +(List)list \ No newline at end of file diff --git a/tests/testData/ast/typeCastExpression/expression/superWildcardCast.kt b/tests/testData/ast/typeCastExpression/expression/superWildcardCast.kt new file mode 100644 index 00000000000..1bc5cd16259 --- /dev/null +++ b/tests/testData/ast/typeCastExpression/expression/superWildcardCast.kt @@ -0,0 +1 @@ +(list as List?) \ No newline at end of file diff --git a/tests/testData/ast/typeCastExpression/expression/wildcardCast.jav b/tests/testData/ast/typeCastExpression/expression/wildcardCast.jav new file mode 100644 index 00000000000..38bd7a07f97 --- /dev/null +++ b/tests/testData/ast/typeCastExpression/expression/wildcardCast.jav @@ -0,0 +1 @@ +(List)list \ No newline at end of file diff --git a/tests/testData/ast/typeCastExpression/expression/wildcardCast.kt b/tests/testData/ast/typeCastExpression/expression/wildcardCast.kt new file mode 100644 index 00000000000..47484fba27b --- /dev/null +++ b/tests/testData/ast/typeCastExpression/expression/wildcardCast.kt @@ -0,0 +1 @@ +(list as List<*>?) \ No newline at end of file diff --git a/tests/testData/ast/typeParameters/class/classDoubleParametrizationWithTwoBoundsWithExtending.jav b/tests/testData/ast/typeParameters/class/classDoubleParametrizationWithTwoBoundsWithExtending.jav new file mode 100644 index 00000000000..c576f7f0633 --- /dev/null +++ b/tests/testData/ast/typeParameters/class/classDoubleParametrizationWithTwoBoundsWithExtending.jav @@ -0,0 +1 @@ +final class CC , K extends Node & Collection> extends A {} \ No newline at end of file diff --git a/tests/testData/ast/typeParameters/class/classDoubleParametrizationWithTwoBoundsWithExtending.kt b/tests/testData/ast/typeParameters/class/classDoubleParametrizationWithTwoBoundsWithExtending.kt new file mode 100644 index 00000000000..52746a3168b --- /dev/null +++ b/tests/testData/ast/typeParameters/class/classDoubleParametrizationWithTwoBoundsWithExtending.kt @@ -0,0 +1,2 @@ +class CC() : A() where T : Comparable?, K : Collection? { +} \ No newline at end of file diff --git a/tests/testData/ast/typeParameters/class/classParametrizationWithTwoBounds.jav b/tests/testData/ast/typeParameters/class/classParametrizationWithTwoBounds.jav new file mode 100644 index 00000000000..9794cb4338c --- /dev/null +++ b/tests/testData/ast/typeParameters/class/classParametrizationWithTwoBounds.jav @@ -0,0 +1 @@ +final class C> {} \ No newline at end of file diff --git a/tests/testData/ast/typeParameters/class/classParametrizationWithTwoBounds.kt b/tests/testData/ast/typeParameters/class/classParametrizationWithTwoBounds.kt new file mode 100644 index 00000000000..cff642a5829 --- /dev/null +++ b/tests/testData/ast/typeParameters/class/classParametrizationWithTwoBounds.kt @@ -0,0 +1,2 @@ +class C() where T : Comparable? { +} \ No newline at end of file diff --git a/tests/testData/ast/typeParameters/class/classParametrizationWithTwoBoundsWithExtending.jav b/tests/testData/ast/typeParameters/class/classParametrizationWithTwoBoundsWithExtending.jav new file mode 100644 index 00000000000..aaea17bff62 --- /dev/null +++ b/tests/testData/ast/typeParameters/class/classParametrizationWithTwoBoundsWithExtending.jav @@ -0,0 +1 @@ +final class C> extends A {} \ No newline at end of file diff --git a/tests/testData/ast/typeParameters/class/classParametrizationWithTwoBoundsWithExtending.kt b/tests/testData/ast/typeParameters/class/classParametrizationWithTwoBoundsWithExtending.kt new file mode 100644 index 00000000000..31037f0e57a --- /dev/null +++ b/tests/testData/ast/typeParameters/class/classParametrizationWithTwoBoundsWithExtending.kt @@ -0,0 +1,2 @@ +class C() : A() where T : Comparable? { +} \ No newline at end of file diff --git a/tests/testData/ast/typeParameters/class/complexExampleWithClassExtending.jav b/tests/testData/ast/typeParameters/class/complexExampleWithClassExtending.jav new file mode 100644 index 00000000000..d23995b68a2 --- /dev/null +++ b/tests/testData/ast/typeParameters/class/complexExampleWithClassExtending.jav @@ -0,0 +1 @@ +interface CommandHandler {} \ No newline at end of file diff --git a/tests/testData/ast/typeParameters/class/complexExampleWithClassExtending.kt b/tests/testData/ast/typeParameters/class/complexExampleWithClassExtending.kt new file mode 100644 index 00000000000..b22bbbcd177 --- /dev/null +++ b/tests/testData/ast/typeParameters/class/complexExampleWithClassExtending.kt @@ -0,0 +1,2 @@ +trait CommandHandler { +} \ No newline at end of file diff --git a/tests/testData/ast/typeParameters/class/complexExampleWithClassMultiplyExtending.jav b/tests/testData/ast/typeParameters/class/complexExampleWithClassMultiplyExtending.jav new file mode 100644 index 00000000000..8d1c87481ff --- /dev/null +++ b/tests/testData/ast/typeParameters/class/complexExampleWithClassMultiplyExtending.jav @@ -0,0 +1 @@ +interface CommandHandler {} \ No newline at end of file diff --git a/tests/testData/ast/typeParameters/class/complexExampleWithClassMultiplyExtending.kt b/tests/testData/ast/typeParameters/class/complexExampleWithClassMultiplyExtending.kt new file mode 100644 index 00000000000..a132e4f8bd9 --- /dev/null +++ b/tests/testData/ast/typeParameters/class/complexExampleWithClassMultiplyExtending.kt @@ -0,0 +1,2 @@ +trait CommandHandler { +} \ No newline at end of file diff --git a/tests/testData/ast/typeParameters/class/genericClass.jav b/tests/testData/ast/typeParameters/class/genericClass.jav new file mode 100644 index 00000000000..10066e3b55d --- /dev/null +++ b/tests/testData/ast/typeParameters/class/genericClass.jav @@ -0,0 +1 @@ +final class Comparable {} \ No newline at end of file diff --git a/tests/testData/ast/typeParameters/class/genericClass.kt b/tests/testData/ast/typeParameters/class/genericClass.kt new file mode 100644 index 00000000000..9a6063c348c --- /dev/null +++ b/tests/testData/ast/typeParameters/class/genericClass.kt @@ -0,0 +1,2 @@ +class Comparable() { +} \ No newline at end of file diff --git a/tests/testData/ast/typeParameters/class/traitDoubleParametrizationWithTwoBoundsWithExtending.jav b/tests/testData/ast/typeParameters/class/traitDoubleParametrizationWithTwoBoundsWithExtending.jav new file mode 100644 index 00000000000..533a138632d --- /dev/null +++ b/tests/testData/ast/typeParameters/class/traitDoubleParametrizationWithTwoBoundsWithExtending.jav @@ -0,0 +1 @@ +interface I , K extends Node & Collection> extends II {} \ No newline at end of file diff --git a/tests/testData/ast/typeParameters/class/traitDoubleParametrizationWithTwoBoundsWithExtending.kt b/tests/testData/ast/typeParameters/class/traitDoubleParametrizationWithTwoBoundsWithExtending.kt new file mode 100644 index 00000000000..57fea19b2c7 --- /dev/null +++ b/tests/testData/ast/typeParameters/class/traitDoubleParametrizationWithTwoBoundsWithExtending.kt @@ -0,0 +1,2 @@ +trait I : II where T : Comparable?, K : Collection? { +} \ No newline at end of file diff --git a/tests/testData/ast/typeParameters/method/methodDoubleParametrizationWithTwoBounds.jav b/tests/testData/ast/typeParameters/method/methodDoubleParametrizationWithTwoBounds.jav new file mode 100644 index 00000000000..40ab13a5851 --- /dev/null +++ b/tests/testData/ast/typeParameters/method/methodDoubleParametrizationWithTwoBounds.jav @@ -0,0 +1 @@ +, K extends Node & Collection> T max(Collection coll) {} \ No newline at end of file diff --git a/tests/testData/ast/typeParameters/method/methodDoubleParametrizationWithTwoBounds.kt b/tests/testData/ast/typeParameters/method/methodDoubleParametrizationWithTwoBounds.kt new file mode 100644 index 00000000000..09103a8d9d4 --- /dev/null +++ b/tests/testData/ast/typeParameters/method/methodDoubleParametrizationWithTwoBounds.kt @@ -0,0 +1,2 @@ +fun max(coll : Collection?) : T? where T : Comparable?, K : Collection? { +} \ No newline at end of file diff --git a/tests/testData/ast/typeParameters/method/where.jav b/tests/testData/ast/typeParameters/method/where.jav new file mode 100644 index 00000000000..20bb1bf62fd --- /dev/null +++ b/tests/testData/ast/typeParameters/method/where.jav @@ -0,0 +1 @@ +> T max(Collection coll) {} \ No newline at end of file diff --git a/tests/testData/ast/typeParameters/method/where.kt b/tests/testData/ast/typeParameters/method/where.kt new file mode 100644 index 00000000000..6283664079b --- /dev/null +++ b/tests/testData/ast/typeParameters/method/where.kt @@ -0,0 +1,2 @@ +fun max(coll : Collection?) : T? where T : Comparable? { +} \ No newline at end of file diff --git a/tests/testData/ast/typeParameters/statement/genericParam.jav b/tests/testData/ast/typeParameters/statement/genericParam.jav new file mode 100644 index 00000000000..89c94caafda --- /dev/null +++ b/tests/testData/ast/typeParameters/statement/genericParam.jav @@ -0,0 +1 @@ +List l; \ No newline at end of file diff --git a/tests/testData/ast/typeParameters/statement/genericParam.kt b/tests/testData/ast/typeParameters/statement/genericParam.kt new file mode 100644 index 00000000000..53f9c91dba7 --- /dev/null +++ b/tests/testData/ast/typeParameters/statement/genericParam.kt @@ -0,0 +1 @@ +var l : List? \ No newline at end of file diff --git a/tests/testData/ast/typeParameters/statement/manyGenericParams.jav b/tests/testData/ast/typeParameters/statement/manyGenericParams.jav new file mode 100644 index 00000000000..65eb2f4ca9d --- /dev/null +++ b/tests/testData/ast/typeParameters/statement/manyGenericParams.jav @@ -0,0 +1 @@ +List l; \ No newline at end of file diff --git a/tests/testData/ast/typeParameters/statement/manyGenericParams.kt b/tests/testData/ast/typeParameters/statement/manyGenericParams.kt new file mode 100644 index 00000000000..007056e4c03 --- /dev/null +++ b/tests/testData/ast/typeParameters/statement/manyGenericParams.kt @@ -0,0 +1 @@ +var l : List? \ No newline at end of file diff --git a/tests/testData/ast/varArg/method/ellipsisTypeSeveralParams.jav b/tests/testData/ast/varArg/method/ellipsisTypeSeveralParams.jav new file mode 100644 index 00000000000..46bdd2765ee --- /dev/null +++ b/tests/testData/ast/varArg/method/ellipsisTypeSeveralParams.jav @@ -0,0 +1 @@ +String format(String pattern, Object... arguments); \ No newline at end of file diff --git a/tests/testData/ast/varArg/method/ellipsisTypeSeveralParams.kt b/tests/testData/ast/varArg/method/ellipsisTypeSeveralParams.kt new file mode 100644 index 00000000000..78207eee74b --- /dev/null +++ b/tests/testData/ast/varArg/method/ellipsisTypeSeveralParams.kt @@ -0,0 +1 @@ +fun format(pattern : String?, vararg arguments : Any?) : String? \ No newline at end of file diff --git a/tests/testData/ast/varArg/method/ellipsisTypeSingleParams.jav b/tests/testData/ast/varArg/method/ellipsisTypeSingleParams.jav new file mode 100644 index 00000000000..2c1f529675e --- /dev/null +++ b/tests/testData/ast/varArg/method/ellipsisTypeSingleParams.jav @@ -0,0 +1 @@ +void pushAll(Object... objs) {} \ No newline at end of file diff --git a/tests/testData/ast/varArg/method/ellipsisTypeSingleParams.kt b/tests/testData/ast/varArg/method/ellipsisTypeSingleParams.kt new file mode 100644 index 00000000000..d6f51ef1270 --- /dev/null +++ b/tests/testData/ast/varArg/method/ellipsisTypeSingleParams.kt @@ -0,0 +1,2 @@ +fun pushAll(vararg objs : Any?) : Unit { +} \ No newline at end of file diff --git a/tests/testData/ast/whileStatement/statement/whileWithBlock.jav b/tests/testData/ast/whileStatement/statement/whileWithBlock.jav new file mode 100644 index 00000000000..729a9e5f6f7 --- /dev/null +++ b/tests/testData/ast/whileStatement/statement/whileWithBlock.jav @@ -0,0 +1 @@ +while (a > b) {int i = 1; i = i + 1;} \ No newline at end of file diff --git a/tests/testData/ast/whileStatement/statement/whileWithBlock.kt b/tests/testData/ast/whileStatement/statement/whileWithBlock.kt new file mode 100644 index 00000000000..30b97616a1b --- /dev/null +++ b/tests/testData/ast/whileStatement/statement/whileWithBlock.kt @@ -0,0 +1,5 @@ +while (a > b) +{ +var i : Int = 1 +i = i + 1 +} \ No newline at end of file diff --git a/tests/testData/ast/whileStatement/statement/whileWithEmptyBlock.jav b/tests/testData/ast/whileStatement/statement/whileWithEmptyBlock.jav new file mode 100644 index 00000000000..5055fb08ee2 --- /dev/null +++ b/tests/testData/ast/whileStatement/statement/whileWithEmptyBlock.jav @@ -0,0 +1 @@ +while (true) {} \ No newline at end of file diff --git a/tests/testData/ast/whileStatement/statement/whileWithEmptyBlock.kt b/tests/testData/ast/whileStatement/statement/whileWithEmptyBlock.kt new file mode 100644 index 00000000000..bd7461448e0 --- /dev/null +++ b/tests/testData/ast/whileStatement/statement/whileWithEmptyBlock.kt @@ -0,0 +1,3 @@ +while (true) +{ +} \ No newline at end of file diff --git a/tests/testData/ast/whileStatement/statement/whileWithExpression.jav b/tests/testData/ast/whileStatement/statement/whileWithExpression.jav new file mode 100644 index 00000000000..b0e6f1b9b32 --- /dev/null +++ b/tests/testData/ast/whileStatement/statement/whileWithExpression.jav @@ -0,0 +1 @@ +while (true) i = i + 1; \ No newline at end of file diff --git a/tests/testData/ast/whileStatement/statement/whileWithExpression.kt b/tests/testData/ast/whileStatement/statement/whileWithExpression.kt new file mode 100644 index 00000000000..ca00a409410 --- /dev/null +++ b/tests/testData/ast/whileStatement/statement/whileWithExpression.kt @@ -0,0 +1,2 @@ +while (true) +i = i + 1 \ No newline at end of file diff --git a/tests/testData/ast/whileStatement/statement/whileWithReturn.jav b/tests/testData/ast/whileStatement/statement/whileWithReturn.jav new file mode 100644 index 00000000000..2174fc827bd --- /dev/null +++ b/tests/testData/ast/whileStatement/statement/whileWithReturn.jav @@ -0,0 +1 @@ +while (true) return 1; \ No newline at end of file diff --git a/tests/testData/ast/whileStatement/statement/whileWithReturn.kt b/tests/testData/ast/whileStatement/statement/whileWithReturn.kt new file mode 100644 index 00000000000..29b446b5b2e --- /dev/null +++ b/tests/testData/ast/whileStatement/statement/whileWithReturn.kt @@ -0,0 +1,2 @@ +while (true) +return 1 \ No newline at end of file