Merge branch 'master' of ssh://git.labs.intellij.net/jet

This commit is contained in:
svtk
2011-08-23 12:50:14 +04:00
122 changed files with 3752 additions and 2847 deletions
+1 -1
View File
@@ -119,7 +119,7 @@ parameter
;
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]
*/
+1 -1
View File
@@ -235,7 +235,7 @@ jump
// 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))
tupleLiteral
: "(" ((SimpleName "=")? expression){","} ")"
: "(" (((SimpleName "=")? expression){","})? ")"
;
// one can use "it" as a parameter name
+1 -1
View File
@@ -45,7 +45,7 @@ constantPattern
;
tuplePattern
: "(" ((SimpleName "=")? pattern{","})? ")"
: "(" (((SimpleName "=")? pattern){","})? ")"
;
bindingPattern
+1 -1
View File
@@ -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 flt : Float
abstract val lng : Long
@@ -29,6 +29,7 @@ public interface JetNodeTypes {
JetNodeType DELEGATOR_BY = new JetNodeType("DELEGATOR_BY", JetDelegatorByExpressionSpecifier.class);
JetNodeType DELEGATOR_SUPER_CALL = new JetNodeType("DELEGATOR_SUPER_CALL", JetDelegatorToSuperCall.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 = 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.PropertyDescriptor;
import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.resolve.BindingContext;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
@@ -29,7 +30,7 @@ public abstract class ClassBodyCodegen {
public ClassBodyCodegen(JetClassOrObject aClass, ClassContext context, ClassVisitor v, GenerationState state) {
this.state = state;
descriptor = state.getBindingContext().getClassDescriptor(aClass);
descriptor = state.getBindingContext().get(BindingContext.CLASS, aClass);
myClass = aClass;
this.context = context;
this.kind = context.getContextKind();
@@ -81,14 +82,14 @@ public abstract class ClassBodyCodegen {
OwnerKind kind = context.getContextKind();
for (JetParameter p : getPrimaryConstructorParameters()) {
if (p.getValOrVarNode() != null) {
PropertyDescriptor propertyDescriptor = state.getBindingContext().getPropertyDescriptor(p);
PropertyDescriptor propertyDescriptor = state.getBindingContext().get(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, p);
if (propertyDescriptor != null) {
propertyCodegen.generateDefaultGetter(propertyDescriptor, Opcodes.ACC_PUBLIC);
if (propertyDescriptor.isVar()) {
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);
}
}
@@ -2,6 +2,7 @@ package org.jetbrains.jet.codegen;
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.resolve.BindingContext;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.Type;
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);
for (JetDeclaration declaration : aClass.getDeclarations()) {
if (declaration instanceof JetClass && !(declaration instanceof JetEnumEntry)) {
@@ -40,13 +41,13 @@ public class ClassCodegen {
}
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);
new InterfaceBodyCodegen(aClass, parentContext.intoClass(descriptor, OwnerKind.INTERFACE), visitor, state).generate();
}
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
? state.forClassImplementation(descriptor)
: state.forClassDelegatingImplementation(descriptor);
@@ -37,7 +37,7 @@ public class ClassContext {
}
public StackValue getThisExpression() {
if (parentContext == null) return null;
if (parentContext == null) return StackValue.none();
thisWasUsed = true;
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.psi.JetFunctionLiteral;
import org.jetbrains.jet.lang.psi.JetFunctionLiteralExpression;
import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.types.JetType;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.MethodVisitor;
@@ -83,7 +84,7 @@ public class ClosureCodegen {
public GeneratedAnonymousClassDescriptor gen(JetFunctionLiteralExpression 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();
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.TypeParameterDescriptor;
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.MethodVisitor;
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.Method;
import java.util.Collections;
import java.util.List;
/**
@@ -31,7 +33,7 @@ public class FunctionCodegen {
public void gen(JetNamedFunction f) {
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);
}
@@ -39,11 +41,10 @@ public class FunctionCodegen {
ClassContext funContext = owner.intoFunction(functionDescriptor);
final JetExpression bodyExpression = f.getBodyExpression();
final List<JetElement> bodyExpressions = bodyExpression != null ? Collections.<JetElement>singletonList(bodyExpression) : null;
generatedMethod(bodyExpressions, jvmMethod, funContext, functionDescriptor.getValueParameters(), functionDescriptor.getTypeParameters());
generatedMethod(bodyExpression, jvmMethod, funContext, functionDescriptor.getValueParameters(), functionDescriptor.getTypeParameters());
}
private void generatedMethod(List<JetElement> bodyExpressions,
private void generatedMethod(JetExpression bodyExpressions,
Method jvmSignature,
ClassContext context,
List<ValueParameterDescriptor> paramDescrs,
@@ -94,35 +95,11 @@ public class FunctionCodegen {
iv.areturn(jvmSignature.getReturnType());
}
else if (!isAbstract) {
JetElement last = null;
for (JetElement expression : bodyExpressions) {
expression.accept(codegen);
last = expression;
}
generateReturn(mv, last, codegen, jvmSignature);
codegen.returnExpression(bodyExpressions);
}
mv.visitMaxs(0, 0);
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) {
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();
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.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lexer.JetTokens;
import org.objectweb.asm.ClassVisitor;
@@ -61,9 +62,9 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
JetDelegationSpecifier first = delegationSpecifiers.get(0);
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();
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()) {
return "java/lang/Object";
}
@@ -146,7 +147,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
}
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;
Method method;
@@ -182,7 +183,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
// TODO correct calculation of super class
String superClass = "java/lang/Object";
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();
if (superClassDescriptor.hasConstructors()) {
superClass = getSuperClass();
@@ -215,7 +216,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
HashSet<FunctionDescriptor> overridden = new HashSet<FunctionDescriptor>();
for (JetDeclaration declaration : myClass.getDeclarations()) {
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) {
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);
}
else if (specifier instanceof JetDelegatorByExpressionSpecifier) {
@@ -237,7 +238,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
}
if (delegateOnStack) {
JetType superType = state.getBindingContext().resolveTypeReference(specifier.getTypeReference());
JetType superType = state.getBindingContext().get(BindingContext.TYPE, specifier.getTypeReference());
ClassDescriptor superClassDescriptor = (ClassDescriptor) superType.getConstructor().getDeclarationDescriptor();
String delegateField = "$delegate_" + n;
Type fieldType = JetTypeMapper.jetInterfaceType(superClassDescriptor);
@@ -245,7 +246,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
v.visitField(Opcodes.ACC_PRIVATE, delegateField, fieldDesc, /*TODO*/null, null);
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,
new OwnerKind.DelegateKind(StackValue.field(fieldType, classname, delegateField, false),
JetTypeMapper.jvmNameForInterface(superClassDescriptor)));
@@ -298,7 +299,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
ConstructorFrameMap frameMap) {
ClassDescriptor classDecl = constructorDescriptor.getContainingDeclaration();
boolean isDelegating = kind == OwnerKind.DELEGATING_IMPLEMENTATION;
PsiElement declaration = state.getBindingContext().getDeclarationPsiElement(classDecl);
PsiElement declaration = state.getBindingContext().get(BindingContext.DESCRIPTOR_TO_DECLARATION, classDecl);
Type type;
if (declaration instanceof PsiClass) {
type = JetTypeMapper.psiClassType((PsiClass) declaration);
@@ -348,7 +349,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
}
private void generateSecondaryConstructor(JetConstructor constructor) {
ConstructorDescriptor constructorDescriptor = state.getBindingContext().getConstructorDescriptor(constructor);
ConstructorDescriptor constructorDescriptor = state.getBindingContext().get(BindingContext.CONSTRUCTOR, constructor);
if (constructorDescriptor == null) {
throw new UnsupportedOperationException("failed to get descriptor for secondary constructor");
}
@@ -365,7 +366,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
for (JetDelegationSpecifier initializer : constructor.getInitializers()) {
if (initializer instanceof JetDelegatorToThisCall) {
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)) {
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) {
for (JetDeclaration declaration : myClass.getDeclarations()) {
if (declaration instanceof JetProperty) {
final PropertyDescriptor propertyDescriptor = (PropertyDescriptor) state.getBindingContext().getVariableDescriptor((JetProperty) declaration);
if (state.getBindingContext().hasBackingField(propertyDescriptor)) {
final PropertyDescriptor propertyDescriptor = (PropertyDescriptor) state.getBindingContext().get(BindingContext.VARIABLE, (JetProperty) declaration);
if ((boolean) state.getBindingContext().get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor)) {
final JetExpression initializer = ((JetProperty) declaration).getInitializer();
if (initializer != null) {
iv.load(0, JetTypeMapper.TYPE_OBJECT);
@@ -435,7 +436,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
propertyCodegen.gen((JetProperty) declaration);
}
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);
}
}
@@ -443,7 +444,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
for (JetParameter p : toClass.getPrimaryConstructorParameters()) {
if (p.getValOrVarNode() != null) {
PropertyDescriptor propertyDescriptor = state.getBindingContext().getPropertyDescriptor(p);
PropertyDescriptor propertyDescriptor = state.getBindingContext().get(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, p);
if (propertyDescriptor != null) {
propertyCodegen.generateDefaultGetter(propertyDescriptor, Opcodes.ACC_PUBLIC);
if (propertyDescriptor.isVar()) {
@@ -47,9 +47,9 @@ public class InterfaceBodyCodegen extends ClassBodyCodegen {
String superClassName = null;
Set<String> superInterfaces = new LinkedHashSet<String>();
for (JetDelegationSpecifier specifier : delegationSpecifiers) {
JetType superType = bindingContext.resolveTypeReference(specifier.getTypeReference());
JetType superType = bindingContext.get(BindingContext.TYPE, specifier.getTypeReference());
ClassDescriptor superClassDescriptor = (ClassDescriptor) superType.getConstructor().getDeclarationDescriptor();
PsiElement superPsi = bindingContext.getDeclarationPsiElement(superClassDescriptor);
PsiElement superPsi = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, superClassDescriptor);
if (superPsi instanceof PsiClass) {
PsiClass psiClass = (PsiClass) superPsi;
@@ -120,7 +120,7 @@ public class InterfaceBodyCodegen extends ClassBodyCodegen {
final JetDelegationSpecifier specifier = delegationSpecifiers.get(0);
if (specifier instanceof JetDelegatorToSuperCall) {
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);
codegen.invokeMethodWithArguments(method, superCall);
}
@@ -138,7 +138,7 @@ public class JetTypeMapper {
}
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) {
return jvmName((PsiClass) declaration);
}
@@ -146,7 +146,7 @@ public class JetTypeMapper {
final PsiElement parent = declaration.getParent();
if (parent instanceof JetClassObject) {
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";
}
String className = classNamesForAnonymousClasses.get(declaration);
@@ -159,12 +159,12 @@ public class JetTypeMapper {
}
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);
}
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) {
return false;
}
@@ -372,14 +372,14 @@ public class JetTypeMapper {
private Method mapSignature(JetNamedFunction f, List<Type> valueParameterTypes) {
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();
List<Type> parameterTypes = new ArrayList<Type>();
if (receiverType != null) {
parameterTypes.add(mapType(receiverType));
}
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);
parameterTypes.add(type);
}
@@ -389,12 +389,12 @@ public class JetTypeMapper {
final JetTypeReference returnTypeRef = f.getReturnTypeRef();
Type returnType;
if (returnTypeRef == null) {
final FunctionDescriptor functionDescriptor = bindingContext.getFunctionDescriptor(f);
final FunctionDescriptor functionDescriptor = bindingContext.get(BindingContext.FUNCTION, f);
final JetType type = functionDescriptor.getReturnType();
returnType = mapType(type);
}
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()]));
}
@@ -407,7 +407,7 @@ public class JetTypeMapper {
throw new UnsupportedOperationException("unknown declaration type " + 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 List<Type> valueParameterTypes = new ArrayList<Type>();
Method descriptor = mapSignature(f, valueParameterTypes);
@@ -561,7 +561,7 @@ public class JetTypeMapper {
baseName = NamespaceCodegen.getJVMClassName(((JetNamespace) container).getFQName());
}
else {
ClassDescriptor aClass = bindingContext.getClassDescriptor((JetClassOrObject) container);
ClassDescriptor aClass = bindingContext.get(BindingContext.CLASS, (JetClassOrObject) container);
baseName = JetTypeMapper.jvmNameForInterface(aClass);
}
@@ -577,7 +577,7 @@ public class JetTypeMapper {
public Collection<String> allJvmNames(JetClassOrObject jetClass) {
Set<String> result = new HashSet<String>();
final ClassDescriptor classDescriptor = bindingContext.getClassDescriptor(jetClass);
final ClassDescriptor classDescriptor = bindingContext.get(BindingContext.CLASS, jetClass);
if (classDescriptor != null) {
result.add(jvmName(classDescriptor, OwnerKind.INTERFACE));
result.add(jvmName(classDescriptor, OwnerKind.IMPLEMENTATION));
@@ -3,6 +3,7 @@ package org.jetbrains.jet.codegen;
import com.intellij.psi.PsiFile;
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.resolve.BindingContext;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
@@ -33,7 +34,7 @@ public class NamespaceCodegen {
}
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 PropertyCodegen propertyCodegen = new PropertyCodegen(context, v, functionCodegen, state);
@@ -78,7 +79,7 @@ public class NamespaceCodegen {
if (declaration instanceof JetProperty) {
final JetExpression initializer = ((JetProperty) declaration).getInitializer();
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.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.VariableDescriptor;
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.lexer.JetTokens;
import org.objectweb.asm.ClassVisitor;
@@ -30,7 +31,7 @@ public class PropertyCodegen {
}
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)) {
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) {
if (state.getBindingContext().hasBackingField(propertyDescriptor)) {
if ((boolean) state.getBindingContext().get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor)) {
Object value = null;
final JetExpression initializer = p.getInitializer();
if (initializer != null) {
if (initializer instanceof JetConstantExpression) {
CompileTimeConstant<?> compileTimeValue = state.getBindingContext().getCompileTimeValue(initializer);
CompileTimeConstant<?> compileTimeValue = state.getBindingContext().get(BindingContext.COMPILE_TIME_VALUE, initializer);
assert compileTimeValue != null;
value = compileTimeValue.getValue();
}
@@ -126,7 +127,7 @@ public class PropertyCodegen {
}
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);
generateDefaultGetter(propertyDescriptor, flags);
}
@@ -166,7 +167,7 @@ public class PropertyCodegen {
}
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);
generateDefaultSetter(propertyDescriptor, flags);
}
@@ -48,8 +48,7 @@ public abstract class StackValue {
}
public static StackValue onStack(Type type) {
assert type != Type.VOID_TYPE;
return new OnStack(type);
return type == Type.VOID_TYPE ? none() : new OnStack(type);
}
public static StackValue constant(Object value, Type type) {
@@ -190,6 +189,21 @@ public abstract class StackValue {
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 {
private final int index;
@@ -15,8 +15,8 @@ import java.util.List;
*/
public class ArraySize implements IntrinsicMethod {
@Override
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element, List<JetExpression> arguments, boolean haveReceiver) {
codegen.ensureReceiverOnStack(element, null, JetTypeMapper.TYPE_OBJECT);
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element, List<JetExpression> arguments, StackValue receiver) {
receiver.put(JetTypeMapper.TYPE_OBJECT, v);
v.arraylength();
return StackValue.onStack(Type.INT_TYPE);
}
@@ -2,7 +2,6 @@ package org.jetbrains.jet.codegen.intrinsics;
import com.intellij.psi.PsiElement;
import org.jetbrains.jet.codegen.ExpressionCodegen;
import org.jetbrains.jet.codegen.JetTypeMapper;
import org.jetbrains.jet.codegen.StackValue;
import org.jetbrains.jet.lang.psi.JetExpression;
import org.objectweb.asm.Type;
@@ -21,16 +20,16 @@ public class BinaryOp implements IntrinsicMethod {
}
@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) {
// 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);
}
else {
if (!haveReceiver) {
codegen.gen(arguments.get(0), expectedType);
}
codegen.gen(arguments.get(0), expectedType);
codegen.gen(arguments.get(1), expectedType);
}
v.visitInsn(expectedType.getOpcode(opcode));
@@ -14,16 +14,18 @@ import java.util.List;
*/
public class Concat implements IntrinsicMethod {
@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();
if (haveReceiver) {
v.swap();
codegen.invokeAppendMethod(codegen.expressionType(arguments.get(0)));
}
else {
if (receiver == null) { // LHS.plus(RHS)
v.swap(); // StringBuilder LHS
codegen.invokeAppendMethod(codegen.expressionType(arguments.get(0))); // StringBuilder(LHS)
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;");
return StackValue.onStack(Type.getObjectType("java/lang/String"));
}
@@ -22,7 +22,7 @@ public class Increment implements IntrinsicMethod {
}
@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);
if (operand instanceof JetReferenceExpression) {
final int index = codegen.indexOfLocal((JetReferenceExpression) operand);
@@ -31,7 +31,7 @@ public class Increment implements IntrinsicMethod {
return StackValue.local(index, expectedType);
}
}
StackValue value = codegen.generateIntermediateValue(operand);
StackValue value = codegen.genQualified(receiver, operand);
value.dupReceiver(v, 0);
value.put(expectedType, v);
if (expectedType == Type.LONG_TYPE) {
@@ -14,5 +14,5 @@ import java.util.List;
* @author yole
*/
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 {
@Override
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element, List<JetExpression> arguments, boolean haveReceiver) {
codegen.putTopOfStack(expectedType);
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element, List<JetExpression> arguments, StackValue receiver) {
receiver.put(expectedType, v);
v.aconst(-1);
v.xor(expectedType);
return StackValue.onStack(expectedType);
@@ -14,13 +14,13 @@ import java.util.List;
*/
public class Not implements IntrinsicMethod {
@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;
if (arguments.size() == 1) {
stackValue = codegen.generateIntermediateValue(arguments.get(0));
stackValue = codegen.gen(arguments.get(0));
}
else {
stackValue = codegen.getReceiverAsStackValue(element, null, expectedType);
stackValue = receiver;
}
return StackValue.not(stackValue);
}
@@ -14,8 +14,8 @@ import java.util.List;
*/
public class NumberCast implements IntrinsicMethod {
@Override
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element, List<JetExpression> arguments, boolean haveReceiver) {
codegen.putTopOfStack(expectedType);
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element, List<JetExpression> arguments, StackValue receiver) {
receiver.put(expectedType, v);
return StackValue.onStack(expectedType);
}
}
@@ -24,9 +24,9 @@ public class PsiMethodCall implements IntrinsicMethod {
@Override
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);
codegen.invokeMethodWithArguments(callableMethod, (JetCallExpression) element, haveReceiver);
codegen.invokeMethodWithArguments(callableMethod, (JetCallExpression) element, receiver);
return StackValue.onStack(callableMethod.getSignature().getReturnType());
}
}
@@ -21,7 +21,7 @@ public class RangeTo implements IntrinsicMethod {
private static final String CLASS_INT_RANGE = "jet/IntRange";
@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;
final Type leftType = codegen.expressionType(expression.getLeft());
if (JetTypeMapper.isIntPrimitive(leftType)) {
@@ -17,7 +17,7 @@ import java.util.List;
*/
public class TypeInfo implements IntrinsicMethod {
@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();
if (typeArguments.size() != 1) {
throw new UnsupportedOperationException("one type argument expected");
@@ -14,12 +14,12 @@ import java.util.List;
*/
public class UnaryMinus implements IntrinsicMethod {
@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) {
codegen.gen(arguments.get(0), expectedType);
}
else {
codegen.ensureReceiverOnStack(element, null, expectedType);
receiver.put(expectedType, v);
}
v.neg(expectedType);
return StackValue.onStack(expectedType);
@@ -15,7 +15,7 @@ import java.util.List;
*/
public class ValueTypeInfo implements IntrinsicMethod {
@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);
v.invokeinterface("jet/JetObject", "getTypeInfo", "()Ljet/typeinfo/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);
}
// @NotNull
// public ErrorHandler getErrorHandler() {
// return errorHandler;
// }
//
@NotNull
public JetTypeChecker getTypeChecker() {
return typeChecker;
@@ -5,6 +5,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.JetSemanticServices;
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.types.JetTypeInferrer;
import org.jetbrains.jet.lexer.JetTokens;
@@ -85,7 +86,7 @@ public class JetControlFlowProcessor {
}
JetElement result = stack.peek();
trace.recordLabelResolution(labelExpression, result);
trace.record(BindingContext.LABEL_TARGET, labelExpression, result);
return result;
}
@@ -351,9 +351,11 @@ public class JetParsing extends AbstractJetParsing {
PsiBuilder.Marker attribute = mark();
PsiBuilder.Marker reference = mark();
PsiBuilder.Marker typeReference = mark();
parseUserType();
typeReference.done(TYPE_REFERENCE);
reference.done(CONSTRUCTOR_CALLEE);
parseTypeArgumentList(-1);
@@ -723,7 +725,9 @@ public class JetParsing extends AbstractJetParsing {
type = THIS_CALL;
}
else if (atSet(TYPE_REF_FIRST)) {
PsiBuilder.Marker reference = mark();
parseTypeRef();
reference.done(CONSTRUCTOR_CALLEE);
type = DELEGATOR_SUPER_CALL;
} else {
errorWithRecovery("Expecting constructor call (this(...)) or supertype initializer", TokenSet.create(LBRACE, COMMA));
@@ -1094,18 +1098,23 @@ public class JetParsing extends AbstractJetParsing {
private void parseDelegationSpecifier() {
PsiBuilder.Marker delegator = mark();
parseAnnotations(false);
PsiBuilder.Marker reference = mark();
parseTypeRef();
if (at(BY_KEYWORD)) {
reference.drop();
advance(); // BY_KEYWORD
createForByClause(myBuilder).myExpressionParsing.parseExpression();
delegator.done(DELEGATOR_BY);
}
else if (at(LPAR)) {
reference.done(CONSTRUCTOR_CALLEE);
myExpressionParsing.parseValueArgumentList();
delegator.done(DELEGATOR_SUPER_CALL);
}
else {
reference.drop();
delegator.done(DELEGATOR_SUPER_CLASS);
}
}
@@ -29,7 +29,16 @@ public class JetAnnotationEntry extends JetElement implements JetCall {
@Nullable @IfNotParsed
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
@@ -10,6 +10,9 @@ import java.util.List;
* @author abreslav
*/
public interface JetCall extends PsiElement {
@Nullable
JetExpression getCalleeExpression();
@Nullable
JetValueArgumentList getValueArgumentList();
@@ -26,6 +26,7 @@ public class JetCallExpression extends JetExpression implements JetCall {
return visitor.visitCallExpression(this, data);
}
@Override
@Nullable
public JetExpression getCalleeExpression() {
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);
}
@NotNull
@Override
public JetConstructorCalleeExpression getCalleeExpression() {
return (JetConstructorCalleeExpression) findChildByType(JetNodeTypes.CONSTRUCTOR_CALLEE);
}
@Nullable
public JetValueArgumentList getValueArgumentList() {
return (JetValueArgumentList) findChildByType(JetNodeTypes.VALUE_ARGUMENT_LIST);
@@ -43,6 +49,11 @@ public class JetDelegatorToSuperCall extends JetDelegationSpecifier implements J
return Collections.emptyList();
}
@Override
public JetTypeReference getTypeReference() {
return getCalleeExpression().getTypeReference();
}
@NotNull
@Override
public List<JetTypeProjection> getTypeArguments() {
@@ -27,6 +27,11 @@ public class JetDelegatorToThisCall extends JetDelegationSpecifier implements Je
return visitor.visitDelegationToThisCall(this, data);
}
@Override
public JetExpression getCalleeExpression() {
return getThisReference();
}
@Nullable
public JetValueArgumentList getValueArgumentList() {
return (JetValueArgumentList) findChildByType(JetNodeTypes.VALUE_ARGUMENT_LIST);
@@ -7,6 +7,7 @@ import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.resolve.AnalyzingUtils;
import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
/**
* @author abreslav
@@ -19,7 +20,7 @@ public abstract class JetReferenceExpression extends JetExpression {
protected PsiElement doResolve() {
JetFile file = (JetFile) getContainingFile();
BindingContext bindingContext = AnalyzingUtils.analyzeFileWithCache(file);
PsiElement psiElement = bindingContext.resolveToDeclarationPsiElement(this);
PsiElement psiElement = BindingContextUtils.resolveToDeclarationPsiElement(bindingContext, this);
return psiElement == null
? file
: psiElement;
@@ -91,7 +91,7 @@ public class JetSimpleNameExpression extends JetReferenceExpression {
JetExpression receiverExpression = qualifiedExpression.getReceiverExpression();
JetFile file = (JetFile) getContainingFile();
BindingContext bindingContext = AnalyzingUtils.analyzeFileWithCache(file);
final JetType expressionType = bindingContext.getExpressionType(receiverExpression);
final JetType expressionType = bindingContext.get(BindingContext.EXPRESSION_TYPE, receiverExpression);
if (expressionType != null) {
return collectLookupElements(bindingContext, expressionType.getMemberScope());
}
@@ -99,7 +99,7 @@ public class JetSimpleNameExpression extends JetReferenceExpression {
else {
JetFile file = (JetFile) getContainingFile();
BindingContext bindingContext = AnalyzingUtils.analyzeFileWithCache(file);
JetScope resolutionScope = bindingContext.getResolutionScope(JetSimpleNameExpression.this);
JetScope resolutionScope = bindingContext.get(BindingContext.RESOLUTION_SCOPE, JetSimpleNameExpression.this);
if (resolutionScope != null) {
return collectLookupElements(bindingContext, resolutionScope);
}
@@ -119,7 +119,7 @@ public class JetSimpleNameExpression extends JetReferenceExpression {
private Object[] collectLookupElements(BindingContext bindingContext, JetScope scope) {
List<LookupElement> result = Lists.newArrayList();
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());
String typeText = "";
String tailText = "";
@@ -52,7 +52,7 @@ public class AnalyzingUtils {
e.printStackTrace();
BindingTraceContext bindingTraceContext = new BindingTraceContext();
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");
}
}, Collections.<JetDeclaration>singletonList(namespace));
return bindingTraceContext;
return bindingTraceContext.getBindingContext();
}
public static void applyHandler(@NotNull ErrorHandler errorHandler, @NotNull BindingContext bindingContext) {
@@ -87,7 +87,7 @@ public class AnnotationResolver {
for (JetAnnotationEntry annotation : annotations) {
AnnotationDescriptor annotationDescriptor = new AnnotationDescriptor();
result.add(annotationDescriptor);
trace.recordAnnotationResolution(annotation, annotationDescriptor);
trace.record(BindingContext.ANNOTATION, annotation, annotationDescriptor);
}
return result;
}
@@ -1,14 +1,13 @@
package org.jetbrains.jet.lang.resolve;
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.descriptors.*;
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;
import org.jetbrains.jet.util.*;
import java.util.Collection;
@@ -16,46 +15,93 @@ import java.util.Collection;
* @author abreslav
*/
public interface BindingContext {
@Deprecated // "Tests only"
DeclarationDescriptor getDeclarationDescriptor(PsiElement declaration);
WritableSlice<JetAnnotationEntry, AnnotationDescriptor> ANNOTATION = ManyMapSlices.createSimpleSlice("ANNOTATION");
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);
ClassDescriptor getClassDescriptor(JetClassOrObject declaration);
TypeParameterDescriptor getTypeParameterDescriptor(JetTypeParameter declaration);
FunctionDescriptor getFunctionDescriptor(JetNamedFunction declaration);
ConstructorDescriptor getConstructorDescriptor(JetElement declaration);
AnnotationDescriptor getAnnotationDescriptor(JetAnnotationEntry annotationEntry);
WritableSlice<JetExpression, Boolean> VARIABLE_REASSIGNMENT = ManyMapSlices.createSimpleSetSlice("VARIABLE_REASSIGNMENT");
WritableSlice<JetExpression, Boolean> PROCESSED = ManyMapSlices.createSimpleSetSlice("PROCESSED");
WritableSlice<JetElement, Boolean> STATEMENT = ManyMapSlices.createRemovableSetSlice("STATEMENT");
@Nullable
CompileTimeConstant<?> getCompileTimeValue(JetExpression expression);
WritableSlice<PropertyDescriptor, Boolean> BACKING_FIELD_REQUIRED = new ManyMapSlices.SetSlice<PropertyDescriptor>("BACKING_FIELD_REQUIRED", RewritePolicy.DO_NOTHING) {
@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);
VariableDescriptor getVariableDescriptor(JetParameter declaration);
WritableSlice<JetFunctionLiteralExpression, Boolean> BLOCK = new ManyMapSlices.SetSlice<JetFunctionLiteralExpression>("BLOCK", RewritePolicy.DO_NOTHING) {
@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);
PropertyDescriptor getPropertyDescriptor(JetObjectDeclarationName objectDeclarationName);
ManyMapSlices.KeyNormalizer<DeclarationDescriptor> DECLARATION_DESCRIPTOR_NORMALIZER = new ManyMapSlices.KeyNormalizer<DeclarationDescriptor>() {
@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);
PsiElement resolveToDeclarationPsiElement(JetReferenceExpression referenceExpression);
PsiElement getDeclarationPsiElement(DeclarationDescriptor descriptor);
WritableSlice[] DECLARATIONS_TO_DESCRIPTORS = new WritableSlice[] {
NAMESPACE, CLASS, TYPE_PARAMETER, FUNCTION, CONSTRUCTOR, VARIABLE, VALUE_PARAMETER, PRIMARY_CONSTRUCTOR_PARAMETER, OBJECT_DECLARATION
};
boolean isBlock(JetFunctionLiteralExpression expression);
boolean isStatement(JetExpression expression);
boolean hasBackingField(PropertyDescriptor propertyDescriptor);
ReadOnlySlice<PsiElement, DeclarationDescriptor> DECLARATION_TO_DESCRIPTOR = ManyMapSlices.<PsiElement, DeclarationDescriptor>sliceBuilder("DECLARATION_TO_DESCRIPTOR")
.setFurtherLookupSlices(DECLARATIONS_TO_DESCRIPTORS).build();
boolean isVariableReassignment(JetExpression expression);
ConstructorDescriptor resolveSuperConstructor(JetDelegatorToSuperCall superCall);
@Nullable
JetType getAutoCastType(@NotNull JetExpression expression);
@Nullable
JetScope getResolutionScope(@NotNull 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();
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;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.ErrorHandlerWithRegions;
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
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;
import org.jetbrains.jet.lang.ErrorHandler;
import org.jetbrains.jet.util.ReadOnlySlice;
import org.jetbrains.jet.util.WritableSlice;
/**
* @author abreslav
*/
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
ErrorHandlerWithRegions getErrorHandler();
boolean isProcessed(@NotNull JetExpression expression);
void markAsProcessed(@NotNull JetExpression expression);
ErrorHandler getErrorHandler();
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;
import com.intellij.psi.PsiElement;
import com.google.common.collect.Maps;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.ErrorHandlerWithRegions;
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
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;
import org.jetbrains.jet.lang.ErrorHandler;
import org.jetbrains.jet.util.ReadOnlySlice;
import org.jetbrains.jet.util.WritableSlice;
import java.util.Map;
/**
* @author abreslav
*/
public class BindingTraceAdapter implements BindingTrace {
private final BindingTrace originalTrace;
@Override
public void recordAutoCast(@NotNull JetExpression expression, @NotNull JetType type, @NotNull VariableDescriptor variableDescriptor) {
originalTrace.recordAutoCast(expression, type, variableDescriptor);
public interface RecordHandler<K, V> {
void handleRecord(WritableSlice<K, V> slice, K key, V value);
}
private final BindingTrace originalTrace;
private Map<WritableSlice, RecordHandler> handlers = Maps.newHashMap();
public BindingTraceAdapter(BindingTrace 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
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
@Override
public ErrorHandlerWithRegions getErrorHandler() {
public ErrorHandler 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
public BindingContext getBindingContext() {
return originalTrace.getBindingContext();
}
@Override
public void recordResolutionScope(@NotNull JetExpression expression, @NotNull JetScope scope) {
originalTrace.recordResolutionScope(expression, scope);
public <K, V> void record(WritableSlice<K, V> slice, K key, V value) {
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;
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.Nullable;
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.descriptors.*;
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;
import org.jetbrains.jet.util.ManyMapImpl;
import org.jetbrains.jet.util.MutableManyMap;
import org.jetbrains.jet.util.ReadOnlySlice;
import org.jetbrains.jet.util.WritableSlice;
import java.util.*;
import java.util.Collection;
import java.util.List;
/**
* @author abreslav
*/
public class BindingTraceContext implements BindingContext, 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();
public class BindingTraceContext implements BindingTrace {
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 Map<JetAnnotationEntry, AnnotationDescriptor> annotationDescriptos = Maps.newHashMap();
private Map<JetExpression, CompileTimeConstant<?>> compileTimeValues = Maps.newHashMap();
private final BindingContext bindingContext = new BindingContext() {
@Override
public Collection<JetDiagnostic> getDiagnostics() {
return diagnostics;
}
public BindingTraceContext() {
}
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;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@Override
public <K, V> V get(ReadOnlySlice<K, V> slice, K key) {
return BindingTraceContext.this.get(slice, key);
}
};
@NotNull
public ErrorHandlerWithRegions getErrorHandler() {
@Override
public ErrorHandler getErrorHandler() {
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
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()),
JetPsiUtil.safeName(classElement.getName()));
trace.recordDeclarationResolution(classElement, classDescriptor);
trace.record(BindingContext.CLASS, classElement, classDescriptor);
final WritableScope parameterScope = new WritableScopeImpl(scope, classDescriptor, trace.getErrorHandler());
@@ -134,15 +134,15 @@ public class ClassDescriptorResolver {
JetPsiUtil.safeName(typeParameter.getName()),
index
);
trace.recordDeclarationResolution(typeParameter, typeParameterDescriptor);
trace.record(BindingContext.TYPE_PARAMETER, typeParameter, typeParameterDescriptor);
typeParameters.add(typeParameterDescriptor);
index++;
}
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) {
@@ -151,7 +151,7 @@ public class ClassDescriptorResolver {
// TODO : beautify
if (jetClass instanceof JetEnumEntry) {
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()) {
defaultSupertype = parentDescriptor.getDefaultType();
}
@@ -227,7 +227,7 @@ public class ClassDescriptorResolver {
valueParameterDescriptors,
returnType);
trace.recordDeclarationResolution(function, functionDescriptor);
trace.record(BindingContext.FUNCTION, function, functionDescriptor);
return functionDescriptor;
}
@@ -272,7 +272,7 @@ public class ClassDescriptorResolver {
);
// TODO : Default values???
trace.recordDeclarationResolution(valueParameter, valueParameterDescriptor);
trace.record(BindingContext.VALUE_PARAMETER, valueParameter, valueParameterDescriptor);
return valueParameterDescriptor;
}
@@ -299,7 +299,7 @@ public class ClassDescriptorResolver {
);
// typeParameterDescriptor.addUpperBound(bound);
extensibleScope.addTypeParameterDescriptor(typeParameterDescriptor);
trace.recordDeclarationResolution(typeParameter, typeParameterDescriptor);
trace.record(BindingContext.TYPE_PARAMETER, typeParameter, typeParameterDescriptor);
return typeParameterDescriptor;
}
@@ -330,14 +330,14 @@ public class ClassDescriptorResolver {
ClassifierDescriptor classifier = scope.getClassifier(referencedName);
if (classifier != null) {
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 {
trace.getErrorHandler().unresolvedReference(subjectTypeParameterName);
}
}
else {
trace.recordReferenceResolution(subjectTypeParameterName, typeParameterDescriptor);
trace.record(BindingContext.REFERENCE_TARGET, subjectTypeParameterName, typeParameterDescriptor);
JetTypeReference boundTypeReference = constraint.getBoundTypeReference();
if (boundTypeReference != null) {
JetType bound = resolveAndCheckUpperBoundType(boundTypeReference, scope, constraint.isClassObjectContraint());
@@ -430,7 +430,7 @@ public class ClassDescriptorResolver {
JetPsiUtil.safeName(parameter.getName()),
type,
parameter.isMutable());
trace.recordDeclarationResolution(parameter, variableDescriptor);
trace.record(BindingContext.VALUE_PARAMETER, parameter, variableDescriptor);
return variableDescriptor;
}
@@ -449,7 +449,7 @@ public class ClassDescriptorResolver {
JetPsiUtil.safeName(property.getName()),
type,
property.isVar());
trace.recordDeclarationResolution(property, variableDescriptor);
trace.record(BindingContext.VARIABLE, property, variableDescriptor);
return variableDescriptor;
}
@@ -472,7 +472,7 @@ public class ClassDescriptorResolver {
JetObjectDeclarationName nameAsDeclaration = objectDeclaration.getNameAsDeclaration();
if (nameAsDeclaration != null) {
trace.recordDeclarationResolution(nameAsDeclaration, propertyDescriptor);
trace.record(BindingContext.OBJECT_DECLARATION, nameAsDeclaration, propertyDescriptor);
}
return propertyDescriptor;
}
@@ -520,7 +520,7 @@ public class ClassDescriptorResolver {
resolvePropertyGetterDescriptor(scopeWithTypeParameters, property, propertyDescriptor),
resolvePropertySetterDescriptor(scopeWithTypeParameters, property, propertyDescriptor));
trace.recordDeclarationResolution(property, propertyDescriptor);
trace.record(BindingContext.VARIABLE, property, propertyDescriptor);
return propertyDescriptor;
}
@@ -612,7 +612,7 @@ public class ClassDescriptorResolver {
MutableValueParameterDescriptor valueParameterDescriptor = resolveValueParameterDescriptor(setterDescriptor, parameter, 0, type);
setterDescriptor.initialize(valueParameterDescriptor);
}
trace.recordDeclarationResolution(setter, setterDescriptor);
trace.record(BindingContext.PROPERTY_ACCESSOR, setter, setterDescriptor);
}
return setterDescriptor;
}
@@ -633,7 +633,7 @@ public class ClassDescriptorResolver {
getterDescriptor = new PropertyGetterDescriptor(
resolveModifiers(getter.getModifierList(), DEFAULT_MODIFIERS), // TODO : default modifiers differ in different contexts
propertyDescriptor, annotations, returnType, getter.getBodyExpression() != null);
trace.recordDeclarationResolution(getter, getterDescriptor);
trace.record(BindingContext.PROPERTY_ACCESSOR, getter, getterDescriptor);
}
return getterDescriptor;
}
@@ -656,7 +656,7 @@ public class ClassDescriptorResolver {
annotationResolver.resolveAnnotations(scope, modifierList),
isPrimary
);
trace.recordDeclarationResolution(declarationToTrace, constructorDescriptor);
trace.record(BindingContext.CONSTRUCTOR, declarationToTrace, constructorDescriptor);
return constructorDescriptor.initialize(
typeParameters,
resolveValueParameters(
@@ -704,7 +704,7 @@ public class ClassDescriptorResolver {
isMutable ? type : null,
type);
propertyDescriptor.initialize(Collections.<TypeParameterDescriptor>emptyList(), null, null);
trace.recordValueParameterAsPropertyResolution(parameter, propertyDescriptor);
trace.record(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, parameter, propertyDescriptor);
return propertyDescriptor;
}
@@ -971,5 +971,4 @@ public class ClassDescriptorResolver {
previousInstruction.accept(visitor);
}
}
}
@@ -37,7 +37,7 @@ public class ScopeWithReceiver extends JetScopeImpl {
// return false;
// }
// // 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.JetTypeInferrer;
import org.jetbrains.jet.lexer.JetTokens;
import org.jetbrains.jet.util.WritableSlice;
import java.util.*;
@@ -31,7 +32,7 @@ public class TopDownAnalyzer {
private final Map<JetNamedFunction, FunctionDescriptorImpl> functions = 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 Set<PropertyDescriptor> primaryConstructorParameterProperties = Sets.newHashSet();
@@ -47,34 +48,32 @@ public class TopDownAnalyzer {
this.trace = bindingTrace;
// 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
public void recordReferenceResolution(@NotNull JetReferenceExpression expression, @NotNull DeclarationDescriptor descriptor) {
super.recordReferenceResolution(expression, descriptor);
public void handleRecord(WritableSlice<JetReferenceExpression, DeclarationDescriptor> slice, JetReferenceExpression expression, DeclarationDescriptor descriptor) {
if (expression instanceof JetSimpleNameExpression) {
JetSimpleNameExpression simpleNameExpression = (JetSimpleNameExpression) expression;
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");
}
}
}
}
};
});
// 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
public void recordReferenceResolution(@NotNull JetReferenceExpression expression, @NotNull DeclarationDescriptor descriptor) {
super.recordReferenceResolution(expression, descriptor);
public void handleRecord(WritableSlice<JetReferenceExpression, DeclarationDescriptor> slice, JetReferenceExpression expression, DeclarationDescriptor descriptor) {
if (descriptor instanceof PropertyDescriptor) {
PropertyDescriptor propertyDescriptor = (PropertyDescriptor) descriptor;
if (primaryConstructorParameterProperties.contains(propertyDescriptor)) {
requireBackingField(propertyDescriptor);
traceForMembers.record(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor);
}
}
}
};
});
}
@Deprecated // For JetStandardLibraryOnly
@@ -129,8 +128,6 @@ public class TopDownAnalyzer {
resolveFunctionAndPropertyHeaders(); // Constructor headers are resolved as well
resolveBehaviorDeclarationBodies();
trace.getErrorHandler().close();
}
private void collectNamespacesAndClassifiers(
@@ -155,7 +152,7 @@ public class TopDownAnalyzer {
);
namespaceDescriptor.initialize(new WritableScopeImpl(JetScope.EMPTY, namespaceDescriptor, trace.getErrorHandler()).setDebugName("Namespace member scope"));
owner.addNamespace(namespaceDescriptor);
trace.recordDeclarationResolution(namespace, namespaceDescriptor);
trace.record(BindingContext.NAMESPACE, namespace, namespaceDescriptor);
}
namespaceDescriptors.put(namespace, namespaceDescriptor);
@@ -222,7 +219,7 @@ public class TopDownAnalyzer {
};
visitClassOrObject(declaration, (Map) objects, owner, outerScope, mutableClassDescriptor);
createPrimaryConstructor(mutableClassDescriptor);
trace.recordDeclarationResolution((PsiElement) declaration, mutableClassDescriptor);
trace.record(BindingContext.CLASS, declaration, mutableClassDescriptor);
return mutableClassDescriptor;
}
@@ -312,7 +309,7 @@ public class TopDownAnalyzer {
}
if (classifierDescriptor != null) {
trace.recordReferenceResolution(referenceExpression, classifierDescriptor);
trace.record(BindingContext.REFERENCE_TARGET, referenceExpression, classifierDescriptor);
String aliasName = importDirective.getAliasName();
String importedClassifierName = aliasName != null ? aliasName : classifierDescriptor.getName();
@@ -356,7 +353,7 @@ public class TopDownAnalyzer {
for (JetDelegationSpecifier delegationSpecifier : jetClass.getDelegationSpecifiers()) {
JetTypeReference typeReference = delegationSpecifier.getTypeReference();
if (typeReference != null) {
JetType type = trace.getBindingContext().resolveTypeReference(typeReference);
JetType type = trace.getBindingContext().get(BindingContext.TYPE, typeReference);
classDescriptorResolver.checkBounds(typeReference, type);
}
}
@@ -364,7 +361,7 @@ public class TopDownAnalyzer {
for (JetTypeParameter jetTypeParameter : jetClass.getTypeParameters()) {
JetTypeReference extendsBound = jetTypeParameter.getExtendsBound();
if (extendsBound != null) {
JetType type = trace.getBindingContext().resolveTypeReference(extendsBound);
JetType type = trace.getBindingContext().get(BindingContext.TYPE, extendsBound);
if (type != null) {
classDescriptorResolver.checkBounds(extendsBound, type);
}
@@ -374,7 +371,7 @@ public class TopDownAnalyzer {
for (JetTypeConstraint constraint : jetClass.getTypeConstaints()) {
JetTypeReference extendsBound = constraint.getBoundTypeReference();
if (extendsBound != null) {
JetType type = trace.getBindingContext().resolveTypeReference(extendsBound);
JetType type = trace.getBindingContext().get(BindingContext.TYPE, extendsBound);
if (type != null) {
classDescriptorResolver.checkBounds(extendsBound, type);
}
@@ -534,7 +531,7 @@ public class TopDownAnalyzer {
JetClass jetClass = entry.getKey();
if (classDescriptor.getUnsubstitutedPrimaryConstructor() == null) {
for (PropertyDescriptor propertyDescriptor : classDescriptor.getProperties()) {
if (trace.getBindingContext().hasBackingField(propertyDescriptor)) {
if ((boolean) trace.getBindingContext().get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor)) {
PsiElement nameIdentifier = jetClass.getNameIdentifier();
if (nameIdentifier != null) {
trace.getErrorHandler().genericError(nameIdentifier.getNode(),
@@ -572,7 +569,7 @@ public class TopDownAnalyzer {
if (delegateExpression != null) {
JetScope scope = scopeForConstructor == null ? descriptor.getScopeForMemberResolution() : scopeForConstructor;
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?
trace.getErrorHandler().typeMismatch(delegateExpression, supertype, type);
}
@@ -597,7 +594,7 @@ public class TopDownAnalyzer {
@Override
public void visitDelegationToSuperClassSpecifier(JetDelegatorToSuperClass specifier) {
JetType supertype = trace.getBindingContext().resolveTypeReference(specifier.getTypeReference());
JetType supertype = trace.getBindingContext().get(BindingContext.TYPE, specifier.getTypeReference());
if (supertype != null) {
DeclarationDescriptor declarationDescriptor = supertype.getConstructor().getDeclarationDescriptor();
if (declarationDescriptor instanceof ClassDescriptor) {
@@ -747,7 +744,7 @@ public class TopDownAnalyzer {
constructorScope.setThisType(descriptor.getContainingDeclaration().getDefaultType());
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) {
constructorScope.addVariableDescriptor(valueParameterDescriptor);
}
@@ -837,27 +834,26 @@ public class TopDownAnalyzer {
}
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");
}
}
private BindingTraceAdapter createFieldTrackingTrace(final PropertyDescriptor propertyDescriptor) {
return new BindingTraceAdapter(traceForMembers) {
return new BindingTraceAdapter(traceForMembers).addHandler(BindingContext.REFERENCE_TARGET, new BindingTraceAdapter.RecordHandler<JetReferenceExpression, DeclarationDescriptor>() {
@Override
public void recordReferenceResolution(@NotNull JetReferenceExpression expression, @NotNull DeclarationDescriptor descriptor) {
super.recordReferenceResolution(expression, descriptor);
public void handleRecord(WritableSlice<JetReferenceExpression, DeclarationDescriptor> slice, JetReferenceExpression expression, DeclarationDescriptor descriptor) {
if (expression instanceof JetSimpleNameExpression) {
JetSimpleNameExpression simpleNameExpression = (JetSimpleNameExpression) expression;
if (simpleNameExpression.getReferencedNameElementType() == JetTokens.FIELD_IDENTIFIER) {
// This check may be considered redundant as long as $x is only accessible from accessors to $x
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) {
@@ -31,14 +31,14 @@ public class TypeResolver {
@NotNull
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;
final List<AnnotationDescriptor> annotations = annotationResolver.createAnnotationStubs(typeReference.getAnnotations());
JetTypeElement typeElement = typeReference.getTypeElement();
JetType type = resolveTypeElement(scope, annotations, typeElement, false);
trace.recordTypeResolution(typeReference, type);
trace.record(BindingContext.TYPE, typeReference, type);
return type;
}
@@ -60,7 +60,7 @@ public class TypeResolver {
if (classifierDescriptor instanceof TypeParameterDescriptor) {
TypeParameterDescriptor typeParameterDescriptor = (TypeParameterDescriptor) classifierDescriptor;
trace.recordReferenceResolution(referenceExpression, typeParameterDescriptor);
trace.record(BindingContext.REFERENCE_TARGET, referenceExpression, typeParameterDescriptor);
result[0] = new JetTypeImpl(
annotations,
@@ -72,8 +72,8 @@ public class TypeResolver {
}
else if (classifierDescriptor instanceof ClassDescriptor) {
ClassDescriptor classDescriptor = (ClassDescriptor) classifierDescriptor;
trace.recordReferenceResolution(referenceExpression, classifierDescriptor);
trace.record(BindingContext.REFERENCE_TARGET, referenceExpression, classifierDescriptor);
TypeConstructor typeConstructor = classifierDescriptor.getTypeConstructor();
List<TypeProjection> arguments = resolveTypeProjections(scope, typeConstructor, type.getTypeArguments());
List<TypeParameterDescriptor> parameters = typeConstructor.getParameters();
@@ -289,7 +289,7 @@ public class TypeResolver {
NamespaceDescriptor namespace = scope.getNamespace(userType.getReferencedName());
if (namespace != null) {
trace.recordReferenceResolution(userType.getReferenceExpression(), namespace);
trace.record(BindingContext.REFERENCE_TARGET, userType.getReferenceExpression(), namespace);
}
return namespace;
}
@@ -9,6 +9,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.types.*;
import java.util.*;
@@ -122,7 +123,7 @@ public class JavaDescriptorResolver {
constructorDescriptor.initialize(typeParameters, Collections.<ValueParameterDescriptor>emptyList());
constructorDescriptor.setReturnType(classDescriptor.getDefaultType());
classDescriptor.addConstructor(constructorDescriptor);
semanticServices.getTrace().recordDeclarationResolution(psiClass, constructorDescriptor);
semanticServices.getTrace().record(BindingContext.CONSTRUCTOR, psiClass, constructorDescriptor);
}
}
else {
@@ -134,11 +135,11 @@ public class JavaDescriptorResolver {
constructorDescriptor.initialize(typeParameters, resolveParameterDescriptors(constructorDescriptor, constructor.getParameterList().getParameters()));
constructorDescriptor.setReturnType(classDescriptor.getDefaultType());
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;
}
@@ -230,7 +231,7 @@ public class JavaDescriptorResolver {
psiPackage.getName()
);
namespaceDescriptor.setMemberScope(new JavaPackageScope(psiPackage.getQualifiedName(), namespaceDescriptor, semanticServices));
semanticServices.getTrace().recordDeclarationResolution(psiPackage, namespaceDescriptor);
semanticServices.getTrace().record(BindingContext.NAMESPACE, psiPackage, namespaceDescriptor);
return namespaceDescriptor;
}
@@ -241,7 +242,7 @@ public class JavaDescriptorResolver {
psiClass.getName()
);
namespaceDescriptor.setMemberScope(new JavaClassMembersScope(namespaceDescriptor, psiClass, semanticServices, true));
semanticServices.getTrace().recordDeclarationResolution(psiClass, namespaceDescriptor);
semanticServices.getTrace().record(BindingContext.NAMESPACE, psiClass, namespaceDescriptor);
return namespaceDescriptor;
}
@@ -280,7 +281,7 @@ public class JavaDescriptorResolver {
field.getName(),
isFinal ? null : type,
type);
semanticServices.getTrace().recordDeclarationResolution(field, propertyDescriptor);
semanticServices.getTrace().record(BindingContext.VARIABLE, field, propertyDescriptor);
fieldDescriptorCache.put(field, propertyDescriptor);
return propertyDescriptor;
}
@@ -344,7 +345,7 @@ public class JavaDescriptorResolver {
semanticServices.getDescriptorResolver().resolveParameterDescriptors(functionDescriptorImpl, parameters),
semanticServices.getTypeTransformer().transformToType(returnType)
);
semanticServices.getTrace().recordDeclarationResolution(method, functionDescriptorImpl);
semanticServices.getTrace().record(BindingContext.FUNCTION, method, functionDescriptorImpl);
FunctionDescriptor substitutedFunctionDescriptor = functionDescriptorImpl;
if (method.getContainingClass() != psiClass) {
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) {
List<ValueParameterDescriptor> result = new ArrayList<ValueParameterDescriptor>();
for (int i = 0, argumentTypesSize = argumentTypes.size(); i < argumentTypesSize; i++) {
@@ -152,7 +152,7 @@ public class ErrorUtils {
functionDescriptor,
i,
Collections.<AnnotationDescriptor>emptyList(),
"<ERROR PARAMETER>",
"<ERROR VALUE_PARAMETER>",
ERROR_PARAMETER_TYPE,
ERROR_PARAMETER_TYPE,
false,
@@ -28,7 +28,8 @@ public class JetStandardLibrary {
// private static final Map<Project, JetStandardLibrary> standardLibraryCache = new HashMap<Project, JetStandardLibrary>();
// TODO : double checked locking
synchronized public static JetStandardLibrary getJetStandardLibrary(@NotNull Project project) {
synchronized
public static JetStandardLibrary getJetStandardLibrary(@NotNull Project project) {
if (cachedLibrary == null) {
cachedLibrary = new JetStandardLibrary(project);
}
@@ -55,8 +56,8 @@ public class JetStandardLibrary {
private final ClassDescriptor arrayClass;
private final ClassDescriptor iterableClass;
private final ClassDescriptor typeInfoClass;
private final JetType byteType;
private final JetType byteType;
private final JetType charType;
private final JetType shortType;
private final JetType intType;
@@ -86,7 +87,7 @@ public class JetStandardLibrary {
// bootstrappingTDA.process(writableScope, JetStandardClasses.STANDARD_CLASSES_NAMESPACE, file.getRootNamespace().getDeclarations());
bootstrappingTDA.processStandardLibraryNamespace(writableScope, JetStandardClasses.STANDARD_CLASSES_NAMESPACE, file.getRootNamespace());
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.charClass = (ClassDescriptor) libraryScope.getClassifier("Char");
@@ -313,28 +313,10 @@ public class JetTypeChecker {
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
// as the second parameter, applying the substitution of type arguments to it
@Nullable
private JetType findCorrespondingSupertype(@NotNull JetType subtype, @NotNull JetType supertype) {
private static JetType findCorrespondingSupertype(@NotNull JetType subtype, @NotNull JetType supertype) {
TypeConstructor constructor = subtype.getConstructor();
if (constructor.equals(supertype.getConstructor())) {
return subtype;
@@ -348,75 +330,270 @@ public class JetTypeChecker {
return null;
}
private 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();
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;
public boolean isSubtypeOf(@NotNull JetType subtype, @NotNull JetType supertype) {
return new TypeCheckingProcedure().run(subtype, supertype);
}
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.Nullable;
import org.jetbrains.jet.JetNodeTypes;
import org.jetbrains.jet.lang.ErrorHandlerWithRegions;
import org.jetbrains.jet.lang.JetSemanticServices;
import org.jetbrains.jet.lang.cfg.JetFlowInformationProvider;
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.CompileTimeConstantResolver;
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.resolve.DescriptorRenderer;
import org.jetbrains.jet.lang.resolve.constants.StringValue;
import org.jetbrains.jet.util.WritableSlice;
import java.util.*;
import static org.jetbrains.jet.lang.resolve.BindingContext.STATEMENT;
/**
* @author abreslav
*/
@@ -176,11 +179,11 @@ public class JetTypeInferrer {
@Nullable
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) {
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
@@ -321,7 +324,7 @@ public class JetTypeInferrer {
private void report(OverloadResolutionResult resolutionResult) {
if (resolutionResult.isSuccess() || resolutionResult.singleFunction()) {
trace.recordReferenceResolution(referenceExpression, resolutionResult.getFunctionDescriptor());
trace.record(BindingContext.REFERENCE_TARGET, referenceExpression, resolutionResult.getFunctionDescriptor());
}
if (reportErrors) {
switch (resolutionResult.getResultCode()) {
@@ -375,7 +378,7 @@ public class JetTypeInferrer {
// return; // The function returns Nothing
// }
// for (Map.Entry<JetElement, JetType> entry : typeMap.entrySet()) {
// JetType actualType = entry.getValue();
// JetType actualType = entry.castValue();
// JetElement element = entry.getKey();
// JetTypeChecker typeChecker = semanticServices.getTypeChecker();
// if (!typeChecker.isSubtypeOf(actualType, expectedReturnType)) {
@@ -414,8 +417,8 @@ public class JetTypeInferrer {
final boolean blockBody = function.hasBlockBody();
final TypeInferenceContext context =
blockBody
? new TypeInferenceContext(trace, functionInnerScope, this, function.hasBlockBody(), dataFlowInfo, NO_EXPECTED_TYPE, expectedReturnType)
: new TypeInferenceContext(trace, functionInnerScope, this, function.hasBlockBody(), dataFlowInfo, expectedReturnType, FORBIDDEN);
? new TypeInferenceContext(trace, functionInnerScope, function.hasBlockBody(), dataFlowInfo, NO_EXPECTED_TYPE, expectedReturnType)
: new TypeInferenceContext(trace, functionInnerScope, function.hasBlockBody(), dataFlowInfo, expectedReturnType, FORBIDDEN);
typeInferrerVisitor.getType(bodyExpression, context);
@@ -484,14 +487,14 @@ public class JetTypeInferrer {
JetExpression bodyExpression = function.getBodyExpression();
assert bodyExpression != null;
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<JetElement> elementsReturningUnit = new ArrayList<JetElement>();
flowInformationProvider.collectReturnedInformation(function.asElement(), returnedExpressions, elementsReturningUnit);
Map<JetElement,JetType> typeMap = new HashMap<JetElement, JetType>();
for (JetExpression returnedExpression : returnedExpressions) {
JetType cachedType = trace.getBindingContext().getExpressionType(returnedExpression);
trace.removeStatementRecord(returnedExpression);
JetType cachedType = trace.getBindingContext().get(BindingContext.EXPRESSION_TYPE, returnedExpression);
trace.record(STATEMENT, returnedExpression, false);
if (cachedType != null) {
typeMap.put(returnedExpression, cachedType);
}
@@ -508,16 +511,16 @@ public class JetTypeInferrer {
}
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;
for (Iterator<? extends JetElement> iterator = block.iterator(); iterator.hasNext(); ) {
JetElement statement = iterator.next();
trace.recordStatement(statement);
trace.record(STATEMENT, statement);
JetExpression statementExpression = (JetExpression) statement;
//TODO constructor assert context.expectedType != FORBIDDEN : ""
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);
@@ -526,13 +529,78 @@ public class JetTypeInferrer {
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?
}
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
private JetType resolveCall(
@NotNull JetScope scope,
@@ -718,7 +786,7 @@ public class JetTypeInferrer {
if (constructorReturnedType == null && !ErrorUtils.isErrorType(receiverType)) {
DeclarationDescriptor declarationDescriptor = receiverType.getConstructor().getDeclarationDescriptor();
assert declarationDescriptor != null;
trace.recordReferenceResolution(referenceExpression, declarationDescriptor);
trace.record(BindingContext.REFERENCE_TARGET, referenceExpression, declarationDescriptor);
// TODO : more helpful message
JetValueArgumentList argumentList = call.getValueArgumentList();
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)) {
return expressionType;
}
JetType enrichedType = null;
VariableDescriptor variableDescriptor = getVariableDescriptorFromSimpleName(expression, context);
if (variableDescriptor != null) {
if (variableDescriptor == null) return expressionType;
List<JetType> possibleTypes = Lists.newArrayList(context.dataFlowInfo.getPossibleTypes(variableDescriptor));
Collections.reverse(possibleTypes);
for (JetType possibleType : possibleTypes) {
if (semanticServices.getTypeChecker().isSubtypeOf(possibleType, context.expectedType)) {
enrichedType = possibleType;
break;
}
}
if (enrichedType == null) {
enrichedType = context.dataFlowInfo.getOutType(variableDescriptor);
JetType enrichedType = null;
List<JetType> possibleTypes = Lists.newArrayList(context.dataFlowInfo.getPossibleTypes(variableDescriptor));
Collections.reverse(possibleTypes);
for (JetType possibleType: possibleTypes) {
if (semanticServices.getTypeChecker().isSubtypeOf(possibleType, context.expectedType)) {
enrichedType = possibleType;
break;
}
}
if (enrichedType == null) {
enrichedType = context.dataFlowInfo.getOutType(variableDescriptor);
}
if (enrichedType == null) {
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);
} else {
context.trace.recordAutoCast(expression, context.expectedType, variableDescriptor);
context.trace.record(BindingContext.AUTOCAST, expression, context.expectedType);
}
return enrichedType;
}
@@ -815,7 +881,7 @@ public class JetTypeInferrer {
VariableDescriptor variableDescriptor = null;
if (receiverExpression instanceof JetSimpleNameExpression) {
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) {
variableDescriptor = (VariableDescriptor) declarationDescriptor;
}
@@ -843,7 +909,6 @@ public class JetTypeInferrer {
private TypeInferenceContext(
@NotNull BindingTrace trace,
@NotNull JetScope scope,
@NotNull Services services,
boolean preferBlock,
@NotNull DataFlowInfo dataFlowInfo,
@NotNull JetType expectedType,
@@ -852,7 +917,7 @@ public class JetTypeInferrer {
this.typeResolver = new TypeResolver(semanticServices, trace, true);
this.classDescriptorResolver = semanticServices.getClassDescriptorResolver(trace);
this.scope = scope;
this.services = services;
this.services = getServices(trace);
this.preferBlock = preferBlock;
this.dataFlowInfo = dataFlowInfo;
this.expectedType = expectedType;
@@ -861,19 +926,24 @@ public class JetTypeInferrer {
}
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) {
if (newExpectedType == null) return replaceExpectedType(NO_EXPECTED_TYPE);
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) {
if (newExpectedReturnType == null) return replaceExpectedReturnType(NO_EXPECTED_TYPE);
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
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) {
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
public final JetType getType(@NotNull JetExpression expression, TypeInferenceContext context) {
if (context.trace.isProcessed(expression)) {
return context.trace.getBindingContext().getExpressionType(expression);
if (context.trace.get(BindingContext.PROCESSED, expression)) {
return context.trace.getBindingContext().get(BindingContext.EXPRESSION_TYPE, expression);
}
JetType result;
try {
result = expression.visit(this, context);
// Some recursive definitions (object expressions) must put their types in the cache manually:
if (context.trace.isProcessed(expression)) {
return context.trace.getBindingContext().getExpressionType(expression);
if ((boolean) context.trace.get(BindingContext.PROCESSED, expression)) {
return context.trace.getBindingContext().get(BindingContext.EXPRESSION_TYPE, expression);
}
if (result instanceof DeferredType) {
result = ((DeferredType) result).getActualType();
}
if (result != null) {
context.trace.recordExpressionType(expression, result);
context.trace.record(BindingContext.EXPRESSION_TYPE, expression, result);
if (JetStandardClasses.isNothing(result) && !result.isNullable()) {
markDominatedExpressionsAsUnreachable(expression, context);
}
@@ -923,10 +993,10 @@ public class JetTypeInferrer {
result = null;
}
if (!context.trace.isProcessed(expression)) {
context.trace.recordResolutionScope(expression, context.scope);
if (!(boolean) context.trace.get(BindingContext.PROCESSED, expression)) {
context.trace.record(BindingContext.RESOLUTION_SCOPE, expression, context.scope);
}
context.trace.markAsProcessed(expression);
context.trace.record(BindingContext.PROCESSED, expression);
return result;
}
@@ -974,7 +1044,7 @@ public class JetTypeInferrer {
context.trace.getErrorHandler().unresolvedReference(expression);
}
else {
context.trace.recordReferenceResolution(expression, property);
context.trace.record(BindingContext.REFERENCE_TARGET, expression, property);
return context.services.checkEnrichedType(property.getOutType(), expression, context);
}
}
@@ -983,7 +1053,7 @@ public class JetTypeInferrer {
if (referencedName != null) {
VariableDescriptor variable = context.scope.getVariable(referencedName);
if (variable != null) {
context.trace.recordReferenceResolution(expression, variable);
context.trace.record(BindingContext.REFERENCE_TARGET, expression, variable);
JetType result = variable.getOutType();
if (result == null) {
context.trace.getErrorHandler().genericError(expression.getNode(), "This variable is not readable in this context");
@@ -1001,7 +1071,7 @@ public class JetTypeInferrer {
else {
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);
}
else {
@@ -1037,16 +1107,17 @@ public class JetTypeInferrer {
if (namespace == null) {
return null;
}
context.trace.recordReferenceResolution(expression, namespace);
context.trace.record(BindingContext.REFERENCE_TARGET, expression, namespace);
return namespace.getNamespaceType();
}
@Override
public JetType visitObjectLiteralExpression(final JetObjectLiteralExpression expression, final TypeInferenceContext context) {
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
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()) {
JetType defaultType = new DeferredType(new LazyValue<JetType>() {
@Override
@@ -1055,14 +1126,19 @@ public class JetTypeInferrer {
}
});
result[0] = defaultType;
if (!context.trace.isProcessed(expression)) {
recordExpressionType(expression, defaultType);
markAsProcessed(expression);
if (!context.trace.get(BindingContext.PROCESSED, expression)) {
context.trace.record(BindingContext.EXPRESSION_TYPE, expression, defaultType);
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());
return context.services.checkType(result[0], expression, context);
}
@@ -1071,7 +1147,7 @@ public class JetTypeInferrer {
public JetType visitFunctionLiteralExpression(JetFunctionLiteralExpression expression, TypeInferenceContext context) {
JetFunctionLiteral functionLiteral = expression.getFunctionLiteral();
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);
}
@@ -1108,7 +1184,7 @@ public class JetTypeInferrer {
JetType effectiveReceiverType = receiverTypeRef == null ? null : receiverType;
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;
JetScope functionInnerScope = FunctionDescriptorUtil.getFunctionInnerScope(context.scope, functionDescriptor, context.trace);
@@ -1171,7 +1247,7 @@ public class JetTypeInferrer {
return null;
}
else {
context.trace.recordCompileTimeValue(expression, value);
context.trace.record(BindingContext.COMPILE_TIME_VALUE, expression, value);
return context.services.checkType(value.getType(standardLibrary), expression, context);
}
}
@@ -1305,22 +1381,22 @@ public class JetTypeInferrer {
else {
throw new UnsupportedOperationException(); // TODO
}
context.trace.recordReferenceResolution(targetLabel, declarationDescriptor);
context.trace.recordReferenceResolution(expression.getThisReference(), declarationDescriptor);
context.trace.record(BindingContext.REFERENCE_TARGET, targetLabel, declarationDescriptor);
context.trace.record(BindingContext.REFERENCE_TARGET, expression.getThisReference(), declarationDescriptor);
}
else if (size == 0) {
// 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) {
DeclarationDescriptor declarationDescriptor = context.trace.getBindingContext().getDeclarationDescriptor(psiElement);
DeclarationDescriptor declarationDescriptor = context.trace.getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, psiElement);
if (declarationDescriptor instanceof FunctionDescriptor) {
thisType = ((FunctionDescriptor) declarationDescriptor).getReceiverType();
if (thisType == null) {
thisType = JetStandardClasses.getNothingType();
}
else {
context.trace.recordReferenceResolution(targetLabel, declarationDescriptor);
context.trace.recordReferenceResolution(expression.getThisReference(), declarationDescriptor);
context.trace.record(BindingContext.REFERENCE_TARGET, targetLabel, declarationDescriptor);
context.trace.record(BindingContext.REFERENCE_TARGET, expression.getThisReference(), declarationDescriptor);
}
}
else {
@@ -1340,7 +1416,7 @@ public class JetTypeInferrer {
DeclarationDescriptor declarationDescriptorForUnqualifiedThis = context.scope.getDeclarationDescriptorForUnqualifiedThis();
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;
}
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
// 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()) {
extendDataFlowWithNullComparison(operationToken, variableDescriptor, !conditionValue);
return;
@@ -1772,7 +1848,7 @@ public class JetTypeInferrer {
VariableDescriptor rightVariable = context.services.getVariableDescriptorFromSimpleName(right, context);
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()) {
extendDataFlowWithNullComparison(operationToken, rightVariable, !conditionValue);
return;
@@ -1865,7 +1941,7 @@ public class JetTypeInferrer {
WritableScope writableScope = newWritableScopeImpl(context.scope, context.trace).setDebugName("do..while body scope");
conditionScope = writableScope;
context.services.getBlockReturnedTypeWithWritableScope(writableScope, function.getFunctionLiteral().getBodyExpression().getStatements(), context);
context.trace.recordBlock(function);
context.trace.record(BindingContext.BLOCK, function);
} else {
getType(context.scope, body, true, context);
}
@@ -2095,11 +2171,15 @@ public class JetTypeInferrer {
// TODO : functions as values
JetExpression selectorExpression = expression.getSelectorExpression();
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;
ErrorHandlerWithRegions errorHandler = context.trace.getErrorHandler();
errorHandler.openRegion();
JetType selectorReturnType = getSelectorReturnType(receiverType, selectorExpression, context);
// Clean resolution: no autocasts
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
if (expression.getOperationSign() == JetTokens.SAFE_ACCESS) {
@@ -2108,37 +2188,41 @@ public class JetTypeInferrer {
}
}
if (selectorReturnType != null) {
errorHandler.closeAndCommitCurrentRegion();
cleanResolutionTrace.addAllMyDataTo(context.trace);
}
else {
ErrorHandlerWithRegions.DiagnosticsRegion regionToCommit = errorHandler.closeAndReturnCurrentRegion();
VariableDescriptor variableDescriptor = context.services.getVariableDescriptorFromSimpleName(receiverExpression, context);
VariableDescriptor variableDescriptor = cleanResolutionContext.services.getVariableDescriptorFromSimpleName(receiverExpression, context);
boolean somethingFound = false;
if (variableDescriptor != null) {
List<JetType> possibleTypes = Lists.newArrayList(context.dataFlowInfo.getPossibleTypes(variableDescriptor));
Collections.reverse(possibleTypes);
TemporaryBindingTrace autocastResolutionTrace = new TemporaryBindingTrace(context.trace.getBindingContext());
TypeInferenceContext autocastResolutionContext = context.replaceBindingTrace(autocastResolutionTrace);
for (JetType possibleType : possibleTypes) {
errorHandler.openRegion();
selectorReturnType = getSelectorReturnType(possibleType, selectorExpression, context);
selectorReturnType = getSelectorReturnType(possibleType, selectorExpression, autocastResolutionContext);
if (selectorReturnType != null) {
regionToCommit = errorHandler.closeAndReturnCurrentRegion();
context.trace.recordAutoCast(receiverExpression, possibleType, variableDescriptor);
autocastResolutionTrace.record(BindingContext.AUTOCAST, receiverExpression, possibleType);
autocastResolutionTrace.addAllMyDataTo(context.trace);
somethingFound = true;
break;
}
else {
errorHandler.closeAndReturnCurrentRegion();
autocastResolutionTrace = new TemporaryBindingTrace(context.trace.getBindingContext());
autocastResolutionContext = context.replaceBindingTrace(autocastResolutionTrace);
}
}
}
regionToCommit.commit();
if (!somethingFound) {
cleanResolutionTrace.addAllMyDataTo(context.trace);
}
}
JetType result;
if (expression.getOperationSign() == JetTokens.QUEST) {
if (selectorReturnType != null && !isBoolean(selectorReturnType) && selectorExpression != null) {
// 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);
}
@@ -2146,7 +2230,7 @@ public class JetTypeInferrer {
result = selectorReturnType;
}
if (selectorExpression != null && result != null) {
context.trace.recordExpressionType(selectorExpression, result);
context.trace.record(BindingContext.EXPRESSION_TYPE, selectorExpression, result);
}
if (selectorReturnType != null) {
// TODO : extensions to 'Any?'
@@ -2174,7 +2258,7 @@ public class JetTypeInferrer {
@Override
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) {
result[0] = (FunctionDescriptor) declarationDescriptor;
}
@@ -2232,6 +2316,7 @@ public class JetTypeInferrer {
@Override
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);
}
@@ -2279,7 +2364,7 @@ public class JetTypeInferrer {
context.trace.getErrorHandler().genericError(operationSign.getNode(), name + " must return " + receiverType + " but returns " + returnType);
}
else {
context.trace.recordVariableReassignment(expression);
context.trace.record(BindingContext.VARIABLE_REASSIGNMENT, expression);
}
// TODO : Maybe returnType?
result = receiverType;
@@ -2459,7 +2544,7 @@ public class JetTypeInferrer {
@Nullable
protected List<JetType> getTypes(JetScope scope, List<JetExpression> indexExpressions, TypeInferenceContext context) {
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) {
JetType type = context.services.typeInferrerVisitor.getType(indexExpression, newContext);
if (type == null) {
@@ -2590,7 +2675,7 @@ public class JetTypeInferrer {
});
}
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);
}
@@ -2638,7 +2723,7 @@ public class JetTypeInferrer {
public JetType visitObjectDeclaration(JetObjectDeclaration declaration, TypeInferenceContext context) {
TopDownAnalyzer topDownAnalyzer = new TopDownAnalyzer(semanticServices, context.trace);
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) {
PropertyDescriptor propertyDescriptor = context.classDescriptorResolver.resolveObjectDeclarationAsPropertyDescriptor(scope.getContainingDeclaration(), declaration, classDescriptor);
scope.addVariableDescriptor(propertyDescriptor);
@@ -2712,7 +2797,7 @@ public class JetTypeInferrer {
String counterpartName = binaryOperationNames.get(assignmentOperationCounterparts.get(operationType));
JetType typeForBinaryCall = getTypeForBinaryCall(expression, counterpartName, scope, true, context);
if (typeForBinaryCall != null) {
context.trace.recordVariableReassignment(expression);
context.trace.record(BindingContext.VARIABLE_REASSIGNMENT, expression);
}
}
return null;
@@ -15,6 +15,30 @@ import java.util.Map;
*/
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 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) {
return new TypeSubstitutor(substitutionContext);
return create(new MapToTypeSubstitutionAdapter(substitutionContext));
}
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;
}
@@ -109,7 +137,7 @@ public class TypeSubstitutor {
@NotNull
private TypeProjection substituteInProjection(
@NotNull Map<TypeConstructor, TypeProjection> substitutionContext,
@NotNull TypeSubstitution substitutionContext,
@NotNull TypeProjection passedProjection,
@NotNull TypeParameterDescriptor correspondingTypeParameter,
@NotNull Variance contextCallSiteVariance) throws SubstitutionException {
@@ -181,10 +209,6 @@ public class TypeSubstitutor {
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) {
return a == Variance.INVARIANT ? b : a;
}
@@ -50,6 +50,9 @@ public class TypeUtils {
StringBuilder debugName = new StringBuilder();
boolean nullable = false;
Set<JetType> resultingTypes = Sets.newHashSet();
outer:
for (Iterator<JetType> iterator = types.iterator(); iterator.hasNext();) {
JetType type = iterator.next();
@@ -63,9 +66,17 @@ public class TypeUtils {
}
return type;
}
else {
for (JetType other : types) {
if (!type.equals(other) && typeChecker.isSubtypeOf(other, type)) {
continue outer;
}
}
}
nullable |= type.isNullable();
resultingTypes.add(type);
debugName.append(type.toString());
if (iterator.hasNext()) {
debugName.append(" & ");
@@ -79,11 +90,11 @@ public class TypeUtils {
false,
debugName.toString(),
Collections.<TypeParameterDescriptor>emptyList(),
types);
resultingTypes);
JetScope[] scopes = new JetScope[types.size()];
JetScope[] scopes = new JetScope[resultingTypes.size()];
int i = 0;
for (JetType type : types) {
for (JetType type : resultingTypes) {
scopes[i] = type.getMemberScope();
i++;
}
@@ -217,12 +228,15 @@ public class TypeUtils {
*/
@NotNull
public static TypeSubstitutor buildDeepSubstitutor(@NotNull JetType type) {
TypeSubstitutor typeSubstitutor = TypeSubstitutor.create(Maps.<TypeConstructor, TypeProjection>newHashMap());
fillInDeepSubstitutor(type, typeSubstitutor);
HashMap<TypeConstructor, TypeProjection> substitution = Maps.<TypeConstructor, TypeProjection>newHashMap();
TypeSubstitutor typeSubstitutor = TypeSubstitutor.create(substitution);
// we use the mutability of the map here
fillInDeepSubstitutor(type, typeSubstitutor, substitution);
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<TypeProjection> arguments = context.getArguments();
for (int i = 0; i < arguments.size(); i++) {
@@ -232,10 +246,10 @@ public class TypeUtils {
JetType substitute = substitutor.substitute(argument.getType(), Variance.INVARIANT);
assert substitute != null;
TypeProjection substitutedTypeProjection = new TypeProjection(argument.getProjectionKind(), substitute);
substitutor.addSubstitution(typeParameterDescriptor.getTypeConstructor(), substitutedTypeProjection);
substitution.put(typeParameterDescriptor.getTypeConstructor(), substitutedTypeProjection);
}
for (JetType supertype : context.getConstructor().getSupertypes()) {
fillInDeepSubstitutor(supertype, substitutor);
fillInDeepSubstitutor(supertype, substitutor, substitution);
}
}
@@ -38,6 +38,18 @@ public enum Variance {
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
public String toString() {
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.resolve.AnalyzingUtils;
import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
import org.jetbrains.jet.resolve.DescriptorRenderer;
/**
@@ -26,13 +27,13 @@ public class JetQuickDocumentationProvider extends AbstractDocumentationProvider
}
if (ref != null) {
BindingContext bindingContext = AnalyzingUtils.analyzeFileWithCache((JetFile) element.getContainingFile());
DeclarationDescriptor declarationDescriptor = bindingContext.resolveReferenceExpression(ref);
DeclarationDescriptor declarationDescriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, ref);
if (declarationDescriptor != null) {
return render(declarationDescriptor);
}
PsiElement psiElement = bindingContext.resolveToDeclarationPsiElement(ref);
PsiElement psiElement = BindingContextUtils.resolveToDeclarationPsiElement(bindingContext, ref);
if (psiElement != null) {
declarationDescriptor = bindingContext.getDeclarationDescriptor(psiElement);
declarationDescriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, psiElement);
if (declarationDescriptor != null) {
return render(declarationDescriptor);
}
@@ -36,7 +36,7 @@ public class ShowExpressionTypeAction extends AnAction {
else {
int offset = editor.getCaretModel().getOffset();
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);
}
if (expression != null) {
@@ -45,7 +45,7 @@ public class ShowExpressionTypeAction extends AnAction {
}
}
if (expression != null) {
JetType type = bindingContext.getExpressionType(expression);
JetType type = bindingContext.get(BindingContext.EXPRESSION_TYPE, expression);
if (type != null) {
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.PsiUtilBase;
import com.intellij.ui.awt.RelativePoint;
import com.intellij.util.Function;
import com.intellij.util.Icons;
import com.intellij.util.PsiIconUtil;
import com.intellij.util.PsiNavigateUtil;
import com.intellij.util.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.psi.*;
@@ -49,14 +46,14 @@ public class JetLineMarkerProvider implements LineMarkerProvider {
if (element instanceof JetClass) {
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);
return createLineMarkerInfo(jetClass, text);
}
if (element instanceof JetProperty) {
JetProperty jetProperty = (JetProperty) element;
final VariableDescriptor variableDescriptor = bindingContext.getVariableDescriptor(jetProperty);
final VariableDescriptor variableDescriptor = bindingContext.get(BindingContext.VARIABLE, jetProperty);
if (variableDescriptor instanceof PropertyDescriptor) {
return createLineMarkerInfo(element, DescriptorRenderer.HTML.render(variableDescriptor));
}
@@ -65,10 +62,10 @@ public class JetLineMarkerProvider implements LineMarkerProvider {
if (element instanceof JetNamedFunction) {
JetNamedFunction jetFunction = (JetNamedFunction) element;
final FunctionDescriptor functionDescriptor = bindingContext.getFunctionDescriptor(jetFunction);
final FunctionDescriptor functionDescriptor = bindingContext.get(BindingContext.FUNCTION, jetFunction);
if (functionDescriptor == null) return null;
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>(
jetFunction, jetFunction.getTextOffset(), icon, Pass.UPDATE_ALL,
new Function<JetNamedFunction, String>() {
@@ -97,7 +94,7 @@ public class JetLineMarkerProvider implements LineMarkerProvider {
if (overriddenFunctions.isEmpty()) return;
final List<PsiElement> list = Lists.newArrayList();
for (FunctionDescriptor overriddenFunction : overriddenFunctions) {
PsiElement declarationPsiElement = bindingContext.getDeclarationPsiElement(overriddenFunction);
PsiElement declarationPsiElement = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, overriddenFunction);
list.add(declarationPsiElement);
}
if (list.isEmpty()) {
@@ -118,7 +115,7 @@ public class JetLineMarkerProvider implements LineMarkerProvider {
public String getElementText(PsiElement element) {
if (element instanceof JetNamedFunction) {
JetNamedFunction function = (JetNamedFunction) element;
return DescriptorRenderer.HTML.render(bindingContext.getFunctionDescriptor(function));
return DescriptorRenderer.HTML.render(bindingContext.get(BindingContext.FUNCTION, function));
}
return super.getElementText(element);
}
@@ -134,18 +131,18 @@ public class JetLineMarkerProvider implements LineMarkerProvider {
if (element instanceof JetNamespace) {
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)) {
JetObjectDeclaration jetObjectDeclaration = (JetObjectDeclaration) element;
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>() {
@Override
public String fun(JetObjectDeclaration jetObjectDeclaration) {
ClassDescriptor classDescriptor = bindingContext.getClassDescriptor(jetObjectDeclaration);
ClassDescriptor classDescriptor = bindingContext.get(BindingContext.CLASS, jetObjectDeclaration);
if (classDescriptor != null) {
return DescriptorRenderer.HTML.renderAsObject(classDescriptor);
}
@@ -75,7 +75,7 @@ public class JetPsiChecker implements Annotator {
private void markRedeclaration(DeclarationDescriptor redeclaration) {
if (!redeclarations.add(redeclaration)) return;
PsiElement declarationPsiElement = bindingContext.getDeclarationPsiElement(redeclaration);
PsiElement declarationPsiElement = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, redeclaration);
if (declarationPsiElement instanceof JetNamedDeclaration) {
PsiElement nameIdentifier = ((JetNamedDeclaration) declarationPsiElement).getNameIdentifier();
assert nameIdentifier != null : declarationPsiElement.getText() + " has nameIdentifier 'null'";
@@ -106,7 +106,7 @@ public class JetPsiChecker implements Annotator {
file.acceptChildren(new JetVisitorVoid() {
@Override
public void visitExpression(JetExpression expression) {
JetType autoCast = bindingContext.getAutoCastType(expression);
JetType autoCast = bindingContext.get(BindingContext.AUTOCAST, expression);
if (autoCast != null) {
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() {
@Override
public void visitProperty(JetProperty property) {
VariableDescriptor propertyDescriptor = bindingContext.getVariableDescriptor(property);
VariableDescriptor propertyDescriptor = bindingContext.get(BindingContext.VARIABLE, property);
if (propertyDescriptor instanceof PropertyDescriptor) {
if (bindingContext.hasBackingField((PropertyDescriptor) propertyDescriptor)) {
if ((boolean) bindingContext.get(BindingContext.BACKING_FIELD_REQUIRED, (PropertyDescriptor) propertyDescriptor)) {
putBackingfieldAnnotation(holder, property);
}
}
@@ -145,8 +145,8 @@ public class JetPsiChecker implements Annotator {
@Override
public void visitParameter(JetParameter parameter) {
PropertyDescriptor propertyDescriptor = bindingContext.getPropertyDescriptor(parameter);
if (propertyDescriptor != null && bindingContext.hasBackingField(propertyDescriptor)) {
PropertyDescriptor propertyDescriptor = bindingContext.get(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, parameter);
if (propertyDescriptor != null && bindingContext.get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor)) {
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();
}
+10 -8
View File
@@ -15,10 +15,11 @@ JetFile: AnnotatedExpressions.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
REFERENCE_EXPRESSION
@@ -31,10 +32,11 @@ JetFile: AnnotatedExpressions.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
THIS_EXPRESSION
+105 -92
View File
@@ -38,25 +38,26 @@ JetFile: Attributes.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('foo')
TYPE_ARGUMENT_LIST
PsiElement(LT)('<')
TYPE_PROJECTION
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('A')
PsiElement(COMMA)(',')
PsiWhiteSpace(' ')
TYPE_PROJECTION
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('B')
PsiElement(GT)('>')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('foo')
TYPE_ARGUMENT_LIST
PsiElement(LT)('<')
TYPE_PROJECTION
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('A')
PsiElement(COMMA)(',')
PsiWhiteSpace(' ')
TYPE_PROJECTION
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('B')
PsiElement(GT)('>')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
@@ -70,68 +71,71 @@ JetFile: Attributes.jet
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('ina')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('ina')
PsiWhiteSpace(' ')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
USER_TYPE
USER_TYPE
USER_TYPE
USER_TYPE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('foo')
PsiElement(IDENTIFIER)('bar')
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('bar')
PsiElement(IDENTIFIER)('goo')
PsiElement(DOT)('.')
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)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('doo')
PsiElement(IDENTIFIER)('foo')
TYPE_ARGUMENT_LIST
PsiElement(LT)('<')
TYPE_PROJECTION
TYPE_REFERENCE
USER_TYPE
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(DOT)('.')
REFERENCE_EXPRESSION
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)(']')
PsiWhiteSpace('\n')
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('df')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('df')
PsiElement(RBRACKET)(']')
PsiWhiteSpace('\n')
PsiElement(in)('in')
@@ -139,10 +143,11 @@ JetFile: Attributes.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('sdfsdf')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('sdfsdf')
PsiElement(RBRACKET)(']')
PsiWhiteSpace('\n')
PsiElement(out)('out')
@@ -163,10 +168,11 @@ JetFile: Attributes.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('sdfsdf')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('sdfsdf')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
@@ -180,19 +186,21 @@ JetFile: Attributes.jet
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace('\n')
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('sdfsdf')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('sdfsdf')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
@@ -209,19 +217,21 @@ JetFile: Attributes.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('sdfsdf')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('sdfsdf')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
@@ -250,34 +260,37 @@ JetFile: Attributes.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('sdfsd')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('sdfsd')
PsiWhiteSpace(' ')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('sdfsd')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('sdfsd')
PsiWhiteSpace(' ')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
USER_TYPE
USER_TYPE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(IDENTIFIER)('b')
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('b')
PsiElement(IDENTIFIER)('f')
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('f')
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('c')
PsiElement(IDENTIFIER)('c')
PsiElement(RBRACKET)(']')
PsiWhiteSpace('\n')
PsiElement(private)('private')
+30 -24
View File
@@ -29,10 +29,11 @@ JetFile: AttributesOnPatterns.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
PROPERTY
@@ -53,10 +54,11 @@ JetFile: AttributesOnPatterns.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
PROPERTY
@@ -86,10 +88,11 @@ JetFile: AttributesOnPatterns.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
PsiElement(MUL)('*')
@@ -107,10 +110,11 @@ JetFile: AttributesOnPatterns.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
INTEGER_CONSTANT
@@ -129,10 +133,11 @@ JetFile: AttributesOnPatterns.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
TYPE_REFERENCE
@@ -153,10 +158,11 @@ JetFile: AttributesOnPatterns.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
REFERENCE_EXPRESSION
+95 -84
View File
@@ -44,25 +44,26 @@ JetFile: Attributes_ERR.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('foo')
TYPE_ARGUMENT_LIST
PsiElement(LT)('<')
TYPE_PROJECTION
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('A')
PsiElement(COMMA)(',')
PsiWhiteSpace(' ')
TYPE_PROJECTION
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('B')
PsiElement(GT)('>')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('foo')
TYPE_ARGUMENT_LIST
PsiElement(LT)('<')
TYPE_PROJECTION
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('A')
PsiElement(COMMA)(',')
PsiWhiteSpace(' ')
TYPE_PROJECTION
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('B')
PsiElement(GT)('>')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
@@ -78,68 +79,71 @@ JetFile: Attributes_ERR.jet
PsiElement(COMMA)(',')
PsiWhiteSpace(' ')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('ina')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('ina')
PsiWhiteSpace(' ')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
USER_TYPE
USER_TYPE
USER_TYPE
USER_TYPE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('foo')
PsiElement(IDENTIFIER)('bar')
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('bar')
PsiElement(IDENTIFIER)('goo')
PsiElement(DOT)('.')
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)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('doo')
PsiElement(IDENTIFIER)('foo')
TYPE_ARGUMENT_LIST
PsiElement(LT)('<')
TYPE_PROJECTION
TYPE_REFERENCE
USER_TYPE
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(DOT)('.')
REFERENCE_EXPRESSION
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)(']')
PsiWhiteSpace('\n')
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('df')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('df')
PsiElement(RBRACKET)(']')
PsiWhiteSpace('\n')
PsiElement(in)('in')
@@ -147,32 +151,36 @@ JetFile: Attributes_ERR.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('sdfsdf')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('sdfsdf')
PsiWhiteSpace(' ')
PsiElement(RBRACKET)(']')
PsiWhiteSpace('\n')
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('s')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('s')
PsiWhiteSpace(' ')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('fd')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('fd')
PsiWhiteSpace(' ')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('d')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('d')
PsiErrorElement:No commas needed to separate attributes
PsiElement(COMMA)(',')
PsiWhiteSpace(' ')
@@ -208,34 +216,37 @@ JetFile: Attributes_ERR.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('sdfsd')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('sdfsd')
PsiWhiteSpace(' ')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('sdfsd')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('sdfsd')
PsiWhiteSpace(' ')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
USER_TYPE
USER_TYPE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(IDENTIFIER)('b')
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('b')
PsiElement(IDENTIFIER)('f')
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('f')
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('c')
PsiElement(IDENTIFIER)('c')
PsiElement(RBRACKET)(']')
PsiWhiteSpace('\n')
PsiElement(private)('private')
+5 -4
View File
@@ -39,10 +39,11 @@ JetFile: BabySteps.jet
PsiWhiteSpace(' ')
DELEGATION_SPECIFIER_LIST
DELEGATOR_SUPER_CALL
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('foo')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('foo')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
+5 -4
View File
@@ -39,10 +39,11 @@ JetFile: BabySteps_ERR.jet
PsiWhiteSpace(' ')
DELEGATION_SPECIFIER_LIST
DELEGATOR_SUPER_CALL
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('foo')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('foo')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
+26 -24
View File
@@ -41,18 +41,19 @@ JetFile: Constructors.jet
PsiElement(COMMA)(',')
PsiWhiteSpace(' ')
DELEGATOR_SUPER_CALL
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Foo')
TYPE_ARGUMENT_LIST
PsiElement(LT)('<')
TYPE_PROJECTION
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('T')
PsiElement(GT)('>')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Foo')
TYPE_ARGUMENT_LIST
PsiElement(LT)('<')
TYPE_PROJECTION
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('T')
PsiElement(GT)('>')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
@@ -100,18 +101,19 @@ JetFile: Constructors.jet
PsiElement(COMMA)(',')
PsiWhiteSpace(' ')
DELEGATOR_SUPER_CALL
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Foo')
TYPE_ARGUMENT_LIST
PsiElement(LT)('<')
TYPE_PROJECTION
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('T')
PsiElement(GT)('>')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Foo')
TYPE_ARGUMENT_LIST
PsiElement(LT)('<')
TYPE_PROJECTION
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('T')
PsiElement(GT)('>')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
+10 -8
View File
@@ -57,10 +57,11 @@ JetFile: EOLsOnRollback.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
PsiElement(var)('var')
@@ -80,10 +81,11 @@ JetFile: EOLsOnRollback.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
PsiElement(val)('val')
+41 -36
View File
@@ -37,10 +37,11 @@ JetFile: Enums.jet
PsiWhiteSpace(' ')
INITIALIZER_LIST
DELEGATOR_SUPER_CALL
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Color')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Color')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
@@ -58,10 +59,11 @@ JetFile: Enums.jet
PsiWhiteSpace(' ')
INITIALIZER_LIST
DELEGATOR_SUPER_CALL
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Color')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Color')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
@@ -79,10 +81,11 @@ JetFile: Enums.jet
PsiWhiteSpace(' ')
INITIALIZER_LIST
DELEGATOR_SUPER_CALL
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Color')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Color')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
@@ -135,18 +138,19 @@ JetFile: Enums.jet
PsiWhiteSpace(' ')
INITIALIZER_LIST
DELEGATOR_SUPER_CALL
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('List')
TYPE_ARGUMENT_LIST
PsiElement(LT)('<')
TYPE_PROJECTION
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Nothing')
PsiElement(GT)('>')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('List')
TYPE_ARGUMENT_LIST
PsiElement(LT)('<')
TYPE_PROJECTION
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Nothing')
PsiElement(GT)('>')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
@@ -202,18 +206,19 @@ JetFile: Enums.jet
PsiWhiteSpace(' ')
INITIALIZER_LIST
DELEGATOR_SUPER_CALL
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('List')
TYPE_ARGUMENT_LIST
PsiElement(LT)('<')
TYPE_PROJECTION
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('T')
PsiElement(GT)('>')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('List')
TYPE_ARGUMENT_LIST
PsiElement(LT)('<')
TYPE_PROJECTION
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('T')
PsiElement(GT)('>')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
PsiComment(BLOCK_COMMENT)('/*tail.size + 1*/')
+15 -12
View File
@@ -463,10 +463,11 @@ JetFile: FunctionLiterals.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('x')
@@ -477,10 +478,11 @@ JetFile: FunctionLiterals.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('b')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('b')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('y')
@@ -491,10 +493,11 @@ JetFile: FunctionLiterals.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('c')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('c')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('z')
+35 -28
View File
@@ -20,10 +20,11 @@ JetFile: FunctionTypes.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
TYPE_REFERENCE
@@ -91,10 +92,11 @@ JetFile: FunctionTypes.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('x')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('x')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
USER_TYPE
@@ -149,10 +151,11 @@ JetFile: FunctionTypes.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
USER_TYPE
@@ -272,10 +275,11 @@ JetFile: FunctionTypes.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
USER_TYPE
@@ -673,10 +677,11 @@ JetFile: FunctionTypes.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
FUNCTION_TYPE
@@ -711,10 +716,11 @@ JetFile: FunctionTypes.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
FUNCTION_TYPE
@@ -753,10 +759,11 @@ JetFile: FunctionTypes.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
FUNCTION_TYPE
+70 -56
View File
@@ -14,10 +14,11 @@ JetFile: Functions.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
@@ -32,10 +33,11 @@ JetFile: Functions.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
USER_TYPE
@@ -54,10 +56,11 @@ JetFile: Functions.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
USER_TYPE
@@ -92,10 +95,11 @@ JetFile: Functions.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
@@ -168,10 +172,11 @@ JetFile: Functions.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
@@ -187,10 +192,11 @@ JetFile: Functions.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
USER_TYPE
@@ -210,10 +216,11 @@ JetFile: Functions.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
USER_TYPE
@@ -249,10 +256,11 @@ JetFile: Functions.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
@@ -329,10 +337,11 @@ JetFile: Functions.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
@@ -351,10 +360,11 @@ JetFile: Functions.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
USER_TYPE
@@ -377,10 +387,11 @@ JetFile: Functions.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
USER_TYPE
@@ -419,10 +430,11 @@ JetFile: Functions.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
@@ -491,10 +503,11 @@ JetFile: Functions.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
@@ -516,10 +529,11 @@ JetFile: Functions.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
FUNCTION_TYPE
+30 -24
View File
@@ -15,10 +15,11 @@ JetFile: Functions_ERR.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('f')
@@ -40,10 +41,11 @@ JetFile: Functions_ERR.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
USER_TYPE
@@ -77,10 +79,11 @@ JetFile: Functions_ERR.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
@@ -123,10 +126,11 @@ JetFile: Functions_ERR.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
@@ -176,10 +180,11 @@ JetFile: Functions_ERR.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
@@ -232,10 +237,11 @@ JetFile: Functions_ERR.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
+75 -66
View File
@@ -51,100 +51,109 @@ JetFile: Imports_ERR.jet
PsiWhiteSpace(' ')
MODIFIER_LIST
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.')
PsiWhiteSpace('\n')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('import')
PsiWhiteSpace(' ')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.')
PsiWhiteSpace('\n')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('bar')
PsiElement(DOT)('.')
PsiWhiteSpace('\n')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('import')
PsiElement(IDENTIFIER)('import')
PsiWhiteSpace(' ')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
CONSTRUCTOR_CALLEE
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
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.')
PsiWhiteSpace(' ')
REFERENCE_EXPRESSION
PsiErrorElement:Type name expected
PsiElement(as)('as')
PsiWhiteSpace(' ')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('bar')
PsiElement(IDENTIFIER)('bar')
PsiWhiteSpace('\n')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('import')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('import')
PsiWhiteSpace(' ')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
USER_TYPE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('foo')
PsiElement(IDENTIFIER)('bar')
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('bar')
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiErrorElement:Type name expected
PsiElement(MUL)('*')
PsiErrorElement:Type name expected
PsiElement(MUL)('*')
PsiWhiteSpace(' ')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(as)('as')
PsiWhiteSpace(' ')
MODIFIER_LIST
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
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
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
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('\n')
ANNOTATION_ENTRY
CONSTRUCTOR_CALLEE
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(' ')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(as)('as')
+15 -12
View File
@@ -22,10 +22,11 @@ JetFile: LocalDeclarations.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
PsiElement(abstract)('abstract')
@@ -47,10 +48,11 @@ JetFile: LocalDeclarations.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
PsiElement(class)('class')
@@ -81,10 +83,11 @@ JetFile: LocalDeclarations.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
PsiElement(var)('var')
+41 -36
View File
@@ -22,48 +22,52 @@ JetFile: NamespaceBlock_ERR.jet
NAMESPACE
MODIFIER_LIST
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.')
PsiWhiteSpace('\n')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('import')
PsiWhiteSpace(' ')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.')
PsiWhiteSpace('\n')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('bar')
PsiElement(DOT)('.')
PsiWhiteSpace('\n')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('import')
PsiElement(IDENTIFIER)('import')
PsiWhiteSpace(' ')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
CONSTRUCTOR_CALLEE
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
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.')
PsiWhiteSpace(' ')
REFERENCE_EXPRESSION
PsiErrorElement:Type name expected
PsiElement(as)('as')
PsiWhiteSpace(' ')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('bar')
PsiElement(IDENTIFIER)('bar')
PsiWhiteSpace('\n\n')
PsiElement(namespace)('namespace')
PsiWhiteSpace(' ')
@@ -255,10 +259,11 @@ JetFile: NamespaceBlock_ERR.jet
CLASS
MODIFIER_LIST
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('dsfgd')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('dsfgd')
PsiWhiteSpace('\n\n')
PsiElement(class)('class')
PsiWhiteSpace(' ')
+10 -8
View File
@@ -6,10 +6,11 @@ JetFile: NamespaceModifiers.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
PsiElement(namespace)('namespace')
@@ -23,10 +24,11 @@ JetFile: NamespaceModifiers.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
PsiElement(namespace)('namespace')
+10 -8
View File
@@ -29,10 +29,11 @@ JetFile: Properties.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
@@ -65,10 +66,11 @@ JetFile: Properties.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
@@ -223,10 +223,11 @@ JetFile: PropertiesFollowedByInitializers.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
PsiElement(abstract)('abstract')
+20 -16
View File
@@ -45,16 +45,18 @@ JetFile: Properties_ERR.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiWhiteSpace(' ')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('foo')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('foo')
PsiErrorElement:Expecting ']' to close an attribute annotation
<empty list>
PsiWhiteSpace(' ')
@@ -81,10 +83,11 @@ JetFile: Properties_ERR.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
@@ -133,10 +136,11 @@ JetFile: Properties_ERR.jet
PROPERTY
MODIFIER_LIST
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('foo')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace('\n\n')
PsiElement(val)('val')
PsiWhiteSpace(' ')
+5 -4
View File
@@ -5,10 +5,11 @@ JetFile: QuotedIdentifiers.jet
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('`return`')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('`return`')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
PsiElement(fun)('fun')

Some files were not shown because too many files have changed in this diff Show More