Get rid of duplicating annotations FQ names usages
E.g. JETBRAINS_NOT_NULL_ANNOTATION were used both in NULLABLE_ANNOTATIONS and for ANNOTATIONS_COPIED_TO_TYPES
This commit is contained in:
+2
-1
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.descriptors.*
|
|||||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||||
import org.jetbrains.kotlin.jvm.compiler.ExpectedLoadErrorsUtil
|
import org.jetbrains.kotlin.jvm.compiler.ExpectedLoadErrorsUtil
|
||||||
import org.jetbrains.kotlin.jvm.compiler.LoadDescriptorUtil
|
import org.jetbrains.kotlin.jvm.compiler.LoadDescriptorUtil
|
||||||
|
import org.jetbrains.kotlin.load.java.ANNOTATIONS_COPIED_TO_TYPES
|
||||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
|
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
|
||||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames.KOTLIN_LOCAL_CLASS
|
import org.jetbrains.kotlin.load.java.JvmAnnotationNames.KOTLIN_LOCAL_CLASS
|
||||||
import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor
|
import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor
|
||||||
@@ -65,7 +66,7 @@ abstract class AbstractJvmRuntimeDescriptorLoaderTest : TestCaseWithTmpdir() {
|
|||||||
withDefinedIn = false
|
withDefinedIn = false
|
||||||
excludedAnnotationClasses = (listOf(
|
excludedAnnotationClasses = (listOf(
|
||||||
FqName(ExpectedLoadErrorsUtil.ANNOTATION_CLASS_NAME)
|
FqName(ExpectedLoadErrorsUtil.ANNOTATION_CLASS_NAME)
|
||||||
) + JvmAnnotationNames.ANNOTATIONS_COPIED_TO_TYPES).toSet()
|
) + ANNOTATIONS_COPIED_TO_TYPES).toSet()
|
||||||
overrideRenderingPolicy = OverrideRenderingPolicy.RENDER_OPEN_OVERRIDE
|
overrideRenderingPolicy = OverrideRenderingPolicy.RENDER_OPEN_OVERRIDE
|
||||||
parameterNameRenderingPolicy = ParameterNameRenderingPolicy.NONE
|
parameterNameRenderingPolicy = ParameterNameRenderingPolicy.NONE
|
||||||
includePropertyConstant = false
|
includePropertyConstant = false
|
||||||
|
|||||||
@@ -62,15 +62,6 @@ public final class JvmAnnotationNames {
|
|||||||
public static final FqName ENHANCED_NULLABILITY_ANNOTATION = new FqName("kotlin.jvm.internal.EnhancedNullability");
|
public static final FqName ENHANCED_NULLABILITY_ANNOTATION = new FqName("kotlin.jvm.internal.EnhancedNullability");
|
||||||
public static final FqName ENHANCED_MUTABILITY_ANNOTATION = new FqName("kotlin.jvm.internal.EnhancedMutability");
|
public static final FqName ENHANCED_MUTABILITY_ANNOTATION = new FqName("kotlin.jvm.internal.EnhancedMutability");
|
||||||
|
|
||||||
// When these annotations appear on a declaration, they are copied to the _type_ of the declaration, becoming type annotations
|
|
||||||
// See also DescriptorRendererOptions#excludedTypeAnnotationClasses
|
|
||||||
public static final Set<FqName> ANNOTATIONS_COPIED_TO_TYPES = SetsKt.setOf(
|
|
||||||
JETBRAINS_READONLY_ANNOTATION,
|
|
||||||
JETBRAINS_MUTABLE_ANNOTATION,
|
|
||||||
JETBRAINS_NOT_NULL_ANNOTATION,
|
|
||||||
JETBRAINS_NULLABLE_ANNOTATION
|
|
||||||
);
|
|
||||||
|
|
||||||
private static final Set<JvmClassName> SPECIAL_ANNOTATIONS = new HashSet<JvmClassName>();
|
private static final Set<JvmClassName> SPECIAL_ANNOTATIONS = new HashSet<JvmClassName>();
|
||||||
private static final Set<JvmClassName> NULLABILITY_ANNOTATIONS = new HashSet<JvmClassName>();
|
private static final Set<JvmClassName> NULLABILITY_ANNOTATIONS = new HashSet<JvmClassName>();
|
||||||
private static final Set<JvmClassName> SPECIAL_META_ANNOTATIONS = new HashSet<JvmClassName>();
|
private static final Set<JvmClassName> SPECIAL_META_ANNOTATIONS = new HashSet<JvmClassName>();
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2015 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.kotlin.load.java
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.name.FqName
|
||||||
|
|
||||||
|
val NULLABLE_ANNOTATIONS = listOf(
|
||||||
|
JvmAnnotationNames.JETBRAINS_NULLABLE_ANNOTATION
|
||||||
|
)
|
||||||
|
|
||||||
|
val NOT_NULL_ANNOTATIONS = listOf(
|
||||||
|
JvmAnnotationNames.JETBRAINS_NOT_NULL_ANNOTATION
|
||||||
|
)
|
||||||
|
|
||||||
|
val READ_ONLY_ANNOTATIONS = listOf(
|
||||||
|
JvmAnnotationNames.JETBRAINS_READONLY_ANNOTATION
|
||||||
|
)
|
||||||
|
|
||||||
|
val MUTABLE_ANNOTATIONS = listOf(
|
||||||
|
JvmAnnotationNames.JETBRAINS_MUTABLE_ANNOTATION
|
||||||
|
)
|
||||||
|
|
||||||
|
// When these annotations appear on a declaration, they are copied to the _type_ of the declaration, becoming type annotations
|
||||||
|
// See also DescriptorRendererOptions#excludedTypeAnnotationClasses
|
||||||
|
val ANNOTATIONS_COPIED_TO_TYPES: Set<FqName> = listOf(
|
||||||
|
NULLABLE_ANNOTATIONS, NOT_NULL_ANNOTATIONS, READ_ONLY_ANNOTATIONS, MUTABLE_ANNOTATIONS
|
||||||
|
).flatMap { it }.toSet()
|
||||||
+1
@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
|||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.CompositeAnnotations
|
import org.jetbrains.kotlin.descriptors.annotations.CompositeAnnotations
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.FilteredAnnotations
|
import org.jetbrains.kotlin.descriptors.annotations.FilteredAnnotations
|
||||||
|
import org.jetbrains.kotlin.load.java.ANNOTATIONS_COPIED_TO_TYPES
|
||||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames.*
|
import org.jetbrains.kotlin.load.java.JvmAnnotationNames.*
|
||||||
import org.jetbrains.kotlin.load.java.components.TypeUsage
|
import org.jetbrains.kotlin.load.java.components.TypeUsage
|
||||||
import org.jetbrains.kotlin.load.java.components.TypeUsage.*
|
import org.jetbrains.kotlin.load.java.components.TypeUsage.*
|
||||||
|
|||||||
+1
-17
@@ -17,7 +17,7 @@
|
|||||||
package org.jetbrains.kotlin.load.java.typeEnhancement
|
package org.jetbrains.kotlin.load.java.typeEnhancement
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
|
import org.jetbrains.kotlin.load.java.*
|
||||||
import org.jetbrains.kotlin.load.java.typeEnhancement.MutabilityQualifier.MUTABLE
|
import org.jetbrains.kotlin.load.java.typeEnhancement.MutabilityQualifier.MUTABLE
|
||||||
import org.jetbrains.kotlin.load.java.typeEnhancement.MutabilityQualifier.READ_ONLY
|
import org.jetbrains.kotlin.load.java.typeEnhancement.MutabilityQualifier.READ_ONLY
|
||||||
import org.jetbrains.kotlin.load.java.typeEnhancement.NullabilityQualifier.NOT_NULL
|
import org.jetbrains.kotlin.load.java.typeEnhancement.NullabilityQualifier.NOT_NULL
|
||||||
@@ -35,27 +35,11 @@ enum class NullabilityQualifier {
|
|||||||
NOT_NULL
|
NOT_NULL
|
||||||
}
|
}
|
||||||
|
|
||||||
private val NULLABLE_ANNOTATIONS = listOf(
|
|
||||||
JvmAnnotationNames.JETBRAINS_NULLABLE_ANNOTATION
|
|
||||||
)
|
|
||||||
|
|
||||||
private val NOT_NULL_ANNOTATIONS = listOf(
|
|
||||||
JvmAnnotationNames.JETBRAINS_NOT_NULL_ANNOTATION
|
|
||||||
)
|
|
||||||
|
|
||||||
enum class MutabilityQualifier {
|
enum class MutabilityQualifier {
|
||||||
READ_ONLY,
|
READ_ONLY,
|
||||||
MUTABLE
|
MUTABLE
|
||||||
}
|
}
|
||||||
|
|
||||||
private val READ_ONLY_ANNOTATIONS = listOf(
|
|
||||||
JvmAnnotationNames.JETBRAINS_READONLY_ANNOTATION
|
|
||||||
)
|
|
||||||
|
|
||||||
private val MUTABLE_ANNOTATIONS = listOf(
|
|
||||||
JvmAnnotationNames.JETBRAINS_MUTABLE_ANNOTATION
|
|
||||||
)
|
|
||||||
|
|
||||||
class JavaTypeQualifiers(
|
class JavaTypeQualifiers(
|
||||||
val nullability: NullabilityQualifier?,
|
val nullability: NullabilityQualifier?,
|
||||||
val mutability: MutabilityQualifier?
|
val mutability: MutabilityQualifier?
|
||||||
|
|||||||
+2
-2
@@ -22,7 +22,7 @@ import com.intellij.psi.stubs.StubElement
|
|||||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||||
import org.jetbrains.kotlin.lexer.KtModifierKeywordToken
|
import org.jetbrains.kotlin.lexer.KtModifierKeywordToken
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens
|
import org.jetbrains.kotlin.lexer.KtTokens
|
||||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
|
import org.jetbrains.kotlin.load.java.ANNOTATIONS_COPIED_TO_TYPES
|
||||||
import org.jetbrains.kotlin.name.ClassId
|
import org.jetbrains.kotlin.name.ClassId
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
@@ -47,7 +47,7 @@ class TypeClsStubBuilder(private val c: ClsStubBuilderContext) {
|
|||||||
|
|
||||||
val annotations = c.components.annotationLoader.loadTypeAnnotations(type, c.nameResolver).filterNot {
|
val annotations = c.components.annotationLoader.loadTypeAnnotations(type, c.nameResolver).filterNot {
|
||||||
val isTopLevelClass = !it.isNestedClass
|
val isTopLevelClass = !it.isNestedClass
|
||||||
isTopLevelClass && it.asSingleFqName() in JvmAnnotationNames.ANNOTATIONS_COPIED_TO_TYPES
|
isTopLevelClass && it.asSingleFqName() in ANNOTATIONS_COPIED_TO_TYPES
|
||||||
}
|
}
|
||||||
|
|
||||||
val effectiveParent =
|
val effectiveParent =
|
||||||
|
|||||||
Reference in New Issue
Block a user