Minor, delete/inline methods

This commit is contained in:
Alexander Udalov
2014-03-04 18:19:14 +04:00
parent 4c49c39f8d
commit e017cf76f2
3 changed files with 19 additions and 33 deletions
@@ -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
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor
@@ -57,7 +73,7 @@ class LazyJavaAnnotationDescriptor(
private val _nameToArgument = c.storageManager.createLazyValue {
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.valuesToMap { a -> a.getName() }
@@ -21,13 +21,8 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.PlatformToKotlinClassMap;
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
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.constants.StringValue;
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.name.FqName;
import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe;
@@ -37,12 +32,7 @@ import org.jetbrains.jet.lang.types.lang.PrimitiveType;
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 static final FqName JAVA_LANG_DEPRECATED = new FqName("java.lang.Deprecated");
private static JavaToKotlinClassMap instance = null;
@NotNull
@@ -95,24 +85,9 @@ public class JavaToKotlinClassMap extends JavaToKotlinClassMapBuilder implements
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
private static AnnotationDescriptor getAnnotationDescriptorForJavaLangDeprecated(@NotNull ClassDescriptor annotationClass) {
AnnotationDescriptorImpl annotation = new AnnotationDescriptorImpl();
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;
private static FqName fqNameByClass(@NotNull Class<?> clazz) {
return new FqName(clazz.getCanonicalName());
}
@Override
@@ -51,11 +51,6 @@ public final class DescriptorResolverUtils {
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
public static <D extends CallableMemberDescriptor> Collection<D> resolveOverrides(
@NotNull Name name,