Merge branch master into pr/269
This commit is contained in:
@@ -9,7 +9,6 @@
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="frontend" />
|
||||
<orderEntry type="module" module-name="frontend.java" />
|
||||
<orderEntry type="library" name="asm-addons" level="project" />
|
||||
<orderEntry type="module" module-name="runtime" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="intellij-core" level="project" />
|
||||
<orderEntry type="library" name="javax.inject" level="project" />
|
||||
|
||||
@@ -115,7 +115,7 @@ public abstract class AnnotationCodegen {
|
||||
}
|
||||
|
||||
Name keyName = entry.getKey().getName();
|
||||
genAnnotationValueArgument(annotationVisitor, valueArgument, keyName.getName());
|
||||
genAnnotationValueArgument(annotationVisitor, valueArgument, keyName.asString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ public abstract class AnnotationCodegen {
|
||||
if (call != null) {
|
||||
if (call.getResultingDescriptor() instanceof PropertyDescriptor) {
|
||||
PropertyDescriptor descriptor = (PropertyDescriptor) call.getResultingDescriptor();
|
||||
annotationVisitor.visitEnum(keyName, typeMapper.mapType(descriptor).getDescriptor(), descriptor.getName().getName());
|
||||
annotationVisitor.visitEnum(keyName, typeMapper.mapType(descriptor).getDescriptor(), descriptor.getName().asString());
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -168,7 +168,7 @@ public abstract class AnnotationCodegen {
|
||||
if (annotations != null) {
|
||||
for (AnnotationDescriptor annotation : annotations) {
|
||||
//noinspection ConstantConditions
|
||||
if ("Intrinsic".equals(annotation.getType().getConstructor().getDeclarationDescriptor().getName().getName())) {
|
||||
if ("Intrinsic".equals(annotation.getType().getConstructor().getDeclarationDescriptor().getName().asString())) {
|
||||
value = (String) annotation.getAllValueArguments().values().iterator().next().getValue();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -354,8 +354,8 @@ public class AsmUtil {
|
||||
v.invokevirtual("java/lang/StringBuilder", "append", "(" + type.getDescriptor() + ")Ljava/lang/StringBuilder;");
|
||||
}
|
||||
|
||||
public static StackValue genToString(InstructionAdapter v, StackValue receiver) {
|
||||
Type type = stringValueOfOrStringBuilderAppendType(receiver.type);
|
||||
public static StackValue genToString(InstructionAdapter v, StackValue receiver, Type receiverType) {
|
||||
Type type = stringValueOfOrStringBuilderAppendType(receiverType);
|
||||
receiver.put(type, v);
|
||||
v.invokestatic("java/lang/String", "valueOf", "(" + type.getDescriptor() + ")Ljava/lang/String;");
|
||||
return StackValue.onStack(JAVA_STRING_TYPE);
|
||||
@@ -505,7 +505,7 @@ public class AsmUtil {
|
||||
Type asmType = state.getTypeMapper().mapReturnType(type);
|
||||
if (asmType.getSort() == Type.OBJECT || asmType.getSort() == Type.ARRAY) {
|
||||
v.load(index, asmType);
|
||||
v.visitLdcInsn(descriptor.getName().getName());
|
||||
v.visitLdcInsn(descriptor.getName().asString());
|
||||
v.invokestatic("jet/runtime/Intrinsics", "checkParameterIsNotNull", "(Ljava/lang/Object;Ljava/lang/String;)V");
|
||||
}
|
||||
}
|
||||
@@ -546,8 +546,8 @@ public class AsmUtil {
|
||||
Type asmType = state.getTypeMapper().mapReturnType(type);
|
||||
if (asmType.getSort() == Type.OBJECT || asmType.getSort() == Type.ARRAY) {
|
||||
v.dup();
|
||||
v.visitLdcInsn(descriptor.getContainingDeclaration().getName().getName());
|
||||
v.visitLdcInsn(descriptor.getName().getName());
|
||||
v.visitLdcInsn(descriptor.getContainingDeclaration().getName().asString());
|
||||
v.visitLdcInsn(descriptor.getName().asString());
|
||||
v.invokestatic("jet/runtime/Intrinsics", assertMethodToCall, "(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;)V");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ public class ClosureCodegen extends GenerationStateAware {
|
||||
return;
|
||||
}
|
||||
|
||||
MethodVisitor mv = cv.newMethod(fun, ACC_PUBLIC | ACC_BRIDGE, interfaceFunction.getName().getName(),
|
||||
MethodVisitor mv = cv.newMethod(fun, ACC_PUBLIC | ACC_BRIDGE, interfaceFunction.getName().asString(),
|
||||
bridge.getDescriptor(), null, ArrayUtil.EMPTY_STRING_ARRAY);
|
||||
if (state.getClassBuilderMode() == ClassBuilderMode.STUBS) {
|
||||
genStubCode(mv);
|
||||
@@ -203,7 +203,7 @@ public class ClosureCodegen extends GenerationStateAware {
|
||||
count++;
|
||||
}
|
||||
|
||||
iv.invokevirtual(name.getInternalName(), interfaceFunction.getName().getName(), delegate.getDescriptor());
|
||||
iv.invokevirtual(name.getInternalName(), interfaceFunction.getName().asString(), delegate.getDescriptor());
|
||||
StackValue.onStack(delegate.getReturnType()).put(bridge.getReturnType(), iv);
|
||||
|
||||
iv.areturn(bridge.getReturnType());
|
||||
@@ -268,11 +268,11 @@ public class ClosureCodegen extends GenerationStateAware {
|
||||
Type type = sharedVarType != null
|
||||
? sharedVarType
|
||||
: typeMapper.mapType((VariableDescriptor) descriptor);
|
||||
args.add(FieldInfo.createForHiddenField(ownerType, type, "$" + descriptor.getName().getName()));
|
||||
args.add(FieldInfo.createForHiddenField(ownerType, type, "$" + descriptor.getName().asString()));
|
||||
}
|
||||
else if (isLocalNamedFun(descriptor)) {
|
||||
JvmClassName className = classNameForAnonymousClass(bindingContext, (FunctionDescriptor) descriptor);
|
||||
args.add(FieldInfo.createForHiddenField(ownerType, className.getAsmType(), "$" + descriptor.getName().getName()));
|
||||
args.add(FieldInfo.createForHiddenField(ownerType, className.getAsmType(), "$" + descriptor.getName().asString()));
|
||||
}
|
||||
else if (descriptor instanceof FunctionDescriptor) {
|
||||
assert captureReceiver != null;
|
||||
|
||||
@@ -560,7 +560,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
@Override
|
||||
public void run() {
|
||||
myFrameMap.leave(parameterDescriptor);
|
||||
v.visitLocalVariable(parameterDescriptor.getName().getName(),
|
||||
v.visitLocalVariable(parameterDescriptor.getName().asString(),
|
||||
asmTypeForParameter.getDescriptor(), null,
|
||||
bodyStart, bodyEnd,
|
||||
loopParameterVar);
|
||||
@@ -601,7 +601,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
@Override
|
||||
public void run() {
|
||||
myFrameMap.leave(componentDescriptor);
|
||||
v.visitLocalVariable(componentDescriptor.getName().getName(),
|
||||
v.visitLocalVariable(componentDescriptor.getName().asString(),
|
||||
componentAsmType.getDescriptor(), null,
|
||||
bodyStart, bodyEnd,
|
||||
componentVarIndex);
|
||||
@@ -1173,7 +1173,8 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
JetStringTemplateEntry[] entries = expression.getEntries();
|
||||
|
||||
if (entries.length == 1 && entries[0] instanceof JetStringTemplateEntryWithExpression) {
|
||||
return genToString(v, gen(entries[0].getExpression()));
|
||||
JetExpression expr = entries[0].getExpression();
|
||||
return genToString(v, gen(expr), expressionType(expr));
|
||||
}
|
||||
|
||||
for (JetStringTemplateEntry entry : entries) {
|
||||
@@ -1414,7 +1415,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
v.store(index, OBJECT_TYPE);
|
||||
}
|
||||
}
|
||||
v.visitLocalVariable(variableDescriptor.getName().getName(), type.getDescriptor(), null, scopeStart, blockEnd,
|
||||
v.visitLocalVariable(variableDescriptor.getName().asString(), type.getDescriptor(), null, scopeStart, blockEnd,
|
||||
index);
|
||||
return null;
|
||||
}
|
||||
@@ -1628,7 +1629,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
ClassDescriptor containing = (ClassDescriptor) variableDescriptor.getContainingDeclaration().getContainingDeclaration();
|
||||
assert containing != null;
|
||||
Type type = typeMapper.mapType(containing);
|
||||
return StackValue.field(type, JvmClassName.byType(type), variableDescriptor.getName().getName(), true);
|
||||
return StackValue.field(type, JvmClassName.byType(type), variableDescriptor.getName().asString(), true);
|
||||
}
|
||||
else {
|
||||
return StackValue.singleton(objectClassDescriptor, typeMapper);
|
||||
@@ -2924,7 +2925,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
else {
|
||||
DeclarationDescriptor cls = op.getContainingDeclaration();
|
||||
CallableMethod callableMethod = (CallableMethod) callable;
|
||||
if (isPrimitiveNumberClassDescriptor(cls) || !(op.getName().getName().equals("inc") || op.getName().getName().equals("dec"))) {
|
||||
if (isPrimitiveNumberClassDescriptor(cls) || !(op.getName().asString().equals("inc") || op.getName().asString().equals("dec"))) {
|
||||
return invokeOperation(expression, (FunctionDescriptor) op, callableMethod);
|
||||
}
|
||||
else {
|
||||
@@ -2981,14 +2982,14 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
if (op instanceof FunctionDescriptor) {
|
||||
Type asmType = expressionType(expression);
|
||||
DeclarationDescriptor cls = op.getContainingDeclaration();
|
||||
if (op.getName().getName().equals("inc") || op.getName().getName().equals("dec")) {
|
||||
if (op.getName().asString().equals("inc") || op.getName().asString().equals("dec")) {
|
||||
if (isPrimitiveNumberClassDescriptor(cls)) {
|
||||
receiver.put(receiver.type, v);
|
||||
JetExpression operand = expression.getBaseExpression();
|
||||
if (operand instanceof JetReferenceExpression) {
|
||||
int index = indexOfLocal((JetReferenceExpression) operand);
|
||||
if (index >= 0 && isIntPrimitive(asmType)) {
|
||||
int increment = op.getName().getName().equals("inc") ? 1 : -1;
|
||||
int increment = op.getName().asString().equals("inc") ? 1 : -1;
|
||||
return StackValue.postIncrement(index, increment);
|
||||
}
|
||||
}
|
||||
@@ -3053,7 +3054,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
}
|
||||
|
||||
private void generateIncrement(DeclarationDescriptor op, Type asmType, JetExpression operand, StackValue receiver) {
|
||||
int increment = op.getName().getName().equals("inc") ? 1 : -1;
|
||||
int increment = op.getName().asString().equals("inc") ? 1 : -1;
|
||||
if (operand instanceof JetReferenceExpression) {
|
||||
int index = indexOfLocal((JetReferenceExpression) operand);
|
||||
if (index >= 0 && isIntPrimitive(asmType)) {
|
||||
@@ -3513,7 +3514,7 @@ The "returned" value of try expression with no finally is either the last expres
|
||||
value.put(boxType(value.type), v);
|
||||
|
||||
if (opToken != JetTokens.AS_SAFE) {
|
||||
if (!rightType.isNullable()) {
|
||||
if (!CodegenUtil.isNullableType(rightType)) {
|
||||
v.dup();
|
||||
Label nonnull = new Label();
|
||||
v.ifnonnull(nonnull);
|
||||
@@ -3626,13 +3627,7 @@ The "returned" value of try expression with no finally is either the last expres
|
||||
}
|
||||
|
||||
Label end = new Label();
|
||||
boolean hasElse = false;
|
||||
for (JetWhenEntry whenEntry : expression.getEntries()) {
|
||||
if (whenEntry.isElse()) {
|
||||
hasElse = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
boolean hasElse = JetPsiUtil.checkWhenExpressionHasSingleElse(expression);
|
||||
|
||||
Label nextCondition = null;
|
||||
for (JetWhenEntry whenEntry : expression.getEntries()) {
|
||||
|
||||
@@ -41,7 +41,7 @@ public class FieldInfo {
|
||||
Type ownerType = typeMapper.mapType(ownerDescriptor.getDefaultType());
|
||||
|
||||
String fieldName = kind == ClassKind.ENUM_ENTRY
|
||||
? fieldClassDescriptor.getName().getName()
|
||||
? fieldClassDescriptor.getName().asString()
|
||||
: fieldClassDescriptor.getKind() == ClassKind.CLASS_OBJECT ? JvmAbi.CLASS_OBJECT_FIELD : JvmAbi.INSTANCE_FIELD;
|
||||
return new FieldInfo(ownerType, fieldType, fieldName, true);
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ public class FunctionCodegen extends GenerationStateAware {
|
||||
List<ValueParameterDescriptor> parameters = functionDescriptor.getValueParameters();
|
||||
List<String> result = new ArrayList<String>(parameters.size());
|
||||
for (ValueParameterDescriptor parameter : parameters) {
|
||||
result.add(parameter.getName().getName());
|
||||
result.add(parameter.getName().asString());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -244,7 +244,7 @@ public class FunctionCodegen extends GenerationStateAware {
|
||||
if (kind == JvmMethodParameterKind.VALUE) {
|
||||
ValueParameterDescriptor parameter = valueParameters.next();
|
||||
Label divideLabel = labelsForSharedVars.get(parameter.getName());
|
||||
parameterName = parameter.getName().getName();
|
||||
parameterName = parameter.getName().asString();
|
||||
if (divideLabel != null) {
|
||||
mv.visitLocalVariable(parameterName, type.getDescriptor(), null, methodBegin, divideLabel, shift);
|
||||
|
||||
@@ -377,7 +377,7 @@ public class FunctionCodegen extends GenerationStateAware {
|
||||
ValueParameterDescriptor parameterDescriptor = null;
|
||||
if (kind == JvmMethodParameterKind.VALUE) {
|
||||
parameterDescriptor = valueParameters.next();
|
||||
parameterName = parameterDescriptor.getName().getName();
|
||||
parameterName = parameterDescriptor.getName().asString();
|
||||
} else if (kind == JvmMethodParameterKind.ENUM_NAME || kind == JvmMethodParameterKind.ENUM_ORDINAL) {
|
||||
//we shouldn't generate annotations for invisible in runtime parameters otherwise we get bad RuntimeInvisibleParameterAnnotations error in javac
|
||||
continue;
|
||||
|
||||
@@ -297,7 +297,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
innerClassInternalName = outerClassInternalName + JvmAbi.CLASS_OBJECT_SUFFIX;
|
||||
}
|
||||
else {
|
||||
innerName = innerClass.getName().isSpecial() ? null : innerClass.getName().getName();
|
||||
innerName = innerClass.getName().isSpecial() ? null : innerClass.getName().asString();
|
||||
innerClassInternalName = getInternalNameForImpl(innerClass);
|
||||
}
|
||||
|
||||
@@ -620,11 +620,11 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
boolean first = true;
|
||||
for (PropertyDescriptor propertyDescriptor : properties) {
|
||||
if (first) {
|
||||
iv.aconst(descriptor.getName() + "(" + propertyDescriptor.getName().getName()+"=");
|
||||
iv.aconst(descriptor.getName() + "(" + propertyDescriptor.getName().asString()+"=");
|
||||
first = false;
|
||||
}
|
||||
else {
|
||||
iv.aconst(", " + propertyDescriptor.getName().getName()+"=");
|
||||
iv.aconst(", " + propertyDescriptor.getName().asString()+"=");
|
||||
}
|
||||
genInvokeAppendMethod(iv, JAVA_STRING_TYPE);
|
||||
|
||||
@@ -821,7 +821,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
Type[] argTypes = method.getArgumentTypes();
|
||||
|
||||
String owner = typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION, isCallInsideSameModuleAsDeclared(original, context)).getInternalName();
|
||||
MethodVisitor mv = v.newMethod(null, ACC_SYNTHETIC | ACC_STATIC, bridge.getName().getName(),
|
||||
MethodVisitor mv = v.newMethod(null, ACC_SYNTHETIC | ACC_STATIC, bridge.getName().asString(),
|
||||
method.getDescriptor(), null, null);
|
||||
if (state.getClassBuilderMode() == ClassBuilderMode.STUBS) {
|
||||
genStubCode(mv);
|
||||
@@ -1015,7 +1015,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
Type type = typeMapper.mapType(descriptor);
|
||||
iv.load(0, classAsmType);
|
||||
iv.load(codegen.myFrameMap.getIndex(descriptor), type);
|
||||
iv.putfield(classAsmType.getInternalName(), descriptor.getName().getName(), type.getDescriptor());
|
||||
iv.putfield(classAsmType.getInternalName(), descriptor.getName().asString(), type.getDescriptor());
|
||||
}
|
||||
curParam++;
|
||||
}
|
||||
@@ -1097,7 +1097,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
Boolean.TRUE.equals(bindingContext.get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor))) {
|
||||
// final property with backing field
|
||||
field = StackValue.field(typeMapper.mapType(propertyDescriptor.getType()), classname,
|
||||
propertyDescriptor.getName().getName(), false);
|
||||
propertyDescriptor.getName().asString(), false);
|
||||
}
|
||||
else {
|
||||
iv.load(0, classType);
|
||||
|
||||
@@ -40,6 +40,7 @@ import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
|
||||
import org.jetbrains.jet.lang.resolve.java.kt.DescriptorKindUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.ErrorUtils;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
@@ -114,7 +115,10 @@ public class PropertyCodegen extends GenerationStateAware {
|
||||
modifiers |= ACC_VOLATILE;
|
||||
}
|
||||
JetType delegateType = bindingContext.get(BindingContext.EXPRESSION_TYPE, p.getDelegateExpression());
|
||||
assert delegateType != null : "Type of delegate should be recorded: " + p.getText();
|
||||
if (delegateType == null) {
|
||||
// If delegate expression is unresolved reference
|
||||
delegateType = ErrorUtils.createErrorType("Delegate type");
|
||||
}
|
||||
Type type = typeMapper.mapType(delegateType);
|
||||
return v.newField(p, modifiers, JvmAbi.getPropertyDelegateName(propertyDescriptor.getName()), type.getDescriptor(),
|
||||
null, null);
|
||||
@@ -122,9 +126,9 @@ public class PropertyCodegen extends GenerationStateAware {
|
||||
|
||||
private FieldVisitor generateBackingFieldAccess(PsiElement p, PropertyDescriptor propertyDescriptor) {
|
||||
Object value = null;
|
||||
JetExpression initializer = p instanceof JetProperty ? ((JetProperty) p).getInitializer() : null;
|
||||
if (initializer != null) {
|
||||
if (initializer instanceof JetConstantExpression && !propertyDescriptor.getType().isNullable()) {
|
||||
if (p instanceof JetProperty && !ImplementationBodyCodegen.shouldInitializeProperty((JetProperty) p, typeMapper)) {
|
||||
JetExpression initializer = ((JetProperty) p).getInitializer();
|
||||
if (initializer != null) {
|
||||
CompileTimeConstant<?> compileTimeValue = bindingContext.get(BindingContext.COMPILE_TIME_VALUE, initializer);
|
||||
value = compileTimeValue != null ? compileTimeValue.getValue() : null;
|
||||
}
|
||||
@@ -144,7 +148,7 @@ public class PropertyCodegen extends GenerationStateAware {
|
||||
modifiers |= ACC_VOLATILE;
|
||||
}
|
||||
Type type = typeMapper.mapType(propertyDescriptor);
|
||||
return v.newField(p, modifiers, propertyDescriptor.getName().getName(), type.getDescriptor(), null, value);
|
||||
return v.newField(p, modifiers, propertyDescriptor.getName().asString(), type.getDescriptor(), null, value);
|
||||
}
|
||||
|
||||
private void generateGetter(JetNamedDeclaration p, PropertyDescriptor propertyDescriptor, JetPropertyAccessor getter) {
|
||||
@@ -244,7 +248,7 @@ public class PropertyCodegen extends GenerationStateAware {
|
||||
iv.visitFieldInsn(
|
||||
kind == OwnerKind.NAMESPACE ? GETSTATIC : GETFIELD,
|
||||
typeMapper.getOwner(propertyDescriptor, kind, isCallInsideSameModuleAsDeclared(propertyDescriptor, context)).getInternalName(),
|
||||
propertyDescriptor.getName().getName(),
|
||||
propertyDescriptor.getName().asString(),
|
||||
type.getDescriptor());
|
||||
iv.areturn(type);
|
||||
}
|
||||
@@ -261,7 +265,7 @@ public class PropertyCodegen extends GenerationStateAware {
|
||||
iv.load(paramCode, type);
|
||||
iv.visitFieldInsn(kind == OwnerKind.NAMESPACE ? PUTSTATIC : PUTFIELD,
|
||||
typeMapper.getOwner(propertyDescriptor, kind, isCallInsideSameModuleAsDeclared(propertyDescriptor, context)).getInternalName(),
|
||||
propertyDescriptor.getName().getName(),
|
||||
propertyDescriptor.getName().asString(),
|
||||
type.getDescriptor());
|
||||
|
||||
iv.visitInsn(RETURN);
|
||||
@@ -332,11 +336,11 @@ public class PropertyCodegen extends GenerationStateAware {
|
||||
}
|
||||
|
||||
public static String getterName(Name propertyName) {
|
||||
return JvmAbi.GETTER_PREFIX + StringUtil.capitalizeWithJavaBeanConvention(propertyName.getName());
|
||||
return JvmAbi.GETTER_PREFIX + StringUtil.capitalizeWithJavaBeanConvention(propertyName.asString());
|
||||
}
|
||||
|
||||
public static String setterName(Name propertyName) {
|
||||
return JvmAbi.SETTER_PREFIX + StringUtil.capitalizeWithJavaBeanConvention(propertyName.getName());
|
||||
return JvmAbi.SETTER_PREFIX + StringUtil.capitalizeWithJavaBeanConvention(propertyName.asString());
|
||||
}
|
||||
|
||||
public void genDelegate(PropertyDescriptor delegate, PropertyDescriptor overridden, StackValue field) {
|
||||
|
||||
@@ -112,7 +112,7 @@ public class RangeCodegenUtil {
|
||||
}
|
||||
|
||||
public static boolean isOptimizableRangeTo(CallableDescriptor rangeTo) {
|
||||
if ("rangeTo".equals(rangeTo.getName().getName())) {
|
||||
if ("rangeTo".equals(rangeTo.getName().asString())) {
|
||||
if (isPrimitiveNumberClassDescriptor(rangeTo.getContainingDeclaration())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -913,7 +913,7 @@ public abstract class StackValue {
|
||||
}
|
||||
|
||||
private String getPropertyName() {
|
||||
return isDelegated ? JvmAbi.getPropertyDelegateName(descriptor.getName()) : descriptor.getName().getName();
|
||||
return isDelegated ? JvmAbi.getPropertyDelegateName(descriptor.getName()) : descriptor.getName().asString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -227,7 +227,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
|
||||
private String getName(ClassDescriptor classDescriptor) {
|
||||
String base = peekFromStack(nameStack);
|
||||
return DescriptorUtils.isTopLevelDeclaration(classDescriptor) ? base.isEmpty() ? classDescriptor.getName()
|
||||
.getName() : base + '/' + classDescriptor.getName() : base + '$' + classDescriptor.getName();
|
||||
.asString() : base + '/' + classDescriptor.getName() : base + '$' + classDescriptor.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -350,7 +350,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
|
||||
DeclarationDescriptor containingDeclaration = descriptor.getContainingDeclaration();
|
||||
|
||||
String peek = peekFromStack(nameStack);
|
||||
String name = descriptor.getName().getName();
|
||||
String name = descriptor.getName().asString();
|
||||
if (containingDeclaration instanceof ClassDescriptor) {
|
||||
return peek + '$' + name;
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ public final class PsiCodegenPredictor {
|
||||
if (declaration instanceof JetNamedFunction) {
|
||||
if (parentDeclaration == null) {
|
||||
JvmClassName packageClass = addPackageClass(parentClassName);
|
||||
return JvmClassName.byInternalName(packageClass.getInternalName() + "$" + name.getName());
|
||||
return JvmClassName.byInternalName(packageClass.getInternalName() + "$" + name.asString());
|
||||
}
|
||||
|
||||
if (!(parentDeclaration instanceof JetClass || parentDeclaration instanceof JetObjectDeclaration)) {
|
||||
@@ -128,16 +128,16 @@ public final class PsiCodegenPredictor {
|
||||
// NOTE: looks like a bug - for class in getter of top level property class name will be $propertyName$ClassName but not
|
||||
// namespace$propertyName$ClassName
|
||||
if (declaration instanceof JetProperty) {
|
||||
return JvmClassName.byInternalName(parentClassName.getInternalName() + "$" + name.getName());
|
||||
return JvmClassName.byInternalName(parentClassName.getInternalName() + "$" + name.asString());
|
||||
}
|
||||
|
||||
if (fqName.isRoot()) {
|
||||
return JvmClassName.byInternalName(name.getName());
|
||||
return JvmClassName.byInternalName(name.asString());
|
||||
}
|
||||
|
||||
return JvmClassName.byInternalName(parentDeclaration == null ?
|
||||
parentClassName.getInternalName() + "/" + name.getName() :
|
||||
parentClassName.getInternalName() + "$" + name.getName());
|
||||
parentClassName.getInternalName() + "/" + name.asString() :
|
||||
parentClassName.getInternalName() + "$" + name.asString());
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -241,7 +241,7 @@ public class IntrinsicMethods {
|
||||
for (AnnotationDescriptor annotation : annotations) {
|
||||
ClassifierDescriptor classifierDescriptor = annotation.getType().getConstructor().getDeclarationDescriptor();
|
||||
assert classifierDescriptor != null;
|
||||
if ("Intrinsic".equals(classifierDescriptor.getName().getName())) {
|
||||
if ("Intrinsic".equals(classifierDescriptor.getName().asString())) {
|
||||
String value = (String) annotation.getAllValueArguments().values().iterator().next().getValue();
|
||||
intrinsicMethod = namedMethods.get(value);
|
||||
if (intrinsicMethod != null) {
|
||||
|
||||
@@ -51,7 +51,7 @@ public class StaticField implements IntrinsicMethod {
|
||||
StackValue receiver,
|
||||
@NotNull GenerationState state
|
||||
) {
|
||||
v.getstatic(JvmClassName.byFqNameWithoutInnerClasses(ownerClass).getInternalName(), propertyName.getName(), expectedType.getDescriptor());
|
||||
v.getstatic(JvmClassName.byFqNameWithoutInnerClasses(ownerClass).getInternalName(), propertyName.asString(), expectedType.getDescriptor());
|
||||
return StackValue.onStack(expectedType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,6 @@ public class ToString implements IntrinsicMethod {
|
||||
StackValue receiver,
|
||||
@NotNull GenerationState state
|
||||
) {
|
||||
return genToString(v, receiver);
|
||||
return genToString(v, receiver, receiver.type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,8 +272,8 @@ public class BothSignatureWriter {
|
||||
}
|
||||
|
||||
public void writeTypeVariable(Name name, boolean nullable, Type asmType) {
|
||||
signatureVisitor().visitTypeVariable(name.getName());
|
||||
jetSignatureWriter.visitTypeVariable(name.getName(), nullable);
|
||||
signatureVisitor().visitTypeVariable(name.asString());
|
||||
jetSignatureWriter.visitTypeVariable(name.asString(), nullable);
|
||||
generic = true;
|
||||
writeAsmType0(asmType);
|
||||
}
|
||||
|
||||
@@ -578,7 +578,7 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
|
||||
@NotNull
|
||||
public JvmMethodSignature mapSignature(@NotNull FunctionDescriptor f, boolean needGenericSignature, @NotNull OwnerKind kind) {
|
||||
String name = f.getName().getName();
|
||||
String name = f.getName().asString();
|
||||
if (f instanceof PropertyAccessorDescriptor) {
|
||||
boolean isGetter = f instanceof PropertyGetterDescriptor;
|
||||
name = getPropertyAccessorName(((PropertyAccessorDescriptor) f).getCorrespondingProperty(), isGetter);
|
||||
@@ -588,7 +588,7 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
|
||||
@NotNull
|
||||
public JvmMethodSignature mapSignature(@NotNull Name functionName, @NotNull FunctionDescriptor f) {
|
||||
return mapSignature(functionName.getName(), f, false, OwnerKind.IMPLEMENTATION);
|
||||
return mapSignature(functionName.asString(), f, false, OwnerKind.IMPLEMENTATION);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -675,7 +675,7 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
}
|
||||
|
||||
private void writeFormalTypeParameter(TypeParameterDescriptor typeParameterDescriptor, BothSignatureWriter signatureVisitor) {
|
||||
signatureVisitor.writeFormalTypeParameter(typeParameterDescriptor.getName().getName(), typeParameterDescriptor.getVariance(),
|
||||
signatureVisitor.writeFormalTypeParameter(typeParameterDescriptor.getName().asString(), typeParameterDescriptor.getVariance(),
|
||||
typeParameterDescriptor.isReified());
|
||||
|
||||
classBound:
|
||||
@@ -730,7 +730,7 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
DeclarationDescriptor parentDescriptor = descriptor.getContainingDeclaration();
|
||||
boolean isAnnotation = parentDescriptor instanceof ClassDescriptor &&
|
||||
((ClassDescriptor) parentDescriptor).getKind() == ClassKind.ANNOTATION_CLASS;
|
||||
return isAnnotation ? descriptor.getName().getName() :
|
||||
return isAnnotation ? descriptor.getName().asString() :
|
||||
isGetter ? PropertyCodegen.getterName(descriptor.getName()) : PropertyCodegen.setterName(descriptor.getName());
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#
|
||||
##############################################################################
|
||||
# Copyright 2002-2011, LAMP/EPFL
|
||||
# Copyright 2011, JetBrains
|
||||
# Copyright 2011-2013, JetBrains
|
||||
#
|
||||
# This is free software; see the distribution for copying conditions.
|
||||
# There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
|
||||
@@ -45,6 +45,7 @@ fi
|
||||
# -D options will be available as system properties.
|
||||
declare -a java_args
|
||||
declare -a kotlin_args
|
||||
profile_preloader="notime"
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
@@ -62,6 +63,10 @@ while [ $# -gt 0 ]; do
|
||||
kotlin_args=("${kotlin_args[@]}" "$1")
|
||||
shift
|
||||
;;
|
||||
-pp)
|
||||
profile_preloader="time"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
kotlin_args=("${kotlin_args[@]}" "$1")
|
||||
shift
|
||||
@@ -82,4 +87,4 @@ CPSELECT="-cp "
|
||||
$JAVA_OPTS \
|
||||
"${java_args[@]}" \
|
||||
${CPSELECT}"${KOTLIN_HOME}/lib/kotlin-preloader.jar" \
|
||||
org.jetbrains.jet.preloading.Preloader "${KOTLIN_HOME}/lib/kotlin-compiler.jar" org.jetbrains.jet.cli.js.K2JSCompiler 4096 "$@"
|
||||
org.jetbrains.jet.preloading.Preloader "${KOTLIN_HOME}/lib/kotlin-compiler.jar" org.jetbrains.jet.cli.js.K2JSCompiler 4096 $profile_preloader "$@"
|
||||
|
||||
@@ -2,13 +2,17 @@
|
||||
rem based on scalac.bat from the Scala distribution
|
||||
rem ##########################################################################
|
||||
rem # Copyright 2002-2011, LAMP/EPFL
|
||||
rem # Copyright 2011, JetBrains
|
||||
rem # Copyright 2011-2013, JetBrains
|
||||
rem #
|
||||
rem # This is free software; see the distribution for copying conditions.
|
||||
rem # There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
|
||||
rem # PARTICULAR PURPOSE.
|
||||
rem ##########################################################################
|
||||
|
||||
rem We adopt the following conventions:
|
||||
rem - System/user environment variables start with a letter
|
||||
rem - Local batch variables start with an underscore ('_')
|
||||
|
||||
@setlocal
|
||||
call :set_home
|
||||
|
||||
@@ -18,12 +22,26 @@ if not "%JAVA_HOME%"=="" (
|
||||
|
||||
if "%_JAVACMD%"=="" set _JAVACMD=java
|
||||
|
||||
set _PROFILE_PRELOADER=notime
|
||||
rem re: E%1 &c., see http://www.riedquat.de/blog/2011-11-27-01#w9aab1c45
|
||||
if E%1==E-pp (
|
||||
shift
|
||||
set _PROFILE_PRELOADER=time
|
||||
)
|
||||
|
||||
rem We use the value of the JAVA_OPTS environment variable if defined
|
||||
set _JAVA_OPTS=-Xmx256M -Xms32M -noverify
|
||||
|
||||
"%_JAVACMD%" %_JAVA_OPTS% -cp "%_KOTLIN_HOME%\lib\kotlin-preloader.jar" ^
|
||||
org.jetbrains.jet.preloading.Preloader "${KOTLIN_HOME}/lib/kotlin-compiler.jar" ^
|
||||
org.jetbrains.jet.cli.jvm.K2JVMCompiler 4096 org.jetbrains.jet.cli.js.K2JSCompiler %*
|
||||
rem re: %1 %2 &c., see http://www.riedquat.de/blog/2011-11-27-01#w9aab1c60
|
||||
if "%_PROFILE_PRELOADER%"=="time" (
|
||||
"%_JAVACMD%" %_JAVA_OPTS% -cp "%_KOTLIN_HOME%\lib\kotlin-preloader.jar" ^
|
||||
org.jetbrains.jet.preloading.Preloader "%_KOTLIN_HOME%\lib\kotlin-compiler.jar" ^
|
||||
org.jetbrains.jet.cli.js.K2JSCompiler 4096 %_PROFILE_PRELOADER% %1 %2 %3 %4 %5 %6 %7 %8 %9
|
||||
) else (
|
||||
"%_JAVACMD%" %_JAVA_OPTS% -cp "%_KOTLIN_HOME%\lib\kotlin-preloader.jar" ^
|
||||
org.jetbrains.jet.preloading.Preloader "%_KOTLIN_HOME%\lib\kotlin-compiler.jar" ^
|
||||
org.jetbrains.jet.cli.js.K2JSCompiler 4096 %_PROFILE_PRELOADER% %*
|
||||
)
|
||||
goto end
|
||||
|
||||
rem ##########################################################################
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#
|
||||
##############################################################################
|
||||
# Copyright 2002-2011, LAMP/EPFL
|
||||
# Copyright 2011, JetBrains
|
||||
# Copyright 2011-2013, JetBrains
|
||||
#
|
||||
# This is free software; see the distribution for copying conditions.
|
||||
# There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
|
||||
@@ -45,6 +45,7 @@ fi
|
||||
# -D options will be available as system properties.
|
||||
declare -a java_args
|
||||
declare -a kotlin_args
|
||||
profile_preloader="notime"
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
@@ -62,6 +63,10 @@ while [ $# -gt 0 ]; do
|
||||
kotlin_args=("${kotlin_args[@]}" "$1")
|
||||
shift
|
||||
;;
|
||||
-pp)
|
||||
profile_preloader="time"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
kotlin_args=("${kotlin_args[@]}" "$1")
|
||||
shift
|
||||
@@ -82,4 +87,4 @@ CPSELECT="-cp "
|
||||
$JAVA_OPTS \
|
||||
"${java_args[@]}" \
|
||||
${CPSELECT}"${KOTLIN_HOME}/lib/kotlin-preloader.jar" \
|
||||
org.jetbrains.jet.preloading.Preloader "${KOTLIN_HOME}/lib/kotlin-compiler.jar" org.jetbrains.jet.cli.jvm.K2JVMCompiler 4096 "$@"
|
||||
org.jetbrains.jet.preloading.Preloader "${KOTLIN_HOME}/lib/kotlin-compiler.jar" org.jetbrains.jet.cli.jvm.K2JVMCompiler 4096 $profile_preloader "$@"
|
||||
|
||||
@@ -2,13 +2,17 @@
|
||||
rem based on scalac.bat from the Scala distribution
|
||||
rem ##########################################################################
|
||||
rem # Copyright 2002-2011, LAMP/EPFL
|
||||
rem # Copyright 2011, JetBrains
|
||||
rem # Copyright 2011-2013, JetBrains
|
||||
rem #
|
||||
rem # This is free software; see the distribution for copying conditions.
|
||||
rem # There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
|
||||
rem # PARTICULAR PURPOSE.
|
||||
rem ##########################################################################
|
||||
|
||||
rem We adopt the following conventions:
|
||||
rem - System/user environment variables start with a letter
|
||||
rem - Local batch variables start with an underscore ('_')
|
||||
|
||||
@setlocal
|
||||
call :set_home
|
||||
|
||||
@@ -18,12 +22,26 @@ if not "%JAVA_HOME%"=="" (
|
||||
|
||||
if "%_JAVACMD%"=="" set _JAVACMD=java
|
||||
|
||||
set _PROFILE_PRELOADER=notime
|
||||
rem re: E%1 &c., see http://www.riedquat.de/blog/2011-11-27-01#w9aab1c45
|
||||
if E%1==E-pp (
|
||||
shift
|
||||
set _PROFILE_PRELOADER=time
|
||||
)
|
||||
|
||||
rem We use the value of the JAVA_OPTS environment variable if defined
|
||||
set _JAVA_OPTS=-Xmx256M -Xms32M -noverify
|
||||
|
||||
"%_JAVACMD%" %_JAVA_OPTS% -cp "%_KOTLIN_HOME%\lib\kotlin-preloader.jar" ^
|
||||
org.jetbrains.jet.preloading.Preloader "${KOTLIN_HOME}/lib/kotlin-compiler.jar" ^
|
||||
org.jetbrains.jet.cli.jvm.K2JVMCompiler 4096 org.jetbrains.jet.cli.jvm.K2JVMCompiler %*
|
||||
rem re: %1 %2 &c., see http://www.riedquat.de/blog/2011-11-27-01#w9aab1c60
|
||||
if "%_PROFILE_PRELOADER%"=="time" (
|
||||
"%_JAVACMD%" %_JAVA_OPTS% -cp "%_KOTLIN_HOME%\lib\kotlin-preloader.jar" ^
|
||||
org.jetbrains.jet.preloading.Preloader "%_KOTLIN_HOME%\lib\kotlin-compiler.jar" ^
|
||||
org.jetbrains.jet.cli.jvm.K2JVMCompiler 4096 %_PROFILE_PRELOADER% %1 %2 %3 %4 %5 %6 %7 %8 %9
|
||||
) else (
|
||||
"%_JAVACMD%" %_JAVA_OPTS% -cp "%_KOTLIN_HOME%\lib\kotlin-preloader.jar" ^
|
||||
org.jetbrains.jet.preloading.Preloader "%_KOTLIN_HOME%\lib\kotlin-compiler.jar" ^
|
||||
org.jetbrains.jet.cli.jvm.K2JVMCompiler 4096 %_PROFILE_PRELOADER% %*
|
||||
)
|
||||
goto end
|
||||
|
||||
rem ##########################################################################
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
<orderEntry type="module" module-name="runtime" />
|
||||
<orderEntry type="module" module-name="jet.as.java.psi" />
|
||||
<orderEntry type="library" name="intellij-core" level="project" />
|
||||
<orderEntry type="library" name="asm-addons" level="project" />
|
||||
<orderEntry type="module" module-name="js.translator" />
|
||||
<orderEntry type="library" name="jline" level="project" />
|
||||
<orderEntry type="module" module-name="cli-common" exported="" />
|
||||
|
||||
+1
-1
@@ -109,7 +109,7 @@ public final class AnalyzerWithCompilerReport {
|
||||
if (!incompletes.isEmpty()) {
|
||||
StringBuilder message = new StringBuilder("The following classes have incomplete hierarchies:\n");
|
||||
for (ClassDescriptor incomplete : incompletes) {
|
||||
String fqName = DescriptorUtils.getFQName(incomplete).getFqName();
|
||||
String fqName = DescriptorUtils.getFQName(incomplete).asString();
|
||||
message.append(" ").append(fqName).append("\n");
|
||||
}
|
||||
messageCollectorWrapper.report(CompilerMessageSeverity.ERROR, message.toString(), CompilerMessageLocation.NO_LOCATION);
|
||||
|
||||
@@ -203,7 +203,7 @@ public class CompileEnvironmentUtil {
|
||||
mainAttributes.putValue("Manifest-Version", "1.0");
|
||||
mainAttributes.putValue("Created-By", "JetBrains Kotlin");
|
||||
if (mainClass != null) {
|
||||
mainAttributes.putValue("Main-Class", mainClass.getFqName());
|
||||
mainAttributes.putValue("Main-Class", mainClass.asString());
|
||||
}
|
||||
JarOutputStream stream = new JarOutputStream(fos, manifest);
|
||||
for (String file : factory.files()) {
|
||||
|
||||
@@ -236,7 +236,7 @@ public class ReplInterpreter {
|
||||
}
|
||||
|
||||
try {
|
||||
Class<?> scriptClass = classLoader.loadClass(scriptClassName.getFqName().getFqName());
|
||||
Class<?> scriptClass = classLoader.loadClass(scriptClassName.getFqName().asString());
|
||||
|
||||
Class<?>[] constructorParams = new Class<?>[earlierLines.size()];
|
||||
Object[] constructorArgs = new Object[earlierLines.size()];
|
||||
|
||||
+25
-24
@@ -30,11 +30,11 @@ import org.jetbrains.jet.lang.resolve.java.resolver.JavaAnnotationResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaCompileTimeConstResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaClassObjectResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaSupertypeResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaNamespaceResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaSignatureResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaConstructorResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaValueParameterResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaFunctionResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaValueParameterResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaSignatureResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaNamespaceResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaConstructorResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaInnerClassResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaPropertyResolver;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -57,11 +57,11 @@ public class InjectorForJavaDescriptorResolver {
|
||||
private JavaCompileTimeConstResolver javaCompileTimeConstResolver;
|
||||
private JavaClassObjectResolver javaClassObjectResolver;
|
||||
private JavaSupertypeResolver javaSupertypeResolver;
|
||||
private JavaNamespaceResolver javaNamespaceResolver;
|
||||
private JavaSignatureResolver javaSignatureResolver;
|
||||
private JavaConstructorResolver javaConstructorResolver;
|
||||
private JavaValueParameterResolver javaValueParameterResolver;
|
||||
private JavaFunctionResolver javaFunctionResolver;
|
||||
private JavaValueParameterResolver javaValueParameterResolver;
|
||||
private JavaSignatureResolver javaSignatureResolver;
|
||||
private JavaNamespaceResolver javaNamespaceResolver;
|
||||
private JavaConstructorResolver javaConstructorResolver;
|
||||
private JavaInnerClassResolver javaInnerClassResolver;
|
||||
private JavaPropertyResolver javaPropertyResolver;
|
||||
|
||||
@@ -84,11 +84,11 @@ public class InjectorForJavaDescriptorResolver {
|
||||
this.javaCompileTimeConstResolver = new JavaCompileTimeConstResolver();
|
||||
this.javaClassObjectResolver = new JavaClassObjectResolver();
|
||||
this.javaSupertypeResolver = new JavaSupertypeResolver();
|
||||
this.javaNamespaceResolver = new JavaNamespaceResolver();
|
||||
this.javaSignatureResolver = new JavaSignatureResolver();
|
||||
this.javaConstructorResolver = new JavaConstructorResolver();
|
||||
this.javaValueParameterResolver = new JavaValueParameterResolver();
|
||||
this.javaFunctionResolver = new JavaFunctionResolver();
|
||||
this.javaValueParameterResolver = new JavaValueParameterResolver();
|
||||
this.javaSignatureResolver = new JavaSignatureResolver();
|
||||
this.javaNamespaceResolver = new JavaNamespaceResolver();
|
||||
this.javaConstructorResolver = new JavaConstructorResolver();
|
||||
this.javaInnerClassResolver = new JavaInnerClassResolver();
|
||||
this.javaPropertyResolver = new JavaPropertyResolver();
|
||||
|
||||
@@ -114,6 +114,7 @@ public class InjectorForJavaDescriptorResolver {
|
||||
|
||||
javaClassResolver.setAnnotationResolver(javaAnnotationResolver);
|
||||
javaClassResolver.setClassObjectResolver(javaClassObjectResolver);
|
||||
javaClassResolver.setFunctionResolver(javaFunctionResolver);
|
||||
javaClassResolver.setNamespaceResolver(javaNamespaceResolver);
|
||||
javaClassResolver.setPsiClassFinder(psiClassFinder);
|
||||
javaClassResolver.setSemanticServices(javaSemanticServices);
|
||||
@@ -136,24 +137,24 @@ public class InjectorForJavaDescriptorResolver {
|
||||
javaSupertypeResolver.setTrace(bindingTrace);
|
||||
javaSupertypeResolver.setTypeTransformer(javaTypeTransformer);
|
||||
|
||||
javaNamespaceResolver.setJavaSemanticServices(javaSemanticServices);
|
||||
javaNamespaceResolver.setPsiClassFinder(psiClassFinder);
|
||||
javaNamespaceResolver.setTrace(bindingTrace);
|
||||
|
||||
javaSignatureResolver.setJavaSemanticServices(javaSemanticServices);
|
||||
|
||||
javaConstructorResolver.setTrace(bindingTrace);
|
||||
javaConstructorResolver.setTypeTransformer(javaTypeTransformer);
|
||||
javaConstructorResolver.setValueParameterResolver(javaValueParameterResolver);
|
||||
|
||||
javaValueParameterResolver.setTypeTransformer(javaTypeTransformer);
|
||||
|
||||
javaFunctionResolver.setAnnotationResolver(javaAnnotationResolver);
|
||||
javaFunctionResolver.setParameterResolver(javaValueParameterResolver);
|
||||
javaFunctionResolver.setSignatureResolver(javaSignatureResolver);
|
||||
javaFunctionResolver.setTrace(bindingTrace);
|
||||
javaFunctionResolver.setTypeTransformer(javaTypeTransformer);
|
||||
|
||||
javaValueParameterResolver.setTypeTransformer(javaTypeTransformer);
|
||||
|
||||
javaSignatureResolver.setJavaSemanticServices(javaSemanticServices);
|
||||
|
||||
javaNamespaceResolver.setJavaSemanticServices(javaSemanticServices);
|
||||
javaNamespaceResolver.setPsiClassFinder(psiClassFinder);
|
||||
javaNamespaceResolver.setTrace(bindingTrace);
|
||||
|
||||
javaConstructorResolver.setTrace(bindingTrace);
|
||||
javaConstructorResolver.setTypeTransformer(javaTypeTransformer);
|
||||
javaConstructorResolver.setValueParameterResolver(javaValueParameterResolver);
|
||||
|
||||
javaInnerClassResolver.setClassResolver(javaClassResolver);
|
||||
|
||||
javaPropertyResolver.setAnnotationResolver(javaAnnotationResolver);
|
||||
|
||||
+25
-24
@@ -30,11 +30,11 @@ import org.jetbrains.jet.lang.resolve.java.resolver.JavaAnnotationResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaCompileTimeConstResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaClassObjectResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaSupertypeResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaNamespaceResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaSignatureResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaConstructorResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaValueParameterResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaFunctionResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaValueParameterResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaSignatureResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaNamespaceResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaConstructorResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaInnerClassResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaPropertyResolver;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -57,11 +57,11 @@ public class InjectorForJavaSemanticServices {
|
||||
private JavaCompileTimeConstResolver javaCompileTimeConstResolver;
|
||||
private JavaClassObjectResolver javaClassObjectResolver;
|
||||
private JavaSupertypeResolver javaSupertypeResolver;
|
||||
private JavaNamespaceResolver javaNamespaceResolver;
|
||||
private JavaSignatureResolver javaSignatureResolver;
|
||||
private JavaConstructorResolver javaConstructorResolver;
|
||||
private JavaValueParameterResolver javaValueParameterResolver;
|
||||
private JavaFunctionResolver javaFunctionResolver;
|
||||
private JavaValueParameterResolver javaValueParameterResolver;
|
||||
private JavaSignatureResolver javaSignatureResolver;
|
||||
private JavaNamespaceResolver javaNamespaceResolver;
|
||||
private JavaConstructorResolver javaConstructorResolver;
|
||||
private JavaInnerClassResolver javaInnerClassResolver;
|
||||
private JavaPropertyResolver javaPropertyResolver;
|
||||
|
||||
@@ -82,11 +82,11 @@ public class InjectorForJavaSemanticServices {
|
||||
this.javaCompileTimeConstResolver = new JavaCompileTimeConstResolver();
|
||||
this.javaClassObjectResolver = new JavaClassObjectResolver();
|
||||
this.javaSupertypeResolver = new JavaSupertypeResolver();
|
||||
this.javaNamespaceResolver = new JavaNamespaceResolver();
|
||||
this.javaSignatureResolver = new JavaSignatureResolver();
|
||||
this.javaConstructorResolver = new JavaConstructorResolver();
|
||||
this.javaValueParameterResolver = new JavaValueParameterResolver();
|
||||
this.javaFunctionResolver = new JavaFunctionResolver();
|
||||
this.javaValueParameterResolver = new JavaValueParameterResolver();
|
||||
this.javaSignatureResolver = new JavaSignatureResolver();
|
||||
this.javaNamespaceResolver = new JavaNamespaceResolver();
|
||||
this.javaConstructorResolver = new JavaConstructorResolver();
|
||||
this.javaInnerClassResolver = new JavaInnerClassResolver();
|
||||
this.javaPropertyResolver = new JavaPropertyResolver();
|
||||
|
||||
@@ -114,6 +114,7 @@ public class InjectorForJavaSemanticServices {
|
||||
|
||||
javaClassResolver.setAnnotationResolver(javaAnnotationResolver);
|
||||
javaClassResolver.setClassObjectResolver(javaClassObjectResolver);
|
||||
javaClassResolver.setFunctionResolver(javaFunctionResolver);
|
||||
javaClassResolver.setNamespaceResolver(javaNamespaceResolver);
|
||||
javaClassResolver.setPsiClassFinder(psiClassFinder);
|
||||
javaClassResolver.setSemanticServices(javaSemanticServices);
|
||||
@@ -136,24 +137,24 @@ public class InjectorForJavaSemanticServices {
|
||||
javaSupertypeResolver.setTrace(bindingTrace);
|
||||
javaSupertypeResolver.setTypeTransformer(javaTypeTransformer);
|
||||
|
||||
javaNamespaceResolver.setJavaSemanticServices(javaSemanticServices);
|
||||
javaNamespaceResolver.setPsiClassFinder(psiClassFinder);
|
||||
javaNamespaceResolver.setTrace(bindingTrace);
|
||||
|
||||
javaSignatureResolver.setJavaSemanticServices(javaSemanticServices);
|
||||
|
||||
javaConstructorResolver.setTrace(bindingTrace);
|
||||
javaConstructorResolver.setTypeTransformer(javaTypeTransformer);
|
||||
javaConstructorResolver.setValueParameterResolver(javaValueParameterResolver);
|
||||
|
||||
javaValueParameterResolver.setTypeTransformer(javaTypeTransformer);
|
||||
|
||||
javaFunctionResolver.setAnnotationResolver(javaAnnotationResolver);
|
||||
javaFunctionResolver.setParameterResolver(javaValueParameterResolver);
|
||||
javaFunctionResolver.setSignatureResolver(javaSignatureResolver);
|
||||
javaFunctionResolver.setTrace(bindingTrace);
|
||||
javaFunctionResolver.setTypeTransformer(javaTypeTransformer);
|
||||
|
||||
javaValueParameterResolver.setTypeTransformer(javaTypeTransformer);
|
||||
|
||||
javaSignatureResolver.setJavaSemanticServices(javaSemanticServices);
|
||||
|
||||
javaNamespaceResolver.setJavaSemanticServices(javaSemanticServices);
|
||||
javaNamespaceResolver.setPsiClassFinder(psiClassFinder);
|
||||
javaNamespaceResolver.setTrace(bindingTrace);
|
||||
|
||||
javaConstructorResolver.setTrace(bindingTrace);
|
||||
javaConstructorResolver.setTypeTransformer(javaTypeTransformer);
|
||||
javaConstructorResolver.setValueParameterResolver(javaValueParameterResolver);
|
||||
|
||||
javaInnerClassResolver.setClassResolver(javaClassResolver);
|
||||
|
||||
javaPropertyResolver.setAnnotationResolver(javaAnnotationResolver);
|
||||
|
||||
+25
-24
@@ -54,11 +54,11 @@ import org.jetbrains.jet.lang.resolve.java.resolver.JavaAnnotationResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaCompileTimeConstResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaClassObjectResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaSupertypeResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaNamespaceResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaSignatureResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaConstructorResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaValueParameterResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaFunctionResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaValueParameterResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaSignatureResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaNamespaceResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaConstructorResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaInnerClassResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaPropertyResolver;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -105,11 +105,11 @@ public class InjectorForTopDownAnalyzerForJvm implements InjectorForTopDownAnaly
|
||||
private JavaCompileTimeConstResolver javaCompileTimeConstResolver;
|
||||
private JavaClassObjectResolver javaClassObjectResolver;
|
||||
private JavaSupertypeResolver javaSupertypeResolver;
|
||||
private JavaNamespaceResolver javaNamespaceResolver;
|
||||
private JavaSignatureResolver javaSignatureResolver;
|
||||
private JavaConstructorResolver javaConstructorResolver;
|
||||
private JavaValueParameterResolver javaValueParameterResolver;
|
||||
private JavaFunctionResolver javaFunctionResolver;
|
||||
private JavaValueParameterResolver javaValueParameterResolver;
|
||||
private JavaSignatureResolver javaSignatureResolver;
|
||||
private JavaNamespaceResolver javaNamespaceResolver;
|
||||
private JavaConstructorResolver javaConstructorResolver;
|
||||
private JavaInnerClassResolver javaInnerClassResolver;
|
||||
private JavaPropertyResolver javaPropertyResolver;
|
||||
|
||||
@@ -157,11 +157,11 @@ public class InjectorForTopDownAnalyzerForJvm implements InjectorForTopDownAnaly
|
||||
this.javaCompileTimeConstResolver = new JavaCompileTimeConstResolver();
|
||||
this.javaClassObjectResolver = new JavaClassObjectResolver();
|
||||
this.javaSupertypeResolver = new JavaSupertypeResolver();
|
||||
this.javaNamespaceResolver = new JavaNamespaceResolver();
|
||||
this.javaSignatureResolver = new JavaSignatureResolver();
|
||||
this.javaConstructorResolver = new JavaConstructorResolver();
|
||||
this.javaValueParameterResolver = new JavaValueParameterResolver();
|
||||
this.javaFunctionResolver = new JavaFunctionResolver();
|
||||
this.javaValueParameterResolver = new JavaValueParameterResolver();
|
||||
this.javaSignatureResolver = new JavaSignatureResolver();
|
||||
this.javaNamespaceResolver = new JavaNamespaceResolver();
|
||||
this.javaConstructorResolver = new JavaConstructorResolver();
|
||||
this.javaInnerClassResolver = new JavaInnerClassResolver();
|
||||
this.javaPropertyResolver = new JavaPropertyResolver();
|
||||
|
||||
@@ -287,6 +287,7 @@ public class InjectorForTopDownAnalyzerForJvm implements InjectorForTopDownAnaly
|
||||
|
||||
javaClassResolver.setAnnotationResolver(javaAnnotationResolver);
|
||||
javaClassResolver.setClassObjectResolver(javaClassObjectResolver);
|
||||
javaClassResolver.setFunctionResolver(javaFunctionResolver);
|
||||
javaClassResolver.setNamespaceResolver(javaNamespaceResolver);
|
||||
javaClassResolver.setPsiClassFinder(psiClassFinder);
|
||||
javaClassResolver.setSemanticServices(javaSemanticServices);
|
||||
@@ -309,24 +310,24 @@ public class InjectorForTopDownAnalyzerForJvm implements InjectorForTopDownAnaly
|
||||
javaSupertypeResolver.setTrace(bindingTrace);
|
||||
javaSupertypeResolver.setTypeTransformer(javaTypeTransformer);
|
||||
|
||||
javaNamespaceResolver.setJavaSemanticServices(javaSemanticServices);
|
||||
javaNamespaceResolver.setPsiClassFinder(psiClassFinder);
|
||||
javaNamespaceResolver.setTrace(bindingTrace);
|
||||
|
||||
javaSignatureResolver.setJavaSemanticServices(javaSemanticServices);
|
||||
|
||||
javaConstructorResolver.setTrace(bindingTrace);
|
||||
javaConstructorResolver.setTypeTransformer(javaTypeTransformer);
|
||||
javaConstructorResolver.setValueParameterResolver(javaValueParameterResolver);
|
||||
|
||||
javaValueParameterResolver.setTypeTransformer(javaTypeTransformer);
|
||||
|
||||
javaFunctionResolver.setAnnotationResolver(javaAnnotationResolver);
|
||||
javaFunctionResolver.setParameterResolver(javaValueParameterResolver);
|
||||
javaFunctionResolver.setSignatureResolver(javaSignatureResolver);
|
||||
javaFunctionResolver.setTrace(bindingTrace);
|
||||
javaFunctionResolver.setTypeTransformer(javaTypeTransformer);
|
||||
|
||||
javaValueParameterResolver.setTypeTransformer(javaTypeTransformer);
|
||||
|
||||
javaSignatureResolver.setJavaSemanticServices(javaSemanticServices);
|
||||
|
||||
javaNamespaceResolver.setJavaSemanticServices(javaSemanticServices);
|
||||
javaNamespaceResolver.setPsiClassFinder(psiClassFinder);
|
||||
javaNamespaceResolver.setTrace(bindingTrace);
|
||||
|
||||
javaConstructorResolver.setTrace(bindingTrace);
|
||||
javaConstructorResolver.setTypeTransformer(javaTypeTransformer);
|
||||
javaConstructorResolver.setValueParameterResolver(javaValueParameterResolver);
|
||||
|
||||
javaInnerClassResolver.setClassResolver(javaClassResolver);
|
||||
|
||||
javaPropertyResolver.setAnnotationResolver(javaAnnotationResolver);
|
||||
|
||||
+1
-1
@@ -140,7 +140,7 @@ public final class DescriptorResolverUtils {
|
||||
public static FqNameUnsafe getFqNameForClassObject(@NotNull PsiClass psiClass) {
|
||||
String psiClassQualifiedName = psiClass.getQualifiedName();
|
||||
assert psiClassQualifiedName != null : "Reading java class with no qualified name";
|
||||
return new FqNameUnsafe(psiClassQualifiedName + "." + getClassObjectName(psiClass.getName()).getName());
|
||||
return new FqNameUnsafe(psiClassQualifiedName + "." + getClassObjectName(psiClass.getName()).asString());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+2
-2
@@ -65,7 +65,7 @@ public class JavaToKotlinClassMap extends JavaToKotlinClassMapBuilder implements
|
||||
PrimitiveType primitiveType = jvmPrimitiveType.getPrimitiveType();
|
||||
primitiveTypesMap.put(jvmPrimitiveType.getName(), KotlinBuiltIns.getInstance().getPrimitiveJetType(primitiveType));
|
||||
primitiveTypesMap.put("[" + jvmPrimitiveType.getName(), KotlinBuiltIns.getInstance().getPrimitiveArrayJetType(primitiveType));
|
||||
primitiveTypesMap.put(jvmPrimitiveType.getWrapper().getFqName().getFqName(), KotlinBuiltIns.getInstance().getNullablePrimitiveJetType(
|
||||
primitiveTypesMap.put(jvmPrimitiveType.getWrapper().getFqName().asString(), KotlinBuiltIns.getInstance().getNullablePrimitiveJetType(
|
||||
primitiveType));
|
||||
}
|
||||
primitiveTypesMap.put("void", KotlinBuiltIns.getInstance().getUnitType());
|
||||
@@ -91,7 +91,7 @@ public class JavaToKotlinClassMap extends JavaToKotlinClassMapBuilder implements
|
||||
@Nullable
|
||||
public AnnotationDescriptor mapToAnnotationClass(@NotNull FqName fqName) {
|
||||
ClassDescriptor classDescriptor = classDescriptorMap.get(fqName);
|
||||
if (classDescriptor != null && fqName.getFqName().equals(CommonClassNames.JAVA_LANG_DEPRECATED)) {
|
||||
if (classDescriptor != null && fqName.asString().equals(CommonClassNames.JAVA_LANG_DEPRECATED)) {
|
||||
return DescriptorResolverUtils.getAnnotationDescriptorForJavaLangDeprecated(classDescriptor);
|
||||
}
|
||||
return null;
|
||||
|
||||
+1
-15
@@ -26,8 +26,6 @@ import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypeUtils;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.renderer.DescriptorRenderer;
|
||||
|
||||
@@ -46,25 +44,13 @@ public class JavaToKotlinMethodMap {
|
||||
private JavaToKotlinMethodMap() {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Set<ClassDescriptor> getAllSuperClasses(@NotNull ClassDescriptor klass) {
|
||||
Set<JetType> allSupertypes = TypeUtils.getAllSupertypes(klass.getDefaultType());
|
||||
Set<ClassDescriptor> allSuperclasses = Sets.newHashSet();
|
||||
for (JetType supertype : allSupertypes) {
|
||||
ClassDescriptor superclass = TypeUtils.getClassDescriptor(supertype);
|
||||
assert superclass != null;
|
||||
allSuperclasses.add(superclass);
|
||||
}
|
||||
return allSuperclasses;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<FunctionDescriptor> getFunctions(@NotNull PsiMethod psiMethod, @NotNull ClassDescriptor containingClass) {
|
||||
ImmutableCollection<ClassData> classDatas = mapContainer.map.get(psiMethod.getContainingClass().getQualifiedName());
|
||||
|
||||
List<FunctionDescriptor> result = Lists.newArrayList();
|
||||
|
||||
Set<ClassDescriptor> allSuperClasses = getAllSuperClasses(containingClass);
|
||||
Set<ClassDescriptor> allSuperClasses = DescriptorUtils.getAllSuperClasses(containingClass);
|
||||
|
||||
String serializedPsiMethod = serializePsiMethod(psiMethod);
|
||||
for (ClassData classData : classDatas) {
|
||||
|
||||
+3
-3
@@ -184,7 +184,7 @@ public class JavaTypeTransformer {
|
||||
" in " + classType.getPresentableText() + "\n PsiClass: \n" + psiClass.getText());
|
||||
|
||||
for (TypeParameterDescriptor parameter : parameters) {
|
||||
arguments.add(new TypeProjection(ErrorUtils.createErrorType(parameter.getName().getName())));
|
||||
arguments.add(new TypeProjection(ErrorUtils.createErrorType(parameter.getName().asString())));
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -275,10 +275,10 @@ public class JavaTypeTransformer {
|
||||
if (!signatureTypeUsages.contains(originalTypeUsage)) {
|
||||
return originalTypeUsage;
|
||||
}
|
||||
if (JavaAnnotationResolver.findAnnotationWithExternal(owner, JvmAbi.JETBRAINS_MUTABLE_ANNOTATION.getFqName().getFqName()) != null) {
|
||||
if (JavaAnnotationResolver.findAnnotationWithExternal(owner, JvmAbi.JETBRAINS_MUTABLE_ANNOTATION.getFqName().asString()) != null) {
|
||||
return TypeUsage.MEMBER_SIGNATURE_COVARIANT;
|
||||
}
|
||||
if (JavaAnnotationResolver.findAnnotationWithExternal(owner, JvmAbi.JETBRAINS_READONLY_ANNOTATION.getFqName().getFqName()) != null) {
|
||||
if (JavaAnnotationResolver.findAnnotationWithExternal(owner, JvmAbi.JETBRAINS_READONLY_ANNOTATION.getFqName().asString()) != null) {
|
||||
return TypeUsage.MEMBER_SIGNATURE_CONTRAVARIANT;
|
||||
}
|
||||
return originalTypeUsage;
|
||||
|
||||
+1
-1
@@ -86,7 +86,7 @@ public abstract class JetTypeJetSignatureReader extends JetSignatureExceptionsAd
|
||||
public void visitClassType(String signatureName, boolean nullable, boolean forceReal) {
|
||||
FqName fqName = JvmClassName.bySignatureName(signatureName).getFqName();
|
||||
|
||||
enterClass(resolveClassDescriptorByFqName(fqName, forceReal), fqName.getFqName(), nullable);
|
||||
enterClass(resolveClassDescriptorByFqName(fqName, forceReal), fqName.asString(), nullable);
|
||||
}
|
||||
|
||||
private void enterClass(@Nullable ClassDescriptor classDescriptor, @NotNull String className, boolean nullable) {
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
package org.jetbrains.jet.lang.resolve.java;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassKind;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
|
||||
@@ -58,7 +56,7 @@ public class JvmAbi {
|
||||
}
|
||||
|
||||
public static String getPropertyDelegateName(@NotNull Name name) {
|
||||
return name.getName() + DELEGATED_PROPERTY_NAME_POSTFIX;
|
||||
return name.asString() + DELEGATED_PROPERTY_NAME_POSTFIX;
|
||||
}
|
||||
|
||||
private JvmAbi() {
|
||||
|
||||
@@ -91,7 +91,7 @@ public class JvmClassName {
|
||||
|
||||
List<String> innerClassNames = Lists.newArrayList();
|
||||
while (descriptor.getContainingDeclaration() instanceof ClassDescriptor) {
|
||||
innerClassNames.add(descriptor.getName().getName());
|
||||
innerClassNames.add(descriptor.getName().asString());
|
||||
descriptor = descriptor.getContainingDeclaration();
|
||||
assert descriptor != null;
|
||||
}
|
||||
@@ -101,7 +101,7 @@ public class JvmClassName {
|
||||
|
||||
@NotNull
|
||||
private static String fqNameToInternalName(@NotNull FqName fqName) {
|
||||
return fqName.getFqName().replace('.', '/');
|
||||
return fqName.asString().replace('.', '/');
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+1
-1
@@ -122,6 +122,6 @@ public class KotlinToJavaTypesMap extends JavaToKotlinClassMapBuilder {
|
||||
|
||||
public boolean isForceReal(@NotNull JvmClassName className) {
|
||||
return JvmPrimitiveType.getByWrapperClass(className) != null
|
||||
|| mappedTypeNames.contains(className.getFqName().getFqName());
|
||||
|| mappedTypeNames.contains(className.getFqName().asString());
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ public class PackageClassUtils {
|
||||
if (packageFQN.isRoot()) {
|
||||
return DEFAULT_PACKAGE;
|
||||
}
|
||||
return StringUtil.capitalize(packageFQN.shortName().getName()) + "Package";
|
||||
return StringUtil.capitalize(packageFQN.shortName().asString()) + "Package";
|
||||
}
|
||||
|
||||
public static FqName getPackageClassFqName(@NotNull FqName packageFQN) {
|
||||
|
||||
+3
-3
@@ -86,7 +86,7 @@ public class PsiClassFinderImpl implements PsiClassFinder {
|
||||
@Override
|
||||
@Nullable
|
||||
public PsiClass findPsiClass(@NotNull FqName qualifiedName, @NotNull RuntimeClassesHandleMode runtimeClassesHandleMode) {
|
||||
PsiClass original = javaFacade.findClass(qualifiedName.getFqName(), javaSearchScope);
|
||||
PsiClass original = javaFacade.findClass(qualifiedName.asString(), javaSearchScope);
|
||||
|
||||
if (original != null) {
|
||||
String classQualifiedName = original.getQualifiedName();
|
||||
@@ -106,7 +106,7 @@ public class PsiClassFinderImpl implements PsiClassFinder {
|
||||
|
||||
if (KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME.equals(qualifiedName.parent())) {
|
||||
PsiAnnotation assertInvisibleAnnotation = JavaAnnotationResolver.findOwnAnnotation(
|
||||
original, JvmStdlibNames.ASSERT_INVISIBLE_IN_RESOLVER.getFqName().getFqName());
|
||||
original, JvmStdlibNames.ASSERT_INVISIBLE_IN_RESOLVER.getFqName().asString());
|
||||
|
||||
if (assertInvisibleAnnotation != null) {
|
||||
switch (runtimeClassesHandleMode) {
|
||||
@@ -131,7 +131,7 @@ public class PsiClassFinderImpl implements PsiClassFinder {
|
||||
@Override
|
||||
@Nullable
|
||||
public PsiPackage findPsiPackage(@NotNull FqName qualifiedName) {
|
||||
return javaFacade.findPackage(qualifiedName.getFqName());
|
||||
return javaFacade.findPackage(qualifiedName.asString());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ public class TypeVariableResolverFromTypeDescriptors implements TypeVariableReso
|
||||
@NotNull DeclarationDescriptor owner,
|
||||
@NotNull String context) {
|
||||
for (TypeParameterDescriptor typeParameter : typeParameters) {
|
||||
if (typeParameter.getName().getName().equals(name)) {
|
||||
if (typeParameter.getName().asString().equals(name)) {
|
||||
return typeParameter;
|
||||
}
|
||||
}
|
||||
|
||||
+10
-6
@@ -23,6 +23,7 @@ import org.jetbrains.jet.lang.descriptors.ConstructorDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.MutableClassDescriptorLite;
|
||||
import org.jetbrains.jet.lang.resolve.java.scope.JavaClassNonStaticMembersScope;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -30,18 +31,16 @@ import java.util.Collection;
|
||||
* @see org.jetbrains.jet.lang.resolve.lazy.descriptors.LazyClassDescriptor
|
||||
*/
|
||||
public class ClassDescriptorFromJvmBytecode extends MutableClassDescriptorLite {
|
||||
private final boolean isSamInterface;
|
||||
private JetType functionTypeForSamInterface;
|
||||
|
||||
private JavaClassNonStaticMembersScope scopeForConstructorResolve;
|
||||
|
||||
public ClassDescriptorFromJvmBytecode(
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull ClassKind kind,
|
||||
boolean isInner,
|
||||
boolean isSamInterface
|
||||
boolean isInner
|
||||
) {
|
||||
super(containingDeclaration, kind, isInner);
|
||||
this.isSamInterface = isSamInterface;
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +61,12 @@ public class ClassDescriptorFromJvmBytecode extends MutableClassDescriptorLite {
|
||||
this.scopeForConstructorResolve = scopeForConstructorResolve;
|
||||
}
|
||||
|
||||
public boolean isSamInterface() {
|
||||
return isSamInterface;
|
||||
@Nullable
|
||||
public JetType getFunctionTypeForSamInterface() {
|
||||
return functionTypeForSamInterface;
|
||||
}
|
||||
|
||||
public void setFunctionTypeForSamInterface(@NotNull JetType functionTypeForSamInterface) {
|
||||
this.functionTypeForSamInterface = functionTypeForSamInterface;
|
||||
}
|
||||
}
|
||||
|
||||
+115
-4
@@ -17,9 +17,11 @@
|
||||
package org.jetbrains.jet.lang.resolve.java.kotlinSignature;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.psi.HierarchicalMethodSignature;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.PsiSubstitutorImpl;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -38,7 +40,11 @@ import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.renderer.DescriptorRenderer;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.intellij.psi.util.TypeConversionUtil.erasure;
|
||||
|
||||
// This class contains heuristics for processing corner cases in propagation
|
||||
class PropagationHeuristics {
|
||||
@@ -122,8 +128,7 @@ class PropagationHeuristics {
|
||||
@NotNull
|
||||
static List<PsiMethod> getSuperMethods(@NotNull PsiMethod method) {
|
||||
List<PsiMethod> superMethods = Lists.newArrayList();
|
||||
for (HierarchicalMethodSignature superSignature : method.getHierarchicalMethodSignature().getSuperSignatures()) {
|
||||
PsiMethod superMethod = superSignature.getMethod();
|
||||
for (PsiMethod superMethod : new SuperMethodCollector(method).collect()) {
|
||||
CallableMemberDescriptor.Kind kindFromFlags =
|
||||
DescriptorKindUtils.flagsToKind(new PsiMethodWrapper(superMethod).getJetMethodAnnotation().kind());
|
||||
if (kindFromFlags == CallableMemberDescriptor.Kind.FAKE_OVERRIDE) {
|
||||
@@ -141,4 +146,110 @@ class PropagationHeuristics {
|
||||
|
||||
private PropagationHeuristics() {
|
||||
}
|
||||
|
||||
private static class SuperMethodCollector {
|
||||
private final PsiMethod initialMethod;
|
||||
private final String initialMethodName;
|
||||
private final List<PsiType> initialParametersErasure;
|
||||
|
||||
private final List<PsiClass> visitedSuperclasses = Lists.newArrayList();
|
||||
private final List<PsiMethod> collectedMethods = Lists.newArrayList();
|
||||
|
||||
private SuperMethodCollector(@NotNull PsiMethod initialMethod) {
|
||||
this.initialMethod = initialMethod;
|
||||
initialMethodName = initialMethod.getName();
|
||||
|
||||
PsiParameterList parameterList = initialMethod.getParameterList();
|
||||
initialParametersErasure = Lists.newArrayListWithExpectedSize(parameterList.getParametersCount());
|
||||
for (PsiParameter parameter : parameterList.getParameters()) {
|
||||
initialParametersErasure.add(erasureNoEllipsis(parameter.getType()));
|
||||
}
|
||||
}
|
||||
|
||||
public List<PsiMethod> collect() {
|
||||
if (!canHaveSuperMethod(initialMethod)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
PsiClass containingClass = initialMethod.getContainingClass();
|
||||
assert containingClass != null : " containing class is null for " + initialMethod;
|
||||
|
||||
for (PsiClassType superType : containingClass.getSuperTypes()) {
|
||||
collectFromSupertype(superType);
|
||||
}
|
||||
|
||||
return collectedMethods;
|
||||
}
|
||||
|
||||
private void collectFromSupertype(PsiClassType type) {
|
||||
PsiClass klass = type.resolve();
|
||||
if (klass == null) {
|
||||
return;
|
||||
}
|
||||
if (!visitedSuperclasses.add(klass)) {
|
||||
return;
|
||||
}
|
||||
|
||||
PsiSubstitutor supertypeSubstitutor = getErasedSubstitutor(type);
|
||||
for (PsiMethod methodFromSuper : klass.getMethods()) {
|
||||
if (isSubMethodOf(methodFromSuper, supertypeSubstitutor)) {
|
||||
collectedMethods.add(methodFromSuper);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (PsiType superType : type.getSuperTypes()) {
|
||||
assert superType instanceof PsiClassType : "supertype is not a PsiClassType for " + type + ": " + superType;
|
||||
collectFromSupertype((PsiClassType) superType);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isSubMethodOf(@NotNull PsiMethod methodFromSuper, @NotNull PsiSubstitutor supertypeSubstitutor) {
|
||||
if (!methodFromSuper.getName().equals(initialMethodName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PsiParameterList fromSuperParameterList = methodFromSuper.getParameterList();
|
||||
|
||||
if (fromSuperParameterList.getParametersCount() != initialParametersErasure.size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < initialParametersErasure.size(); i++) {
|
||||
PsiType originalType = initialParametersErasure.get(i);
|
||||
PsiType typeFromSuper = fromSuperParameterList.getParameters()[i].getType();
|
||||
PsiType typeFromSuperErased = erasureNoEllipsis(supertypeSubstitutor.substitute(typeFromSuper));
|
||||
|
||||
if (!Comparing.equal(originalType, typeFromSuperErased)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static PsiType erasureNoEllipsis(PsiType type) {
|
||||
if (type instanceof PsiEllipsisType) {
|
||||
return erasureNoEllipsis(((PsiEllipsisType) type).toArrayType());
|
||||
}
|
||||
return erasure(type);
|
||||
}
|
||||
|
||||
private static PsiSubstitutor getErasedSubstitutor(PsiClassType type) {
|
||||
Map<PsiTypeParameter, PsiType> unerasedMap = type.resolveGenerics().getSubstitutor().getSubstitutionMap();
|
||||
Map<PsiTypeParameter, PsiType> erasedMap = Maps.newHashMapWithExpectedSize(unerasedMap.size());
|
||||
for (Map.Entry<PsiTypeParameter, PsiType> entry : unerasedMap.entrySet()) {
|
||||
erasedMap.put(entry.getKey(), erasure(entry.getValue()));
|
||||
}
|
||||
return PsiSubstitutorImpl.createSubstitutor(erasedMap);
|
||||
}
|
||||
|
||||
private static boolean canHaveSuperMethod(PsiMethod method) {
|
||||
if (method.isConstructor()) return false;
|
||||
if (method.hasModifierProperty(PsiModifier.STATIC)) return false;
|
||||
if (method.hasModifierProperty(PsiModifier.PRIVATE)) return false;
|
||||
PsiClass containingClass = method.getContainingClass();
|
||||
return containingClass != null && !CommonClassNames.JAVA_LANG_OBJECT.equals(containingClass.getQualifiedName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-4
@@ -242,9 +242,10 @@ public class SignaturesPropagationData {
|
||||
continue;
|
||||
}
|
||||
|
||||
assert superFun instanceof FunctionDescriptor : superFun.getClass().getName();
|
||||
|
||||
superFunctions.add(substituteSuperFunction(superclassToSupertype, (FunctionDescriptor) superFun));
|
||||
// TODO: Add propagation for other kotlin descriptors (KT-3621)
|
||||
if (superFun instanceof FunctionDescriptor) {
|
||||
superFunctions.add(substituteSuperFunction(superclassToSupertype, (FunctionDescriptor) superFun));
|
||||
}
|
||||
}
|
||||
|
||||
// sorting for diagnostic stability
|
||||
@@ -253,7 +254,7 @@ public class SignaturesPropagationData {
|
||||
public int compare(FunctionDescriptor fun1, FunctionDescriptor fun2) {
|
||||
FqNameUnsafe fqName1 = getFQName(fun1.getContainingDeclaration());
|
||||
FqNameUnsafe fqName2 = getFQName(fun2.getContainingDeclaration());
|
||||
return fqName1.getFqName().compareTo(fqName2.getFqName());
|
||||
return fqName1.asString().compareTo(fqName2.asString());
|
||||
}
|
||||
});
|
||||
return superFunctions;
|
||||
|
||||
+3
-3
@@ -99,14 +99,14 @@ public class TypeTransformingVisitor extends JetVisitor<JetType, Void> {
|
||||
}
|
||||
|
||||
private JetType visitCommonType(@NotNull ClassDescriptor classDescriptor, @NotNull JetTypeElement type) {
|
||||
return visitCommonType(DescriptorUtils.getFQName(classDescriptor).toSafe().getFqName(), type);
|
||||
return visitCommonType(DescriptorUtils.getFQName(classDescriptor).toSafe().asString(), type);
|
||||
}
|
||||
|
||||
private JetType visitCommonType(@NotNull String qualifiedName, @NotNull JetTypeElement type) {
|
||||
TypeConstructor originalTypeConstructor = originalType.getConstructor();
|
||||
ClassifierDescriptor declarationDescriptor = originalTypeConstructor.getDeclarationDescriptor();
|
||||
assert declarationDescriptor != null;
|
||||
String fqName = DescriptorUtils.getFQName(declarationDescriptor).toSafe().getFqName();
|
||||
String fqName = DescriptorUtils.getFQName(declarationDescriptor).toSafe().asString();
|
||||
ClassDescriptor classFromLibrary = getAutoTypeAnalogWithinBuiltins(qualifiedName);
|
||||
if (!isSameName(qualifiedName, fqName) && classFromLibrary == null) {
|
||||
throw new AlternativeSignatureMismatchException("Alternative signature type mismatch, expected: %s, actual: %s", qualifiedName, fqName);
|
||||
@@ -212,7 +212,7 @@ public class TypeTransformingVisitor extends JetVisitor<JetType, Void> {
|
||||
Collection<ClassDescriptor> descriptors =
|
||||
JavaToKotlinClassMap.getInstance().mapPlatformClass(JvmClassName.byType(javaAnalog).getFqName());
|
||||
for (ClassDescriptor descriptor : descriptors) {
|
||||
String fqName = DescriptorUtils.getFQName(descriptor).getFqName();
|
||||
String fqName = DescriptorUtils.getFQName(descriptor).asString();
|
||||
if (isSameName(qualifiedName, fqName)) {
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ public class JetClassAnnotation extends PsiAnnotationWithAbiVersion {
|
||||
@NotNull
|
||||
public static JetClassAnnotation get(PsiClass psiClass) {
|
||||
PsiAnnotation annotation = JavaAnnotationResolver.findOwnAnnotation(psiClass,
|
||||
JvmStdlibNames.JET_CLASS.getFqName().getFqName());
|
||||
JvmStdlibNames.JET_CLASS.getFqName().asString());
|
||||
return annotation != null ? new JetClassAnnotation(annotation) : NULL_ANNOTATION;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ public class JetClassObjectAnnotation extends PsiAnnotationWithAbiVersion {
|
||||
@NotNull
|
||||
public static JetClassObjectAnnotation get(@NotNull PsiClass psiClass) {
|
||||
PsiAnnotation annotation =
|
||||
JavaAnnotationResolver.findOwnAnnotation(psiClass, JvmStdlibNames.JET_CLASS_OBJECT.getFqName().getFqName());
|
||||
JavaAnnotationResolver.findOwnAnnotation(psiClass, JvmStdlibNames.JET_CLASS_OBJECT.getFqName().asString());
|
||||
return annotation != null ? new JetClassObjectAnnotation(annotation) : NULL_ANNOTATION;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ public class JetConstructorAnnotation extends PsiAnnotationWithFlags {
|
||||
|
||||
public static JetConstructorAnnotation get(PsiMethod constructor) {
|
||||
PsiAnnotation annotation =
|
||||
JavaAnnotationResolver.findOwnAnnotation(constructor, JvmStdlibNames.JET_CONSTRUCTOR.getFqName().getFqName());
|
||||
JavaAnnotationResolver.findOwnAnnotation(constructor, JvmStdlibNames.JET_CONSTRUCTOR.getFqName().asString());
|
||||
return annotation != null ? new JetConstructorAnnotation(annotation) : NULL_ANNOTATION;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -69,7 +69,7 @@ public class JetMethodAnnotation extends PsiAnnotationWithFlags {
|
||||
|
||||
public static JetMethodAnnotation get(PsiMethod psiMethod) {
|
||||
PsiAnnotation annotation =
|
||||
JavaAnnotationResolver.findOwnAnnotation(psiMethod, JvmStdlibNames.JET_METHOD.getFqName().getFqName());
|
||||
JavaAnnotationResolver.findOwnAnnotation(psiMethod, JvmStdlibNames.JET_METHOD.getFqName().asString());
|
||||
return annotation != null ? new JetMethodAnnotation(annotation) : NULL_ANNOTATION;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ public class JetPackageClassAnnotation extends PsiAnnotationWithAbiVersion {
|
||||
@NotNull
|
||||
public static JetPackageClassAnnotation get(PsiClass psiClass) {
|
||||
PsiAnnotation annotation = JavaAnnotationResolver.findOwnAnnotation(psiClass,
|
||||
JvmStdlibNames.JET_PACKAGE_CLASS.getFqName().getFqName());
|
||||
JvmStdlibNames.JET_PACKAGE_CLASS.getFqName().asString());
|
||||
return annotation != null ? new JetPackageClassAnnotation(annotation) : NULL_ANNOTATION;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ public class JetTypeParameterAnnotation extends PsiAnnotationWrapper {
|
||||
@NotNull
|
||||
public static JetTypeParameterAnnotation get(@NotNull PsiParameter psiParameter) {
|
||||
PsiAnnotation annotation =
|
||||
JavaAnnotationResolver.findOwnAnnotation(psiParameter, JvmStdlibNames.JET_TYPE_PARAMETER.getFqName().getFqName());
|
||||
JavaAnnotationResolver.findOwnAnnotation(psiParameter, JvmStdlibNames.JET_TYPE_PARAMETER.getFqName().asString());
|
||||
return annotation != null ? new JetTypeParameterAnnotation(annotation) : NULL_ANNOTATION;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -77,7 +77,7 @@ public class JetValueParameterAnnotation extends PsiAnnotationWrapper {
|
||||
|
||||
public static JetValueParameterAnnotation get(PsiParameter psiParameter) {
|
||||
PsiAnnotation annotation =
|
||||
JavaAnnotationResolver.findOwnAnnotation(psiParameter, JvmStdlibNames.JET_VALUE_PARAMETER.getFqName().getFqName());
|
||||
JavaAnnotationResolver.findOwnAnnotation(psiParameter, JvmStdlibNames.JET_VALUE_PARAMETER.getFqName().asString());
|
||||
return annotation != null ? new JetValueParameterAnnotation(annotation) : NULL_ANNOTATION;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ public class KotlinSignatureAnnotation extends PsiAnnotationWrapper {
|
||||
@NotNull
|
||||
public static KotlinSignatureAnnotation get(PsiModifierListOwner psiModifierListOwner) {
|
||||
PsiAnnotation annotation =
|
||||
JavaAnnotationResolver.findAnnotationWithExternal(psiModifierListOwner, JvmStdlibNames.KOTLIN_SIGNATURE.getFqName().getFqName());
|
||||
JavaAnnotationResolver.findAnnotationWithExternal(psiModifierListOwner, JvmStdlibNames.KOTLIN_SIGNATURE.getFqName().asString());
|
||||
return annotation != null ? new KotlinSignatureAnnotation(annotation) : NULL_ANNOTATION;
|
||||
}
|
||||
}
|
||||
|
||||
+15
-8
@@ -18,6 +18,7 @@ package org.jetbrains.jet.lang.resolve.java.provider;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiFormatUtil;
|
||||
@@ -402,28 +403,34 @@ public final class MembersCache {
|
||||
}
|
||||
|
||||
public static boolean isSamInterface(@NotNull PsiClass psiClass) {
|
||||
return getSamInterfaceMethod(psiClass) != null;
|
||||
}
|
||||
|
||||
// Returns null if not SAM interface
|
||||
@Nullable
|
||||
public static PsiMethod getSamInterfaceMethod(@NotNull PsiClass psiClass) {
|
||||
if (DescriptorResolverUtils.isKotlinClass(psiClass)) {
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
String qualifiedName = psiClass.getQualifiedName();
|
||||
if (qualifiedName == null || qualifiedName.startsWith(KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME.getFqName() + ".")) {
|
||||
return false;
|
||||
if (qualifiedName == null || qualifiedName.startsWith(KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME.asString() + ".")) {
|
||||
return null;
|
||||
}
|
||||
if (!psiClass.isInterface() || psiClass.isAnnotationType()) {
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
int foundAbstractMethods = 0;
|
||||
List<PsiMethod> methods = Lists.newArrayList();
|
||||
for (PsiMethod method : psiClass.getAllMethods()) {
|
||||
if (!isObjectMethod(method) && method.hasModifierProperty(PsiModifier.ABSTRACT)) {
|
||||
foundAbstractMethods++;
|
||||
methods.add(method);
|
||||
|
||||
if (method.hasTypeParameters()) {
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return foundAbstractMethods == 1;
|
||||
return methods.size() == 1 ? methods.get(0) : null;
|
||||
}
|
||||
|
||||
private static abstract class RunOnce implements Runnable {
|
||||
|
||||
+1
-1
@@ -84,7 +84,7 @@ public final class JavaAnnotationResolver {
|
||||
}
|
||||
|
||||
// Don't process internal jet annotations and jetbrains NotNull annotations
|
||||
if (qname.startsWith("jet.runtime.typeinfo.") || qname.equals(JvmAbi.JETBRAINS_NOT_NULL_ANNOTATION.getFqName().getFqName())) {
|
||||
if (qname.startsWith("jet.runtime.typeinfo.") || qname.equals(JvmAbi.JETBRAINS_NOT_NULL_ANNOTATION.getFqName().asString())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -100,7 +100,7 @@ public final class JavaClassObjectResolver {
|
||||
FqName fqName = new FqName(qualifiedName);
|
||||
ClassPsiDeclarationProvider classObjectData = semanticServices.getPsiDeclarationProviderFactory().createBinaryClassData(classObjectPsiClass);
|
||||
ClassDescriptorFromJvmBytecode classObjectDescriptor
|
||||
= new ClassDescriptorFromJvmBytecode(containing, ClassKind.CLASS_OBJECT, false, false);
|
||||
= new ClassDescriptorFromJvmBytecode(containing, ClassKind.CLASS_OBJECT, false);
|
||||
classObjectDescriptor.setSupertypes(supertypesResolver.getSupertypes(classObjectDescriptor,
|
||||
new PsiClassWrapper(classObjectPsiClass),
|
||||
classObjectData,
|
||||
@@ -129,9 +129,9 @@ public final class JavaClassObjectResolver {
|
||||
) {
|
||||
FqNameUnsafe fqName = DescriptorResolverUtils.getFqNameForClassObject(psiClass);
|
||||
ClassDescriptorFromJvmBytecode classObjectDescriptor =
|
||||
new ClassDescriptorFromJvmBytecode(containing, ClassKind.CLASS_OBJECT, false, false);
|
||||
new ClassDescriptorFromJvmBytecode(containing, ClassKind.CLASS_OBJECT, false);
|
||||
ClassPsiDeclarationProvider data = semanticServices.getPsiDeclarationProviderFactory().createSyntheticClassObjectClassData(psiClass);
|
||||
setUpClassObjectDescriptor(classObjectDescriptor, containing, fqName, data, getClassObjectName(containing.getName().getName()));
|
||||
setUpClassObjectDescriptor(classObjectDescriptor, containing, fqName, data, getClassObjectName(containing.getName().asString()));
|
||||
return classObjectDescriptor;
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ public final class JavaClassObjectResolver {
|
||||
classObjectDescriptor.createTypeConstructor();
|
||||
JavaClassNonStaticMembersScope classMembersScope = new JavaClassNonStaticMembersScope(classObjectDescriptor, data, semanticServices);
|
||||
WritableScopeImpl writableScope =
|
||||
new WritableScopeImpl(classMembersScope, classObjectDescriptor, RedeclarationHandler.THROW_EXCEPTION, fqName.toString());
|
||||
new WritableScopeImpl(classMembersScope, classObjectDescriptor, RedeclarationHandler.THROW_EXCEPTION, "Member lookup scope");
|
||||
writableScope.changeLockLevel(WritableScope.LockLevel.BOTH);
|
||||
classObjectDescriptor.setScopeForMemberLookup(writableScope);
|
||||
classObjectDescriptor.setScopeForConstructorResolve(classMembersScope);
|
||||
|
||||
+48
-3
@@ -20,6 +20,7 @@ import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.psi.PsiModifier;
|
||||
import gnu.trove.THashMap;
|
||||
import gnu.trove.TObjectHashingStrategy;
|
||||
@@ -34,13 +35,16 @@ import org.jetbrains.jet.lang.resolve.java.descriptor.ClassDescriptorFromJvmByte
|
||||
import org.jetbrains.jet.lang.resolve.java.kt.JetClassAnnotation;
|
||||
import org.jetbrains.jet.lang.resolve.java.provider.ClassPsiDeclarationProvider;
|
||||
import org.jetbrains.jet.lang.resolve.java.provider.MembersCache;
|
||||
import org.jetbrains.jet.lang.resolve.java.sam.SingleAbstractMethodUtils;
|
||||
import org.jetbrains.jet.lang.resolve.java.scope.JavaClassNonStaticMembersScope;
|
||||
import org.jetbrains.jet.lang.resolve.java.wrapper.PsiClassWrapper;
|
||||
import org.jetbrains.jet.lang.resolve.java.wrapper.PsiMethodWrapper;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqNameBase;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypeUtils;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.ArrayList;
|
||||
@@ -80,6 +84,7 @@ public final class JavaClassResolver {
|
||||
private JavaNamespaceResolver namespaceResolver;
|
||||
private JavaClassObjectResolver classObjectResolver;
|
||||
private JavaSupertypeResolver supertypesResolver;
|
||||
private JavaFunctionResolver functionResolver;
|
||||
|
||||
public JavaClassResolver() {
|
||||
}
|
||||
@@ -124,6 +129,11 @@ public final class JavaClassResolver {
|
||||
this.supertypesResolver = supertypesResolver;
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void setFunctionResolver(JavaFunctionResolver functionResolver) {
|
||||
this.functionResolver = functionResolver;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ClassDescriptor resolveClass(@NotNull FqName qualifiedName, @NotNull DescriptorSearchRule searchRule) {
|
||||
PostponedTasks postponedTasks = new PostponedTasks();
|
||||
@@ -192,7 +202,7 @@ public final class JavaClassResolver {
|
||||
|
||||
private static boolean isTraitImplementation(@NotNull FqName qualifiedName) {
|
||||
// TODO: only if -$$TImpl class is created by Kotlin
|
||||
return qualifiedName.getFqName().endsWith(JvmAbi.TRAIT_IMPL_SUFFIX);
|
||||
return qualifiedName.asString().endsWith(JvmAbi.TRAIT_IMPL_SUFFIX);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -229,7 +239,7 @@ public final class JavaClassResolver {
|
||||
ClassKind kind = getClassKind(psiClass, jetClassAnnotation);
|
||||
ClassPsiDeclarationProvider classData = semanticServices.getPsiDeclarationProviderFactory().createBinaryClassData(psiClass);
|
||||
ClassDescriptorFromJvmBytecode classDescriptor = new ClassDescriptorFromJvmBytecode(
|
||||
containingDeclaration, kind, isInnerClass(psiClass), MembersCache.isSamInterface(psiClass));
|
||||
containingDeclaration, kind, isInnerClass(psiClass));
|
||||
|
||||
cache(javaClassToKotlinFqName(fqName), classDescriptor);
|
||||
classDescriptor.setName(Name.identifier(psiClass.getName()));
|
||||
@@ -264,9 +274,44 @@ public final class JavaClassResolver {
|
||||
|
||||
trace.record(BindingContext.CLASS, psiClass, classDescriptor);
|
||||
|
||||
PsiMethod samInterfaceMethod = MembersCache.getSamInterfaceMethod(psiClass);
|
||||
if (samInterfaceMethod != null) {
|
||||
SimpleFunctionDescriptor abstractMethod = resolveFunctionOfSamInterface(psiClass, samInterfaceMethod, classDescriptor);
|
||||
classDescriptor.setFunctionTypeForSamInterface(SingleAbstractMethodUtils.getFunctionTypeForAbstractMethod(abstractMethod));
|
||||
}
|
||||
|
||||
return classDescriptor;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private SimpleFunctionDescriptor resolveFunctionOfSamInterface(
|
||||
@NotNull PsiClass psiClass,
|
||||
@NotNull PsiMethod samInterfaceMethod,
|
||||
@NotNull ClassDescriptorFromJvmBytecode samInterface
|
||||
) {
|
||||
PsiClass methodContainer = samInterfaceMethod.getContainingClass();
|
||||
assert methodContainer != null : "method container is null for " + methodContainer;
|
||||
String containerQualifiedName = methodContainer.getQualifiedName();
|
||||
assert containerQualifiedName != null : "qualified name is null for " + psiClass;
|
||||
|
||||
if (DescriptorUtils.getFQName(samInterface).asString().equals(containerQualifiedName)) {
|
||||
SimpleFunctionDescriptor abstractMethod =
|
||||
functionResolver.resolveFunctionMutely(new PsiMethodWrapper(samInterfaceMethod), samInterface);
|
||||
assert abstractMethod != null : "couldn't resolve method " + samInterfaceMethod;
|
||||
return abstractMethod;
|
||||
}
|
||||
else {
|
||||
Set<JetType> supertypes = TypeUtils.getAllSupertypes(samInterface.getDefaultType());
|
||||
for (JetType supertype : supertypes) {
|
||||
List<CallableMemberDescriptor> abstractMembers = SingleAbstractMethodUtils.getAbstractMembers(supertype);
|
||||
if (!abstractMembers.isEmpty()) {
|
||||
return (SimpleFunctionDescriptor) abstractMembers.get(0);
|
||||
}
|
||||
}
|
||||
throw new IllegalStateException("Couldn't find abstract method in supertypes " + supertypes);
|
||||
}
|
||||
}
|
||||
|
||||
private void cache(@NotNull FqNameBase fqName, @Nullable ClassDescriptor classDescriptor) {
|
||||
if (classDescriptor == null) {
|
||||
cacheNegativeValue(fqName);
|
||||
@@ -332,7 +377,7 @@ public final class JavaClassResolver {
|
||||
private static FqNameUnsafe javaClassToKotlinFqName(@NotNull FqName rawFqName) {
|
||||
List<Name> correctedSegments = new ArrayList<Name>();
|
||||
for (Name segment : rawFqName.pathSegments()) {
|
||||
if (JvmAbi.CLASS_OBJECT_CLASS_NAME.equals(segment.getName())) {
|
||||
if (JvmAbi.CLASS_OBJECT_CLASS_NAME.equals(segment.asString())) {
|
||||
assert !correctedSegments.isEmpty();
|
||||
Name previous = correctedSegments.get(correctedSegments.size() - 1);
|
||||
correctedSegments.add(DescriptorUtils.getClassObjectName(previous));
|
||||
|
||||
+24
-13
@@ -34,10 +34,7 @@ import org.jetbrains.jet.lang.resolve.java.*;
|
||||
import org.jetbrains.jet.lang.resolve.java.kotlinSignature.AlternativeMethodSignatureData;
|
||||
import org.jetbrains.jet.lang.resolve.java.kotlinSignature.SignaturesPropagationData;
|
||||
import org.jetbrains.jet.lang.resolve.java.kt.DescriptorKindUtils;
|
||||
import org.jetbrains.jet.lang.resolve.java.provider.ClassPsiDeclarationProvider;
|
||||
import org.jetbrains.jet.lang.resolve.java.provider.NamedMembers;
|
||||
import org.jetbrains.jet.lang.resolve.java.provider.PackagePsiDeclarationProvider;
|
||||
import org.jetbrains.jet.lang.resolve.java.provider.PsiDeclarationProvider;
|
||||
import org.jetbrains.jet.lang.resolve.java.provider.*;
|
||||
import org.jetbrains.jet.lang.resolve.java.sam.SingleAbstractMethodUtils;
|
||||
import org.jetbrains.jet.lang.resolve.java.wrapper.PsiMethodWrapper;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
@@ -93,10 +90,20 @@ public final class JavaFunctionResolver {
|
||||
this.annotationResolver = annotationResolver;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
SimpleFunctionDescriptor resolveFunctionMutely(
|
||||
@NotNull PsiMethodWrapper method,
|
||||
@NotNull ClassOrNamespaceDescriptor ownerDescriptor
|
||||
) {
|
||||
PsiClass containingClass = method.getPsiMethod().getContainingClass();
|
||||
assert containingClass != null : "containing class is null for " + method;
|
||||
return resolveMethodToFunctionDescriptor(containingClass, method, DeclarationOrigin.JAVA, ownerDescriptor, false);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private SimpleFunctionDescriptor resolveMethodToFunctionDescriptor(
|
||||
@NotNull PsiClass psiClass, PsiMethodWrapper method,
|
||||
@NotNull PsiDeclarationProvider scopeData, @NotNull ClassOrNamespaceDescriptor ownerDescriptor
|
||||
@NotNull DeclarationOrigin declarationOrigin, @NotNull ClassOrNamespaceDescriptor ownerDescriptor, boolean record
|
||||
) {
|
||||
if (!DescriptorResolverUtils.isCorrectOwnerForEnumMember(ownerDescriptor, method.getPsiMember())) {
|
||||
return null;
|
||||
@@ -114,11 +121,11 @@ public final class JavaFunctionResolver {
|
||||
|
||||
PsiMethod psiMethod = method.getPsiMethod();
|
||||
PsiClass containingClass = psiMethod.getContainingClass();
|
||||
if (scopeData.getDeclarationOrigin() == KOTLIN) {
|
||||
if (declarationOrigin == KOTLIN) {
|
||||
// TODO: unless maybe class explicitly extends Object
|
||||
assert containingClass != null;
|
||||
String ownerClassName = containingClass.getQualifiedName();
|
||||
if (DescriptorResolverUtils.OBJECT_FQ_NAME.getFqName().equals(ownerClassName)) {
|
||||
if (DescriptorResolverUtils.OBJECT_FQ_NAME.asString().equals(ownerClassName)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -189,11 +196,11 @@ public final class JavaFunctionResolver {
|
||||
/*isInline = */ false
|
||||
);
|
||||
|
||||
if (functionDescriptorImpl.getKind() == CallableMemberDescriptor.Kind.DECLARATION) {
|
||||
if (functionDescriptorImpl.getKind() == CallableMemberDescriptor.Kind.DECLARATION && record) {
|
||||
BindingContextUtils.recordFunctionDeclarationToDescriptor(trace, psiMethod, functionDescriptorImpl);
|
||||
}
|
||||
|
||||
if (scopeData.getDeclarationOrigin() == JAVA) {
|
||||
if (declarationOrigin == JAVA && record) {
|
||||
trace.record(BindingContext.IS_DECLARED_IN_JAVA, functionDescriptorImpl);
|
||||
}
|
||||
|
||||
@@ -208,7 +215,9 @@ public final class JavaFunctionResolver {
|
||||
checkFunctionsOverrideCorrectly(method, superFunctions, functionDescriptorImpl);
|
||||
}
|
||||
else {
|
||||
trace.record(BindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS, functionDescriptorImpl, signatureErrors);
|
||||
if (record) {
|
||||
trace.record(BindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS, functionDescriptorImpl, signatureErrors);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,11 +276,13 @@ public final class JavaFunctionResolver {
|
||||
|
||||
Set<SimpleFunctionDescriptor> functionsFromCurrent = Sets.newHashSet();
|
||||
for (PsiMethodWrapper method : namedMembers.getMethods()) {
|
||||
SimpleFunctionDescriptor function = resolveMethodToFunctionDescriptor(psiClass, method, scopeData, owner);
|
||||
SimpleFunctionDescriptor function = resolveMethodToFunctionDescriptor(psiClass, method, scopeData.getDeclarationOrigin(), owner, true);
|
||||
if (function != null) {
|
||||
functionsFromCurrent.add(function);
|
||||
|
||||
ContainerUtil.addIfNotNull(functionsFromCurrent, resolveSamAdapter(function));
|
||||
if (!DescriptorResolverUtils.isKotlinClass(psiClass)) {
|
||||
ContainerUtil.addIfNotNull(functionsFromCurrent, resolveSamAdapter(function));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -430,7 +441,7 @@ public final class JavaFunctionResolver {
|
||||
transformedType = typeTransformer.transformToType(returnType, typeUsage, typeVariableResolver);
|
||||
}
|
||||
|
||||
if (JavaAnnotationResolver.findAnnotationWithExternal(method.getPsiMethod(), JvmAbi.JETBRAINS_NOT_NULL_ANNOTATION.getFqName().getFqName()) !=
|
||||
if (JavaAnnotationResolver.findAnnotationWithExternal(method.getPsiMethod(), JvmAbi.JETBRAINS_NOT_NULL_ANNOTATION.getFqName().asString()) !=
|
||||
null) {
|
||||
return TypeUtils.makeNullableAsSpecified(transformedType, false);
|
||||
}
|
||||
|
||||
+1
-1
@@ -392,7 +392,7 @@ public final class JavaPropertyResolver {
|
||||
|
||||
boolean hasNotNullAnnotation = JavaAnnotationResolver.findAnnotationWithExternal(
|
||||
characteristicMember.getType().getPsiNotNullOwner(),
|
||||
JvmAbi.JETBRAINS_NOT_NULL_ANNOTATION.getFqName().getFqName()) != null;
|
||||
JvmAbi.JETBRAINS_NOT_NULL_ANNOTATION.getFqName().asString()) != null;
|
||||
|
||||
if (hasNotNullAnnotation || members.isStaticFinalField()) {
|
||||
propertyType = TypeUtils.makeNotNullable(propertyType);
|
||||
|
||||
+1
-1
@@ -90,7 +90,7 @@ public final class JavaValueParameterResolver {
|
||||
else {
|
||||
|
||||
JetType transformedType;
|
||||
if (JavaAnnotationResolver.findAnnotationWithExternal(parameter.getPsiParameter(), JvmAbi.JETBRAINS_NOT_NULL_ANNOTATION.getFqName().getFqName()) !=
|
||||
if (JavaAnnotationResolver.findAnnotationWithExternal(parameter.getPsiParameter(), JvmAbi.JETBRAINS_NOT_NULL_ANNOTATION.getFqName().asString()) !=
|
||||
null) {
|
||||
transformedType = TypeUtils.makeNullableAsSpecified(outType, false);
|
||||
}
|
||||
|
||||
+63
-15
@@ -27,10 +27,7 @@ import org.jetbrains.jet.lang.descriptors.impl.ValueParameterDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.resolve.java.descriptor.ClassDescriptorFromJvmBytecode;
|
||||
import org.jetbrains.jet.lang.resolve.java.kotlinSignature.SignaturesUtil;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypeSubstitutor;
|
||||
import org.jetbrains.jet.lang.types.TypeUtils;
|
||||
import org.jetbrains.jet.lang.types.Variance;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -38,9 +35,12 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.jetbrains.jet.lang.types.Variance.INVARIANT;
|
||||
|
||||
public class SingleAbstractMethodUtils {
|
||||
|
||||
@NotNull
|
||||
private static List<CallableMemberDescriptor> getAbstractMembers(@NotNull JetType type) {
|
||||
public static List<CallableMemberDescriptor> getAbstractMembers(@NotNull JetType type) {
|
||||
List<CallableMemberDescriptor> abstractMembers = Lists.newArrayList();
|
||||
for (DeclarationDescriptor member : type.getMemberScope().getAllDescriptors()) {
|
||||
if (member instanceof CallableMemberDescriptor &&
|
||||
@@ -52,18 +52,67 @@ public class SingleAbstractMethodUtils {
|
||||
return abstractMembers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
// TODO maybe do this in substitutor?
|
||||
private static JetType fixProjections(@NotNull JetType functionType) {
|
||||
//removes redundant projection kinds and detects conflicts
|
||||
|
||||
List<TypeProjection> arguments = Lists.newArrayList();
|
||||
for (TypeParameterDescriptor typeParameter : functionType.getConstructor().getParameters()) {
|
||||
Variance variance = typeParameter.getVariance();
|
||||
TypeProjection argument = functionType.getArguments().get(typeParameter.getIndex());
|
||||
Variance kind = argument.getProjectionKind();
|
||||
if (kind != INVARIANT && variance != INVARIANT) {
|
||||
if (kind == variance) {
|
||||
arguments.add(new TypeProjection(argument.getType()));
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
arguments.add(argument);
|
||||
}
|
||||
}
|
||||
ClassifierDescriptor classifier = functionType.getConstructor().getDeclarationDescriptor();
|
||||
assert classifier instanceof ClassDescriptor : "Not class: " + classifier;
|
||||
return new JetTypeImpl(
|
||||
functionType.getAnnotations(),
|
||||
functionType.getConstructor(),
|
||||
functionType.isNullable(),
|
||||
arguments,
|
||||
((ClassDescriptor) classifier).getMemberScope(arguments)
|
||||
);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static JetType getFunctionTypeForSamType(@NotNull JetType samType) {
|
||||
FunctionDescriptor function = getAbstractMethodOfSamType(samType);
|
||||
// e.g. samType == Comparator<String>?
|
||||
|
||||
ClassifierDescriptor classifier = samType.getConstructor().getDeclarationDescriptor();
|
||||
if (classifier instanceof ClassDescriptorFromJvmBytecode) {
|
||||
// Function2<T, T, Int>
|
||||
JetType functionTypeDefault = ((ClassDescriptorFromJvmBytecode) classifier).getFunctionTypeForSamInterface();
|
||||
|
||||
if (functionTypeDefault != null) {
|
||||
// Function2<String, String, Int>?
|
||||
JetType substitute = TypeSubstitutor.create(samType).substitute(functionTypeDefault, Variance.INVARIANT);
|
||||
|
||||
return substitute == null ? null : fixProjections(TypeUtils.makeNullableAsSpecified(substitute, samType.isNullable()));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static JetType getFunctionTypeForAbstractMethod(@NotNull FunctionDescriptor function) {
|
||||
JetType returnType = function.getReturnType();
|
||||
assert returnType != null : "function is not initialized: " + function;
|
||||
List<JetType> parameterTypes = Lists.newArrayList();
|
||||
for (ValueParameterDescriptor parameter : function.getValueParameters()) {
|
||||
parameterTypes.add(parameter.getType());
|
||||
}
|
||||
JetType functionType = KotlinBuiltIns.getInstance()
|
||||
.getFunctionType(Collections.<AnnotationDescriptor>emptyList(), null, parameterTypes, returnType);
|
||||
return TypeUtils.makeNullableAsSpecified(functionType, samType.isNullable());
|
||||
return KotlinBuiltIns.getInstance().getFunctionType(
|
||||
Collections.<AnnotationDescriptor>emptyList(), null, parameterTypes, returnType);
|
||||
}
|
||||
|
||||
private static boolean isSamInterface(@NotNull ClassDescriptor klass) {
|
||||
@@ -98,6 +147,7 @@ public class SingleAbstractMethodUtils {
|
||||
TypeParameters typeParameters = recreateAndInitializeTypeParameters(samInterface.getTypeConstructor().getParameters(), result);
|
||||
|
||||
JetType parameterTypeUnsubstituted = getFunctionTypeForSamType(samInterface.getDefaultType());
|
||||
assert parameterTypeUnsubstituted != null : "couldn't get function type for SAM type " + samInterface.getDefaultType();
|
||||
JetType parameterType = typeParameters.substitutor.substitute(parameterTypeUnsubstituted, Variance.IN_VARIANCE);
|
||||
assert parameterType != null : "couldn't substitute type: " + parameterType + ", substitutor = " + typeParameters.substitutor;
|
||||
ValueParameterDescriptor parameter = new ValueParameterDescriptorImpl(
|
||||
@@ -121,10 +171,7 @@ public class SingleAbstractMethodUtils {
|
||||
}
|
||||
|
||||
public static boolean isSamType(@NotNull JetType type) {
|
||||
ClassifierDescriptor classifier = type.getConstructor().getDeclarationDescriptor();
|
||||
return classifier instanceof ClassDescriptorFromJvmBytecode &&
|
||||
((ClassDescriptorFromJvmBytecode) classifier).isSamInterface() &&
|
||||
getAbstractMembers(type).size() == 1; // Comparator<*> is not a SAM type, because substituted compare() method doesn't exist
|
||||
return getFunctionTypeForSamType(type) != null;
|
||||
}
|
||||
|
||||
public static boolean isSamAdapterNecessary(@NotNull SimpleFunctionDescriptor fun) {
|
||||
@@ -155,7 +202,8 @@ public class SingleAbstractMethodUtils {
|
||||
List<ValueParameterDescriptor> valueParameters = Lists.newArrayList();
|
||||
for (ValueParameterDescriptor originalParam : original.getValueParameters()) {
|
||||
JetType originalType = originalParam.getType();
|
||||
JetType newTypeUnsubstituted = isSamType(originalType) ? getFunctionTypeForSamType(originalType) : originalType;
|
||||
JetType functionType = getFunctionTypeForSamType(originalType);
|
||||
JetType newTypeUnsubstituted = functionType != null ? functionType : originalType;
|
||||
JetType newType = typeParameters.substitutor.substitute(newTypeUnsubstituted, Variance.IN_VARIANCE);
|
||||
assert newType != null : "couldn't substitute type: " + newTypeUnsubstituted + ", substitutor = " + typeParameters.substitutor;
|
||||
|
||||
|
||||
+24
-5
@@ -20,7 +20,9 @@ import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.intellij.openapi.progress.ProgressIndicatorProvider;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
@@ -33,10 +35,7 @@ import org.jetbrains.jet.lang.resolve.java.provider.PsiDeclarationProvider;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScopeImpl;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
public abstract class JavaBaseScope extends JetScopeImpl {
|
||||
|
||||
@@ -50,6 +49,8 @@ public abstract class JavaBaseScope extends JetScopeImpl {
|
||||
private final Map<Name, Set<VariableDescriptor>> propertyDescriptors = Maps.newHashMap();
|
||||
@Nullable
|
||||
private Collection<DeclarationDescriptor> allDescriptors = null;
|
||||
@Nullable
|
||||
private Set<ClassDescriptor> objectDescriptors = null;
|
||||
@NotNull
|
||||
protected final ClassOrNamespaceDescriptor descriptor;
|
||||
|
||||
@@ -130,10 +131,19 @@ public abstract class JavaBaseScope extends JetScopeImpl {
|
||||
protected Collection<DeclarationDescriptor> computeAllDescriptors() {
|
||||
Collection<DeclarationDescriptor> result = Sets.newHashSet();
|
||||
result.addAll(computeFieldAndFunctionDescriptors());
|
||||
result.addAll(getInnerClasses());
|
||||
result.addAll(filterObjects(getInnerClasses(), false));
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<ClassDescriptor> getObjectDescriptors() {
|
||||
if (objectDescriptors == null) {
|
||||
objectDescriptors = new HashSet<ClassDescriptor>(filterObjects(getInnerClasses(), true));
|
||||
}
|
||||
return objectDescriptors;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected abstract Collection<ClassDescriptor> computeInnerClasses();
|
||||
|
||||
@@ -174,4 +184,13 @@ public abstract class JavaBaseScope extends JetScopeImpl {
|
||||
}
|
||||
return innerClasses;
|
||||
}
|
||||
|
||||
private static <T extends ClassDescriptor> Collection<T> filterObjects(Collection<T> classes, final boolean objects) {
|
||||
return ContainerUtil.filter(classes, new Condition<T>() {
|
||||
@Override
|
||||
public boolean value(T classDescriptor) {
|
||||
return classDescriptor.getKind().isObject() == objects;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,8 @@
|
||||
<target name="lexer">
|
||||
<echo message="${flex.base}"/>
|
||||
<flex flexfile="${home}/src/org/jetbrains/jet/lexer/Jet.flex"
|
||||
destdir="${home}//src/org/jetbrains/jet/lexer/"/>
|
||||
destdir="${home}/src/org/jetbrains/jet/lexer/"/>
|
||||
<flex flexfile="${home}/src/org/jetbrains/jet/kdoc/lexer/KDoc.flex"
|
||||
destdir="${home}/src/org/jetbrains/jet/kdoc/lexer/"/>
|
||||
</target>
|
||||
</project>
|
||||
|
||||
@@ -65,18 +65,12 @@ public open class Throwable(message : String? = null, cause: Throwable? = null)
|
||||
public fun printStackTrace() : Unit
|
||||
}
|
||||
|
||||
/*
|
||||
* Should have an abstract property 'name', overridden in PropertyMetadataImpl
|
||||
*/
|
||||
public trait PropertyMetadata {
|
||||
public fun getName(): String
|
||||
public val name: String
|
||||
}
|
||||
|
||||
/*
|
||||
* In front-end we need to resolve call PropertyMetadataImpl() in getter of delegated property
|
||||
* to be able generate it in back-end using ExpressionCodegen.invokeFunction
|
||||
*/
|
||||
public class PropertyMetadataImpl(private val innerName: String): PropertyMetadata {
|
||||
public override fun getName(): String = innerName
|
||||
}
|
||||
|
||||
public class PropertyMetadataImpl(public override val name: String): PropertyMetadata
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
package org.jetbrains.jet.kdoc.lexer;
|
||||
|
||||
import com.intellij.lexer.FlexLexer;
|
||||
import com.intellij.psi.TokenType;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.util.text.CharArrayUtil;
|
||||
import java.lang.Character;
|
||||
|
||||
%%
|
||||
|
||||
%unicode
|
||||
%class _KDocLexer
|
||||
%implements FlexLexer
|
||||
|
||||
%{
|
||||
public _KDocLexer() {
|
||||
this((java.io.Reader)null);
|
||||
}
|
||||
|
||||
private boolean isLastToken() {
|
||||
return zzMarkedPos == zzBuffer.length();
|
||||
}
|
||||
|
||||
private Boolean yytextContainLineBreaks() {
|
||||
return CharArrayUtil.containLineBreaks(zzBuffer, zzStartRead, zzMarkedPos);
|
||||
}
|
||||
|
||||
private boolean nextIsNotWhitespace() {
|
||||
return zzMarkedPos <= zzBuffer.length() && !Character.isWhitespace(zzBuffer.charAt(zzMarkedPos + 1));
|
||||
}
|
||||
|
||||
private boolean prevIsNotWhitespace() {
|
||||
return zzMarkedPos != 0 && !Character.isWhitespace(zzBuffer.charAt(zzMarkedPos - 1));
|
||||
}
|
||||
%}
|
||||
|
||||
%function advance
|
||||
%type IElementType
|
||||
%eof{
|
||||
return;
|
||||
%eof}
|
||||
|
||||
%state LINE_BEGINNING
|
||||
%state CONTENTS_BEGINNING
|
||||
%state CONTENTS
|
||||
%state CODE
|
||||
%state CODE2
|
||||
|
||||
WHITE_SPACE_CHAR =[\ \t\f\n\r]
|
||||
NOT_WHITE_SPACE_CHAR=[^\ \t\f\n\r]
|
||||
|
||||
DIGIT=[0-9]
|
||||
ALPHA=[:jletter:]
|
||||
TAG_NAME={ALPHA}({ALPHA}|{DIGIT})*
|
||||
|
||||
MARKDOWN_EMPHASIS=[\*_]
|
||||
|
||||
%%
|
||||
|
||||
|
||||
<YYINITIAL> "/**" { yybegin(CONTENTS);
|
||||
return KDocTokens.START; }
|
||||
"*"+ "/" { if (isLastToken()) return KDocTokens.END;
|
||||
else return KDocTokens.TEXT; }
|
||||
|
||||
<LINE_BEGINNING> "*"+ { yybegin(CONTENTS_BEGINNING);
|
||||
return KDocTokens.LEADING_ASTERISK; }
|
||||
|
||||
<CONTENTS_BEGINNING> "@"{TAG_NAME} { yybegin(CONTENTS);
|
||||
return KDocTokens.TAG_NAME; }
|
||||
|
||||
<LINE_BEGINNING, CONTENTS_BEGINNING, CONTENTS> {
|
||||
{WHITE_SPACE_CHAR}+ {
|
||||
if (yytextContainLineBreaks()) {
|
||||
yybegin(LINE_BEGINNING);
|
||||
return TokenType.WHITE_SPACE;
|
||||
} else {
|
||||
yybegin(yystate() == CONTENTS_BEGINNING? CONTENTS_BEGINNING:CONTENTS);
|
||||
return KDocTokens.TEXT; // internal white space
|
||||
}
|
||||
}
|
||||
|
||||
"\\"[\[\]] { yybegin(CONTENTS);
|
||||
return KDocTokens.MARKDOWN_ESCAPED_CHAR; }
|
||||
|
||||
"[[" { yybegin(CONTENTS);
|
||||
return KDocTokens.WIKI_LINK_OPEN; }
|
||||
"]]" { yybegin(CONTENTS);
|
||||
return KDocTokens.WIKI_LINK_CLOSE; }
|
||||
|
||||
. { yybegin(CONTENTS);
|
||||
return KDocTokens.TEXT; }
|
||||
}
|
||||
|
||||
. { return TokenType.BAD_CHARACTER; }
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.kdoc.lexer;
|
||||
|
||||
import com.intellij.lexer.FlexAdapter;
|
||||
import com.intellij.lexer.MergingLexerAdapter;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
|
||||
import java.io.Reader;
|
||||
|
||||
public class KDocLexer extends MergingLexerAdapter {
|
||||
public KDocLexer() {
|
||||
super(
|
||||
new FlexAdapter(
|
||||
new _KDocLexer((Reader) null)
|
||||
),
|
||||
TokenSet.create(KDocTokens.TEXT)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.kdoc.lexer;
|
||||
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lexer.JetToken;
|
||||
|
||||
public class KDocToken extends JetToken {
|
||||
public KDocToken(@NotNull @NonNls String debugName) {
|
||||
super(debugName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.kdoc.lexer;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.PsiBuilder;
|
||||
import com.intellij.lang.PsiBuilderFactory;
|
||||
import com.intellij.lang.PsiParser;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.tree.ILazyParseableElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.kdoc.parser.KDocParser;
|
||||
import org.jetbrains.jet.kdoc.psi.impl.KDocImpl;
|
||||
import org.jetbrains.jet.plugin.JetLanguage;
|
||||
|
||||
public interface KDocTokens {
|
||||
ILazyParseableElementType KDOC = new ILazyParseableElementType("KDoc", JetLanguage.INSTANCE) {
|
||||
@Override
|
||||
public ASTNode parseContents(ASTNode chameleon) {
|
||||
PsiElement parentElement = chameleon.getTreeParent().getPsi();
|
||||
Project project = parentElement.getProject();
|
||||
PsiBuilder builder = PsiBuilderFactory.getInstance().createBuilder(project, chameleon, new KDocLexer(), getLanguage(),
|
||||
chameleon.getText());
|
||||
PsiParser parser = new KDocParser();
|
||||
|
||||
return parser.parse(this, builder).getFirstChildNode();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ASTNode createNode(CharSequence text) {
|
||||
return new KDocImpl(text);
|
||||
}
|
||||
};
|
||||
|
||||
KDocToken START = new KDocToken("KDOC_START");
|
||||
KDocToken END = new KDocToken("KDOC_END");
|
||||
KDocToken LEADING_ASTERISK = new KDocToken("KDOC_LEADING_ASTERISK");
|
||||
|
||||
KDocToken TEXT = new KDocToken("KDOC_TEXT");
|
||||
KDocToken TAG_NAME = new KDocToken("KDOC_TAG_NAME");
|
||||
KDocToken WIKI_LINK_OPEN = new KDocToken("KDOC_WIKI_LINK_OPEN");
|
||||
KDocToken WIKI_LINK_CLOSE = new KDocToken("KDOC_WIKI_LINK_CLOSE");
|
||||
|
||||
KDocToken MARKDOWN_ESCAPED_CHAR = new KDocToken("KDOC_MARKDOWN_ESCAPED_CHAR");
|
||||
|
||||
TokenSet CONTENT_TOKENS = TokenSet.create(START, END, LEADING_ASTERISK, TEXT, WIKI_LINK_OPEN, WIKI_LINK_CLOSE, MARKDOWN_ESCAPED_CHAR);
|
||||
}
|
||||
@@ -0,0 +1,623 @@
|
||||
/* The following code was generated by JFlex 1.4.3 on 25.05.13 16:39 */
|
||||
|
||||
package org.jetbrains.jet.kdoc.lexer;
|
||||
|
||||
import com.intellij.lexer.FlexLexer;
|
||||
import com.intellij.psi.TokenType;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.util.text.CharArrayUtil;
|
||||
|
||||
|
||||
/**
|
||||
* This class is a scanner generated by
|
||||
* <a href="http://www.jflex.de/">JFlex</a> 1.4.3
|
||||
* on 25.05.13 16:39 from the specification file
|
||||
* <tt>/Users/factitious/Documents/kotlin/compiler/frontend/src/org/jetbrains/jet/kdoc/lexer/KDoc.flex</tt>
|
||||
*/
|
||||
class _KDocLexer implements FlexLexer {
|
||||
/** initial size of the lookahead buffer */
|
||||
private static final int ZZ_BUFFERSIZE = 16384;
|
||||
|
||||
/** lexical states */
|
||||
public static final int CODE = 8;
|
||||
public static final int CONTENTS_BEGINNING = 4;
|
||||
public static final int CODE2 = 10;
|
||||
public static final int LINE_BEGINNING = 2;
|
||||
public static final int CONTENTS = 6;
|
||||
public static final int YYINITIAL = 0;
|
||||
|
||||
/**
|
||||
* ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l
|
||||
* ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l
|
||||
* at the beginning of a line
|
||||
* l is of the form l = 2*k, k a non negative integer
|
||||
*/
|
||||
private static final int ZZ_LEXSTATE[] = {
|
||||
0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 4, 4
|
||||
};
|
||||
|
||||
/**
|
||||
* Translates characters to character classes
|
||||
*/
|
||||
private static final String ZZ_CMAP_PACKED =
|
||||
"\11\0\1\1\1\12\1\0\2\1\22\0\1\1\3\0\1\3\5\0"+
|
||||
"\1\4\4\0\1\5\12\2\6\0\1\6\32\3\1\11\1\7\1\10"+
|
||||
"\1\0\1\3\1\0\32\3\47\0\4\3\4\0\1\3\12\0\1\3"+
|
||||
"\4\0\1\3\5\0\27\3\1\0\37\3\1\0\u013f\3\31\0\162\3"+
|
||||
"\4\0\14\3\16\0\5\3\11\0\1\3\213\0\1\3\13\0\1\3"+
|
||||
"\1\0\3\3\1\0\1\3\1\0\24\3\1\0\54\3\1\0\46\3"+
|
||||
"\1\0\5\3\4\0\202\3\10\0\105\3\1\0\46\3\2\0\2\3"+
|
||||
"\6\0\20\3\41\0\46\3\2\0\1\3\7\0\47\3\110\0\33\3"+
|
||||
"\5\0\3\3\56\0\32\3\5\0\13\3\43\0\2\3\1\0\143\3"+
|
||||
"\1\0\1\3\17\0\2\3\7\0\2\3\12\0\3\3\2\0\1\3"+
|
||||
"\20\0\1\3\1\0\36\3\35\0\3\3\60\0\46\3\13\0\1\3"+
|
||||
"\u0152\0\66\3\3\0\1\3\22\0\1\3\7\0\12\3\43\0\10\3"+
|
||||
"\2\0\2\3\2\0\26\3\1\0\7\3\1\0\1\3\3\0\4\3"+
|
||||
"\3\0\1\3\36\0\2\3\1\0\3\3\16\0\4\3\21\0\6\3"+
|
||||
"\4\0\2\3\2\0\26\3\1\0\7\3\1\0\2\3\1\0\2\3"+
|
||||
"\1\0\2\3\37\0\4\3\1\0\1\3\23\0\3\3\20\0\11\3"+
|
||||
"\1\0\3\3\1\0\26\3\1\0\7\3\1\0\2\3\1\0\5\3"+
|
||||
"\3\0\1\3\22\0\1\3\17\0\2\3\17\0\1\3\23\0\10\3"+
|
||||
"\2\0\2\3\2\0\26\3\1\0\7\3\1\0\2\3\1\0\5\3"+
|
||||
"\3\0\1\3\36\0\2\3\1\0\3\3\17\0\1\3\21\0\1\3"+
|
||||
"\1\0\6\3\3\0\3\3\1\0\4\3\3\0\2\3\1\0\1\3"+
|
||||
"\1\0\2\3\3\0\2\3\3\0\3\3\3\0\10\3\1\0\3\3"+
|
||||
"\77\0\1\3\13\0\10\3\1\0\3\3\1\0\27\3\1\0\12\3"+
|
||||
"\1\0\5\3\46\0\2\3\43\0\10\3\1\0\3\3\1\0\27\3"+
|
||||
"\1\0\12\3\1\0\5\3\3\0\1\3\40\0\1\3\1\0\2\3"+
|
||||
"\43\0\10\3\1\0\3\3\1\0\27\3\1\0\20\3\46\0\2\3"+
|
||||
"\43\0\22\3\3\0\30\3\1\0\11\3\1\0\1\3\2\0\7\3"+
|
||||
"\72\0\60\3\1\0\2\3\13\0\10\3\72\0\2\3\1\0\1\3"+
|
||||
"\2\0\2\3\1\0\1\3\2\0\1\3\6\0\4\3\1\0\7\3"+
|
||||
"\1\0\3\3\1\0\1\3\1\0\1\3\2\0\2\3\1\0\4\3"+
|
||||
"\1\0\2\3\11\0\1\3\2\0\5\3\1\0\1\3\25\0\2\3"+
|
||||
"\42\0\1\3\77\0\10\3\1\0\42\3\35\0\4\3\164\0\42\3"+
|
||||
"\1\0\5\3\1\0\2\3\45\0\6\3\112\0\46\3\12\0\51\3"+
|
||||
"\7\0\132\3\5\0\104\3\5\0\122\3\6\0\7\3\1\0\77\3"+
|
||||
"\1\0\1\3\1\0\4\3\2\0\7\3\1\0\1\3\1\0\4\3"+
|
||||
"\2\0\47\3\1\0\1\3\1\0\4\3\2\0\37\3\1\0\1\3"+
|
||||
"\1\0\4\3\2\0\7\3\1\0\1\3\1\0\4\3\2\0\7\3"+
|
||||
"\1\0\7\3\1\0\27\3\1\0\37\3\1\0\1\3\1\0\4\3"+
|
||||
"\2\0\7\3\1\0\47\3\1\0\23\3\105\0\125\3\14\0\u026c\3"+
|
||||
"\2\0\10\3\12\0\32\3\5\0\113\3\3\0\3\3\17\0\15\3"+
|
||||
"\1\0\4\3\16\0\22\3\16\0\22\3\16\0\15\3\1\0\3\3"+
|
||||
"\17\0\64\3\43\0\1\3\3\0\2\3\103\0\130\3\10\0\51\3"+
|
||||
"\127\0\35\3\63\0\36\3\2\0\5\3\u038b\0\154\3\224\0\234\3"+
|
||||
"\4\0\132\3\6\0\26\3\2\0\6\3\2\0\46\3\2\0\6\3"+
|
||||
"\2\0\10\3\1\0\1\3\1\0\1\3\1\0\1\3\1\0\37\3"+
|
||||
"\2\0\65\3\1\0\7\3\1\0\1\3\3\0\3\3\1\0\7\3"+
|
||||
"\3\0\4\3\2\0\6\3\4\0\15\3\5\0\3\3\1\0\7\3"+
|
||||
"\102\0\2\3\23\0\1\3\34\0\1\3\15\0\1\3\40\0\22\3"+
|
||||
"\120\0\1\3\4\0\1\3\2\0\12\3\1\0\1\3\3\0\5\3"+
|
||||
"\6\0\1\3\1\0\1\3\1\0\1\3\1\0\4\3\1\0\3\3"+
|
||||
"\1\0\7\3\3\0\3\3\5\0\5\3\26\0\44\3\u0e81\0\3\3"+
|
||||
"\31\0\11\3\7\0\5\3\2\0\5\3\4\0\126\3\6\0\3\3"+
|
||||
"\1\0\137\3\5\0\50\3\4\0\136\3\21\0\30\3\70\0\20\3"+
|
||||
"\u0200\0\u19b6\3\112\0\u51a6\3\132\0\u048d\3\u0773\0\u2ba4\3\u215c\0\u012e\3"+
|
||||
"\2\0\73\3\225\0\7\3\14\0\5\3\5\0\1\3\1\0\12\3"+
|
||||
"\1\0\15\3\1\0\5\3\1\0\1\3\1\0\2\3\1\0\2\3"+
|
||||
"\1\0\154\3\41\0\u016b\3\22\0\100\3\2\0\66\3\50\0\15\3"+
|
||||
"\66\0\2\3\30\0\3\3\31\0\1\3\6\0\5\3\1\0\207\3"+
|
||||
"\7\0\1\3\34\0\32\3\4\0\1\3\1\0\32\3\12\0\132\3"+
|
||||
"\3\0\6\3\2\0\6\3\2\0\6\3\2\0\3\3\3\0\2\3"+
|
||||
"\3\0\2\3\31\0";
|
||||
|
||||
/**
|
||||
* Translates characters to character classes
|
||||
*/
|
||||
private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED);
|
||||
|
||||
/**
|
||||
* Translates DFA states to action switch labels.
|
||||
*/
|
||||
private static final int [] ZZ_ACTION = zzUnpackAction();
|
||||
|
||||
private static final String ZZ_ACTION_PACKED_0 =
|
||||
"\5\0\3\1\1\2\1\3\1\4\5\2\1\0\1\5"+
|
||||
"\1\0\1\6\1\7\1\10\1\11\1\12";
|
||||
|
||||
private static int [] zzUnpackAction() {
|
||||
int [] result = new int[24];
|
||||
int offset = 0;
|
||||
offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static int zzUnpackAction(String packed, int offset, int [] result) {
|
||||
int i = 0; /* index in packed string */
|
||||
int j = offset; /* index in unpacked array */
|
||||
int l = packed.length();
|
||||
while (i < l) {
|
||||
int count = packed.charAt(i++);
|
||||
int value = packed.charAt(i++);
|
||||
do result[j++] = value; while (--count > 0);
|
||||
}
|
||||
return j;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Translates a state to a row index in the transition table
|
||||
*/
|
||||
private static final int [] ZZ_ROWMAP = zzUnpackRowMap();
|
||||
|
||||
private static final String ZZ_ROWMAP_PACKED_0 =
|
||||
"\0\0\0\13\0\26\0\41\0\54\0\67\0\102\0\115"+
|
||||
"\0\67\0\130\0\143\0\156\0\171\0\204\0\102\0\217"+
|
||||
"\0\102\0\67\0\232\0\67\0\67\0\67\0\245\0\67";
|
||||
|
||||
private static int [] zzUnpackRowMap() {
|
||||
int [] result = new int[24];
|
||||
int offset = 0;
|
||||
offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static int zzUnpackRowMap(String packed, int offset, int [] result) {
|
||||
int i = 0; /* index in packed string */
|
||||
int j = offset; /* index in unpacked array */
|
||||
int l = packed.length();
|
||||
while (i < l) {
|
||||
int high = packed.charAt(i++) << 16;
|
||||
result[j++] = high | packed.charAt(i++);
|
||||
}
|
||||
return j;
|
||||
}
|
||||
|
||||
/**
|
||||
* The transition table of the DFA
|
||||
*/
|
||||
private static final int [] ZZ_TRANS = zzUnpackTrans();
|
||||
|
||||
private static final String ZZ_TRANS_PACKED_0 =
|
||||
"\4\6\1\7\1\10\4\6\1\0\1\11\1\12\2\11"+
|
||||
"\1\13\2\11\1\14\1\15\1\16\1\12\1\11\1\12"+
|
||||
"\2\11\1\17\1\11\1\20\1\14\1\15\1\16\1\12"+
|
||||
"\1\11\1\12\2\11\1\17\2\11\1\14\1\15\1\16"+
|
||||
"\1\12\4\6\1\7\5\6\20\0\1\21\1\22\11\0"+
|
||||
"\1\23\7\0\1\12\10\0\1\12\4\0\1\13\1\22"+
|
||||
"\15\0\2\24\11\0\1\25\13\0\1\26\4\0\1\27"+
|
||||
"\13\0\1\30\10\0\2\27\7\0";
|
||||
|
||||
private static int [] zzUnpackTrans() {
|
||||
int [] result = new int[176];
|
||||
int offset = 0;
|
||||
offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static int zzUnpackTrans(String packed, int offset, int [] result) {
|
||||
int i = 0; /* index in packed string */
|
||||
int j = offset; /* index in unpacked array */
|
||||
int l = packed.length();
|
||||
while (i < l) {
|
||||
int count = packed.charAt(i++);
|
||||
int value = packed.charAt(i++);
|
||||
value--;
|
||||
do result[j++] = value; while (--count > 0);
|
||||
}
|
||||
return j;
|
||||
}
|
||||
|
||||
|
||||
/* error codes */
|
||||
private static final int ZZ_UNKNOWN_ERROR = 0;
|
||||
private static final int ZZ_NO_MATCH = 1;
|
||||
private static final int ZZ_PUSHBACK_2BIG = 2;
|
||||
private static final char[] EMPTY_BUFFER = new char[0];
|
||||
private static final int YYEOF = -1;
|
||||
private static java.io.Reader zzReader = null; // Fake
|
||||
|
||||
/* error messages for the codes above */
|
||||
private static final String ZZ_ERROR_MSG[] = {
|
||||
"Unkown internal scanner error",
|
||||
"Error: could not match input",
|
||||
"Error: pushback value was too large"
|
||||
};
|
||||
|
||||
/**
|
||||
* ZZ_ATTRIBUTE[aState] contains the attributes of state <code>aState</code>
|
||||
*/
|
||||
private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute();
|
||||
|
||||
private static final String ZZ_ATTRIBUTE_PACKED_0 =
|
||||
"\5\0\1\11\2\1\1\11\7\1\1\0\1\11\1\0"+
|
||||
"\3\11\1\1\1\11";
|
||||
|
||||
private static int [] zzUnpackAttribute() {
|
||||
int [] result = new int[24];
|
||||
int offset = 0;
|
||||
offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static int zzUnpackAttribute(String packed, int offset, int [] result) {
|
||||
int i = 0; /* index in packed string */
|
||||
int j = offset; /* index in unpacked array */
|
||||
int l = packed.length();
|
||||
while (i < l) {
|
||||
int count = packed.charAt(i++);
|
||||
int value = packed.charAt(i++);
|
||||
do result[j++] = value; while (--count > 0);
|
||||
}
|
||||
return j;
|
||||
}
|
||||
|
||||
/** the current state of the DFA */
|
||||
private int zzState;
|
||||
|
||||
/** the current lexical state */
|
||||
private int zzLexicalState = YYINITIAL;
|
||||
|
||||
/** this buffer contains the current text to be matched and is
|
||||
the source of the yytext() string */
|
||||
private CharSequence zzBuffer = "";
|
||||
|
||||
/** this buffer may contains the current text array to be matched when it is cheap to acquire it */
|
||||
private char[] zzBufferArray;
|
||||
|
||||
/** the textposition at the last accepting state */
|
||||
private int zzMarkedPos;
|
||||
|
||||
/** the textposition at the last state to be included in yytext */
|
||||
private int zzPushbackPos;
|
||||
|
||||
/** the current text position in the buffer */
|
||||
private int zzCurrentPos;
|
||||
|
||||
/** startRead marks the beginning of the yytext() string in the buffer */
|
||||
private int zzStartRead;
|
||||
|
||||
/** endRead marks the last character in the buffer, that has been read
|
||||
from input */
|
||||
private int zzEndRead;
|
||||
|
||||
/**
|
||||
* zzAtBOL == true <=> the scanner is currently at the beginning of a line
|
||||
*/
|
||||
private boolean zzAtBOL = true;
|
||||
|
||||
/** zzAtEOF == true <=> the scanner is at the EOF */
|
||||
private boolean zzAtEOF;
|
||||
|
||||
/** denotes if the user-EOF-code has already been executed */
|
||||
private boolean zzEOFDone;
|
||||
|
||||
/* user code: */
|
||||
public _KDocLexer() {
|
||||
this((java.io.Reader)null);
|
||||
}
|
||||
|
||||
private boolean isLastToken() {
|
||||
return zzMarkedPos == zzBuffer.length();
|
||||
}
|
||||
|
||||
private Boolean yytextContainLineBreaks() {
|
||||
return CharArrayUtil.containLineBreaks(zzBuffer, zzStartRead, zzMarkedPos);
|
||||
}
|
||||
|
||||
private boolean nextIsNotWhitespace() {
|
||||
return zzMarkedPos <= zzBuffer.length() && !Character.isWhitespace(zzBuffer.charAt(zzMarkedPos + 1));
|
||||
}
|
||||
|
||||
private boolean prevIsNotWhitespace() {
|
||||
return zzMarkedPos != 0 && !Character.isWhitespace(zzBuffer.charAt(zzMarkedPos - 1));
|
||||
}
|
||||
|
||||
|
||||
_KDocLexer(java.io.Reader in) {
|
||||
this.zzReader = in;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new scanner.
|
||||
* There is also java.io.Reader version of this constructor.
|
||||
*
|
||||
* @param in the java.io.Inputstream to read input from.
|
||||
*/
|
||||
_KDocLexer(java.io.InputStream in) {
|
||||
this(new java.io.InputStreamReader(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* Unpacks the compressed character translation table.
|
||||
*
|
||||
* @param packed the packed character translation table
|
||||
* @return the unpacked character translation table
|
||||
*/
|
||||
private static char [] zzUnpackCMap(String packed) {
|
||||
char [] map = new char[0x10000];
|
||||
int i = 0; /* index in packed string */
|
||||
int j = 0; /* index in unpacked array */
|
||||
while (i < 1206) {
|
||||
int count = packed.charAt(i++);
|
||||
char value = packed.charAt(i++);
|
||||
do map[j++] = value; while (--count > 0);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public final int getTokenStart(){
|
||||
return zzStartRead;
|
||||
}
|
||||
|
||||
public final int getTokenEnd(){
|
||||
return getTokenStart() + yylength();
|
||||
}
|
||||
|
||||
public void reset(CharSequence buffer, int start, int end,int initialState){
|
||||
zzBuffer = buffer;
|
||||
zzBufferArray = com.intellij.util.text.CharArrayUtil.fromSequenceWithoutCopying(buffer);
|
||||
zzCurrentPos = zzMarkedPos = zzStartRead = start;
|
||||
zzPushbackPos = 0;
|
||||
zzAtEOF = false;
|
||||
zzAtBOL = true;
|
||||
zzEndRead = end;
|
||||
yybegin(initialState);
|
||||
}
|
||||
|
||||
/**
|
||||
* Refills the input buffer.
|
||||
*
|
||||
* @return <code>false</code>, iff there was new input.
|
||||
*
|
||||
* @exception java.io.IOException if any I/O-Error occurs
|
||||
*/
|
||||
private boolean zzRefill() throws java.io.IOException {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the current lexical state.
|
||||
*/
|
||||
public final int yystate() {
|
||||
return zzLexicalState;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Enters a new lexical state
|
||||
*
|
||||
* @param newState the new lexical state
|
||||
*/
|
||||
public final void yybegin(int newState) {
|
||||
zzLexicalState = newState;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the text matched by the current regular expression.
|
||||
*/
|
||||
public final CharSequence yytext() {
|
||||
return zzBuffer.subSequence(zzStartRead, zzMarkedPos);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the character at position <tt>pos</tt> from the
|
||||
* matched text.
|
||||
*
|
||||
* It is equivalent to yytext().charAt(pos), but faster
|
||||
*
|
||||
* @param pos the position of the character to fetch.
|
||||
* A value from 0 to yylength()-1.
|
||||
*
|
||||
* @return the character at position pos
|
||||
*/
|
||||
public final char yycharat(int pos) {
|
||||
return zzBufferArray != null ? zzBufferArray[zzStartRead+pos]:zzBuffer.charAt(zzStartRead+pos);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the length of the matched text region.
|
||||
*/
|
||||
public final int yylength() {
|
||||
return zzMarkedPos-zzStartRead;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reports an error that occured while scanning.
|
||||
*
|
||||
* In a wellformed scanner (no or only correct usage of
|
||||
* yypushback(int) and a match-all fallback rule) this method
|
||||
* will only be called with things that "Can't Possibly Happen".
|
||||
* If this method is called, something is seriously wrong
|
||||
* (e.g. a JFlex bug producing a faulty scanner etc.).
|
||||
*
|
||||
* Usual syntax/scanner level error handling should be done
|
||||
* in error fallback rules.
|
||||
*
|
||||
* @param errorCode the code of the errormessage to display
|
||||
*/
|
||||
private void zzScanError(int errorCode) {
|
||||
String message;
|
||||
try {
|
||||
message = ZZ_ERROR_MSG[errorCode];
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException e) {
|
||||
message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
|
||||
}
|
||||
|
||||
throw new Error(message);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Pushes the specified amount of characters back into the input stream.
|
||||
*
|
||||
* They will be read again by then next call of the scanning method
|
||||
*
|
||||
* @param number the number of characters to be read again.
|
||||
* This number must not be greater than yylength()!
|
||||
*/
|
||||
public void yypushback(int number) {
|
||||
if ( number > yylength() )
|
||||
zzScanError(ZZ_PUSHBACK_2BIG);
|
||||
|
||||
zzMarkedPos -= number;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Contains user EOF-code, which will be executed exactly once,
|
||||
* when the end of file is reached
|
||||
*/
|
||||
private void zzDoEOF() {
|
||||
if (!zzEOFDone) {
|
||||
zzEOFDone = true;
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Resumes scanning until the next regular expression is matched,
|
||||
* the end of input is encountered or an I/O-Error occurs.
|
||||
*
|
||||
* @return the next token
|
||||
* @exception java.io.IOException if any I/O-Error occurs
|
||||
*/
|
||||
public IElementType advance() throws java.io.IOException {
|
||||
int zzInput;
|
||||
int zzAction;
|
||||
|
||||
// cached fields:
|
||||
int zzCurrentPosL;
|
||||
int zzMarkedPosL;
|
||||
int zzEndReadL = zzEndRead;
|
||||
CharSequence zzBufferL = zzBuffer;
|
||||
char[] zzBufferArrayL = zzBufferArray;
|
||||
char [] zzCMapL = ZZ_CMAP;
|
||||
|
||||
int [] zzTransL = ZZ_TRANS;
|
||||
int [] zzRowMapL = ZZ_ROWMAP;
|
||||
int [] zzAttrL = ZZ_ATTRIBUTE;
|
||||
|
||||
while (true) {
|
||||
zzMarkedPosL = zzMarkedPos;
|
||||
|
||||
zzAction = -1;
|
||||
|
||||
zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL;
|
||||
|
||||
zzState = ZZ_LEXSTATE[zzLexicalState];
|
||||
|
||||
|
||||
zzForAction: {
|
||||
while (true) {
|
||||
|
||||
if (zzCurrentPosL < zzEndReadL)
|
||||
zzInput = (zzBufferArrayL != null ? zzBufferArrayL[zzCurrentPosL++] : zzBufferL.charAt(zzCurrentPosL++));
|
||||
else if (zzAtEOF) {
|
||||
zzInput = YYEOF;
|
||||
break zzForAction;
|
||||
}
|
||||
else {
|
||||
// store back cached positions
|
||||
zzCurrentPos = zzCurrentPosL;
|
||||
zzMarkedPos = zzMarkedPosL;
|
||||
boolean eof = zzRefill();
|
||||
// get translated positions and possibly new buffer
|
||||
zzCurrentPosL = zzCurrentPos;
|
||||
zzMarkedPosL = zzMarkedPos;
|
||||
zzBufferL = zzBuffer;
|
||||
zzEndReadL = zzEndRead;
|
||||
if (eof) {
|
||||
zzInput = YYEOF;
|
||||
break zzForAction;
|
||||
}
|
||||
else {
|
||||
zzInput = (zzBufferArrayL != null ? zzBufferArrayL[zzCurrentPosL++] : zzBufferL.charAt(zzCurrentPosL++));
|
||||
}
|
||||
}
|
||||
int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ];
|
||||
if (zzNext == -1) break zzForAction;
|
||||
zzState = zzNext;
|
||||
|
||||
int zzAttributes = zzAttrL[zzState];
|
||||
if ( (zzAttributes & 1) == 1 ) {
|
||||
zzAction = zzState;
|
||||
zzMarkedPosL = zzCurrentPosL;
|
||||
if ( (zzAttributes & 8) == 8 ) break zzForAction;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// store back cached position
|
||||
zzMarkedPos = zzMarkedPosL;
|
||||
|
||||
switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
|
||||
case 3:
|
||||
{ if (yytextContainLineBreaks()) {
|
||||
yybegin(LINE_BEGINNING);
|
||||
return TokenType.WHITE_SPACE;
|
||||
} else {
|
||||
yybegin(yystate() == CONTENTS_BEGINNING? CONTENTS_BEGINNING:CONTENTS);
|
||||
return KDocTokens.TEXT; // internal white space
|
||||
}
|
||||
}
|
||||
case 11: break;
|
||||
case 5:
|
||||
{ if (isLastToken()) return KDocTokens.END;
|
||||
else return KDocTokens.TEXT;
|
||||
}
|
||||
case 12: break;
|
||||
case 9:
|
||||
{ yybegin(CONTENTS);
|
||||
return KDocTokens.TAG_NAME;
|
||||
}
|
||||
case 13: break;
|
||||
case 7:
|
||||
{ yybegin(CONTENTS);
|
||||
return KDocTokens.WIKI_LINK_CLOSE;
|
||||
}
|
||||
case 14: break;
|
||||
case 8:
|
||||
{ yybegin(CONTENTS);
|
||||
return KDocTokens.WIKI_LINK_OPEN;
|
||||
}
|
||||
case 15: break;
|
||||
case 10:
|
||||
{ yybegin(CONTENTS);
|
||||
return KDocTokens.START;
|
||||
}
|
||||
case 16: break;
|
||||
case 1:
|
||||
{ return TokenType.BAD_CHARACTER;
|
||||
}
|
||||
case 17: break;
|
||||
case 6:
|
||||
{ yybegin(CONTENTS);
|
||||
return KDocTokens.MARKDOWN_ESCAPED_CHAR;
|
||||
}
|
||||
case 18: break;
|
||||
case 2:
|
||||
{ yybegin(CONTENTS);
|
||||
return KDocTokens.TEXT;
|
||||
}
|
||||
case 19: break;
|
||||
case 4:
|
||||
{ yybegin(CONTENTS_BEGINNING);
|
||||
return KDocTokens.LEADING_ASTERISK;
|
||||
}
|
||||
case 20: break;
|
||||
default:
|
||||
if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
|
||||
zzAtEOF = true;
|
||||
zzDoEOF();
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
zzScanError(ZZ_NO_MATCH);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.kdoc.parser;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.PsiBuilder;
|
||||
import com.intellij.lang.PsiParser;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class KDocParser implements PsiParser {
|
||||
@Override
|
||||
@NotNull
|
||||
public ASTNode parse(IElementType root, PsiBuilder builder) {
|
||||
PsiBuilder.Marker rootMarker = builder.mark();
|
||||
|
||||
// todo: parse KDoc tags, markdown, etc...
|
||||
while (!builder.eof()) {
|
||||
builder.advanceLexer();
|
||||
}
|
||||
|
||||
rootMarker.done(root);
|
||||
return builder.getTreeBuilt();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.kdoc.psi.api;
|
||||
|
||||
import com.intellij.psi.PsiComment;
|
||||
|
||||
// Don't implement JetElement (or it will be treated as statement)
|
||||
public interface KDoc extends PsiComment {
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.kdoc.psi.api;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
|
||||
public interface KDocElement extends PsiElement {
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.kdoc.psi.impl;
|
||||
|
||||
import com.intellij.extapi.psi.ASTWrapperPsiElement;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.Language;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.plugin.JetLanguage;
|
||||
|
||||
public abstract class KDocElementImpl extends ASTWrapperPsiElement {
|
||||
@NotNull
|
||||
@Override
|
||||
public Language getLanguage() {
|
||||
return JetLanguage.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getNode().getElementType().toString();
|
||||
}
|
||||
|
||||
public KDocElementImpl(@NotNull ASTNode node) {
|
||||
super(node);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.kdoc.psi.impl;
|
||||
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.psi.impl.source.tree.LazyParseablePsiElement;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.kdoc.lexer.KDocTokens;
|
||||
import org.jetbrains.jet.kdoc.psi.api.KDoc;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
import org.jetbrains.jet.plugin.JetLanguage;
|
||||
|
||||
public class KDocImpl extends LazyParseablePsiElement implements KDoc {
|
||||
public KDocImpl(CharSequence buffer) {
|
||||
super(KDocTokens.KDOC, buffer);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Language getLanguage() {
|
||||
return JetLanguage.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getNode().getElementType().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IElementType getTokenType() {
|
||||
return JetTokens.DOC_COMMENT;
|
||||
}
|
||||
}
|
||||
@@ -277,9 +277,6 @@ public class JetFlowInformationProvider {
|
||||
}
|
||||
|
||||
boolean isInitializedNotHere = ctxt.enterInitState.isInitialized;
|
||||
if (expression.getParent() instanceof JetProperty && ((JetProperty)expression).getInitializer() != null) {
|
||||
isInitializedNotHere = false;
|
||||
}
|
||||
boolean hasBackingField = true;
|
||||
if (variableDescriptor instanceof PropertyDescriptor) {
|
||||
hasBackingField = trace.get(BindingContext.BACKING_FIELD_REQUIRED, (PropertyDescriptor) variableDescriptor);
|
||||
|
||||
@@ -45,6 +45,8 @@ public class PseudocodeVariablesData {
|
||||
private final Map<Pseudocode, Set<VariableDescriptor>> declaredVariablesForDeclaration = Maps.newHashMap();
|
||||
private final Map<Pseudocode, Set<VariableDescriptor>> usedVariablesForDeclaration = Maps.newHashMap();
|
||||
|
||||
private Map<Instruction, Edges<Map<VariableDescriptor, VariableInitState>>> variableInitializers;
|
||||
|
||||
public PseudocodeVariablesData(@NotNull Pseudocode pseudocode, @NotNull BindingContext bindingContext) {
|
||||
this.pseudocode = pseudocode;
|
||||
this.bindingContext = bindingContext;
|
||||
@@ -121,7 +123,11 @@ public class PseudocodeVariablesData {
|
||||
|
||||
@NotNull
|
||||
public Map<Instruction, Edges<Map<VariableDescriptor, VariableInitState>>> getVariableInitializers() {
|
||||
return getVariableInitializers(pseudocode);
|
||||
if (variableInitializers == null) {
|
||||
variableInitializers = getVariableInitializers(pseudocode);
|
||||
}
|
||||
|
||||
return variableInitializers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -164,7 +170,7 @@ public class PseudocodeVariablesData {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Map<VariableDescriptor, VariableInitState> prepareInitializersMapForStartInstruction(
|
||||
private static Map<VariableDescriptor, VariableInitState> prepareInitializersMapForStartInstruction(
|
||||
@NotNull Collection<VariableDescriptor> usedVariables,
|
||||
@NotNull Collection<VariableDescriptor> declaredVariables) {
|
||||
|
||||
@@ -184,7 +190,7 @@ public class PseudocodeVariablesData {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Map<VariableDescriptor, VariableInitState> mergeIncomingEdgesDataForInitializers(
|
||||
private static Map<VariableDescriptor, VariableInitState> mergeIncomingEdgesDataForInitializers(
|
||||
@NotNull Collection<Map<VariableDescriptor, VariableInitState>> incomingEdgesData) {
|
||||
|
||||
Set<VariableDescriptor> variablesInScope = Sets.newHashSet();
|
||||
@@ -194,14 +200,20 @@ public class PseudocodeVariablesData {
|
||||
|
||||
Map<VariableDescriptor, VariableInitState> enterInstructionData = Maps.newHashMap();
|
||||
for (VariableDescriptor variable : variablesInScope) {
|
||||
Set<VariableInitState> edgesDataForVariable = Sets.newHashSet();
|
||||
boolean isInitialized = true;
|
||||
boolean isDeclared = true;
|
||||
for (Map<VariableDescriptor, VariableInitState> edgeData : incomingEdgesData) {
|
||||
VariableInitState initState = edgeData.get(variable);
|
||||
if (initState != null) {
|
||||
edgesDataForVariable.add(initState);
|
||||
if (!initState.isInitialized) {
|
||||
isInitialized = false;
|
||||
}
|
||||
if (!initState.isDeclared) {
|
||||
isDeclared = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
enterInstructionData.put(variable, VariableInitState.create(edgesDataForVariable));
|
||||
enterInstructionData.put(variable, VariableInitState.create(isInitialized, isDeclared));
|
||||
}
|
||||
return enterInstructionData;
|
||||
}
|
||||
@@ -323,20 +335,6 @@ public class PseudocodeVariablesData {
|
||||
private static VariableInitState create(boolean isDeclaredHere, @Nullable VariableInitState mergedEdgesData) {
|
||||
return create(true, isDeclaredHere || (mergedEdgesData != null && mergedEdgesData.isDeclared));
|
||||
}
|
||||
|
||||
private static VariableInitState create(@NotNull Set<VariableInitState> edgesData) {
|
||||
boolean isInitialized = true;
|
||||
boolean isDeclared = true;
|
||||
for (VariableInitState edgeData : edgesData) {
|
||||
if (!edgeData.isInitialized) {
|
||||
isInitialized = false;
|
||||
}
|
||||
if (!edgeData.isDeclared) {
|
||||
isDeclared = false;
|
||||
}
|
||||
}
|
||||
return create(isInitialized, isDeclared);
|
||||
}
|
||||
}
|
||||
|
||||
public static enum VariableUseState {
|
||||
|
||||
+2
-1
@@ -19,6 +19,7 @@ package org.jetbrains.jet.lang.descriptors;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.Annotated;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
import java.util.Set;
|
||||
@@ -57,7 +58,7 @@ public interface ValueParameterDescriptor extends VariableDescriptor, Annotated
|
||||
ValueParameterDescriptor getOriginal();
|
||||
|
||||
@NotNull
|
||||
ValueParameterDescriptor copy(DeclarationDescriptor newOwner);
|
||||
ValueParameterDescriptor copy(DeclarationDescriptor newOwner, Name newName);
|
||||
|
||||
/**
|
||||
* Parameter p1 overrides p2 iff
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ public class ClassDescriptorImpl extends DeclarationDescriptorNonRootImpl implem
|
||||
@Nullable ConstructorDescriptor primaryConstructor,
|
||||
boolean isInner
|
||||
) {
|
||||
this.typeConstructor = new TypeConstructorImpl(this, getAnnotations(), sealed, getName().getName(), typeParameters, supertypes);
|
||||
this.typeConstructor = new TypeConstructorImpl(this, getAnnotations(), sealed, getName().asString(), typeParameters, supertypes);
|
||||
this.memberDeclarations = memberDeclarations;
|
||||
this.constructors = constructors;
|
||||
this.primaryConstructor = primaryConstructor;
|
||||
|
||||
+1
-2
@@ -71,8 +71,7 @@ public class FunctionDescriptorUtil {
|
||||
public static List<ValueParameterDescriptor> getSubstitutedValueParameters(FunctionDescriptor substitutedDescriptor, @NotNull FunctionDescriptor functionDescriptor, @NotNull TypeSubstitutor substitutor) {
|
||||
List<ValueParameterDescriptor> result = new ArrayList<ValueParameterDescriptor>();
|
||||
List<ValueParameterDescriptor> unsubstitutedValueParameters = functionDescriptor.getValueParameters();
|
||||
for (int i = 0, unsubstitutedValueParametersSize = unsubstitutedValueParameters.size(); i < unsubstitutedValueParametersSize; i++) {
|
||||
ValueParameterDescriptor unsubstitutedValueParameter = unsubstitutedValueParameters.get(i);
|
||||
for (ValueParameterDescriptor unsubstitutedValueParameter : unsubstitutedValueParameters) {
|
||||
// TODO : Lazy?
|
||||
JetType substitutedType = substitutor.substitute(unsubstitutedValueParameter.getType(), Variance.IN_VARIANCE);
|
||||
JetType varargElementType = unsubstitutedValueParameter.getVarargElementType();
|
||||
|
||||
+2
-15
@@ -26,7 +26,6 @@ import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.*;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -224,7 +223,7 @@ public class MutableClassDescriptor extends MutableClassDescriptorLite {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassObjectStatus setClassObjectDescriptor(@NotNull final MutableClassDescriptorLite classObjectDescriptor) {
|
||||
public ClassObjectStatus setClassObjectDescriptor(@NotNull MutableClassDescriptorLite classObjectDescriptor) {
|
||||
ClassObjectStatus r = superBuilder.setClassObjectDescriptor(classObjectDescriptor);
|
||||
if (r != ClassObjectStatus.OK) {
|
||||
return r;
|
||||
@@ -232,19 +231,7 @@ public class MutableClassDescriptor extends MutableClassDescriptorLite {
|
||||
|
||||
// Members of the class object are accessible from the class
|
||||
// The scope must be lazy, because classObjectDescriptor may not by fully built yet
|
||||
scopeForMemberResolution.importScope(new AbstractScopeAdapter() {
|
||||
@NotNull
|
||||
@Override
|
||||
protected JetScope getWorkerScope() {
|
||||
return classObjectDescriptor.getDefaultType().getMemberScope();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<ReceiverParameterDescriptor> getImplicitReceiversHierarchy() {
|
||||
return Collections.singletonList(classObjectDescriptor.getThisAsReceiverParameter());
|
||||
}
|
||||
});
|
||||
scopeForMemberResolution.importScope(new ClassObjectMixinScope(classObjectDescriptor));
|
||||
|
||||
return ClassObjectStatus.OK;
|
||||
}
|
||||
|
||||
+1
-1
@@ -109,7 +109,7 @@ public abstract class MutableClassDescriptorLite extends ClassDescriptorBase {
|
||||
this,
|
||||
Collections.<AnnotationDescriptor>emptyList(), // TODO : pass annotations from the class?
|
||||
!getModality().isOverridable(),
|
||||
getName().getName(),
|
||||
getName().asString(),
|
||||
typeParameters,
|
||||
supertypes);
|
||||
}
|
||||
|
||||
+1
-1
@@ -91,7 +91,7 @@ public class TypeParameterDescriptorImpl extends DeclarationDescriptorNonRootImp
|
||||
this,
|
||||
annotations,
|
||||
false,
|
||||
name.getName(),
|
||||
name.asString(),
|
||||
Collections.<TypeParameterDescriptor>emptyList(),
|
||||
upperBounds);
|
||||
}
|
||||
|
||||
+3
-2
@@ -111,6 +111,7 @@ public class ValueParameterDescriptorImpl extends VariableDescriptorImpl impleme
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public JetType getVarargElementType() {
|
||||
return varargElementType;
|
||||
}
|
||||
@@ -139,8 +140,8 @@ public class ValueParameterDescriptorImpl extends VariableDescriptorImpl impleme
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ValueParameterDescriptor copy(@NotNull DeclarationDescriptor newOwner) {
|
||||
return new ValueParameterDescriptorImpl(newOwner, index, Lists.newArrayList(getAnnotations()), getName(), getType(), hasDefaultValue, varargElementType);
|
||||
public ValueParameterDescriptor copy(@NotNull DeclarationDescriptor newOwner, @NotNull Name newName) {
|
||||
return new ValueParameterDescriptorImpl(newOwner, index, Lists.newArrayList(getAnnotations()), newName, getType(), declaresDefaultValue(), varargElementType);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -64,7 +64,7 @@ public class Renderers {
|
||||
@Override
|
||||
public String render(@NotNull Object element) {
|
||||
if (element instanceof Named) {
|
||||
return ((Named) element).getName().getName();
|
||||
return ((Named) element).getName().asString();
|
||||
}
|
||||
return element.toString();
|
||||
}
|
||||
@@ -184,7 +184,7 @@ public class Renderers {
|
||||
result.text(newText()
|
||||
.normal("Cannot infer type parameter ")
|
||||
.strong(firstConflictingParameter.getName())
|
||||
.normal(" in"));
|
||||
.normal(" in "));
|
||||
//String type = strong(firstConflictingParameter.getName());
|
||||
TableRenderer table = newTable();
|
||||
result.table(table);
|
||||
@@ -299,7 +299,7 @@ public class Renderers {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int index = 0;
|
||||
for (ClassDescriptor descriptor : descriptors) {
|
||||
sb.append(DescriptorUtils.getFQName(descriptor).getFqName());
|
||||
sb.append(DescriptorUtils.getFQName(descriptor).asString());
|
||||
index++;
|
||||
if (index <= descriptors.size() - 2) {
|
||||
sb.append(", ");
|
||||
|
||||
@@ -53,7 +53,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
TRUE_KEYWORD, FALSE_KEYWORD, IS_KEYWORD, THROW_KEYWORD, RETURN_KEYWORD, BREAK_KEYWORD,
|
||||
CONTINUE_KEYWORD, OBJECT_KEYWORD, IF_KEYWORD, TRY_KEYWORD, ELSE_KEYWORD, WHILE_KEYWORD, DO_KEYWORD,
|
||||
WHEN_KEYWORD, RBRACKET, RBRACE, RPAR, PLUSPLUS, MINUSMINUS, EXCLEXCL,
|
||||
// MUL,
|
||||
// MUL,
|
||||
PLUS, MINUS, EXCL, DIV, PERC, LTEQ,
|
||||
// TODO GTEQ, foo<bar, baz>=x
|
||||
EQEQEQ, EXCLEQEQEQ, EQEQ, EXCLEQ, ANDAND, OROR, SAFE_ACCESS, ELVIS,
|
||||
@@ -111,17 +111,17 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
);
|
||||
|
||||
private static final TokenSet STATEMENT_FIRST = TokenSet.orSet(
|
||||
EXPRESSION_FIRST,
|
||||
TokenSet.create(
|
||||
// declaration
|
||||
LBRACKET, // attribute
|
||||
FUN_KEYWORD,
|
||||
VAL_KEYWORD, VAR_KEYWORD,
|
||||
TRAIT_KEYWORD,
|
||||
CLASS_KEYWORD,
|
||||
TYPE_KEYWORD
|
||||
),
|
||||
MODIFIER_KEYWORDS
|
||||
EXPRESSION_FIRST,
|
||||
TokenSet.create(
|
||||
// declaration
|
||||
LBRACKET, // attribute
|
||||
FUN_KEYWORD,
|
||||
VAL_KEYWORD, VAR_KEYWORD,
|
||||
TRAIT_KEYWORD,
|
||||
CLASS_KEYWORD,
|
||||
TYPE_KEYWORD
|
||||
),
|
||||
MODIFIER_KEYWORDS
|
||||
);
|
||||
|
||||
/*package*/ static final TokenSet EXPRESSION_FOLLOW = TokenSet.create(
|
||||
@@ -174,7 +174,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
EQUALITY(EQEQ, EXCLEQ, EQEQEQ, EXCLEQEQEQ),
|
||||
CONJUNCTION(ANDAND),
|
||||
DISJUNCTION(OROR),
|
||||
// ARROW(JetTokens.ARROW),
|
||||
// ARROW(JetTokens.ARROW),
|
||||
ASSIGNMENT(EQ, PLUSEQ, MINUSEQ, MULTEQ, DIVEQ, PERCEQ),
|
||||
;
|
||||
|
||||
@@ -287,7 +287,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
* see the precedence table
|
||||
*/
|
||||
private void parseBinaryExpression(Precedence precedence) {
|
||||
// System.out.println(precedence.name() + " at " + myBuilder.getTokenText());
|
||||
// System.out.println(precedence.name() + " at " + myBuilder.getTokenText());
|
||||
|
||||
PsiBuilder.Marker expression = mark();
|
||||
|
||||
@@ -300,7 +300,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
|
||||
JetNodeType resultType = precedence.parseRightHandSide(operation, this);
|
||||
expression.done(resultType);
|
||||
expression = expression.precede();
|
||||
expression = expression.precede();
|
||||
}
|
||||
|
||||
expression.drop();
|
||||
@@ -310,7 +310,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
* operation? prefixExpression
|
||||
*/
|
||||
private void parsePrefixExpression() {
|
||||
// System.out.println("pre at " + myBuilder.getTokenText());
|
||||
// System.out.println("pre at " + myBuilder.getTokenText());
|
||||
|
||||
if (at(LBRACKET)) {
|
||||
if (!parseLocalDeclaration()) {
|
||||
@@ -485,10 +485,10 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
*/
|
||||
protected boolean parseCallWithClosure() {
|
||||
boolean success = false;
|
||||
// while (!myBuilder.newlineBeforeCurrentToken()
|
||||
// && (at(LBRACE)
|
||||
// while (!myBuilder.newlineBeforeCurrentToken()
|
||||
// && (at(LBRACE)
|
||||
while ((at(LBRACE)
|
||||
|| atSet(LABELS) && lookahead(1) == LBRACE)) {
|
||||
|| atSet(LABELS) && lookahead(1) == LBRACE)) {
|
||||
if (!at(LBRACE)) {
|
||||
assert _atSet(LABELS);
|
||||
parsePrefixExpression();
|
||||
@@ -520,7 +520,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
* ;
|
||||
*/
|
||||
private void parseAtomicExpression() {
|
||||
// System.out.println("atom at " + myBuilder.getTokenText());
|
||||
// System.out.println("atom at " + myBuilder.getTokenText());
|
||||
|
||||
if (at(LPAR)) {
|
||||
parseParenthesizedExpression();
|
||||
@@ -574,7 +574,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
parseDoWhile();
|
||||
}
|
||||
else if (atSet(CLASS_KEYWORD, FUN_KEYWORD, VAL_KEYWORD,
|
||||
VAR_KEYWORD, TYPE_KEYWORD)) {
|
||||
VAR_KEYWORD, TYPE_KEYWORD)) {
|
||||
parseLocalDeclaration();
|
||||
}
|
||||
else if (at(FIELD_IDENTIFIER)) {
|
||||
@@ -784,7 +784,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
|
||||
if (!at(ARROW)) {
|
||||
errorUntil("Expecting '->'", TokenSet.create(ARROW,
|
||||
RBRACE, EOL_OR_SEMICOLON));
|
||||
RBRACE, EOL_OR_SEMICOLON));
|
||||
}
|
||||
|
||||
if (at(ARROW)) {
|
||||
@@ -798,7 +798,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
}
|
||||
}
|
||||
else if (!atSet(WHEN_CONDITION_RECOVERY_SET)) {
|
||||
errorAndAdvance("Expecting '->'");
|
||||
errorAndAdvance("Expecting '->'");
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -982,8 +982,8 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
parseFunctionLiteralParametersAndType();
|
||||
|
||||
paramsFound = preferParamsToExpressions ?
|
||||
rollbackOrDrop(rollbackMarker, ARROW, "An -> is expected", RBRACE) :
|
||||
rollbackOrDropAt(rollbackMarker, ARROW);
|
||||
rollbackOrDrop(rollbackMarker, ARROW, "An -> is expected", RBRACE) :
|
||||
rollbackOrDropAt(rollbackMarker, ARROW);
|
||||
}
|
||||
|
||||
if (!paramsFound) {
|
||||
@@ -1047,8 +1047,8 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
}
|
||||
|
||||
private boolean rollbackOrDrop(PsiBuilder.Marker rollbackMarker,
|
||||
JetToken expected, String expectMessage,
|
||||
IElementType validForDrop) {
|
||||
JetToken expected, String expectMessage,
|
||||
IElementType validForDrop) {
|
||||
if (at(expected)) {
|
||||
advance(); // dropAt
|
||||
rollbackMarker.drop();
|
||||
@@ -1074,8 +1074,8 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
while (!eof()) {
|
||||
PsiBuilder.Marker parameter = mark();
|
||||
|
||||
// int parameterNamePos = matchTokenStreamPredicate(new LastBefore(new At(IDENTIFIER), new AtOffset(doubleArrowPos)));
|
||||
// createTruncatedBuilder(parameterNamePos).parseModifierList(MODIFIER_LIST, false);
|
||||
// int parameterNamePos = matchTokenStreamPredicate(new LastBefore(new At(IDENTIFIER), new AtOffset(doubleArrowPos)));
|
||||
// createTruncatedBuilder(parameterNamePos).parseModifierList(MODIFIER_LIST, false);
|
||||
|
||||
expect(IDENTIFIER, "Expecting parameter name", TokenSet.create(ARROW));
|
||||
|
||||
@@ -1135,8 +1135,8 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
}
|
||||
|
||||
return preferParamsToExpressions ?
|
||||
rollbackOrDrop(rollbackMarker, ARROW, "An -> is expected", RBRACE) :
|
||||
rollbackOrDropAt(rollbackMarker, ARROW);
|
||||
rollbackOrDrop(rollbackMarker, ARROW, "An -> is expected", RBRACE) :
|
||||
rollbackOrDropAt(rollbackMarker, ARROW);
|
||||
}
|
||||
|
||||
private void parseFunctionLiteralParametersAndType() {
|
||||
@@ -1252,38 +1252,38 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
* ;
|
||||
*/
|
||||
private IElementType parseLocalDeclarationRest(boolean isEnum) {
|
||||
IElementType keywordToken = tt();
|
||||
IElementType declType = null;
|
||||
if (keywordToken == CLASS_KEYWORD || keywordToken == TRAIT_KEYWORD) {
|
||||
declType = myJetParsing.parseClass(isEnum);
|
||||
}
|
||||
else if (keywordToken == FUN_KEYWORD) {
|
||||
declType = myJetParsing.parseFunction();
|
||||
}
|
||||
else if (keywordToken == VAL_KEYWORD || keywordToken == VAR_KEYWORD) {
|
||||
declType = myJetParsing.parseProperty(true);
|
||||
}
|
||||
else if (keywordToken == TYPE_KEYWORD) {
|
||||
declType = myJetParsing.parseTypeDef();
|
||||
}
|
||||
else if (keywordToken == OBJECT_KEYWORD) {
|
||||
// Object expression may appear at the statement position: should parse it
|
||||
// as expression instead of object declaration
|
||||
// sample:
|
||||
// {
|
||||
// object : Thread() {
|
||||
// }
|
||||
// }
|
||||
IElementType lookahead = lookahead(1);
|
||||
if (lookahead == COLON || lookahead == LBRACE) {
|
||||
return null;
|
||||
}
|
||||
|
||||
myJetParsing.parseObject(true, true);
|
||||
declType = OBJECT_DECLARATION;
|
||||
}
|
||||
return declType;
|
||||
}
|
||||
IElementType keywordToken = tt();
|
||||
IElementType declType = null;
|
||||
if (keywordToken == CLASS_KEYWORD || keywordToken == TRAIT_KEYWORD) {
|
||||
declType = myJetParsing.parseClass(isEnum);
|
||||
}
|
||||
else if (keywordToken == FUN_KEYWORD) {
|
||||
declType = myJetParsing.parseFunction();
|
||||
}
|
||||
else if (keywordToken == VAL_KEYWORD || keywordToken == VAR_KEYWORD) {
|
||||
declType = myJetParsing.parseProperty(true);
|
||||
}
|
||||
else if (keywordToken == TYPE_KEYWORD) {
|
||||
declType = myJetParsing.parseTypeDef();
|
||||
}
|
||||
else if (keywordToken == OBJECT_KEYWORD) {
|
||||
// Object expression may appear at the statement position: should parse it
|
||||
// as expression instead of object declaration
|
||||
// sample:
|
||||
// {
|
||||
// object : Thread() {
|
||||
// }
|
||||
// }
|
||||
IElementType lookahead = lookahead(1);
|
||||
if (lookahead == COLON || lookahead == LBRACE) {
|
||||
return null;
|
||||
}
|
||||
|
||||
myJetParsing.parseObject(true, true);
|
||||
declType = OBJECT_DECLARATION;
|
||||
}
|
||||
return declType;
|
||||
}
|
||||
|
||||
/*
|
||||
* doWhile
|
||||
|
||||
@@ -50,6 +50,7 @@ public class JetParsing extends AbstractJetParsing {
|
||||
private static final TokenSet IMPORT_RECOVERY_SET = TokenSet.create(AS_KEYWORD, DOT, EOL_OR_SEMICOLON);
|
||||
/*package*/ static final TokenSet TYPE_REF_FIRST = TokenSet.create(LBRACKET, IDENTIFIER, FUN_KEYWORD, LPAR, CAPITALIZED_THIS_KEYWORD, HASH);
|
||||
private static final TokenSet RECEIVER_TYPE_TERMINATORS = TokenSet.create(DOT, SAFE_ACCESS);
|
||||
private static final TokenSet VALUE_PARAMETER_FIRST = TokenSet.orSet(TokenSet.create(IDENTIFIER, LBRACKET), MODIFIER_KEYWORDS);
|
||||
|
||||
static JetParsing createForTopLevel(SemanticWhitespaceAwarePsiBuilder builder) {
|
||||
JetParsing jetParsing = new JetParsing(builder);
|
||||
@@ -1722,8 +1723,10 @@ public class JetParsing extends AbstractJetParsing {
|
||||
else {
|
||||
parseValueParameter();
|
||||
}
|
||||
if (!at(COMMA)) break;
|
||||
advance(); // COMMA
|
||||
if (at(COMMA)) {
|
||||
advance(); // COMMA
|
||||
}
|
||||
else if (!atSet(VALUE_PARAMETER_FIRST)) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,17 @@ public class JetBlockExpression extends JetExpressionImpl implements JetStatemen
|
||||
|
||||
@Nullable
|
||||
public TextRange getLastBracketRange() {
|
||||
PsiElement rBrace = findChildByType(JetTokens.RBRACE);
|
||||
PsiElement rBrace = getRBrace();
|
||||
return rBrace != null ? rBrace.getTextRange() : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PsiElement getRBrace() {
|
||||
return findChildByType(JetTokens.RBRACE);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PsiElement getLBrace() {
|
||||
return findChildByType(JetTokens.LBRACE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ public class JetClass extends JetTypeParameterListOwnerStub<PsiJetClassStub> imp
|
||||
PsiJetClassStub stub = getStub();
|
||||
if (stub != null) {
|
||||
FqName fqName = stub.getFqName();
|
||||
return fqName == null ? null : fqName.getFqName();
|
||||
return fqName == null ? null : fqName.asString();
|
||||
}
|
||||
|
||||
List<String> parts = new ArrayList<String>();
|
||||
|
||||
@@ -17,7 +17,10 @@
|
||||
package org.jetbrains.jet.lang.psi;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
|
||||
public class JetClassInitializer extends JetDeclarationImpl implements JetStatementExpression {
|
||||
public JetClassInitializer(@NotNull ASTNode node) {
|
||||
@@ -40,4 +43,10 @@ public class JetClassInitializer extends JetDeclarationImpl implements JetStatem
|
||||
assert body != null;
|
||||
return body;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PsiElement getOpenBraceNode() {
|
||||
JetExpression body = getBody();
|
||||
return (body instanceof JetBlockExpression) ? ((JetBlockExpression) body).getLBrace() : null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,9 +17,11 @@
|
||||
package org.jetbrains.jet.lang.psi;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.JetNodeTypes;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
|
||||
public class JetClassObject extends JetDeclarationImpl implements JetStatementExpression {
|
||||
public JetClassObject(@NotNull ASTNode node) {
|
||||
@@ -41,4 +43,9 @@ public class JetClassObject extends JetDeclarationImpl implements JetStatementEx
|
||||
return (JetObjectDeclaration) findChildByType(JetNodeTypes.OBJECT_DECLARATION);
|
||||
}
|
||||
|
||||
@Nullable @IfNotParsed
|
||||
public PsiElement getClassKeywordNode() {
|
||||
ASTNode keywordNode = getNode().findChildByType(JetTokens.CLASS_KEYWORD);
|
||||
return keywordNode != null ? keywordNode.getPsi() : null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
package org.jetbrains.jet.lang.psi;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.navigation.ItemPresentation;
|
||||
import com.intellij.navigation.ItemPresentationProviders;
|
||||
import com.intellij.psi.stubs.IStubElementType;
|
||||
import com.intellij.util.ArrayFactory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -107,5 +109,8 @@ public class JetParameter extends JetNamedDeclarationStub<PsiJetParameterStub> {
|
||||
return getNode().findChildByType(JetTokens.VAR_KEYWORD);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ItemPresentation getPresentation() {
|
||||
return ItemPresentationProviders.getItemPresentation(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,6 +73,13 @@ public class JetPsiFactory {
|
||||
return star;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static PsiElement createComma(Project project) {
|
||||
PsiElement comma = createType(project, "T<X, Y>").findElementAt(3);
|
||||
assert comma != null;
|
||||
return comma;
|
||||
}
|
||||
|
||||
//the pair contains the first and the last elements of a range
|
||||
public static Pair<PsiElement, PsiElement> createColonAndWhiteSpaces(Project project) {
|
||||
JetProperty property = createProperty(project, "val x : Int");
|
||||
@@ -228,7 +235,7 @@ public class JetPsiFactory {
|
||||
|
||||
Name alias = importPath.getAlias();
|
||||
if (alias != null) {
|
||||
importDirectiveBuilder.append(" as ").append(alias.getName());
|
||||
importDirectiveBuilder.append(" as ").append(alias.asString());
|
||||
}
|
||||
|
||||
JetFile namespace = createFile(project, importDirectiveBuilder.toString());
|
||||
@@ -249,20 +256,14 @@ public class JetPsiFactory {
|
||||
return createExpression(project, "$" + fieldName);
|
||||
}
|
||||
|
||||
public static JetBinaryExpression createAssignment(Project project, @NotNull String lhs, @NotNull String rhs) {
|
||||
return (JetBinaryExpression) createExpression(project, lhs + " = " + rhs);
|
||||
@NotNull
|
||||
public static JetBinaryExpression createBinaryExpression(Project project, @NotNull String lhs, @NotNull String op, @NotNull String rhs) {
|
||||
return (JetBinaryExpression) createExpression(project, lhs + " " + op + " " + rhs);
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public static JetBinaryExpression createAssignment(Project project, @NotNull JetExpression lhs, @NotNull JetExpression rhs) {
|
||||
JetBinaryExpression assignment = createAssignment(project, "_", "_");
|
||||
|
||||
assert assignment.getRight() != null;
|
||||
|
||||
assignment = (JetBinaryExpression)assignment.getLeft().replace(lhs).getParent();
|
||||
assignment = (JetBinaryExpression)assignment.getRight().replace(rhs).getParent();
|
||||
|
||||
return assignment;
|
||||
@NotNull
|
||||
public static JetBinaryExpression createBinaryExpression(Project project, @Nullable JetExpression lhs, @NotNull String op, @Nullable JetExpression rhs) {
|
||||
return createBinaryExpression(project, JetPsiUtil.getText(lhs), op, JetPsiUtil.getText(rhs));
|
||||
}
|
||||
|
||||
public static JetTypeCodeFragment createTypeCodeFragment(Project project, String text, PsiElement context) {
|
||||
@@ -273,6 +274,186 @@ public class JetPsiFactory {
|
||||
return new JetExpressionCodeFragmentImpl(project, "fragment.kt", text, context);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static JetReturnExpression createReturn(Project project, @NotNull String text) {
|
||||
return (JetReturnExpression) createExpression(project, "return " + text);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static JetReturnExpression createReturn(Project project, @Nullable JetExpression expression) {
|
||||
return createReturn(project, JetPsiUtil.getText(expression));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static JetIfExpression createIf(Project project,
|
||||
@Nullable JetExpression condition, @Nullable JetExpression thenExpr, @Nullable JetExpression elseExpr) {
|
||||
return (JetIfExpression) createExpression(project, JetPsiUnparsingUtils.toIf(condition, thenExpr, elseExpr));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static JetValueArgument createArgumentWithName(
|
||||
@NotNull Project project,
|
||||
@NotNull String name,
|
||||
@NotNull JetExpression argumentExpression
|
||||
) {
|
||||
return createCallArguments(project, "(" + name + " = " + argumentExpression.getText() + ")").getArguments().get(0);
|
||||
}
|
||||
|
||||
public static class IfChainBuilder {
|
||||
private final StringBuilder sb = new StringBuilder();
|
||||
private boolean first = true;
|
||||
private boolean frozen = false;
|
||||
|
||||
public IfChainBuilder() {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public IfChainBuilder ifBranch(@NotNull String conditionText, @NotNull String expressionText) {
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
sb.append("else ");
|
||||
}
|
||||
|
||||
sb.append("if (").append(conditionText).append(") ").append(expressionText).append("\n");
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public IfChainBuilder ifBranch(@NotNull JetExpression condition, @NotNull JetExpression expression) {
|
||||
return ifBranch(condition.getText(), expression.getText());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public IfChainBuilder elseBranch(@NotNull String expressionText) {
|
||||
sb.append("else ").append(expressionText);
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public IfChainBuilder elseBranch(@Nullable JetExpression expression) {
|
||||
return elseBranch(JetPsiUtil.getText(expression));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JetIfExpression toExpression(Project project) {
|
||||
if (!frozen) {
|
||||
frozen = true;
|
||||
}
|
||||
return (JetIfExpression) createExpression(project, sb.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public static class WhenBuilder {
|
||||
private final StringBuilder sb = new StringBuilder("when ");
|
||||
private boolean frozen = false;
|
||||
private boolean inCondition = false;
|
||||
|
||||
public WhenBuilder() {
|
||||
this((String)null);
|
||||
}
|
||||
|
||||
public WhenBuilder(@Nullable String subjectText) {
|
||||
if (subjectText != null) {
|
||||
sb.append("(").append(subjectText).append(") ");
|
||||
}
|
||||
sb.append("{\n");
|
||||
}
|
||||
|
||||
public WhenBuilder(@Nullable JetExpression subject) {
|
||||
this(subject != null ? subject.getText() : null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public WhenBuilder condition(@NotNull String text) {
|
||||
assert !frozen;
|
||||
|
||||
if (!inCondition) {
|
||||
inCondition = true;
|
||||
} else {
|
||||
sb.append(", ");
|
||||
}
|
||||
sb.append(text);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public WhenBuilder condition(@Nullable JetExpression expression) {
|
||||
return condition(JetPsiUtil.getText(expression));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public WhenBuilder pattern(@NotNull String typeReferenceText, boolean negated) {
|
||||
return condition((negated ? "!is" : "is") + " " + typeReferenceText);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public WhenBuilder pattern(@Nullable JetTypeReference typeReference, boolean negated) {
|
||||
return pattern(JetPsiUtil.getText(typeReference), negated);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public WhenBuilder range(@NotNull String argumentText, boolean negated) {
|
||||
return condition((negated ? "!in" : "in") + " " + argumentText);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public WhenBuilder range(@Nullable JetExpression argument, boolean negated) {
|
||||
return range(JetPsiUtil.getText(argument), negated);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public WhenBuilder branchExpression(@NotNull String expressionText) {
|
||||
assert !frozen;
|
||||
assert inCondition;
|
||||
|
||||
inCondition = false;
|
||||
sb.append(" -> ").append(expressionText).append("\n");
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public WhenBuilder branchExpression(@Nullable JetExpression expression) {
|
||||
return branchExpression(JetPsiUtil.getText(expression));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public WhenBuilder entry(@NotNull String entryText) {
|
||||
assert !frozen;
|
||||
assert !inCondition;
|
||||
|
||||
sb.append(entryText).append("\n");
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public WhenBuilder entry(@Nullable JetWhenEntry whenEntry) {
|
||||
return entry(JetPsiUtil.getText(whenEntry));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public WhenBuilder elseEntry(@NotNull String text) {
|
||||
return entry("else -> " + text);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public WhenBuilder elseEntry(@Nullable JetExpression expression) {
|
||||
return elseEntry(JetPsiUtil.getText(expression));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JetWhenExpression toExpression(Project project) {
|
||||
if (!frozen) {
|
||||
sb.append("}");
|
||||
frozen = true;
|
||||
}
|
||||
return (JetWhenExpression) createExpression(project, sb.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public static JetExpression createFunctionBody(Project project, @NotNull String bodyText) {
|
||||
JetFunction func = createFunction(project, "fun foo() {\n" + bodyText + "\n}");
|
||||
return func.getBodyExpression();
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.lang.psi;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class JetPsiUnparsingUtils {
|
||||
private JetPsiUnparsingUtils() {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String toIf(@Nullable JetExpression condition, @Nullable JetExpression thenExpression, @Nullable JetExpression elseExpression) {
|
||||
return toIf(
|
||||
JetPsiUtil.getText(condition),
|
||||
JetPsiUtil.getText(thenExpression),
|
||||
elseExpression != null ? elseExpression.getText() : null
|
||||
);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String toIf(@NotNull String condition, @NotNull String thenExpression, @Nullable String elseExpression) {
|
||||
return "if " + parenthesizeTextIfNeeded(condition) + " " + thenExpression + (elseExpression != null ? " else " + elseExpression : "");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String toBinaryExpression(@Nullable JetExpression left, @NotNull String op, @Nullable JetElement right) {
|
||||
return toBinaryExpression(JetPsiUtil.getText(left), op, JetPsiUtil.getText(right));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String toBinaryExpression(@NotNull String left, @NotNull String op, @NotNull String right) {
|
||||
return left + " " + op + " " + right;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String parenthesizeIfNeeded(@Nullable JetExpression expression) {
|
||||
String text = JetPsiUtil.getText(expression);
|
||||
|
||||
return (expression instanceof JetParenthesizedExpression ||
|
||||
expression instanceof JetConstantExpression ||
|
||||
expression instanceof JetSimpleNameExpression)
|
||||
? text : "(" + text + ")";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String parenthesizeTextIfNeeded(@NotNull String expressionText) {
|
||||
return (expressionText.startsWith("(") && expressionText.endsWith(")")) ? expressionText : "(" + expressionText + ")";
|
||||
}
|
||||
}
|
||||
@@ -17,18 +17,23 @@
|
||||
package org.jetbrains.jet.lang.psi;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.PsiComment;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiWhiteSpace;
|
||||
import com.intellij.psi.impl.CheckUtil;
|
||||
import com.intellij.psi.impl.source.codeStyle.CodeEditUtil;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.codeInsight.CommentUtilCore;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.JetNodeTypes;
|
||||
import org.jetbrains.jet.kdoc.psi.api.KDocElement;
|
||||
import org.jetbrains.jet.lang.parsing.JetExpressionParsing;
|
||||
import org.jetbrains.jet.lang.resolve.ImportPath;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
@@ -154,13 +159,14 @@ public class JetPsiUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static FqName getFQName(JetFile file) {
|
||||
@NotNull
|
||||
public static FqName getFQName(@NotNull JetFile file) {
|
||||
JetNamespaceHeader header = file.getNamespaceHeader();
|
||||
return header != null ? header.getFqName() : FqName.ROOT;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static FqName getFQName(JetNamedDeclaration namedDeclaration) {
|
||||
public static FqName getFQName(@NotNull JetNamedDeclaration namedDeclaration) {
|
||||
if (namedDeclaration instanceof JetObjectDeclarationName) {
|
||||
JetNamedDeclaration objectDeclaration = PsiTreeUtil.getParentOfType(namedDeclaration, JetObjectDeclaration.class);
|
||||
if (objectDeclaration == null) {
|
||||
@@ -192,11 +198,17 @@ public class JetPsiUtil {
|
||||
else if (parent instanceof JetNamedFunction || parent instanceof JetClass) {
|
||||
firstPart = getFQName((JetNamedDeclaration) parent);
|
||||
}
|
||||
else if (namedDeclaration instanceof JetParameter) {
|
||||
JetClass constructorClass = getClassIfParameterIsProperty((JetParameter) namedDeclaration);
|
||||
if (constructorClass != null) {
|
||||
firstPart = getFQName(constructorClass);
|
||||
}
|
||||
}
|
||||
else if (parent instanceof JetObjectDeclaration) {
|
||||
if (parent.getParent() instanceof JetClassObject) {
|
||||
JetClassOrObject classOrObject = PsiTreeUtil.getParentOfType(parent, JetClassOrObject.class);
|
||||
if (classOrObject != null) {
|
||||
firstPart = getFQName((JetNamedDeclaration) classOrObject);
|
||||
firstPart = getFQName(classOrObject);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -229,7 +241,7 @@ public class JetPsiUtil {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Name getShortName(JetAnnotationEntry annotation) {
|
||||
public static Name getShortName(@NotNull JetAnnotationEntry annotation) {
|
||||
JetTypeReference typeReference = annotation.getTypeReference();
|
||||
assert typeReference != null : "Annotation entry hasn't typeReference " + annotation.getText();
|
||||
JetTypeElement typeElement = typeReference.getTypeElement();
|
||||
@@ -243,7 +255,7 @@ public class JetPsiUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isDeprecated(JetModifierListOwner owner) {
|
||||
public static boolean isDeprecated(@NotNull JetModifierListOwner owner) {
|
||||
JetModifierList modifierList = owner.getModifierList();
|
||||
if (modifierList != null) {
|
||||
List<JetAnnotationEntry> annotationEntries = modifierList.getAnnotationEntries();
|
||||
@@ -259,7 +271,7 @@ public class JetPsiUtil {
|
||||
|
||||
@Nullable
|
||||
@IfNotParsed
|
||||
public static ImportPath getImportPath(JetImportDirective importDirective) {
|
||||
public static ImportPath getImportPath(@NotNull JetImportDirective importDirective) {
|
||||
if (PsiTreeUtil.hasErrorElements(importDirective)) {
|
||||
return null;
|
||||
}
|
||||
@@ -398,7 +410,7 @@ public class JetPsiUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
return KotlinBuiltIns.getInstance().getUnit().getName().getName().equals(typeReference.getText());
|
||||
return KotlinBuiltIns.getInstance().getUnit().getName().asString().equals(typeReference.getText());
|
||||
}
|
||||
|
||||
public static boolean isSafeCall(@NotNull Call call) {
|
||||
@@ -406,7 +418,7 @@ public class JetPsiUtil {
|
||||
return callOperationNode != null && callOperationNode.getElementType() == JetTokens.SAFE_ACCESS;
|
||||
}
|
||||
|
||||
public static boolean isFunctionLiteralWithoutDeclaredParameterTypes(JetExpression expression) {
|
||||
public static boolean isFunctionLiteralWithoutDeclaredParameterTypes(@Nullable JetExpression expression) {
|
||||
if (!(expression instanceof JetFunctionLiteralExpression)) return false;
|
||||
JetFunctionLiteralExpression functionLiteral = (JetFunctionLiteralExpression) expression;
|
||||
for (JetParameter parameter : functionLiteral.getValueParameters()) {
|
||||
@@ -458,6 +470,7 @@ public class JetPsiUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiElement getTopmostParentOfTypes(@Nullable PsiElement element, @NotNull Class<? extends PsiElement>... parentTypes) {
|
||||
if (element == null) {
|
||||
return null;
|
||||
@@ -564,6 +577,19 @@ public class JetPsiUtil {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static JetClass getClassIfParameterIsProperty(@NotNull JetParameter jetParameter) {
|
||||
if (jetParameter.getValOrVarNode() != null) {
|
||||
PsiElement parent = jetParameter.getParent();
|
||||
if (parent instanceof JetParameterList && parent.getParent() instanceof JetClass) {
|
||||
return (JetClass) parent.getParent();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static IElementType getOperation(@NotNull JetExpression expression) {
|
||||
if (expression instanceof JetQualifiedExpression) {
|
||||
return ((JetQualifiedExpression) expression).getOperationSign();
|
||||
@@ -621,4 +647,197 @@ public class JetPsiUtil {
|
||||
int parentPrecedence = getPrecedenceOfOperation(parentExpression, parentOperation);
|
||||
return innerPrecedence < parentPrecedence;
|
||||
}
|
||||
|
||||
public static boolean isAssignment(@NotNull PsiElement element) {
|
||||
return element instanceof JetBinaryExpression &&
|
||||
JetTokens.ALL_ASSIGNMENTS.contains(((JetBinaryExpression) element).getOperationToken());
|
||||
}
|
||||
|
||||
public static boolean isBranchedExpression(@Nullable PsiElement element) {
|
||||
return element instanceof JetIfExpression || element instanceof JetWhenExpression;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static JetElement getOutermostLastBlockElement(@Nullable JetElement element, @NotNull Predicate<JetElement> checkElement) {
|
||||
if (element == null) return null;
|
||||
|
||||
if (!(element instanceof JetBlockExpression)) return checkElement.apply(element) ? element : null;
|
||||
|
||||
JetBlockExpression block = (JetBlockExpression)element;
|
||||
int n = block.getStatements().size();
|
||||
|
||||
if (n == 0) return null;
|
||||
|
||||
JetElement lastElement = block.getStatements().get(n - 1);
|
||||
return checkElement.apply(lastElement) ? lastElement : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiElement getParentByTypeAndPredicate(
|
||||
@Nullable PsiElement element, @NotNull Class<? extends PsiElement> aClass, @NotNull Predicate<PsiElement> predicate, boolean strict) {
|
||||
if (element == null) return null;
|
||||
if (strict) {
|
||||
element = element.getParent();
|
||||
}
|
||||
|
||||
while (element != null) {
|
||||
//noinspection unchecked
|
||||
if (aClass.isInstance(element) && predicate.apply(element)) {
|
||||
//noinspection unchecked
|
||||
return element;
|
||||
}
|
||||
if (element instanceof PsiFile) return null;
|
||||
element = element.getParent();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean checkVariableDeclarationInBlock(@NotNull JetBlockExpression block, @NotNull String varName) {
|
||||
for (JetElement element : block.getStatements()) {
|
||||
if (element instanceof JetVariableDeclaration) {
|
||||
if (((JetVariableDeclaration) element).getNameAsSafeName().asString().equals(varName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <C extends Collection<JetVariableDeclaration>> C getBlockVariableDeclarations(@NotNull JetBlockExpression block, @NotNull C collection) {
|
||||
for (JetElement element : block.getStatements()) {
|
||||
if (element instanceof JetVariableDeclaration) {
|
||||
collection.add((JetVariableDeclaration) element);
|
||||
}
|
||||
}
|
||||
|
||||
return collection;
|
||||
}
|
||||
|
||||
public static boolean checkWhenExpressionHasSingleElse(@NotNull JetWhenExpression whenExpression) {
|
||||
int elseCount = 0;
|
||||
for (JetWhenEntry entry : whenExpression.getEntries()) {
|
||||
if (entry.isElse()) {
|
||||
elseCount++;
|
||||
}
|
||||
}
|
||||
return (elseCount == 1);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiElement skipTrailingWhitespacesAndComments(@Nullable PsiElement element) {
|
||||
return PsiTreeUtil.skipSiblingsForward(element, PsiWhiteSpace.class, PsiComment.class);
|
||||
}
|
||||
|
||||
public static final Predicate<JetElement> ANY_JET_ELEMENT = new Predicate<JetElement>() {
|
||||
@Override
|
||||
public boolean apply(@Nullable JetElement input) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
@NotNull
|
||||
public static String getText(@Nullable PsiElement element) {
|
||||
return element != null ? element.getText() : "";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String getNullableText(@Nullable PsiElement element) {
|
||||
return element != null ? element.getText() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* CommentUtilCore.isComment fails if element <strong>inside</strong> comment.
|
||||
*
|
||||
* Also, we can not add KDocTokens to COMMENTS TokenSet, because it is used in JetParserDefinition.getCommentTokens(),
|
||||
* and therefor all COMMENTS tokens will be ignored by PsiBuilder.
|
||||
*
|
||||
* @param element
|
||||
* @return
|
||||
*/
|
||||
public static boolean isInComment(PsiElement element) {
|
||||
return CommentUtilCore.isComment(element) || element instanceof KDocElement;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiElement getOutermostParent(@NotNull PsiElement element, @NotNull PsiElement upperBound, boolean strict) {
|
||||
PsiElement parent = strict ? element.getParent() : element;
|
||||
while (parent != null && parent.getParent() != upperBound) {
|
||||
parent = parent.getParent();
|
||||
}
|
||||
|
||||
return parent;
|
||||
}
|
||||
|
||||
public static <T extends PsiElement> T getLastChildByType(@NotNull PsiElement root, @NotNull Class<? extends T>... elementTypes) {
|
||||
PsiElement[] children = root.getChildren();
|
||||
|
||||
for (int i = children.length - 1; i >= 0; i--) {
|
||||
if (PsiTreeUtil.instanceOf(children[i], elementTypes)) {
|
||||
//noinspection unchecked
|
||||
return (T) children[i];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static <T extends JetElement> T getOutermostJetElement(
|
||||
@Nullable PsiElement root,
|
||||
boolean first,
|
||||
@NotNull final Class<? extends T>... elementTypes
|
||||
) {
|
||||
if (!(root instanceof JetElement)) return null;
|
||||
|
||||
final List<T> results = Lists.newArrayList();
|
||||
|
||||
((JetElement) root).accept(
|
||||
new JetVisitorVoid() {
|
||||
@Override
|
||||
public void visitJetElement(JetElement element) {
|
||||
if (PsiTreeUtil.instanceOf(element, elementTypes)) {
|
||||
//noinspection unchecked
|
||||
results.add((T) element);
|
||||
}
|
||||
else {
|
||||
element.acceptChildren(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
if (results.isEmpty()) return null;
|
||||
|
||||
return first ? results.get(0) : results.get(results.size() - 1);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiElement findChildByType(@NotNull PsiElement element, @NotNull IElementType type) {
|
||||
ASTNode node = element.getNode().findChildByType(type);
|
||||
return node == null ? null : node.getPsi();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static JetExpression getCalleeExpressionIfAny(@NotNull JetExpression expression) {
|
||||
if (expression instanceof JetCallElement) {
|
||||
JetCallElement callExpression = (JetCallElement) expression;
|
||||
return callExpression.getCalleeExpression();
|
||||
}
|
||||
if (expression instanceof JetQualifiedExpression) {
|
||||
JetExpression selectorExpression = ((JetQualifiedExpression) expression).getSelectorExpression();
|
||||
if (selectorExpression != null) {
|
||||
return getCalleeExpressionIfAny(selectorExpression);
|
||||
}
|
||||
}
|
||||
if (expression instanceof JetUnaryExpression) {
|
||||
return ((JetUnaryExpression) expression).getOperationReference();
|
||||
}
|
||||
if (expression instanceof JetBinaryExpression) {
|
||||
return ((JetBinaryExpression) expression).getOperationReference();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -408,5 +408,4 @@ public class JetVisitor<R, D> extends PsiElementVisitor {
|
||||
public R visitEscapeStringTemplateEntry(JetEscapeStringTemplateEntry entry, D data) {
|
||||
return visitStringTemplateEntry(entry, data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -60,4 +60,14 @@ public class JetWhenExpression extends JetExpressionImpl {
|
||||
ASTNode openBraceNode = getNode().findChildByType(JetTokens.RBRACE);
|
||||
return openBraceNode != null ? openBraceNode.getPsi() : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public JetExpression getElseExpression() {
|
||||
for (JetWhenEntry entry : getEntries()) {
|
||||
if (entry.isElse()) {
|
||||
return entry.getExpression();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ public class JetAnnotationElementType extends JetStubElementType<PsiJetAnnotatio
|
||||
@Override
|
||||
public PsiJetAnnotationStub createStub(@NotNull JetAnnotationEntry psi, StubElement parentStub) {
|
||||
Name shortName = JetPsiUtil.getShortName(psi);
|
||||
String resultName = shortName != null ? shortName.getName() : psi.getText();
|
||||
String resultName = shortName != null ? shortName.asString() : psi.getText();
|
||||
return new PsiJetAnnotationStubImpl(parentStub, JetStubElementTypes.ANNOTATION_ENTRY, resultName);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -54,7 +54,7 @@ public class JetClassElementType extends JetStubElementType<PsiJetClassStub, Jet
|
||||
public PsiJetClassStub createStub(@NotNull JetClass psi, StubElement parentStub) {
|
||||
FqName fqName = JetPsiUtil.getFQName(psi);
|
||||
boolean isEnumEntry = psi instanceof JetEnumEntry;
|
||||
return new PsiJetClassStubImpl(getStubType(isEnumEntry), parentStub, fqName != null ? fqName.getFqName() : null, psi.getName(),
|
||||
return new PsiJetClassStubImpl(getStubType(isEnumEntry), parentStub, fqName != null ? fqName.asString() : null, psi.getName(),
|
||||
psi.getSuperNames(), psi.isTrait(), psi.isEnum(), isEnumEntry, psi.isAnnotation(), psi.isInner());
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public class JetClassElementType extends JetStubElementType<PsiJetClassStub, Jet
|
||||
public void serialize(PsiJetClassStub stub, StubOutputStream dataStream) throws IOException {
|
||||
dataStream.writeName(stub.getName());
|
||||
FqName fqName = stub.getFqName();
|
||||
dataStream.writeName(fqName == null ? null : fqName.getFqName());
|
||||
dataStream.writeName(fqName == null ? null : fqName.asString());
|
||||
dataStream.writeBoolean(stub.isTrait());
|
||||
dataStream.writeBoolean(stub.isEnumClass());
|
||||
dataStream.writeBoolean(stub.isEnumEntry());
|
||||
|
||||
+11
-4
@@ -23,10 +23,7 @@ import com.intellij.psi.stubs.StubElement;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.psi.JetBlockExpression;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
import org.jetbrains.jet.lang.psi.JetFunctionLiteral;
|
||||
import org.jetbrains.jet.lang.psi.JetWithExpressionInitializer;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.plugin.JetLanguage;
|
||||
|
||||
public abstract class JetStubElementType<StubT extends StubElement, PsiT extends PsiElement> extends IStubElementType<StubT, PsiT> {
|
||||
@@ -67,6 +64,16 @@ public abstract class JetStubElementType<StubT extends StubElement, PsiT extends
|
||||
}
|
||||
}
|
||||
|
||||
// Don't create stubs if declaration is inside property delegate
|
||||
@SuppressWarnings("unchecked") JetPropertyDelegate delegate =
|
||||
PsiTreeUtil.getParentOfType(psi, JetPropertyDelegate.class, true, JetBlockExpression.class);
|
||||
if (delegate != null) {
|
||||
JetExpression delegateExpression = delegate.getExpression();
|
||||
if (PsiTreeUtil.isAncestor(delegateExpression, psi, true)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return super.shouldCreateStub(node);
|
||||
}
|
||||
}
|
||||
|
||||
+19
-1
@@ -16,14 +16,21 @@
|
||||
|
||||
package org.jetbrains.jet.lang.psi.stubs.impl;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.impl.java.stubs.PsiClassStub;
|
||||
import com.intellij.psi.stubs.PsiClassHolderFileStub;
|
||||
import com.intellij.psi.stubs.PsiFileStubImpl;
|
||||
import com.intellij.psi.stubs.StubElement;
|
||||
import com.intellij.psi.tree.IStubFileElementType;
|
||||
import com.intellij.util.io.StringRef;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.psi.stubs.PsiJetFileStub;
|
||||
import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes;
|
||||
|
||||
public class PsiJetFileStubImpl extends PsiFileStubImpl<JetFile> implements PsiJetFileStub {
|
||||
import java.util.List;
|
||||
|
||||
public class PsiJetFileStubImpl extends PsiFileStubImpl<JetFile> implements PsiJetFileStub, PsiClassHolderFileStub<JetFile> {
|
||||
|
||||
private final StringRef packageName;
|
||||
private final boolean isScript;
|
||||
@@ -65,4 +72,15 @@ public class PsiJetFileStubImpl extends PsiFileStubImpl<JetFile> implements PsiJ
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiClass[] getClasses() {
|
||||
List<PsiClass> result = Lists.newArrayList();
|
||||
for (StubElement child : getChildrenStubs()) {
|
||||
if (child instanceof PsiClassStub) {
|
||||
result.add((PsiClass) child.getPsi());
|
||||
}
|
||||
}
|
||||
return result.toArray(new PsiClass[result.size()]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,11 +93,11 @@ public class AnnotationResolver {
|
||||
ConstructorDescriptor constructor = (ConstructorDescriptor)descriptor;
|
||||
ClassDescriptor classDescriptor = constructor.getContainingDeclaration();
|
||||
if (classDescriptor.getKind() != ClassKind.ANNOTATION_CLASS) {
|
||||
trace.report(Errors.NOT_AN_ANNOTATION_CLASS.on(entryElement, classDescriptor.getName().getName()));
|
||||
trace.report(Errors.NOT_AN_ANNOTATION_CLASS.on(entryElement, classDescriptor.getName().asString()));
|
||||
}
|
||||
}
|
||||
else {
|
||||
trace.report(Errors.NOT_AN_ANNOTATION_CLASS.on(entryElement, descriptor.getName().getName()));
|
||||
trace.report(Errors.NOT_AN_ANNOTATION_CLASS.on(entryElement, descriptor.getName().asString()));
|
||||
}
|
||||
}
|
||||
JetType annotationType = results.getResultingDescriptor().getReturnType();
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user