Class DeclarationAnnotationHelper
java.lang.Object
org.benf.cfr.reader.bytecode.analysis.types.DeclarationAnnotationHelper
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
static class
Represents information about where to place declaration andElementType.TYPE_USE
annotations for a place where both can occur.private static class
private static class
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static boolean
areAnnotationsEqual
(List<AnnotationTableEntry> declAnnotations, List<AnnotationTableTypeEntry> typeAnnotations) private static boolean
canTypeAnnotationBeMovedToDecl
(JavaTypeInstance annotatedType, AnnotationTableTypeEntry typeAnnotation, Integer commonInnerAnnotationIndex) Returns whether the type annotation can be moved to the declaration.private static Integer
getCommonInnerClassAnnotationIndex
(List<AnnotationTableTypeEntry> typeAnnotations) Returns for the annotations the common inner class annotation index, ornull
if there is no common index.private static Set<JavaTypeInstance>
getDeclAndTypeUseAnnotationTypes
(List<AnnotationTableEntry> declAnnotations, List<AnnotationTableTypeEntry> typeAnnotations) getDeclarationInfo
(JavaTypeInstance nullableAnnotatedType, List<AnnotationTableEntry> declarationAnnotations, List<AnnotationTableTypeEntry> typeAnnotations) Calculates information about where to place declaration andElementType.TYPE_USE
annotations for a place where both can occur.
-
Field Details
-
EMPTY_DECOMPILER_COMMENTS
-
-
Constructor Details
-
DeclarationAnnotationHelper
private DeclarationAnnotationHelper()
-
-
Method Details
-
getDeclAndTypeUseAnnotationTypes
private static Set<JavaTypeInstance> getDeclAndTypeUseAnnotationTypes(List<AnnotationTableEntry> declAnnotations, List<AnnotationTableTypeEntry> typeAnnotations) -
getCommonInnerClassAnnotationIndex
private static Integer getCommonInnerClassAnnotationIndex(List<AnnotationTableTypeEntry> typeAnnotations) Returns for the annotations the common inner class annotation index, ornull
if there is no common index. For example withA
andB
being inner classes:@TypeUse1 @TypeUse2 A.B f; // Common index: 0 A. @TypeUse1 @TypeUse2 B f; // Common index: 1 @TypeUse1 A.@TypeUse2 B f; // No common index
- Parameters:
typeAnnotations
- For which the common inner annotation index should be determined- Returns:
- Common annotation index or
null
-
canTypeAnnotationBeMovedToDecl
private static boolean canTypeAnnotationBeMovedToDecl(JavaTypeInstance annotatedType, AnnotationTableTypeEntry typeAnnotation, Integer commonInnerAnnotationIndex) Returns whether the type annotation can be moved to the declaration. For example:
The common inner annotation index is used to be not too restrictive if the outer class has no annotations and therefore the type annotation could be moved (relies on// Can be moved public @TypeUse String[] f; // when moved: @TypeUse public String[] f; // Cannot be moved public String @TypeUse[] f;
JavaRefTypeInstance
to only refer to the first annotated type). For example withA
andB
being inner classes:public @TypeUse A.@TypeUse B f; // Not movable // Can be moved if B is not qualified using outer class public @TypeUse1 @TypeUse2 B f;
- Parameters:
annotatedType
- Type to be annotatedtypeAnnotation
- Annotation for the typecommonInnerAnnotationIndex
- Nullable index of the common annotation position for inner classes- Returns:
- Whether the annotation can be moved to the declaration
-
areAnnotationsEqual
private static boolean areAnnotationsEqual(List<AnnotationTableEntry> declAnnotations, List<AnnotationTableTypeEntry> typeAnnotations) -
getDeclarationInfo
public static DeclarationAnnotationHelper.DeclarationAnnotationsInfo getDeclarationInfo(JavaTypeInstance nullableAnnotatedType, List<AnnotationTableEntry> declarationAnnotations, List<AnnotationTableTypeEntry> typeAnnotations) Calculates information about where to place declaration andElementType.TYPE_USE
annotations for a place where both can occur.- Parameters:
nullableAnnotatedType
- Type for which theTYPE_USE
annotations apply,null
if there is no type (e.g. for constructor declarations)declarationAnnotations
- Annotations for the declaration, e.g.ElementType.FIELD
typeAnnotations
- Annotations for the type, i.e.ElementType.TYPE_USE
- Returns:
- Information about how to place the annotations
-