Minor, delete/inline methods
This commit is contained in:
+17
-1
@@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2014 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.resolve.java.lazy.descriptors
|
package org.jetbrains.jet.lang.resolve.java.lazy.descriptors
|
||||||
|
|
||||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor
|
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor
|
||||||
@@ -57,7 +73,7 @@ class LazyJavaAnnotationDescriptor(
|
|||||||
|
|
||||||
private val _nameToArgument = c.storageManager.createLazyValue {
|
private val _nameToArgument = c.storageManager.createLazyValue {
|
||||||
var arguments: Collection<JavaAnnotationArgument> = javaAnnotation.getArguments()
|
var arguments: Collection<JavaAnnotationArgument> = javaAnnotation.getArguments()
|
||||||
if (arguments.isEmpty() && _fqName() == JavaToKotlinClassMap.JAVA_LANG_DEPRECATED) {
|
if (arguments.isEmpty() && _fqName()?.asString() == "java.lang.Deprecated") {
|
||||||
arguments = listOf(DEPRECATED_IN_JAVA)
|
arguments = listOf(DEPRECATED_IN_JAVA)
|
||||||
}
|
}
|
||||||
arguments.valuesToMap { a -> a.getName() }
|
arguments.valuesToMap { a -> a.getName() }
|
||||||
|
|||||||
+2
-27
@@ -21,13 +21,8 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import org.jetbrains.jet.lang.PlatformToKotlinClassMap;
|
import org.jetbrains.jet.lang.PlatformToKotlinClassMap;
|
||||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
|
|
||||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
|
||||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptorImpl;
|
|
||||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||||
import org.jetbrains.jet.lang.resolve.constants.StringValue;
|
|
||||||
import org.jetbrains.jet.lang.resolve.java.JvmPrimitiveType;
|
import org.jetbrains.jet.lang.resolve.java.JvmPrimitiveType;
|
||||||
import org.jetbrains.jet.lang.resolve.java.resolver.DescriptorResolverUtils;
|
|
||||||
import org.jetbrains.jet.lang.resolve.java.resolver.TypeUsage;
|
import org.jetbrains.jet.lang.resolve.java.resolver.TypeUsage;
|
||||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||||
import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe;
|
import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe;
|
||||||
@@ -37,12 +32,7 @@ import org.jetbrains.jet.lang.types.lang.PrimitiveType;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames.DEFAULT_ANNOTATION_MEMBER_NAME;
|
|
||||||
import static org.jetbrains.jet.lang.resolve.java.resolver.DescriptorResolverUtils.fqNameByClass;
|
|
||||||
|
|
||||||
public class JavaToKotlinClassMap extends JavaToKotlinClassMapBuilder implements PlatformToKotlinClassMap {
|
public class JavaToKotlinClassMap extends JavaToKotlinClassMapBuilder implements PlatformToKotlinClassMap {
|
||||||
public static final FqName JAVA_LANG_DEPRECATED = new FqName("java.lang.Deprecated");
|
|
||||||
|
|
||||||
private static JavaToKotlinClassMap instance = null;
|
private static JavaToKotlinClassMap instance = null;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -95,24 +85,9 @@ public class JavaToKotlinClassMap extends JavaToKotlinClassMapBuilder implements
|
|||||||
return classDescriptorMap.get(fqName);
|
return classDescriptorMap.get(fqName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public AnnotationDescriptor mapToAnnotationClass(@NotNull FqName fqName) {
|
|
||||||
ClassDescriptor classDescriptor = classDescriptorMap.get(fqName);
|
|
||||||
if (classDescriptor != null && fqName.equals(JAVA_LANG_DEPRECATED)) {
|
|
||||||
return getAnnotationDescriptorForJavaLangDeprecated(classDescriptor);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private static AnnotationDescriptor getAnnotationDescriptorForJavaLangDeprecated(@NotNull ClassDescriptor annotationClass) {
|
private static FqName fqNameByClass(@NotNull Class<?> clazz) {
|
||||||
AnnotationDescriptorImpl annotation = new AnnotationDescriptorImpl();
|
return new FqName(clazz.getCanonicalName());
|
||||||
annotation.setAnnotationType(annotationClass.getDefaultType());
|
|
||||||
ValueParameterDescriptor value =
|
|
||||||
DescriptorResolverUtils.getAnnotationParameterByName(DEFAULT_ANNOTATION_MEMBER_NAME, annotationClass);
|
|
||||||
assert value != null : "kotlin.deprecated must have one parameter called value";
|
|
||||||
annotation.setValueArgument(value, new StringValue("Deprecated in Java", true));
|
|
||||||
return annotation;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
-5
@@ -51,11 +51,6 @@ public final class DescriptorResolverUtils {
|
|||||||
return javaClass.getOriginKind() == JavaClass.OriginKind.COMPILED && javaClass.findAnnotation(KOTLIN_CLASS) != null;
|
return javaClass.getOriginKind() == JavaClass.OriginKind.COMPILED && javaClass.findAnnotation(KOTLIN_CLASS) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public static FqName fqNameByClass(@NotNull Class<?> clazz) {
|
|
||||||
return new FqName(clazz.getCanonicalName());
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static <D extends CallableMemberDescriptor> Collection<D> resolveOverrides(
|
public static <D extends CallableMemberDescriptor> Collection<D> resolveOverrides(
|
||||||
@NotNull Name name,
|
@NotNull Name name,
|
||||||
|
|||||||
Reference in New Issue
Block a user