Merge branch 'master' of ssh://git.labs.intellij.net/jet
This commit is contained in:
@@ -119,7 +119,7 @@ parameter
|
|||||||
;
|
;
|
||||||
|
|
||||||
object
|
object
|
||||||
: "object" SimpleName ":" delegationSpecifier{","}? classBody? // Class body can be optional: this is a declaration
|
: "object" SimpleName (":" delegationSpecifier{","})? classBody? // Class body can be optional: this is a declaration
|
||||||
/**
|
/**
|
||||||
bq. See [Object expressions and Declarations]
|
bq. See [Object expressions and Declarations]
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -235,7 +235,7 @@ jump
|
|||||||
// Ambiguity when after a SimpleName (infix call). In this case (e) is treated as an expression in parentheses
|
// Ambiguity when after a SimpleName (infix call). In this case (e) is treated as an expression in parentheses
|
||||||
// to put a tuple, write write ((e))
|
// to put a tuple, write write ((e))
|
||||||
tupleLiteral
|
tupleLiteral
|
||||||
: "(" ((SimpleName "=")? expression){","} ")"
|
: "(" (((SimpleName "=")? expression){","})? ")"
|
||||||
;
|
;
|
||||||
|
|
||||||
// one can use "it" as a parameter name
|
// one can use "it" as a parameter name
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ constantPattern
|
|||||||
;
|
;
|
||||||
|
|
||||||
tuplePattern
|
tuplePattern
|
||||||
: "(" ((SimpleName "=")? pattern{","})? ")"
|
: "(" (((SimpleName "=")? pattern){","})? ")"
|
||||||
;
|
;
|
||||||
|
|
||||||
bindingPattern
|
bindingPattern
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ class IntRange<T : Comparable<T>> : Range<T>, Iterable<T> {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class Number : Hashable {
|
abstract class Number : Hashable {
|
||||||
abstract val dbl : Double
|
abstract val dbl : Double
|
||||||
abstract val flt : Float
|
abstract val flt : Float
|
||||||
abstract val lng : Long
|
abstract val lng : Long
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ public interface JetNodeTypes {
|
|||||||
JetNodeType DELEGATOR_BY = new JetNodeType("DELEGATOR_BY", JetDelegatorByExpressionSpecifier.class);
|
JetNodeType DELEGATOR_BY = new JetNodeType("DELEGATOR_BY", JetDelegatorByExpressionSpecifier.class);
|
||||||
JetNodeType DELEGATOR_SUPER_CALL = new JetNodeType("DELEGATOR_SUPER_CALL", JetDelegatorToSuperCall.class);
|
JetNodeType DELEGATOR_SUPER_CALL = new JetNodeType("DELEGATOR_SUPER_CALL", JetDelegatorToSuperCall.class);
|
||||||
JetNodeType DELEGATOR_SUPER_CLASS = new JetNodeType("DELEGATOR_SUPER_CLASS", JetDelegatorToSuperClass.class);
|
JetNodeType DELEGATOR_SUPER_CLASS = new JetNodeType("DELEGATOR_SUPER_CLASS", JetDelegatorToSuperClass.class);
|
||||||
|
JetNodeType CONSTRUCTOR_CALLEE = new JetNodeType("CONSTRUCTOR_CALLEE", JetConstructorCalleeExpression.class);
|
||||||
JetNodeType VALUE_PARAMETER_LIST = new JetNodeType("VALUE_PARAMETER_LIST", JetParameterList.class);
|
JetNodeType VALUE_PARAMETER_LIST = new JetNodeType("VALUE_PARAMETER_LIST", JetParameterList.class);
|
||||||
JetNodeType VALUE_PARAMETER = new JetNodeType("VALUE_PARAMETER", JetParameter.class);
|
JetNodeType VALUE_PARAMETER = new JetNodeType("VALUE_PARAMETER", JetParameter.class);
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package org.jetbrains.jet.codegen;
|
|||||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
|
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
|
||||||
import org.jetbrains.jet.lang.psi.*;
|
import org.jetbrains.jet.lang.psi.*;
|
||||||
|
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||||
import org.objectweb.asm.ClassVisitor;
|
import org.objectweb.asm.ClassVisitor;
|
||||||
import org.objectweb.asm.MethodVisitor;
|
import org.objectweb.asm.MethodVisitor;
|
||||||
import org.objectweb.asm.Opcodes;
|
import org.objectweb.asm.Opcodes;
|
||||||
@@ -29,7 +30,7 @@ public abstract class ClassBodyCodegen {
|
|||||||
|
|
||||||
public ClassBodyCodegen(JetClassOrObject aClass, ClassContext context, ClassVisitor v, GenerationState state) {
|
public ClassBodyCodegen(JetClassOrObject aClass, ClassContext context, ClassVisitor v, GenerationState state) {
|
||||||
this.state = state;
|
this.state = state;
|
||||||
descriptor = state.getBindingContext().getClassDescriptor(aClass);
|
descriptor = state.getBindingContext().get(BindingContext.CLASS, aClass);
|
||||||
myClass = aClass;
|
myClass = aClass;
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.kind = context.getContextKind();
|
this.kind = context.getContextKind();
|
||||||
@@ -81,14 +82,14 @@ public abstract class ClassBodyCodegen {
|
|||||||
OwnerKind kind = context.getContextKind();
|
OwnerKind kind = context.getContextKind();
|
||||||
for (JetParameter p : getPrimaryConstructorParameters()) {
|
for (JetParameter p : getPrimaryConstructorParameters()) {
|
||||||
if (p.getValOrVarNode() != null) {
|
if (p.getValOrVarNode() != null) {
|
||||||
PropertyDescriptor propertyDescriptor = state.getBindingContext().getPropertyDescriptor(p);
|
PropertyDescriptor propertyDescriptor = state.getBindingContext().get(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, p);
|
||||||
if (propertyDescriptor != null) {
|
if (propertyDescriptor != null) {
|
||||||
propertyCodegen.generateDefaultGetter(propertyDescriptor, Opcodes.ACC_PUBLIC);
|
propertyCodegen.generateDefaultGetter(propertyDescriptor, Opcodes.ACC_PUBLIC);
|
||||||
if (propertyDescriptor.isVar()) {
|
if (propertyDescriptor.isVar()) {
|
||||||
propertyCodegen.generateDefaultSetter(propertyDescriptor, Opcodes.ACC_PUBLIC);
|
propertyCodegen.generateDefaultSetter(propertyDescriptor, Opcodes.ACC_PUBLIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(kind instanceof OwnerKind.DelegateKind) && kind != OwnerKind.INTERFACE && state.getBindingContext().hasBackingField(propertyDescriptor)) {
|
if (!(kind instanceof OwnerKind.DelegateKind) && kind != OwnerKind.INTERFACE && state.getBindingContext().get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor)) {
|
||||||
v.visitField(Opcodes.ACC_PRIVATE, p.getName(), state.getTypeMapper().mapType(propertyDescriptor.getOutType()).getDescriptor(), null, null);
|
v.visitField(Opcodes.ACC_PRIVATE, p.getName(), state.getTypeMapper().mapType(propertyDescriptor.getOutType()).getDescriptor(), null, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package org.jetbrains.jet.codegen;
|
|||||||
|
|
||||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||||
import org.jetbrains.jet.lang.psi.*;
|
import org.jetbrains.jet.lang.psi.*;
|
||||||
|
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||||
import org.objectweb.asm.ClassVisitor;
|
import org.objectweb.asm.ClassVisitor;
|
||||||
import org.objectweb.asm.Type;
|
import org.objectweb.asm.Type;
|
||||||
import org.objectweb.asm.commons.InstructionAdapter;
|
import org.objectweb.asm.commons.InstructionAdapter;
|
||||||
@@ -30,7 +31,7 @@ public class ClassCodegen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ClassDescriptor descriptor = state.getBindingContext().getClassDescriptor(aClass);
|
ClassDescriptor descriptor = state.getBindingContext().get(BindingContext.CLASS, aClass);
|
||||||
final ClassContext contextForInners = parentContext.intoClass(descriptor, OwnerKind.IMPLEMENTATION);
|
final ClassContext contextForInners = parentContext.intoClass(descriptor, OwnerKind.IMPLEMENTATION);
|
||||||
for (JetDeclaration declaration : aClass.getDeclarations()) {
|
for (JetDeclaration declaration : aClass.getDeclarations()) {
|
||||||
if (declaration instanceof JetClass && !(declaration instanceof JetEnumEntry)) {
|
if (declaration instanceof JetClass && !(declaration instanceof JetEnumEntry)) {
|
||||||
@@ -40,13 +41,13 @@ public class ClassCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void generateInterface(ClassContext parentContext, JetClassOrObject aClass) {
|
private void generateInterface(ClassContext parentContext, JetClassOrObject aClass) {
|
||||||
ClassDescriptor descriptor = state.getBindingContext().getClassDescriptor(aClass);
|
ClassDescriptor descriptor = state.getBindingContext().get(BindingContext.CLASS, aClass);
|
||||||
final ClassVisitor visitor = state.forClassInterface(descriptor);
|
final ClassVisitor visitor = state.forClassInterface(descriptor);
|
||||||
new InterfaceBodyCodegen(aClass, parentContext.intoClass(descriptor, OwnerKind.INTERFACE), visitor, state).generate();
|
new InterfaceBodyCodegen(aClass, parentContext.intoClass(descriptor, OwnerKind.INTERFACE), visitor, state).generate();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generateImplementation(ClassContext parentContext, JetClassOrObject aClass, OwnerKind kind) {
|
private void generateImplementation(ClassContext parentContext, JetClassOrObject aClass, OwnerKind kind) {
|
||||||
ClassDescriptor descriptor = state.getBindingContext().getClassDescriptor(aClass);
|
ClassDescriptor descriptor = state.getBindingContext().get(BindingContext.CLASS, aClass);
|
||||||
ClassVisitor v = kind == OwnerKind.IMPLEMENTATION
|
ClassVisitor v = kind == OwnerKind.IMPLEMENTATION
|
||||||
? state.forClassImplementation(descriptor)
|
? state.forClassImplementation(descriptor)
|
||||||
: state.forClassDelegatingImplementation(descriptor);
|
: state.forClassDelegatingImplementation(descriptor);
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class ClassContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public StackValue getThisExpression() {
|
public StackValue getThisExpression() {
|
||||||
if (parentContext == null) return null;
|
if (parentContext == null) return StackValue.none();
|
||||||
|
|
||||||
thisWasUsed = true;
|
thisWasUsed = true;
|
||||||
if (thisExpression != null) return thisExpression;
|
if (thisExpression != null) return thisExpression;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
|
|||||||
import org.jetbrains.jet.lang.descriptors.VariableDescriptor;
|
import org.jetbrains.jet.lang.descriptors.VariableDescriptor;
|
||||||
import org.jetbrains.jet.lang.psi.JetFunctionLiteral;
|
import org.jetbrains.jet.lang.psi.JetFunctionLiteral;
|
||||||
import org.jetbrains.jet.lang.psi.JetFunctionLiteralExpression;
|
import org.jetbrains.jet.lang.psi.JetFunctionLiteralExpression;
|
||||||
|
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||||
import org.jetbrains.jet.lang.types.JetType;
|
import org.jetbrains.jet.lang.types.JetType;
|
||||||
import org.objectweb.asm.ClassVisitor;
|
import org.objectweb.asm.ClassVisitor;
|
||||||
import org.objectweb.asm.MethodVisitor;
|
import org.objectweb.asm.MethodVisitor;
|
||||||
@@ -83,7 +84,7 @@ public class ClosureCodegen {
|
|||||||
public GeneratedAnonymousClassDescriptor gen(JetFunctionLiteralExpression fun) {
|
public GeneratedAnonymousClassDescriptor gen(JetFunctionLiteralExpression fun) {
|
||||||
final Pair<String, ClassVisitor> nameAndVisitor = state.forAnonymousSubclass(fun);
|
final Pair<String, ClassVisitor> nameAndVisitor = state.forAnonymousSubclass(fun);
|
||||||
|
|
||||||
final FunctionDescriptor funDescriptor = (FunctionDescriptor) state.getBindingContext().getDeclarationDescriptor(fun);
|
final FunctionDescriptor funDescriptor = (FunctionDescriptor) state.getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, fun);
|
||||||
|
|
||||||
cv = nameAndVisitor.getSecond();
|
cv = nameAndVisitor.getSecond();
|
||||||
name = nameAndVisitor.getFirst();
|
name = nameAndVisitor.getFirst();
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,10 @@ package org.jetbrains.jet.codegen;
|
|||||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
|
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
|
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
|
||||||
import org.jetbrains.jet.lang.psi.*;
|
import org.jetbrains.jet.lang.psi.JetDeclarationWithBody;
|
||||||
|
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||||
|
import org.jetbrains.jet.lang.psi.JetNamedFunction;
|
||||||
|
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||||
import org.objectweb.asm.ClassVisitor;
|
import org.objectweb.asm.ClassVisitor;
|
||||||
import org.objectweb.asm.MethodVisitor;
|
import org.objectweb.asm.MethodVisitor;
|
||||||
import org.objectweb.asm.Opcodes;
|
import org.objectweb.asm.Opcodes;
|
||||||
@@ -11,7 +14,6 @@ import org.objectweb.asm.Type;
|
|||||||
import org.objectweb.asm.commons.InstructionAdapter;
|
import org.objectweb.asm.commons.InstructionAdapter;
|
||||||
import org.objectweb.asm.commons.Method;
|
import org.objectweb.asm.commons.Method;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -31,7 +33,7 @@ public class FunctionCodegen {
|
|||||||
|
|
||||||
public void gen(JetNamedFunction f) {
|
public void gen(JetNamedFunction f) {
|
||||||
Method method = state.getTypeMapper().mapToCallableMethod(f).getSignature();
|
Method method = state.getTypeMapper().mapToCallableMethod(f).getSignature();
|
||||||
final FunctionDescriptor functionDescriptor = state.getBindingContext().getFunctionDescriptor(f);
|
final FunctionDescriptor functionDescriptor = state.getBindingContext().get(BindingContext.FUNCTION, f);
|
||||||
generateMethod(f, method, functionDescriptor);
|
generateMethod(f, method, functionDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,11 +41,10 @@ public class FunctionCodegen {
|
|||||||
ClassContext funContext = owner.intoFunction(functionDescriptor);
|
ClassContext funContext = owner.intoFunction(functionDescriptor);
|
||||||
|
|
||||||
final JetExpression bodyExpression = f.getBodyExpression();
|
final JetExpression bodyExpression = f.getBodyExpression();
|
||||||
final List<JetElement> bodyExpressions = bodyExpression != null ? Collections.<JetElement>singletonList(bodyExpression) : null;
|
generatedMethod(bodyExpression, jvmMethod, funContext, functionDescriptor.getValueParameters(), functionDescriptor.getTypeParameters());
|
||||||
generatedMethod(bodyExpressions, jvmMethod, funContext, functionDescriptor.getValueParameters(), functionDescriptor.getTypeParameters());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generatedMethod(List<JetElement> bodyExpressions,
|
private void generatedMethod(JetExpression bodyExpressions,
|
||||||
Method jvmSignature,
|
Method jvmSignature,
|
||||||
ClassContext context,
|
ClassContext context,
|
||||||
List<ValueParameterDescriptor> paramDescrs,
|
List<ValueParameterDescriptor> paramDescrs,
|
||||||
@@ -94,35 +95,11 @@ public class FunctionCodegen {
|
|||||||
iv.areturn(jvmSignature.getReturnType());
|
iv.areturn(jvmSignature.getReturnType());
|
||||||
}
|
}
|
||||||
else if (!isAbstract) {
|
else if (!isAbstract) {
|
||||||
JetElement last = null;
|
codegen.returnExpression(bodyExpressions);
|
||||||
for (JetElement expression : bodyExpressions) {
|
|
||||||
expression.accept(codegen);
|
|
||||||
last = expression;
|
|
||||||
}
|
|
||||||
generateReturn(mv, last, codegen, jvmSignature);
|
|
||||||
}
|
}
|
||||||
mv.visitMaxs(0, 0);
|
mv.visitMaxs(0, 0);
|
||||||
mv.visitEnd();
|
mv.visitEnd();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generateReturn(MethodVisitor mv, JetElement bodyExpression, ExpressionCodegen codegen, Method jvmSignature) {
|
|
||||||
if (!endsWithReturn(bodyExpression)) {
|
|
||||||
if (jvmSignature.getReturnType() == Type.VOID_TYPE) {
|
|
||||||
mv.visitInsn(Opcodes.RETURN);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
codegen.returnTopOfStack();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean endsWithReturn(JetElement bodyExpression) {
|
|
||||||
if (bodyExpression instanceof JetBlockExpression) {
|
|
||||||
final List<JetElement> statements = ((JetBlockExpression) bodyExpression).getStatements();
|
|
||||||
return statements.size() > 0 && statements.get(statements.size()-1) instanceof JetReturnExpression;
|
|
||||||
}
|
|
||||||
|
|
||||||
return bodyExpression instanceof JetReturnExpression;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ public class GenerationState {
|
|||||||
public GeneratedAnonymousClassDescriptor generateObjectLiteral(JetObjectLiteralExpression literal, ExpressionCodegen context, ClassContext classContext) {
|
public GeneratedAnonymousClassDescriptor generateObjectLiteral(JetObjectLiteralExpression literal, ExpressionCodegen context, ClassContext classContext) {
|
||||||
Pair<String, ClassVisitor> nameAndVisitor = forAnonymousSubclass(literal.getObjectDeclaration());
|
Pair<String, ClassVisitor> nameAndVisitor = forAnonymousSubclass(literal.getObjectDeclaration());
|
||||||
|
|
||||||
final ClassContext objectContext = classContext.intoClass(getBindingContext().getClassDescriptor(literal.getObjectDeclaration()), OwnerKind.IMPLEMENTATION);
|
final ClassContext objectContext = classContext.intoClass(getBindingContext().get(BindingContext.CLASS, literal.getObjectDeclaration()), OwnerKind.IMPLEMENTATION);
|
||||||
|
|
||||||
new ImplementationBodyCodegen(literal.getObjectDeclaration(), objectContext, nameAndVisitor.getSecond(), this).generate();
|
new ImplementationBodyCodegen(literal.getObjectDeclaration(), objectContext, nameAndVisitor.getSecond(), this).generate();
|
||||||
return new GeneratedAnonymousClassDescriptor(nameAndVisitor.first, new Method("<init>", "()V"), false);
|
return new GeneratedAnonymousClassDescriptor(nameAndVisitor.first, new Method("<init>", "()V"), false);
|
||||||
@@ -122,4 +122,5 @@ public class GenerationState {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.intellij.psi.PsiElement;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.lang.descriptors.*;
|
import org.jetbrains.jet.lang.descriptors.*;
|
||||||
import org.jetbrains.jet.lang.psi.*;
|
import org.jetbrains.jet.lang.psi.*;
|
||||||
|
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||||
import org.jetbrains.jet.lang.types.JetType;
|
import org.jetbrains.jet.lang.types.JetType;
|
||||||
import org.jetbrains.jet.lexer.JetTokens;
|
import org.jetbrains.jet.lexer.JetTokens;
|
||||||
import org.objectweb.asm.ClassVisitor;
|
import org.objectweb.asm.ClassVisitor;
|
||||||
@@ -61,9 +62,9 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
|
|
||||||
JetDelegationSpecifier first = delegationSpecifiers.get(0);
|
JetDelegationSpecifier first = delegationSpecifiers.get(0);
|
||||||
if (first instanceof JetDelegatorToSuperClass || first instanceof JetDelegatorToSuperCall) {
|
if (first instanceof JetDelegatorToSuperClass || first instanceof JetDelegatorToSuperCall) {
|
||||||
JetType superType = state.getBindingContext().resolveTypeReference(first.getTypeReference());
|
JetType superType = state.getBindingContext().get(BindingContext.TYPE, first.getTypeReference());
|
||||||
ClassDescriptor superClassDescriptor = (ClassDescriptor) superType.getConstructor().getDeclarationDescriptor();
|
ClassDescriptor superClassDescriptor = (ClassDescriptor) superType.getConstructor().getDeclarationDescriptor();
|
||||||
final PsiElement declaration = state.getBindingContext().getDeclarationPsiElement(superClassDescriptor);
|
final PsiElement declaration = state.getBindingContext().get(BindingContext.DESCRIPTOR_TO_DECLARATION, superClassDescriptor);
|
||||||
if (declaration instanceof PsiClass && ((PsiClass) declaration).isInterface()) {
|
if (declaration instanceof PsiClass && ((PsiClass) declaration).isInterface()) {
|
||||||
return "java/lang/Object";
|
return "java/lang/Object";
|
||||||
}
|
}
|
||||||
@@ -146,7 +147,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void generatePrimaryConstructor() {
|
protected void generatePrimaryConstructor() {
|
||||||
ConstructorDescriptor constructorDescriptor = state.getBindingContext().getConstructorDescriptor((JetElement) myClass);
|
ConstructorDescriptor constructorDescriptor = state.getBindingContext().get(BindingContext.CONSTRUCTOR, (JetElement) myClass);
|
||||||
if (constructorDescriptor == null && !(myClass instanceof JetObjectDeclaration) && !isEnum(myClass)) return;
|
if (constructorDescriptor == null && !(myClass instanceof JetObjectDeclaration) && !isEnum(myClass)) return;
|
||||||
|
|
||||||
Method method;
|
Method method;
|
||||||
@@ -182,7 +183,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
// TODO correct calculation of super class
|
// TODO correct calculation of super class
|
||||||
String superClass = "java/lang/Object";
|
String superClass = "java/lang/Object";
|
||||||
if (!specifiers.isEmpty()) {
|
if (!specifiers.isEmpty()) {
|
||||||
final JetType superType = state.getBindingContext().resolveTypeReference(specifiers.get(0).getTypeReference());
|
final JetType superType = state.getBindingContext().get(BindingContext.TYPE, specifiers.get(0).getTypeReference());
|
||||||
ClassDescriptor superClassDescriptor = (ClassDescriptor) superType.getConstructor().getDeclarationDescriptor();
|
ClassDescriptor superClassDescriptor = (ClassDescriptor) superType.getConstructor().getDeclarationDescriptor();
|
||||||
if (superClassDescriptor.hasConstructors()) {
|
if (superClassDescriptor.hasConstructors()) {
|
||||||
superClass = getSuperClass();
|
superClass = getSuperClass();
|
||||||
@@ -215,7 +216,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
HashSet<FunctionDescriptor> overridden = new HashSet<FunctionDescriptor>();
|
HashSet<FunctionDescriptor> overridden = new HashSet<FunctionDescriptor>();
|
||||||
for (JetDeclaration declaration : myClass.getDeclarations()) {
|
for (JetDeclaration declaration : myClass.getDeclarations()) {
|
||||||
if (declaration instanceof JetFunction) {
|
if (declaration instanceof JetFunction) {
|
||||||
overridden.addAll(state.getBindingContext().getFunctionDescriptor((JetNamedFunction) declaration).getOverriddenFunctions());
|
overridden.addAll(state.getBindingContext().get(BindingContext.FUNCTION, (JetNamedFunction) declaration).getOverriddenFunctions());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,7 +230,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (specifier instanceof JetDelegatorToSuperCall) {
|
if (specifier instanceof JetDelegatorToSuperCall) {
|
||||||
ConstructorDescriptor constructorDescriptor1 = state.getBindingContext().resolveSuperConstructor((JetDelegatorToSuperCall) specifier);
|
ConstructorDescriptor constructorDescriptor1 = (ConstructorDescriptor) state.getBindingContext().get(BindingContext.REFERENCE_TARGET, ((JetDelegatorToSuperCall) specifier).getCalleeExpression().getConstructorReferenceExpression());
|
||||||
generateDelegatorToConstructorCall(iv, codegen, (JetDelegatorToSuperCall) specifier, constructorDescriptor1, n == 0, frameMap);
|
generateDelegatorToConstructorCall(iv, codegen, (JetDelegatorToSuperCall) specifier, constructorDescriptor1, n == 0, frameMap);
|
||||||
}
|
}
|
||||||
else if (specifier instanceof JetDelegatorByExpressionSpecifier) {
|
else if (specifier instanceof JetDelegatorByExpressionSpecifier) {
|
||||||
@@ -237,7 +238,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (delegateOnStack) {
|
if (delegateOnStack) {
|
||||||
JetType superType = state.getBindingContext().resolveTypeReference(specifier.getTypeReference());
|
JetType superType = state.getBindingContext().get(BindingContext.TYPE, specifier.getTypeReference());
|
||||||
ClassDescriptor superClassDescriptor = (ClassDescriptor) superType.getConstructor().getDeclarationDescriptor();
|
ClassDescriptor superClassDescriptor = (ClassDescriptor) superType.getConstructor().getDeclarationDescriptor();
|
||||||
String delegateField = "$delegate_" + n;
|
String delegateField = "$delegate_" + n;
|
||||||
Type fieldType = JetTypeMapper.jetInterfaceType(superClassDescriptor);
|
Type fieldType = JetTypeMapper.jetInterfaceType(superClassDescriptor);
|
||||||
@@ -245,7 +246,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
v.visitField(Opcodes.ACC_PRIVATE, delegateField, fieldDesc, /*TODO*/null, null);
|
v.visitField(Opcodes.ACC_PRIVATE, delegateField, fieldDesc, /*TODO*/null, null);
|
||||||
iv.putfield(classname, delegateField, fieldDesc);
|
iv.putfield(classname, delegateField, fieldDesc);
|
||||||
|
|
||||||
JetClass superClass = (JetClass) state.getBindingContext().getDeclarationPsiElement(superClassDescriptor);
|
JetClass superClass = (JetClass) state.getBindingContext().get(BindingContext.DESCRIPTOR_TO_DECLARATION, superClassDescriptor);
|
||||||
final ClassContext delegateContext = context.intoClass(superClassDescriptor,
|
final ClassContext delegateContext = context.intoClass(superClassDescriptor,
|
||||||
new OwnerKind.DelegateKind(StackValue.field(fieldType, classname, delegateField, false),
|
new OwnerKind.DelegateKind(StackValue.field(fieldType, classname, delegateField, false),
|
||||||
JetTypeMapper.jvmNameForInterface(superClassDescriptor)));
|
JetTypeMapper.jvmNameForInterface(superClassDescriptor)));
|
||||||
@@ -298,7 +299,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
ConstructorFrameMap frameMap) {
|
ConstructorFrameMap frameMap) {
|
||||||
ClassDescriptor classDecl = constructorDescriptor.getContainingDeclaration();
|
ClassDescriptor classDecl = constructorDescriptor.getContainingDeclaration();
|
||||||
boolean isDelegating = kind == OwnerKind.DELEGATING_IMPLEMENTATION;
|
boolean isDelegating = kind == OwnerKind.DELEGATING_IMPLEMENTATION;
|
||||||
PsiElement declaration = state.getBindingContext().getDeclarationPsiElement(classDecl);
|
PsiElement declaration = state.getBindingContext().get(BindingContext.DESCRIPTOR_TO_DECLARATION, classDecl);
|
||||||
Type type;
|
Type type;
|
||||||
if (declaration instanceof PsiClass) {
|
if (declaration instanceof PsiClass) {
|
||||||
type = JetTypeMapper.psiClassType((PsiClass) declaration);
|
type = JetTypeMapper.psiClassType((PsiClass) declaration);
|
||||||
@@ -348,7 +349,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void generateSecondaryConstructor(JetConstructor constructor) {
|
private void generateSecondaryConstructor(JetConstructor constructor) {
|
||||||
ConstructorDescriptor constructorDescriptor = state.getBindingContext().getConstructorDescriptor(constructor);
|
ConstructorDescriptor constructorDescriptor = state.getBindingContext().get(BindingContext.CONSTRUCTOR, constructor);
|
||||||
if (constructorDescriptor == null) {
|
if (constructorDescriptor == null) {
|
||||||
throw new UnsupportedOperationException("failed to get descriptor for secondary constructor");
|
throw new UnsupportedOperationException("failed to get descriptor for secondary constructor");
|
||||||
}
|
}
|
||||||
@@ -365,7 +366,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
for (JetDelegationSpecifier initializer : constructor.getInitializers()) {
|
for (JetDelegationSpecifier initializer : constructor.getInitializers()) {
|
||||||
if (initializer instanceof JetDelegatorToThisCall) {
|
if (initializer instanceof JetDelegatorToThisCall) {
|
||||||
JetDelegatorToThisCall thisCall = (JetDelegatorToThisCall) initializer;
|
JetDelegatorToThisCall thisCall = (JetDelegatorToThisCall) initializer;
|
||||||
DeclarationDescriptor thisDescriptor = state.getBindingContext().resolveReferenceExpression(thisCall.getThisReference());
|
DeclarationDescriptor thisDescriptor = state.getBindingContext().get(BindingContext.REFERENCE_TARGET, thisCall.getThisReference());
|
||||||
if (!(thisDescriptor instanceof ConstructorDescriptor)) {
|
if (!(thisDescriptor instanceof ConstructorDescriptor)) {
|
||||||
throw new UnsupportedOperationException("expected 'this' delegator to resolve to constructor");
|
throw new UnsupportedOperationException("expected 'this' delegator to resolve to constructor");
|
||||||
}
|
}
|
||||||
@@ -409,8 +410,8 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
protected void generateInitializers(ExpressionCodegen codegen, InstructionAdapter iv) {
|
protected void generateInitializers(ExpressionCodegen codegen, InstructionAdapter iv) {
|
||||||
for (JetDeclaration declaration : myClass.getDeclarations()) {
|
for (JetDeclaration declaration : myClass.getDeclarations()) {
|
||||||
if (declaration instanceof JetProperty) {
|
if (declaration instanceof JetProperty) {
|
||||||
final PropertyDescriptor propertyDescriptor = (PropertyDescriptor) state.getBindingContext().getVariableDescriptor((JetProperty) declaration);
|
final PropertyDescriptor propertyDescriptor = (PropertyDescriptor) state.getBindingContext().get(BindingContext.VARIABLE, (JetProperty) declaration);
|
||||||
if (state.getBindingContext().hasBackingField(propertyDescriptor)) {
|
if ((boolean) state.getBindingContext().get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor)) {
|
||||||
final JetExpression initializer = ((JetProperty) declaration).getInitializer();
|
final JetExpression initializer = ((JetProperty) declaration).getInitializer();
|
||||||
if (initializer != null) {
|
if (initializer != null) {
|
||||||
iv.load(0, JetTypeMapper.TYPE_OBJECT);
|
iv.load(0, JetTypeMapper.TYPE_OBJECT);
|
||||||
@@ -435,7 +436,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
propertyCodegen.gen((JetProperty) declaration);
|
propertyCodegen.gen((JetProperty) declaration);
|
||||||
}
|
}
|
||||||
else if (declaration instanceof JetFunction) {
|
else if (declaration instanceof JetFunction) {
|
||||||
if (!overriden.contains(state.getBindingContext().getFunctionDescriptor((JetNamedFunction) declaration))) {
|
if (!overriden.contains(state.getBindingContext().get(BindingContext.FUNCTION, (JetNamedFunction) declaration))) {
|
||||||
functionCodegen.gen((JetNamedFunction) declaration);
|
functionCodegen.gen((JetNamedFunction) declaration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -443,7 +444,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
|
|
||||||
for (JetParameter p : toClass.getPrimaryConstructorParameters()) {
|
for (JetParameter p : toClass.getPrimaryConstructorParameters()) {
|
||||||
if (p.getValOrVarNode() != null) {
|
if (p.getValOrVarNode() != null) {
|
||||||
PropertyDescriptor propertyDescriptor = state.getBindingContext().getPropertyDescriptor(p);
|
PropertyDescriptor propertyDescriptor = state.getBindingContext().get(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, p);
|
||||||
if (propertyDescriptor != null) {
|
if (propertyDescriptor != null) {
|
||||||
propertyCodegen.generateDefaultGetter(propertyDescriptor, Opcodes.ACC_PUBLIC);
|
propertyCodegen.generateDefaultGetter(propertyDescriptor, Opcodes.ACC_PUBLIC);
|
||||||
if (propertyDescriptor.isVar()) {
|
if (propertyDescriptor.isVar()) {
|
||||||
|
|||||||
@@ -47,9 +47,9 @@ public class InterfaceBodyCodegen extends ClassBodyCodegen {
|
|||||||
String superClassName = null;
|
String superClassName = null;
|
||||||
Set<String> superInterfaces = new LinkedHashSet<String>();
|
Set<String> superInterfaces = new LinkedHashSet<String>();
|
||||||
for (JetDelegationSpecifier specifier : delegationSpecifiers) {
|
for (JetDelegationSpecifier specifier : delegationSpecifiers) {
|
||||||
JetType superType = bindingContext.resolveTypeReference(specifier.getTypeReference());
|
JetType superType = bindingContext.get(BindingContext.TYPE, specifier.getTypeReference());
|
||||||
ClassDescriptor superClassDescriptor = (ClassDescriptor) superType.getConstructor().getDeclarationDescriptor();
|
ClassDescriptor superClassDescriptor = (ClassDescriptor) superType.getConstructor().getDeclarationDescriptor();
|
||||||
PsiElement superPsi = bindingContext.getDeclarationPsiElement(superClassDescriptor);
|
PsiElement superPsi = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, superClassDescriptor);
|
||||||
|
|
||||||
if (superPsi instanceof PsiClass) {
|
if (superPsi instanceof PsiClass) {
|
||||||
PsiClass psiClass = (PsiClass) superPsi;
|
PsiClass psiClass = (PsiClass) superPsi;
|
||||||
@@ -120,7 +120,7 @@ public class InterfaceBodyCodegen extends ClassBodyCodegen {
|
|||||||
final JetDelegationSpecifier specifier = delegationSpecifiers.get(0);
|
final JetDelegationSpecifier specifier = delegationSpecifiers.get(0);
|
||||||
if (specifier instanceof JetDelegatorToSuperCall) {
|
if (specifier instanceof JetDelegatorToSuperCall) {
|
||||||
final JetDelegatorToSuperCall superCall = (JetDelegatorToSuperCall) specifier;
|
final JetDelegatorToSuperCall superCall = (JetDelegatorToSuperCall) specifier;
|
||||||
ConstructorDescriptor constructorDescriptor = state.getBindingContext().resolveSuperConstructor(superCall);
|
ConstructorDescriptor constructorDescriptor = (ConstructorDescriptor) state.getBindingContext().get(BindingContext.REFERENCE_TARGET, superCall.getCalleeExpression().getConstructorReferenceExpression());
|
||||||
CallableMethod method = state.getTypeMapper().mapToCallableMethod(constructorDescriptor, OwnerKind.IMPLEMENTATION);
|
CallableMethod method = state.getTypeMapper().mapToCallableMethod(constructorDescriptor, OwnerKind.IMPLEMENTATION);
|
||||||
codegen.invokeMethodWithArguments(method, superCall);
|
codegen.invokeMethodWithArguments(method, superCall);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ public class JetTypeMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String jvmName(ClassDescriptor jetClass, OwnerKind kind) {
|
public String jvmName(ClassDescriptor jetClass, OwnerKind kind) {
|
||||||
PsiElement declaration = bindingContext.getDeclarationPsiElement(jetClass);
|
PsiElement declaration = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, jetClass);
|
||||||
if (declaration instanceof PsiClass) {
|
if (declaration instanceof PsiClass) {
|
||||||
return jvmName((PsiClass) declaration);
|
return jvmName((PsiClass) declaration);
|
||||||
}
|
}
|
||||||
@@ -146,7 +146,7 @@ public class JetTypeMapper {
|
|||||||
final PsiElement parent = declaration.getParent();
|
final PsiElement parent = declaration.getParent();
|
||||||
if (parent instanceof JetClassObject) {
|
if (parent instanceof JetClassObject) {
|
||||||
JetClass containingClass = PsiTreeUtil.getParentOfType(parent, JetClass.class);
|
JetClass containingClass = PsiTreeUtil.getParentOfType(parent, JetClass.class);
|
||||||
final ClassDescriptor containingClassDescriptor = bindingContext.getClassDescriptor(containingClass);
|
final ClassDescriptor containingClassDescriptor = bindingContext.get(BindingContext.CLASS, containingClass);
|
||||||
return jvmName(containingClassDescriptor, OwnerKind.INTERFACE) + "$$ClassObj";
|
return jvmName(containingClassDescriptor, OwnerKind.INTERFACE) + "$$ClassObj";
|
||||||
}
|
}
|
||||||
String className = classNamesForAnonymousClasses.get(declaration);
|
String className = classNamesForAnonymousClasses.get(declaration);
|
||||||
@@ -159,12 +159,12 @@ public class JetTypeMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String jvmName(JetClassObject classObject) {
|
public String jvmName(JetClassObject classObject) {
|
||||||
final ClassDescriptor descriptor = bindingContext.getClassDescriptor(classObject.getObjectDeclaration());
|
final ClassDescriptor descriptor = bindingContext.get(BindingContext.CLASS, classObject.getObjectDeclaration());
|
||||||
return jvmName(descriptor, OwnerKind.IMPLEMENTATION);
|
return jvmName(descriptor, OwnerKind.IMPLEMENTATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInterface(ClassDescriptor jetClass, OwnerKind kind) {
|
public boolean isInterface(ClassDescriptor jetClass, OwnerKind kind) {
|
||||||
PsiElement declaration = bindingContext.getDeclarationPsiElement(jetClass);
|
PsiElement declaration = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, jetClass);
|
||||||
if (declaration instanceof JetObjectDeclaration) {
|
if (declaration instanceof JetObjectDeclaration) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -372,14 +372,14 @@ public class JetTypeMapper {
|
|||||||
|
|
||||||
private Method mapSignature(JetNamedFunction f, List<Type> valueParameterTypes) {
|
private Method mapSignature(JetNamedFunction f, List<Type> valueParameterTypes) {
|
||||||
final JetTypeReference receiverTypeRef = f.getReceiverTypeRef();
|
final JetTypeReference receiverTypeRef = f.getReceiverTypeRef();
|
||||||
final JetType receiverType = receiverTypeRef == null ? null : bindingContext.resolveTypeReference(receiverTypeRef);
|
final JetType receiverType = receiverTypeRef == null ? null : bindingContext.get(BindingContext.TYPE, receiverTypeRef);
|
||||||
final List<JetParameter> parameters = f.getValueParameters();
|
final List<JetParameter> parameters = f.getValueParameters();
|
||||||
List<Type> parameterTypes = new ArrayList<Type>();
|
List<Type> parameterTypes = new ArrayList<Type>();
|
||||||
if (receiverType != null) {
|
if (receiverType != null) {
|
||||||
parameterTypes.add(mapType(receiverType));
|
parameterTypes.add(mapType(receiverType));
|
||||||
}
|
}
|
||||||
for (JetParameter parameter : parameters) {
|
for (JetParameter parameter : parameters) {
|
||||||
final Type type = mapType(bindingContext.resolveTypeReference(parameter.getTypeReference()));
|
final Type type = mapType(bindingContext.get(BindingContext.TYPE, parameter.getTypeReference()));
|
||||||
valueParameterTypes.add(type);
|
valueParameterTypes.add(type);
|
||||||
parameterTypes.add(type);
|
parameterTypes.add(type);
|
||||||
}
|
}
|
||||||
@@ -389,12 +389,12 @@ public class JetTypeMapper {
|
|||||||
final JetTypeReference returnTypeRef = f.getReturnTypeRef();
|
final JetTypeReference returnTypeRef = f.getReturnTypeRef();
|
||||||
Type returnType;
|
Type returnType;
|
||||||
if (returnTypeRef == null) {
|
if (returnTypeRef == null) {
|
||||||
final FunctionDescriptor functionDescriptor = bindingContext.getFunctionDescriptor(f);
|
final FunctionDescriptor functionDescriptor = bindingContext.get(BindingContext.FUNCTION, f);
|
||||||
final JetType type = functionDescriptor.getReturnType();
|
final JetType type = functionDescriptor.getReturnType();
|
||||||
returnType = mapType(type);
|
returnType = mapType(type);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
returnType = mapType(bindingContext.resolveTypeReference(returnTypeRef));
|
returnType = mapType(bindingContext.get(BindingContext.TYPE, returnTypeRef));
|
||||||
}
|
}
|
||||||
return new Method(f.getName(), returnType, parameterTypes.toArray(new Type[parameterTypes.size()]));
|
return new Method(f.getName(), returnType, parameterTypes.toArray(new Type[parameterTypes.size()]));
|
||||||
}
|
}
|
||||||
@@ -407,7 +407,7 @@ public class JetTypeMapper {
|
|||||||
throw new UnsupportedOperationException("unknown declaration type " + declaration);
|
throw new UnsupportedOperationException("unknown declaration type " + declaration);
|
||||||
}
|
}
|
||||||
JetNamedFunction f = (JetNamedFunction) declaration;
|
JetNamedFunction f = (JetNamedFunction) declaration;
|
||||||
final FunctionDescriptor functionDescriptor = bindingContext.getFunctionDescriptor(f);
|
final FunctionDescriptor functionDescriptor = bindingContext.get(BindingContext.FUNCTION, f);
|
||||||
final DeclarationDescriptor functionParent = functionDescriptor.getContainingDeclaration();
|
final DeclarationDescriptor functionParent = functionDescriptor.getContainingDeclaration();
|
||||||
final List<Type> valueParameterTypes = new ArrayList<Type>();
|
final List<Type> valueParameterTypes = new ArrayList<Type>();
|
||||||
Method descriptor = mapSignature(f, valueParameterTypes);
|
Method descriptor = mapSignature(f, valueParameterTypes);
|
||||||
@@ -561,7 +561,7 @@ public class JetTypeMapper {
|
|||||||
baseName = NamespaceCodegen.getJVMClassName(((JetNamespace) container).getFQName());
|
baseName = NamespaceCodegen.getJVMClassName(((JetNamespace) container).getFQName());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ClassDescriptor aClass = bindingContext.getClassDescriptor((JetClassOrObject) container);
|
ClassDescriptor aClass = bindingContext.get(BindingContext.CLASS, (JetClassOrObject) container);
|
||||||
baseName = JetTypeMapper.jvmNameForInterface(aClass);
|
baseName = JetTypeMapper.jvmNameForInterface(aClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -577,7 +577,7 @@ public class JetTypeMapper {
|
|||||||
|
|
||||||
public Collection<String> allJvmNames(JetClassOrObject jetClass) {
|
public Collection<String> allJvmNames(JetClassOrObject jetClass) {
|
||||||
Set<String> result = new HashSet<String>();
|
Set<String> result = new HashSet<String>();
|
||||||
final ClassDescriptor classDescriptor = bindingContext.getClassDescriptor(jetClass);
|
final ClassDescriptor classDescriptor = bindingContext.get(BindingContext.CLASS, jetClass);
|
||||||
if (classDescriptor != null) {
|
if (classDescriptor != null) {
|
||||||
result.add(jvmName(classDescriptor, OwnerKind.INTERFACE));
|
result.add(jvmName(classDescriptor, OwnerKind.INTERFACE));
|
||||||
result.add(jvmName(classDescriptor, OwnerKind.IMPLEMENTATION));
|
result.add(jvmName(classDescriptor, OwnerKind.IMPLEMENTATION));
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package org.jetbrains.jet.codegen;
|
|||||||
import com.intellij.psi.PsiFile;
|
import com.intellij.psi.PsiFile;
|
||||||
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
|
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
|
||||||
import org.jetbrains.jet.lang.psi.*;
|
import org.jetbrains.jet.lang.psi.*;
|
||||||
|
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||||
import org.objectweb.asm.ClassVisitor;
|
import org.objectweb.asm.ClassVisitor;
|
||||||
import org.objectweb.asm.MethodVisitor;
|
import org.objectweb.asm.MethodVisitor;
|
||||||
import org.objectweb.asm.Opcodes;
|
import org.objectweb.asm.Opcodes;
|
||||||
@@ -33,7 +34,7 @@ public class NamespaceCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void generate(JetNamespace namespace) {
|
public void generate(JetNamespace namespace) {
|
||||||
final ClassContext context = ClassContext.STATIC.intoNamespace(state.getBindingContext().getNamespaceDescriptor(namespace));
|
final ClassContext context = ClassContext.STATIC.intoNamespace(state.getBindingContext().get(BindingContext.NAMESPACE, namespace));
|
||||||
|
|
||||||
final FunctionCodegen functionCodegen = new FunctionCodegen(context, v, state);
|
final FunctionCodegen functionCodegen = new FunctionCodegen(context, v, state);
|
||||||
final PropertyCodegen propertyCodegen = new PropertyCodegen(context, v, functionCodegen, state);
|
final PropertyCodegen propertyCodegen = new PropertyCodegen(context, v, functionCodegen, state);
|
||||||
@@ -78,7 +79,7 @@ public class NamespaceCodegen {
|
|||||||
if (declaration instanceof JetProperty) {
|
if (declaration instanceof JetProperty) {
|
||||||
final JetExpression initializer = ((JetProperty) declaration).getInitializer();
|
final JetExpression initializer = ((JetProperty) declaration).getInitializer();
|
||||||
if (initializer != null && !(initializer instanceof JetConstantExpression)) {
|
if (initializer != null && !(initializer instanceof JetConstantExpression)) {
|
||||||
final PropertyDescriptor descriptor = (PropertyDescriptor) state.getBindingContext().getVariableDescriptor((JetProperty) declaration);
|
final PropertyDescriptor descriptor = (PropertyDescriptor) state.getBindingContext().get(BindingContext.VARIABLE, (JetProperty) declaration);
|
||||||
codegen.genToJVMStack(initializer);
|
codegen.genToJVMStack(initializer);
|
||||||
codegen.intermediateValueForProperty(descriptor, true, false).store(new InstructionAdapter(mv));
|
codegen.intermediateValueForProperty(descriptor, true, false).store(new InstructionAdapter(mv));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
|
|||||||
import org.jetbrains.jet.lang.descriptors.PropertySetterDescriptor;
|
import org.jetbrains.jet.lang.descriptors.PropertySetterDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.VariableDescriptor;
|
import org.jetbrains.jet.lang.descriptors.VariableDescriptor;
|
||||||
import org.jetbrains.jet.lang.psi.*;
|
import org.jetbrains.jet.lang.psi.*;
|
||||||
|
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
||||||
import org.jetbrains.jet.lexer.JetTokens;
|
import org.jetbrains.jet.lexer.JetTokens;
|
||||||
import org.objectweb.asm.ClassVisitor;
|
import org.objectweb.asm.ClassVisitor;
|
||||||
@@ -30,7 +31,7 @@ public class PropertyCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void gen(JetProperty p) {
|
public void gen(JetProperty p) {
|
||||||
final VariableDescriptor descriptor = state.getBindingContext().getVariableDescriptor(p);
|
final VariableDescriptor descriptor = state.getBindingContext().get(BindingContext.VARIABLE, p);
|
||||||
if (!(descriptor instanceof PropertyDescriptor)) {
|
if (!(descriptor instanceof PropertyDescriptor)) {
|
||||||
throw new UnsupportedOperationException("expect a property to have a property descriptor");
|
throw new UnsupportedOperationException("expect a property to have a property descriptor");
|
||||||
}
|
}
|
||||||
@@ -67,12 +68,12 @@ public class PropertyCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void generateBackingField(JetProperty p, PropertyDescriptor propertyDescriptor) {
|
private void generateBackingField(JetProperty p, PropertyDescriptor propertyDescriptor) {
|
||||||
if (state.getBindingContext().hasBackingField(propertyDescriptor)) {
|
if ((boolean) state.getBindingContext().get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor)) {
|
||||||
Object value = null;
|
Object value = null;
|
||||||
final JetExpression initializer = p.getInitializer();
|
final JetExpression initializer = p.getInitializer();
|
||||||
if (initializer != null) {
|
if (initializer != null) {
|
||||||
if (initializer instanceof JetConstantExpression) {
|
if (initializer instanceof JetConstantExpression) {
|
||||||
CompileTimeConstant<?> compileTimeValue = state.getBindingContext().getCompileTimeValue(initializer);
|
CompileTimeConstant<?> compileTimeValue = state.getBindingContext().get(BindingContext.COMPILE_TIME_VALUE, initializer);
|
||||||
assert compileTimeValue != null;
|
assert compileTimeValue != null;
|
||||||
value = compileTimeValue.getValue();
|
value = compileTimeValue.getValue();
|
||||||
}
|
}
|
||||||
@@ -126,7 +127,7 @@ public class PropertyCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void generateDefaultGetter(JetProperty p, JetDeclaration declaration) {
|
private void generateDefaultGetter(JetProperty p, JetDeclaration declaration) {
|
||||||
final PropertyDescriptor propertyDescriptor = (PropertyDescriptor) state.getBindingContext().getVariableDescriptor(p);
|
final PropertyDescriptor propertyDescriptor = (PropertyDescriptor) state.getBindingContext().get(BindingContext.VARIABLE, p);
|
||||||
int flags = JetTypeMapper.getAccessModifiers(declaration, Opcodes.ACC_PUBLIC);
|
int flags = JetTypeMapper.getAccessModifiers(declaration, Opcodes.ACC_PUBLIC);
|
||||||
generateDefaultGetter(propertyDescriptor, flags);
|
generateDefaultGetter(propertyDescriptor, flags);
|
||||||
}
|
}
|
||||||
@@ -166,7 +167,7 @@ public class PropertyCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void generateDefaultSetter(JetProperty p, JetDeclaration declaration) {
|
private void generateDefaultSetter(JetProperty p, JetDeclaration declaration) {
|
||||||
final PropertyDescriptor propertyDescriptor = (PropertyDescriptor) state.getBindingContext().getVariableDescriptor(p);
|
final PropertyDescriptor propertyDescriptor = (PropertyDescriptor) state.getBindingContext().get(BindingContext.VARIABLE, p);
|
||||||
int flags = JetTypeMapper.getAccessModifiers(declaration, Opcodes.ACC_PUBLIC);
|
int flags = JetTypeMapper.getAccessModifiers(declaration, Opcodes.ACC_PUBLIC);
|
||||||
generateDefaultSetter(propertyDescriptor, flags);
|
generateDefaultSetter(propertyDescriptor, flags);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,8 +48,7 @@ public abstract class StackValue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static StackValue onStack(Type type) {
|
public static StackValue onStack(Type type) {
|
||||||
assert type != Type.VOID_TYPE;
|
return type == Type.VOID_TYPE ? none() : new OnStack(type);
|
||||||
return new OnStack(type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static StackValue constant(Object value, Type type) {
|
public static StackValue constant(Object value, Type type) {
|
||||||
@@ -190,6 +189,21 @@ public abstract class StackValue {
|
|||||||
v.mark(end);
|
v.mark(end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static StackValue none() {
|
||||||
|
return None.INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class None extends StackValue {
|
||||||
|
public static None INSTANCE = new None();
|
||||||
|
private None() {
|
||||||
|
super(Type.VOID_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void put(Type type, InstructionAdapter v) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static class Local extends StackValue {
|
public static class Local extends StackValue {
|
||||||
private final int index;
|
private final int index;
|
||||||
|
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class ArraySize implements IntrinsicMethod {
|
public class ArraySize implements IntrinsicMethod {
|
||||||
@Override
|
@Override
|
||||||
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element, List<JetExpression> arguments, boolean haveReceiver) {
|
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element, List<JetExpression> arguments, StackValue receiver) {
|
||||||
codegen.ensureReceiverOnStack(element, null, JetTypeMapper.TYPE_OBJECT);
|
receiver.put(JetTypeMapper.TYPE_OBJECT, v);
|
||||||
v.arraylength();
|
v.arraylength();
|
||||||
return StackValue.onStack(Type.INT_TYPE);
|
return StackValue.onStack(Type.INT_TYPE);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package org.jetbrains.jet.codegen.intrinsics;
|
|||||||
|
|
||||||
import com.intellij.psi.PsiElement;
|
import com.intellij.psi.PsiElement;
|
||||||
import org.jetbrains.jet.codegen.ExpressionCodegen;
|
import org.jetbrains.jet.codegen.ExpressionCodegen;
|
||||||
import org.jetbrains.jet.codegen.JetTypeMapper;
|
|
||||||
import org.jetbrains.jet.codegen.StackValue;
|
import org.jetbrains.jet.codegen.StackValue;
|
||||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||||
import org.objectweb.asm.Type;
|
import org.objectweb.asm.Type;
|
||||||
@@ -21,16 +20,16 @@ public class BinaryOp implements IntrinsicMethod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element, List<JetExpression> arguments, boolean haveReceiver) {
|
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element, List<JetExpression> arguments, StackValue receiver) {
|
||||||
if (arguments.size() == 1) {
|
if (arguments.size() == 1) {
|
||||||
// intrinsic is called as an ordinary function
|
// intrinsic is called as an ordinary function
|
||||||
codegen.ensureReceiverOnStack(element, null, expectedType);
|
if (receiver != null) {
|
||||||
|
receiver.put(expectedType, v);
|
||||||
|
}
|
||||||
codegen.gen(arguments.get(0), expectedType);
|
codegen.gen(arguments.get(0), expectedType);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!haveReceiver) {
|
codegen.gen(arguments.get(0), expectedType);
|
||||||
codegen.gen(arguments.get(0), expectedType);
|
|
||||||
}
|
|
||||||
codegen.gen(arguments.get(1), expectedType);
|
codegen.gen(arguments.get(1), expectedType);
|
||||||
}
|
}
|
||||||
v.visitInsn(expectedType.getOpcode(opcode));
|
v.visitInsn(expectedType.getOpcode(opcode));
|
||||||
|
|||||||
@@ -14,16 +14,18 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class Concat implements IntrinsicMethod {
|
public class Concat implements IntrinsicMethod {
|
||||||
@Override
|
@Override
|
||||||
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element, List<JetExpression> arguments, boolean haveReceiver) {
|
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element, List<JetExpression> arguments, StackValue receiver) {
|
||||||
codegen.generateStringBuilderConstructor();
|
codegen.generateStringBuilderConstructor();
|
||||||
if (haveReceiver) {
|
if (receiver == null) { // LHS.plus(RHS)
|
||||||
v.swap();
|
v.swap(); // StringBuilder LHS
|
||||||
codegen.invokeAppendMethod(codegen.expressionType(arguments.get(0)));
|
codegen.invokeAppendMethod(codegen.expressionType(arguments.get(0))); // StringBuilder(LHS)
|
||||||
}
|
|
||||||
else {
|
|
||||||
codegen.invokeAppend(arguments.get(0));
|
codegen.invokeAppend(arguments.get(0));
|
||||||
}
|
}
|
||||||
codegen.invokeAppend(arguments.get(1));
|
else { // LHS + RHS
|
||||||
|
codegen.invokeAppend(arguments.get(0)); // StringBuilder(LHS)
|
||||||
|
codegen.invokeAppend(arguments.get(1));
|
||||||
|
}
|
||||||
|
|
||||||
v.invokevirtual(ExpressionCodegen.CLASS_STRING_BUILDER, "toString", "()Ljava/lang/String;");
|
v.invokevirtual(ExpressionCodegen.CLASS_STRING_BUILDER, "toString", "()Ljava/lang/String;");
|
||||||
return StackValue.onStack(Type.getObjectType("java/lang/String"));
|
return StackValue.onStack(Type.getObjectType("java/lang/String"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public class Increment implements IntrinsicMethod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element, List<JetExpression> arguments, boolean haveReceiver) {
|
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element, List<JetExpression> arguments, StackValue receiver) {
|
||||||
final JetExpression operand = arguments.get(0);
|
final JetExpression operand = arguments.get(0);
|
||||||
if (operand instanceof JetReferenceExpression) {
|
if (operand instanceof JetReferenceExpression) {
|
||||||
final int index = codegen.indexOfLocal((JetReferenceExpression) operand);
|
final int index = codegen.indexOfLocal((JetReferenceExpression) operand);
|
||||||
@@ -31,7 +31,7 @@ public class Increment implements IntrinsicMethod {
|
|||||||
return StackValue.local(index, expectedType);
|
return StackValue.local(index, expectedType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
StackValue value = codegen.generateIntermediateValue(operand);
|
StackValue value = codegen.genQualified(receiver, operand);
|
||||||
value.dupReceiver(v, 0);
|
value.dupReceiver(v, 0);
|
||||||
value.put(expectedType, v);
|
value.put(expectedType, v);
|
||||||
if (expectedType == Type.LONG_TYPE) {
|
if (expectedType == Type.LONG_TYPE) {
|
||||||
|
|||||||
@@ -14,5 +14,5 @@ import java.util.List;
|
|||||||
* @author yole
|
* @author yole
|
||||||
*/
|
*/
|
||||||
public interface IntrinsicMethod extends Callable {
|
public interface IntrinsicMethod extends Callable {
|
||||||
StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element, List<JetExpression> arguments, boolean haveReceiver);
|
StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element, List<JetExpression> arguments, StackValue receiver);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class Inv implements IntrinsicMethod {
|
public class Inv implements IntrinsicMethod {
|
||||||
@Override
|
@Override
|
||||||
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element, List<JetExpression> arguments, boolean haveReceiver) {
|
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element, List<JetExpression> arguments, StackValue receiver) {
|
||||||
codegen.putTopOfStack(expectedType);
|
receiver.put(expectedType, v);
|
||||||
v.aconst(-1);
|
v.aconst(-1);
|
||||||
v.xor(expectedType);
|
v.xor(expectedType);
|
||||||
return StackValue.onStack(expectedType);
|
return StackValue.onStack(expectedType);
|
||||||
|
|||||||
@@ -14,13 +14,13 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class Not implements IntrinsicMethod {
|
public class Not implements IntrinsicMethod {
|
||||||
@Override
|
@Override
|
||||||
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element, List<JetExpression> arguments, boolean haveReceiver) {
|
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element, List<JetExpression> arguments, StackValue receiver) {
|
||||||
final StackValue stackValue;
|
final StackValue stackValue;
|
||||||
if (arguments.size() == 1) {
|
if (arguments.size() == 1) {
|
||||||
stackValue = codegen.generateIntermediateValue(arguments.get(0));
|
stackValue = codegen.gen(arguments.get(0));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
stackValue = codegen.getReceiverAsStackValue(element, null, expectedType);
|
stackValue = receiver;
|
||||||
}
|
}
|
||||||
return StackValue.not(stackValue);
|
return StackValue.not(stackValue);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class NumberCast implements IntrinsicMethod {
|
public class NumberCast implements IntrinsicMethod {
|
||||||
@Override
|
@Override
|
||||||
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element, List<JetExpression> arguments, boolean haveReceiver) {
|
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element, List<JetExpression> arguments, StackValue receiver) {
|
||||||
codegen.putTopOfStack(expectedType);
|
receiver.put(expectedType, v);
|
||||||
return StackValue.onStack(expectedType);
|
return StackValue.onStack(expectedType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,9 +24,9 @@ public class PsiMethodCall implements IntrinsicMethod {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element,
|
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element,
|
||||||
List<JetExpression> arguments, boolean haveReceiver) {
|
List<JetExpression> arguments, StackValue receiver) {
|
||||||
final CallableMethod callableMethod = codegen.getTypeMapper().mapToCallableMethod(myMethod);
|
final CallableMethod callableMethod = codegen.getTypeMapper().mapToCallableMethod(myMethod);
|
||||||
codegen.invokeMethodWithArguments(callableMethod, (JetCallExpression) element, haveReceiver);
|
codegen.invokeMethodWithArguments(callableMethod, (JetCallExpression) element, receiver);
|
||||||
return StackValue.onStack(callableMethod.getSignature().getReturnType());
|
return StackValue.onStack(callableMethod.getSignature().getReturnType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ public class RangeTo implements IntrinsicMethod {
|
|||||||
private static final String CLASS_INT_RANGE = "jet/IntRange";
|
private static final String CLASS_INT_RANGE = "jet/IntRange";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element, List<JetExpression> arguments, boolean haveReceiver) {
|
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element, List<JetExpression> arguments, StackValue receiver) {
|
||||||
JetBinaryExpression expression = (JetBinaryExpression) element;
|
JetBinaryExpression expression = (JetBinaryExpression) element;
|
||||||
final Type leftType = codegen.expressionType(expression.getLeft());
|
final Type leftType = codegen.expressionType(expression.getLeft());
|
||||||
if (JetTypeMapper.isIntPrimitive(leftType)) {
|
if (JetTypeMapper.isIntPrimitive(leftType)) {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class TypeInfo implements IntrinsicMethod {
|
public class TypeInfo implements IntrinsicMethod {
|
||||||
@Override
|
@Override
|
||||||
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element, List<JetExpression> arguments, boolean haveReceiver) {
|
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element, List<JetExpression> arguments, StackValue receiver) {
|
||||||
final List<JetTypeProjection> typeArguments = ((JetCallExpression) element).getTypeArguments();
|
final List<JetTypeProjection> typeArguments = ((JetCallExpression) element).getTypeArguments();
|
||||||
if (typeArguments.size() != 1) {
|
if (typeArguments.size() != 1) {
|
||||||
throw new UnsupportedOperationException("one type argument expected");
|
throw new UnsupportedOperationException("one type argument expected");
|
||||||
|
|||||||
@@ -14,12 +14,12 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class UnaryMinus implements IntrinsicMethod {
|
public class UnaryMinus implements IntrinsicMethod {
|
||||||
@Override
|
@Override
|
||||||
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element, List<JetExpression> arguments, boolean haveReceiver) {
|
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element, List<JetExpression> arguments, StackValue receiver) {
|
||||||
if (arguments.size() == 1) {
|
if (arguments.size() == 1) {
|
||||||
codegen.gen(arguments.get(0), expectedType);
|
codegen.gen(arguments.get(0), expectedType);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
codegen.ensureReceiverOnStack(element, null, expectedType);
|
receiver.put(expectedType, v);
|
||||||
}
|
}
|
||||||
v.neg(expectedType);
|
v.neg(expectedType);
|
||||||
return StackValue.onStack(expectedType);
|
return StackValue.onStack(expectedType);
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class ValueTypeInfo implements IntrinsicMethod {
|
public class ValueTypeInfo implements IntrinsicMethod {
|
||||||
@Override
|
@Override
|
||||||
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element, List<JetExpression> arguments, boolean haveReceiver) {
|
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element, List<JetExpression> arguments, StackValue receiver) {
|
||||||
codegen.gen(arguments.get(0), JetTypeMapper.TYPE_JET_OBJECT);
|
codegen.gen(arguments.get(0), JetTypeMapper.TYPE_JET_OBJECT);
|
||||||
v.invokeinterface("jet/JetObject", "getTypeInfo", "()Ljet/typeinfo/TypeInfo;");
|
v.invokeinterface("jet/JetObject", "getTypeInfo", "()Ljet/typeinfo/TypeInfo;");
|
||||||
return StackValue.onStack(JetTypeMapper.TYPE_TYPEINFO);
|
return StackValue.onStack(JetTypeMapper.TYPE_TYPEINFO);
|
||||||
|
|||||||
@@ -1,101 +0,0 @@
|
|||||||
package org.jetbrains.jet.lang;
|
|
||||||
|
|
||||||
import com.intellij.lang.ASTNode;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
|
||||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
|
||||||
import org.jetbrains.jet.lang.psi.JetReferenceExpression;
|
|
||||||
import org.jetbrains.jet.lang.resolve.AnalyzingUtils;
|
|
||||||
import org.jetbrains.jet.lang.types.JetType;
|
|
||||||
|
|
||||||
import java.util.Stack;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author abreslav
|
|
||||||
*/
|
|
||||||
public class ErrorHandlerWithRegions extends ErrorHandler {
|
|
||||||
|
|
||||||
public class DiagnosticsRegion {
|
|
||||||
private final CollectingErrorHandler errorHandler;
|
|
||||||
private boolean committed = false;
|
|
||||||
|
|
||||||
private DiagnosticsRegion(CollectingErrorHandler errorHandler) {
|
|
||||||
this.errorHandler = errorHandler;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CollectingErrorHandler getErrorHandler() {
|
|
||||||
assert !committed;
|
|
||||||
return errorHandler;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void commit() {
|
|
||||||
assert !committed;
|
|
||||||
AnalyzingUtils.applyHandler(parent, errorHandler.getDiagnostics());
|
|
||||||
committed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private final ErrorHandler parent;
|
|
||||||
private final Stack<CollectingErrorHandler> workers;
|
|
||||||
private ErrorHandler worker;
|
|
||||||
|
|
||||||
public ErrorHandlerWithRegions(ErrorHandler parent) {
|
|
||||||
this.parent = parent;
|
|
||||||
this.worker = parent;
|
|
||||||
this.workers = new Stack<CollectingErrorHandler>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void openRegion() {
|
|
||||||
CollectingErrorHandler newWorker = new CollectingErrorHandler();
|
|
||||||
workers.push(newWorker);
|
|
||||||
worker = newWorker;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void closeAndCommitCurrentRegion() {
|
|
||||||
assert !workers.isEmpty();
|
|
||||||
CollectingErrorHandler region = workers.pop();
|
|
||||||
AnalyzingUtils.applyHandler(parent, region.getDiagnostics());
|
|
||||||
|
|
||||||
setWorker();
|
|
||||||
}
|
|
||||||
|
|
||||||
public DiagnosticsRegion closeAndReturnCurrentRegion() {
|
|
||||||
assert !workers.isEmpty();
|
|
||||||
CollectingErrorHandler currentWorker = workers.pop();
|
|
||||||
setWorker();
|
|
||||||
return new DiagnosticsRegion(currentWorker);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void close() {
|
|
||||||
assert workers.isEmpty() : "Open regions remain: " + workers;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setWorker() {
|
|
||||||
worker = workers.isEmpty() ? parent : workers.peek();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void unresolvedReference(@NotNull JetReferenceExpression referenceExpression) {
|
|
||||||
worker.unresolvedReference(referenceExpression);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void typeMismatch(@NotNull JetExpression expression, @NotNull JetType expectedType, @NotNull JetType actualType) {
|
|
||||||
worker.typeMismatch(expression, expectedType, actualType);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void redeclaration(@NotNull DeclarationDescriptor existingDescriptor, @NotNull DeclarationDescriptor redeclaredDescriptor) {
|
|
||||||
worker.redeclaration(existingDescriptor, redeclaredDescriptor);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void genericError(@NotNull ASTNode node, @NotNull String errorMessage) {
|
|
||||||
worker.genericError(node, errorMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void genericWarning(@NotNull ASTNode node, @NotNull String message) {
|
|
||||||
worker.genericWarning(node, message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -50,11 +50,6 @@ public class JetSemanticServices {
|
|||||||
return new JetTypeInferrer(flowInformationProvider, this).getServices(trace);
|
return new JetTypeInferrer(flowInformationProvider, this).getServices(trace);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @NotNull
|
|
||||||
// public ErrorHandler getErrorHandler() {
|
|
||||||
// return errorHandler;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public JetTypeChecker getTypeChecker() {
|
public JetTypeChecker getTypeChecker() {
|
||||||
return typeChecker;
|
return typeChecker;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.lang.JetSemanticServices;
|
import org.jetbrains.jet.lang.JetSemanticServices;
|
||||||
import org.jetbrains.jet.lang.psi.*;
|
import org.jetbrains.jet.lang.psi.*;
|
||||||
|
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||||
import org.jetbrains.jet.lang.types.JetTypeInferrer;
|
import org.jetbrains.jet.lang.types.JetTypeInferrer;
|
||||||
import org.jetbrains.jet.lexer.JetTokens;
|
import org.jetbrains.jet.lexer.JetTokens;
|
||||||
@@ -85,7 +86,7 @@ public class JetControlFlowProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
JetElement result = stack.peek();
|
JetElement result = stack.peek();
|
||||||
trace.recordLabelResolution(labelExpression, result);
|
trace.record(BindingContext.LABEL_TARGET, labelExpression, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -351,9 +351,11 @@ public class JetParsing extends AbstractJetParsing {
|
|||||||
|
|
||||||
PsiBuilder.Marker attribute = mark();
|
PsiBuilder.Marker attribute = mark();
|
||||||
|
|
||||||
|
PsiBuilder.Marker reference = mark();
|
||||||
PsiBuilder.Marker typeReference = mark();
|
PsiBuilder.Marker typeReference = mark();
|
||||||
parseUserType();
|
parseUserType();
|
||||||
typeReference.done(TYPE_REFERENCE);
|
typeReference.done(TYPE_REFERENCE);
|
||||||
|
reference.done(CONSTRUCTOR_CALLEE);
|
||||||
|
|
||||||
parseTypeArgumentList(-1);
|
parseTypeArgumentList(-1);
|
||||||
|
|
||||||
@@ -723,7 +725,9 @@ public class JetParsing extends AbstractJetParsing {
|
|||||||
type = THIS_CALL;
|
type = THIS_CALL;
|
||||||
}
|
}
|
||||||
else if (atSet(TYPE_REF_FIRST)) {
|
else if (atSet(TYPE_REF_FIRST)) {
|
||||||
|
PsiBuilder.Marker reference = mark();
|
||||||
parseTypeRef();
|
parseTypeRef();
|
||||||
|
reference.done(CONSTRUCTOR_CALLEE);
|
||||||
type = DELEGATOR_SUPER_CALL;
|
type = DELEGATOR_SUPER_CALL;
|
||||||
} else {
|
} else {
|
||||||
errorWithRecovery("Expecting constructor call (this(...)) or supertype initializer", TokenSet.create(LBRACE, COMMA));
|
errorWithRecovery("Expecting constructor call (this(...)) or supertype initializer", TokenSet.create(LBRACE, COMMA));
|
||||||
@@ -1094,18 +1098,23 @@ public class JetParsing extends AbstractJetParsing {
|
|||||||
private void parseDelegationSpecifier() {
|
private void parseDelegationSpecifier() {
|
||||||
PsiBuilder.Marker delegator = mark();
|
PsiBuilder.Marker delegator = mark();
|
||||||
parseAnnotations(false);
|
parseAnnotations(false);
|
||||||
|
|
||||||
|
PsiBuilder.Marker reference = mark();
|
||||||
parseTypeRef();
|
parseTypeRef();
|
||||||
|
|
||||||
if (at(BY_KEYWORD)) {
|
if (at(BY_KEYWORD)) {
|
||||||
|
reference.drop();
|
||||||
advance(); // BY_KEYWORD
|
advance(); // BY_KEYWORD
|
||||||
createForByClause(myBuilder).myExpressionParsing.parseExpression();
|
createForByClause(myBuilder).myExpressionParsing.parseExpression();
|
||||||
delegator.done(DELEGATOR_BY);
|
delegator.done(DELEGATOR_BY);
|
||||||
}
|
}
|
||||||
else if (at(LPAR)) {
|
else if (at(LPAR)) {
|
||||||
|
reference.done(CONSTRUCTOR_CALLEE);
|
||||||
myExpressionParsing.parseValueArgumentList();
|
myExpressionParsing.parseValueArgumentList();
|
||||||
delegator.done(DELEGATOR_SUPER_CALL);
|
delegator.done(DELEGATOR_SUPER_CALL);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
reference.drop();
|
||||||
delegator.done(DELEGATOR_SUPER_CLASS);
|
delegator.done(DELEGATOR_SUPER_CLASS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,16 @@ public class JetAnnotationEntry extends JetElement implements JetCall {
|
|||||||
|
|
||||||
@Nullable @IfNotParsed
|
@Nullable @IfNotParsed
|
||||||
public JetTypeReference getTypeReference() {
|
public JetTypeReference getTypeReference() {
|
||||||
return (JetTypeReference) findChildByType(JetNodeTypes.TYPE_REFERENCE);
|
JetConstructorCalleeExpression calleeExpression = getCalleeExpression();
|
||||||
|
if (calleeExpression == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return calleeExpression.getTypeReference();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JetConstructorCalleeExpression getCalleeExpression() {
|
||||||
|
return (JetConstructorCalleeExpression) findChildByType(JetNodeTypes.CONSTRUCTOR_CALLEE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ import java.util.List;
|
|||||||
* @author abreslav
|
* @author abreslav
|
||||||
*/
|
*/
|
||||||
public interface JetCall extends PsiElement {
|
public interface JetCall extends PsiElement {
|
||||||
|
@Nullable
|
||||||
|
JetExpression getCalleeExpression();
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
JetValueArgumentList getValueArgumentList();
|
JetValueArgumentList getValueArgumentList();
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ public class JetCallExpression extends JetExpression implements JetCall {
|
|||||||
return visitor.visitCallExpression(this, data);
|
return visitor.visitCallExpression(this, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public JetExpression getCalleeExpression() {
|
public JetExpression getCalleeExpression() {
|
||||||
return findChildByClass(JetExpression.class);
|
return findChildByClass(JetExpression.class);
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package org.jetbrains.jet.lang.psi;
|
||||||
|
|
||||||
|
import com.intellij.lang.ASTNode;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author abreslav
|
||||||
|
*/
|
||||||
|
public class JetConstructorCalleeExpression extends JetExpression {
|
||||||
|
public JetConstructorCalleeExpression(@NotNull ASTNode node) {
|
||||||
|
super(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable @IfNotParsed
|
||||||
|
public JetTypeReference getTypeReference() {
|
||||||
|
return findChildByClass(JetTypeReference.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable @IfNotParsed
|
||||||
|
public JetReferenceExpression getConstructorReferenceExpression() {
|
||||||
|
JetTypeReference typeReference = getTypeReference();
|
||||||
|
if (typeReference == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
JetTypeElement typeElement = typeReference.getTypeElement();
|
||||||
|
assert typeElement instanceof JetUserType;
|
||||||
|
return ((JetUserType) typeElement).getReferenceExpression();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -26,6 +26,12 @@ public class JetDelegatorToSuperCall extends JetDelegationSpecifier implements J
|
|||||||
return visitor.visitDelegationToSuperCallSpecifier(this, data);
|
return visitor.visitDelegationToSuperCallSpecifier(this, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public JetConstructorCalleeExpression getCalleeExpression() {
|
||||||
|
return (JetConstructorCalleeExpression) findChildByType(JetNodeTypes.CONSTRUCTOR_CALLEE);
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public JetValueArgumentList getValueArgumentList() {
|
public JetValueArgumentList getValueArgumentList() {
|
||||||
return (JetValueArgumentList) findChildByType(JetNodeTypes.VALUE_ARGUMENT_LIST);
|
return (JetValueArgumentList) findChildByType(JetNodeTypes.VALUE_ARGUMENT_LIST);
|
||||||
@@ -43,6 +49,11 @@ public class JetDelegatorToSuperCall extends JetDelegationSpecifier implements J
|
|||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JetTypeReference getTypeReference() {
|
||||||
|
return getCalleeExpression().getTypeReference();
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public List<JetTypeProjection> getTypeArguments() {
|
public List<JetTypeProjection> getTypeArguments() {
|
||||||
|
|||||||
@@ -27,6 +27,11 @@ public class JetDelegatorToThisCall extends JetDelegationSpecifier implements Je
|
|||||||
return visitor.visitDelegationToThisCall(this, data);
|
return visitor.visitDelegationToThisCall(this, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JetExpression getCalleeExpression() {
|
||||||
|
return getThisReference();
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public JetValueArgumentList getValueArgumentList() {
|
public JetValueArgumentList getValueArgumentList() {
|
||||||
return (JetValueArgumentList) findChildByType(JetNodeTypes.VALUE_ARGUMENT_LIST);
|
return (JetValueArgumentList) findChildByType(JetNodeTypes.VALUE_ARGUMENT_LIST);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import com.intellij.util.IncorrectOperationException;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.lang.resolve.AnalyzingUtils;
|
import org.jetbrains.jet.lang.resolve.AnalyzingUtils;
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||||
|
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author abreslav
|
* @author abreslav
|
||||||
@@ -19,7 +20,7 @@ public abstract class JetReferenceExpression extends JetExpression {
|
|||||||
protected PsiElement doResolve() {
|
protected PsiElement doResolve() {
|
||||||
JetFile file = (JetFile) getContainingFile();
|
JetFile file = (JetFile) getContainingFile();
|
||||||
BindingContext bindingContext = AnalyzingUtils.analyzeFileWithCache(file);
|
BindingContext bindingContext = AnalyzingUtils.analyzeFileWithCache(file);
|
||||||
PsiElement psiElement = bindingContext.resolveToDeclarationPsiElement(this);
|
PsiElement psiElement = BindingContextUtils.resolveToDeclarationPsiElement(bindingContext, this);
|
||||||
return psiElement == null
|
return psiElement == null
|
||||||
? file
|
? file
|
||||||
: psiElement;
|
: psiElement;
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ public class JetSimpleNameExpression extends JetReferenceExpression {
|
|||||||
JetExpression receiverExpression = qualifiedExpression.getReceiverExpression();
|
JetExpression receiverExpression = qualifiedExpression.getReceiverExpression();
|
||||||
JetFile file = (JetFile) getContainingFile();
|
JetFile file = (JetFile) getContainingFile();
|
||||||
BindingContext bindingContext = AnalyzingUtils.analyzeFileWithCache(file);
|
BindingContext bindingContext = AnalyzingUtils.analyzeFileWithCache(file);
|
||||||
final JetType expressionType = bindingContext.getExpressionType(receiverExpression);
|
final JetType expressionType = bindingContext.get(BindingContext.EXPRESSION_TYPE, receiverExpression);
|
||||||
if (expressionType != null) {
|
if (expressionType != null) {
|
||||||
return collectLookupElements(bindingContext, expressionType.getMemberScope());
|
return collectLookupElements(bindingContext, expressionType.getMemberScope());
|
||||||
}
|
}
|
||||||
@@ -99,7 +99,7 @@ public class JetSimpleNameExpression extends JetReferenceExpression {
|
|||||||
else {
|
else {
|
||||||
JetFile file = (JetFile) getContainingFile();
|
JetFile file = (JetFile) getContainingFile();
|
||||||
BindingContext bindingContext = AnalyzingUtils.analyzeFileWithCache(file);
|
BindingContext bindingContext = AnalyzingUtils.analyzeFileWithCache(file);
|
||||||
JetScope resolutionScope = bindingContext.getResolutionScope(JetSimpleNameExpression.this);
|
JetScope resolutionScope = bindingContext.get(BindingContext.RESOLUTION_SCOPE, JetSimpleNameExpression.this);
|
||||||
if (resolutionScope != null) {
|
if (resolutionScope != null) {
|
||||||
return collectLookupElements(bindingContext, resolutionScope);
|
return collectLookupElements(bindingContext, resolutionScope);
|
||||||
}
|
}
|
||||||
@@ -119,7 +119,7 @@ public class JetSimpleNameExpression extends JetReferenceExpression {
|
|||||||
private Object[] collectLookupElements(BindingContext bindingContext, JetScope scope) {
|
private Object[] collectLookupElements(BindingContext bindingContext, JetScope scope) {
|
||||||
List<LookupElement> result = Lists.newArrayList();
|
List<LookupElement> result = Lists.newArrayList();
|
||||||
for (final DeclarationDescriptor descriptor : scope.getAllDescriptors()) {
|
for (final DeclarationDescriptor descriptor : scope.getAllDescriptors()) {
|
||||||
PsiElement declaration = bindingContext.getDeclarationPsiElement(descriptor.getOriginal());
|
PsiElement declaration = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, descriptor.getOriginal());
|
||||||
LookupElementBuilder element = LookupElementBuilder.create(descriptor.getName());
|
LookupElementBuilder element = LookupElementBuilder.create(descriptor.getName());
|
||||||
String typeText = "";
|
String typeText = "";
|
||||||
String tailText = "";
|
String tailText = "";
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class AnalyzingUtils {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
BindingTraceContext bindingTraceContext = new BindingTraceContext();
|
BindingTraceContext bindingTraceContext = new BindingTraceContext();
|
||||||
bindingTraceContext.getErrorHandler().genericError(file.getNode(), e.getClass().getSimpleName() + ": " + e.getMessage());
|
bindingTraceContext.getErrorHandler().genericError(file.getNode(), e.getClass().getSimpleName() + ": " + e.getMessage());
|
||||||
return new Result<BindingContext>(bindingTraceContext, PsiModificationTracker.MODIFICATION_COUNT);
|
return new Result<BindingContext>(bindingTraceContext.getBindingContext(), PsiModificationTracker.MODIFICATION_COUNT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -112,7 +112,7 @@ public class AnalyzingUtils {
|
|||||||
throw new IllegalStateException("Must be guaranteed not to happen by the parser");
|
throw new IllegalStateException("Must be guaranteed not to happen by the parser");
|
||||||
}
|
}
|
||||||
}, Collections.<JetDeclaration>singletonList(namespace));
|
}, Collections.<JetDeclaration>singletonList(namespace));
|
||||||
return bindingTraceContext;
|
return bindingTraceContext.getBindingContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void applyHandler(@NotNull ErrorHandler errorHandler, @NotNull BindingContext bindingContext) {
|
public static void applyHandler(@NotNull ErrorHandler errorHandler, @NotNull BindingContext bindingContext) {
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ public class AnnotationResolver {
|
|||||||
for (JetAnnotationEntry annotation : annotations) {
|
for (JetAnnotationEntry annotation : annotations) {
|
||||||
AnnotationDescriptor annotationDescriptor = new AnnotationDescriptor();
|
AnnotationDescriptor annotationDescriptor = new AnnotationDescriptor();
|
||||||
result.add(annotationDescriptor);
|
result.add(annotationDescriptor);
|
||||||
trace.recordAnnotationResolution(annotation, annotationDescriptor);
|
trace.record(BindingContext.ANNOTATION, annotation, annotationDescriptor);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
package org.jetbrains.jet.lang.resolve;
|
package org.jetbrains.jet.lang.resolve;
|
||||||
|
|
||||||
import com.intellij.psi.PsiElement;
|
import com.intellij.psi.PsiElement;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.jetbrains.jet.lang.JetDiagnostic;
|
import org.jetbrains.jet.lang.JetDiagnostic;
|
||||||
import org.jetbrains.jet.lang.descriptors.*;
|
import org.jetbrains.jet.lang.descriptors.*;
|
||||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||||
import org.jetbrains.jet.lang.psi.*;
|
import org.jetbrains.jet.lang.psi.*;
|
||||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
||||||
import org.jetbrains.jet.lang.types.JetType;
|
import org.jetbrains.jet.lang.types.JetType;
|
||||||
|
import org.jetbrains.jet.util.*;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
@@ -16,46 +15,93 @@ import java.util.Collection;
|
|||||||
* @author abreslav
|
* @author abreslav
|
||||||
*/
|
*/
|
||||||
public interface BindingContext {
|
public interface BindingContext {
|
||||||
@Deprecated // "Tests only"
|
WritableSlice<JetAnnotationEntry, AnnotationDescriptor> ANNOTATION = ManyMapSlices.createSimpleSlice("ANNOTATION");
|
||||||
DeclarationDescriptor getDeclarationDescriptor(PsiElement declaration);
|
WritableSlice<JetExpression, CompileTimeConstant<?>> COMPILE_TIME_VALUE = ManyMapSlices.createSimpleSlice("COMPILE_TIME_VALUE");
|
||||||
|
WritableSlice<JetTypeReference, JetType> TYPE = ManyMapSlices.createSimpleSlice("TYPE");
|
||||||
|
WritableSlice<JetExpression, JetType> EXPRESSION_TYPE = new BasicWritableSlice<JetExpression, JetType>("EXPRESSION_TYPE", RewritePolicy.DO_NOTHING);
|
||||||
|
WritableSlice<JetReferenceExpression, DeclarationDescriptor> REFERENCE_TARGET = new BasicWritableSlice<JetReferenceExpression, DeclarationDescriptor>("REFERENCE_TARGET", RewritePolicy.DO_NOTHING);
|
||||||
|
WritableSlice<JetExpression, JetType> AUTOCAST = ManyMapSlices.createSimpleSlice("AUTOCAST");
|
||||||
|
WritableSlice<JetExpression, JetScope> RESOLUTION_SCOPE = ManyMapSlices.createSimpleSlice("RESOLUTION_SCOPE");
|
||||||
|
|
||||||
NamespaceDescriptor getNamespaceDescriptor(JetNamespace declaration);
|
WritableSlice<JetExpression, Boolean> VARIABLE_REASSIGNMENT = ManyMapSlices.createSimpleSetSlice("VARIABLE_REASSIGNMENT");
|
||||||
ClassDescriptor getClassDescriptor(JetClassOrObject declaration);
|
WritableSlice<JetExpression, Boolean> PROCESSED = ManyMapSlices.createSimpleSetSlice("PROCESSED");
|
||||||
TypeParameterDescriptor getTypeParameterDescriptor(JetTypeParameter declaration);
|
WritableSlice<JetElement, Boolean> STATEMENT = ManyMapSlices.createRemovableSetSlice("STATEMENT");
|
||||||
FunctionDescriptor getFunctionDescriptor(JetNamedFunction declaration);
|
|
||||||
ConstructorDescriptor getConstructorDescriptor(JetElement declaration);
|
|
||||||
AnnotationDescriptor getAnnotationDescriptor(JetAnnotationEntry annotationEntry);
|
|
||||||
|
|
||||||
@Nullable
|
WritableSlice<PropertyDescriptor, Boolean> BACKING_FIELD_REQUIRED = new ManyMapSlices.SetSlice<PropertyDescriptor>("BACKING_FIELD_REQUIRED", RewritePolicy.DO_NOTHING) {
|
||||||
CompileTimeConstant<?> getCompileTimeValue(JetExpression expression);
|
@Override
|
||||||
|
public Boolean computeValue(ManyMap map, PropertyDescriptor propertyDescriptor, Boolean backingFieldRequired, boolean valueNotFound) {
|
||||||
|
backingFieldRequired = valueNotFound ? false : backingFieldRequired;
|
||||||
|
assert backingFieldRequired != null;
|
||||||
|
PsiElement declarationPsiElement = map.get(DESCRIPTOR_TO_DECLARATION, propertyDescriptor);
|
||||||
|
if (declarationPsiElement instanceof JetParameter) {
|
||||||
|
JetParameter jetParameter = (JetParameter) declarationPsiElement;
|
||||||
|
return jetParameter.getValOrVarNode() != null ||
|
||||||
|
backingFieldRequired;
|
||||||
|
}
|
||||||
|
if (propertyDescriptor.getModifiers().isAbstract()) return false;
|
||||||
|
PropertyGetterDescriptor getter = propertyDescriptor.getGetter();
|
||||||
|
PropertySetterDescriptor setter = propertyDescriptor.getSetter();
|
||||||
|
if (getter == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (propertyDescriptor.isVar() && setter == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (setter != null && !setter.hasBody() && !setter.getModifiers().isAbstract()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (!getter.hasBody() && !getter.getModifiers().isAbstract()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return backingFieldRequired;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
VariableDescriptor getVariableDescriptor(JetProperty declaration);
|
WritableSlice<JetFunctionLiteralExpression, Boolean> BLOCK = new ManyMapSlices.SetSlice<JetFunctionLiteralExpression>("BLOCK", RewritePolicy.DO_NOTHING) {
|
||||||
VariableDescriptor getVariableDescriptor(JetParameter declaration);
|
@Override
|
||||||
|
public Boolean computeValue(ManyMap map, JetFunctionLiteralExpression expression, Boolean isBlock, boolean valueNotFound) {
|
||||||
|
isBlock = valueNotFound ? false : isBlock;
|
||||||
|
assert isBlock != null;
|
||||||
|
return isBlock && !expression.getFunctionLiteral().hasParameterSpecification();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
PropertyDescriptor getPropertyDescriptor(JetParameter primaryConstructorParameter);
|
ManyMapSlices.KeyNormalizer<DeclarationDescriptor> DECLARATION_DESCRIPTOR_NORMALIZER = new ManyMapSlices.KeyNormalizer<DeclarationDescriptor>() {
|
||||||
PropertyDescriptor getPropertyDescriptor(JetObjectDeclarationName objectDeclarationName);
|
@Override
|
||||||
|
public DeclarationDescriptor normalize(DeclarationDescriptor declarationDescriptor) {
|
||||||
|
if (declarationDescriptor instanceof VariableAsFunctionDescriptor) {
|
||||||
|
VariableAsFunctionDescriptor descriptor = (VariableAsFunctionDescriptor) declarationDescriptor;
|
||||||
|
return descriptor.getVariableDescriptor().getOriginal();
|
||||||
|
}
|
||||||
|
return declarationDescriptor.getOriginal();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
ReadOnlySlice<DeclarationDescriptor, PsiElement> DESCRIPTOR_TO_DECLARATION = ManyMapSlices.<DeclarationDescriptor, PsiElement>sliceBuilder("DECLARATION_TO_DESCRIPTOR").setKeyNormalizer(DECLARATION_DESCRIPTOR_NORMALIZER).build();
|
||||||
|
|
||||||
JetType getExpressionType(JetExpression expression);
|
WritableSlice<PsiElement, NamespaceDescriptor> NAMESPACE = ManyMapSlices.<PsiElement, NamespaceDescriptor>sliceBuilder("DECLARATION").setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build();
|
||||||
|
WritableSlice<PsiElement, ClassDescriptor> CLASS = ManyMapSlices.<PsiElement, ClassDescriptor>sliceBuilder("CLASS").setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build();
|
||||||
|
WritableSlice<JetTypeParameter, TypeParameterDescriptor> TYPE_PARAMETER = ManyMapSlices.<JetTypeParameter, TypeParameterDescriptor>sliceBuilder("TYPE_PARAMETER").setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build();
|
||||||
|
WritableSlice<PsiElement, FunctionDescriptor> FUNCTION = ManyMapSlices.<PsiElement, FunctionDescriptor>sliceBuilder("FUNCTION").setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build();
|
||||||
|
WritableSlice<PsiElement, ConstructorDescriptor> CONSTRUCTOR = ManyMapSlices.<PsiElement, ConstructorDescriptor>sliceBuilder("CONSTRUCTOR").setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build();
|
||||||
|
WritableSlice<PsiElement, VariableDescriptor> VARIABLE = ManyMapSlices.<PsiElement, VariableDescriptor>sliceBuilder("VARIABLE").setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build();
|
||||||
|
WritableSlice<JetParameter, VariableDescriptor> VALUE_PARAMETER = ManyMapSlices.<JetParameter, VariableDescriptor>sliceBuilder("VALUE_PARAMETER").setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build();
|
||||||
|
WritableSlice<JetPropertyAccessor, PropertyAccessorDescriptor> PROPERTY_ACCESSOR = ManyMapSlices.<JetPropertyAccessor, PropertyAccessorDescriptor>sliceBuilder("PROPERTY_ACCESSOR").setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build();
|
||||||
|
|
||||||
DeclarationDescriptor resolveReferenceExpression(JetReferenceExpression referenceExpression);
|
// normalize value to getOriginal(value)
|
||||||
|
WritableSlice<PsiElement, PropertyDescriptor> PRIMARY_CONSTRUCTOR_PARAMETER = ManyMapSlices.<PsiElement, PropertyDescriptor>sliceBuilder("PRIMARY_CONSTRUCTOR_PARAMETER").setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build();
|
||||||
|
WritableSlice<JetObjectDeclarationName, PropertyDescriptor> OBJECT_DECLARATION = ManyMapSlices.<JetObjectDeclarationName, PropertyDescriptor>sliceBuilder("OBJECT_DECLARATION").setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build();
|
||||||
|
|
||||||
JetType resolveTypeReference(JetTypeReference typeReference);
|
WritableSlice[] DECLARATIONS_TO_DESCRIPTORS = new WritableSlice[] {
|
||||||
PsiElement resolveToDeclarationPsiElement(JetReferenceExpression referenceExpression);
|
NAMESPACE, CLASS, TYPE_PARAMETER, FUNCTION, CONSTRUCTOR, VARIABLE, VALUE_PARAMETER, PRIMARY_CONSTRUCTOR_PARAMETER, OBJECT_DECLARATION
|
||||||
PsiElement getDeclarationPsiElement(DeclarationDescriptor descriptor);
|
};
|
||||||
|
|
||||||
boolean isBlock(JetFunctionLiteralExpression expression);
|
ReadOnlySlice<PsiElement, DeclarationDescriptor> DECLARATION_TO_DESCRIPTOR = ManyMapSlices.<PsiElement, DeclarationDescriptor>sliceBuilder("DECLARATION_TO_DESCRIPTOR")
|
||||||
boolean isStatement(JetExpression expression);
|
.setFurtherLookupSlices(DECLARATIONS_TO_DESCRIPTORS).build();
|
||||||
boolean hasBackingField(PropertyDescriptor propertyDescriptor);
|
|
||||||
|
|
||||||
boolean isVariableReassignment(JetExpression expression);
|
WritableSlice<JetReferenceExpression, PsiElement> LABEL_TARGET = ManyMapSlices.<JetReferenceExpression, PsiElement>sliceBuilder("LABEL_TARGET").build();
|
||||||
|
WritableSlice<JetParameter, PropertyDescriptor> VALUE_PARAMETER_AS_PROPERTY = ManyMapSlices.<JetParameter, PropertyDescriptor>sliceBuilder("VALUE_PARAMETER_AS_PROPERTY").build();
|
||||||
ConstructorDescriptor resolveSuperConstructor(JetDelegatorToSuperCall superCall);
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
JetType getAutoCastType(@NotNull JetExpression expression);
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
JetScope getResolutionScope(@NotNull JetExpression expression);
|
|
||||||
|
|
||||||
Collection<JetDiagnostic> getDiagnostics();
|
Collection<JetDiagnostic> getDiagnostics();
|
||||||
|
|
||||||
|
<K, V> V get(ReadOnlySlice<K, V> slice, K key);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package org.jetbrains.jet.lang.resolve;
|
||||||
|
|
||||||
|
import com.intellij.psi.PsiElement;
|
||||||
|
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||||
|
import org.jetbrains.jet.lang.psi.JetReferenceExpression;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author abreslav
|
||||||
|
*/
|
||||||
|
public class BindingContextUtils {
|
||||||
|
public static PsiElement resolveToDeclarationPsiElement(BindingContext bindingContext, JetReferenceExpression referenceExpression) {
|
||||||
|
DeclarationDescriptor declarationDescriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, referenceExpression);
|
||||||
|
if (declarationDescriptor == null) {
|
||||||
|
return bindingContext.get(BindingContext.LABEL_TARGET, referenceExpression);
|
||||||
|
}
|
||||||
|
return bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, declarationDescriptor);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,57 +1,24 @@
|
|||||||
package org.jetbrains.jet.lang.resolve;
|
package org.jetbrains.jet.lang.resolve;
|
||||||
|
|
||||||
import com.intellij.psi.PsiElement;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.lang.ErrorHandlerWithRegions;
|
import org.jetbrains.jet.lang.ErrorHandler;
|
||||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
import org.jetbrains.jet.util.ReadOnlySlice;
|
||||||
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
|
import org.jetbrains.jet.util.WritableSlice;
|
||||||
import org.jetbrains.jet.lang.descriptors.VariableDescriptor;
|
|
||||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
|
||||||
import org.jetbrains.jet.lang.psi.*;
|
|
||||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
|
||||||
import org.jetbrains.jet.lang.types.JetType;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author abreslav
|
* @author abreslav
|
||||||
*/
|
*/
|
||||||
public interface BindingTrace {
|
public interface BindingTrace {
|
||||||
|
|
||||||
void recordExpressionType(@NotNull JetExpression expression, @NotNull JetType type);
|
|
||||||
|
|
||||||
void recordReferenceResolution(@NotNull JetReferenceExpression expression, @NotNull DeclarationDescriptor descriptor);
|
|
||||||
|
|
||||||
void recordLabelResolution(@NotNull JetReferenceExpression expression, @NotNull PsiElement element);
|
|
||||||
|
|
||||||
void recordDeclarationResolution(@NotNull PsiElement declaration, @NotNull DeclarationDescriptor descriptor);
|
|
||||||
|
|
||||||
void recordValueParameterAsPropertyResolution(@NotNull JetParameter declaration, @NotNull PropertyDescriptor descriptor);
|
|
||||||
|
|
||||||
void recordTypeResolution(@NotNull JetTypeReference typeReference, @NotNull JetType type);
|
|
||||||
|
|
||||||
void recordAnnotationResolution(@NotNull JetAnnotationEntry annotationEntry, @NotNull AnnotationDescriptor annotationDescriptor);
|
|
||||||
|
|
||||||
void recordCompileTimeValue(@NotNull JetExpression expression, @NotNull CompileTimeConstant<?> value);
|
|
||||||
|
|
||||||
void recordBlock(JetFunctionLiteralExpression expression);
|
|
||||||
|
|
||||||
void recordStatement(@NotNull JetElement statement);
|
|
||||||
|
|
||||||
void recordVariableReassignment(@NotNull JetExpression expression);
|
|
||||||
|
|
||||||
void recordResolutionScope(@NotNull JetExpression expression, @NotNull JetScope scope);
|
|
||||||
|
|
||||||
void removeStatementRecord(@NotNull JetElement statement);
|
|
||||||
|
|
||||||
void requireBackingField(@NotNull PropertyDescriptor propertyDescriptor);
|
|
||||||
|
|
||||||
void recordAutoCast(@NotNull JetExpression expression, @NotNull JetType type, @NotNull VariableDescriptor variableDescriptor);
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
ErrorHandlerWithRegions getErrorHandler();
|
ErrorHandler getErrorHandler();
|
||||||
|
|
||||||
boolean isProcessed(@NotNull JetExpression expression);
|
|
||||||
|
|
||||||
void markAsProcessed(@NotNull JetExpression expression);
|
|
||||||
|
|
||||||
BindingContext getBindingContext();
|
BindingContext getBindingContext();
|
||||||
|
|
||||||
|
<K, V> void record(WritableSlice<K, V> slice, K key, V value);
|
||||||
|
|
||||||
|
// Writes TRUE for a boolean value
|
||||||
|
<K> void record(WritableSlice<K, Boolean> slice, K key);
|
||||||
|
|
||||||
|
<K, V> V get(ReadOnlySlice<K, V> slice, K key);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,113 +1,61 @@
|
|||||||
package org.jetbrains.jet.lang.resolve;
|
package org.jetbrains.jet.lang.resolve;
|
||||||
|
|
||||||
import com.intellij.psi.PsiElement;
|
import com.google.common.collect.Maps;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.lang.ErrorHandlerWithRegions;
|
import org.jetbrains.jet.lang.ErrorHandler;
|
||||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
import org.jetbrains.jet.util.ReadOnlySlice;
|
||||||
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
|
import org.jetbrains.jet.util.WritableSlice;
|
||||||
import org.jetbrains.jet.lang.descriptors.VariableDescriptor;
|
|
||||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
import java.util.Map;
|
||||||
import org.jetbrains.jet.lang.psi.*;
|
|
||||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
|
||||||
import org.jetbrains.jet.lang.types.JetType;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author abreslav
|
* @author abreslav
|
||||||
*/
|
*/
|
||||||
public class BindingTraceAdapter implements BindingTrace {
|
public class BindingTraceAdapter implements BindingTrace {
|
||||||
private final BindingTrace originalTrace;
|
public interface RecordHandler<K, V> {
|
||||||
|
void handleRecord(WritableSlice<K, V> slice, K key, V value);
|
||||||
@Override
|
|
||||||
public void recordAutoCast(@NotNull JetExpression expression, @NotNull JetType type, @NotNull VariableDescriptor variableDescriptor) {
|
|
||||||
originalTrace.recordAutoCast(expression, type, variableDescriptor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final BindingTrace originalTrace;
|
||||||
|
private Map<WritableSlice, RecordHandler> handlers = Maps.newHashMap();
|
||||||
|
|
||||||
public BindingTraceAdapter(BindingTrace originalTrace) {
|
public BindingTraceAdapter(BindingTrace originalTrace) {
|
||||||
this.originalTrace = originalTrace;
|
this.originalTrace = originalTrace;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void recordExpressionType(@NotNull JetExpression expression, @NotNull JetType type) {
|
|
||||||
originalTrace.recordExpressionType(expression, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void recordReferenceResolution(@NotNull JetReferenceExpression expression, @NotNull DeclarationDescriptor descriptor) {
|
|
||||||
originalTrace.recordReferenceResolution(expression, descriptor);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void recordLabelResolution(@NotNull JetReferenceExpression expression, @NotNull PsiElement element) {
|
|
||||||
originalTrace.recordLabelResolution(expression, element);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void recordDeclarationResolution(@NotNull PsiElement declaration, @NotNull DeclarationDescriptor descriptor) {
|
|
||||||
originalTrace.recordDeclarationResolution(declaration, descriptor);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void recordValueParameterAsPropertyResolution(@NotNull JetParameter declaration, @NotNull PropertyDescriptor descriptor) {
|
|
||||||
originalTrace.recordValueParameterAsPropertyResolution(declaration, descriptor);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void recordTypeResolution(@NotNull JetTypeReference typeReference, @NotNull JetType type) {
|
|
||||||
originalTrace.recordTypeResolution(typeReference, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void recordAnnotationResolution(@NotNull JetAnnotationEntry annotationEntry, @NotNull AnnotationDescriptor annotationDescriptor) {
|
|
||||||
originalTrace.recordAnnotationResolution(annotationEntry, annotationDescriptor);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void recordCompileTimeValue(@NotNull JetExpression expression, @NotNull CompileTimeConstant<?> value) {
|
|
||||||
originalTrace.recordCompileTimeValue(expression, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void recordBlock(JetFunctionLiteralExpression expression) {
|
|
||||||
originalTrace.recordBlock(expression);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void recordStatement(@NotNull JetElement statement) {
|
|
||||||
originalTrace.recordStatement(statement);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void recordVariableReassignment(@NotNull JetExpression expression) {
|
|
||||||
originalTrace.recordVariableReassignment(expression);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void requireBackingField(@NotNull PropertyDescriptor propertyDescriptor) {
|
|
||||||
originalTrace.requireBackingField(propertyDescriptor);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
public ErrorHandler getErrorHandler() {
|
||||||
public ErrorHandlerWithRegions getErrorHandler() {
|
|
||||||
return originalTrace.getErrorHandler();
|
return originalTrace.getErrorHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeStatementRecord(@NotNull JetElement statement) {
|
|
||||||
originalTrace.removeStatementRecord(statement);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void markAsProcessed(@NotNull JetExpression expression) {
|
|
||||||
originalTrace.markAsProcessed(expression);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isProcessed(@NotNull JetExpression expression) {
|
|
||||||
return originalTrace.isProcessed(expression);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BindingContext getBindingContext() {
|
public BindingContext getBindingContext() {
|
||||||
return originalTrace.getBindingContext();
|
return originalTrace.getBindingContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void recordResolutionScope(@NotNull JetExpression expression, @NotNull JetScope scope) {
|
public <K, V> void record(WritableSlice<K, V> slice, K key, V value) {
|
||||||
originalTrace.recordResolutionScope(expression, scope);
|
originalTrace.record(slice, key, value);
|
||||||
|
RecordHandler recordHandler = handlers.get(slice);
|
||||||
|
if (recordHandler != null) {
|
||||||
|
recordHandler.handleRecord(slice, key, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <K> void record(WritableSlice<K, Boolean> slice, K key) {
|
||||||
|
record(slice, key, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <K, V> V get(ReadOnlySlice<K, V> slice, K key) {
|
||||||
|
return originalTrace.get(slice, key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public <K, V> BindingTraceAdapter addHandler(@NotNull WritableSlice<K, V> slice, @NotNull RecordHandler<K, V> handler) {
|
||||||
|
handlers.put(slice, handler);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,389 +1,61 @@
|
|||||||
package org.jetbrains.jet.lang.resolve;
|
package org.jetbrains.jet.lang.resolve;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
import com.intellij.psi.PsiElement;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.jetbrains.jet.lang.CollectingErrorHandler;
|
import org.jetbrains.jet.lang.CollectingErrorHandler;
|
||||||
import org.jetbrains.jet.lang.ErrorHandlerWithRegions;
|
import org.jetbrains.jet.lang.ErrorHandler;
|
||||||
import org.jetbrains.jet.lang.JetDiagnostic;
|
import org.jetbrains.jet.lang.JetDiagnostic;
|
||||||
import org.jetbrains.jet.lang.descriptors.*;
|
import org.jetbrains.jet.util.ManyMapImpl;
|
||||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
import org.jetbrains.jet.util.MutableManyMap;
|
||||||
import org.jetbrains.jet.lang.psi.*;
|
import org.jetbrains.jet.util.ReadOnlySlice;
|
||||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
import org.jetbrains.jet.util.WritableSlice;
|
||||||
import org.jetbrains.jet.lang.types.JetType;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author abreslav
|
* @author abreslav
|
||||||
*/
|
*/
|
||||||
public class BindingTraceContext implements BindingContext, BindingTrace {
|
public class BindingTraceContext implements BindingTrace {
|
||||||
private final Map<JetExpression, JetType> expressionTypes = new HashMap<JetExpression, JetType>();
|
|
||||||
private final Map<JetReferenceExpression, DeclarationDescriptor> resolutionResults = new HashMap<JetReferenceExpression, DeclarationDescriptor>();
|
|
||||||
private final Map<JetReferenceExpression, PsiElement> labelResolutionResults = new HashMap<JetReferenceExpression, PsiElement>();
|
|
||||||
private final Map<JetTypeReference, JetType> types = new HashMap<JetTypeReference, JetType>();
|
|
||||||
private final Map<DeclarationDescriptor, PsiElement> descriptorToDeclarations = new HashMap<DeclarationDescriptor, PsiElement>();
|
|
||||||
private final Map<PsiElement, DeclarationDescriptor> declarationsToDescriptors = new HashMap<PsiElement, DeclarationDescriptor>();
|
|
||||||
private final Map<PsiElement, ConstructorDescriptor> constructorDeclarationsToDescriptors = new HashMap<PsiElement, ConstructorDescriptor>();
|
|
||||||
private final Map<PsiElement, NamespaceDescriptor> namespaceDeclarationsToDescriptors = Maps.newHashMap();
|
|
||||||
private final Map<PsiElement, PropertyDescriptor> primaryConstructorParameterDeclarationsToPropertyDescriptors = Maps.newHashMap();
|
|
||||||
private final Map<JetExpression, JetType> autoCasts = Maps.newHashMap();
|
|
||||||
private final Map<JetExpression, JetScope> resolutionScopes = Maps.newHashMap();
|
|
||||||
|
|
||||||
private final Set<JetExpression> variableReassignments = Sets.newHashSet();
|
|
||||||
|
|
||||||
private final Set<JetFunctionLiteralExpression> blocks = new HashSet<JetFunctionLiteralExpression>();
|
|
||||||
private final Set<JetElement> statements = new HashSet<JetElement>();
|
|
||||||
private final Set<PropertyDescriptor> backingFieldRequired = new HashSet<PropertyDescriptor>();
|
|
||||||
private final Set<JetExpression> processed = Sets.newHashSet();
|
|
||||||
|
|
||||||
private final List<JetDiagnostic> diagnostics = Lists.newArrayList();
|
private final List<JetDiagnostic> diagnostics = Lists.newArrayList();
|
||||||
|
private final ErrorHandler errorHandler = new CollectingErrorHandler(diagnostics);
|
||||||
|
private final MutableManyMap map = ManyMapImpl.create();
|
||||||
|
|
||||||
private final ErrorHandlerWithRegions errorHandler = new ErrorHandlerWithRegions(new CollectingErrorHandler(diagnostics));
|
private final BindingContext bindingContext = new BindingContext() {
|
||||||
private Map<JetAnnotationEntry, AnnotationDescriptor> annotationDescriptos = Maps.newHashMap();
|
@Override
|
||||||
private Map<JetExpression, CompileTimeConstant<?>> compileTimeValues = Maps.newHashMap();
|
public Collection<JetDiagnostic> getDiagnostics() {
|
||||||
|
return diagnostics;
|
||||||
|
}
|
||||||
|
|
||||||
public BindingTraceContext() {
|
@Override
|
||||||
}
|
public <K, V> V get(ReadOnlySlice<K, V> slice, K key) {
|
||||||
|
return BindingTraceContext.this.get(slice, key);
|
||||||
public void destructiveMerge(BindingTraceContext other) {
|
}
|
||||||
safePutAll(expressionTypes, other.expressionTypes);
|
};
|
||||||
resolutionResults.putAll(other.resolutionResults);
|
|
||||||
safePutAll(labelResolutionResults, other.labelResolutionResults);
|
|
||||||
safePutAll(types, other.types);
|
|
||||||
safePutAll(descriptorToDeclarations, other.descriptorToDeclarations);
|
|
||||||
safePutAll(declarationsToDescriptors, other.declarationsToDescriptors);
|
|
||||||
safePutAll(constructorDeclarationsToDescriptors, other.constructorDeclarationsToDescriptors);
|
|
||||||
safePutAll(namespaceDeclarationsToDescriptors, other.namespaceDeclarationsToDescriptors);
|
|
||||||
safePutAll(primaryConstructorParameterDeclarationsToPropertyDescriptors, other.primaryConstructorParameterDeclarationsToPropertyDescriptors);
|
|
||||||
safePutAll(autoCasts, other.autoCasts);
|
|
||||||
safePutAll(resolutionScopes, other.resolutionScopes);
|
|
||||||
|
|
||||||
blocks.addAll(other.blocks);
|
|
||||||
statements.addAll(other.statements);
|
|
||||||
backingFieldRequired.addAll(other.backingFieldRequired);
|
|
||||||
processed.addAll(other.processed);
|
|
||||||
|
|
||||||
variableReassignments.addAll(other.variableReassignments);
|
|
||||||
|
|
||||||
diagnostics.addAll(other.diagnostics);
|
|
||||||
}
|
|
||||||
|
|
||||||
private <K, V> void safePutAll(Map<K, V> my, Map<K, V> other) {
|
|
||||||
assert keySetIntersection(my, other).isEmpty() : keySetIntersection(my, other);
|
|
||||||
|
|
||||||
my.putAll(other);
|
|
||||||
}
|
|
||||||
|
|
||||||
private <K, V> HashSet<K> keySetIntersection(Map<K, V> my, Map<K, V> other) {
|
|
||||||
HashSet<K> keySet = Sets.newHashSet(my.keySet());
|
|
||||||
keySet.retainAll(other.keySet());
|
|
||||||
return keySet;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public ErrorHandlerWithRegions getErrorHandler() {
|
@Override
|
||||||
|
public ErrorHandler getErrorHandler() {
|
||||||
return errorHandler;
|
return errorHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void recordExpressionType(@NotNull JetExpression expression, @NotNull JetType type) {
|
|
||||||
safePut(expressionTypes, expression, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void recordReferenceResolution(@NotNull JetReferenceExpression expression, @NotNull DeclarationDescriptor descriptor) {
|
|
||||||
resolutionResults.put(expression, descriptor);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void recordLabelResolution(@NotNull JetReferenceExpression expression, @NotNull PsiElement element) {
|
|
||||||
safePut(labelResolutionResults, expression, element);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void recordTypeResolution(@NotNull JetTypeReference typeReference, @NotNull JetType type) {
|
|
||||||
safePut(types, typeReference, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void recordAnnotationResolution(@NotNull JetAnnotationEntry annotationEntry, @NotNull AnnotationDescriptor annotationDescriptor) {
|
|
||||||
safePut(annotationDescriptos, annotationEntry, annotationDescriptor);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void recordCompileTimeValue(@NotNull JetExpression expression, @NotNull CompileTimeConstant<?> value) {
|
|
||||||
safePut(compileTimeValues, expression, value, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void recordDeclarationResolution(@NotNull PsiElement declaration, @NotNull DeclarationDescriptor descriptor) {
|
|
||||||
safePut(descriptorToDeclarations, getOriginal(descriptor), declaration);
|
|
||||||
descriptor.accept(new DeclarationDescriptorVisitor<Void, PsiElement>() {
|
|
||||||
@Override
|
|
||||||
public Void visitConstructorDescriptor(ConstructorDescriptor constructorDescriptor, PsiElement declaration) {
|
|
||||||
safePut(constructorDeclarationsToDescriptors, declaration, constructorDescriptor);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Void visitNamespaceDescriptor(NamespaceDescriptor descriptor, PsiElement declaration) {
|
|
||||||
safePut(namespaceDeclarationsToDescriptors, declaration, descriptor);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Void visitDeclarationDescriptor(DeclarationDescriptor descriptor, PsiElement declaration) {
|
|
||||||
safePut(declarationsToDescriptors, declaration, getOriginal(descriptor));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}, declaration);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void recordValueParameterAsPropertyResolution(@NotNull JetParameter declaration, @NotNull PropertyDescriptor descriptor) {
|
|
||||||
safePut(primaryConstructorParameterDeclarationsToPropertyDescriptors, declaration, (PropertyDescriptor) getOriginal(descriptor));
|
|
||||||
safePut(descriptorToDeclarations, getOriginal(descriptor), declaration);
|
|
||||||
}
|
|
||||||
|
|
||||||
private <K, V> void safePut(Map<K, V> map, K key, V value) {
|
|
||||||
safePut(map, key, value, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private <K, V> void safePut(Map<K, V> map, K key, V value, boolean canBeEquals) {
|
|
||||||
V oldValue = map.put(key, value);
|
|
||||||
assert oldValue == null || oldValue == value || (!canBeEquals || oldValue.equals(value)) :
|
|
||||||
(key instanceof PsiElement ? key.toString() + " \"" + ((PsiElement) key).getText() + "\"" : key.toString()) + " -> " + oldValue + " and " + value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void requireBackingField(@NotNull PropertyDescriptor propertyDescriptor) {
|
|
||||||
backingFieldRequired.add(propertyDescriptor);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void recordAutoCast(@NotNull JetExpression expression, @NotNull JetType type, @NotNull VariableDescriptor variableDescriptor) {
|
|
||||||
if (variableDescriptor.isVar()) {
|
|
||||||
getErrorHandler().genericError(expression.getNode(), "Automatic cast to " + type + " is impossible, because variable " + variableDescriptor.getName() + " is mutable");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
safePut(autoCasts, expression, type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void recordBlock(JetFunctionLiteralExpression expression) {
|
|
||||||
blocks.add(expression);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void recordStatement(@NotNull JetElement statement) {
|
|
||||||
statements.add(statement);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void recordVariableReassignment(@NotNull JetExpression expression) {
|
|
||||||
variableReassignments.add(expression);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void recordResolutionScope(@NotNull JetExpression expression, @NotNull JetScope scope) {
|
|
||||||
safePut(resolutionScopes, expression, scope);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeStatementRecord(@NotNull JetElement statement) {
|
|
||||||
statements.remove(statement);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DeclarationDescriptor getDeclarationDescriptor(PsiElement declaration) {
|
|
||||||
if (declaration instanceof JetNamespace) {
|
|
||||||
JetNamespace namespace = (JetNamespace) declaration;
|
|
||||||
return getNamespaceDescriptor(namespace);
|
|
||||||
}
|
|
||||||
return declarationsToDescriptors.get(declaration);
|
|
||||||
}
|
|
||||||
|
|
||||||
public NamespaceDescriptor getNamespaceDescriptor(JetNamespace declaration) {
|
|
||||||
return namespaceDeclarationsToDescriptors.get(declaration);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ClassDescriptor getClassDescriptor(JetClassOrObject declaration) {
|
|
||||||
return (ClassDescriptor) declarationsToDescriptors.get((JetDeclaration) declaration);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TypeParameterDescriptor getTypeParameterDescriptor(JetTypeParameter declaration) {
|
|
||||||
return (TypeParameterDescriptor) declarationsToDescriptors.get(declaration);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FunctionDescriptor getFunctionDescriptor(JetNamedFunction declaration) {
|
|
||||||
return (FunctionDescriptor) declarationsToDescriptors.get(declaration);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VariableDescriptor getVariableDescriptor(JetProperty declaration) {
|
|
||||||
return (VariableDescriptor) declarationsToDescriptors.get(declaration);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VariableDescriptor getVariableDescriptor(JetParameter declaration) {
|
|
||||||
return (VariableDescriptor) declarationsToDescriptors.get(declaration);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PropertyDescriptor getPropertyDescriptor(JetParameter primaryConstructorParameter) {
|
|
||||||
return primaryConstructorParameterDeclarationsToPropertyDescriptors.get(primaryConstructorParameter);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PropertyDescriptor getPropertyDescriptor(JetObjectDeclarationName objectDeclarationName) {
|
|
||||||
return (PropertyDescriptor) declarationsToDescriptors.get(objectDeclarationName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public ConstructorDescriptor getConstructorDescriptor(@NotNull JetElement declaration) {
|
|
||||||
return constructorDeclarationsToDescriptors.get(declaration);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AnnotationDescriptor getAnnotationDescriptor(JetAnnotationEntry annotationEntry) {
|
|
||||||
return annotationDescriptos.get(annotationEntry);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CompileTimeConstant<?> getCompileTimeValue(JetExpression expression) {
|
|
||||||
return compileTimeValues.get(expression);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public JetType resolveTypeReference(JetTypeReference typeReference) {
|
|
||||||
return types.get(typeReference);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public JetType getExpressionType(JetExpression expression) {
|
|
||||||
return expressionTypes.get(expression);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DeclarationDescriptor resolveReferenceExpression(JetReferenceExpression referenceExpression) {
|
|
||||||
return resolutionResults.get(referenceExpression);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PsiElement resolveToDeclarationPsiElement(JetReferenceExpression referenceExpression) {
|
|
||||||
DeclarationDescriptor declarationDescriptor = resolveReferenceExpression(referenceExpression);
|
|
||||||
if (declarationDescriptor == null) {
|
|
||||||
return labelResolutionResults.get(referenceExpression);
|
|
||||||
}
|
|
||||||
return descriptorToDeclarations.get(getOriginal(declarationDescriptor));
|
|
||||||
}
|
|
||||||
|
|
||||||
private DeclarationDescriptor getOriginal(DeclarationDescriptor declarationDescriptor) {
|
|
||||||
if (declarationDescriptor instanceof VariableAsFunctionDescriptor) {
|
|
||||||
VariableAsFunctionDescriptor descriptor = (VariableAsFunctionDescriptor) declarationDescriptor;
|
|
||||||
return descriptor.getVariableDescriptor().getOriginal();
|
|
||||||
}
|
|
||||||
return declarationDescriptor.getOriginal();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PsiElement getDeclarationPsiElement(@NotNull DeclarationDescriptor descriptor) {
|
|
||||||
return descriptorToDeclarations.get(getOriginal(descriptor));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isBlock(JetFunctionLiteralExpression expression) {
|
|
||||||
return !expression.getFunctionLiteral().hasParameterSpecification() && blocks.contains(expression);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isStatement(@NotNull JetExpression expression) {
|
|
||||||
return statements.contains(expression);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasBackingField(@NotNull PropertyDescriptor propertyDescriptor) {
|
|
||||||
PsiElement declarationPsiElement = getDeclarationPsiElement(propertyDescriptor);
|
|
||||||
if (declarationPsiElement instanceof JetParameter) {
|
|
||||||
JetParameter jetParameter = (JetParameter) declarationPsiElement;
|
|
||||||
return jetParameter.getValOrVarNode() != null ||
|
|
||||||
backingFieldRequired.contains(propertyDescriptor);
|
|
||||||
}
|
|
||||||
if (propertyDescriptor.getModifiers().isAbstract()) return false;
|
|
||||||
PropertyGetterDescriptor getter = propertyDescriptor.getGetter();
|
|
||||||
PropertySetterDescriptor setter = propertyDescriptor.getSetter();
|
|
||||||
if (getter == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (propertyDescriptor.isVar() && setter == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (setter != null && !setter.hasBody() && !setter.getModifiers().isAbstract()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (!getter.hasBody() && !getter.getModifiers().isAbstract()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return backingFieldRequired.contains(propertyDescriptor);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isVariableReassignment(JetExpression expression) {
|
|
||||||
return variableReassignments.contains(expression);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ConstructorDescriptor resolveSuperConstructor(JetDelegatorToSuperCall superCall) {
|
|
||||||
JetTypeReference typeReference = superCall.getTypeReference();
|
|
||||||
if (typeReference == null) return null;
|
|
||||||
|
|
||||||
JetTypeElement typeElement = typeReference.getTypeElement();
|
|
||||||
if (!(typeElement instanceof JetUserType)) return null;
|
|
||||||
|
|
||||||
DeclarationDescriptor descriptor = resolveReferenceExpression(((JetUserType) typeElement).getReferenceExpression());
|
|
||||||
return descriptor instanceof ConstructorDescriptor ? (ConstructorDescriptor) descriptor : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public JetType getAutoCastType(@NotNull JetExpression expression) {
|
|
||||||
return autoCasts.get(expression);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public JetScope getResolutionScope(@NotNull JetExpression expression) {
|
|
||||||
return resolutionScopes.get(expression);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<JetDiagnostic> getDiagnostics() {
|
|
||||||
return diagnostics;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void markAsProcessed(@NotNull JetExpression expression) {
|
|
||||||
processed.add(expression);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isProcessed(@NotNull JetExpression expression) {
|
|
||||||
return processed.contains(expression);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BindingContext getBindingContext() {
|
public BindingContext getBindingContext() {
|
||||||
return this;
|
return bindingContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <K, V> void record(WritableSlice<K, V> slice, K key, V value) {
|
||||||
|
map.put(slice, key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <K> void record(WritableSlice<K, Boolean> slice, K key) {
|
||||||
|
record(slice, key, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <K, V> V get(ReadOnlySlice<K, V> slice, K key) {
|
||||||
|
return map.get(slice, key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -51,7 +51,7 @@ public class ClassDescriptorResolver {
|
|||||||
annotationResolver.resolveAnnotations(scope, classElement.getModifierList()),
|
annotationResolver.resolveAnnotations(scope, classElement.getModifierList()),
|
||||||
JetPsiUtil.safeName(classElement.getName()));
|
JetPsiUtil.safeName(classElement.getName()));
|
||||||
|
|
||||||
trace.recordDeclarationResolution(classElement, classDescriptor);
|
trace.record(BindingContext.CLASS, classElement, classDescriptor);
|
||||||
|
|
||||||
final WritableScope parameterScope = new WritableScopeImpl(scope, classDescriptor, trace.getErrorHandler());
|
final WritableScope parameterScope = new WritableScopeImpl(scope, classDescriptor, trace.getErrorHandler());
|
||||||
|
|
||||||
@@ -134,15 +134,15 @@ public class ClassDescriptorResolver {
|
|||||||
JetPsiUtil.safeName(typeParameter.getName()),
|
JetPsiUtil.safeName(typeParameter.getName()),
|
||||||
index
|
index
|
||||||
);
|
);
|
||||||
trace.recordDeclarationResolution(typeParameter, typeParameterDescriptor);
|
trace.record(BindingContext.TYPE_PARAMETER, typeParameter, typeParameterDescriptor);
|
||||||
typeParameters.add(typeParameterDescriptor);
|
typeParameters.add(typeParameterDescriptor);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
descriptor.setTypeParameterDescriptors(typeParameters);
|
descriptor.setTypeParameterDescriptors(typeParameters);
|
||||||
|
|
||||||
descriptor.setOpen(classElement.hasModifier(JetTokens.OPEN_KEYWORD));
|
descriptor.setOpen(classElement.hasModifier(JetTokens.OPEN_KEYWORD) || classElement.hasModifier(JetTokens.ABSTRACT_KEYWORD));
|
||||||
|
|
||||||
trace.recordDeclarationResolution(classElement, descriptor);
|
trace.record(BindingContext.CLASS, classElement, descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resolveSupertypes(@NotNull JetClassOrObject jetClass, @NotNull MutableClassDescriptor descriptor) {
|
public void resolveSupertypes(@NotNull JetClassOrObject jetClass, @NotNull MutableClassDescriptor descriptor) {
|
||||||
@@ -151,7 +151,7 @@ public class ClassDescriptorResolver {
|
|||||||
// TODO : beautify
|
// TODO : beautify
|
||||||
if (jetClass instanceof JetEnumEntry) {
|
if (jetClass instanceof JetEnumEntry) {
|
||||||
JetClassOrObject parent = PsiTreeUtil.getParentOfType(jetClass, JetClassOrObject.class);
|
JetClassOrObject parent = PsiTreeUtil.getParentOfType(jetClass, JetClassOrObject.class);
|
||||||
ClassDescriptor parentDescriptor = trace.getBindingContext().getClassDescriptor(parent);
|
ClassDescriptor parentDescriptor = trace.getBindingContext().get(BindingContext.CLASS, parent);
|
||||||
if (parentDescriptor.getTypeConstructor().getParameters().isEmpty()) {
|
if (parentDescriptor.getTypeConstructor().getParameters().isEmpty()) {
|
||||||
defaultSupertype = parentDescriptor.getDefaultType();
|
defaultSupertype = parentDescriptor.getDefaultType();
|
||||||
}
|
}
|
||||||
@@ -227,7 +227,7 @@ public class ClassDescriptorResolver {
|
|||||||
valueParameterDescriptors,
|
valueParameterDescriptors,
|
||||||
returnType);
|
returnType);
|
||||||
|
|
||||||
trace.recordDeclarationResolution(function, functionDescriptor);
|
trace.record(BindingContext.FUNCTION, function, functionDescriptor);
|
||||||
return functionDescriptor;
|
return functionDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,7 +272,7 @@ public class ClassDescriptorResolver {
|
|||||||
);
|
);
|
||||||
// TODO : Default values???
|
// TODO : Default values???
|
||||||
|
|
||||||
trace.recordDeclarationResolution(valueParameter, valueParameterDescriptor);
|
trace.record(BindingContext.VALUE_PARAMETER, valueParameter, valueParameterDescriptor);
|
||||||
return valueParameterDescriptor;
|
return valueParameterDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,7 +299,7 @@ public class ClassDescriptorResolver {
|
|||||||
);
|
);
|
||||||
// typeParameterDescriptor.addUpperBound(bound);
|
// typeParameterDescriptor.addUpperBound(bound);
|
||||||
extensibleScope.addTypeParameterDescriptor(typeParameterDescriptor);
|
extensibleScope.addTypeParameterDescriptor(typeParameterDescriptor);
|
||||||
trace.recordDeclarationResolution(typeParameter, typeParameterDescriptor);
|
trace.record(BindingContext.TYPE_PARAMETER, typeParameter, typeParameterDescriptor);
|
||||||
return typeParameterDescriptor;
|
return typeParameterDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -330,14 +330,14 @@ public class ClassDescriptorResolver {
|
|||||||
ClassifierDescriptor classifier = scope.getClassifier(referencedName);
|
ClassifierDescriptor classifier = scope.getClassifier(referencedName);
|
||||||
if (classifier != null) {
|
if (classifier != null) {
|
||||||
trace.getErrorHandler().genericError(subjectTypeParameterName.getNode(), referencedName + " does not refer to a type parameter of " + declaration.getName());
|
trace.getErrorHandler().genericError(subjectTypeParameterName.getNode(), referencedName + " does not refer to a type parameter of " + declaration.getName());
|
||||||
trace.recordReferenceResolution(subjectTypeParameterName, classifier);
|
trace.record(BindingContext.REFERENCE_TARGET, subjectTypeParameterName, classifier);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
trace.getErrorHandler().unresolvedReference(subjectTypeParameterName);
|
trace.getErrorHandler().unresolvedReference(subjectTypeParameterName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
trace.recordReferenceResolution(subjectTypeParameterName, typeParameterDescriptor);
|
trace.record(BindingContext.REFERENCE_TARGET, subjectTypeParameterName, typeParameterDescriptor);
|
||||||
JetTypeReference boundTypeReference = constraint.getBoundTypeReference();
|
JetTypeReference boundTypeReference = constraint.getBoundTypeReference();
|
||||||
if (boundTypeReference != null) {
|
if (boundTypeReference != null) {
|
||||||
JetType bound = resolveAndCheckUpperBoundType(boundTypeReference, scope, constraint.isClassObjectContraint());
|
JetType bound = resolveAndCheckUpperBoundType(boundTypeReference, scope, constraint.isClassObjectContraint());
|
||||||
@@ -430,7 +430,7 @@ public class ClassDescriptorResolver {
|
|||||||
JetPsiUtil.safeName(parameter.getName()),
|
JetPsiUtil.safeName(parameter.getName()),
|
||||||
type,
|
type,
|
||||||
parameter.isMutable());
|
parameter.isMutable());
|
||||||
trace.recordDeclarationResolution(parameter, variableDescriptor);
|
trace.record(BindingContext.VALUE_PARAMETER, parameter, variableDescriptor);
|
||||||
return variableDescriptor;
|
return variableDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -449,7 +449,7 @@ public class ClassDescriptorResolver {
|
|||||||
JetPsiUtil.safeName(property.getName()),
|
JetPsiUtil.safeName(property.getName()),
|
||||||
type,
|
type,
|
||||||
property.isVar());
|
property.isVar());
|
||||||
trace.recordDeclarationResolution(property, variableDescriptor);
|
trace.record(BindingContext.VARIABLE, property, variableDescriptor);
|
||||||
return variableDescriptor;
|
return variableDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -472,7 +472,7 @@ public class ClassDescriptorResolver {
|
|||||||
|
|
||||||
JetObjectDeclarationName nameAsDeclaration = objectDeclaration.getNameAsDeclaration();
|
JetObjectDeclarationName nameAsDeclaration = objectDeclaration.getNameAsDeclaration();
|
||||||
if (nameAsDeclaration != null) {
|
if (nameAsDeclaration != null) {
|
||||||
trace.recordDeclarationResolution(nameAsDeclaration, propertyDescriptor);
|
trace.record(BindingContext.OBJECT_DECLARATION, nameAsDeclaration, propertyDescriptor);
|
||||||
}
|
}
|
||||||
return propertyDescriptor;
|
return propertyDescriptor;
|
||||||
}
|
}
|
||||||
@@ -520,7 +520,7 @@ public class ClassDescriptorResolver {
|
|||||||
resolvePropertyGetterDescriptor(scopeWithTypeParameters, property, propertyDescriptor),
|
resolvePropertyGetterDescriptor(scopeWithTypeParameters, property, propertyDescriptor),
|
||||||
resolvePropertySetterDescriptor(scopeWithTypeParameters, property, propertyDescriptor));
|
resolvePropertySetterDescriptor(scopeWithTypeParameters, property, propertyDescriptor));
|
||||||
|
|
||||||
trace.recordDeclarationResolution(property, propertyDescriptor);
|
trace.record(BindingContext.VARIABLE, property, propertyDescriptor);
|
||||||
return propertyDescriptor;
|
return propertyDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -612,7 +612,7 @@ public class ClassDescriptorResolver {
|
|||||||
MutableValueParameterDescriptor valueParameterDescriptor = resolveValueParameterDescriptor(setterDescriptor, parameter, 0, type);
|
MutableValueParameterDescriptor valueParameterDescriptor = resolveValueParameterDescriptor(setterDescriptor, parameter, 0, type);
|
||||||
setterDescriptor.initialize(valueParameterDescriptor);
|
setterDescriptor.initialize(valueParameterDescriptor);
|
||||||
}
|
}
|
||||||
trace.recordDeclarationResolution(setter, setterDescriptor);
|
trace.record(BindingContext.PROPERTY_ACCESSOR, setter, setterDescriptor);
|
||||||
}
|
}
|
||||||
return setterDescriptor;
|
return setterDescriptor;
|
||||||
}
|
}
|
||||||
@@ -633,7 +633,7 @@ public class ClassDescriptorResolver {
|
|||||||
getterDescriptor = new PropertyGetterDescriptor(
|
getterDescriptor = new PropertyGetterDescriptor(
|
||||||
resolveModifiers(getter.getModifierList(), DEFAULT_MODIFIERS), // TODO : default modifiers differ in different contexts
|
resolveModifiers(getter.getModifierList(), DEFAULT_MODIFIERS), // TODO : default modifiers differ in different contexts
|
||||||
propertyDescriptor, annotations, returnType, getter.getBodyExpression() != null);
|
propertyDescriptor, annotations, returnType, getter.getBodyExpression() != null);
|
||||||
trace.recordDeclarationResolution(getter, getterDescriptor);
|
trace.record(BindingContext.PROPERTY_ACCESSOR, getter, getterDescriptor);
|
||||||
}
|
}
|
||||||
return getterDescriptor;
|
return getterDescriptor;
|
||||||
}
|
}
|
||||||
@@ -656,7 +656,7 @@ public class ClassDescriptorResolver {
|
|||||||
annotationResolver.resolveAnnotations(scope, modifierList),
|
annotationResolver.resolveAnnotations(scope, modifierList),
|
||||||
isPrimary
|
isPrimary
|
||||||
);
|
);
|
||||||
trace.recordDeclarationResolution(declarationToTrace, constructorDescriptor);
|
trace.record(BindingContext.CONSTRUCTOR, declarationToTrace, constructorDescriptor);
|
||||||
return constructorDescriptor.initialize(
|
return constructorDescriptor.initialize(
|
||||||
typeParameters,
|
typeParameters,
|
||||||
resolveValueParameters(
|
resolveValueParameters(
|
||||||
@@ -704,7 +704,7 @@ public class ClassDescriptorResolver {
|
|||||||
isMutable ? type : null,
|
isMutable ? type : null,
|
||||||
type);
|
type);
|
||||||
propertyDescriptor.initialize(Collections.<TypeParameterDescriptor>emptyList(), null, null);
|
propertyDescriptor.initialize(Collections.<TypeParameterDescriptor>emptyList(), null, null);
|
||||||
trace.recordValueParameterAsPropertyResolution(parameter, propertyDescriptor);
|
trace.record(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, parameter, propertyDescriptor);
|
||||||
return propertyDescriptor;
|
return propertyDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -971,5 +971,4 @@ public class ClassDescriptorResolver {
|
|||||||
previousInstruction.accept(visitor);
|
previousInstruction.accept(visitor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class ScopeWithReceiver extends JetScopeImpl {
|
|||||||
// return false;
|
// return false;
|
||||||
// }
|
// }
|
||||||
// // TODO : in case of inferred type arguments, substitute the receiver type first
|
// // TODO : in case of inferred type arguments, substitute the receiver type first
|
||||||
// return typeChecker.isSubtypeOf(receiverType, functionReceiverType);
|
// return typeChecker.startForPairOfTypes(receiverType, functionReceiverType);
|
||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,79 @@
|
|||||||
|
package org.jetbrains.jet.lang.resolve;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.jet.lang.CollectingErrorHandler;
|
||||||
|
import org.jetbrains.jet.lang.ErrorHandler;
|
||||||
|
import org.jetbrains.jet.lang.JetDiagnostic;
|
||||||
|
import org.jetbrains.jet.util.*;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author abreslav
|
||||||
|
*/
|
||||||
|
public class TemporaryBindingTrace implements BindingTrace {
|
||||||
|
private final BindingContext parentContext;
|
||||||
|
private final MutableManyMap map = ManyMapImpl.create();
|
||||||
|
private final List<JetDiagnostic> diagnostics = Lists.newArrayList();
|
||||||
|
private final ErrorHandler errorHandler = new CollectingErrorHandler(diagnostics);
|
||||||
|
|
||||||
|
private final BindingContext bindingContext = new BindingContext() {
|
||||||
|
@Override
|
||||||
|
public Collection<JetDiagnostic> getDiagnostics() {
|
||||||
|
throw new UnsupportedOperationException(); // TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <K, V> V get(ReadOnlySlice<K, V> slice, K key) {
|
||||||
|
return TemporaryBindingTrace.this.get(slice, key);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public TemporaryBindingTrace(BindingContext parentContext) {
|
||||||
|
this.parentContext = parentContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NotNull
|
||||||
|
public ErrorHandler getErrorHandler() {
|
||||||
|
return errorHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BindingContext getBindingContext() {
|
||||||
|
return bindingContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <K, V> void record(WritableSlice<K, V> slice, K key, V value) {
|
||||||
|
map.put(slice, key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <K> void record(WritableSlice<K, Boolean> slice, K key) {
|
||||||
|
record(slice, key, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <K, V> V get(ReadOnlySlice<K, V> slice, K key) {
|
||||||
|
if (map.containsKey(slice, key)) {
|
||||||
|
return map.get(slice, key);
|
||||||
|
}
|
||||||
|
return parentContext.get(slice, key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addAllMyDataTo(BindingTrace trace) {
|
||||||
|
for (Map.Entry<ManyMapKey<?, ?>, ?> entry : map) {
|
||||||
|
ManyMapKey manyMapKey = entry.getKey();
|
||||||
|
Object value = entry.getValue();
|
||||||
|
|
||||||
|
//noinspection unchecked
|
||||||
|
trace.record(manyMapKey.getSlice(), manyMapKey.getKey(), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
AnalyzingUtils.applyHandler(trace.getErrorHandler(), diagnostics);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,6 +16,7 @@ import org.jetbrains.jet.lang.types.JetStandardClasses;
|
|||||||
import org.jetbrains.jet.lang.types.JetType;
|
import org.jetbrains.jet.lang.types.JetType;
|
||||||
import org.jetbrains.jet.lang.types.JetTypeInferrer;
|
import org.jetbrains.jet.lang.types.JetTypeInferrer;
|
||||||
import org.jetbrains.jet.lexer.JetTokens;
|
import org.jetbrains.jet.lexer.JetTokens;
|
||||||
|
import org.jetbrains.jet.util.WritableSlice;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@@ -31,7 +32,7 @@ public class TopDownAnalyzer {
|
|||||||
|
|
||||||
private final Map<JetNamedFunction, FunctionDescriptorImpl> functions = Maps.newLinkedHashMap();
|
private final Map<JetNamedFunction, FunctionDescriptorImpl> functions = Maps.newLinkedHashMap();
|
||||||
private final Map<JetDeclaration, ConstructorDescriptor> constructors = Maps.newLinkedHashMap();
|
private final Map<JetDeclaration, ConstructorDescriptor> constructors = Maps.newLinkedHashMap();
|
||||||
private final Map<JetProperty, PropertyDescriptor> properties = new LinkedHashMap<JetProperty, PropertyDescriptor>();
|
private final Map<JetProperty, PropertyDescriptor> properties = Maps.newLinkedHashMap();
|
||||||
private final Map<JetDeclaration, JetScope> declaringScopes = Maps.newHashMap();
|
private final Map<JetDeclaration, JetScope> declaringScopes = Maps.newHashMap();
|
||||||
private final Set<PropertyDescriptor> primaryConstructorParameterProperties = Sets.newHashSet();
|
private final Set<PropertyDescriptor> primaryConstructorParameterProperties = Sets.newHashSet();
|
||||||
|
|
||||||
@@ -47,34 +48,32 @@ public class TopDownAnalyzer {
|
|||||||
this.trace = bindingTrace;
|
this.trace = bindingTrace;
|
||||||
|
|
||||||
// This allows access to backing fields
|
// This allows access to backing fields
|
||||||
this.traceForConstructors = new BindingTraceAdapter(bindingTrace) {
|
this.traceForConstructors = new BindingTraceAdapter(bindingTrace).addHandler(BindingContext.REFERENCE_TARGET, new BindingTraceAdapter.RecordHandler<JetReferenceExpression, DeclarationDescriptor>() {
|
||||||
@Override
|
@Override
|
||||||
public void recordReferenceResolution(@NotNull JetReferenceExpression expression, @NotNull DeclarationDescriptor descriptor) {
|
public void handleRecord(WritableSlice<JetReferenceExpression, DeclarationDescriptor> slice, JetReferenceExpression expression, DeclarationDescriptor descriptor) {
|
||||||
super.recordReferenceResolution(expression, descriptor);
|
|
||||||
if (expression instanceof JetSimpleNameExpression) {
|
if (expression instanceof JetSimpleNameExpression) {
|
||||||
JetSimpleNameExpression simpleNameExpression = (JetSimpleNameExpression) expression;
|
JetSimpleNameExpression simpleNameExpression = (JetSimpleNameExpression) expression;
|
||||||
if (simpleNameExpression.getReferencedNameElementType() == JetTokens.FIELD_IDENTIFIER) {
|
if (simpleNameExpression.getReferencedNameElementType() == JetTokens.FIELD_IDENTIFIER) {
|
||||||
if (!trace.getBindingContext().hasBackingField((PropertyDescriptor) descriptor)) {
|
if (!trace.getBindingContext().get(BindingContext.BACKING_FIELD_REQUIRED, (PropertyDescriptor) descriptor)) {
|
||||||
TopDownAnalyzer.this.trace.getErrorHandler().genericError(expression.getNode(), "This property does not have a backing field");
|
TopDownAnalyzer.this.trace.getErrorHandler().genericError(expression.getNode(), "This property does not have a backing field");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
// This tracks access to properties in order to register primary constructor parameters that yield real fields (JET-9)
|
// This tracks access to properties in order to register primary constructor parameters that yield real fields (JET-9)
|
||||||
this.traceForMembers = new BindingTraceAdapter(bindingTrace) {
|
this.traceForMembers = new BindingTraceAdapter(bindingTrace).addHandler(BindingContext.REFERENCE_TARGET, new BindingTraceAdapter.RecordHandler<JetReferenceExpression, DeclarationDescriptor>() {
|
||||||
@Override
|
@Override
|
||||||
public void recordReferenceResolution(@NotNull JetReferenceExpression expression, @NotNull DeclarationDescriptor descriptor) {
|
public void handleRecord(WritableSlice<JetReferenceExpression, DeclarationDescriptor> slice, JetReferenceExpression expression, DeclarationDescriptor descriptor) {
|
||||||
super.recordReferenceResolution(expression, descriptor);
|
|
||||||
if (descriptor instanceof PropertyDescriptor) {
|
if (descriptor instanceof PropertyDescriptor) {
|
||||||
PropertyDescriptor propertyDescriptor = (PropertyDescriptor) descriptor;
|
PropertyDescriptor propertyDescriptor = (PropertyDescriptor) descriptor;
|
||||||
if (primaryConstructorParameterProperties.contains(propertyDescriptor)) {
|
if (primaryConstructorParameterProperties.contains(propertyDescriptor)) {
|
||||||
requireBackingField(propertyDescriptor);
|
traceForMembers.record(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated // For JetStandardLibraryOnly
|
@Deprecated // For JetStandardLibraryOnly
|
||||||
@@ -129,8 +128,6 @@ public class TopDownAnalyzer {
|
|||||||
resolveFunctionAndPropertyHeaders(); // Constructor headers are resolved as well
|
resolveFunctionAndPropertyHeaders(); // Constructor headers are resolved as well
|
||||||
|
|
||||||
resolveBehaviorDeclarationBodies();
|
resolveBehaviorDeclarationBodies();
|
||||||
|
|
||||||
trace.getErrorHandler().close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void collectNamespacesAndClassifiers(
|
private void collectNamespacesAndClassifiers(
|
||||||
@@ -155,7 +152,7 @@ public class TopDownAnalyzer {
|
|||||||
);
|
);
|
||||||
namespaceDescriptor.initialize(new WritableScopeImpl(JetScope.EMPTY, namespaceDescriptor, trace.getErrorHandler()).setDebugName("Namespace member scope"));
|
namespaceDescriptor.initialize(new WritableScopeImpl(JetScope.EMPTY, namespaceDescriptor, trace.getErrorHandler()).setDebugName("Namespace member scope"));
|
||||||
owner.addNamespace(namespaceDescriptor);
|
owner.addNamespace(namespaceDescriptor);
|
||||||
trace.recordDeclarationResolution(namespace, namespaceDescriptor);
|
trace.record(BindingContext.NAMESPACE, namespace, namespaceDescriptor);
|
||||||
}
|
}
|
||||||
namespaceDescriptors.put(namespace, namespaceDescriptor);
|
namespaceDescriptors.put(namespace, namespaceDescriptor);
|
||||||
|
|
||||||
@@ -222,7 +219,7 @@ public class TopDownAnalyzer {
|
|||||||
};
|
};
|
||||||
visitClassOrObject(declaration, (Map) objects, owner, outerScope, mutableClassDescriptor);
|
visitClassOrObject(declaration, (Map) objects, owner, outerScope, mutableClassDescriptor);
|
||||||
createPrimaryConstructor(mutableClassDescriptor);
|
createPrimaryConstructor(mutableClassDescriptor);
|
||||||
trace.recordDeclarationResolution((PsiElement) declaration, mutableClassDescriptor);
|
trace.record(BindingContext.CLASS, declaration, mutableClassDescriptor);
|
||||||
return mutableClassDescriptor;
|
return mutableClassDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,7 +309,7 @@ public class TopDownAnalyzer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (classifierDescriptor != null) {
|
if (classifierDescriptor != null) {
|
||||||
trace.recordReferenceResolution(referenceExpression, classifierDescriptor);
|
trace.record(BindingContext.REFERENCE_TARGET, referenceExpression, classifierDescriptor);
|
||||||
|
|
||||||
String aliasName = importDirective.getAliasName();
|
String aliasName = importDirective.getAliasName();
|
||||||
String importedClassifierName = aliasName != null ? aliasName : classifierDescriptor.getName();
|
String importedClassifierName = aliasName != null ? aliasName : classifierDescriptor.getName();
|
||||||
@@ -356,7 +353,7 @@ public class TopDownAnalyzer {
|
|||||||
for (JetDelegationSpecifier delegationSpecifier : jetClass.getDelegationSpecifiers()) {
|
for (JetDelegationSpecifier delegationSpecifier : jetClass.getDelegationSpecifiers()) {
|
||||||
JetTypeReference typeReference = delegationSpecifier.getTypeReference();
|
JetTypeReference typeReference = delegationSpecifier.getTypeReference();
|
||||||
if (typeReference != null) {
|
if (typeReference != null) {
|
||||||
JetType type = trace.getBindingContext().resolveTypeReference(typeReference);
|
JetType type = trace.getBindingContext().get(BindingContext.TYPE, typeReference);
|
||||||
classDescriptorResolver.checkBounds(typeReference, type);
|
classDescriptorResolver.checkBounds(typeReference, type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -364,7 +361,7 @@ public class TopDownAnalyzer {
|
|||||||
for (JetTypeParameter jetTypeParameter : jetClass.getTypeParameters()) {
|
for (JetTypeParameter jetTypeParameter : jetClass.getTypeParameters()) {
|
||||||
JetTypeReference extendsBound = jetTypeParameter.getExtendsBound();
|
JetTypeReference extendsBound = jetTypeParameter.getExtendsBound();
|
||||||
if (extendsBound != null) {
|
if (extendsBound != null) {
|
||||||
JetType type = trace.getBindingContext().resolveTypeReference(extendsBound);
|
JetType type = trace.getBindingContext().get(BindingContext.TYPE, extendsBound);
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
classDescriptorResolver.checkBounds(extendsBound, type);
|
classDescriptorResolver.checkBounds(extendsBound, type);
|
||||||
}
|
}
|
||||||
@@ -374,7 +371,7 @@ public class TopDownAnalyzer {
|
|||||||
for (JetTypeConstraint constraint : jetClass.getTypeConstaints()) {
|
for (JetTypeConstraint constraint : jetClass.getTypeConstaints()) {
|
||||||
JetTypeReference extendsBound = constraint.getBoundTypeReference();
|
JetTypeReference extendsBound = constraint.getBoundTypeReference();
|
||||||
if (extendsBound != null) {
|
if (extendsBound != null) {
|
||||||
JetType type = trace.getBindingContext().resolveTypeReference(extendsBound);
|
JetType type = trace.getBindingContext().get(BindingContext.TYPE, extendsBound);
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
classDescriptorResolver.checkBounds(extendsBound, type);
|
classDescriptorResolver.checkBounds(extendsBound, type);
|
||||||
}
|
}
|
||||||
@@ -534,7 +531,7 @@ public class TopDownAnalyzer {
|
|||||||
JetClass jetClass = entry.getKey();
|
JetClass jetClass = entry.getKey();
|
||||||
if (classDescriptor.getUnsubstitutedPrimaryConstructor() == null) {
|
if (classDescriptor.getUnsubstitutedPrimaryConstructor() == null) {
|
||||||
for (PropertyDescriptor propertyDescriptor : classDescriptor.getProperties()) {
|
for (PropertyDescriptor propertyDescriptor : classDescriptor.getProperties()) {
|
||||||
if (trace.getBindingContext().hasBackingField(propertyDescriptor)) {
|
if ((boolean) trace.getBindingContext().get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor)) {
|
||||||
PsiElement nameIdentifier = jetClass.getNameIdentifier();
|
PsiElement nameIdentifier = jetClass.getNameIdentifier();
|
||||||
if (nameIdentifier != null) {
|
if (nameIdentifier != null) {
|
||||||
trace.getErrorHandler().genericError(nameIdentifier.getNode(),
|
trace.getErrorHandler().genericError(nameIdentifier.getNode(),
|
||||||
@@ -572,7 +569,7 @@ public class TopDownAnalyzer {
|
|||||||
if (delegateExpression != null) {
|
if (delegateExpression != null) {
|
||||||
JetScope scope = scopeForConstructor == null ? descriptor.getScopeForMemberResolution() : scopeForConstructor;
|
JetScope scope = scopeForConstructor == null ? descriptor.getScopeForMemberResolution() : scopeForConstructor;
|
||||||
JetType type = typeInferrer.getType(scope, delegateExpression, false, JetTypeInferrer.NO_EXPECTED_TYPE);
|
JetType type = typeInferrer.getType(scope, delegateExpression, false, JetTypeInferrer.NO_EXPECTED_TYPE);
|
||||||
JetType supertype = trace.getBindingContext().resolveTypeReference(specifier.getTypeReference());
|
JetType supertype = trace.getBindingContext().get(BindingContext.TYPE, specifier.getTypeReference());
|
||||||
if (type != null && !semanticServices.getTypeChecker().isSubtypeOf(type, supertype)) { // TODO : Convertible?
|
if (type != null && !semanticServices.getTypeChecker().isSubtypeOf(type, supertype)) { // TODO : Convertible?
|
||||||
trace.getErrorHandler().typeMismatch(delegateExpression, supertype, type);
|
trace.getErrorHandler().typeMismatch(delegateExpression, supertype, type);
|
||||||
}
|
}
|
||||||
@@ -597,7 +594,7 @@ public class TopDownAnalyzer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitDelegationToSuperClassSpecifier(JetDelegatorToSuperClass specifier) {
|
public void visitDelegationToSuperClassSpecifier(JetDelegatorToSuperClass specifier) {
|
||||||
JetType supertype = trace.getBindingContext().resolveTypeReference(specifier.getTypeReference());
|
JetType supertype = trace.getBindingContext().get(BindingContext.TYPE, specifier.getTypeReference());
|
||||||
if (supertype != null) {
|
if (supertype != null) {
|
||||||
DeclarationDescriptor declarationDescriptor = supertype.getConstructor().getDeclarationDescriptor();
|
DeclarationDescriptor declarationDescriptor = supertype.getConstructor().getDeclarationDescriptor();
|
||||||
if (declarationDescriptor instanceof ClassDescriptor) {
|
if (declarationDescriptor instanceof ClassDescriptor) {
|
||||||
@@ -747,7 +744,7 @@ public class TopDownAnalyzer {
|
|||||||
constructorScope.setThisType(descriptor.getContainingDeclaration().getDefaultType());
|
constructorScope.setThisType(descriptor.getContainingDeclaration().getDefaultType());
|
||||||
|
|
||||||
for (ValueParameterDescriptor valueParameterDescriptor : descriptor.getValueParameters()) {
|
for (ValueParameterDescriptor valueParameterDescriptor : descriptor.getValueParameters()) {
|
||||||
JetParameter parameter = (JetParameter) trace.getBindingContext().getDeclarationPsiElement(valueParameterDescriptor);
|
JetParameter parameter = (JetParameter) trace.getBindingContext().get(BindingContext.DESCRIPTOR_TO_DECLARATION, valueParameterDescriptor);
|
||||||
if (parameter.getValOrVarNode() == null || !primary) {
|
if (parameter.getValOrVarNode() == null || !primary) {
|
||||||
constructorScope.addVariableDescriptor(valueParameterDescriptor);
|
constructorScope.addVariableDescriptor(valueParameterDescriptor);
|
||||||
}
|
}
|
||||||
@@ -837,27 +834,26 @@ public class TopDownAnalyzer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
JetExpression initializer = property.getInitializer();
|
JetExpression initializer = property.getInitializer();
|
||||||
if (!property.isVar() && initializer != null && !trace.getBindingContext().hasBackingField(propertyDescriptor)) {
|
if (!property.isVar() && initializer != null && !trace.getBindingContext().get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor)) {
|
||||||
trace.getErrorHandler().genericError(initializer.getNode(), "Initializer is not allowed here because this property has no setter and no backing field either");
|
trace.getErrorHandler().genericError(initializer.getNode(), "Initializer is not allowed here because this property has no setter and no backing field either");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private BindingTraceAdapter createFieldTrackingTrace(final PropertyDescriptor propertyDescriptor) {
|
private BindingTraceAdapter createFieldTrackingTrace(final PropertyDescriptor propertyDescriptor) {
|
||||||
return new BindingTraceAdapter(traceForMembers) {
|
return new BindingTraceAdapter(traceForMembers).addHandler(BindingContext.REFERENCE_TARGET, new BindingTraceAdapter.RecordHandler<JetReferenceExpression, DeclarationDescriptor>() {
|
||||||
@Override
|
@Override
|
||||||
public void recordReferenceResolution(@NotNull JetReferenceExpression expression, @NotNull DeclarationDescriptor descriptor) {
|
public void handleRecord(WritableSlice<JetReferenceExpression, DeclarationDescriptor> slice, JetReferenceExpression expression, DeclarationDescriptor descriptor) {
|
||||||
super.recordReferenceResolution(expression, descriptor);
|
|
||||||
if (expression instanceof JetSimpleNameExpression) {
|
if (expression instanceof JetSimpleNameExpression) {
|
||||||
JetSimpleNameExpression simpleNameExpression = (JetSimpleNameExpression) expression;
|
JetSimpleNameExpression simpleNameExpression = (JetSimpleNameExpression) expression;
|
||||||
if (simpleNameExpression.getReferencedNameElementType() == JetTokens.FIELD_IDENTIFIER) {
|
if (simpleNameExpression.getReferencedNameElementType() == JetTokens.FIELD_IDENTIFIER) {
|
||||||
// This check may be considered redundant as long as $x is only accessible from accessors to $x
|
// This check may be considered redundant as long as $x is only accessible from accessors to $x
|
||||||
if (descriptor == propertyDescriptor) { // TODO : original?
|
if (descriptor == propertyDescriptor) { // TODO : original?
|
||||||
requireBackingField(propertyDescriptor);
|
traceForMembers.record(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor); // TODO: this trace?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resolvePropertyInitializer(JetProperty property, PropertyDescriptor propertyDescriptor, JetExpression initializer, JetScope scope) {
|
private void resolvePropertyInitializer(JetProperty property, PropertyDescriptor propertyDescriptor, JetExpression initializer, JetScope scope) {
|
||||||
|
|||||||
@@ -31,14 +31,14 @@ public class TypeResolver {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public JetType resolveType(@NotNull final JetScope scope, @NotNull final JetTypeReference typeReference) {
|
public JetType resolveType(@NotNull final JetScope scope, @NotNull final JetTypeReference typeReference) {
|
||||||
JetType cachedType = trace.getBindingContext().resolveTypeReference(typeReference);
|
JetType cachedType = trace.getBindingContext().get(BindingContext.TYPE, typeReference);
|
||||||
if (cachedType != null) return cachedType;
|
if (cachedType != null) return cachedType;
|
||||||
|
|
||||||
final List<AnnotationDescriptor> annotations = annotationResolver.createAnnotationStubs(typeReference.getAnnotations());
|
final List<AnnotationDescriptor> annotations = annotationResolver.createAnnotationStubs(typeReference.getAnnotations());
|
||||||
|
|
||||||
JetTypeElement typeElement = typeReference.getTypeElement();
|
JetTypeElement typeElement = typeReference.getTypeElement();
|
||||||
JetType type = resolveTypeElement(scope, annotations, typeElement, false);
|
JetType type = resolveTypeElement(scope, annotations, typeElement, false);
|
||||||
trace.recordTypeResolution(typeReference, type);
|
trace.record(BindingContext.TYPE, typeReference, type);
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ public class TypeResolver {
|
|||||||
if (classifierDescriptor instanceof TypeParameterDescriptor) {
|
if (classifierDescriptor instanceof TypeParameterDescriptor) {
|
||||||
TypeParameterDescriptor typeParameterDescriptor = (TypeParameterDescriptor) classifierDescriptor;
|
TypeParameterDescriptor typeParameterDescriptor = (TypeParameterDescriptor) classifierDescriptor;
|
||||||
|
|
||||||
trace.recordReferenceResolution(referenceExpression, typeParameterDescriptor);
|
trace.record(BindingContext.REFERENCE_TARGET, referenceExpression, typeParameterDescriptor);
|
||||||
|
|
||||||
result[0] = new JetTypeImpl(
|
result[0] = new JetTypeImpl(
|
||||||
annotations,
|
annotations,
|
||||||
@@ -73,7 +73,7 @@ public class TypeResolver {
|
|||||||
else if (classifierDescriptor instanceof ClassDescriptor) {
|
else if (classifierDescriptor instanceof ClassDescriptor) {
|
||||||
ClassDescriptor classDescriptor = (ClassDescriptor) classifierDescriptor;
|
ClassDescriptor classDescriptor = (ClassDescriptor) classifierDescriptor;
|
||||||
|
|
||||||
trace.recordReferenceResolution(referenceExpression, classifierDescriptor);
|
trace.record(BindingContext.REFERENCE_TARGET, referenceExpression, classifierDescriptor);
|
||||||
TypeConstructor typeConstructor = classifierDescriptor.getTypeConstructor();
|
TypeConstructor typeConstructor = classifierDescriptor.getTypeConstructor();
|
||||||
List<TypeProjection> arguments = resolveTypeProjections(scope, typeConstructor, type.getTypeArguments());
|
List<TypeProjection> arguments = resolveTypeProjections(scope, typeConstructor, type.getTypeArguments());
|
||||||
List<TypeParameterDescriptor> parameters = typeConstructor.getParameters();
|
List<TypeParameterDescriptor> parameters = typeConstructor.getParameters();
|
||||||
@@ -289,7 +289,7 @@ public class TypeResolver {
|
|||||||
|
|
||||||
NamespaceDescriptor namespace = scope.getNamespace(userType.getReferencedName());
|
NamespaceDescriptor namespace = scope.getNamespace(userType.getReferencedName());
|
||||||
if (namespace != null) {
|
if (namespace != null) {
|
||||||
trace.recordReferenceResolution(userType.getReferenceExpression(), namespace);
|
trace.record(BindingContext.REFERENCE_TARGET, userType.getReferenceExpression(), namespace);
|
||||||
}
|
}
|
||||||
return namespace;
|
return namespace;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.lang.descriptors.*;
|
import org.jetbrains.jet.lang.descriptors.*;
|
||||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||||
|
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||||
import org.jetbrains.jet.lang.types.*;
|
import org.jetbrains.jet.lang.types.*;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -122,7 +123,7 @@ public class JavaDescriptorResolver {
|
|||||||
constructorDescriptor.initialize(typeParameters, Collections.<ValueParameterDescriptor>emptyList());
|
constructorDescriptor.initialize(typeParameters, Collections.<ValueParameterDescriptor>emptyList());
|
||||||
constructorDescriptor.setReturnType(classDescriptor.getDefaultType());
|
constructorDescriptor.setReturnType(classDescriptor.getDefaultType());
|
||||||
classDescriptor.addConstructor(constructorDescriptor);
|
classDescriptor.addConstructor(constructorDescriptor);
|
||||||
semanticServices.getTrace().recordDeclarationResolution(psiClass, constructorDescriptor);
|
semanticServices.getTrace().record(BindingContext.CONSTRUCTOR, psiClass, constructorDescriptor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -134,11 +135,11 @@ public class JavaDescriptorResolver {
|
|||||||
constructorDescriptor.initialize(typeParameters, resolveParameterDescriptors(constructorDescriptor, constructor.getParameterList().getParameters()));
|
constructorDescriptor.initialize(typeParameters, resolveParameterDescriptors(constructorDescriptor, constructor.getParameterList().getParameters()));
|
||||||
constructorDescriptor.setReturnType(classDescriptor.getDefaultType());
|
constructorDescriptor.setReturnType(classDescriptor.getDefaultType());
|
||||||
classDescriptor.addConstructor(constructorDescriptor);
|
classDescriptor.addConstructor(constructorDescriptor);
|
||||||
semanticServices.getTrace().recordDeclarationResolution(constructor, constructorDescriptor);
|
semanticServices.getTrace().record(BindingContext.CONSTRUCTOR, constructor, constructorDescriptor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
semanticServices.getTrace().recordDeclarationResolution(psiClass, classDescriptor);
|
semanticServices.getTrace().record(BindingContext.CLASS, psiClass, classDescriptor);
|
||||||
|
|
||||||
return classDescriptor;
|
return classDescriptor;
|
||||||
}
|
}
|
||||||
@@ -230,7 +231,7 @@ public class JavaDescriptorResolver {
|
|||||||
psiPackage.getName()
|
psiPackage.getName()
|
||||||
);
|
);
|
||||||
namespaceDescriptor.setMemberScope(new JavaPackageScope(psiPackage.getQualifiedName(), namespaceDescriptor, semanticServices));
|
namespaceDescriptor.setMemberScope(new JavaPackageScope(psiPackage.getQualifiedName(), namespaceDescriptor, semanticServices));
|
||||||
semanticServices.getTrace().recordDeclarationResolution(psiPackage, namespaceDescriptor);
|
semanticServices.getTrace().record(BindingContext.NAMESPACE, psiPackage, namespaceDescriptor);
|
||||||
return namespaceDescriptor;
|
return namespaceDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,7 +242,7 @@ public class JavaDescriptorResolver {
|
|||||||
psiClass.getName()
|
psiClass.getName()
|
||||||
);
|
);
|
||||||
namespaceDescriptor.setMemberScope(new JavaClassMembersScope(namespaceDescriptor, psiClass, semanticServices, true));
|
namespaceDescriptor.setMemberScope(new JavaClassMembersScope(namespaceDescriptor, psiClass, semanticServices, true));
|
||||||
semanticServices.getTrace().recordDeclarationResolution(psiClass, namespaceDescriptor);
|
semanticServices.getTrace().record(BindingContext.NAMESPACE, psiClass, namespaceDescriptor);
|
||||||
return namespaceDescriptor;
|
return namespaceDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -280,7 +281,7 @@ public class JavaDescriptorResolver {
|
|||||||
field.getName(),
|
field.getName(),
|
||||||
isFinal ? null : type,
|
isFinal ? null : type,
|
||||||
type);
|
type);
|
||||||
semanticServices.getTrace().recordDeclarationResolution(field, propertyDescriptor);
|
semanticServices.getTrace().record(BindingContext.VARIABLE, field, propertyDescriptor);
|
||||||
fieldDescriptorCache.put(field, propertyDescriptor);
|
fieldDescriptorCache.put(field, propertyDescriptor);
|
||||||
return propertyDescriptor;
|
return propertyDescriptor;
|
||||||
}
|
}
|
||||||
@@ -344,7 +345,7 @@ public class JavaDescriptorResolver {
|
|||||||
semanticServices.getDescriptorResolver().resolveParameterDescriptors(functionDescriptorImpl, parameters),
|
semanticServices.getDescriptorResolver().resolveParameterDescriptors(functionDescriptorImpl, parameters),
|
||||||
semanticServices.getTypeTransformer().transformToType(returnType)
|
semanticServices.getTypeTransformer().transformToType(returnType)
|
||||||
);
|
);
|
||||||
semanticServices.getTrace().recordDeclarationResolution(method, functionDescriptorImpl);
|
semanticServices.getTrace().record(BindingContext.FUNCTION, method, functionDescriptorImpl);
|
||||||
FunctionDescriptor substitutedFunctionDescriptor = functionDescriptorImpl;
|
FunctionDescriptor substitutedFunctionDescriptor = functionDescriptorImpl;
|
||||||
if (method.getContainingClass() != psiClass) {
|
if (method.getContainingClass() != psiClass) {
|
||||||
substitutedFunctionDescriptor = functionDescriptorImpl.substitute(typeSubstitutorForGenericSuperclasses);
|
substitutedFunctionDescriptor = functionDescriptorImpl.substitute(typeSubstitutorForGenericSuperclasses);
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ public class ErrorUtils {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final JetType ERROR_PARAMETER_TYPE = createErrorType("<ERROR PARAMETER TYPE>");
|
private static final JetType ERROR_PARAMETER_TYPE = createErrorType("<ERROR VALUE_PARAMETER TYPE>");
|
||||||
private static List<ValueParameterDescriptor> getValueParameters(FunctionDescriptor functionDescriptor, List<JetType> argumentTypes) {
|
private static List<ValueParameterDescriptor> getValueParameters(FunctionDescriptor functionDescriptor, List<JetType> argumentTypes) {
|
||||||
List<ValueParameterDescriptor> result = new ArrayList<ValueParameterDescriptor>();
|
List<ValueParameterDescriptor> result = new ArrayList<ValueParameterDescriptor>();
|
||||||
for (int i = 0, argumentTypesSize = argumentTypes.size(); i < argumentTypesSize; i++) {
|
for (int i = 0, argumentTypesSize = argumentTypes.size(); i < argumentTypesSize; i++) {
|
||||||
@@ -152,7 +152,7 @@ public class ErrorUtils {
|
|||||||
functionDescriptor,
|
functionDescriptor,
|
||||||
i,
|
i,
|
||||||
Collections.<AnnotationDescriptor>emptyList(),
|
Collections.<AnnotationDescriptor>emptyList(),
|
||||||
"<ERROR PARAMETER>",
|
"<ERROR VALUE_PARAMETER>",
|
||||||
ERROR_PARAMETER_TYPE,
|
ERROR_PARAMETER_TYPE,
|
||||||
ERROR_PARAMETER_TYPE,
|
ERROR_PARAMETER_TYPE,
|
||||||
false,
|
false,
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ public class JetStandardLibrary {
|
|||||||
// private static final Map<Project, JetStandardLibrary> standardLibraryCache = new HashMap<Project, JetStandardLibrary>();
|
// private static final Map<Project, JetStandardLibrary> standardLibraryCache = new HashMap<Project, JetStandardLibrary>();
|
||||||
|
|
||||||
// TODO : double checked locking
|
// TODO : double checked locking
|
||||||
synchronized public static JetStandardLibrary getJetStandardLibrary(@NotNull Project project) {
|
synchronized
|
||||||
|
public static JetStandardLibrary getJetStandardLibrary(@NotNull Project project) {
|
||||||
if (cachedLibrary == null) {
|
if (cachedLibrary == null) {
|
||||||
cachedLibrary = new JetStandardLibrary(project);
|
cachedLibrary = new JetStandardLibrary(project);
|
||||||
}
|
}
|
||||||
@@ -55,8 +56,8 @@ public class JetStandardLibrary {
|
|||||||
private final ClassDescriptor arrayClass;
|
private final ClassDescriptor arrayClass;
|
||||||
private final ClassDescriptor iterableClass;
|
private final ClassDescriptor iterableClass;
|
||||||
private final ClassDescriptor typeInfoClass;
|
private final ClassDescriptor typeInfoClass;
|
||||||
private final JetType byteType;
|
|
||||||
|
|
||||||
|
private final JetType byteType;
|
||||||
private final JetType charType;
|
private final JetType charType;
|
||||||
private final JetType shortType;
|
private final JetType shortType;
|
||||||
private final JetType intType;
|
private final JetType intType;
|
||||||
@@ -86,7 +87,7 @@ public class JetStandardLibrary {
|
|||||||
// bootstrappingTDA.process(writableScope, JetStandardClasses.STANDARD_CLASSES_NAMESPACE, file.getRootNamespace().getDeclarations());
|
// bootstrappingTDA.process(writableScope, JetStandardClasses.STANDARD_CLASSES_NAMESPACE, file.getRootNamespace().getDeclarations());
|
||||||
bootstrappingTDA.processStandardLibraryNamespace(writableScope, JetStandardClasses.STANDARD_CLASSES_NAMESPACE, file.getRootNamespace());
|
bootstrappingTDA.processStandardLibraryNamespace(writableScope, JetStandardClasses.STANDARD_CLASSES_NAMESPACE, file.getRootNamespace());
|
||||||
this.libraryScope = JetStandardClasses.STANDARD_CLASSES_NAMESPACE.getMemberScope();
|
this.libraryScope = JetStandardClasses.STANDARD_CLASSES_NAMESPACE.getMemberScope();
|
||||||
AnalyzingUtils.applyHandler(ErrorHandler.THROW_EXCEPTION, bindingTraceContext);
|
AnalyzingUtils.applyHandler(ErrorHandler.THROW_EXCEPTION, bindingTraceContext.getBindingContext());
|
||||||
|
|
||||||
this.byteClass = (ClassDescriptor) libraryScope.getClassifier("Byte");
|
this.byteClass = (ClassDescriptor) libraryScope.getClassifier("Byte");
|
||||||
this.charClass = (ClassDescriptor) libraryScope.getClassifier("Char");
|
this.charClass = (ClassDescriptor) libraryScope.getClassifier("Char");
|
||||||
|
|||||||
@@ -313,28 +313,10 @@ public class JetTypeChecker {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSubtypeOf(@NotNull JetType subtype, @NotNull JetType supertype) {
|
|
||||||
if (ErrorUtils.isErrorType(subtype) || ErrorUtils.isErrorType(supertype)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!supertype.isNullable() && subtype.isNullable()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (JetStandardClasses.isNothing(subtype)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
@Nullable JetType closestSupertype = findCorrespondingSupertype(subtype, supertype);
|
|
||||||
if (closestSupertype == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return checkSubtypeForTheSameConstructor(closestSupertype, supertype);
|
|
||||||
}
|
|
||||||
|
|
||||||
// This method returns the supertype of the first parameter that has the same constructor
|
// This method returns the supertype of the first parameter that has the same constructor
|
||||||
// as the second parameter, applying the substitution of type arguments to it
|
// as the second parameter, applying the substitution of type arguments to it
|
||||||
@Nullable
|
@Nullable
|
||||||
private JetType findCorrespondingSupertype(@NotNull JetType subtype, @NotNull JetType supertype) {
|
private static JetType findCorrespondingSupertype(@NotNull JetType subtype, @NotNull JetType supertype) {
|
||||||
TypeConstructor constructor = subtype.getConstructor();
|
TypeConstructor constructor = subtype.getConstructor();
|
||||||
if (constructor.equals(supertype.getConstructor())) {
|
if (constructor.equals(supertype.getConstructor())) {
|
||||||
return subtype;
|
return subtype;
|
||||||
@@ -348,75 +330,270 @@ public class JetTypeChecker {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkSubtypeForTheSameConstructor(@NotNull JetType subtype, @NotNull JetType supertype) {
|
public boolean isSubtypeOf(@NotNull JetType subtype, @NotNull JetType supertype) {
|
||||||
TypeConstructor constructor = subtype.getConstructor();
|
return new TypeCheckingProcedure().run(subtype, supertype);
|
||||||
assert constructor.equals(supertype.getConstructor()) : constructor + " is not " + supertype.getConstructor();
|
|
||||||
|
|
||||||
List<TypeProjection> subArguments = subtype.getArguments();
|
|
||||||
List<TypeProjection> superArguments = supertype.getArguments();
|
|
||||||
List<TypeParameterDescriptor> parameters = constructor.getParameters();
|
|
||||||
for (int i = 0, parametersSize = parameters.size(); i < parametersSize; i++) {
|
|
||||||
TypeParameterDescriptor parameter = parameters.get(i);
|
|
||||||
TypeProjection subArgument = subArguments.get(i);
|
|
||||||
TypeProjection superArgument = superArguments.get(i);
|
|
||||||
|
|
||||||
JetType subArgumentType = subArgument.getType();
|
|
||||||
JetType superArgumentType = superArgument.getType();
|
|
||||||
switch (parameter.getVariance()) {
|
|
||||||
case INVARIANT:
|
|
||||||
switch (superArgument.getProjectionKind()) {
|
|
||||||
case INVARIANT:
|
|
||||||
if (!subArgumentType.equals(superArgumentType)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case OUT_VARIANCE:
|
|
||||||
if (!subArgument.getProjectionKind().allowsOutPosition()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!isSubtypeOf(subArgumentType, superArgumentType)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case IN_VARIANCE:
|
|
||||||
if (!subArgument.getProjectionKind().allowsInPosition()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!isSubtypeOf(superArgumentType, subArgumentType)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case IN_VARIANCE:
|
|
||||||
switch (superArgument.getProjectionKind()) {
|
|
||||||
case INVARIANT:
|
|
||||||
case IN_VARIANCE:
|
|
||||||
if (!isSubtypeOf(superArgumentType, subArgumentType)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case OUT_VARIANCE:
|
|
||||||
if (!isSubtypeOf(subArgumentType, superArgumentType)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case OUT_VARIANCE:
|
|
||||||
switch (superArgument.getProjectionKind()) {
|
|
||||||
case INVARIANT:
|
|
||||||
case OUT_VARIANCE:
|
|
||||||
case IN_VARIANCE:
|
|
||||||
if (!isSubtypeOf(subArgumentType, superArgumentType)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class OldProcedure {
|
||||||
|
public static boolean isSubtypeOf(@NotNull JetType subtype, @NotNull JetType supertype) {
|
||||||
|
if (ErrorUtils.isErrorType(subtype) || ErrorUtils.isErrorType(supertype)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!supertype.isNullable() && subtype.isNullable()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (JetStandardClasses.isNothing(subtype)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@Nullable JetType closestSupertype = findCorrespondingSupertype(subtype, supertype);
|
||||||
|
if (closestSupertype == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return checkSubtypeForTheSameConstructor(closestSupertype, supertype);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean checkSubtypeForTheSameConstructor(@NotNull JetType subtype, @NotNull JetType supertype) {
|
||||||
|
TypeConstructor constructor = subtype.getConstructor();
|
||||||
|
assert constructor.equals(supertype.getConstructor()) : constructor + " is not " + supertype.getConstructor();
|
||||||
|
|
||||||
|
List<TypeProjection> subArguments = subtype.getArguments();
|
||||||
|
List<TypeProjection> superArguments = supertype.getArguments();
|
||||||
|
List<TypeParameterDescriptor> parameters = constructor.getParameters();
|
||||||
|
boolean status = true;
|
||||||
|
for (int i = 0, parametersSize = parameters.size(); i < parametersSize; i++) {
|
||||||
|
TypeParameterDescriptor parameter = parameters.get(i);
|
||||||
|
TypeProjection subArgument = subArguments.get(i);
|
||||||
|
TypeProjection superArgument = superArguments.get(i);
|
||||||
|
|
||||||
|
JetType subArgumentType = subArgument.getType();
|
||||||
|
JetType superArgumentType = superArgument.getType();
|
||||||
|
switch (parameter.getVariance()) {
|
||||||
|
case INVARIANT:
|
||||||
|
switch (superArgument.getProjectionKind()) {
|
||||||
|
case INVARIANT:
|
||||||
|
status = subArgumentType.equals(superArgumentType);
|
||||||
|
break;
|
||||||
|
case OUT_VARIANCE:
|
||||||
|
if (!subArgument.getProjectionKind().allowsOutPosition()) {
|
||||||
|
status = false;
|
||||||
|
} else {
|
||||||
|
status = !isSubtypeOf(subArgumentType, superArgumentType);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case IN_VARIANCE:
|
||||||
|
if (!subArgument.getProjectionKind().allowsInPosition()) {
|
||||||
|
status = false;
|
||||||
|
} else {
|
||||||
|
status = isSubtypeOf(superArgumentType, subArgumentType);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case IN_VARIANCE:
|
||||||
|
switch (superArgument.getProjectionKind()) {
|
||||||
|
case INVARIANT:
|
||||||
|
case IN_VARIANCE:
|
||||||
|
status = isSubtypeOf(superArgumentType, subArgumentType);
|
||||||
|
break;
|
||||||
|
case OUT_VARIANCE:
|
||||||
|
status = isSubtypeOf(subArgumentType, superArgumentType);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case OUT_VARIANCE:
|
||||||
|
switch (superArgument.getProjectionKind()) {
|
||||||
|
case INVARIANT:
|
||||||
|
case OUT_VARIANCE:
|
||||||
|
case IN_VARIANCE:
|
||||||
|
status = isSubtypeOf(subArgumentType, superArgumentType);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!status) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static abstract class AbstractTypeCheckingProcedure<T> {
|
||||||
|
|
||||||
|
protected enum StatusAction {
|
||||||
|
PROCEED(false),
|
||||||
|
DONE_WITH_CURRENT_TYPE(true),
|
||||||
|
ABORT_ALL(true);
|
||||||
|
|
||||||
|
private final boolean abort;
|
||||||
|
|
||||||
|
private StatusAction(boolean abort) {
|
||||||
|
this.abort = abort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAbort() {
|
||||||
|
return abort;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public final T run(@NotNull JetType subtype, @NotNull JetType supertype) {
|
||||||
|
proceedOrStop(subtype, supertype);
|
||||||
|
return result();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract StatusAction startForPairOfTypes(@NotNull JetType subtype, @NotNull JetType supertype);
|
||||||
|
|
||||||
|
protected abstract StatusAction noCorrespondingSupertype(@NotNull JetType subtype, @NotNull JetType supertype);
|
||||||
|
|
||||||
|
protected abstract StatusAction equalTypesRequired(@NotNull JetType subArgumentType, @NotNull JetType superArgumentType);
|
||||||
|
|
||||||
|
protected abstract StatusAction varianceConflictFound(@NotNull TypeProjection subArgument, @NotNull TypeProjection superArgument);
|
||||||
|
|
||||||
|
protected abstract StatusAction doneForPairOfTypes(@NotNull JetType subtype, @NotNull JetType supertype);
|
||||||
|
|
||||||
|
protected abstract T result();
|
||||||
|
|
||||||
|
private StatusAction proceedOrStop(@NotNull JetType subtype, @NotNull JetType supertype) {
|
||||||
|
StatusAction statusAction = startForPairOfTypes(subtype, supertype);
|
||||||
|
if (statusAction.isAbort()) {
|
||||||
|
return statusAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
JetType closestSupertype = findCorrespondingSupertype(subtype, supertype);
|
||||||
|
if (closestSupertype == null) {
|
||||||
|
return noCorrespondingSupertype(subtype, supertype);
|
||||||
|
}
|
||||||
|
|
||||||
|
proceed(closestSupertype, supertype);
|
||||||
|
return doneForPairOfTypes(subtype, supertype);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void proceed(@NotNull JetType subtype, @NotNull JetType supertype) {
|
||||||
|
TypeConstructor constructor = subtype.getConstructor();
|
||||||
|
assert constructor.equals(supertype.getConstructor()) : constructor + " is not " + supertype.getConstructor();
|
||||||
|
|
||||||
|
List<TypeProjection> subArguments = subtype.getArguments();
|
||||||
|
List<TypeProjection> superArguments = supertype.getArguments();
|
||||||
|
List<TypeParameterDescriptor> parameters = constructor.getParameters();
|
||||||
|
|
||||||
|
loop:
|
||||||
|
for (int i = 0; i < parameters.size(); i++) {
|
||||||
|
TypeParameterDescriptor parameter = parameters.get(i);
|
||||||
|
TypeProjection subArgument = subArguments.get(i);
|
||||||
|
TypeProjection superArgument = superArguments.get(i);
|
||||||
|
|
||||||
|
JetType subArgumentType = subArgument.getType();
|
||||||
|
JetType superArgumentType = superArgument.getType();
|
||||||
|
|
||||||
|
StatusAction action = null;
|
||||||
|
switch (parameter.getVariance()) {
|
||||||
|
case INVARIANT:
|
||||||
|
switch (superArgument.getProjectionKind()) {
|
||||||
|
case INVARIANT:
|
||||||
|
action = equalTypesRequired(subArgumentType, superArgumentType);
|
||||||
|
break;
|
||||||
|
case OUT_VARIANCE:
|
||||||
|
if (!subArgument.getProjectionKind().allowsOutPosition()) {
|
||||||
|
action = varianceConflictFound(subArgument, superArgument);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
action = proceedOrStop(subArgumentType, superArgumentType);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case IN_VARIANCE:
|
||||||
|
if (!subArgument.getProjectionKind().allowsInPosition()) {
|
||||||
|
action = varianceConflictFound(subArgument, superArgument);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
action = proceedOrStop(superArgumentType, subArgumentType);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case IN_VARIANCE:
|
||||||
|
switch (superArgument.getProjectionKind()) {
|
||||||
|
case INVARIANT:
|
||||||
|
case IN_VARIANCE:
|
||||||
|
action = proceedOrStop(superArgumentType, subArgumentType);
|
||||||
|
break;
|
||||||
|
case OUT_VARIANCE:
|
||||||
|
action = proceedOrStop(subArgumentType, superArgumentType);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case OUT_VARIANCE:
|
||||||
|
switch (superArgument.getProjectionKind()) {
|
||||||
|
case INVARIANT:
|
||||||
|
case OUT_VARIANCE:
|
||||||
|
case IN_VARIANCE:
|
||||||
|
action = proceedOrStop(subArgumentType, superArgumentType);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
switch (action) {
|
||||||
|
case ABORT_ALL: break loop;
|
||||||
|
case DONE_WITH_CURRENT_TYPE:
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static class TypeCheckingProcedure extends AbstractTypeCheckingProcedure<Boolean> {
|
||||||
|
|
||||||
|
private boolean result = true;
|
||||||
|
|
||||||
|
private StatusAction fail() {
|
||||||
|
result = false;
|
||||||
|
return StatusAction.ABORT_ALL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StatusAction startForPairOfTypes(@NotNull JetType subtype, @NotNull JetType supertype) {
|
||||||
|
if (ErrorUtils.isErrorType(subtype) || ErrorUtils.isErrorType(supertype)) {
|
||||||
|
return StatusAction.DONE_WITH_CURRENT_TYPE;
|
||||||
|
}
|
||||||
|
if (!supertype.isNullable() && subtype.isNullable()) {
|
||||||
|
return fail();
|
||||||
|
}
|
||||||
|
if (JetStandardClasses.isNothing(subtype)) {
|
||||||
|
return StatusAction.DONE_WITH_CURRENT_TYPE;
|
||||||
|
}
|
||||||
|
return StatusAction.PROCEED;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected StatusAction noCorrespondingSupertype(@NotNull JetType subtype, @NotNull JetType supertype) {
|
||||||
|
return fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected StatusAction equalTypesRequired(@NotNull JetType subArgumentType, @NotNull JetType superArgumentType) {
|
||||||
|
if (!subArgumentType.equals(superArgumentType)) {
|
||||||
|
return fail();
|
||||||
|
}
|
||||||
|
return StatusAction.PROCEED;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected StatusAction varianceConflictFound(@NotNull TypeProjection subArgument, @NotNull TypeProjection superArgument) {
|
||||||
|
return fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected StatusAction doneForPairOfTypes(@NotNull JetType subtype, @NotNull JetType supertype) {
|
||||||
|
return StatusAction.PROCEED;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Boolean result() {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import com.intellij.psi.tree.IElementType;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.JetNodeTypes;
|
import org.jetbrains.jet.JetNodeTypes;
|
||||||
import org.jetbrains.jet.lang.ErrorHandlerWithRegions;
|
|
||||||
import org.jetbrains.jet.lang.JetSemanticServices;
|
import org.jetbrains.jet.lang.JetSemanticServices;
|
||||||
import org.jetbrains.jet.lang.cfg.JetFlowInformationProvider;
|
import org.jetbrains.jet.lang.cfg.JetFlowInformationProvider;
|
||||||
import org.jetbrains.jet.lang.descriptors.*;
|
import org.jetbrains.jet.lang.descriptors.*;
|
||||||
@@ -20,12 +19,16 @@ import org.jetbrains.jet.lang.resolve.*;
|
|||||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
||||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstantResolver;
|
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstantResolver;
|
||||||
import org.jetbrains.jet.lang.resolve.constants.ErrorValue;
|
import org.jetbrains.jet.lang.resolve.constants.ErrorValue;
|
||||||
|
import org.jetbrains.jet.lang.resolve.constants.StringValue;
|
||||||
|
import org.jetbrains.jet.lang.types.inference.ConstraintSystem;
|
||||||
import org.jetbrains.jet.lexer.JetTokens;
|
import org.jetbrains.jet.lexer.JetTokens;
|
||||||
import org.jetbrains.jet.resolve.DescriptorRenderer;
|
import org.jetbrains.jet.resolve.DescriptorRenderer;
|
||||||
import org.jetbrains.jet.lang.resolve.constants.StringValue;
|
import org.jetbrains.jet.util.WritableSlice;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import static org.jetbrains.jet.lang.resolve.BindingContext.STATEMENT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author abreslav
|
* @author abreslav
|
||||||
*/
|
*/
|
||||||
@@ -176,11 +179,11 @@ public class JetTypeInferrer {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public JetType getType(@NotNull final JetScope scope, @NotNull JetExpression expression, boolean preferBlock, @NotNull JetType expectedType) {
|
public JetType getType(@NotNull final JetScope scope, @NotNull JetExpression expression, boolean preferBlock, @NotNull JetType expectedType) {
|
||||||
return typeInferrerVisitor.getType(expression, new TypeInferenceContext(trace, scope, this, preferBlock, DataFlowInfo.getEmpty(), expectedType, FORBIDDEN));
|
return typeInferrerVisitor.getType(expression, new TypeInferenceContext(trace, scope, preferBlock, DataFlowInfo.getEmpty(), expectedType, FORBIDDEN));
|
||||||
}
|
}
|
||||||
|
|
||||||
public JetType getTypeWithNamespaces(@NotNull final JetScope scope, @NotNull JetExpression expression, boolean preferBlock) {
|
public JetType getTypeWithNamespaces(@NotNull final JetScope scope, @NotNull JetExpression expression, boolean preferBlock) {
|
||||||
return typeInferrerVisitorWithNamespaces.getType(expression, new TypeInferenceContext(trace, scope, this, preferBlock, DataFlowInfo.getEmpty(), NO_EXPECTED_TYPE, NO_EXPECTED_TYPE));
|
return typeInferrerVisitorWithNamespaces.getType(expression, new TypeInferenceContext(trace, scope, preferBlock, DataFlowInfo.getEmpty(), NO_EXPECTED_TYPE, NO_EXPECTED_TYPE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -321,7 +324,7 @@ public class JetTypeInferrer {
|
|||||||
|
|
||||||
private void report(OverloadResolutionResult resolutionResult) {
|
private void report(OverloadResolutionResult resolutionResult) {
|
||||||
if (resolutionResult.isSuccess() || resolutionResult.singleFunction()) {
|
if (resolutionResult.isSuccess() || resolutionResult.singleFunction()) {
|
||||||
trace.recordReferenceResolution(referenceExpression, resolutionResult.getFunctionDescriptor());
|
trace.record(BindingContext.REFERENCE_TARGET, referenceExpression, resolutionResult.getFunctionDescriptor());
|
||||||
}
|
}
|
||||||
if (reportErrors) {
|
if (reportErrors) {
|
||||||
switch (resolutionResult.getResultCode()) {
|
switch (resolutionResult.getResultCode()) {
|
||||||
@@ -375,7 +378,7 @@ public class JetTypeInferrer {
|
|||||||
// return; // The function returns Nothing
|
// return; // The function returns Nothing
|
||||||
// }
|
// }
|
||||||
// for (Map.Entry<JetElement, JetType> entry : typeMap.entrySet()) {
|
// for (Map.Entry<JetElement, JetType> entry : typeMap.entrySet()) {
|
||||||
// JetType actualType = entry.getValue();
|
// JetType actualType = entry.castValue();
|
||||||
// JetElement element = entry.getKey();
|
// JetElement element = entry.getKey();
|
||||||
// JetTypeChecker typeChecker = semanticServices.getTypeChecker();
|
// JetTypeChecker typeChecker = semanticServices.getTypeChecker();
|
||||||
// if (!typeChecker.isSubtypeOf(actualType, expectedReturnType)) {
|
// if (!typeChecker.isSubtypeOf(actualType, expectedReturnType)) {
|
||||||
@@ -414,8 +417,8 @@ public class JetTypeInferrer {
|
|||||||
final boolean blockBody = function.hasBlockBody();
|
final boolean blockBody = function.hasBlockBody();
|
||||||
final TypeInferenceContext context =
|
final TypeInferenceContext context =
|
||||||
blockBody
|
blockBody
|
||||||
? new TypeInferenceContext(trace, functionInnerScope, this, function.hasBlockBody(), dataFlowInfo, NO_EXPECTED_TYPE, expectedReturnType)
|
? new TypeInferenceContext(trace, functionInnerScope, function.hasBlockBody(), dataFlowInfo, NO_EXPECTED_TYPE, expectedReturnType)
|
||||||
: new TypeInferenceContext(trace, functionInnerScope, this, function.hasBlockBody(), dataFlowInfo, expectedReturnType, FORBIDDEN);
|
: new TypeInferenceContext(trace, functionInnerScope, function.hasBlockBody(), dataFlowInfo, expectedReturnType, FORBIDDEN);
|
||||||
|
|
||||||
typeInferrerVisitor.getType(bodyExpression, context);
|
typeInferrerVisitor.getType(bodyExpression, context);
|
||||||
|
|
||||||
@@ -484,14 +487,14 @@ public class JetTypeInferrer {
|
|||||||
JetExpression bodyExpression = function.getBodyExpression();
|
JetExpression bodyExpression = function.getBodyExpression();
|
||||||
assert bodyExpression != null;
|
assert bodyExpression != null;
|
||||||
JetScope functionInnerScope = FunctionDescriptorUtil.getFunctionInnerScope(outerScope, functionDescriptor, trace);
|
JetScope functionInnerScope = FunctionDescriptorUtil.getFunctionInnerScope(outerScope, functionDescriptor, trace);
|
||||||
typeInferrerVisitor.getType(bodyExpression, new TypeInferenceContext(trace, functionInnerScope, this, function.hasBlockBody(), DataFlowInfo.getEmpty(), NO_EXPECTED_TYPE, FORBIDDEN));
|
typeInferrerVisitor.getType(bodyExpression, new TypeInferenceContext(trace, functionInnerScope, function.hasBlockBody(), DataFlowInfo.getEmpty(), NO_EXPECTED_TYPE, FORBIDDEN));
|
||||||
Collection<JetExpression> returnedExpressions = new ArrayList<JetExpression>();
|
Collection<JetExpression> returnedExpressions = new ArrayList<JetExpression>();
|
||||||
Collection<JetElement> elementsReturningUnit = new ArrayList<JetElement>();
|
Collection<JetElement> elementsReturningUnit = new ArrayList<JetElement>();
|
||||||
flowInformationProvider.collectReturnedInformation(function.asElement(), returnedExpressions, elementsReturningUnit);
|
flowInformationProvider.collectReturnedInformation(function.asElement(), returnedExpressions, elementsReturningUnit);
|
||||||
Map<JetElement,JetType> typeMap = new HashMap<JetElement, JetType>();
|
Map<JetElement,JetType> typeMap = new HashMap<JetElement, JetType>();
|
||||||
for (JetExpression returnedExpression : returnedExpressions) {
|
for (JetExpression returnedExpression : returnedExpressions) {
|
||||||
JetType cachedType = trace.getBindingContext().getExpressionType(returnedExpression);
|
JetType cachedType = trace.getBindingContext().get(BindingContext.EXPRESSION_TYPE, returnedExpression);
|
||||||
trace.removeStatementRecord(returnedExpression);
|
trace.record(STATEMENT, returnedExpression, false);
|
||||||
if (cachedType != null) {
|
if (cachedType != null) {
|
||||||
typeMap.put(returnedExpression, cachedType);
|
typeMap.put(returnedExpression, cachedType);
|
||||||
}
|
}
|
||||||
@@ -508,16 +511,16 @@ public class JetTypeInferrer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TypeInferrerVisitorWithWritableScope blockLevelVisitor = newTypeInferrerVisitorWithWritableScope(scope);
|
TypeInferrerVisitorWithWritableScope blockLevelVisitor = newTypeInferrerVisitorWithWritableScope(scope);
|
||||||
TypeInferenceContext newContext = new TypeInferenceContext(trace, scope, this, true, context.dataFlowInfo, NO_EXPECTED_TYPE, context.expectedReturnType);
|
TypeInferenceContext newContext = new TypeInferenceContext(trace, scope, true, context.dataFlowInfo, NO_EXPECTED_TYPE, context.expectedReturnType);
|
||||||
|
|
||||||
JetType result = null;
|
JetType result = null;
|
||||||
for (Iterator<? extends JetElement> iterator = block.iterator(); iterator.hasNext(); ) {
|
for (Iterator<? extends JetElement> iterator = block.iterator(); iterator.hasNext(); ) {
|
||||||
JetElement statement = iterator.next();
|
JetElement statement = iterator.next();
|
||||||
trace.recordStatement(statement);
|
trace.record(STATEMENT, statement);
|
||||||
JetExpression statementExpression = (JetExpression) statement;
|
JetExpression statementExpression = (JetExpression) statement;
|
||||||
//TODO constructor assert context.expectedType != FORBIDDEN : ""
|
//TODO constructor assert context.expectedType != FORBIDDEN : ""
|
||||||
if (!iterator.hasNext() && context.expectedType != NO_EXPECTED_TYPE) {
|
if (!iterator.hasNext() && context.expectedType != NO_EXPECTED_TYPE) {
|
||||||
newContext = new TypeInferenceContext(trace, scope, this, true, newContext.dataFlowInfo, context.expectedType, context.expectedReturnType);
|
newContext = new TypeInferenceContext(trace, scope, true, newContext.dataFlowInfo, context.expectedType, context.expectedReturnType);
|
||||||
}
|
}
|
||||||
|
|
||||||
result = blockLevelVisitor.getType(statementExpression, newContext);
|
result = blockLevelVisitor.getType(statementExpression, newContext);
|
||||||
@@ -526,13 +529,78 @@ public class JetTypeInferrer {
|
|||||||
newDataFlowInfo = context.dataFlowInfo;
|
newDataFlowInfo = context.dataFlowInfo;
|
||||||
}
|
}
|
||||||
if (newDataFlowInfo != context.dataFlowInfo) {
|
if (newDataFlowInfo != context.dataFlowInfo) {
|
||||||
newContext = new TypeInferenceContext(trace, scope, this, true, newDataFlowInfo, NO_EXPECTED_TYPE, context.expectedReturnType);
|
newContext = new TypeInferenceContext(trace, scope, true, newDataFlowInfo, NO_EXPECTED_TYPE, context.expectedReturnType);
|
||||||
}
|
}
|
||||||
blockLevelVisitor.resetResult(); // TODO : maybe it's better to recreate the visitors with the same scope?
|
blockLevelVisitor.resetResult(); // TODO : maybe it's better to recreate the visitors with the same scope?
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private JetType resolveCall(
|
||||||
|
@NotNull JetScope scope,
|
||||||
|
@NotNull JetCall call,
|
||||||
|
@NotNull JetType expectedType
|
||||||
|
) {
|
||||||
|
if (call.getTypeArguments().isEmpty()) {
|
||||||
|
JetExpression calleeExpression = call.getCalleeExpression();
|
||||||
|
Collection<FunctionDescriptor> candidates;
|
||||||
|
if (calleeExpression instanceof JetSimpleNameExpression) {
|
||||||
|
JetSimpleNameExpression expression = (JetSimpleNameExpression) calleeExpression;
|
||||||
|
candidates = scope.getFunctionGroup(expression.getReferencedName()).getFunctionDescriptors();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new UnsupportedOperationException("Type argument inference not implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
assert candidates.size() == 1;
|
||||||
|
|
||||||
|
FunctionDescriptor candidate = candidates.iterator().next();
|
||||||
|
|
||||||
|
assert candidate.getTypeParameters().size() == call.getTypeArguments().size();
|
||||||
|
|
||||||
|
ConstraintSystem constraintSystem = new ConstraintSystem();
|
||||||
|
for (TypeParameterDescriptor typeParameterDescriptor : candidate.getTypeParameters()) {
|
||||||
|
constraintSystem.registerTypeVariable(typeParameterDescriptor, Variance.INVARIANT); // TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterator<ValueParameterDescriptor> parameters = candidate.getValueParameters().iterator();
|
||||||
|
for (JetValueArgument valueArgument : call.getValueArguments()) {
|
||||||
|
assert !valueArgument.isNamed();
|
||||||
|
ValueParameterDescriptor valueParameterDescriptor = parameters.next();
|
||||||
|
JetExpression expression = valueArgument.getArgumentExpression();
|
||||||
|
JetType type = getType(scope, expression, false, NO_EXPECTED_TYPE);
|
||||||
|
constraintSystem.addSubtypingConstraint(type, valueParameterDescriptor.getOutType());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expectedType != NO_EXPECTED_TYPE) {
|
||||||
|
System.out.println("expectedType = " + expectedType);
|
||||||
|
constraintSystem.addSubtypingConstraint(candidate.getReturnType(), expectedType);
|
||||||
|
}
|
||||||
|
|
||||||
|
ConstraintSystem.Solution solution = constraintSystem.solve();
|
||||||
|
if (!solution.isSuccessful()) {
|
||||||
|
trace.getErrorHandler().genericError(calleeExpression.getNode(), "Type inference failed");
|
||||||
|
// for (Inconsistency inconsistency : solution.getInconsistencies()) {
|
||||||
|
// System.out.println("inconsistency = " + inconsistency);
|
||||||
|
// }
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for (TypeParameterDescriptor typeParameterDescriptor : candidate.getTypeParameters()) {
|
||||||
|
JetType value = solution.getValue(typeParameterDescriptor);
|
||||||
|
System.out.println("typeParameterDescriptor = " + typeParameterDescriptor);
|
||||||
|
System.out.println("value = " + value);
|
||||||
|
}
|
||||||
|
return solution.getSubstitutor().substitute(candidate.getReturnType(), Variance.INVARIANT); // TODO
|
||||||
|
}
|
||||||
|
// return null;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new UnsupportedOperationException("Explicit type arguments not implemented");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private JetType resolveCall(
|
private JetType resolveCall(
|
||||||
@NotNull JetScope scope,
|
@NotNull JetScope scope,
|
||||||
@@ -718,7 +786,7 @@ public class JetTypeInferrer {
|
|||||||
if (constructorReturnedType == null && !ErrorUtils.isErrorType(receiverType)) {
|
if (constructorReturnedType == null && !ErrorUtils.isErrorType(receiverType)) {
|
||||||
DeclarationDescriptor declarationDescriptor = receiverType.getConstructor().getDeclarationDescriptor();
|
DeclarationDescriptor declarationDescriptor = receiverType.getConstructor().getDeclarationDescriptor();
|
||||||
assert declarationDescriptor != null;
|
assert declarationDescriptor != null;
|
||||||
trace.recordReferenceResolution(referenceExpression, declarationDescriptor);
|
trace.record(BindingContext.REFERENCE_TARGET, referenceExpression, declarationDescriptor);
|
||||||
// TODO : more helpful message
|
// TODO : more helpful message
|
||||||
JetValueArgumentList argumentList = call.getValueArgumentList();
|
JetValueArgumentList argumentList = call.getValueArgumentList();
|
||||||
final String errorMessage = "Cannot find a constructor overload for class " + classDescriptor.getName() + " with these arguments";
|
final String errorMessage = "Cannot find a constructor overload for class " + classDescriptor.getName() + " with these arguments";
|
||||||
@@ -763,31 +831,29 @@ public class JetTypeInferrer {
|
|||||||
semanticServices.getTypeChecker().isSubtypeOf(expressionType, context.expectedType)) {
|
semanticServices.getTypeChecker().isSubtypeOf(expressionType, context.expectedType)) {
|
||||||
return expressionType;
|
return expressionType;
|
||||||
}
|
}
|
||||||
JetType enrichedType = null;
|
|
||||||
|
|
||||||
VariableDescriptor variableDescriptor = getVariableDescriptorFromSimpleName(expression, context);
|
VariableDescriptor variableDescriptor = getVariableDescriptorFromSimpleName(expression, context);
|
||||||
if (variableDescriptor != null) {
|
if (variableDescriptor == null) return expressionType;
|
||||||
|
|
||||||
List<JetType> possibleTypes = Lists.newArrayList(context.dataFlowInfo.getPossibleTypes(variableDescriptor));
|
JetType enrichedType = null;
|
||||||
Collections.reverse(possibleTypes);
|
List<JetType> possibleTypes = Lists.newArrayList(context.dataFlowInfo.getPossibleTypes(variableDescriptor));
|
||||||
for (JetType possibleType : possibleTypes) {
|
Collections.reverse(possibleTypes);
|
||||||
if (semanticServices.getTypeChecker().isSubtypeOf(possibleType, context.expectedType)) {
|
for (JetType possibleType: possibleTypes) {
|
||||||
enrichedType = possibleType;
|
if (semanticServices.getTypeChecker().isSubtypeOf(possibleType, context.expectedType)) {
|
||||||
break;
|
enrichedType = possibleType;
|
||||||
}
|
break;
|
||||||
}
|
|
||||||
if (enrichedType == null) {
|
|
||||||
enrichedType = context.dataFlowInfo.getOutType(variableDescriptor);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (enrichedType == null) {
|
||||||
|
enrichedType = context.dataFlowInfo.getOutType(variableDescriptor);
|
||||||
|
}
|
||||||
if (enrichedType == null) {
|
if (enrichedType == null) {
|
||||||
enrichedType = expressionType;
|
enrichedType = expressionType;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (variableDescriptor == null || !semanticServices.getTypeChecker().isSubtypeOf(enrichedType, context.expectedType)) {
|
if (!semanticServices.getTypeChecker().isSubtypeOf(enrichedType, context.expectedType)) {
|
||||||
context.trace.getErrorHandler().typeMismatch(expression, context.expectedType, expressionType);
|
context.trace.getErrorHandler().typeMismatch(expression, context.expectedType, expressionType);
|
||||||
} else {
|
} else {
|
||||||
context.trace.recordAutoCast(expression, context.expectedType, variableDescriptor);
|
context.trace.record(BindingContext.AUTOCAST, expression, context.expectedType);
|
||||||
}
|
}
|
||||||
return enrichedType;
|
return enrichedType;
|
||||||
}
|
}
|
||||||
@@ -815,7 +881,7 @@ public class JetTypeInferrer {
|
|||||||
VariableDescriptor variableDescriptor = null;
|
VariableDescriptor variableDescriptor = null;
|
||||||
if (receiverExpression instanceof JetSimpleNameExpression) {
|
if (receiverExpression instanceof JetSimpleNameExpression) {
|
||||||
JetSimpleNameExpression nameExpression = (JetSimpleNameExpression) receiverExpression;
|
JetSimpleNameExpression nameExpression = (JetSimpleNameExpression) receiverExpression;
|
||||||
DeclarationDescriptor declarationDescriptor = context.trace.getBindingContext().resolveReferenceExpression(nameExpression);
|
DeclarationDescriptor declarationDescriptor = context.trace.getBindingContext().get(BindingContext.REFERENCE_TARGET, nameExpression);
|
||||||
if (declarationDescriptor instanceof VariableDescriptor) {
|
if (declarationDescriptor instanceof VariableDescriptor) {
|
||||||
variableDescriptor = (VariableDescriptor) declarationDescriptor;
|
variableDescriptor = (VariableDescriptor) declarationDescriptor;
|
||||||
}
|
}
|
||||||
@@ -843,7 +909,6 @@ public class JetTypeInferrer {
|
|||||||
private TypeInferenceContext(
|
private TypeInferenceContext(
|
||||||
@NotNull BindingTrace trace,
|
@NotNull BindingTrace trace,
|
||||||
@NotNull JetScope scope,
|
@NotNull JetScope scope,
|
||||||
@NotNull Services services,
|
|
||||||
boolean preferBlock,
|
boolean preferBlock,
|
||||||
@NotNull DataFlowInfo dataFlowInfo,
|
@NotNull DataFlowInfo dataFlowInfo,
|
||||||
@NotNull JetType expectedType,
|
@NotNull JetType expectedType,
|
||||||
@@ -852,7 +917,7 @@ public class JetTypeInferrer {
|
|||||||
this.typeResolver = new TypeResolver(semanticServices, trace, true);
|
this.typeResolver = new TypeResolver(semanticServices, trace, true);
|
||||||
this.classDescriptorResolver = semanticServices.getClassDescriptorResolver(trace);
|
this.classDescriptorResolver = semanticServices.getClassDescriptorResolver(trace);
|
||||||
this.scope = scope;
|
this.scope = scope;
|
||||||
this.services = services;
|
this.services = getServices(trace);
|
||||||
this.preferBlock = preferBlock;
|
this.preferBlock = preferBlock;
|
||||||
this.dataFlowInfo = dataFlowInfo;
|
this.dataFlowInfo = dataFlowInfo;
|
||||||
this.expectedType = expectedType;
|
this.expectedType = expectedType;
|
||||||
@@ -861,19 +926,24 @@ public class JetTypeInferrer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public TypeInferenceContext replaceDataFlowInfo(DataFlowInfo newDataFlowInfo) {
|
public TypeInferenceContext replaceDataFlowInfo(DataFlowInfo newDataFlowInfo) {
|
||||||
return new TypeInferenceContext(trace, scope, services, preferBlock, newDataFlowInfo, expectedType, expectedReturnType);
|
return new TypeInferenceContext(trace, scope, preferBlock, newDataFlowInfo, expectedType, expectedReturnType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TypeInferenceContext replaceExpectedType(@Nullable JetType newExpectedType) {
|
public TypeInferenceContext replaceExpectedType(@Nullable JetType newExpectedType) {
|
||||||
if (newExpectedType == null) return replaceExpectedType(NO_EXPECTED_TYPE);
|
if (newExpectedType == null) return replaceExpectedType(NO_EXPECTED_TYPE);
|
||||||
if (expectedType == newExpectedType) return this;
|
if (expectedType == newExpectedType) return this;
|
||||||
return new TypeInferenceContext(trace, scope, services, preferBlock, dataFlowInfo, newExpectedType, expectedReturnType);
|
return new TypeInferenceContext(trace, scope, preferBlock, dataFlowInfo, newExpectedType, expectedReturnType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TypeInferenceContext replaceExpectedReturnType(@Nullable JetType newExpectedReturnType) {
|
public TypeInferenceContext replaceExpectedReturnType(@Nullable JetType newExpectedReturnType) {
|
||||||
if (newExpectedReturnType == null) return replaceExpectedReturnType(NO_EXPECTED_TYPE);
|
if (newExpectedReturnType == null) return replaceExpectedReturnType(NO_EXPECTED_TYPE);
|
||||||
if (expectedReturnType == newExpectedReturnType) return this;
|
if (expectedReturnType == newExpectedReturnType) return this;
|
||||||
return new TypeInferenceContext(trace, scope, services, preferBlock, dataFlowInfo, expectedType, newExpectedReturnType);
|
return new TypeInferenceContext(trace, scope, preferBlock, dataFlowInfo, expectedType, newExpectedReturnType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TypeInferenceContext replaceBindingTrace(@NotNull BindingTrace newTrace) {
|
||||||
|
if (newTrace == trace) return this;
|
||||||
|
return new TypeInferenceContext(newTrace, scope, preferBlock, dataFlowInfo, expectedType, expectedReturnType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -888,31 +958,31 @@ public class JetTypeInferrer {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public JetType getType(@NotNull JetScope scope, @NotNull JetExpression expression, boolean preferBlock, TypeInferenceContext context) {
|
public JetType getType(@NotNull JetScope scope, @NotNull JetExpression expression, boolean preferBlock, TypeInferenceContext context) {
|
||||||
return getType(expression, new TypeInferenceContext(context.trace, scope, context.services, preferBlock, context.dataFlowInfo, context.expectedType, context.expectedReturnType));
|
return getType(expression, new TypeInferenceContext(context.trace, scope, preferBlock, context.dataFlowInfo, context.expectedType, context.expectedReturnType));
|
||||||
}
|
}
|
||||||
|
|
||||||
private JetType getTypeWithNewDataFlowInfo(JetScope scope, JetExpression expression, boolean preferBlock, @NotNull DataFlowInfo newDataFlowInfo, TypeInferenceContext context) {
|
private JetType getTypeWithNewDataFlowInfo(JetScope scope, JetExpression expression, boolean preferBlock, @NotNull DataFlowInfo newDataFlowInfo, TypeInferenceContext context) {
|
||||||
return getType(expression, new TypeInferenceContext(context.trace, scope, context.services, preferBlock, newDataFlowInfo, context.expectedType, context.expectedReturnType));
|
return getType(expression, new TypeInferenceContext(context.trace, scope, preferBlock, newDataFlowInfo, context.expectedType, context.expectedReturnType));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public final JetType getType(@NotNull JetExpression expression, TypeInferenceContext context) {
|
public final JetType getType(@NotNull JetExpression expression, TypeInferenceContext context) {
|
||||||
if (context.trace.isProcessed(expression)) {
|
if (context.trace.get(BindingContext.PROCESSED, expression)) {
|
||||||
return context.trace.getBindingContext().getExpressionType(expression);
|
return context.trace.getBindingContext().get(BindingContext.EXPRESSION_TYPE, expression);
|
||||||
}
|
}
|
||||||
JetType result;
|
JetType result;
|
||||||
try {
|
try {
|
||||||
result = expression.visit(this, context);
|
result = expression.visit(this, context);
|
||||||
// Some recursive definitions (object expressions) must put their types in the cache manually:
|
// Some recursive definitions (object expressions) must put their types in the cache manually:
|
||||||
if (context.trace.isProcessed(expression)) {
|
if ((boolean) context.trace.get(BindingContext.PROCESSED, expression)) {
|
||||||
return context.trace.getBindingContext().getExpressionType(expression);
|
return context.trace.getBindingContext().get(BindingContext.EXPRESSION_TYPE, expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result instanceof DeferredType) {
|
if (result instanceof DeferredType) {
|
||||||
result = ((DeferredType) result).getActualType();
|
result = ((DeferredType) result).getActualType();
|
||||||
}
|
}
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
context.trace.recordExpressionType(expression, result);
|
context.trace.record(BindingContext.EXPRESSION_TYPE, expression, result);
|
||||||
if (JetStandardClasses.isNothing(result) && !result.isNullable()) {
|
if (JetStandardClasses.isNothing(result) && !result.isNullable()) {
|
||||||
markDominatedExpressionsAsUnreachable(expression, context);
|
markDominatedExpressionsAsUnreachable(expression, context);
|
||||||
}
|
}
|
||||||
@@ -923,10 +993,10 @@ public class JetTypeInferrer {
|
|||||||
result = null;
|
result = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!context.trace.isProcessed(expression)) {
|
if (!(boolean) context.trace.get(BindingContext.PROCESSED, expression)) {
|
||||||
context.trace.recordResolutionScope(expression, context.scope);
|
context.trace.record(BindingContext.RESOLUTION_SCOPE, expression, context.scope);
|
||||||
}
|
}
|
||||||
context.trace.markAsProcessed(expression);
|
context.trace.record(BindingContext.PROCESSED, expression);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -974,7 +1044,7 @@ public class JetTypeInferrer {
|
|||||||
context.trace.getErrorHandler().unresolvedReference(expression);
|
context.trace.getErrorHandler().unresolvedReference(expression);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
context.trace.recordReferenceResolution(expression, property);
|
context.trace.record(BindingContext.REFERENCE_TARGET, expression, property);
|
||||||
return context.services.checkEnrichedType(property.getOutType(), expression, context);
|
return context.services.checkEnrichedType(property.getOutType(), expression, context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -983,7 +1053,7 @@ public class JetTypeInferrer {
|
|||||||
if (referencedName != null) {
|
if (referencedName != null) {
|
||||||
VariableDescriptor variable = context.scope.getVariable(referencedName);
|
VariableDescriptor variable = context.scope.getVariable(referencedName);
|
||||||
if (variable != null) {
|
if (variable != null) {
|
||||||
context.trace.recordReferenceResolution(expression, variable);
|
context.trace.record(BindingContext.REFERENCE_TARGET, expression, variable);
|
||||||
JetType result = variable.getOutType();
|
JetType result = variable.getOutType();
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
context.trace.getErrorHandler().genericError(expression.getNode(), "This variable is not readable in this context");
|
context.trace.getErrorHandler().genericError(expression.getNode(), "This variable is not readable in this context");
|
||||||
@@ -1001,7 +1071,7 @@ public class JetTypeInferrer {
|
|||||||
else {
|
else {
|
||||||
context.trace.getErrorHandler().genericError(expression.getNode(), "Classifier " + classifier.getName() + " does not have a class object");
|
context.trace.getErrorHandler().genericError(expression.getNode(), "Classifier " + classifier.getName() + " does not have a class object");
|
||||||
}
|
}
|
||||||
context.trace.recordReferenceResolution(expression, classifier);
|
context.trace.record(BindingContext.REFERENCE_TARGET, expression, classifier);
|
||||||
return context.services.checkEnrichedType(result, expression, context);
|
return context.services.checkEnrichedType(result, expression, context);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -1037,16 +1107,17 @@ public class JetTypeInferrer {
|
|||||||
if (namespace == null) {
|
if (namespace == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
context.trace.recordReferenceResolution(expression, namespace);
|
context.trace.record(BindingContext.REFERENCE_TARGET, expression, namespace);
|
||||||
return namespace.getNamespaceType();
|
return namespace.getNamespaceType();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetType visitObjectLiteralExpression(final JetObjectLiteralExpression expression, final TypeInferenceContext context) {
|
public JetType visitObjectLiteralExpression(final JetObjectLiteralExpression expression, final TypeInferenceContext context) {
|
||||||
final JetType[] result = new JetType[1];
|
final JetType[] result = new JetType[1];
|
||||||
TopDownAnalyzer topDownAnalyzer = new TopDownAnalyzer(semanticServices, new BindingTraceAdapter(context.trace) {
|
BindingTraceAdapter.RecordHandler<PsiElement, DeclarationDescriptor> handler = new BindingTraceAdapter.RecordHandler<PsiElement, DeclarationDescriptor>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void recordDeclarationResolution(@NotNull PsiElement declaration, @NotNull final DeclarationDescriptor descriptor) {
|
public void handleRecord(WritableSlice<PsiElement, DeclarationDescriptor> slice, PsiElement declaration, final DeclarationDescriptor descriptor) {
|
||||||
if (declaration == expression.getObjectDeclaration()) {
|
if (declaration == expression.getObjectDeclaration()) {
|
||||||
JetType defaultType = new DeferredType(new LazyValue<JetType>() {
|
JetType defaultType = new DeferredType(new LazyValue<JetType>() {
|
||||||
@Override
|
@Override
|
||||||
@@ -1055,14 +1126,19 @@ public class JetTypeInferrer {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
result[0] = defaultType;
|
result[0] = defaultType;
|
||||||
if (!context.trace.isProcessed(expression)) {
|
if (!context.trace.get(BindingContext.PROCESSED, expression)) {
|
||||||
recordExpressionType(expression, defaultType);
|
context.trace.record(BindingContext.EXPRESSION_TYPE, expression, defaultType);
|
||||||
markAsProcessed(expression);
|
context.trace.record(BindingContext.PROCESSED, expression);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.recordDeclarationResolution(declaration, descriptor);
|
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
BindingTraceAdapter traceAdapter = new BindingTraceAdapter(context.trace);
|
||||||
|
for (WritableSlice slice : BindingContext.DECLARATIONS_TO_DESCRIPTORS) {
|
||||||
|
//noinspection unchecked
|
||||||
|
traceAdapter.addHandler(slice, handler);
|
||||||
|
}
|
||||||
|
TopDownAnalyzer topDownAnalyzer = new TopDownAnalyzer(semanticServices, traceAdapter);
|
||||||
topDownAnalyzer.processObject(context.scope, context.scope.getContainingDeclaration(), expression.getObjectDeclaration());
|
topDownAnalyzer.processObject(context.scope, context.scope.getContainingDeclaration(), expression.getObjectDeclaration());
|
||||||
return context.services.checkType(result[0], expression, context);
|
return context.services.checkType(result[0], expression, context);
|
||||||
}
|
}
|
||||||
@@ -1071,7 +1147,7 @@ public class JetTypeInferrer {
|
|||||||
public JetType visitFunctionLiteralExpression(JetFunctionLiteralExpression expression, TypeInferenceContext context) {
|
public JetType visitFunctionLiteralExpression(JetFunctionLiteralExpression expression, TypeInferenceContext context) {
|
||||||
JetFunctionLiteral functionLiteral = expression.getFunctionLiteral();
|
JetFunctionLiteral functionLiteral = expression.getFunctionLiteral();
|
||||||
if (context.preferBlock && !functionLiteral.hasParameterSpecification()) {
|
if (context.preferBlock && !functionLiteral.hasParameterSpecification()) {
|
||||||
context.trace.recordBlock(expression);
|
context.trace.record(BindingContext.BLOCK, expression);
|
||||||
return context.services.checkType(getBlockReturnedType(context.scope, functionLiteral.getBodyExpression(), context), expression, context);
|
return context.services.checkType(getBlockReturnedType(context.scope, functionLiteral.getBodyExpression(), context), expression, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1108,7 +1184,7 @@ public class JetTypeInferrer {
|
|||||||
|
|
||||||
JetType effectiveReceiverType = receiverTypeRef == null ? null : receiverType;
|
JetType effectiveReceiverType = receiverTypeRef == null ? null : receiverType;
|
||||||
functionDescriptor.initialize(effectiveReceiverType, Collections.<TypeParameterDescriptor>emptyList(), valueParameterDescriptors, null);
|
functionDescriptor.initialize(effectiveReceiverType, Collections.<TypeParameterDescriptor>emptyList(), valueParameterDescriptors, null);
|
||||||
context.trace.recordDeclarationResolution(expression, functionDescriptor);
|
context.trace.record(BindingContext.FUNCTION, expression, functionDescriptor);
|
||||||
|
|
||||||
JetType returnType = NO_EXPECTED_TYPE;
|
JetType returnType = NO_EXPECTED_TYPE;
|
||||||
JetScope functionInnerScope = FunctionDescriptorUtil.getFunctionInnerScope(context.scope, functionDescriptor, context.trace);
|
JetScope functionInnerScope = FunctionDescriptorUtil.getFunctionInnerScope(context.scope, functionDescriptor, context.trace);
|
||||||
@@ -1171,7 +1247,7 @@ public class JetTypeInferrer {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
context.trace.recordCompileTimeValue(expression, value);
|
context.trace.record(BindingContext.COMPILE_TIME_VALUE, expression, value);
|
||||||
return context.services.checkType(value.getType(standardLibrary), expression, context);
|
return context.services.checkType(value.getType(standardLibrary), expression, context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1305,22 +1381,22 @@ public class JetTypeInferrer {
|
|||||||
else {
|
else {
|
||||||
throw new UnsupportedOperationException(); // TODO
|
throw new UnsupportedOperationException(); // TODO
|
||||||
}
|
}
|
||||||
context.trace.recordReferenceResolution(targetLabel, declarationDescriptor);
|
context.trace.record(BindingContext.REFERENCE_TARGET, targetLabel, declarationDescriptor);
|
||||||
context.trace.recordReferenceResolution(expression.getThisReference(), declarationDescriptor);
|
context.trace.record(BindingContext.REFERENCE_TARGET, expression.getThisReference(), declarationDescriptor);
|
||||||
}
|
}
|
||||||
else if (size == 0) {
|
else if (size == 0) {
|
||||||
// This uses the info written by the control flow processor
|
// This uses the info written by the control flow processor
|
||||||
PsiElement psiElement = context.trace.getBindingContext().resolveToDeclarationPsiElement(targetLabel);
|
PsiElement psiElement = BindingContextUtils.resolveToDeclarationPsiElement(context.trace.getBindingContext(), targetLabel);
|
||||||
if (psiElement instanceof JetFunctionLiteralExpression) {
|
if (psiElement instanceof JetFunctionLiteralExpression) {
|
||||||
DeclarationDescriptor declarationDescriptor = context.trace.getBindingContext().getDeclarationDescriptor(psiElement);
|
DeclarationDescriptor declarationDescriptor = context.trace.getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, psiElement);
|
||||||
if (declarationDescriptor instanceof FunctionDescriptor) {
|
if (declarationDescriptor instanceof FunctionDescriptor) {
|
||||||
thisType = ((FunctionDescriptor) declarationDescriptor).getReceiverType();
|
thisType = ((FunctionDescriptor) declarationDescriptor).getReceiverType();
|
||||||
if (thisType == null) {
|
if (thisType == null) {
|
||||||
thisType = JetStandardClasses.getNothingType();
|
thisType = JetStandardClasses.getNothingType();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
context.trace.recordReferenceResolution(targetLabel, declarationDescriptor);
|
context.trace.record(BindingContext.REFERENCE_TARGET, targetLabel, declarationDescriptor);
|
||||||
context.trace.recordReferenceResolution(expression.getThisReference(), declarationDescriptor);
|
context.trace.record(BindingContext.REFERENCE_TARGET, expression.getThisReference(), declarationDescriptor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -1340,7 +1416,7 @@ public class JetTypeInferrer {
|
|||||||
|
|
||||||
DeclarationDescriptor declarationDescriptorForUnqualifiedThis = context.scope.getDeclarationDescriptorForUnqualifiedThis();
|
DeclarationDescriptor declarationDescriptorForUnqualifiedThis = context.scope.getDeclarationDescriptorForUnqualifiedThis();
|
||||||
if (declarationDescriptorForUnqualifiedThis != null) {
|
if (declarationDescriptorForUnqualifiedThis != null) {
|
||||||
context.trace.recordReferenceResolution(expression.getThisReference(), declarationDescriptorForUnqualifiedThis);
|
context.trace.record(BindingContext.REFERENCE_TARGET, expression.getThisReference(), declarationDescriptorForUnqualifiedThis);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1377,7 +1453,7 @@ public class JetTypeInferrer {
|
|||||||
result = thisType;
|
result = thisType;
|
||||||
}
|
}
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
context.trace.recordExpressionType(expression.getThisReference(), result);
|
context.trace.record(BindingContext.EXPRESSION_TYPE, expression.getThisReference(), result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1764,7 +1840,7 @@ public class JetTypeInferrer {
|
|||||||
// TODO : validate that DF makes sense for this variable: local, val, internal w/backing field, etc
|
// TODO : validate that DF makes sense for this variable: local, val, internal w/backing field, etc
|
||||||
|
|
||||||
// Comparison to a non-null expression
|
// Comparison to a non-null expression
|
||||||
JetType rhsType = context.trace.getBindingContext().getExpressionType(right);
|
JetType rhsType = context.trace.getBindingContext().get(BindingContext.EXPRESSION_TYPE, right);
|
||||||
if (rhsType != null && !rhsType.isNullable()) {
|
if (rhsType != null && !rhsType.isNullable()) {
|
||||||
extendDataFlowWithNullComparison(operationToken, variableDescriptor, !conditionValue);
|
extendDataFlowWithNullComparison(operationToken, variableDescriptor, !conditionValue);
|
||||||
return;
|
return;
|
||||||
@@ -1772,7 +1848,7 @@ public class JetTypeInferrer {
|
|||||||
|
|
||||||
VariableDescriptor rightVariable = context.services.getVariableDescriptorFromSimpleName(right, context);
|
VariableDescriptor rightVariable = context.services.getVariableDescriptorFromSimpleName(right, context);
|
||||||
if (rightVariable != null) {
|
if (rightVariable != null) {
|
||||||
JetType lhsType = context.trace.getBindingContext().getExpressionType(left);
|
JetType lhsType = context.trace.getBindingContext().get(BindingContext.EXPRESSION_TYPE, left);
|
||||||
if (lhsType != null && !lhsType.isNullable()) {
|
if (lhsType != null && !lhsType.isNullable()) {
|
||||||
extendDataFlowWithNullComparison(operationToken, rightVariable, !conditionValue);
|
extendDataFlowWithNullComparison(operationToken, rightVariable, !conditionValue);
|
||||||
return;
|
return;
|
||||||
@@ -1865,7 +1941,7 @@ public class JetTypeInferrer {
|
|||||||
WritableScope writableScope = newWritableScopeImpl(context.scope, context.trace).setDebugName("do..while body scope");
|
WritableScope writableScope = newWritableScopeImpl(context.scope, context.trace).setDebugName("do..while body scope");
|
||||||
conditionScope = writableScope;
|
conditionScope = writableScope;
|
||||||
context.services.getBlockReturnedTypeWithWritableScope(writableScope, function.getFunctionLiteral().getBodyExpression().getStatements(), context);
|
context.services.getBlockReturnedTypeWithWritableScope(writableScope, function.getFunctionLiteral().getBodyExpression().getStatements(), context);
|
||||||
context.trace.recordBlock(function);
|
context.trace.record(BindingContext.BLOCK, function);
|
||||||
} else {
|
} else {
|
||||||
getType(context.scope, body, true, context);
|
getType(context.scope, body, true, context);
|
||||||
}
|
}
|
||||||
@@ -2095,11 +2171,15 @@ public class JetTypeInferrer {
|
|||||||
// TODO : functions as values
|
// TODO : functions as values
|
||||||
JetExpression selectorExpression = expression.getSelectorExpression();
|
JetExpression selectorExpression = expression.getSelectorExpression();
|
||||||
JetExpression receiverExpression = expression.getReceiverExpression();
|
JetExpression receiverExpression = expression.getReceiverExpression();
|
||||||
JetType receiverType = context.services.typeInferrerVisitorWithNamespaces.getType(receiverExpression, new TypeInferenceContext(context.trace, context.scope, context.services, false, context.dataFlowInfo, NO_EXPECTED_TYPE, NO_EXPECTED_TYPE));
|
JetType receiverType = context.services.typeInferrerVisitorWithNamespaces.getType(receiverExpression, new TypeInferenceContext(context.trace, context.scope, false, context.dataFlowInfo, NO_EXPECTED_TYPE, NO_EXPECTED_TYPE));
|
||||||
if (receiverType == null) return null;
|
if (receiverType == null) return null;
|
||||||
ErrorHandlerWithRegions errorHandler = context.trace.getErrorHandler();
|
|
||||||
errorHandler.openRegion();
|
// Clean resolution: no autocasts
|
||||||
JetType selectorReturnType = getSelectorReturnType(receiverType, selectorExpression, context);
|
TemporaryBindingTrace cleanResolutionTrace = new TemporaryBindingTrace(context.trace.getBindingContext());
|
||||||
|
TypeInferenceContext cleanResolutionContext = context.replaceBindingTrace(cleanResolutionTrace);
|
||||||
|
// ErrorHandler errorHandler = context.trace.getErrorHandler();
|
||||||
|
// errorHandler.openRegion();
|
||||||
|
JetType selectorReturnType = getSelectorReturnType(receiverType, selectorExpression, cleanResolutionContext);
|
||||||
|
|
||||||
//TODO move further
|
//TODO move further
|
||||||
if (expression.getOperationSign() == JetTokens.SAFE_ACCESS) {
|
if (expression.getOperationSign() == JetTokens.SAFE_ACCESS) {
|
||||||
@@ -2108,37 +2188,41 @@ public class JetTypeInferrer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (selectorReturnType != null) {
|
if (selectorReturnType != null) {
|
||||||
errorHandler.closeAndCommitCurrentRegion();
|
cleanResolutionTrace.addAllMyDataTo(context.trace);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ErrorHandlerWithRegions.DiagnosticsRegion regionToCommit = errorHandler.closeAndReturnCurrentRegion();
|
VariableDescriptor variableDescriptor = cleanResolutionContext.services.getVariableDescriptorFromSimpleName(receiverExpression, context);
|
||||||
|
boolean somethingFound = false;
|
||||||
VariableDescriptor variableDescriptor = context.services.getVariableDescriptorFromSimpleName(receiverExpression, context);
|
|
||||||
if (variableDescriptor != null) {
|
if (variableDescriptor != null) {
|
||||||
List<JetType> possibleTypes = Lists.newArrayList(context.dataFlowInfo.getPossibleTypes(variableDescriptor));
|
List<JetType> possibleTypes = Lists.newArrayList(context.dataFlowInfo.getPossibleTypes(variableDescriptor));
|
||||||
Collections.reverse(possibleTypes);
|
Collections.reverse(possibleTypes);
|
||||||
|
|
||||||
|
TemporaryBindingTrace autocastResolutionTrace = new TemporaryBindingTrace(context.trace.getBindingContext());
|
||||||
|
TypeInferenceContext autocastResolutionContext = context.replaceBindingTrace(autocastResolutionTrace);
|
||||||
for (JetType possibleType : possibleTypes) {
|
for (JetType possibleType : possibleTypes) {
|
||||||
errorHandler.openRegion();
|
selectorReturnType = getSelectorReturnType(possibleType, selectorExpression, autocastResolutionContext);
|
||||||
selectorReturnType = getSelectorReturnType(possibleType, selectorExpression, context);
|
|
||||||
if (selectorReturnType != null) {
|
if (selectorReturnType != null) {
|
||||||
regionToCommit = errorHandler.closeAndReturnCurrentRegion();
|
autocastResolutionTrace.record(BindingContext.AUTOCAST, receiverExpression, possibleType);
|
||||||
context.trace.recordAutoCast(receiverExpression, possibleType, variableDescriptor);
|
autocastResolutionTrace.addAllMyDataTo(context.trace);
|
||||||
|
somethingFound = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
errorHandler.closeAndReturnCurrentRegion();
|
autocastResolutionTrace = new TemporaryBindingTrace(context.trace.getBindingContext());
|
||||||
|
autocastResolutionContext = context.replaceBindingTrace(autocastResolutionTrace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!somethingFound) {
|
||||||
regionToCommit.commit();
|
cleanResolutionTrace.addAllMyDataTo(context.trace);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JetType result;
|
JetType result;
|
||||||
if (expression.getOperationSign() == JetTokens.QUEST) {
|
if (expression.getOperationSign() == JetTokens.QUEST) {
|
||||||
if (selectorReturnType != null && !isBoolean(selectorReturnType) && selectorExpression != null) {
|
if (selectorReturnType != null && !isBoolean(selectorReturnType) && selectorExpression != null) {
|
||||||
// TODO : more comprehensible error message
|
// TODO : more comprehensible error message
|
||||||
errorHandler.typeMismatch(selectorExpression, semanticServices.getStandardLibrary().getBooleanType(), selectorReturnType);
|
context.trace.getErrorHandler().typeMismatch(selectorExpression, semanticServices.getStandardLibrary().getBooleanType(), selectorReturnType);
|
||||||
}
|
}
|
||||||
result = TypeUtils.makeNullable(receiverType);
|
result = TypeUtils.makeNullable(receiverType);
|
||||||
}
|
}
|
||||||
@@ -2146,7 +2230,7 @@ public class JetTypeInferrer {
|
|||||||
result = selectorReturnType;
|
result = selectorReturnType;
|
||||||
}
|
}
|
||||||
if (selectorExpression != null && result != null) {
|
if (selectorExpression != null && result != null) {
|
||||||
context.trace.recordExpressionType(selectorExpression, result);
|
context.trace.record(BindingContext.EXPRESSION_TYPE, selectorExpression, result);
|
||||||
}
|
}
|
||||||
if (selectorReturnType != null) {
|
if (selectorReturnType != null) {
|
||||||
// TODO : extensions to 'Any?'
|
// TODO : extensions to 'Any?'
|
||||||
@@ -2174,7 +2258,7 @@ public class JetTypeInferrer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitReferenceExpression(JetReferenceExpression referenceExpression) {
|
public void visitReferenceExpression(JetReferenceExpression referenceExpression) {
|
||||||
DeclarationDescriptor declarationDescriptor = context.trace.getBindingContext().resolveReferenceExpression(referenceExpression);
|
DeclarationDescriptor declarationDescriptor = context.trace.getBindingContext().get(BindingContext.REFERENCE_TARGET, referenceExpression);
|
||||||
if (declarationDescriptor instanceof FunctionDescriptor) {
|
if (declarationDescriptor instanceof FunctionDescriptor) {
|
||||||
result[0] = (FunctionDescriptor) declarationDescriptor;
|
result[0] = (FunctionDescriptor) declarationDescriptor;
|
||||||
}
|
}
|
||||||
@@ -2232,6 +2316,7 @@ public class JetTypeInferrer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetType visitCallExpression(JetCallExpression expression, TypeInferenceContext context) {
|
public JetType visitCallExpression(JetCallExpression expression, TypeInferenceContext context) {
|
||||||
|
// return context.services.checkType(context.services.resolveCall(context.scope, expression, context.expectedType), expression, context);
|
||||||
return context.services.checkType(getCallExpressionType(null, expression, context), expression, context);
|
return context.services.checkType(getCallExpressionType(null, expression, context), expression, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2279,7 +2364,7 @@ public class JetTypeInferrer {
|
|||||||
context.trace.getErrorHandler().genericError(operationSign.getNode(), name + " must return " + receiverType + " but returns " + returnType);
|
context.trace.getErrorHandler().genericError(operationSign.getNode(), name + " must return " + receiverType + " but returns " + returnType);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
context.trace.recordVariableReassignment(expression);
|
context.trace.record(BindingContext.VARIABLE_REASSIGNMENT, expression);
|
||||||
}
|
}
|
||||||
// TODO : Maybe returnType?
|
// TODO : Maybe returnType?
|
||||||
result = receiverType;
|
result = receiverType;
|
||||||
@@ -2459,7 +2544,7 @@ public class JetTypeInferrer {
|
|||||||
@Nullable
|
@Nullable
|
||||||
protected List<JetType> getTypes(JetScope scope, List<JetExpression> indexExpressions, TypeInferenceContext context) {
|
protected List<JetType> getTypes(JetScope scope, List<JetExpression> indexExpressions, TypeInferenceContext context) {
|
||||||
List<JetType> argumentTypes = new ArrayList<JetType>();
|
List<JetType> argumentTypes = new ArrayList<JetType>();
|
||||||
TypeInferenceContext newContext = new TypeInferenceContext(context.trace, scope, context.services, false, context.dataFlowInfo, NO_EXPECTED_TYPE, NO_EXPECTED_TYPE);
|
TypeInferenceContext newContext = new TypeInferenceContext(context.trace, scope, false, context.dataFlowInfo, NO_EXPECTED_TYPE, NO_EXPECTED_TYPE);
|
||||||
for (JetExpression indexExpression : indexExpressions) {
|
for (JetExpression indexExpression : indexExpressions) {
|
||||||
JetType type = context.services.typeInferrerVisitor.getType(indexExpression, newContext);
|
JetType type = context.services.typeInferrerVisitor.getType(indexExpression, newContext);
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
@@ -2590,7 +2675,7 @@ public class JetTypeInferrer {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (value[0] != CompileTimeConstantResolver.OUT_OF_RANGE) {
|
if (value[0] != CompileTimeConstantResolver.OUT_OF_RANGE) {
|
||||||
context.trace.recordCompileTimeValue(expression, new StringValue(builder.toString()));
|
context.trace.record(BindingContext.COMPILE_TIME_VALUE, expression, new StringValue(builder.toString()));
|
||||||
}
|
}
|
||||||
return context.services.checkType(semanticServices.getStandardLibrary().getStringType(), expression, contextWithExpectedType);
|
return context.services.checkType(semanticServices.getStandardLibrary().getStringType(), expression, contextWithExpectedType);
|
||||||
}
|
}
|
||||||
@@ -2638,7 +2723,7 @@ public class JetTypeInferrer {
|
|||||||
public JetType visitObjectDeclaration(JetObjectDeclaration declaration, TypeInferenceContext context) {
|
public JetType visitObjectDeclaration(JetObjectDeclaration declaration, TypeInferenceContext context) {
|
||||||
TopDownAnalyzer topDownAnalyzer = new TopDownAnalyzer(semanticServices, context.trace);
|
TopDownAnalyzer topDownAnalyzer = new TopDownAnalyzer(semanticServices, context.trace);
|
||||||
topDownAnalyzer.processObject(scope, scope.getContainingDeclaration(), declaration);
|
topDownAnalyzer.processObject(scope, scope.getContainingDeclaration(), declaration);
|
||||||
ClassDescriptor classDescriptor = context.trace.getBindingContext().getClassDescriptor(declaration);
|
ClassDescriptor classDescriptor = context.trace.getBindingContext().get(BindingContext.CLASS, declaration);
|
||||||
if (classDescriptor != null) {
|
if (classDescriptor != null) {
|
||||||
PropertyDescriptor propertyDescriptor = context.classDescriptorResolver.resolveObjectDeclarationAsPropertyDescriptor(scope.getContainingDeclaration(), declaration, classDescriptor);
|
PropertyDescriptor propertyDescriptor = context.classDescriptorResolver.resolveObjectDeclarationAsPropertyDescriptor(scope.getContainingDeclaration(), declaration, classDescriptor);
|
||||||
scope.addVariableDescriptor(propertyDescriptor);
|
scope.addVariableDescriptor(propertyDescriptor);
|
||||||
@@ -2712,7 +2797,7 @@ public class JetTypeInferrer {
|
|||||||
String counterpartName = binaryOperationNames.get(assignmentOperationCounterparts.get(operationType));
|
String counterpartName = binaryOperationNames.get(assignmentOperationCounterparts.get(operationType));
|
||||||
JetType typeForBinaryCall = getTypeForBinaryCall(expression, counterpartName, scope, true, context);
|
JetType typeForBinaryCall = getTypeForBinaryCall(expression, counterpartName, scope, true, context);
|
||||||
if (typeForBinaryCall != null) {
|
if (typeForBinaryCall != null) {
|
||||||
context.trace.recordVariableReassignment(expression);
|
context.trace.record(BindingContext.VARIABLE_REASSIGNMENT, expression);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -15,6 +15,30 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public class TypeSubstitutor {
|
public class TypeSubstitutor {
|
||||||
|
|
||||||
|
public interface TypeSubstitution {
|
||||||
|
@Nullable
|
||||||
|
TypeProjection get(TypeConstructor key);
|
||||||
|
boolean isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class MapToTypeSubstitutionAdapter implements TypeSubstitution {
|
||||||
|
private final @NotNull Map<TypeConstructor, TypeProjection> substitutionContext;
|
||||||
|
|
||||||
|
public MapToTypeSubstitutionAdapter(@NotNull Map<TypeConstructor, TypeProjection> substitutionContext) {
|
||||||
|
this.substitutionContext = substitutionContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TypeProjection get(TypeConstructor key) {
|
||||||
|
return substitutionContext.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return substitutionContext.isEmpty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static final TypeSubstitutor EMPTY = create(Collections.<TypeConstructor, TypeProjection>emptyMap());
|
public static final TypeSubstitutor EMPTY = create(Collections.<TypeConstructor, TypeProjection>emptyMap());
|
||||||
|
|
||||||
public static final class SubstitutionException extends Exception {
|
public static final class SubstitutionException extends Exception {
|
||||||
@@ -23,8 +47,12 @@ public class TypeSubstitutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static TypeSubstitutor create(@NotNull TypeSubstitution substitution) {
|
||||||
|
return new TypeSubstitutor(substitution);
|
||||||
|
}
|
||||||
|
|
||||||
public static TypeSubstitutor create(@NotNull Map<TypeConstructor, TypeProjection> substitutionContext) {
|
public static TypeSubstitutor create(@NotNull Map<TypeConstructor, TypeProjection> substitutionContext) {
|
||||||
return new TypeSubstitutor(substitutionContext);
|
return create(new MapToTypeSubstitutionAdapter(substitutionContext));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TypeSubstitutor create(@NotNull JetType context) {
|
public static TypeSubstitutor create(@NotNull JetType context) {
|
||||||
@@ -33,9 +61,9 @@ public class TypeSubstitutor {
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
private final @NotNull Map<TypeConstructor, TypeProjection> substitutionContext;
|
private final @NotNull TypeSubstitution substitutionContext;
|
||||||
|
|
||||||
private TypeSubstitutor(@NotNull Map<TypeConstructor, TypeProjection> substitutionContext) {
|
private TypeSubstitutor(@NotNull TypeSubstitution substitutionContext) {
|
||||||
this.substitutionContext = substitutionContext;
|
this.substitutionContext = substitutionContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +137,7 @@ public class TypeSubstitutor {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private TypeProjection substituteInProjection(
|
private TypeProjection substituteInProjection(
|
||||||
@NotNull Map<TypeConstructor, TypeProjection> substitutionContext,
|
@NotNull TypeSubstitution substitutionContext,
|
||||||
@NotNull TypeProjection passedProjection,
|
@NotNull TypeProjection passedProjection,
|
||||||
@NotNull TypeParameterDescriptor correspondingTypeParameter,
|
@NotNull TypeParameterDescriptor correspondingTypeParameter,
|
||||||
@NotNull Variance contextCallSiteVariance) throws SubstitutionException {
|
@NotNull Variance contextCallSiteVariance) throws SubstitutionException {
|
||||||
@@ -181,10 +209,6 @@ public class TypeSubstitutor {
|
|||||||
return new TypeProjection(effectiveProjectionKindValue, specializeType(effectiveTypeValue, effectiveContextVariance));
|
return new TypeProjection(effectiveProjectionKindValue, specializeType(effectiveTypeValue, effectiveContextVariance));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*package*/ void addSubstitution(@NotNull TypeConstructor typeConstructor, @NotNull TypeProjection typeProjection) {
|
|
||||||
substitutionContext.put(typeConstructor, typeProjection);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Variance asymmetricOr(Variance a, Variance b) {
|
private static Variance asymmetricOr(Variance a, Variance b) {
|
||||||
return a == Variance.INVARIANT ? b : a;
|
return a == Variance.INVARIANT ? b : a;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,6 +50,9 @@ public class TypeUtils {
|
|||||||
|
|
||||||
StringBuilder debugName = new StringBuilder();
|
StringBuilder debugName = new StringBuilder();
|
||||||
boolean nullable = false;
|
boolean nullable = false;
|
||||||
|
Set<JetType> resultingTypes = Sets.newHashSet();
|
||||||
|
|
||||||
|
outer:
|
||||||
for (Iterator<JetType> iterator = types.iterator(); iterator.hasNext();) {
|
for (Iterator<JetType> iterator = types.iterator(); iterator.hasNext();) {
|
||||||
JetType type = iterator.next();
|
JetType type = iterator.next();
|
||||||
|
|
||||||
@@ -63,9 +66,17 @@ public class TypeUtils {
|
|||||||
}
|
}
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
for (JetType other : types) {
|
||||||
|
if (!type.equals(other) && typeChecker.isSubtypeOf(other, type)) {
|
||||||
|
continue outer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
nullable |= type.isNullable();
|
nullable |= type.isNullable();
|
||||||
|
|
||||||
|
resultingTypes.add(type);
|
||||||
debugName.append(type.toString());
|
debugName.append(type.toString());
|
||||||
if (iterator.hasNext()) {
|
if (iterator.hasNext()) {
|
||||||
debugName.append(" & ");
|
debugName.append(" & ");
|
||||||
@@ -79,11 +90,11 @@ public class TypeUtils {
|
|||||||
false,
|
false,
|
||||||
debugName.toString(),
|
debugName.toString(),
|
||||||
Collections.<TypeParameterDescriptor>emptyList(),
|
Collections.<TypeParameterDescriptor>emptyList(),
|
||||||
types);
|
resultingTypes);
|
||||||
|
|
||||||
JetScope[] scopes = new JetScope[types.size()];
|
JetScope[] scopes = new JetScope[resultingTypes.size()];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (JetType type : types) {
|
for (JetType type : resultingTypes) {
|
||||||
scopes[i] = type.getMemberScope();
|
scopes[i] = type.getMemberScope();
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@@ -217,12 +228,15 @@ public class TypeUtils {
|
|||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public static TypeSubstitutor buildDeepSubstitutor(@NotNull JetType type) {
|
public static TypeSubstitutor buildDeepSubstitutor(@NotNull JetType type) {
|
||||||
TypeSubstitutor typeSubstitutor = TypeSubstitutor.create(Maps.<TypeConstructor, TypeProjection>newHashMap());
|
HashMap<TypeConstructor, TypeProjection> substitution = Maps.<TypeConstructor, TypeProjection>newHashMap();
|
||||||
fillInDeepSubstitutor(type, typeSubstitutor);
|
TypeSubstitutor typeSubstitutor = TypeSubstitutor.create(substitution);
|
||||||
|
// we use the mutability of the map here
|
||||||
|
fillInDeepSubstitutor(type, typeSubstitutor, substitution);
|
||||||
return typeSubstitutor;
|
return typeSubstitutor;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void fillInDeepSubstitutor(JetType context, TypeSubstitutor substitutor) {
|
// we use the mutability of the substitution map here
|
||||||
|
private static void fillInDeepSubstitutor(JetType context, TypeSubstitutor substitutor, Map<TypeConstructor, TypeProjection> substitution) {
|
||||||
List<TypeParameterDescriptor> parameters = context.getConstructor().getParameters();
|
List<TypeParameterDescriptor> parameters = context.getConstructor().getParameters();
|
||||||
List<TypeProjection> arguments = context.getArguments();
|
List<TypeProjection> arguments = context.getArguments();
|
||||||
for (int i = 0; i < arguments.size(); i++) {
|
for (int i = 0; i < arguments.size(); i++) {
|
||||||
@@ -232,10 +246,10 @@ public class TypeUtils {
|
|||||||
JetType substitute = substitutor.substitute(argument.getType(), Variance.INVARIANT);
|
JetType substitute = substitutor.substitute(argument.getType(), Variance.INVARIANT);
|
||||||
assert substitute != null;
|
assert substitute != null;
|
||||||
TypeProjection substitutedTypeProjection = new TypeProjection(argument.getProjectionKind(), substitute);
|
TypeProjection substitutedTypeProjection = new TypeProjection(argument.getProjectionKind(), substitute);
|
||||||
substitutor.addSubstitution(typeParameterDescriptor.getTypeConstructor(), substitutedTypeProjection);
|
substitution.put(typeParameterDescriptor.getTypeConstructor(), substitutedTypeProjection);
|
||||||
}
|
}
|
||||||
for (JetType supertype : context.getConstructor().getSupertypes()) {
|
for (JetType supertype : context.getConstructor().getSupertypes()) {
|
||||||
fillInDeepSubstitutor(supertype, substitutor);
|
fillInDeepSubstitutor(supertype, substitutor, substitution);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,18 @@ public enum Variance {
|
|||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Variance opposite() {
|
||||||
|
switch (this) {
|
||||||
|
case INVARIANT:
|
||||||
|
return INVARIANT;
|
||||||
|
case IN_VARIANCE:
|
||||||
|
return OUT_VARIANCE;
|
||||||
|
case OUT_VARIANCE:
|
||||||
|
return IN_VARIANCE;
|
||||||
|
}
|
||||||
|
throw new IllegalStateException("Impossible variance: " + this);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return label;
|
return label;
|
||||||
|
|||||||
@@ -0,0 +1,415 @@
|
|||||||
|
package org.jetbrains.jet.lang.types.inference;
|
||||||
|
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||||
|
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
|
||||||
|
import org.jetbrains.jet.lang.types.*;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author abreslav
|
||||||
|
*/
|
||||||
|
public class ConstraintSystem {
|
||||||
|
|
||||||
|
// private static final Supplier<Set<TypeValue>> SET_SUPPLIER = new Supplier<Set<TypeValue>>() {
|
||||||
|
// @Override
|
||||||
|
// public Set<TypeValue> get() {
|
||||||
|
// return Sets.newHashSet();
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
|
||||||
|
private static class LoopInTypeVariableConstraintsException extends RuntimeException {
|
||||||
|
private LoopInTypeVariableConstraintsException() {
|
||||||
|
}
|
||||||
|
|
||||||
|
private LoopInTypeVariableConstraintsException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
private LoopInTypeVariableConstraintsException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
private LoopInTypeVariableConstraintsException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static abstract class TypeValue {
|
||||||
|
private final Set<TypeValue> upperBounds = Sets.newHashSet();
|
||||||
|
private final Set<TypeValue> lowerBounds = Sets.newHashSet();
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public Set<TypeValue> getUpperBounds() {
|
||||||
|
return upperBounds;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public Set<TypeValue> getLowerBounds() {
|
||||||
|
return lowerBounds;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract KnownType getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class UnknownType extends TypeValue {
|
||||||
|
|
||||||
|
private final TypeParameterDescriptor typeParameterDescriptor;
|
||||||
|
private final Variance positionVariance;
|
||||||
|
private KnownType value;
|
||||||
|
private boolean beingComputed = false;
|
||||||
|
|
||||||
|
private UnknownType(TypeParameterDescriptor typeParameterDescriptor, Variance positionVariance) {
|
||||||
|
this.typeParameterDescriptor = typeParameterDescriptor;
|
||||||
|
this.positionVariance = positionVariance;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public TypeParameterDescriptor getTypeParameterDescriptor() {
|
||||||
|
return typeParameterDescriptor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KnownType getValue() {
|
||||||
|
if (beingComputed) {
|
||||||
|
throw new LoopInTypeVariableConstraintsException();
|
||||||
|
}
|
||||||
|
if (value == null) {
|
||||||
|
JetTypeChecker typeChecker = JetTypeChecker.INSTANCE;
|
||||||
|
beingComputed = true;
|
||||||
|
try {
|
||||||
|
if (positionVariance == Variance.IN_VARIANCE) {
|
||||||
|
// maximal solution
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// minimal solution
|
||||||
|
|
||||||
|
Set<TypeValue> lowerBounds = getLowerBounds();
|
||||||
|
if (!lowerBounds.isEmpty()) {
|
||||||
|
Set<JetType> types = getTypes(lowerBounds);
|
||||||
|
|
||||||
|
JetType commonSupertype = typeChecker.commonSupertype(types);
|
||||||
|
for (TypeValue upperBound : getUpperBounds()) {
|
||||||
|
if (!typeChecker.isSubtypeOf(commonSupertype, upperBound.getValue().getType())) {
|
||||||
|
value = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("minimal solution from lowerbounds for " + this + " is " + commonSupertype);
|
||||||
|
value = new KnownType(commonSupertype);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Set<TypeValue> upperBounds = getUpperBounds();
|
||||||
|
Set<JetType> types = getTypes(upperBounds);
|
||||||
|
JetType intersect = TypeUtils.intersect(typeChecker, types);
|
||||||
|
|
||||||
|
value = new KnownType(intersect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
beingComputed = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Set<JetType> getTypes(Set<TypeValue> lowerBounds) {
|
||||||
|
Set<JetType> types = Sets.newHashSet();
|
||||||
|
for (TypeValue lowerBound : lowerBounds) {
|
||||||
|
types.add(lowerBound.getValue().getType());
|
||||||
|
}
|
||||||
|
return types;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "?" + typeParameterDescriptor;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class KnownType extends TypeValue {
|
||||||
|
|
||||||
|
private final JetType type;
|
||||||
|
|
||||||
|
public KnownType(@NotNull JetType type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public JetType getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KnownType getValue() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return type.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final Map<JetType, KnownType> knownTypes = Maps.newHashMap();
|
||||||
|
private final Map<TypeParameterDescriptor, UnknownType> unknownTypes = Maps.newHashMap();
|
||||||
|
private final JetTypeChecker typeChecker = JetTypeChecker.INSTANCE;
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private TypeValue getTypeValueFor(@NotNull JetType type) {
|
||||||
|
DeclarationDescriptor declarationDescriptor = type.getConstructor().getDeclarationDescriptor();
|
||||||
|
if (declarationDescriptor instanceof TypeParameterDescriptor) {
|
||||||
|
TypeParameterDescriptor typeParameterDescriptor = (TypeParameterDescriptor) declarationDescriptor;
|
||||||
|
UnknownType unknownType = unknownTypes.get(typeParameterDescriptor);
|
||||||
|
if (unknownType != null) {
|
||||||
|
return unknownType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
KnownType typeValue = knownTypes.get(type);
|
||||||
|
if (typeValue == null) {
|
||||||
|
typeValue = new KnownType(type);
|
||||||
|
knownTypes.put(type, typeValue);
|
||||||
|
}
|
||||||
|
return typeValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerTypeVariable(@NotNull TypeParameterDescriptor typeParameterDescriptor, @NotNull Variance positionVariance) {
|
||||||
|
assert !unknownTypes.containsKey(typeParameterDescriptor);
|
||||||
|
UnknownType typeValue = new UnknownType(typeParameterDescriptor, positionVariance);
|
||||||
|
unknownTypes.put(typeParameterDescriptor, typeValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private UnknownType getTypeVariable(TypeParameterDescriptor typeParameterDescriptor) {
|
||||||
|
UnknownType unknownType = unknownTypes.get(typeParameterDescriptor);
|
||||||
|
if (unknownType == null) {
|
||||||
|
throw new IllegalArgumentException("This type parameter is not an unknown in this constraint system");
|
||||||
|
}
|
||||||
|
return unknownType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addSubtypingConstraint(JetType lower, JetType upper) {
|
||||||
|
TypeValue typeValueForLower = getTypeValueFor(lower);
|
||||||
|
TypeValue typeValueForUpper = getTypeValueFor(upper);
|
||||||
|
addSubtypingConstraintOnTypeValues(typeValueForLower, typeValueForUpper);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addSubtypingConstraintOnTypeValues(TypeValue typeValueForLower, TypeValue typeValueForUpper) {
|
||||||
|
System.out.println(typeValueForLower + " :< " + typeValueForUpper);
|
||||||
|
typeValueForLower.getUpperBounds().add(typeValueForUpper);
|
||||||
|
typeValueForUpper.getLowerBounds().add(typeValueForLower);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public Solution solve() {
|
||||||
|
// Expand custom bounds, e.g. List<T> <: List<Int>
|
||||||
|
for (Map.Entry<JetType, KnownType> entry : Sets.newHashSet(knownTypes.entrySet())) {
|
||||||
|
JetType jetType = entry.getKey();
|
||||||
|
KnownType typeValue = entry.getValue();
|
||||||
|
|
||||||
|
for (TypeValue upperBound : typeValue.getUpperBounds()) {
|
||||||
|
if (upperBound instanceof KnownType) {
|
||||||
|
KnownType knownBoundType = (KnownType) upperBound;
|
||||||
|
boolean ok = new TypeConstraintExpander().run(jetType, knownBoundType.getType());
|
||||||
|
if (!ok) {
|
||||||
|
return new Solution(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lower bounds?
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fill in upper bounds from type parameter bounds
|
||||||
|
for (Map.Entry<TypeParameterDescriptor, UnknownType> entry : Sets.newHashSet(unknownTypes.entrySet())) {
|
||||||
|
TypeParameterDescriptor typeParameterDescriptor = entry.getKey();
|
||||||
|
UnknownType typeValue = entry.getValue();
|
||||||
|
for (JetType upperBound : typeParameterDescriptor.getUpperBounds()) {
|
||||||
|
addSubtypingConstraintOnTypeValues(typeValue, getTypeValueFor(upperBound));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// effective bounds for each node
|
||||||
|
Set<TypeValue> visited = Sets.newHashSet();
|
||||||
|
for (KnownType knownType : knownTypes.values()) {
|
||||||
|
transitiveClosure(knownType, visited);
|
||||||
|
}
|
||||||
|
for (UnknownType unknownType : unknownTypes.values()) {
|
||||||
|
transitiveClosure(unknownType, visited);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find inconsistencies
|
||||||
|
Solution solution = new Solution(false);
|
||||||
|
|
||||||
|
for (UnknownType unknownType : unknownTypes.values()) {
|
||||||
|
check(unknownType, solution);
|
||||||
|
}
|
||||||
|
for (KnownType knownType : knownTypes.values()) {
|
||||||
|
check(knownType, solution);
|
||||||
|
}
|
||||||
|
|
||||||
|
return solution;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void check(TypeValue typeValue, Solution solution) {
|
||||||
|
try {
|
||||||
|
KnownType resultingValue = typeValue.getValue();
|
||||||
|
JetType type = solution.getSubstitutor().substitute(resultingValue.getType(), Variance.INVARIANT); // TODO
|
||||||
|
for (TypeValue upperBound : typeValue.getUpperBounds()) {
|
||||||
|
JetType boundingType = solution.getSubstitutor().substitute(upperBound.getValue().getType(), Variance.INVARIANT);
|
||||||
|
if (!typeChecker.isSubtypeOf(type, boundingType)) { // TODO
|
||||||
|
solution.registerError();
|
||||||
|
System.out.println("Constraint violation: " + type + " :< " + boundingType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (TypeValue lowerBound : typeValue.getLowerBounds()) {
|
||||||
|
JetType boundingType = solution.getSubstitutor().substitute(lowerBound.getValue().getType(), Variance.INVARIANT);
|
||||||
|
if (!typeChecker.isSubtypeOf(boundingType, type)) {
|
||||||
|
solution.registerError();
|
||||||
|
System.out.println("Constraint violation: " + boundingType + " :< " + type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (LoopInTypeVariableConstraintsException e) {
|
||||||
|
solution.registerError();
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void transitiveClosure(TypeValue current, Set<TypeValue> visited) {
|
||||||
|
if (!visited.add(current)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (TypeValue upperBound : Sets.newHashSet(current.getUpperBounds())) {
|
||||||
|
transitiveClosure(upperBound, visited);
|
||||||
|
Set<TypeValue> upperBounds = upperBound.getUpperBounds();
|
||||||
|
for (TypeValue transitiveBound : upperBounds) {
|
||||||
|
addSubtypingConstraintOnTypeValues(current, transitiveBound);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Solution {
|
||||||
|
private final TypeSubstitutor typeSubstitutor = TypeSubstitutor.create(new TypeSubstitutor.TypeSubstitution() {
|
||||||
|
@Override
|
||||||
|
public TypeProjection get(TypeConstructor key) {
|
||||||
|
DeclarationDescriptor declarationDescriptor = key.getDeclarationDescriptor();
|
||||||
|
if (declarationDescriptor instanceof TypeParameterDescriptor) {
|
||||||
|
TypeParameterDescriptor descriptor = (TypeParameterDescriptor) declarationDescriptor;
|
||||||
|
System.out.println(descriptor + " |-> " + getValue(descriptor));
|
||||||
|
return new TypeProjection(getValue(descriptor));
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
private boolean failed;
|
||||||
|
|
||||||
|
public Solution(boolean failed) {
|
||||||
|
this.failed = failed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerError() {
|
||||||
|
failed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSuccessful() {
|
||||||
|
return !failed;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public JetType getValue(TypeParameterDescriptor typeParameterDescriptor) {
|
||||||
|
KnownType value = getTypeVariable(typeParameterDescriptor).getValue();
|
||||||
|
return value == null ? null : value.getType();
|
||||||
|
}
|
||||||
|
|
||||||
|
public TypeSubstitutor getSubstitutor() {
|
||||||
|
return typeSubstitutor;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TypeConstraintExpander extends JetTypeChecker.AbstractTypeCheckingProcedure<Boolean> {
|
||||||
|
|
||||||
|
private boolean error = false;
|
||||||
|
|
||||||
|
private StatusAction fail() {
|
||||||
|
error = true;
|
||||||
|
return StatusAction.ABORT_ALL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected StatusAction startForPairOfTypes(@NotNull JetType subtype, @NotNull JetType supertype) {
|
||||||
|
return tryToAddConstraint(subtype, supertype);
|
||||||
|
}
|
||||||
|
|
||||||
|
private StatusAction tryToAddConstraint(@NotNull JetType subtype, @NotNull JetType supertype) {
|
||||||
|
TypeValue subtypeValue = getTypeValueFor(subtype);
|
||||||
|
TypeValue supertypeValue = getTypeValueFor(supertype);
|
||||||
|
|
||||||
|
if (someUnknown(subtypeValue, supertypeValue)) {
|
||||||
|
addSubtypingConstraintOnTypeValues(subtypeValue, supertypeValue);
|
||||||
|
}
|
||||||
|
return StatusAction.PROCEED;
|
||||||
|
|
||||||
|
// // both types are known
|
||||||
|
// if (typeChecker.isSubtypeOf(subtype, supertype)) {
|
||||||
|
// return StatusAction.PROCEED;
|
||||||
|
// }
|
||||||
|
// return fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean someUnknown(TypeValue subtypeValue, TypeValue supertypeValue) {
|
||||||
|
return subtypeValue instanceof UnknownType || supertypeValue instanceof UnknownType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected StatusAction noCorrespondingSupertype(@NotNull JetType subtype, @NotNull JetType supertype) {
|
||||||
|
if (someUnknown(getTypeValueFor(subtype), getTypeValueFor(supertype))) {
|
||||||
|
return StatusAction.PROCEED;
|
||||||
|
}
|
||||||
|
return fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected StatusAction equalTypesRequired(@NotNull JetType subArgumentType, @NotNull JetType superArgumentType) {
|
||||||
|
if (!subArgumentType.equals(superArgumentType)) {
|
||||||
|
return fail();
|
||||||
|
}
|
||||||
|
return StatusAction.PROCEED;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected StatusAction varianceConflictFound(@NotNull TypeProjection subArgument, @NotNull TypeProjection superArgument) {
|
||||||
|
return fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected StatusAction doneForPairOfTypes(@NotNull JetType subtype, @NotNull JetType supertype) {
|
||||||
|
return StatusAction.PROCEED;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Boolean result() {
|
||||||
|
return !error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -8,6 +8,7 @@ import org.jetbrains.jet.lang.psi.JetFile;
|
|||||||
import org.jetbrains.jet.lang.psi.JetReferenceExpression;
|
import org.jetbrains.jet.lang.psi.JetReferenceExpression;
|
||||||
import org.jetbrains.jet.lang.resolve.AnalyzingUtils;
|
import org.jetbrains.jet.lang.resolve.AnalyzingUtils;
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||||
|
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||||
import org.jetbrains.jet.resolve.DescriptorRenderer;
|
import org.jetbrains.jet.resolve.DescriptorRenderer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -26,13 +27,13 @@ public class JetQuickDocumentationProvider extends AbstractDocumentationProvider
|
|||||||
}
|
}
|
||||||
if (ref != null) {
|
if (ref != null) {
|
||||||
BindingContext bindingContext = AnalyzingUtils.analyzeFileWithCache((JetFile) element.getContainingFile());
|
BindingContext bindingContext = AnalyzingUtils.analyzeFileWithCache((JetFile) element.getContainingFile());
|
||||||
DeclarationDescriptor declarationDescriptor = bindingContext.resolveReferenceExpression(ref);
|
DeclarationDescriptor declarationDescriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, ref);
|
||||||
if (declarationDescriptor != null) {
|
if (declarationDescriptor != null) {
|
||||||
return render(declarationDescriptor);
|
return render(declarationDescriptor);
|
||||||
}
|
}
|
||||||
PsiElement psiElement = bindingContext.resolveToDeclarationPsiElement(ref);
|
PsiElement psiElement = BindingContextUtils.resolveToDeclarationPsiElement(bindingContext, ref);
|
||||||
if (psiElement != null) {
|
if (psiElement != null) {
|
||||||
declarationDescriptor = bindingContext.getDeclarationDescriptor(psiElement);
|
declarationDescriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, psiElement);
|
||||||
if (declarationDescriptor != null) {
|
if (declarationDescriptor != null) {
|
||||||
return render(declarationDescriptor);
|
return render(declarationDescriptor);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public class ShowExpressionTypeAction extends AnAction {
|
|||||||
else {
|
else {
|
||||||
int offset = editor.getCaretModel().getOffset();
|
int offset = editor.getCaretModel().getOffset();
|
||||||
expression = PsiTreeUtil.getParentOfType(psiFile.findElementAt(offset), JetExpression.class);
|
expression = PsiTreeUtil.getParentOfType(psiFile.findElementAt(offset), JetExpression.class);
|
||||||
while (expression != null && bindingContext.getExpressionType(expression) == null) {
|
while (expression != null && bindingContext.get(BindingContext.EXPRESSION_TYPE, expression) == null) {
|
||||||
expression = PsiTreeUtil.getParentOfType(expression, JetExpression.class);
|
expression = PsiTreeUtil.getParentOfType(expression, JetExpression.class);
|
||||||
}
|
}
|
||||||
if (expression != null) {
|
if (expression != null) {
|
||||||
@@ -45,7 +45,7 @@ public class ShowExpressionTypeAction extends AnAction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (expression != null) {
|
if (expression != null) {
|
||||||
JetType type = bindingContext.getExpressionType(expression);
|
JetType type = bindingContext.get(BindingContext.EXPRESSION_TYPE, expression);
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
HintManager.getInstance().showInformationHint(editor, type.toString());
|
HintManager.getInstance().showInformationHint(editor, type.toString());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,10 +16,7 @@ import com.intellij.psi.PsiElement;
|
|||||||
import com.intellij.psi.util.PsiTreeUtil;
|
import com.intellij.psi.util.PsiTreeUtil;
|
||||||
import com.intellij.psi.util.PsiUtilBase;
|
import com.intellij.psi.util.PsiUtilBase;
|
||||||
import com.intellij.ui.awt.RelativePoint;
|
import com.intellij.ui.awt.RelativePoint;
|
||||||
import com.intellij.util.Function;
|
import com.intellij.util.*;
|
||||||
import com.intellij.util.Icons;
|
|
||||||
import com.intellij.util.PsiIconUtil;
|
|
||||||
import com.intellij.util.PsiNavigateUtil;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.lang.descriptors.*;
|
import org.jetbrains.jet.lang.descriptors.*;
|
||||||
import org.jetbrains.jet.lang.psi.*;
|
import org.jetbrains.jet.lang.psi.*;
|
||||||
@@ -49,14 +46,14 @@ public class JetLineMarkerProvider implements LineMarkerProvider {
|
|||||||
|
|
||||||
if (element instanceof JetClass) {
|
if (element instanceof JetClass) {
|
||||||
JetClass jetClass = (JetClass) element;
|
JetClass jetClass = (JetClass) element;
|
||||||
ClassDescriptor classDescriptor = bindingContext.getClassDescriptor(jetClass);
|
ClassDescriptor classDescriptor = bindingContext.get(BindingContext.CLASS, jetClass);
|
||||||
String text = classDescriptor == null ? "<i>Unresolved</i>" : DescriptorRenderer.HTML.render(classDescriptor);
|
String text = classDescriptor == null ? "<i>Unresolved</i>" : DescriptorRenderer.HTML.render(classDescriptor);
|
||||||
return createLineMarkerInfo(jetClass, text);
|
return createLineMarkerInfo(jetClass, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (element instanceof JetProperty) {
|
if (element instanceof JetProperty) {
|
||||||
JetProperty jetProperty = (JetProperty) element;
|
JetProperty jetProperty = (JetProperty) element;
|
||||||
final VariableDescriptor variableDescriptor = bindingContext.getVariableDescriptor(jetProperty);
|
final VariableDescriptor variableDescriptor = bindingContext.get(BindingContext.VARIABLE, jetProperty);
|
||||||
if (variableDescriptor instanceof PropertyDescriptor) {
|
if (variableDescriptor instanceof PropertyDescriptor) {
|
||||||
return createLineMarkerInfo(element, DescriptorRenderer.HTML.render(variableDescriptor));
|
return createLineMarkerInfo(element, DescriptorRenderer.HTML.render(variableDescriptor));
|
||||||
}
|
}
|
||||||
@@ -65,10 +62,10 @@ public class JetLineMarkerProvider implements LineMarkerProvider {
|
|||||||
if (element instanceof JetNamedFunction) {
|
if (element instanceof JetNamedFunction) {
|
||||||
JetNamedFunction jetFunction = (JetNamedFunction) element;
|
JetNamedFunction jetFunction = (JetNamedFunction) element;
|
||||||
|
|
||||||
final FunctionDescriptor functionDescriptor = bindingContext.getFunctionDescriptor(jetFunction);
|
final FunctionDescriptor functionDescriptor = bindingContext.get(BindingContext.FUNCTION, jetFunction);
|
||||||
if (functionDescriptor == null) return null;
|
if (functionDescriptor == null) return null;
|
||||||
final Set<? extends FunctionDescriptor> overriddenFunctions = functionDescriptor.getOverriddenFunctions();
|
final Set<? extends FunctionDescriptor> overriddenFunctions = functionDescriptor.getOverriddenFunctions();
|
||||||
Icon icon = isMember(functionDescriptor) ? (overriddenFunctions.isEmpty() ? Icons.METHOD_ICON : OVERRIDING_FUNCTION) : Icons.FUNCTION_ICON;
|
Icon icon = isMember(functionDescriptor) ? (overriddenFunctions.isEmpty() ? PlatformIcons.METHOD_ICON : OVERRIDING_FUNCTION) : PlatformIcons.FUNCTION_ICON;
|
||||||
return new LineMarkerInfo<JetNamedFunction>(
|
return new LineMarkerInfo<JetNamedFunction>(
|
||||||
jetFunction, jetFunction.getTextOffset(), icon, Pass.UPDATE_ALL,
|
jetFunction, jetFunction.getTextOffset(), icon, Pass.UPDATE_ALL,
|
||||||
new Function<JetNamedFunction, String>() {
|
new Function<JetNamedFunction, String>() {
|
||||||
@@ -97,7 +94,7 @@ public class JetLineMarkerProvider implements LineMarkerProvider {
|
|||||||
if (overriddenFunctions.isEmpty()) return;
|
if (overriddenFunctions.isEmpty()) return;
|
||||||
final List<PsiElement> list = Lists.newArrayList();
|
final List<PsiElement> list = Lists.newArrayList();
|
||||||
for (FunctionDescriptor overriddenFunction : overriddenFunctions) {
|
for (FunctionDescriptor overriddenFunction : overriddenFunctions) {
|
||||||
PsiElement declarationPsiElement = bindingContext.getDeclarationPsiElement(overriddenFunction);
|
PsiElement declarationPsiElement = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, overriddenFunction);
|
||||||
list.add(declarationPsiElement);
|
list.add(declarationPsiElement);
|
||||||
}
|
}
|
||||||
if (list.isEmpty()) {
|
if (list.isEmpty()) {
|
||||||
@@ -118,7 +115,7 @@ public class JetLineMarkerProvider implements LineMarkerProvider {
|
|||||||
public String getElementText(PsiElement element) {
|
public String getElementText(PsiElement element) {
|
||||||
if (element instanceof JetNamedFunction) {
|
if (element instanceof JetNamedFunction) {
|
||||||
JetNamedFunction function = (JetNamedFunction) element;
|
JetNamedFunction function = (JetNamedFunction) element;
|
||||||
return DescriptorRenderer.HTML.render(bindingContext.getFunctionDescriptor(function));
|
return DescriptorRenderer.HTML.render(bindingContext.get(BindingContext.FUNCTION, function));
|
||||||
}
|
}
|
||||||
return super.getElementText(element);
|
return super.getElementText(element);
|
||||||
}
|
}
|
||||||
@@ -134,18 +131,18 @@ public class JetLineMarkerProvider implements LineMarkerProvider {
|
|||||||
|
|
||||||
if (element instanceof JetNamespace) {
|
if (element instanceof JetNamespace) {
|
||||||
return createLineMarkerInfo((JetNamespace) element,
|
return createLineMarkerInfo((JetNamespace) element,
|
||||||
DescriptorRenderer.HTML.render(bindingContext.getNamespaceDescriptor((JetNamespace) element)));
|
DescriptorRenderer.HTML.render(bindingContext.get(BindingContext.NAMESPACE, element)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (element instanceof JetObjectDeclaration && !(element.getParent() instanceof JetExpression)) {
|
if (element instanceof JetObjectDeclaration && !(element.getParent() instanceof JetExpression)) {
|
||||||
JetObjectDeclaration jetObjectDeclaration = (JetObjectDeclaration) element;
|
JetObjectDeclaration jetObjectDeclaration = (JetObjectDeclaration) element;
|
||||||
|
|
||||||
return new LineMarkerInfo<JetObjectDeclaration>(
|
return new LineMarkerInfo<JetObjectDeclaration>(
|
||||||
jetObjectDeclaration, jetObjectDeclaration.getTextOffset(), Icons.ANONYMOUS_CLASS_ICON, Pass.UPDATE_ALL,
|
jetObjectDeclaration, jetObjectDeclaration.getTextOffset(), PlatformIcons.ANONYMOUS_CLASS_ICON, Pass.UPDATE_ALL,
|
||||||
new Function<JetObjectDeclaration, String>() {
|
new Function<JetObjectDeclaration, String>() {
|
||||||
@Override
|
@Override
|
||||||
public String fun(JetObjectDeclaration jetObjectDeclaration) {
|
public String fun(JetObjectDeclaration jetObjectDeclaration) {
|
||||||
ClassDescriptor classDescriptor = bindingContext.getClassDescriptor(jetObjectDeclaration);
|
ClassDescriptor classDescriptor = bindingContext.get(BindingContext.CLASS, jetObjectDeclaration);
|
||||||
if (classDescriptor != null) {
|
if (classDescriptor != null) {
|
||||||
return DescriptorRenderer.HTML.renderAsObject(classDescriptor);
|
return DescriptorRenderer.HTML.renderAsObject(classDescriptor);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ public class JetPsiChecker implements Annotator {
|
|||||||
|
|
||||||
private void markRedeclaration(DeclarationDescriptor redeclaration) {
|
private void markRedeclaration(DeclarationDescriptor redeclaration) {
|
||||||
if (!redeclarations.add(redeclaration)) return;
|
if (!redeclarations.add(redeclaration)) return;
|
||||||
PsiElement declarationPsiElement = bindingContext.getDeclarationPsiElement(redeclaration);
|
PsiElement declarationPsiElement = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, redeclaration);
|
||||||
if (declarationPsiElement instanceof JetNamedDeclaration) {
|
if (declarationPsiElement instanceof JetNamedDeclaration) {
|
||||||
PsiElement nameIdentifier = ((JetNamedDeclaration) declarationPsiElement).getNameIdentifier();
|
PsiElement nameIdentifier = ((JetNamedDeclaration) declarationPsiElement).getNameIdentifier();
|
||||||
assert nameIdentifier != null : declarationPsiElement.getText() + " has nameIdentifier 'null'";
|
assert nameIdentifier != null : declarationPsiElement.getText() + " has nameIdentifier 'null'";
|
||||||
@@ -106,7 +106,7 @@ public class JetPsiChecker implements Annotator {
|
|||||||
file.acceptChildren(new JetVisitorVoid() {
|
file.acceptChildren(new JetVisitorVoid() {
|
||||||
@Override
|
@Override
|
||||||
public void visitExpression(JetExpression expression) {
|
public void visitExpression(JetExpression expression) {
|
||||||
JetType autoCast = bindingContext.getAutoCastType(expression);
|
JetType autoCast = bindingContext.get(BindingContext.AUTOCAST, expression);
|
||||||
if (autoCast != null) {
|
if (autoCast != null) {
|
||||||
holder.createInfoAnnotation(expression, "Automatically cast to " + autoCast).setTextAttributes(JetHighlighter.JET_AUTO_CAST_EXPRESSION);
|
holder.createInfoAnnotation(expression, "Automatically cast to " + autoCast).setTextAttributes(JetHighlighter.JET_AUTO_CAST_EXPRESSION);
|
||||||
}
|
}
|
||||||
@@ -135,9 +135,9 @@ public class JetPsiChecker implements Annotator {
|
|||||||
file.acceptChildren(new JetVisitorVoid() {
|
file.acceptChildren(new JetVisitorVoid() {
|
||||||
@Override
|
@Override
|
||||||
public void visitProperty(JetProperty property) {
|
public void visitProperty(JetProperty property) {
|
||||||
VariableDescriptor propertyDescriptor = bindingContext.getVariableDescriptor(property);
|
VariableDescriptor propertyDescriptor = bindingContext.get(BindingContext.VARIABLE, property);
|
||||||
if (propertyDescriptor instanceof PropertyDescriptor) {
|
if (propertyDescriptor instanceof PropertyDescriptor) {
|
||||||
if (bindingContext.hasBackingField((PropertyDescriptor) propertyDescriptor)) {
|
if ((boolean) bindingContext.get(BindingContext.BACKING_FIELD_REQUIRED, (PropertyDescriptor) propertyDescriptor)) {
|
||||||
putBackingfieldAnnotation(holder, property);
|
putBackingfieldAnnotation(holder, property);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -145,8 +145,8 @@ public class JetPsiChecker implements Annotator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitParameter(JetParameter parameter) {
|
public void visitParameter(JetParameter parameter) {
|
||||||
PropertyDescriptor propertyDescriptor = bindingContext.getPropertyDescriptor(parameter);
|
PropertyDescriptor propertyDescriptor = bindingContext.get(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, parameter);
|
||||||
if (propertyDescriptor != null && bindingContext.hasBackingField(propertyDescriptor)) {
|
if (propertyDescriptor != null && bindingContext.get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor)) {
|
||||||
putBackingfieldAnnotation(holder, parameter);
|
putBackingfieldAnnotation(holder, parameter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package org.jetbrains.jet.util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author abreslav
|
||||||
|
*/
|
||||||
|
public class BasicWritableSlice<K, V> implements WritableSlice<K,V> {
|
||||||
|
|
||||||
|
private final String debugName;
|
||||||
|
private final RewritePolicy rewritePolicy;
|
||||||
|
|
||||||
|
public BasicWritableSlice(String debugName, RewritePolicy rewritePolicy) {
|
||||||
|
this.debugName = debugName;
|
||||||
|
this.rewritePolicy = rewritePolicy;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ManyMapKey<K, V> makeKey(K key) {
|
||||||
|
return new ManyMapKey<K, V>(this, key);
|
||||||
|
}
|
||||||
|
|
||||||
|
// True to put, false to skip
|
||||||
|
@Override
|
||||||
|
public boolean check(K key, V value) {
|
||||||
|
assert key != null;
|
||||||
|
assert value != null;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterPut(MutableManyMap manyMap, K key, V value) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public V computeValue(ManyMap map, K key, V value, boolean valueNotFound) {
|
||||||
|
if (valueNotFound) assert value == null;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RewritePolicy getRewritePolicy() {
|
||||||
|
return rewritePolicy;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return debugName;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package org.jetbrains.jet.util;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author abreslav
|
||||||
|
*/
|
||||||
|
public interface ManyMap extends Iterable<Map.Entry<ManyMapKey<?, ?>, ?>> {
|
||||||
|
<K, V> V get(ReadOnlySlice<K, V> slice, K key);
|
||||||
|
|
||||||
|
<K, V> boolean containsKey(ReadOnlySlice<K, V> slice, K key);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
package org.jetbrains.jet.util;
|
||||||
|
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author abreslav
|
||||||
|
*/
|
||||||
|
public class ManyMapImpl implements MutableManyMap {
|
||||||
|
|
||||||
|
public static ManyMapImpl create() {
|
||||||
|
return new ManyMapImpl(Maps.<ManyMapKey<?, ?>, Object>newLinkedHashMap());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ManyMapImpl create(Map<ManyMapKey<?, ?>, Object> map) {
|
||||||
|
return new ManyMapImpl(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ManyMapImpl create(MapSupplier mapSupplier) {
|
||||||
|
return new ManyMapImpl(mapSupplier.<ManyMapKey<?, ?>, Object>get());
|
||||||
|
}
|
||||||
|
|
||||||
|
private final Map<ManyMapKey<?, ?>, Object> map;
|
||||||
|
|
||||||
|
private ManyMapImpl(Map<ManyMapKey<?, ?>, Object> map) {
|
||||||
|
this.map = map;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <K, V> void put(WritableSlice<K, V> slice, K key, V value) {
|
||||||
|
if (!slice.check(key, value)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ManyMapKey<K, V> manyMapKey = slice.makeKey(key);
|
||||||
|
if (slice.getRewritePolicy().rewriteProcessingNeeded(key)) {
|
||||||
|
if (map.containsKey(manyMapKey)) {
|
||||||
|
//noinspection unchecked
|
||||||
|
if (!slice.getRewritePolicy().processRewrite(slice, key, (V) map.get(manyMapKey), value)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
map.put(manyMapKey, value);
|
||||||
|
slice.afterPut(this, key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <K, V> V get(ReadOnlySlice<K, V> slice, K key) {
|
||||||
|
ManyMapKey<K, V> manyMapKey = slice.makeKey(key);
|
||||||
|
//noinspection unchecked
|
||||||
|
V value = (V) map.get(manyMapKey);
|
||||||
|
return slice.computeValue(this, key, value, value == null && !map.containsKey(manyMapKey));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <K, V> boolean containsKey(ReadOnlySlice<K, V> slice, K key) {
|
||||||
|
return map.containsKey(slice.makeKey(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <K, V> V remove(RemovableSlice<K, V> slice, K key) {
|
||||||
|
//noinspection unchecked
|
||||||
|
return (V) map.remove(slice.makeKey(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterator<Map.Entry<ManyMapKey<?, ?>, ?>> iterator() {
|
||||||
|
//noinspection unchecked
|
||||||
|
return (Iterator) map.entrySet().iterator();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package org.jetbrains.jet.util;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author abreslav
|
||||||
|
*/
|
||||||
|
public final class ManyMapKey<K, V> {
|
||||||
|
|
||||||
|
private final WritableSlice<K, V> slice;
|
||||||
|
private final K key;
|
||||||
|
|
||||||
|
public ManyMapKey(@NotNull WritableSlice<K, V> slice, K key) {
|
||||||
|
this.slice = slice;
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WritableSlice<K, V> getSlice() {
|
||||||
|
return slice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public K getKey() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
|
||||||
|
ManyMapKey that = (ManyMapKey) o;
|
||||||
|
|
||||||
|
if (key != null ? !key.equals(that.key) : that.key != null) return false;
|
||||||
|
if (!slice.equals(that.slice)) return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int result = slice.hashCode();
|
||||||
|
result = 31 * result + (key != null ? key.hashCode() : 0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,175 @@
|
|||||||
|
package org.jetbrains.jet.util;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author abreslav
|
||||||
|
*/
|
||||||
|
public class ManyMapSlices {
|
||||||
|
|
||||||
|
public static final RewritePolicy ONLY_REWRITE_TO_EQUAL = new RewritePolicy() {
|
||||||
|
@Override
|
||||||
|
public <K> boolean rewriteProcessingNeeded(K key) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <K, V> boolean processRewrite(WritableSlice<K, V> slice, K key, V oldValue, V newValue) {
|
||||||
|
assert (oldValue == null && newValue == null) || (oldValue != null && oldValue.equals(newValue))
|
||||||
|
: "Rewrite at slice " + slice + " key: " + key + " old value: " + oldValue + " new value: " + newValue;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public interface KeyNormalizer<K> {
|
||||||
|
|
||||||
|
KeyNormalizer DO_NOTHING = new KeyNormalizer<Object>() {
|
||||||
|
@Override
|
||||||
|
public Object normalize(Object key) {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
K normalize(K key);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <K, V> SliceBuilder<K, V> sliceBuilder(String debugName) {
|
||||||
|
return new SliceBuilder<K, V>(debugName, ONLY_REWRITE_TO_EQUAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <K, V> WritableSlice<K, V> createSimpleSlice(String debugName) {
|
||||||
|
return new BasicWritableSlice<K, V>(debugName, ONLY_REWRITE_TO_EQUAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <K> WritableSlice<K, Boolean> createSimpleSetSlice(String debugName) {
|
||||||
|
return createRemovableSetSlice(debugName);
|
||||||
|
}
|
||||||
|
public static <K> RemovableSlice<K, Boolean> createRemovableSetSlice(String debugName) {
|
||||||
|
return new SetSlice<K>(debugName, RewritePolicy.DO_NOTHING);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class SliceBuilder<K, V> {
|
||||||
|
private V defaultValue = null;
|
||||||
|
private List<ReadOnlySlice<K, V>> furtherLookupSlices = null;
|
||||||
|
private WritableSlice<? super V, ? super K> opposite = null;
|
||||||
|
private KeyNormalizer<K> keyNormalizer = null;
|
||||||
|
|
||||||
|
private RewritePolicy rewritePolicy;
|
||||||
|
|
||||||
|
private String debugName;
|
||||||
|
|
||||||
|
private SliceBuilder(String debugName, RewritePolicy rewritePolicy) {
|
||||||
|
this.rewritePolicy = rewritePolicy;
|
||||||
|
this.debugName = debugName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SliceBuilder<K, V> setDefaultValue(V defaultValue) {
|
||||||
|
this.defaultValue = defaultValue;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SliceBuilder<K, V> setFurtherLookupSlices(ReadOnlySlice<K, V>... furtherLookupSlices) {
|
||||||
|
this.furtherLookupSlices = Arrays.asList(furtherLookupSlices);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SliceBuilder<K, V> setOpposite(WritableSlice<? super V, ? super K> opposite) {
|
||||||
|
this.opposite = opposite;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SliceBuilder<K, V> setKeyNormalizer(KeyNormalizer<K> keyNormalizer) {
|
||||||
|
this.keyNormalizer = keyNormalizer;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RemovableSlice<K, V> build() {
|
||||||
|
if (defaultValue != null) {
|
||||||
|
return new SliceWithOpposite<K, V>(debugName, rewritePolicy, opposite, keyNormalizer) {
|
||||||
|
@Override
|
||||||
|
public V computeValue(ManyMap map, K key, V value, boolean valueNotFound) {
|
||||||
|
if (valueNotFound) return defaultValue;
|
||||||
|
return super.computeValue(map, key, value, valueNotFound);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (furtherLookupSlices != null) {
|
||||||
|
return new SliceWithOpposite<K, V>(debugName, rewritePolicy, opposite, keyNormalizer) {
|
||||||
|
@Override
|
||||||
|
public V computeValue(ManyMap map, K key, V value, boolean valueNotFound) {
|
||||||
|
if (valueNotFound) {
|
||||||
|
for (ReadOnlySlice<K, V> slice : furtherLookupSlices) {
|
||||||
|
if (map.containsKey(slice, key)) {
|
||||||
|
return map.get(slice, key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
return super.computeValue(map, key, value, valueNotFound);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return new SliceWithOpposite<K, V>(debugName, rewritePolicy, opposite, keyNormalizer);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class BasicRemovableSlice<K, V> extends BasicWritableSlice<K, V> implements RemovableSlice<K, V> {
|
||||||
|
protected BasicRemovableSlice(String debugName, RewritePolicy rewritePolicy) {
|
||||||
|
super(debugName, rewritePolicy);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class SliceWithOpposite<K, V> extends BasicRemovableSlice<K, V> {
|
||||||
|
private final WritableSlice<? super V, ? super K> opposite;
|
||||||
|
|
||||||
|
|
||||||
|
private final KeyNormalizer<K> keyNormalizer;
|
||||||
|
|
||||||
|
public SliceWithOpposite(String debugName, RewritePolicy rewritePolicy) {
|
||||||
|
this(debugName, rewritePolicy, KeyNormalizer.DO_NOTHING);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SliceWithOpposite(String debugName, RewritePolicy rewritePolicy, KeyNormalizer<K> keyNormalizer) {
|
||||||
|
this(debugName, rewritePolicy, null, keyNormalizer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SliceWithOpposite(String debugName, RewritePolicy rewritePolicy, WritableSlice<? super V, ? super K> opposite, KeyNormalizer<K> keyNormalizer) {
|
||||||
|
super(debugName, rewritePolicy);
|
||||||
|
this.opposite = opposite;
|
||||||
|
this.keyNormalizer = keyNormalizer;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterPut(MutableManyMap manyMap, K key, V value) {
|
||||||
|
if (opposite != null) {
|
||||||
|
manyMap.put(opposite, value, key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public ManyMapKey<K, V> makeKey(K key) {
|
||||||
|
if (keyNormalizer == null) {
|
||||||
|
return super.makeKey(key);
|
||||||
|
}
|
||||||
|
return super.makeKey(keyNormalizer.normalize(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class SetSlice<K> extends BasicRemovableSlice<K, Boolean> {
|
||||||
|
|
||||||
|
|
||||||
|
protected SetSlice(String debugName, RewritePolicy rewritePolicy) {
|
||||||
|
super(debugName, rewritePolicy);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public Boolean computeValue(ManyMap map, K key, Boolean value, boolean valueNotFound) {
|
||||||
|
if (valueNotFound) return false;
|
||||||
|
return super.computeValue(map, key, value, valueNotFound);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package org.jetbrains.jet.util;
|
||||||
|
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author abreslav
|
||||||
|
*/
|
||||||
|
public interface MapSupplier {
|
||||||
|
|
||||||
|
MapSupplier HASH_MAP_SUPPLIER = new MapSupplier() {
|
||||||
|
@Override
|
||||||
|
public <K, V> Map<K, V> get() {
|
||||||
|
return Maps.newHashMap();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
MapSupplier LINKED_HASH_MAP_SUPPLIER = new MapSupplier() {
|
||||||
|
@Override
|
||||||
|
public <K, V> Map<K, V> get() {
|
||||||
|
return Maps.newLinkedHashMap();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
<K, V> Map<K, V> get();
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package org.jetbrains.jet.util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author abreslav
|
||||||
|
*/
|
||||||
|
public interface MutableManyMap extends ManyMap {
|
||||||
|
|
||||||
|
<K, V> void put(WritableSlice<K, V> slice, K key, V value);
|
||||||
|
|
||||||
|
<K, V> V remove(RemovableSlice<K, V> slice, K key);
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package org.jetbrains.jet.util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author abreslav
|
||||||
|
*/
|
||||||
|
public interface ReadOnlySlice<K, V> {
|
||||||
|
ManyMapKey<K, V> makeKey(K key);
|
||||||
|
|
||||||
|
V computeValue(ManyMap map, K key, V value, boolean valueNotFound);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package org.jetbrains.jet.util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author abreslav
|
||||||
|
*/
|
||||||
|
public interface RemovableSlice<K, V> extends WritableSlice<K, V> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package org.jetbrains.jet.util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author abreslav
|
||||||
|
*/
|
||||||
|
public interface RewritePolicy {
|
||||||
|
|
||||||
|
RewritePolicy DO_NOTHING = new RewritePolicy() {
|
||||||
|
@Override
|
||||||
|
public <K> boolean rewriteProcessingNeeded(K key) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <K, V> boolean processRewrite(WritableSlice<K, V> slice, K key, V oldValue, V newValue) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
<K> boolean rewriteProcessingNeeded(K key);
|
||||||
|
|
||||||
|
// True to put, false to skip
|
||||||
|
<K, V> boolean processRewrite(WritableSlice<K, V> slice, K key, V oldValue, V newValue);
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package org.jetbrains.jet.util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author abreslav
|
||||||
|
*/
|
||||||
|
public interface WritableSlice<K, V> extends ReadOnlySlice<K, V> {
|
||||||
|
// True to put, false to skip
|
||||||
|
boolean check(K key, V value);
|
||||||
|
|
||||||
|
void afterPut(MutableManyMap manyMap, K key, V value);
|
||||||
|
|
||||||
|
RewritePolicy getRewritePolicy();
|
||||||
|
}
|
||||||
@@ -15,10 +15,11 @@ JetFile: AnnotatedExpressions.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
REFERENCE_EXPRESSION
|
REFERENCE_EXPRESSION
|
||||||
@@ -31,10 +32,11 @@ JetFile: AnnotatedExpressions.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
THIS_EXPRESSION
|
THIS_EXPRESSION
|
||||||
|
|||||||
@@ -38,25 +38,26 @@ JetFile: Attributes.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('foo')
|
REFERENCE_EXPRESSION
|
||||||
TYPE_ARGUMENT_LIST
|
PsiElement(IDENTIFIER)('foo')
|
||||||
PsiElement(LT)('<')
|
TYPE_ARGUMENT_LIST
|
||||||
TYPE_PROJECTION
|
PsiElement(LT)('<')
|
||||||
TYPE_REFERENCE
|
TYPE_PROJECTION
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('A')
|
REFERENCE_EXPRESSION
|
||||||
PsiElement(COMMA)(',')
|
PsiElement(IDENTIFIER)('A')
|
||||||
PsiWhiteSpace(' ')
|
PsiElement(COMMA)(',')
|
||||||
TYPE_PROJECTION
|
PsiWhiteSpace(' ')
|
||||||
TYPE_REFERENCE
|
TYPE_PROJECTION
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('B')
|
REFERENCE_EXPRESSION
|
||||||
PsiElement(GT)('>')
|
PsiElement(IDENTIFIER)('B')
|
||||||
|
PsiElement(GT)('>')
|
||||||
VALUE_ARGUMENT_LIST
|
VALUE_ARGUMENT_LIST
|
||||||
PsiElement(LPAR)('(')
|
PsiElement(LPAR)('(')
|
||||||
VALUE_ARGUMENT
|
VALUE_ARGUMENT
|
||||||
@@ -70,68 +71,71 @@ JetFile: Attributes.jet
|
|||||||
PsiElement(RPAR)(')')
|
PsiElement(RPAR)(')')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('ina')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('ina')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
|
USER_TYPE
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('foo')
|
||||||
|
PsiElement(DOT)('.')
|
||||||
REFERENCE_EXPRESSION
|
REFERENCE_EXPRESSION
|
||||||
PsiElement(IDENTIFIER)('foo')
|
PsiElement(IDENTIFIER)('bar')
|
||||||
PsiElement(DOT)('.')
|
PsiElement(DOT)('.')
|
||||||
REFERENCE_EXPRESSION
|
REFERENCE_EXPRESSION
|
||||||
PsiElement(IDENTIFIER)('bar')
|
PsiElement(IDENTIFIER)('goo')
|
||||||
PsiElement(DOT)('.')
|
PsiElement(DOT)('.')
|
||||||
REFERENCE_EXPRESSION
|
REFERENCE_EXPRESSION
|
||||||
PsiElement(IDENTIFIER)('goo')
|
PsiElement(IDENTIFIER)('doo')
|
||||||
|
TYPE_ARGUMENT_LIST
|
||||||
|
PsiElement(LT)('<')
|
||||||
|
TYPE_PROJECTION
|
||||||
|
TYPE_REFERENCE
|
||||||
|
USER_TYPE
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('f')
|
||||||
|
PsiElement(GT)('>')
|
||||||
PsiElement(DOT)('.')
|
PsiElement(DOT)('.')
|
||||||
REFERENCE_EXPRESSION
|
REFERENCE_EXPRESSION
|
||||||
PsiElement(IDENTIFIER)('doo')
|
PsiElement(IDENTIFIER)('foo')
|
||||||
TYPE_ARGUMENT_LIST
|
TYPE_ARGUMENT_LIST
|
||||||
PsiElement(LT)('<')
|
PsiElement(LT)('<')
|
||||||
TYPE_PROJECTION
|
TYPE_PROJECTION
|
||||||
TYPE_REFERENCE
|
TYPE_REFERENCE
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
REFERENCE_EXPRESSION
|
REFERENCE_EXPRESSION
|
||||||
PsiElement(IDENTIFIER)('f')
|
PsiElement(IDENTIFIER)('bar')
|
||||||
|
PsiElement(COMMA)(',')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
TYPE_PROJECTION
|
||||||
|
TYPE_REFERENCE
|
||||||
|
USER_TYPE
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('goo')
|
||||||
PsiElement(GT)('>')
|
PsiElement(GT)('>')
|
||||||
PsiElement(DOT)('.')
|
PsiElement(DOT)('.')
|
||||||
REFERENCE_EXPRESSION
|
REFERENCE_EXPRESSION
|
||||||
PsiElement(IDENTIFIER)('foo')
|
PsiElement(IDENTIFIER)('foo')
|
||||||
TYPE_ARGUMENT_LIST
|
|
||||||
PsiElement(LT)('<')
|
|
||||||
TYPE_PROJECTION
|
|
||||||
TYPE_REFERENCE
|
|
||||||
USER_TYPE
|
|
||||||
REFERENCE_EXPRESSION
|
|
||||||
PsiElement(IDENTIFIER)('bar')
|
|
||||||
PsiElement(COMMA)(',')
|
|
||||||
PsiWhiteSpace(' ')
|
|
||||||
TYPE_PROJECTION
|
|
||||||
TYPE_REFERENCE
|
|
||||||
USER_TYPE
|
|
||||||
REFERENCE_EXPRESSION
|
|
||||||
PsiElement(IDENTIFIER)('goo')
|
|
||||||
PsiElement(GT)('>')
|
|
||||||
PsiElement(DOT)('.')
|
|
||||||
REFERENCE_EXPRESSION
|
|
||||||
PsiElement(IDENTIFIER)('foo')
|
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace('\n')
|
PsiWhiteSpace('\n')
|
||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('df')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('df')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace('\n')
|
PsiWhiteSpace('\n')
|
||||||
PsiElement(in)('in')
|
PsiElement(in)('in')
|
||||||
@@ -139,10 +143,11 @@ JetFile: Attributes.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('sdfsdf')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('sdfsdf')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace('\n')
|
PsiWhiteSpace('\n')
|
||||||
PsiElement(out)('out')
|
PsiElement(out)('out')
|
||||||
@@ -163,10 +168,11 @@ JetFile: Attributes.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('sdfsdf')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('sdfsdf')
|
||||||
VALUE_ARGUMENT_LIST
|
VALUE_ARGUMENT_LIST
|
||||||
PsiElement(LPAR)('(')
|
PsiElement(LPAR)('(')
|
||||||
VALUE_ARGUMENT
|
VALUE_ARGUMENT
|
||||||
@@ -180,19 +186,21 @@ JetFile: Attributes.jet
|
|||||||
PsiElement(RPAR)(')')
|
PsiElement(RPAR)(')')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace('\n')
|
PsiWhiteSpace('\n')
|
||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('sdfsdf')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('sdfsdf')
|
||||||
VALUE_ARGUMENT_LIST
|
VALUE_ARGUMENT_LIST
|
||||||
PsiElement(LPAR)('(')
|
PsiElement(LPAR)('(')
|
||||||
VALUE_ARGUMENT
|
VALUE_ARGUMENT
|
||||||
@@ -209,19 +217,21 @@ JetFile: Attributes.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
VALUE_ARGUMENT_LIST
|
VALUE_ARGUMENT_LIST
|
||||||
PsiElement(LPAR)('(')
|
PsiElement(LPAR)('(')
|
||||||
PsiElement(RPAR)(')')
|
PsiElement(RPAR)(')')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('sdfsdf')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('sdfsdf')
|
||||||
VALUE_ARGUMENT_LIST
|
VALUE_ARGUMENT_LIST
|
||||||
PsiElement(LPAR)('(')
|
PsiElement(LPAR)('(')
|
||||||
VALUE_ARGUMENT
|
VALUE_ARGUMENT
|
||||||
@@ -250,34 +260,37 @@ JetFile: Attributes.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('sdfsd')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('sdfsd')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('sdfsd')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('sdfsd')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
|
USER_TYPE
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
|
PsiElement(DOT)('.')
|
||||||
REFERENCE_EXPRESSION
|
REFERENCE_EXPRESSION
|
||||||
PsiElement(IDENTIFIER)('a')
|
PsiElement(IDENTIFIER)('b')
|
||||||
PsiElement(DOT)('.')
|
PsiElement(DOT)('.')
|
||||||
REFERENCE_EXPRESSION
|
REFERENCE_EXPRESSION
|
||||||
PsiElement(IDENTIFIER)('b')
|
PsiElement(IDENTIFIER)('f')
|
||||||
PsiElement(DOT)('.')
|
PsiElement(DOT)('.')
|
||||||
REFERENCE_EXPRESSION
|
REFERENCE_EXPRESSION
|
||||||
PsiElement(IDENTIFIER)('f')
|
PsiElement(IDENTIFIER)('c')
|
||||||
PsiElement(DOT)('.')
|
|
||||||
REFERENCE_EXPRESSION
|
|
||||||
PsiElement(IDENTIFIER)('c')
|
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace('\n')
|
PsiWhiteSpace('\n')
|
||||||
PsiElement(private)('private')
|
PsiElement(private)('private')
|
||||||
|
|||||||
@@ -29,10 +29,11 @@ JetFile: AttributesOnPatterns.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
PROPERTY
|
PROPERTY
|
||||||
@@ -53,10 +54,11 @@ JetFile: AttributesOnPatterns.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
PROPERTY
|
PROPERTY
|
||||||
@@ -86,10 +88,11 @@ JetFile: AttributesOnPatterns.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
PsiElement(MUL)('*')
|
PsiElement(MUL)('*')
|
||||||
@@ -107,10 +110,11 @@ JetFile: AttributesOnPatterns.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
INTEGER_CONSTANT
|
INTEGER_CONSTANT
|
||||||
@@ -129,10 +133,11 @@ JetFile: AttributesOnPatterns.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
TYPE_REFERENCE
|
TYPE_REFERENCE
|
||||||
@@ -153,10 +158,11 @@ JetFile: AttributesOnPatterns.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
REFERENCE_EXPRESSION
|
REFERENCE_EXPRESSION
|
||||||
|
|||||||
@@ -44,25 +44,26 @@ JetFile: Attributes_ERR.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('foo')
|
REFERENCE_EXPRESSION
|
||||||
TYPE_ARGUMENT_LIST
|
PsiElement(IDENTIFIER)('foo')
|
||||||
PsiElement(LT)('<')
|
TYPE_ARGUMENT_LIST
|
||||||
TYPE_PROJECTION
|
PsiElement(LT)('<')
|
||||||
TYPE_REFERENCE
|
TYPE_PROJECTION
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('A')
|
REFERENCE_EXPRESSION
|
||||||
PsiElement(COMMA)(',')
|
PsiElement(IDENTIFIER)('A')
|
||||||
PsiWhiteSpace(' ')
|
PsiElement(COMMA)(',')
|
||||||
TYPE_PROJECTION
|
PsiWhiteSpace(' ')
|
||||||
TYPE_REFERENCE
|
TYPE_PROJECTION
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('B')
|
REFERENCE_EXPRESSION
|
||||||
PsiElement(GT)('>')
|
PsiElement(IDENTIFIER)('B')
|
||||||
|
PsiElement(GT)('>')
|
||||||
VALUE_ARGUMENT_LIST
|
VALUE_ARGUMENT_LIST
|
||||||
PsiElement(LPAR)('(')
|
PsiElement(LPAR)('(')
|
||||||
VALUE_ARGUMENT
|
VALUE_ARGUMENT
|
||||||
@@ -78,68 +79,71 @@ JetFile: Attributes_ERR.jet
|
|||||||
PsiElement(COMMA)(',')
|
PsiElement(COMMA)(',')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('ina')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('ina')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
|
USER_TYPE
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('foo')
|
||||||
|
PsiElement(DOT)('.')
|
||||||
REFERENCE_EXPRESSION
|
REFERENCE_EXPRESSION
|
||||||
PsiElement(IDENTIFIER)('foo')
|
PsiElement(IDENTIFIER)('bar')
|
||||||
PsiElement(DOT)('.')
|
PsiElement(DOT)('.')
|
||||||
REFERENCE_EXPRESSION
|
REFERENCE_EXPRESSION
|
||||||
PsiElement(IDENTIFIER)('bar')
|
PsiElement(IDENTIFIER)('goo')
|
||||||
PsiElement(DOT)('.')
|
PsiElement(DOT)('.')
|
||||||
REFERENCE_EXPRESSION
|
REFERENCE_EXPRESSION
|
||||||
PsiElement(IDENTIFIER)('goo')
|
PsiElement(IDENTIFIER)('doo')
|
||||||
|
TYPE_ARGUMENT_LIST
|
||||||
|
PsiElement(LT)('<')
|
||||||
|
TYPE_PROJECTION
|
||||||
|
TYPE_REFERENCE
|
||||||
|
USER_TYPE
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('f')
|
||||||
|
PsiElement(GT)('>')
|
||||||
PsiElement(DOT)('.')
|
PsiElement(DOT)('.')
|
||||||
REFERENCE_EXPRESSION
|
REFERENCE_EXPRESSION
|
||||||
PsiElement(IDENTIFIER)('doo')
|
PsiElement(IDENTIFIER)('foo')
|
||||||
TYPE_ARGUMENT_LIST
|
TYPE_ARGUMENT_LIST
|
||||||
PsiElement(LT)('<')
|
PsiElement(LT)('<')
|
||||||
TYPE_PROJECTION
|
TYPE_PROJECTION
|
||||||
TYPE_REFERENCE
|
TYPE_REFERENCE
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
REFERENCE_EXPRESSION
|
REFERENCE_EXPRESSION
|
||||||
PsiElement(IDENTIFIER)('f')
|
PsiElement(IDENTIFIER)('bar')
|
||||||
|
PsiElement(COMMA)(',')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
TYPE_PROJECTION
|
||||||
|
TYPE_REFERENCE
|
||||||
|
USER_TYPE
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('goo')
|
||||||
PsiElement(GT)('>')
|
PsiElement(GT)('>')
|
||||||
PsiElement(DOT)('.')
|
PsiElement(DOT)('.')
|
||||||
REFERENCE_EXPRESSION
|
REFERENCE_EXPRESSION
|
||||||
PsiElement(IDENTIFIER)('foo')
|
PsiElement(IDENTIFIER)('foo')
|
||||||
TYPE_ARGUMENT_LIST
|
|
||||||
PsiElement(LT)('<')
|
|
||||||
TYPE_PROJECTION
|
|
||||||
TYPE_REFERENCE
|
|
||||||
USER_TYPE
|
|
||||||
REFERENCE_EXPRESSION
|
|
||||||
PsiElement(IDENTIFIER)('bar')
|
|
||||||
PsiElement(COMMA)(',')
|
|
||||||
PsiWhiteSpace(' ')
|
|
||||||
TYPE_PROJECTION
|
|
||||||
TYPE_REFERENCE
|
|
||||||
USER_TYPE
|
|
||||||
REFERENCE_EXPRESSION
|
|
||||||
PsiElement(IDENTIFIER)('goo')
|
|
||||||
PsiElement(GT)('>')
|
|
||||||
PsiElement(DOT)('.')
|
|
||||||
REFERENCE_EXPRESSION
|
|
||||||
PsiElement(IDENTIFIER)('foo')
|
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace('\n')
|
PsiWhiteSpace('\n')
|
||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('df')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('df')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace('\n')
|
PsiWhiteSpace('\n')
|
||||||
PsiElement(in)('in')
|
PsiElement(in)('in')
|
||||||
@@ -147,32 +151,36 @@ JetFile: Attributes_ERR.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('sdfsdf')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('sdfsdf')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace('\n')
|
PsiWhiteSpace('\n')
|
||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('s')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('s')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('fd')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('fd')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('d')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('d')
|
||||||
PsiErrorElement:No commas needed to separate attributes
|
PsiErrorElement:No commas needed to separate attributes
|
||||||
PsiElement(COMMA)(',')
|
PsiElement(COMMA)(',')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
@@ -208,34 +216,37 @@ JetFile: Attributes_ERR.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('sdfsd')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('sdfsd')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('sdfsd')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('sdfsd')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
|
USER_TYPE
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
|
PsiElement(DOT)('.')
|
||||||
REFERENCE_EXPRESSION
|
REFERENCE_EXPRESSION
|
||||||
PsiElement(IDENTIFIER)('a')
|
PsiElement(IDENTIFIER)('b')
|
||||||
PsiElement(DOT)('.')
|
PsiElement(DOT)('.')
|
||||||
REFERENCE_EXPRESSION
|
REFERENCE_EXPRESSION
|
||||||
PsiElement(IDENTIFIER)('b')
|
PsiElement(IDENTIFIER)('f')
|
||||||
PsiElement(DOT)('.')
|
PsiElement(DOT)('.')
|
||||||
REFERENCE_EXPRESSION
|
REFERENCE_EXPRESSION
|
||||||
PsiElement(IDENTIFIER)('f')
|
PsiElement(IDENTIFIER)('c')
|
||||||
PsiElement(DOT)('.')
|
|
||||||
REFERENCE_EXPRESSION
|
|
||||||
PsiElement(IDENTIFIER)('c')
|
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace('\n')
|
PsiWhiteSpace('\n')
|
||||||
PsiElement(private)('private')
|
PsiElement(private)('private')
|
||||||
|
|||||||
@@ -39,10 +39,11 @@ JetFile: BabySteps.jet
|
|||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
DELEGATION_SPECIFIER_LIST
|
DELEGATION_SPECIFIER_LIST
|
||||||
DELEGATOR_SUPER_CALL
|
DELEGATOR_SUPER_CALL
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('foo')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('foo')
|
||||||
VALUE_ARGUMENT_LIST
|
VALUE_ARGUMENT_LIST
|
||||||
PsiElement(LPAR)('(')
|
PsiElement(LPAR)('(')
|
||||||
VALUE_ARGUMENT
|
VALUE_ARGUMENT
|
||||||
|
|||||||
@@ -39,10 +39,11 @@ JetFile: BabySteps_ERR.jet
|
|||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
DELEGATION_SPECIFIER_LIST
|
DELEGATION_SPECIFIER_LIST
|
||||||
DELEGATOR_SUPER_CALL
|
DELEGATOR_SUPER_CALL
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('foo')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('foo')
|
||||||
VALUE_ARGUMENT_LIST
|
VALUE_ARGUMENT_LIST
|
||||||
PsiElement(LPAR)('(')
|
PsiElement(LPAR)('(')
|
||||||
VALUE_ARGUMENT
|
VALUE_ARGUMENT
|
||||||
|
|||||||
@@ -41,18 +41,19 @@ JetFile: Constructors.jet
|
|||||||
PsiElement(COMMA)(',')
|
PsiElement(COMMA)(',')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
DELEGATOR_SUPER_CALL
|
DELEGATOR_SUPER_CALL
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('Foo')
|
REFERENCE_EXPRESSION
|
||||||
TYPE_ARGUMENT_LIST
|
PsiElement(IDENTIFIER)('Foo')
|
||||||
PsiElement(LT)('<')
|
TYPE_ARGUMENT_LIST
|
||||||
TYPE_PROJECTION
|
PsiElement(LT)('<')
|
||||||
TYPE_REFERENCE
|
TYPE_PROJECTION
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('T')
|
REFERENCE_EXPRESSION
|
||||||
PsiElement(GT)('>')
|
PsiElement(IDENTIFIER)('T')
|
||||||
|
PsiElement(GT)('>')
|
||||||
VALUE_ARGUMENT_LIST
|
VALUE_ARGUMENT_LIST
|
||||||
PsiElement(LPAR)('(')
|
PsiElement(LPAR)('(')
|
||||||
VALUE_ARGUMENT
|
VALUE_ARGUMENT
|
||||||
@@ -100,18 +101,19 @@ JetFile: Constructors.jet
|
|||||||
PsiElement(COMMA)(',')
|
PsiElement(COMMA)(',')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
DELEGATOR_SUPER_CALL
|
DELEGATOR_SUPER_CALL
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('Foo')
|
REFERENCE_EXPRESSION
|
||||||
TYPE_ARGUMENT_LIST
|
PsiElement(IDENTIFIER)('Foo')
|
||||||
PsiElement(LT)('<')
|
TYPE_ARGUMENT_LIST
|
||||||
TYPE_PROJECTION
|
PsiElement(LT)('<')
|
||||||
TYPE_REFERENCE
|
TYPE_PROJECTION
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('T')
|
REFERENCE_EXPRESSION
|
||||||
PsiElement(GT)('>')
|
PsiElement(IDENTIFIER)('T')
|
||||||
|
PsiElement(GT)('>')
|
||||||
VALUE_ARGUMENT_LIST
|
VALUE_ARGUMENT_LIST
|
||||||
PsiElement(LPAR)('(')
|
PsiElement(LPAR)('(')
|
||||||
VALUE_ARGUMENT
|
VALUE_ARGUMENT
|
||||||
|
|||||||
@@ -57,10 +57,11 @@ JetFile: EOLsOnRollback.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
PsiElement(var)('var')
|
PsiElement(var)('var')
|
||||||
@@ -80,10 +81,11 @@ JetFile: EOLsOnRollback.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
PsiElement(val)('val')
|
PsiElement(val)('val')
|
||||||
|
|||||||
+41
-36
@@ -37,10 +37,11 @@ JetFile: Enums.jet
|
|||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
INITIALIZER_LIST
|
INITIALIZER_LIST
|
||||||
DELEGATOR_SUPER_CALL
|
DELEGATOR_SUPER_CALL
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('Color')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('Color')
|
||||||
VALUE_ARGUMENT_LIST
|
VALUE_ARGUMENT_LIST
|
||||||
PsiElement(LPAR)('(')
|
PsiElement(LPAR)('(')
|
||||||
VALUE_ARGUMENT
|
VALUE_ARGUMENT
|
||||||
@@ -58,10 +59,11 @@ JetFile: Enums.jet
|
|||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
INITIALIZER_LIST
|
INITIALIZER_LIST
|
||||||
DELEGATOR_SUPER_CALL
|
DELEGATOR_SUPER_CALL
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('Color')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('Color')
|
||||||
VALUE_ARGUMENT_LIST
|
VALUE_ARGUMENT_LIST
|
||||||
PsiElement(LPAR)('(')
|
PsiElement(LPAR)('(')
|
||||||
VALUE_ARGUMENT
|
VALUE_ARGUMENT
|
||||||
@@ -79,10 +81,11 @@ JetFile: Enums.jet
|
|||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
INITIALIZER_LIST
|
INITIALIZER_LIST
|
||||||
DELEGATOR_SUPER_CALL
|
DELEGATOR_SUPER_CALL
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('Color')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('Color')
|
||||||
VALUE_ARGUMENT_LIST
|
VALUE_ARGUMENT_LIST
|
||||||
PsiElement(LPAR)('(')
|
PsiElement(LPAR)('(')
|
||||||
VALUE_ARGUMENT
|
VALUE_ARGUMENT
|
||||||
@@ -135,18 +138,19 @@ JetFile: Enums.jet
|
|||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
INITIALIZER_LIST
|
INITIALIZER_LIST
|
||||||
DELEGATOR_SUPER_CALL
|
DELEGATOR_SUPER_CALL
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('List')
|
REFERENCE_EXPRESSION
|
||||||
TYPE_ARGUMENT_LIST
|
PsiElement(IDENTIFIER)('List')
|
||||||
PsiElement(LT)('<')
|
TYPE_ARGUMENT_LIST
|
||||||
TYPE_PROJECTION
|
PsiElement(LT)('<')
|
||||||
TYPE_REFERENCE
|
TYPE_PROJECTION
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('Nothing')
|
REFERENCE_EXPRESSION
|
||||||
PsiElement(GT)('>')
|
PsiElement(IDENTIFIER)('Nothing')
|
||||||
|
PsiElement(GT)('>')
|
||||||
VALUE_ARGUMENT_LIST
|
VALUE_ARGUMENT_LIST
|
||||||
PsiElement(LPAR)('(')
|
PsiElement(LPAR)('(')
|
||||||
VALUE_ARGUMENT
|
VALUE_ARGUMENT
|
||||||
@@ -202,18 +206,19 @@ JetFile: Enums.jet
|
|||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
INITIALIZER_LIST
|
INITIALIZER_LIST
|
||||||
DELEGATOR_SUPER_CALL
|
DELEGATOR_SUPER_CALL
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('List')
|
REFERENCE_EXPRESSION
|
||||||
TYPE_ARGUMENT_LIST
|
PsiElement(IDENTIFIER)('List')
|
||||||
PsiElement(LT)('<')
|
TYPE_ARGUMENT_LIST
|
||||||
TYPE_PROJECTION
|
PsiElement(LT)('<')
|
||||||
TYPE_REFERENCE
|
TYPE_PROJECTION
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('T')
|
REFERENCE_EXPRESSION
|
||||||
PsiElement(GT)('>')
|
PsiElement(IDENTIFIER)('T')
|
||||||
|
PsiElement(GT)('>')
|
||||||
VALUE_ARGUMENT_LIST
|
VALUE_ARGUMENT_LIST
|
||||||
PsiElement(LPAR)('(')
|
PsiElement(LPAR)('(')
|
||||||
PsiComment(BLOCK_COMMENT)('/*tail.size + 1*/')
|
PsiComment(BLOCK_COMMENT)('/*tail.size + 1*/')
|
||||||
|
|||||||
@@ -463,10 +463,11 @@ JetFile: FunctionLiterals.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
PsiElement(IDENTIFIER)('x')
|
PsiElement(IDENTIFIER)('x')
|
||||||
@@ -477,10 +478,11 @@ JetFile: FunctionLiterals.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('b')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('b')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
PsiElement(IDENTIFIER)('y')
|
PsiElement(IDENTIFIER)('y')
|
||||||
@@ -491,10 +493,11 @@ JetFile: FunctionLiterals.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('c')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('c')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
PsiElement(IDENTIFIER)('z')
|
PsiElement(IDENTIFIER)('z')
|
||||||
|
|||||||
@@ -20,10 +20,11 @@ JetFile: FunctionTypes.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
TYPE_REFERENCE
|
TYPE_REFERENCE
|
||||||
@@ -91,10 +92,11 @@ JetFile: FunctionTypes.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('x')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('x')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
@@ -149,10 +151,11 @@ JetFile: FunctionTypes.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
@@ -272,10 +275,11 @@ JetFile: FunctionTypes.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
@@ -673,10 +677,11 @@ JetFile: FunctionTypes.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
FUNCTION_TYPE
|
FUNCTION_TYPE
|
||||||
@@ -711,10 +716,11 @@ JetFile: FunctionTypes.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
FUNCTION_TYPE
|
FUNCTION_TYPE
|
||||||
@@ -753,10 +759,11 @@ JetFile: FunctionTypes.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
FUNCTION_TYPE
|
FUNCTION_TYPE
|
||||||
|
|||||||
@@ -14,10 +14,11 @@ JetFile: Functions.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
PsiElement(IDENTIFIER)('foo')
|
PsiElement(IDENTIFIER)('foo')
|
||||||
@@ -32,10 +33,11 @@ JetFile: Functions.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
@@ -54,10 +56,11 @@ JetFile: Functions.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
@@ -92,10 +95,11 @@ JetFile: Functions.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
VALUE_ARGUMENT_LIST
|
VALUE_ARGUMENT_LIST
|
||||||
PsiElement(LPAR)('(')
|
PsiElement(LPAR)('(')
|
||||||
PsiElement(RPAR)(')')
|
PsiElement(RPAR)(')')
|
||||||
@@ -168,10 +172,11 @@ JetFile: Functions.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
PsiElement(IDENTIFIER)('foo')
|
PsiElement(IDENTIFIER)('foo')
|
||||||
@@ -187,10 +192,11 @@ JetFile: Functions.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
@@ -210,10 +216,11 @@ JetFile: Functions.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
@@ -249,10 +256,11 @@ JetFile: Functions.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
VALUE_ARGUMENT_LIST
|
VALUE_ARGUMENT_LIST
|
||||||
PsiElement(LPAR)('(')
|
PsiElement(LPAR)('(')
|
||||||
PsiElement(RPAR)(')')
|
PsiElement(RPAR)(')')
|
||||||
@@ -329,10 +337,11 @@ JetFile: Functions.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
PsiElement(IDENTIFIER)('foo')
|
PsiElement(IDENTIFIER)('foo')
|
||||||
@@ -351,10 +360,11 @@ JetFile: Functions.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
@@ -377,10 +387,11 @@ JetFile: Functions.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
@@ -419,10 +430,11 @@ JetFile: Functions.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
VALUE_ARGUMENT_LIST
|
VALUE_ARGUMENT_LIST
|
||||||
PsiElement(LPAR)('(')
|
PsiElement(LPAR)('(')
|
||||||
PsiElement(RPAR)(')')
|
PsiElement(RPAR)(')')
|
||||||
@@ -491,10 +503,11 @@ JetFile: Functions.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
VALUE_ARGUMENT_LIST
|
VALUE_ARGUMENT_LIST
|
||||||
PsiElement(LPAR)('(')
|
PsiElement(LPAR)('(')
|
||||||
PsiElement(RPAR)(')')
|
PsiElement(RPAR)(')')
|
||||||
@@ -516,10 +529,11 @@ JetFile: Functions.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
FUNCTION_TYPE
|
FUNCTION_TYPE
|
||||||
|
|||||||
@@ -15,10 +15,11 @@ JetFile: Functions_ERR.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
PsiElement(IDENTIFIER)('f')
|
PsiElement(IDENTIFIER)('f')
|
||||||
@@ -40,10 +41,11 @@ JetFile: Functions_ERR.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
@@ -77,10 +79,11 @@ JetFile: Functions_ERR.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
VALUE_ARGUMENT_LIST
|
VALUE_ARGUMENT_LIST
|
||||||
PsiElement(LPAR)('(')
|
PsiElement(LPAR)('(')
|
||||||
PsiElement(RPAR)(')')
|
PsiElement(RPAR)(')')
|
||||||
@@ -123,10 +126,11 @@ JetFile: Functions_ERR.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
VALUE_ARGUMENT_LIST
|
VALUE_ARGUMENT_LIST
|
||||||
PsiElement(LPAR)('(')
|
PsiElement(LPAR)('(')
|
||||||
PsiElement(RPAR)(')')
|
PsiElement(RPAR)(')')
|
||||||
@@ -176,10 +180,11 @@ JetFile: Functions_ERR.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
VALUE_ARGUMENT_LIST
|
VALUE_ARGUMENT_LIST
|
||||||
PsiElement(LPAR)('(')
|
PsiElement(LPAR)('(')
|
||||||
PsiElement(RPAR)(')')
|
PsiElement(RPAR)(')')
|
||||||
@@ -232,10 +237,11 @@ JetFile: Functions_ERR.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
VALUE_ARGUMENT_LIST
|
VALUE_ARGUMENT_LIST
|
||||||
PsiElement(LPAR)('(')
|
PsiElement(LPAR)('(')
|
||||||
PsiElement(RPAR)(')')
|
PsiElement(RPAR)(')')
|
||||||
|
|||||||
@@ -51,100 +51,109 @@ JetFile: Imports_ERR.jet
|
|||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
MODIFIER_LIST
|
MODIFIER_LIST
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
USER_TYPE
|
|
||||||
REFERENCE_EXPRESSION
|
|
||||||
PsiElement(IDENTIFIER)('foo')
|
|
||||||
PsiElement(DOT)('.')
|
|
||||||
PsiWhiteSpace('\n')
|
|
||||||
REFERENCE_EXPRESSION
|
|
||||||
PsiElement(IDENTIFIER)('import')
|
|
||||||
PsiWhiteSpace(' ')
|
|
||||||
ANNOTATION_ENTRY
|
|
||||||
TYPE_REFERENCE
|
|
||||||
USER_TYPE
|
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
REFERENCE_EXPRESSION
|
REFERENCE_EXPRESSION
|
||||||
PsiElement(IDENTIFIER)('foo')
|
PsiElement(IDENTIFIER)('foo')
|
||||||
PsiElement(DOT)('.')
|
PsiElement(DOT)('.')
|
||||||
|
PsiWhiteSpace('\n')
|
||||||
REFERENCE_EXPRESSION
|
REFERENCE_EXPRESSION
|
||||||
PsiElement(IDENTIFIER)('bar')
|
PsiElement(IDENTIFIER)('import')
|
||||||
PsiElement(DOT)('.')
|
|
||||||
PsiWhiteSpace('\n')
|
|
||||||
REFERENCE_EXPRESSION
|
|
||||||
PsiElement(IDENTIFIER)('import')
|
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
|
USER_TYPE
|
||||||
|
USER_TYPE
|
||||||
|
USER_TYPE
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('foo')
|
||||||
|
PsiElement(DOT)('.')
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('bar')
|
||||||
|
PsiElement(DOT)('.')
|
||||||
|
PsiWhiteSpace('\n')
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('import')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
ANNOTATION_ENTRY
|
||||||
|
CONSTRUCTOR_CALLEE
|
||||||
|
TYPE_REFERENCE
|
||||||
|
USER_TYPE
|
||||||
|
USER_TYPE
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('foo')
|
||||||
|
PsiElement(DOT)('.')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiErrorElement:Type name expected
|
||||||
|
PsiElement(as)('as')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
ANNOTATION_ENTRY
|
||||||
|
CONSTRUCTOR_CALLEE
|
||||||
|
TYPE_REFERENCE
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
REFERENCE_EXPRESSION
|
REFERENCE_EXPRESSION
|
||||||
PsiElement(IDENTIFIER)('foo')
|
PsiElement(IDENTIFIER)('bar')
|
||||||
PsiElement(DOT)('.')
|
|
||||||
PsiWhiteSpace(' ')
|
|
||||||
REFERENCE_EXPRESSION
|
|
||||||
PsiErrorElement:Type name expected
|
|
||||||
PsiElement(as)('as')
|
|
||||||
PsiWhiteSpace(' ')
|
|
||||||
ANNOTATION_ENTRY
|
|
||||||
TYPE_REFERENCE
|
|
||||||
USER_TYPE
|
|
||||||
REFERENCE_EXPRESSION
|
|
||||||
PsiElement(IDENTIFIER)('bar')
|
|
||||||
PsiWhiteSpace('\n')
|
PsiWhiteSpace('\n')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('import')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('import')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
|
USER_TYPE
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('foo')
|
||||||
|
PsiElement(DOT)('.')
|
||||||
REFERENCE_EXPRESSION
|
REFERENCE_EXPRESSION
|
||||||
PsiElement(IDENTIFIER)('foo')
|
PsiElement(IDENTIFIER)('bar')
|
||||||
PsiElement(DOT)('.')
|
PsiElement(DOT)('.')
|
||||||
REFERENCE_EXPRESSION
|
REFERENCE_EXPRESSION
|
||||||
PsiElement(IDENTIFIER)('bar')
|
PsiErrorElement:Type name expected
|
||||||
PsiElement(DOT)('.')
|
PsiElement(MUL)('*')
|
||||||
REFERENCE_EXPRESSION
|
|
||||||
PsiErrorElement:Type name expected
|
|
||||||
PsiElement(MUL)('*')
|
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
PsiErrorElement:Expecting namespace or top level declaration
|
PsiErrorElement:Expecting namespace or top level declaration
|
||||||
PsiElement(as)('as')
|
PsiElement(as)('as')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
MODIFIER_LIST
|
MODIFIER_LIST
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
|
||||||
PsiElement(IDENTIFIER)('bar')
|
|
||||||
PsiWhiteSpace('\n')
|
|
||||||
ANNOTATION_ENTRY
|
|
||||||
TYPE_REFERENCE
|
|
||||||
USER_TYPE
|
|
||||||
REFERENCE_EXPRESSION
|
|
||||||
PsiElement(IDENTIFIER)('import')
|
|
||||||
PsiWhiteSpace(' ')
|
|
||||||
ANNOTATION_ENTRY
|
|
||||||
TYPE_REFERENCE
|
|
||||||
USER_TYPE
|
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
USER_TYPE
|
|
||||||
REFERENCE_EXPRESSION
|
|
||||||
PsiElement(IDENTIFIER)('foo')
|
|
||||||
PsiElement(DOT)('.')
|
|
||||||
REFERENCE_EXPRESSION
|
REFERENCE_EXPRESSION
|
||||||
PsiElement(IDENTIFIER)('bar')
|
PsiElement(IDENTIFIER)('bar')
|
||||||
PsiElement(DOT)('.')
|
PsiWhiteSpace('\n')
|
||||||
REFERENCE_EXPRESSION
|
ANNOTATION_ENTRY
|
||||||
PsiErrorElement:Type name expected
|
CONSTRUCTOR_CALLEE
|
||||||
PsiElement(MUL)('*')
|
TYPE_REFERENCE
|
||||||
|
USER_TYPE
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('import')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
ANNOTATION_ENTRY
|
||||||
|
CONSTRUCTOR_CALLEE
|
||||||
|
TYPE_REFERENCE
|
||||||
|
USER_TYPE
|
||||||
|
USER_TYPE
|
||||||
|
USER_TYPE
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('foo')
|
||||||
|
PsiElement(DOT)('.')
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('bar')
|
||||||
|
PsiElement(DOT)('.')
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiErrorElement:Type name expected
|
||||||
|
PsiElement(MUL)('*')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
PsiErrorElement:Expecting namespace or top level declaration
|
PsiErrorElement:Expecting namespace or top level declaration
|
||||||
PsiElement(as)('as')
|
PsiElement(as)('as')
|
||||||
|
|||||||
@@ -22,10 +22,11 @@ JetFile: LocalDeclarations.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
PsiElement(abstract)('abstract')
|
PsiElement(abstract)('abstract')
|
||||||
@@ -47,10 +48,11 @@ JetFile: LocalDeclarations.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
PsiElement(class)('class')
|
PsiElement(class)('class')
|
||||||
@@ -81,10 +83,11 @@ JetFile: LocalDeclarations.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
PsiElement(var)('var')
|
PsiElement(var)('var')
|
||||||
|
|||||||
@@ -22,48 +22,52 @@ JetFile: NamespaceBlock_ERR.jet
|
|||||||
NAMESPACE
|
NAMESPACE
|
||||||
MODIFIER_LIST
|
MODIFIER_LIST
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
USER_TYPE
|
|
||||||
REFERENCE_EXPRESSION
|
|
||||||
PsiElement(IDENTIFIER)('foo')
|
|
||||||
PsiElement(DOT)('.')
|
|
||||||
PsiWhiteSpace('\n')
|
|
||||||
REFERENCE_EXPRESSION
|
|
||||||
PsiElement(IDENTIFIER)('import')
|
|
||||||
PsiWhiteSpace(' ')
|
|
||||||
ANNOTATION_ENTRY
|
|
||||||
TYPE_REFERENCE
|
|
||||||
USER_TYPE
|
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
REFERENCE_EXPRESSION
|
REFERENCE_EXPRESSION
|
||||||
PsiElement(IDENTIFIER)('foo')
|
PsiElement(IDENTIFIER)('foo')
|
||||||
PsiElement(DOT)('.')
|
PsiElement(DOT)('.')
|
||||||
|
PsiWhiteSpace('\n')
|
||||||
REFERENCE_EXPRESSION
|
REFERENCE_EXPRESSION
|
||||||
PsiElement(IDENTIFIER)('bar')
|
PsiElement(IDENTIFIER)('import')
|
||||||
PsiElement(DOT)('.')
|
|
||||||
PsiWhiteSpace('\n')
|
|
||||||
REFERENCE_EXPRESSION
|
|
||||||
PsiElement(IDENTIFIER)('import')
|
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
|
USER_TYPE
|
||||||
|
USER_TYPE
|
||||||
|
USER_TYPE
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('foo')
|
||||||
|
PsiElement(DOT)('.')
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('bar')
|
||||||
|
PsiElement(DOT)('.')
|
||||||
|
PsiWhiteSpace('\n')
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('import')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
ANNOTATION_ENTRY
|
||||||
|
CONSTRUCTOR_CALLEE
|
||||||
|
TYPE_REFERENCE
|
||||||
|
USER_TYPE
|
||||||
|
USER_TYPE
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('foo')
|
||||||
|
PsiElement(DOT)('.')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiErrorElement:Type name expected
|
||||||
|
PsiElement(as)('as')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
ANNOTATION_ENTRY
|
||||||
|
CONSTRUCTOR_CALLEE
|
||||||
|
TYPE_REFERENCE
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
REFERENCE_EXPRESSION
|
REFERENCE_EXPRESSION
|
||||||
PsiElement(IDENTIFIER)('foo')
|
PsiElement(IDENTIFIER)('bar')
|
||||||
PsiElement(DOT)('.')
|
|
||||||
PsiWhiteSpace(' ')
|
|
||||||
REFERENCE_EXPRESSION
|
|
||||||
PsiErrorElement:Type name expected
|
|
||||||
PsiElement(as)('as')
|
|
||||||
PsiWhiteSpace(' ')
|
|
||||||
ANNOTATION_ENTRY
|
|
||||||
TYPE_REFERENCE
|
|
||||||
USER_TYPE
|
|
||||||
REFERENCE_EXPRESSION
|
|
||||||
PsiElement(IDENTIFIER)('bar')
|
|
||||||
PsiWhiteSpace('\n\n')
|
PsiWhiteSpace('\n\n')
|
||||||
PsiElement(namespace)('namespace')
|
PsiElement(namespace)('namespace')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
@@ -255,10 +259,11 @@ JetFile: NamespaceBlock_ERR.jet
|
|||||||
CLASS
|
CLASS
|
||||||
MODIFIER_LIST
|
MODIFIER_LIST
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('dsfgd')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('dsfgd')
|
||||||
PsiWhiteSpace('\n\n')
|
PsiWhiteSpace('\n\n')
|
||||||
PsiElement(class)('class')
|
PsiElement(class)('class')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
|
|||||||
@@ -6,10 +6,11 @@ JetFile: NamespaceModifiers.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
PsiElement(namespace)('namespace')
|
PsiElement(namespace)('namespace')
|
||||||
@@ -23,10 +24,11 @@ JetFile: NamespaceModifiers.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
PsiElement(namespace)('namespace')
|
PsiElement(namespace)('namespace')
|
||||||
|
|||||||
@@ -29,10 +29,11 @@ JetFile: Properties.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
PsiElement(IDENTIFIER)('foo')
|
PsiElement(IDENTIFIER)('foo')
|
||||||
@@ -65,10 +66,11 @@ JetFile: Properties.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
PsiElement(IDENTIFIER)('foo')
|
PsiElement(IDENTIFIER)('foo')
|
||||||
|
|||||||
@@ -223,10 +223,11 @@ JetFile: PropertiesFollowedByInitializers.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
PsiElement(abstract)('abstract')
|
PsiElement(abstract)('abstract')
|
||||||
|
|||||||
@@ -45,16 +45,18 @@ JetFile: Properties_ERR.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('foo')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('foo')
|
||||||
PsiErrorElement:Expecting ']' to close an attribute annotation
|
PsiErrorElement:Expecting ']' to close an attribute annotation
|
||||||
<empty list>
|
<empty list>
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
@@ -81,10 +83,11 @@ JetFile: Properties_ERR.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('a')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
PsiElement(IDENTIFIER)('foo')
|
PsiElement(IDENTIFIER)('foo')
|
||||||
@@ -133,10 +136,11 @@ JetFile: Properties_ERR.jet
|
|||||||
PROPERTY
|
PROPERTY
|
||||||
MODIFIER_LIST
|
MODIFIER_LIST
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('foo')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('foo')
|
||||||
PsiWhiteSpace('\n\n')
|
PsiWhiteSpace('\n\n')
|
||||||
PsiElement(val)('val')
|
PsiElement(val)('val')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
|
|||||||
@@ -5,10 +5,11 @@ JetFile: QuotedIdentifiers.jet
|
|||||||
ANNOTATION
|
ANNOTATION
|
||||||
PsiElement(LBRACKET)('[')
|
PsiElement(LBRACKET)('[')
|
||||||
ANNOTATION_ENTRY
|
ANNOTATION_ENTRY
|
||||||
TYPE_REFERENCE
|
CONSTRUCTOR_CALLEE
|
||||||
USER_TYPE
|
TYPE_REFERENCE
|
||||||
REFERENCE_EXPRESSION
|
USER_TYPE
|
||||||
PsiElement(IDENTIFIER)('`return`')
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('`return`')
|
||||||
PsiElement(RBRACKET)(']')
|
PsiElement(RBRACKET)(']')
|
||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
PsiElement(fun)('fun')
|
PsiElement(fun)('fun')
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user