- small optimizations of JavaDescriptorResolver
- kind of method encoded in flags - nullable return type encoded in flags
This commit is contained in:
+7
-8
@@ -1214,7 +1214,7 @@ public class JavaDescriptorResolver implements DependencyClassByQualifiedNameRes
|
||||
if (members.getter != null && members.getter.getMember() instanceof PsiMethodWrapper) {
|
||||
JetMethodAnnotation jetMethod = ((PsiMethodWrapper) members.getter.getMember()).getJetMethod();
|
||||
visibility = resolveVisibility(anyMember.getMember().psiMember, jetMethod);
|
||||
kind = DescriptorKindUtils.intToKind(jetMethod.kind());
|
||||
kind = DescriptorKindUtils.flagsToKind(jetMethod.kind());
|
||||
}
|
||||
|
||||
DeclarationDescriptor realOwner = getRealOwner(owner, scopeData, anyMember.getMember().isStatic());
|
||||
@@ -1533,7 +1533,7 @@ public class JavaDescriptorResolver implements DependencyClassByQualifiedNameRes
|
||||
}
|
||||
|
||||
// TODO: ugly
|
||||
if (method.getJetMethod().flags().get(JvmStdlibNames.FLAG_PROPERTY_BIT)) {
|
||||
if (method.getJetMethod().hasPropertyFlag()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1549,7 +1549,7 @@ public class JavaDescriptorResolver implements DependencyClassByQualifiedNameRes
|
||||
scopeData.classOrNamespaceDescriptor,
|
||||
resolveAnnotations(method.getPsiMethod()),
|
||||
Name.identifier(method.getName()),
|
||||
DescriptorKindUtils.intToKind(method.getJetMethod().kind())
|
||||
DescriptorKindUtils.flagsToKind(method.getJetMethod().kind())
|
||||
);
|
||||
|
||||
String context = "method " + method.getName() + " in class " + psiClass.getQualifiedName();
|
||||
@@ -1893,10 +1893,10 @@ public class JavaDescriptorResolver implements DependencyClassByQualifiedNameRes
|
||||
private static Modality resolveModality(PsiMemberWrapper memberWrapper, boolean isFinal) {
|
||||
if (memberWrapper instanceof PsiMethodWrapper) {
|
||||
PsiMethodWrapper method = (PsiMethodWrapper) memberWrapper;
|
||||
if (method.getJetMethod().flags().get(JvmStdlibNames.FLAG_FORCE_OPEN_BIT)) {
|
||||
if (method.getJetMethod().hasForceOpenFlag()) {
|
||||
return Modality.OPEN;
|
||||
}
|
||||
if (method.getJetMethod().flags().get(JvmStdlibNames.FLAG_FORCE_FINAL_BIT)) {
|
||||
if (method.getJetMethod().hasForceFinalFlag()) {
|
||||
return Modality.FINAL;
|
||||
}
|
||||
}
|
||||
@@ -1907,11 +1907,10 @@ public class JavaDescriptorResolver implements DependencyClassByQualifiedNameRes
|
||||
private static Visibility resolveVisibility(PsiModifierListOwner modifierListOwner,
|
||||
@Nullable PsiAnnotationWithFlags annotation) {
|
||||
if (annotation != null) {
|
||||
BitSet flags = annotation.flags();
|
||||
if (flags.get(JvmStdlibNames.FLAG_PRIVATE_BIT)) {
|
||||
if (annotation.hasPrivateFlag()) {
|
||||
return Visibilities.PRIVATE;
|
||||
}
|
||||
else if (flags.get(JvmStdlibNames.FLAG_INTERNAL_BIT)) {
|
||||
else if (annotation.hasInternalFlag()) {
|
||||
return Visibilities.INTERNAL;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -131,7 +131,7 @@ class JavaDescriptorResolverHelper {
|
||||
NamedMembers members = getNamedMembers(Name.identifier(propertyName));
|
||||
|
||||
// TODO: some java properties too
|
||||
if (method.getJetMethod().flags().get(JvmStdlibNames.FLAG_PROPERTY_BIT)) {
|
||||
if (method.getJetMethod().hasPropertyFlag()) {
|
||||
|
||||
int i = 0;
|
||||
|
||||
@@ -173,7 +173,7 @@ class JavaDescriptorResolverHelper {
|
||||
String propertyName = propertyParseResult.getPropertyName();
|
||||
NamedMembers members = getNamedMembers(Name.identifier(propertyName));
|
||||
|
||||
if (method.getJetMethod().flags().get(JvmStdlibNames.FLAG_PROPERTY_BIT)) {
|
||||
if (method.getJetMethod().hasPropertyFlag()) {
|
||||
if (method.getParameters().size() == 0) {
|
||||
// TODO: report error properly
|
||||
throw new IllegalStateException();
|
||||
@@ -210,7 +210,7 @@ class JavaDescriptorResolverHelper {
|
||||
}
|
||||
}
|
||||
|
||||
if (!method.getJetMethod().flags().get(JvmStdlibNames.FLAG_PROPERTY_BIT)) {
|
||||
if (!method.getJetMethod().hasPropertyFlag()) {
|
||||
NamedMembers namedMembers = getNamedMembers(Name.identifier(method.getName()));
|
||||
namedMembers.addMethod(method);
|
||||
}
|
||||
|
||||
+15
-11
@@ -17,7 +17,6 @@
|
||||
package org.jetbrains.jet.lang.resolve.java;
|
||||
|
||||
import jet.runtime.typeinfo.JetConstructor;
|
||||
import jet.runtime.typeinfo.KotlinSignature;
|
||||
|
||||
/**
|
||||
* @author Stepan Koltsov
|
||||
@@ -40,20 +39,27 @@ public class JvmStdlibNames {
|
||||
|
||||
public static final JvmClassName JET_METHOD = JvmClassName.byFqNameWithoutInnerClasses("jet.runtime.typeinfo.JetMethod");
|
||||
|
||||
public static final String JET_METHOD_KIND_FIELD = "kind";
|
||||
public static final String JET_METHOD_FLAGS_FIELD = "flags";
|
||||
public static final String JET_METHOD_NULLABLE_RETURN_TYPE_FIELD = "nullableReturnType";
|
||||
public static final String JET_FLAGS_FIELD = "flags";
|
||||
|
||||
public static final String JET_METHOD_RETURN_TYPE_FIELD = "returnType";
|
||||
public static final String JET_METHOD_TYPE_PARAMETERS_FIELD = "typeParameters";
|
||||
public static final String JET_METHOD_PROPERTY_TYPE_FIELD = "propertyType";
|
||||
|
||||
public static final int FLAGS_DEFAULT_VALUE = 0;
|
||||
|
||||
public static final int FLAG_PROPERTY_BIT = 0;
|
||||
public static final int FLAG_FORCE_OPEN_BIT = 1;
|
||||
public static final int FLAG_FORCE_FINAL_BIT = 2;
|
||||
public static final int FLAG_PRIVATE_BIT = 3;
|
||||
public static final int FLAG_INTERNAL_BIT = 4;
|
||||
public static final int FLAG_PROPERTY_BIT = 1 << 0;
|
||||
public static final int FLAG_FORCE_OPEN_BIT = 1 << 1;
|
||||
public static final int FLAG_FORCE_FINAL_BIT = 1 << 2;
|
||||
public static final int FLAG_PRIVATE_BIT = 1 << 3;
|
||||
public static final int FLAG_INTERNAL_BIT = 1 << 4;
|
||||
public static final int FLAG_NULLABLE_RETURN_TYPE_BIT = 1 << 5;
|
||||
|
||||
// three bits (one reserved)
|
||||
public static final int FLAG_KIND_MASK = 7 << 6;
|
||||
public static final int FLAG_KIND_DECLARATION = 0 << 6;
|
||||
public static final int FLAG_KIND_FAKE_OVERRIDE = 1 << 6;
|
||||
public static final int FLAG_KIND_DELEGATION = 2 << 6;
|
||||
public static final int FLAG_KIND_SYNTHESIZED = 3 << 6;
|
||||
|
||||
public static final JvmClassName JET_CONSTRUCTOR = JvmClassName.byFqNameWithoutInnerClasses("jet.runtime.typeinfo.JetConstructor");
|
||||
|
||||
@@ -62,13 +68,11 @@ public class JvmStdlibNames {
|
||||
* @see JetConstructor#hidden()
|
||||
*/
|
||||
public static final String JET_CONSTRUCTOR_HIDDEN_FIELD = "hidden";
|
||||
public static final String JET_CONSTRUCTOR_FLAGS_FIELD = "flags";
|
||||
|
||||
|
||||
public static final JvmClassName JET_CLASS = JvmClassName.byFqNameWithoutInnerClasses("jet.runtime.typeinfo.JetClass");
|
||||
|
||||
public static final String JET_CLASS_SIGNATURE = "signature";
|
||||
public static final String JET_CLASS_FLAGS_FIELD = "flags";
|
||||
|
||||
|
||||
public static final JvmClassName JET_OBJECT = JvmClassName.byFqNameWithoutInnerClasses("jet.JetObject");
|
||||
|
||||
+13
-20
@@ -17,39 +17,32 @@
|
||||
package org.jetbrains.jet.lang.resolve.java.kt;
|
||||
|
||||
import org.jetbrains.jet.lang.descriptors.CallableMemberDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
|
||||
|
||||
/**
|
||||
* @author udalov
|
||||
* @author alex.tkachman
|
||||
*/
|
||||
public class DescriptorKindUtils {
|
||||
private static final int KIND_DECLARATION = 0;
|
||||
private static final int KIND_FAKE_OVERRIDE = 1;
|
||||
private static final int KIND_DELEGATION = 2;
|
||||
private static final int KIND_SYNTHESIZED = 3;
|
||||
|
||||
private DescriptorKindUtils() {
|
||||
}
|
||||
|
||||
public static int getDefaultKindValue() {
|
||||
return KIND_DECLARATION;
|
||||
}
|
||||
|
||||
public static int kindToInt(CallableMemberDescriptor.Kind kind) {
|
||||
public static int kindToFlags(CallableMemberDescriptor.Kind kind) {
|
||||
switch (kind) {
|
||||
case DECLARATION: return KIND_DECLARATION;
|
||||
case FAKE_OVERRIDE: return KIND_FAKE_OVERRIDE;
|
||||
case DELEGATION: return KIND_DELEGATION;
|
||||
case SYNTHESIZED: return KIND_SYNTHESIZED;
|
||||
case DECLARATION: return JvmStdlibNames.FLAG_KIND_DECLARATION;
|
||||
case FAKE_OVERRIDE: return JvmStdlibNames.FLAG_KIND_FAKE_OVERRIDE;
|
||||
case DELEGATION: return JvmStdlibNames.FLAG_KIND_DELEGATION;
|
||||
case SYNTHESIZED: return JvmStdlibNames.FLAG_KIND_SYNTHESIZED;
|
||||
default: throw new IllegalArgumentException("Unknown kind: " + kind);
|
||||
}
|
||||
}
|
||||
|
||||
public static CallableMemberDescriptor.Kind intToKind(int value) {
|
||||
switch (value) {
|
||||
case KIND_DECLARATION: return CallableMemberDescriptor.Kind.DECLARATION;
|
||||
case KIND_FAKE_OVERRIDE: return CallableMemberDescriptor.Kind.FAKE_OVERRIDE;
|
||||
case KIND_DELEGATION: return CallableMemberDescriptor.Kind.DELEGATION;
|
||||
case KIND_SYNTHESIZED: return CallableMemberDescriptor.Kind.SYNTHESIZED;
|
||||
public static CallableMemberDescriptor.Kind flagsToKind(int value) {
|
||||
switch (value & JvmStdlibNames.FLAG_KIND_MASK) {
|
||||
case JvmStdlibNames.FLAG_KIND_DECLARATION: return CallableMemberDescriptor.Kind.DECLARATION;
|
||||
case JvmStdlibNames.FLAG_KIND_FAKE_OVERRIDE: return CallableMemberDescriptor.Kind.FAKE_OVERRIDE;
|
||||
case JvmStdlibNames.FLAG_KIND_DELEGATION: return CallableMemberDescriptor.Kind.DELEGATION;
|
||||
case JvmStdlibNames.FLAG_KIND_SYNTHESIZED: return CallableMemberDescriptor.Kind.SYNTHESIZED;
|
||||
default: throw new IllegalArgumentException("Unknown int value of kind: " + value);
|
||||
}
|
||||
}
|
||||
|
||||
+10
-18
@@ -22,37 +22,29 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
|
||||
import org.jetbrains.jet.utils.BitSetUtils;
|
||||
|
||||
import java.util.BitSet;
|
||||
|
||||
/**
|
||||
* @author Stepan Koltsov
|
||||
*/
|
||||
public class JetClassAnnotation extends PsiAnnotationWithFlags {
|
||||
|
||||
private String signature;
|
||||
|
||||
public JetClassAnnotation(@Nullable PsiAnnotation psiAnnotation) {
|
||||
super(psiAnnotation);
|
||||
}
|
||||
|
||||
private String signature;
|
||||
|
||||
@Override
|
||||
protected void initialize() {
|
||||
super.initialize();
|
||||
signature = getStringAttribute(JvmStdlibNames.JET_CLASS_SIGNATURE, "");
|
||||
}
|
||||
|
||||
public String signature() {
|
||||
if (signature == null) {
|
||||
signature = getStringAttribute(JvmStdlibNames.JET_CLASS_SIGNATURE, "");
|
||||
}
|
||||
checkInitialized();
|
||||
return signature;
|
||||
}
|
||||
|
||||
|
||||
private BitSet flags = null;
|
||||
@NotNull
|
||||
public BitSet flags() {
|
||||
if (flags == null) {
|
||||
flags = BitSetUtils.toBitSet(getIntAttribute(JvmStdlibNames.JET_CLASS_FLAGS_FIELD, JvmStdlibNames.FLAGS_DEFAULT_VALUE));
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static JetClassAnnotation get(PsiClass psiClass) {
|
||||
return new JetClassAnnotation(JavaDescriptorResolver.findAnnotation(psiClass, JvmStdlibNames.JET_CLASS.getFqName().getFqName()));
|
||||
|
||||
+8
-19
@@ -18,13 +18,9 @@ package org.jetbrains.jet.lang.resolve.java.kt;
|
||||
|
||||
import com.intellij.psi.PsiAnnotation;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
|
||||
import org.jetbrains.jet.utils.BitSetUtils;
|
||||
|
||||
import java.util.BitSet;
|
||||
|
||||
/**
|
||||
* @author Stepan Koltsov
|
||||
@@ -35,27 +31,20 @@ public class JetConstructorAnnotation extends PsiAnnotationWithFlags {
|
||||
super(psiAnnotation);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initialize() {
|
||||
super.initialize();
|
||||
hidden = getBooleanAttribute(JvmStdlibNames.JET_CONSTRUCTOR_HIDDEN_FIELD, false);
|
||||
}
|
||||
|
||||
private boolean hidden;
|
||||
private boolean hiddenInitialized = false;
|
||||
|
||||
/** @deprecated */
|
||||
public boolean hidden() {
|
||||
if (!hiddenInitialized) {
|
||||
hidden = getBooleanAttribute(JvmStdlibNames.JET_CONSTRUCTOR_HIDDEN_FIELD, false);
|
||||
hiddenInitialized = true;
|
||||
}
|
||||
checkInitialized();
|
||||
return hidden;
|
||||
}
|
||||
|
||||
private BitSet flags;
|
||||
@NotNull
|
||||
@Override
|
||||
public BitSet flags() {
|
||||
if (flags == null) {
|
||||
flags = BitSetUtils.toBitSet(getIntAttribute(JvmStdlibNames.JET_CONSTRUCTOR_FLAGS_FIELD, JvmStdlibNames.FLAGS_DEFAULT_VALUE));
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
public static JetConstructorAnnotation get(PsiMethod constructor) {
|
||||
return new JetConstructorAnnotation(JavaDescriptorResolver.findAnnotation(constructor, JvmStdlibNames.JET_CONSTRUCTOR.getFqName().getFqName()));
|
||||
}
|
||||
|
||||
+17
-39
@@ -22,74 +22,52 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
|
||||
import org.jetbrains.jet.utils.BitSetUtils;
|
||||
|
||||
import java.util.BitSet;
|
||||
|
||||
/**
|
||||
* @author Stepan Koltsov
|
||||
* @author alex.tkachman
|
||||
*/
|
||||
public class JetMethodAnnotation extends PsiAnnotationWithFlags {
|
||||
|
||||
private String typeParameters;
|
||||
private String returnType;
|
||||
private String propertyType;
|
||||
|
||||
public JetMethodAnnotation(@Nullable PsiAnnotation psiAnnotation) {
|
||||
super(psiAnnotation);
|
||||
}
|
||||
|
||||
private BitSet flags = null;
|
||||
@NotNull
|
||||
public BitSet flags() {
|
||||
if (flags == null) {
|
||||
int flagsValue = getIntAttribute(JvmStdlibNames.JET_METHOD_FLAGS_FIELD, JvmStdlibNames.FLAGS_DEFAULT_VALUE);
|
||||
flags = BitSetUtils.toBitSet(flagsValue);
|
||||
}
|
||||
return flags;
|
||||
|
||||
@Override
|
||||
protected void initialize() {
|
||||
super.initialize();
|
||||
typeParameters = getStringAttribute(JvmStdlibNames.JET_METHOD_TYPE_PARAMETERS_FIELD, "");
|
||||
returnType = getStringAttribute(JvmStdlibNames.JET_METHOD_RETURN_TYPE_FIELD, "");
|
||||
propertyType = getStringAttribute(JvmStdlibNames.JET_METHOD_PROPERTY_TYPE_FIELD, "");
|
||||
}
|
||||
|
||||
private int kind;
|
||||
private boolean kindInitialized;
|
||||
public int kind() {
|
||||
if (!kindInitialized) {
|
||||
kind = getIntAttribute(JvmStdlibNames.JET_METHOD_KIND_FIELD, DescriptorKindUtils.getDefaultKindValue());
|
||||
kindInitialized = true;
|
||||
}
|
||||
return kind;
|
||||
return flags() & JvmStdlibNames.FLAG_KIND_MASK;
|
||||
}
|
||||
|
||||
private String typeParameters;
|
||||
@NotNull
|
||||
public String typeParameters() {
|
||||
if (typeParameters == null) {
|
||||
typeParameters = getStringAttribute(JvmStdlibNames.JET_METHOD_TYPE_PARAMETERS_FIELD, "");
|
||||
}
|
||||
checkInitialized();
|
||||
return typeParameters;
|
||||
}
|
||||
|
||||
private String returnType;
|
||||
@NotNull
|
||||
public String returnType() {
|
||||
if (returnType == null) {
|
||||
returnType = getStringAttribute(JvmStdlibNames.JET_METHOD_RETURN_TYPE_FIELD, "");
|
||||
}
|
||||
checkInitialized();
|
||||
return returnType;
|
||||
}
|
||||
|
||||
private boolean returnTypeNullable;
|
||||
private boolean returnTypeNullableInitialized;
|
||||
@NotNull
|
||||
public boolean returnTypeNullable() {
|
||||
if (!returnTypeNullableInitialized) {
|
||||
returnTypeNullable = getBooleanAttribute(JvmStdlibNames.JET_METHOD_NULLABLE_RETURN_TYPE_FIELD, false);
|
||||
returnTypeNullableInitialized = true;
|
||||
}
|
||||
return returnTypeNullable;
|
||||
return (flags() & JvmStdlibNames.FLAG_NULLABLE_RETURN_TYPE_BIT) != 0;
|
||||
}
|
||||
|
||||
private String propertyType;
|
||||
@NotNull
|
||||
public String propertyType() {
|
||||
if (propertyType == null) {
|
||||
propertyType = getStringAttribute(JvmStdlibNames.JET_METHOD_PROPERTY_TYPE_FIELD, "");
|
||||
}
|
||||
checkInitialized();
|
||||
return propertyType;
|
||||
}
|
||||
|
||||
|
||||
+4
@@ -32,6 +32,10 @@ public class JetTypeParameterAnnotation extends PsiAnnotationWrapper {
|
||||
super(psiAnnotation);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initialize() {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static JetTypeParameterAnnotation get(@NotNull PsiParameter psiParameter) {
|
||||
return new JetTypeParameterAnnotation(
|
||||
|
||||
+21
-27
@@ -25,6 +25,7 @@ import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
|
||||
|
||||
/**
|
||||
* @author Stepan Koltsov
|
||||
* @author alex.tkachman
|
||||
*/
|
||||
public class JetValueParameterAnnotation extends PsiAnnotationWrapper {
|
||||
|
||||
@@ -33,50 +34,44 @@ public class JetValueParameterAnnotation extends PsiAnnotationWrapper {
|
||||
}
|
||||
|
||||
private String name;
|
||||
private String type;
|
||||
private boolean nullable;
|
||||
private boolean receiver;
|
||||
private boolean hasDefaultValue;
|
||||
|
||||
@Override
|
||||
protected void initialize() {
|
||||
name = getStringAttribute(JvmStdlibNames.JET_VALUE_PARAMETER_NAME_FIELD, "");
|
||||
type = getStringAttribute(JvmStdlibNames.JET_VALUE_PARAMETER_TYPE_FIELD, "");
|
||||
nullable = getBooleanAttribute(JvmStdlibNames.JET_VALUE_PARAMETER_NULLABLE_FIELD, false);
|
||||
receiver = getBooleanAttribute(JvmStdlibNames.JET_VALUE_PARAMETER_RECEIVER_FIELD, false);
|
||||
hasDefaultValue = getBooleanAttribute(JvmStdlibNames.JET_VALUE_PARAMETER_HAS_DEFAULT_VALUE_FIELD, false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String name() {
|
||||
if (name == null) {
|
||||
name = getStringAttribute(JvmStdlibNames.JET_VALUE_PARAMETER_NAME_FIELD, "");
|
||||
}
|
||||
checkInitialized();
|
||||
return name;
|
||||
}
|
||||
|
||||
private String type;
|
||||
|
||||
@NotNull
|
||||
public String type() {
|
||||
if (type == null) {
|
||||
type = getStringAttribute(JvmStdlibNames.JET_VALUE_PARAMETER_TYPE_FIELD, "");
|
||||
}
|
||||
checkInitialized();
|
||||
return type;
|
||||
}
|
||||
|
||||
private boolean nullable;
|
||||
private boolean nullableInitialized = false;
|
||||
public boolean nullable() {
|
||||
if (!nullableInitialized) {
|
||||
nullable = getBooleanAttribute(JvmStdlibNames.JET_VALUE_PARAMETER_NULLABLE_FIELD, false);
|
||||
nullableInitialized = true;
|
||||
}
|
||||
checkInitialized();
|
||||
return nullable;
|
||||
}
|
||||
|
||||
private boolean receiver;
|
||||
private boolean receiverInitialized = false;
|
||||
public boolean receiver() {
|
||||
if (!receiverInitialized) {
|
||||
receiver = getBooleanAttribute(JvmStdlibNames.JET_VALUE_PARAMETER_RECEIVER_FIELD, false);
|
||||
receiverInitialized = true;
|
||||
}
|
||||
checkInitialized();
|
||||
return receiver;
|
||||
}
|
||||
|
||||
private boolean hasDefaultValue;
|
||||
private boolean hasDefaultValueInitialized = false;
|
||||
public boolean hasDefaultValue() {
|
||||
if (!hasDefaultValueInitialized) {
|
||||
hasDefaultValue = getBooleanAttribute(JvmStdlibNames.JET_VALUE_PARAMETER_HAS_DEFAULT_VALUE_FIELD, false);
|
||||
hasDefaultValueInitialized = true;
|
||||
}
|
||||
checkInitialized();
|
||||
return hasDefaultValue;
|
||||
}
|
||||
|
||||
@@ -84,5 +79,4 @@ public class JetValueParameterAnnotation extends PsiAnnotationWrapper {
|
||||
return new JetValueParameterAnnotation(
|
||||
JavaDescriptorResolver.findAnnotation(psiParameter, JvmStdlibNames.JET_VALUE_PARAMETER.getFqName().getFqName()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+9
-6
@@ -29,21 +29,24 @@ import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
|
||||
* @since 6/1/12
|
||||
*/
|
||||
public class KotlinSignatureAnnotation extends PsiAnnotationWrapper {
|
||||
private String signature;
|
||||
|
||||
public KotlinSignatureAnnotation(@Nullable PsiAnnotation psiAnnotation) {
|
||||
super(psiAnnotation);
|
||||
}
|
||||
|
||||
private String signature;
|
||||
@Override
|
||||
protected void initialize() {
|
||||
signature = StringUtil.unescapeStringCharacters(getStringAttribute(JvmStdlibNames.KOTLIN_SIGNATURE_VALUE_METHOD, ""));
|
||||
}
|
||||
|
||||
public String signature() {
|
||||
if (signature == null) {
|
||||
signature = StringUtil.unescapeStringCharacters(getStringAttribute(JvmStdlibNames.KOTLIN_SIGNATURE_VALUE_METHOD, ""));
|
||||
}
|
||||
checkInitialized();
|
||||
return signature;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static KotlinSignatureAnnotation get(PsiMethod psiClass) {
|
||||
return new KotlinSignatureAnnotation(JavaDescriptorResolver.findAnnotation(psiClass, JvmStdlibNames.KOTLIN_SIGNATURE.getFqName().getFqName()));
|
||||
public static KotlinSignatureAnnotation get(PsiMethod psiMethod) {
|
||||
return new KotlinSignatureAnnotation(JavaDescriptorResolver.findAnnotation(psiMethod, JvmStdlibNames.KOTLIN_SIGNATURE.getFqName().getFqName()));
|
||||
}
|
||||
}
|
||||
|
||||
+30
-5
@@ -17,10 +17,8 @@
|
||||
package org.jetbrains.jet.lang.resolve.java.kt;
|
||||
|
||||
import com.intellij.psi.PsiAnnotation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.BitSet;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
|
||||
|
||||
/**
|
||||
* @author Evgeny Gerashchenko
|
||||
@@ -31,6 +29,33 @@ public abstract class PsiAnnotationWithFlags extends PsiAnnotationWrapper {
|
||||
super(psiAnnotation);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public abstract BitSet flags();
|
||||
@Override
|
||||
protected void initialize() {
|
||||
initialized = getIntAttribute(JvmStdlibNames.JET_FLAGS_FIELD, JvmStdlibNames.FLAGS_DEFAULT_VALUE);
|
||||
}
|
||||
|
||||
public final int flags() {
|
||||
checkInitialized();
|
||||
return initialized;
|
||||
}
|
||||
|
||||
public final boolean hasPropertyFlag() {
|
||||
return (flags() & JvmStdlibNames.FLAG_PROPERTY_BIT) != 0;
|
||||
}
|
||||
|
||||
public final boolean hasForceFinalFlag() {
|
||||
return (flags() & JvmStdlibNames.FLAG_FORCE_FINAL_BIT) != 0;
|
||||
}
|
||||
|
||||
public final boolean hasForceOpenFlag() {
|
||||
return (flags() & JvmStdlibNames.FLAG_FORCE_OPEN_BIT) != 0;
|
||||
}
|
||||
|
||||
public final boolean hasInternalFlag() {
|
||||
return (flags() & JvmStdlibNames.FLAG_INTERNAL_BIT) != 0;
|
||||
|
||||
}
|
||||
public final boolean hasPrivateFlag() {
|
||||
return (flags() & JvmStdlibNames.FLAG_PRIVATE_BIT) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
+14
-9
@@ -26,26 +26,32 @@ import org.jetbrains.annotations.Nullable;
|
||||
public abstract class PsiAnnotationWrapper {
|
||||
|
||||
@Nullable
|
||||
private PsiAnnotation psiAnnotation;
|
||||
private final PsiAnnotation psiAnnotation;
|
||||
|
||||
protected int initialized = -1;
|
||||
|
||||
protected PsiAnnotationWrapper(@Nullable PsiAnnotation psiAnnotation) {
|
||||
this.psiAnnotation = psiAnnotation;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PsiAnnotation getPsiAnnotation() {
|
||||
return psiAnnotation;
|
||||
}
|
||||
|
||||
public boolean isDefined() {
|
||||
return psiAnnotation != null;
|
||||
}
|
||||
|
||||
|
||||
protected abstract void initialize();
|
||||
|
||||
protected void checkInitialized () {
|
||||
if (initialized == -1) {
|
||||
initialized = 0;
|
||||
initialize();
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected String getStringAttribute(String name, String defaultValue) {
|
||||
return PsiAnnotationUtils.getStringAttribute(psiAnnotation, name, defaultValue);
|
||||
}
|
||||
|
||||
|
||||
protected boolean getBooleanAttribute(String name, boolean defaultValue) {
|
||||
return PsiAnnotationUtils.getBooleanAttribute(psiAnnotation, name, defaultValue);
|
||||
}
|
||||
@@ -53,5 +59,4 @@ public abstract class PsiAnnotationWrapper {
|
||||
protected int getIntAttribute(String name, int defaultValue) {
|
||||
return PsiAnnotationUtils.getIntAttribute(psiAnnotation, name, defaultValue);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user