Merge remote branch 'origin/master'
This commit is contained in:
@@ -69,6 +69,7 @@ public class KotlinCompiler {
|
||||
environment.addToClasspath(rtJar);
|
||||
|
||||
environment.registerFileType(JetFileType.INSTANCE, "kt");
|
||||
environment.registerFileType(JetFileType.INSTANCE, "jet");
|
||||
environment.registerParserDefinition(new JetParserDefinition());
|
||||
|
||||
VirtualFile vFile = environment.getLocalFileSystem().findFileByPath(arguments.src);
|
||||
|
||||
+1
-1
@@ -168,7 +168,7 @@ public class JavaDescriptorResolver {
|
||||
private DeclarationDescriptor resolveParentDescriptor(PsiClass psiClass) {
|
||||
PsiClass containingClass = psiClass.getContainingClass();
|
||||
if (containingClass != null) {
|
||||
return resolveClass(psiClass);
|
||||
return resolveClass(containingClass);
|
||||
}
|
||||
|
||||
PsiJavaFile containingFile = (PsiJavaFile) psiClass.getContainingFile();
|
||||
|
||||
@@ -556,6 +556,7 @@ public class JetControlFlowProcessor {
|
||||
List<JetElement> statements = bodyExpression.getStatements();
|
||||
generateSubroutineControlFlow(functionLiteral, statements);
|
||||
}
|
||||
builder.read(expression);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -39,6 +39,6 @@ public class LocalDeclarationInstruction extends ReadValueInstruction {
|
||||
else if (element instanceof JetObjectDeclaration) {
|
||||
kind = "o";
|
||||
}
|
||||
return "r" + kind + "(" + element.getText() + ")";
|
||||
return "d" + kind + "(" + element.getText() + ")";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.jetbrains.jet.lang.psi;
|
||||
import com.intellij.extapi.psi.ASTWrapperPsiElement;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiElementVisitor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.plugin.JetLanguage;
|
||||
@@ -48,6 +49,16 @@ public class JetElement extends ASTWrapperPsiElement {
|
||||
}
|
||||
}
|
||||
|
||||
public <D> void acceptChildren(@NotNull JetTreeVisitor<D> visitor, D data) {
|
||||
PsiElement child = getFirstChild();
|
||||
while (child != null) {
|
||||
if (child instanceof JetElement) {
|
||||
((JetElement) child).accept(visitor, data);
|
||||
}
|
||||
child = child.getNextSibling();
|
||||
}
|
||||
}
|
||||
|
||||
public void accept(@NotNull JetVisitorVoid visitor) {
|
||||
visitor.visitJetElement(this);
|
||||
}
|
||||
|
||||
@@ -1,804 +1,12 @@
|
||||
package org.jetbrains.jet.lang.psi;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
*/
|
||||
public class JetTreeVisitor<D> extends JetVisitor<Void, D> {
|
||||
@Override
|
||||
public Void visitNamespace(JetNamespace namespace, D data) {
|
||||
List<JetImportDirective> importDirectives = namespace.getImportDirectives();
|
||||
for (JetImportDirective directive : importDirectives) {
|
||||
directive.accept(this, data);
|
||||
}
|
||||
List<JetDeclaration> declarations = namespace.getDeclarations();
|
||||
for (JetDeclaration declaration : declarations) {
|
||||
declaration.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitClass(JetClass klass, D data) {
|
||||
List<JetDeclaration> declarations = klass.getDeclarations();
|
||||
for (JetDeclaration declaration : declarations) {
|
||||
declaration.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitClassObject(JetClassObject classObject, D data) {
|
||||
JetObjectDeclaration objectDeclaration = classObject.getObjectDeclaration();
|
||||
if (objectDeclaration != null) {
|
||||
objectDeclaration.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitConstructor(JetConstructor constructor, D data) {
|
||||
visitDeclarationWithBody(constructor, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitNamedFunction(JetNamedFunction function, D data) {
|
||||
visitDeclarationWithBody(function, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitProperty(JetProperty property, D data) {
|
||||
List<JetPropertyAccessor> accessors = property.getAccessors();
|
||||
for (JetPropertyAccessor accessor : accessors) {
|
||||
accessor.accept(this, data);
|
||||
}
|
||||
JetExpression initializer = property.getInitializer();
|
||||
if (initializer != null) {
|
||||
initializer.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitTypedef(JetTypedef typedef, D data) {
|
||||
return super.visitTypedef(typedef, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitJetFile(JetFile file, D data) {
|
||||
JetNamespace rootNamespace = file.getRootNamespace();
|
||||
return rootNamespace.accept(this, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitImportDirective(JetImportDirective importDirective, D data) {
|
||||
return super.visitImportDirective(importDirective, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitClassBody(JetClassBody classBody, D data) {
|
||||
List<JetDeclaration> declarations = classBody.getDeclarations();
|
||||
for (JetDeclaration declaration : declarations) {
|
||||
declaration.accept(this, data);
|
||||
}
|
||||
List<JetConstructor> secondaryConstructors = classBody.getSecondaryConstructors();
|
||||
for (JetConstructor constructor : secondaryConstructors) {
|
||||
constructor.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitNamespaceBody(JetNamespaceBody body, D data) {
|
||||
List<JetDeclaration> declarations = body.getDeclarations();
|
||||
for (JetDeclaration declaration : declarations) {
|
||||
declaration.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitModifierList(JetModifierList list, D data) {
|
||||
return super.visitModifierList(list, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitAnnotation(JetAnnotation annotation, D data) {
|
||||
return super.visitAnnotation(annotation, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitAnnotationEntry(JetAnnotationEntry annotationEntry, D data) {
|
||||
return super.visitAnnotationEntry(annotationEntry, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitTypeParameterList(JetTypeParameterList list, D data) {
|
||||
List<JetTypeParameter> parameters = list.getParameters();
|
||||
for (JetTypeParameter parameter : parameters) {
|
||||
parameter.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitTypeParameter(JetTypeParameter parameter, D data) {
|
||||
return super.visitTypeParameter(parameter, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitEnumEntry(JetEnumEntry enumEntry, D data) {
|
||||
List<JetDelegationSpecifier> delegationSpecifiers = enumEntry.getDelegationSpecifiers();
|
||||
for (JetDelegationSpecifier delegationSpecifier : delegationSpecifiers) {
|
||||
delegationSpecifier.accept(this, data);
|
||||
}
|
||||
JetModifierList modifierList = enumEntry.getModifierList();
|
||||
if (modifierList != null) {
|
||||
modifierList.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitParameterList(JetParameterList list, D data) {
|
||||
List<JetParameter> parameters = list.getParameters();
|
||||
for (JetParameter parameter : parameters) {
|
||||
parameter.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitParameter(JetParameter parameter, D data) {
|
||||
return super.visitParameter(parameter, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitDelegationSpecifierList(JetDelegationSpecifierList list, D data) {
|
||||
List<JetDelegationSpecifier> delegationSpecifiers = list.getDelegationSpecifiers();
|
||||
for (JetDelegationSpecifier delegationSpecifier : delegationSpecifiers) {
|
||||
delegationSpecifier.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitDelegationSpecifier(JetDelegationSpecifier specifier, D data) {
|
||||
return super.visitDelegationSpecifier(specifier, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitDelegationByExpressionSpecifier(JetDelegatorByExpressionSpecifier specifier, D data) {
|
||||
return super.visitDelegationByExpressionSpecifier(specifier, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitDelegationToSuperCallSpecifier(JetDelegatorToSuperCall call, D data) {
|
||||
return super.visitDelegationToSuperCallSpecifier(call, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitDelegationToSuperClassSpecifier(JetDelegatorToSuperClass specifier, D data) {
|
||||
return super.visitDelegationToSuperClassSpecifier(specifier, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitDelegationToThisCall(JetDelegatorToThisCall thisCall, D data) {
|
||||
return super.visitDelegationToThisCall(thisCall, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitTypeReference(JetTypeReference typeReference, D data) {
|
||||
return super.visitTypeReference(typeReference, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitValueArgumentList(JetValueArgumentList list, D data) {
|
||||
List<JetValueArgument> arguments = list.getArguments();
|
||||
for (JetValueArgument argument : arguments) {
|
||||
argument.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitArgument(JetValueArgument argument, D data) {
|
||||
return super.visitArgument(argument, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitLoopExpression(JetLoopExpression loopExpression, D data) {
|
||||
JetExpression body = loopExpression.getBody();
|
||||
if (body != null) {
|
||||
body.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitConstantExpression(JetConstantExpression expression, D data) {
|
||||
return super.visitConstantExpression(expression, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitSimpleNameExpression(JetSimpleNameExpression expression, D data) {
|
||||
return super.visitSimpleNameExpression(expression, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitReferenceExpression(JetReferenceExpression expression, D data) {
|
||||
return super.visitReferenceExpression(expression, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitTupleExpression(JetTupleExpression expression, D data) {
|
||||
return super.visitTupleExpression(expression, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitPrefixExpression(JetPrefixExpression expression, D data) {
|
||||
JetExpression baseExpression = expression.getBaseExpression();
|
||||
if (baseExpression != null) {
|
||||
baseExpression.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitPostfixExpression(JetPostfixExpression expression, D data) {
|
||||
JetExpression baseExpression = expression.getBaseExpression();
|
||||
baseExpression.accept(this, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitUnaryExpression(JetUnaryExpression expression, D data) {
|
||||
JetExpression baseExpression = expression.getBaseExpression();
|
||||
assert baseExpression != null;
|
||||
baseExpression.accept(this, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitBinaryExpression(JetBinaryExpression expression, D data) {
|
||||
JetExpression left = expression.getLeft();
|
||||
left.accept(this, data);
|
||||
JetExpression right = expression.getRight();
|
||||
if (right != null) {
|
||||
right.accept(this, data);
|
||||
}
|
||||
return super.visitBinaryExpression(expression, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitReturnExpression(JetReturnExpression expression, D data) {
|
||||
JetExpression returnedExpression = expression.getReturnedExpression();
|
||||
if (returnedExpression != null) {
|
||||
returnedExpression.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitLabelQualifiedExpression(JetLabelQualifiedExpression expression, D data) {
|
||||
JetExpression labeledExpression = expression.getLabeledExpression();
|
||||
if (labeledExpression != null) {
|
||||
labeledExpression.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitThrowExpression(JetThrowExpression expression, D data) {
|
||||
JetExpression thrownExpression = expression.getThrownExpression();
|
||||
if (thrownExpression != null) {
|
||||
thrownExpression.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitBreakExpression(JetBreakExpression expression, D data) {
|
||||
return super.visitBreakExpression(expression, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitContinueExpression(JetContinueExpression expression, D data) {
|
||||
return super.visitContinueExpression(expression, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitIfExpression(JetIfExpression expression, D data) {
|
||||
JetExpression condition = expression.getCondition();
|
||||
if (condition != null) {
|
||||
condition.accept(this, data);
|
||||
}
|
||||
JetExpression then = expression.getThen();
|
||||
if (then != null) {
|
||||
then.accept(this, data);
|
||||
}
|
||||
JetExpression anElse = expression.getElse();
|
||||
if (anElse != null) {
|
||||
anElse.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitWhenExpression(JetWhenExpression expression, D data) {
|
||||
List<JetWhenEntry> entries = expression.getEntries();
|
||||
for (JetWhenEntry entry : entries) {
|
||||
entry.accept(this, data);
|
||||
}
|
||||
JetExpression subjectExpression = expression.getSubjectExpression();
|
||||
if (subjectExpression != null) {
|
||||
subjectExpression.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitTryExpression(JetTryExpression expression, D data) {
|
||||
JetBlockExpression tryBlock = expression.getTryBlock();
|
||||
tryBlock.accept(this, data);
|
||||
List<JetCatchClause> catchClauses = expression.getCatchClauses();
|
||||
for (JetCatchClause catchClause : catchClauses) {
|
||||
catchClause.accept(this, data);
|
||||
}
|
||||
JetFinallySection finallyBlock = expression.getFinallyBlock();
|
||||
if (finallyBlock != null) {
|
||||
finallyBlock.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitForExpression(JetForExpression expression, D data) {
|
||||
JetParameter loopParameter = expression.getLoopParameter();
|
||||
if (loopParameter != null) {
|
||||
loopParameter.accept(this, data);
|
||||
}
|
||||
JetExpression loopRange = expression.getLoopRange();
|
||||
if (loopRange != null) {
|
||||
loopRange.accept(this, data);
|
||||
}
|
||||
visitLoopExpression(expression, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitWhileExpression(JetWhileExpression expression, D data) {
|
||||
JetExpression condition = expression.getCondition();
|
||||
if (condition != null) {
|
||||
condition.accept(this, data);
|
||||
}
|
||||
visitLoopExpression(expression, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitDoWhileExpression(JetDoWhileExpression expression, D data) {
|
||||
JetExpression condition = expression.getCondition();
|
||||
if (condition != null) {
|
||||
condition.accept(this, data);
|
||||
}
|
||||
visitLoopExpression(expression, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitFunctionLiteralExpression(JetFunctionLiteralExpression expression, D data) {
|
||||
JetFunctionLiteral functionLiteral = expression.getFunctionLiteral();
|
||||
functionLiteral.accept(this, data);
|
||||
visitDeclarationWithBody(expression, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitAnnotatedExpression(JetAnnotatedExpression expression, D data) {
|
||||
JetExpression baseExpression = expression.getBaseExpression();
|
||||
baseExpression.accept(this, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitCallExpression(JetCallExpression expression, D data) {
|
||||
JetExpression calleeExpression = expression.getCalleeExpression();
|
||||
if (calleeExpression != null) {
|
||||
calleeExpression.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitArrayAccessExpression(JetArrayAccessExpression expression, D data) {
|
||||
JetExpression arrayExpression = expression.getArrayExpression();
|
||||
arrayExpression.accept(this, data);
|
||||
List<JetExpression> indexExpressions = expression.getIndexExpressions();
|
||||
for (JetExpression indexExpression : indexExpressions) {
|
||||
indexExpression.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitQualifiedExpression(JetQualifiedExpression expression, D data) {
|
||||
JetExpression receiver = expression.getReceiverExpression();
|
||||
receiver.accept(this, data);
|
||||
JetExpression selector = expression.getSelectorExpression();
|
||||
if (selector != null) {
|
||||
selector.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitHashQualifiedExpression(JetHashQualifiedExpression expression, D data) {
|
||||
visitQualifiedExpression(expression, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitDotQualifiedExpression(JetDotQualifiedExpression expression, D data) {
|
||||
visitQualifiedExpression(expression, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitPredicateExpression(JetPredicateExpression expression, D data) {
|
||||
visitQualifiedExpression(expression, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitSafeQualifiedExpression(JetSafeQualifiedExpression expression, D data) {
|
||||
visitQualifiedExpression(expression, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitObjectLiteralExpression(JetObjectLiteralExpression expression, D data) {
|
||||
JetObjectDeclaration objectDeclaration = expression.getObjectDeclaration();
|
||||
objectDeclaration.accept(this, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitRootNamespaceExpression(JetRootNamespaceExpression expression, D data) {
|
||||
return super.visitRootNamespaceExpression(expression, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitBlockExpression(JetBlockExpression expression, D data) {
|
||||
List<JetElement> statements = expression.getStatements();
|
||||
for (JetElement statement : statements) {
|
||||
statement.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitCatchSection(JetCatchClause catchClause, D data) {
|
||||
JetParameter catchParameter = catchClause.getCatchParameter();
|
||||
if (catchParameter != null) {
|
||||
catchParameter.accept(this, data);
|
||||
}
|
||||
JetExpression catchBody = catchClause.getCatchBody();
|
||||
if (catchBody != null) {
|
||||
catchBody.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitFinallySection(JetFinallySection finallySection, D data) {
|
||||
JetBlockExpression finalExpression = finallySection.getFinalExpression();
|
||||
finalExpression.accept(this, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitTypeArgumentList(JetTypeArgumentList typeArgumentList, D data) {
|
||||
List<JetTypeProjection> arguments = typeArgumentList.getArguments();
|
||||
for (JetTypeProjection argument : arguments) {
|
||||
argument.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitThisExpression(JetThisExpression expression, D data) {
|
||||
JetReferenceExpression thisReference = expression.getInstanceReference();
|
||||
thisReference.accept(this, data);
|
||||
visitLabelQualifiedExpression(expression, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitSuperExpression(JetSuperExpression expression, D data) {
|
||||
JetReferenceExpression thisReference = expression.getInstanceReference();
|
||||
thisReference.accept(this, data);
|
||||
JetTypeReference superTypeQualifier = expression.getSuperTypeQualifier();
|
||||
if (superTypeQualifier != null) {
|
||||
superTypeQualifier.accept(this, data);
|
||||
}
|
||||
visitLabelQualifiedExpression(expression, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitParenthesizedExpression(JetParenthesizedExpression expression, D data) {
|
||||
JetExpression innerExpression = expression.getExpression();
|
||||
if (innerExpression != null) {
|
||||
innerExpression.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitInitializerList(JetInitializerList list, D data) {
|
||||
List<JetDelegationSpecifier> initializers = list.getInitializers();
|
||||
for (JetDelegationSpecifier initializer : initializers) {
|
||||
initializer.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitAnonymousInitializer(JetClassInitializer initializer, D data) {
|
||||
JetExpression body = initializer.getBody();
|
||||
body.accept(this, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitPropertyAccessor(JetPropertyAccessor accessor, D data) {
|
||||
visitDeclarationWithBody(accessor, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitTypeConstraintList(JetTypeConstraintList list, D data) {
|
||||
List<JetTypeConstraint> constraints = list.getConstraints();
|
||||
for (JetTypeConstraint constraint : constraints) {
|
||||
constraint.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitTypeConstraint(JetTypeConstraint constraint, D data) {
|
||||
JetSimpleNameExpression subjectTypeParameterName = constraint.getSubjectTypeParameterName();
|
||||
if (subjectTypeParameterName != null) {
|
||||
subjectTypeParameterName.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitUserType(JetUserType type, D data) {
|
||||
return super.visitUserType(type, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitTupleType(JetTupleType type, D data) {
|
||||
return super.visitTupleType(type, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitFunctionType(JetFunctionType type, D data) {
|
||||
return super.visitFunctionType(type, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitSelfType(JetSelfType type, D data) {
|
||||
return super.visitSelfType(type, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitBinaryWithTypeRHSExpression(JetBinaryExpressionWithTypeRHS expression, D data) {
|
||||
JetExpression left = expression.getLeft();
|
||||
left.accept(this, data);
|
||||
JetTypeReference right = expression.getRight();
|
||||
if (right != null) {
|
||||
right.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitStringTemplateExpression(JetStringTemplateExpression expression, D data) {
|
||||
JetStringTemplateEntry[] entries = expression.getEntries();
|
||||
for (JetStringTemplateEntry entry : entries) {
|
||||
entry.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitNamedDeclaration(JetNamedDeclaration declaration, D data) {
|
||||
return super.visitNamedDeclaration(declaration, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitNullableType(JetNullableType nullableType, D data) {
|
||||
return super.visitNullableType(nullableType, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitTypeProjection(JetTypeProjection typeProjection, D data) {
|
||||
return super.visitTypeProjection(typeProjection, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitWhenEntry(JetWhenEntry jetWhenEntry, D data) {
|
||||
JetExpression expression = jetWhenEntry.getExpression();
|
||||
if (expression != null) {
|
||||
expression.accept(this, data);
|
||||
}
|
||||
JetWhenCondition[] conditions = jetWhenEntry.getConditions();
|
||||
for (JetWhenCondition condition : conditions) {
|
||||
condition.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitIsExpression(JetIsExpression expression, D data) {
|
||||
JetExpression leftHandSide = expression.getLeftHandSide();
|
||||
leftHandSide.accept(this, data);
|
||||
JetSimpleNameExpression operationReference = expression.getOperationReference();
|
||||
operationReference.accept(this, data);
|
||||
JetPattern pattern = expression.getPattern();
|
||||
if (pattern != null) {
|
||||
pattern.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitWhenConditionCall(JetWhenConditionCall condition, D data) {
|
||||
JetExpression callSuffixExpression = condition.getCallSuffixExpression();
|
||||
if (callSuffixExpression != null) {
|
||||
callSuffixExpression.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitWhenConditionIsPattern(JetWhenConditionIsPattern condition, D data) {
|
||||
JetPattern pattern = condition.getPattern();
|
||||
if (pattern != null) {
|
||||
pattern.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitWhenConditionInRange(JetWhenConditionInRange condition, D data) {
|
||||
JetSimpleNameExpression operationReference = condition.getOperationReference();
|
||||
operationReference.accept(this, data);
|
||||
JetExpression rangeExpression = condition.getRangeExpression();
|
||||
if (rangeExpression != null) {
|
||||
rangeExpression.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitTypePattern(JetTypePattern pattern, D data) {
|
||||
return super.visitTypePattern(pattern, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitWildcardPattern(JetWildcardPattern pattern, D data) {
|
||||
return super.visitWildcardPattern(pattern, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitExpressionPattern(JetExpressionPattern pattern, D data) {
|
||||
JetExpression expression = pattern.getExpression();
|
||||
if (expression != null) {
|
||||
expression.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitTuplePattern(JetTuplePattern pattern, D data) {
|
||||
List<JetTuplePatternEntry> entries = pattern.getEntries();
|
||||
for (JetTuplePatternEntry entry : entries) {
|
||||
entry.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitDecomposerPattern(JetDecomposerPattern pattern, D data) {
|
||||
JetTuplePattern argumentList = pattern.getArgumentList();
|
||||
argumentList.accept(this, data);
|
||||
JetExpression decomposerExpression = pattern.getDecomposerExpression();
|
||||
if (decomposerExpression != null) {
|
||||
decomposerExpression.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitObjectDeclaration(JetObjectDeclaration objectDeclaration, D data) {
|
||||
List<JetDeclaration> declarations = objectDeclaration.getDeclarations();
|
||||
for (JetDeclaration declaration : declarations) {
|
||||
declaration.accept(this, data);
|
||||
}
|
||||
JetDelegationSpecifierList delegationSpecifierList = objectDeclaration.getDelegationSpecifierList();
|
||||
if (delegationSpecifierList != null) {
|
||||
delegationSpecifierList.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitBindingPattern(JetBindingPattern pattern, D data) {
|
||||
JetWhenCondition condition = pattern.getCondition();
|
||||
if (condition != null) {
|
||||
condition.accept(this, data);
|
||||
}
|
||||
JetProperty variableDeclaration = pattern.getVariableDeclaration();
|
||||
variableDeclaration.accept(this, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitStringTemplateEntry(JetStringTemplateEntry entry, D data) {
|
||||
JetExpression expression = entry.getExpression();
|
||||
if (expression != null) {
|
||||
expression.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitStringTemplateEntryWithExpression(JetStringTemplateEntryWithExpression entry, D data) {
|
||||
visitStringTemplateEntry(entry, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitBlockStringTemplateEntry(JetBlockStringTemplateEntry entry, D data) {
|
||||
visitStringTemplateEntry(entry, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitSimpleNameStringTemplateEntry(JetSimpleNameStringTemplateEntry entry, D data) {
|
||||
visitStringTemplateEntry(entry, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitLiteralStringTemplateEntry(JetLiteralStringTemplateEntry entry, D data) {
|
||||
visitStringTemplateEntry(entry, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitEscapeStringTemplateEntry(JetEscapeStringTemplateEntry entry, D data) {
|
||||
visitStringTemplateEntry(entry, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
private Void visitDeclarationWithBody(JetDeclarationWithBody declaration, D data) {
|
||||
JetExpression bodyExpression = declaration.getBodyExpression();
|
||||
if (bodyExpression != null) {
|
||||
bodyExpression.accept(this, data);
|
||||
}
|
||||
List<JetParameter> valueParameters = declaration.getValueParameters();
|
||||
for (JetParameter valueParameter : valueParameters) {
|
||||
valueParameter.accept(this, data);
|
||||
}
|
||||
public Void visitJetElement(JetElement element, D data) {
|
||||
element.acceptChildren(this, data);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,11 +25,12 @@ import java.util.Set;
|
||||
protected final Map<JetNamespace, WritableScope> namespaceScopes = Maps.newHashMap();
|
||||
protected final Map<JetNamespace, NamespaceDescriptorImpl> namespaceDescriptors = Maps.newHashMap();
|
||||
|
||||
private final Map<JetDeclaration, JetScope> declaringScopes = Maps.newHashMap();
|
||||
|
||||
private final Map<JetNamedFunction, FunctionDescriptorImpl> functions = Maps.newLinkedHashMap();
|
||||
private final Map<JetDeclaration, ConstructorDescriptor> constructors = Maps.newLinkedHashMap();
|
||||
private final Map<JetProperty, PropertyDescriptor> properties = Maps.newLinkedHashMap();
|
||||
private final Set<PropertyDescriptor> primaryConstructorParameterProperties = Sets.newHashSet();
|
||||
private final Map<JetDeclaration, JetScope> declaringScopes = Maps.newHashMap();
|
||||
|
||||
public TopDownAnalysisContext(JetSemanticServices semanticServices, BindingTrace trace) {
|
||||
this.trace = new ObservableBindingTrace(trace);
|
||||
|
||||
@@ -18,44 +18,14 @@ public class TopDownAnalyzer {
|
||||
|
||||
private TopDownAnalyzer() {}
|
||||
|
||||
public static void processObject(
|
||||
public static void process(
|
||||
@NotNull JetSemanticServices semanticServices,
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull JetScope outerScope,
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull JetObjectDeclaration object) {
|
||||
process(semanticServices, trace, outerScope, new NamespaceLike.Adapter(containingDeclaration) {
|
||||
|
||||
@Override
|
||||
public NamespaceDescriptorImpl getNamespace(String name) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNamespace(@NotNull NamespaceDescriptor namespaceDescriptor) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addClassifierDescriptor(@NotNull MutableClassDescriptor classDescriptor) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFunctionDescriptor(@NotNull FunctionDescriptor functionDescriptor) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPropertyDescriptor(@NotNull PropertyDescriptor propertyDescriptor) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassObjectStatus setClassObjectDescriptor(@NotNull MutableClassDescriptor classObjectDescriptor) {
|
||||
return ClassObjectStatus.NOT_ALLOWED;
|
||||
}
|
||||
}, Collections.<JetDeclaration>singletonList(object), JetControlFlowDataTraceFactory.EMPTY, true);
|
||||
NamespaceLike owner,
|
||||
@NotNull List<? extends JetDeclaration> declarations,
|
||||
@NotNull JetControlFlowDataTraceFactory flowDataTraceFactory) {
|
||||
process(semanticServices, trace, outerScope, owner, declarations, flowDataTraceFactory, false);
|
||||
}
|
||||
|
||||
private static void process(
|
||||
@@ -75,16 +45,6 @@ public class TopDownAnalyzer {
|
||||
new DeclarationsChecker(context).process();
|
||||
new ControlFlowAnalyzer(context, flowDataTraceFactory, declaredLocally).process();
|
||||
}
|
||||
|
||||
public static void process(
|
||||
@NotNull JetSemanticServices semanticServices,
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull JetScope outerScope,
|
||||
NamespaceLike owner,
|
||||
@NotNull List<? extends JetDeclaration> declarations,
|
||||
@NotNull JetControlFlowDataTraceFactory flowDataTraceFactory) {
|
||||
process(semanticServices, trace, outerScope, owner, declarations, flowDataTraceFactory, false);
|
||||
}
|
||||
|
||||
public static void processStandardLibraryNamespace(
|
||||
@NotNull JetSemanticServices semanticServices,
|
||||
@@ -93,6 +53,8 @@ public class TopDownAnalyzer {
|
||||
TopDownAnalysisContext context = new TopDownAnalysisContext(semanticServices, trace);
|
||||
context.getNamespaceScopes().put(namespace, standardLibraryNamespace.getMemberScope());
|
||||
context.getNamespaceDescriptors().put(namespace, standardLibraryNamespace);
|
||||
context.getDeclaringScopes().put(namespace, outerScope);
|
||||
|
||||
new TypeHierarchyResolver(context).process(outerScope, standardLibraryNamespace, namespace.getDeclarations());
|
||||
new DeclarationResolver(context).process();
|
||||
new DelegationResolver(context).process();
|
||||
@@ -105,6 +67,46 @@ public class TopDownAnalyzer {
|
||||
new BodyResolver(context).resolveBehaviorDeclarationBodies();
|
||||
}
|
||||
|
||||
public static void processObject(
|
||||
@NotNull JetSemanticServices semanticServices,
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull JetScope outerScope,
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull JetObjectDeclaration object) {
|
||||
process(semanticServices, trace, outerScope, new NamespaceLike.Adapter(containingDeclaration) {
|
||||
|
||||
@Override
|
||||
public NamespaceDescriptorImpl getNamespace(String name) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNamespace(@NotNull NamespaceDescriptor namespaceDescriptor) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addClassifierDescriptor(@NotNull MutableClassDescriptor classDescriptor) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFunctionDescriptor(@NotNull FunctionDescriptor functionDescriptor) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPropertyDescriptor(@NotNull PropertyDescriptor propertyDescriptor) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassObjectStatus setClassObjectDescriptor(@NotNull MutableClassDescriptor classObjectDescriptor) {
|
||||
return ClassObjectStatus.NOT_ALLOWED;
|
||||
}
|
||||
}, Collections.<JetDeclaration>singletonList(object), JetControlFlowDataTraceFactory.EMPTY, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScopeImpl;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WriteThroughScope;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
@@ -38,6 +39,8 @@ public class TypeHierarchyResolver {
|
||||
public void process(@NotNull JetScope outerScope, NamespaceLike owner, @NotNull List<? extends JetDeclaration> declarations) {
|
||||
collectNamespacesAndClassifiers(outerScope, owner, declarations); // namespaceScopes, classes
|
||||
|
||||
processTypeImports();
|
||||
|
||||
createTypeConstructors(); // create type constructors for classes and generic parameters, supertypes are not filled in
|
||||
resolveTypesInClassHeaders(); // Generic bounds and types in supertype lists (no expressions or constructor resolution)
|
||||
|
||||
@@ -82,8 +85,9 @@ public class TypeHierarchyResolver {
|
||||
|
||||
WriteThroughScope namespaceScope = new WriteThroughScope(outerScope, namespaceDescriptor.getMemberScope(), new TraceBasedRedeclarationHandler(context.getTrace()));
|
||||
context.getNamespaceScopes().put(namespace, namespaceScope);
|
||||
context.getDeclaringScopes().put(namespace, outerScope);
|
||||
|
||||
processImports(namespace, namespaceScope, outerScope);
|
||||
// processImports(namespace, namespaceScope, outerScope);
|
||||
|
||||
collectNamespacesAndClassifiers(namespaceScope, namespaceDescriptor, namespace.getDeclarations());
|
||||
}
|
||||
@@ -205,12 +209,17 @@ public class TypeHierarchyResolver {
|
||||
return ClassKind.CLASS;
|
||||
}
|
||||
|
||||
private void processImports(@NotNull JetNamespace namespace, @NotNull WriteThroughScope namespaceScope, @NotNull JetScope outerScope) {
|
||||
private void processTypeImports() {
|
||||
for (JetNamespace jetNamespace : context.getNamespaceDescriptors().keySet()) {
|
||||
processImports(jetNamespace, context.getNamespaceScopes().get(jetNamespace), context.getDeclaringScopes().get(jetNamespace));
|
||||
}
|
||||
}
|
||||
|
||||
private void processImports(@NotNull JetNamespace namespace, @NotNull WritableScope namespaceScope, @NotNull JetScope outerScope) {
|
||||
List<JetImportDirective> importDirectives = namespace.getImportDirectives();
|
||||
for (JetImportDirective importDirective : importDirectives) {
|
||||
if (importDirective.isAbsoluteInRootNamespace()) {
|
||||
// context.getTrace().getErrorHandler().genericError(namespace.getNode(), "Unsupported by TDA"); // TODO
|
||||
context.getTrace().report(UNSUPPORTED.on(namespace, "TypeHierarchyResolver")); // TODO
|
||||
context.getTrace().report(UNSUPPORTED.on(importDirective, "TypeHierarchyResolver")); // TODO
|
||||
continue;
|
||||
}
|
||||
if (importDirective.isAllUnder()) {
|
||||
|
||||
@@ -33,4 +33,8 @@ public interface WritableScope extends JetScope {
|
||||
void importScope(@NotNull JetScope imported);
|
||||
|
||||
void setImplicitReceiver(@NotNull ReceiverDescriptor implicitReceiver);
|
||||
|
||||
void importClassifierAlias(@NotNull String importedClassifierName, @NotNull ClassifierDescriptor classifierDescriptor);
|
||||
|
||||
void importNamespaceAlias(String aliasName, NamespaceDescriptor namespaceDescriptor);
|
||||
}
|
||||
|
||||
+2
@@ -106,11 +106,13 @@ public abstract class WritableScopeWithImports extends JetScopeAdapter implement
|
||||
return currentIndividualImportScope;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void importClassifierAlias(@NotNull String importedClassifierName, @NotNull ClassifierDescriptor classifierDescriptor) {
|
||||
getCurrentIndividualImportScope().addClassifierAlias(importedClassifierName, classifierDescriptor);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void importNamespaceAlias(String aliasName, NamespaceDescriptor namespaceDescriptor) {
|
||||
getCurrentIndividualImportScope().addNamespaceAlias(aliasName, namespaceDescriptor);
|
||||
}
|
||||
|
||||
@@ -167,4 +167,9 @@ public class WriteThroughScope extends WritableScopeWithImports {
|
||||
}
|
||||
return allDescriptors;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JetScope getOuterScope() {
|
||||
return getWorkerScope();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,9 +40,10 @@ l0:
|
||||
r(foo) NEXT:[r(foo(a, 3))] PREV:[r(3)]
|
||||
r(foo(a, 3)) NEXT:[r(genfun)] PREV:[r(foo)]
|
||||
r(genfun) NEXT:[r(genfun<Any>())] PREV:[r(foo(a, 3))]
|
||||
r(genfun<Any>()) NEXT:[rf({1})] PREV:[r(genfun)]
|
||||
rf({1}) NEXT:[r(flfun)] PREV:[r(genfun<Any>())]
|
||||
r(flfun) NEXT:[r(flfun {1})] PREV:[rf({1})]
|
||||
r(genfun<Any>()) NEXT:[df({1})] PREV:[r(genfun)]
|
||||
df({1}) NEXT:[r({1})] PREV:[r(genfun<Any>())]
|
||||
r({1}) NEXT:[r(flfun)] PREV:[df({1})]
|
||||
r(flfun) NEXT:[r(flfun {1})] PREV:[r({1})]
|
||||
r(flfun {1}) NEXT:[r(3)] PREV:[r(flfun)]
|
||||
r(3) NEXT:[r(4)] PREV:[r(flfun {1})]
|
||||
r(4) NEXT:[r(equals)] PREV:[r(3)]
|
||||
|
||||
@@ -93,14 +93,19 @@ fun t3() {
|
||||
l0:
|
||||
<START> NEXT:[jmp?(l2)] PREV:[]
|
||||
jmp?(l2) NEXT:[r(2), r(1)] PREV:[<START>]
|
||||
r(1) NEXT:[rf({ () => if (2 > 3) { retu..)] PREV:[jmp?(l2)]
|
||||
rf({ () =>
|
||||
r(1) NEXT:[df({ () => if (2 > 3) { retu..)] PREV:[jmp?(l2)]
|
||||
df({ () =>
|
||||
if (2 > 3) {
|
||||
return@
|
||||
}
|
||||
}) NEXT:[r(2)] PREV:[r(1)]
|
||||
}) NEXT:[r({ () => if (2 > 3) { retur..)] PREV:[r(1)]
|
||||
r({ () =>
|
||||
if (2 > 3) {
|
||||
return@
|
||||
}
|
||||
}) NEXT:[r(2)] PREV:[df({ () => if (2 > 3) { retu..)]
|
||||
l2:
|
||||
r(2) NEXT:[<END>] PREV:[jmp?(l2), rf({ () => if (2 > 3) { retu..)]
|
||||
r(2) NEXT:[<END>] PREV:[jmp?(l2), r({ () => if (2 > 3) { retur..)]
|
||||
l1:
|
||||
<END> NEXT:[] PREV:[r(2)]
|
||||
error:
|
||||
@@ -171,8 +176,8 @@ fun t3() {
|
||||
}
|
||||
---------------------
|
||||
l0:
|
||||
<START> NEXT:[rf({ () => try { 1 if (2 > 3..)] PREV:[]
|
||||
rf({ () =>
|
||||
<START> NEXT:[df({ () => try { 1 if (2 > 3..)] PREV:[]
|
||||
df({ () =>
|
||||
try {
|
||||
1
|
||||
if (2 > 3) {
|
||||
@@ -181,9 +186,19 @@ l0:
|
||||
} finally {
|
||||
2
|
||||
}
|
||||
}) NEXT:[<END>] PREV:[<START>]
|
||||
}) NEXT:[r({ () => try { 1 if (2 > 3)..)] PREV:[<START>]
|
||||
r({ () =>
|
||||
try {
|
||||
1
|
||||
if (2 > 3) {
|
||||
return@
|
||||
}
|
||||
} finally {
|
||||
2
|
||||
}
|
||||
}) NEXT:[<END>] PREV:[df({ () => try { 1 if (2 > 3..)]
|
||||
l1:
|
||||
<END> NEXT:[] PREV:[rf({ () => try { 1 if (2 > 3..)]
|
||||
<END> NEXT:[] PREV:[r({ () => try { 1 if (2 > 3)..)]
|
||||
error:
|
||||
<ERROR> NEXT:[] PREV:[]
|
||||
l2:
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace kt402
|
||||
|
||||
fun getTypeChecker() : fun(Any):Boolean {
|
||||
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>{ (a : Any) => a is <!UNRESOLVED_REFERENCE!>T<!> }<!> // reports unsupported
|
||||
}
|
||||
fun f() : fun(Any) : Boolean {
|
||||
return { (a : Any) => a is String }
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// KT-355 Resolve imports after all symbols are built
|
||||
|
||||
namespace a {
|
||||
import b.*
|
||||
val x : X = X()
|
||||
}
|
||||
|
||||
namespace b {
|
||||
class X() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import java.util.List;
|
||||
*/
|
||||
public abstract class JetTestCaseBase extends LightDaemonAnalyzerTestCase {
|
||||
|
||||
private static FilenameFilter emptyFilter;
|
||||
private boolean checkInfos = false;
|
||||
private String dataPath;
|
||||
protected final String name;
|
||||
@@ -75,20 +76,49 @@ public abstract class JetTestCaseBase extends LightDaemonAnalyzerTestCase {
|
||||
return dataPath;
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
emptyFilter = new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File file, String name) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public interface NamedTestFactory {
|
||||
@NotNull Test createTest(@NotNull String dataPath, @NotNull String name);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static TestSuite suiteForDirectory(String baseDataDir, @NotNull final String dataPath, boolean recursive, @NotNull NamedTestFactory factory) {
|
||||
return suiteForDirectory(baseDataDir, dataPath, recursive, emptyFilter, factory);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static TestSuite suiteForDirectory(String baseDataDir, @NotNull final String dataPath, boolean recursive, final FilenameFilter filter, @NotNull NamedTestFactory factory) {
|
||||
TestSuite suite = new TestSuite(dataPath);
|
||||
final String extension = ".jet";
|
||||
FilenameFilter extensionFilter = new FilenameFilter() {
|
||||
final String extensionJet = ".jet";
|
||||
final String extensionKt = ".kt";
|
||||
final FilenameFilter extensionFilter = new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File dir, String name) {
|
||||
return name.endsWith(extension);
|
||||
return name.endsWith(extensionJet) || name.endsWith(extensionKt);
|
||||
}
|
||||
};
|
||||
FilenameFilter resultFilter;
|
||||
if (filter != emptyFilter) {
|
||||
resultFilter = new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File file, String s) {
|
||||
if (extensionFilter.accept(file, s) && filter.accept(file, s)) return true;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
else {
|
||||
resultFilter = extensionFilter;
|
||||
}
|
||||
File dir = new File(baseDataDir + dataPath);
|
||||
FileFilter dirFilter = new FileFilter() {
|
||||
@Override
|
||||
@@ -105,11 +135,12 @@ public abstract class JetTestCaseBase extends LightDaemonAnalyzerTestCase {
|
||||
suite.addTest(suiteForDirectory(baseDataDir, dataPath + "/" + subdir.getName(), recursive, factory));
|
||||
}
|
||||
}
|
||||
List<File> files = Arrays.asList(dir.listFiles(extensionFilter));
|
||||
List<File> files = Arrays.asList(dir.listFiles(resultFilter));
|
||||
Collections.sort(files);
|
||||
for (File file : files) {
|
||||
String fileName = file.getName();
|
||||
assert fileName != null;
|
||||
String extension = fileName.endsWith(extensionJet) ? extensionJet : extensionKt;
|
||||
suite.addTest(factory.createTest(dataPath, fileName.substring(0, fileName.length() - extension.length())));
|
||||
}
|
||||
return suite;
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package org.jetbrains.jet.plugin;
|
||||
|
||||
import com.intellij.CommonBundle;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.PropertyKey;
|
||||
|
||||
import java.lang.ref.Reference;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
*/
|
||||
public class JetBundle {
|
||||
private static Reference<ResourceBundle> ourBundle;
|
||||
|
||||
@NonNls
|
||||
private static final String BUNDLE = "org.jetbrains.jet.plugin.JetBundle";
|
||||
|
||||
private JetBundle() {
|
||||
}
|
||||
|
||||
public static String message(@NonNls @PropertyKey(resourceBundle = BUNDLE)String key, Object... params) {
|
||||
return CommonBundle.message(getBundle(), key, params);
|
||||
}
|
||||
|
||||
private static ResourceBundle getBundle() {
|
||||
ResourceBundle bundle = null;
|
||||
if (ourBundle != null) bundle = ourBundle.get();
|
||||
if (bundle == null) {
|
||||
bundle = ResourceBundle.getBundle(BUNDLE);
|
||||
ourBundle = new SoftReference<ResourceBundle>(bundle);
|
||||
}
|
||||
return bundle;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#quick fix messages
|
||||
add.function.body=Add function body
|
||||
add.primary.constructor=Add primary constructor to {0}
|
||||
add.primary.constructor.family=Add primary constructor
|
||||
add.return.type=Add return type declaration
|
||||
change.accessor.type=Change accessor type
|
||||
change.getter.type=Change getter type to {0}
|
||||
change.setter.type=Change setter parameter type to {0}
|
||||
make.variable.immutable=Make variable immutable
|
||||
make.variable.mutable=Make variable mutable
|
||||
change.variable.mutability.family=Change variable mutability
|
||||
remove.function.body=Remove function body
|
||||
make.element.modifier=Make {0} {1}
|
||||
add.modifier=Add ''{0}'' modifier
|
||||
make.element.not.modifier=Make {0} not {1}
|
||||
remove.modifier=Remove ''{0}'' modifier
|
||||
remove.modifier.family=Remove modifier
|
||||
remove.redundant.modifier=Remove redundant ''{0}'' modifier
|
||||
remove.parts.from.property=Remove {0} from property
|
||||
remove.parts.from.property.family=Remove parts from property
|
||||
remove.right.part.of.binary.expression=Remove right part of a binary expression
|
||||
remove.cast=Remove cast
|
||||
remove.elvis.operator=Remove elvis operator
|
||||
replace.operation.in.binary.expression=Replace operation in a binary expression
|
||||
replace.cast.with.static.assert=Replace a cast with a static assert
|
||||
replace.with.dot.call=Replace with dot call
|
||||
@@ -8,6 +8,7 @@ import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticWithPsiElement;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
@@ -20,13 +21,13 @@ public class AddFunctionBodyFix extends JetIntentionAction<JetFunction> {
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return "Add function body";
|
||||
return JetBundle.message("add.function.body");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return "Add function body";
|
||||
return JetBundle.message("add.function.body");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.jetbrains.jet.lang.psi.JetPsiFactory;
|
||||
import org.jetbrains.jet.lexer.JetKeywordToken;
|
||||
import org.jetbrains.jet.lexer.JetToken;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
@@ -51,9 +52,9 @@ public class AddModifierFix extends JetIntentionAction<JetModifierListOwner> {
|
||||
@Override
|
||||
public String getText() {
|
||||
if (modifier == JetTokens.ABSTRACT_KEYWORD || modifier == JetTokens.OPEN_KEYWORD) {
|
||||
return "Make " + getElementName(element) + " " + modifier.getValue();
|
||||
return JetBundle.message("make.element.modifier", getElementName(element), modifier.getValue());
|
||||
}
|
||||
return "Add '" + modifier.getValue() + "' modifier";
|
||||
return JetBundle.message("add.modifier", modifier.getValue());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -9,6 +9,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticWithPsiElement;
|
||||
import org.jetbrains.jet.lang.psi.JetClass;
|
||||
import org.jetbrains.jet.lang.psi.JetPsiFactory;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
@@ -22,13 +23,13 @@ public class AddPrimaryConstructorFix extends JetIntentionAction<JetClass> {
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return "Add primary constructor to " + element.getName();
|
||||
return JetBundle.message("add.primary.constructor", element.getName());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return "Add primary constructor";
|
||||
return JetBundle.message("add.primary.constructor.family");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.jetbrains.jet.lang.diagnostics.DiagnosticWithParameters;
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticWithPsiElement;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
@@ -27,13 +28,13 @@ public class AddReturnTypeFix extends JetIntentionAction<JetNamedDeclaration> {
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return "Add return type declaration";
|
||||
return JetBundle.message("add.return.type");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return "Add return type declaration";
|
||||
return JetBundle.message("add.return.type");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.jetbrains.jet.lang.psi.JetPropertyAccessor;
|
||||
import org.jetbrains.jet.lang.psi.JetPsiFactory;
|
||||
import org.jetbrains.jet.lang.psi.JetTypeReference;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
@@ -30,13 +31,13 @@ public class ChangeAccessorTypeFix extends JetIntentionAction<JetPropertyAccesso
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return (element.isGetter() ? "Change getter " : "Change setter parameter ") + "type to " + type;
|
||||
return element.isGetter() ? JetBundle.message("change.getter.type", type) : JetBundle.message("change.setter.type", type);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return "Change accessor type";
|
||||
return JetBundle.message("change.accessor.type");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.jetbrains.jet.lang.diagnostics.DiagnosticWithPsiElement;
|
||||
import org.jetbrains.jet.lang.psi.JetProperty;
|
||||
import org.jetbrains.jet.lang.psi.JetPsiFactory;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
@@ -23,13 +24,13 @@ public class ChangeVariableMutabilityFix extends JetIntentionAction<JetProperty>
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return "Make variable " + (element.isVar() ? "immutable" : "mutable");
|
||||
return element.isVar() ? JetBundle.message("make.variable.immutable") : JetBundle.message("make.variable.mutable");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return "Change variable mutability";
|
||||
return JetBundle.message("change.variable.mutability.family");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -81,7 +81,7 @@ public class QuickFixes {
|
||||
|
||||
add(Errors.USELESS_ELVIS, RemoveRightPartOfBinaryExpressionFix.createRemoveElvisOperatorFactory());
|
||||
|
||||
add(Errors.UNNECESSARY_SAFE_CALL, ReplaceSafeCallToDotCall.createFactory());
|
||||
add(Errors.UNNECESSARY_SAFE_CALL, ReplaceSafeCallWithDotCall.createFactory());
|
||||
|
||||
JetIntentionActionFactory<JetModifierList> removeRedundantModifierFactory = RemoveModifierFix.createRemoveModifierFromListFactory(true);
|
||||
add(Errors.REDUNDANT_MODIFIER, removeRedundantModifierFactory);
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.jetbrains.jet.lang.psi.JetElement;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
import org.jetbrains.jet.lang.psi.JetFunction;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
@@ -26,13 +27,13 @@ public class RemoveFunctionBodyFix extends JetIntentionAction<JetFunction> {
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return "Remove function body";
|
||||
return JetBundle.message("remove.function.body");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return "Remove function body";
|
||||
return JetBundle.message("remove.function.body");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.jetbrains.jet.lang.psi.JetModifierListOwner;
|
||||
import org.jetbrains.jet.lexer.JetKeywordToken;
|
||||
import org.jetbrains.jet.lexer.JetToken;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
@@ -32,16 +33,16 @@ public class RemoveModifierFix {
|
||||
|
||||
private static String makeText(@Nullable JetModifierListOwner element, JetKeywordToken modifier, boolean isRedundant) {
|
||||
if (isRedundant) {
|
||||
return "Remove redundant '" + modifier.getValue() + "' modifier";
|
||||
return JetBundle.message("remove.redundant.modifier", modifier.getValue());
|
||||
}
|
||||
if (element != null && modifier == JetTokens.ABSTRACT_KEYWORD || modifier == JetTokens.OPEN_KEYWORD) {
|
||||
return "Make " + AddModifierFix.getElementName(element) + " not " + modifier.getValue();
|
||||
return JetBundle.message("make.element.not.modifier", AddModifierFix.getElementName(element), modifier.getValue());
|
||||
}
|
||||
return "Remove '" + modifier.getValue() + "' modifier";
|
||||
return JetBundle.message("remove.modifier", modifier.getValue());
|
||||
}
|
||||
|
||||
private static String getFamilyName() {
|
||||
return "Remove modifier fix";
|
||||
return JetBundle.message("remove.modifier.family");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.jetbrains.jet.lang.diagnostics.DiagnosticWithParameters;
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticWithPsiElement;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
@@ -66,13 +67,13 @@ public class RemovePartsFromPropertyFix extends JetIntentionAction<JetProperty>
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return "Remove " + partsToRemove(removeGetter, removeSetter, removeInitializer) + " from property";
|
||||
return JetBundle.message("remove.parts.from.property", partsToRemove(removeGetter, removeSetter, removeInitializer));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return "Remove parts from property to make it abstract";
|
||||
return JetBundle.message("remove.parts.from.property.family");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+4
-3
@@ -9,6 +9,7 @@ import org.jetbrains.jet.lang.diagnostics.DiagnosticWithPsiElement;
|
||||
import org.jetbrains.jet.lang.psi.JetBinaryExpression;
|
||||
import org.jetbrains.jet.lang.psi.JetBinaryExpressionWithTypeRHS;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
@@ -21,7 +22,7 @@ public abstract class RemoveRightPartOfBinaryExpressionFix<T extends JetExpressi
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return "Remove right part of a binary expression";
|
||||
return JetBundle.message("remove.right.part.of.binary.expression");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -45,7 +46,7 @@ public abstract class RemoveRightPartOfBinaryExpressionFix<T extends JetExpressi
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return "Remove cast";
|
||||
return JetBundle.message("remove.cast");
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -61,7 +62,7 @@ public abstract class RemoveRightPartOfBinaryExpressionFix<T extends JetExpressi
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return "Remove elvis operator";
|
||||
return JetBundle.message("remove.elvis.operator");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
+3
-2
@@ -10,6 +10,7 @@ import org.jetbrains.jet.lang.diagnostics.DiagnosticWithPsiElement;
|
||||
import org.jetbrains.jet.lang.psi.JetBinaryExpressionWithTypeRHS;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
import org.jetbrains.jet.lang.psi.JetPsiFactory;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
@@ -24,7 +25,7 @@ public abstract class ReplaceOperationInBinaryExpressionFix<T extends JetExpress
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return "Replace operation in a binary expression";
|
||||
return JetBundle.message("replace.operation.in.binary.expression");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -48,7 +49,7 @@ public abstract class ReplaceOperationInBinaryExpressionFix<T extends JetExpress
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return "Replace a cast with a static assert";
|
||||
return JetBundle.message("replace.cast.with.static.assert");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
+6
-5
@@ -8,26 +8,27 @@ import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticWithPsiElement;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
*/
|
||||
public class ReplaceSafeCallToDotCall extends JetIntentionAction<JetElement> {
|
||||
public class ReplaceSafeCallWithDotCall extends JetIntentionAction<JetElement> {
|
||||
|
||||
public ReplaceSafeCallToDotCall(@NotNull JetElement element) {
|
||||
public ReplaceSafeCallWithDotCall(@NotNull JetElement element) {
|
||||
super(element);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return "Replace to dot call";
|
||||
return JetBundle.message("replace.with.dot.call");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return "Replace safe call to dot call";
|
||||
return JetBundle.message("replace.with.dot.call");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,7 +56,7 @@ public class ReplaceSafeCallToDotCall extends JetIntentionAction<JetElement> {
|
||||
@Override
|
||||
public JetIntentionAction<JetElement> createAction(DiagnosticWithPsiElement diagnostic) {
|
||||
assert diagnostic.getPsiElement() instanceof JetElement;
|
||||
return new ReplaceSafeCallToDotCall((JetElement) diagnostic.getPsiElement());
|
||||
return new ReplaceSafeCallWithDotCall((JetElement) diagnostic.getPsiElement());
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace to dot call" "true"
|
||||
// "Replace with dot call" "true"
|
||||
fun foo(a: Any) {
|
||||
<caret>a.equals(0)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace to dot call" "true"
|
||||
// "Replace with dot call" "true"
|
||||
fun foo(a: Any) {
|
||||
when (a) {
|
||||
.equals(0) => true
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace to dot call" "true"
|
||||
// "Replace with dot call" "true"
|
||||
fun foo(a: Any) {
|
||||
a<caret>?.equals(0)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace to dot call" "true"
|
||||
// "Replace with dot call" "true"
|
||||
fun foo(a: Any) {
|
||||
when (a) {
|
||||
<caret>?.equals(0) => true
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
package org.jetbrains.jet.plugin.quickfix;
|
||||
|
||||
import com.intellij.codeInsight.daemon.quickFix.LightQuickFixTestCase;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
*/
|
||||
public class AbstractModifierFixTest extends LightQuickFixTestCase {
|
||||
|
||||
public void test() throws Exception {
|
||||
doAllTests();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return "/quickfix/abstract";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return PluginTestCaseBase.getTestDataPathBase();
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package org.jetbrains.jet.plugin.quickfix;
|
||||
|
||||
import com.intellij.codeInsight.daemon.quickFix.LightQuickFixTestCase;
|
||||
import org.jetbrains.jet.JetTestCaseBase;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
*/
|
||||
public class AddPrimaryConstructorFixTest extends LightQuickFixTestCase {
|
||||
|
||||
public void test() throws Exception {
|
||||
doAllTests();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return "/quickfix/addPrimaryConstructor";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return PluginTestCaseBase.getTestDataPathBase();
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package org.jetbrains.jet.plugin.quickfix;
|
||||
|
||||
import com.intellij.codeInsight.daemon.quickFix.LightQuickFixTestCase;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
*/
|
||||
public class ChangeVariableMutabilityFixTest extends LightQuickFixTestCase {
|
||||
|
||||
public void test() throws Exception {
|
||||
doAllTests();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return "/quickfix/changeVariableMutability";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return PluginTestCaseBase.getTestDataPathBase();
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package org.jetbrains.jet.plugin.quickfix;
|
||||
|
||||
import com.intellij.codeInsight.daemon.quickFix.LightQuickFixTestCase;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import org.jetbrains.jet.JetTestCaseBase;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
*/
|
||||
public class ClassImportFixTest extends LightQuickFixTestCase {
|
||||
|
||||
public void test() throws Exception {
|
||||
doAllTests();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return "/quickfix/classImport";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return PluginTestCaseBase.getTestDataPathBase();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Sdk getProjectJDK() {
|
||||
return JetTestCaseBase.jdkFromIdeaHome();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
package org.jetbrains.jet.plugin.quickfix;
|
||||
|
||||
import com.intellij.codeInsight.daemon.quickFix.LightQuickFixTestCase;
|
||||
import org.jetbrains.jet.JetTestCaseBase;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
*/
|
||||
public class ExpressionsFixTest extends LightQuickFixTestCase {
|
||||
|
||||
public void test() throws Exception {
|
||||
doAllTests();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return "/quickfix/expressions";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return PluginTestCaseBase.getTestDataPathBase();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package org.jetbrains.jet.plugin.quickfix;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.intellij.codeInsight.daemon.quickFix.LightQuickFixTestCase;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.JetTestCaseBase;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
*/
|
||||
public class JetQuickFixTest extends LightQuickFixTestCase {
|
||||
private final String dataPath;
|
||||
private final String name;
|
||||
private static FilenameFilter quickFixTestsFilter;
|
||||
|
||||
public JetQuickFixTest(String dataPath, String name) {
|
||||
this.dataPath = dataPath;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
private static void setFilter() {
|
||||
final ArrayList<String> appropriateDirs = Lists.newArrayList("classImport", "expressions");
|
||||
quickFixTestsFilter = new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File file, String s) {
|
||||
if (appropriateDirs.contains(s)) return true;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
//setFilter(); //to launch only part of tests
|
||||
TestSuite suite = new TestSuite();
|
||||
FilenameFilter fileNameFilter = new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File file, String s) {
|
||||
if (s.startsWith("before")) return true;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
JetTestCaseBase.NamedTestFactory namedTestFactory = new JetTestCaseBase.NamedTestFactory() {
|
||||
@NotNull
|
||||
@Override
|
||||
public Test createTest(@NotNull String dataPath, @NotNull String name) {
|
||||
return new JetQuickFixTest(dataPath, name);
|
||||
}
|
||||
};
|
||||
File dir = new File(getTestDataPathBase());
|
||||
List<String> subDirs = Arrays.asList(quickFixTestsFilter != null ? dir.list(quickFixTestsFilter) : dir.list());
|
||||
Collections.sort(subDirs);
|
||||
for (String subDirName : subDirs) {
|
||||
suite.addTest(JetTestCaseBase.suiteForDirectory(getTestDataPathBase(), subDirName, false, fileNameFilter, namedTestFactory));
|
||||
|
||||
}
|
||||
return suite;
|
||||
}
|
||||
|
||||
public static String getTestDataPathBase() {
|
||||
return JetTestCaseBase.getHomeDirectory() + "/idea/testData/quickfix/";
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "test" + name.replaceFirst(name.substring(0, 1), name.substring(0, 1).toUpperCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runTest() throws Throwable {
|
||||
doSingleTest(name.substring("before".length()) + ".kt");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return "/quickfix/" + dataPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return PluginTestCaseBase.getTestDataPathBase();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Sdk getProjectJDK() {
|
||||
return JetTestCaseBase.jdkFromIdeaHome();
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package org.jetbrains.jet.plugin.quickfix;
|
||||
|
||||
import com.intellij.codeInsight.daemon.quickFix.LightQuickFixTestCase;
|
||||
import org.jetbrains.jet.JetTestCaseBase;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
*/
|
||||
public class ModifiersFixTest extends LightQuickFixTestCase {
|
||||
|
||||
public void test() throws Exception {
|
||||
doAllTests();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return "/quickfix/modifiers";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return PluginTestCaseBase.getTestDataPathBase();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
package org.jetbrains.jet.plugin.quickfix;
|
||||
|
||||
import com.intellij.codeInsight.daemon.quickFix.LightQuickFixTestCase;
|
||||
import org.jetbrains.jet.JetTestCaseBase;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
*/
|
||||
public class OverrideModifierFixTest extends LightQuickFixTestCase {
|
||||
|
||||
public void test() throws Exception {
|
||||
doAllTests();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return "/quickfix/override";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return PluginTestCaseBase.getTestDataPathBase();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
package org.jetbrains.jet.plugin.quickfix;
|
||||
|
||||
import com.intellij.codeInsight.daemon.quickFix.LightQuickFixTestCase;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import org.jetbrains.jet.JetTestCaseBase;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
*/
|
||||
public class TypeAdditionFixTests extends LightQuickFixTestCase {
|
||||
|
||||
public void test() throws Exception {
|
||||
doAllTests();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return "/quickfix/typeAddition";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return PluginTestCaseBase.getTestDataPathBase();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Sdk getProjectJDK() {
|
||||
return JetTestCaseBase.jdkFromIdeaHome();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user