Class DeclarationAnnotationHelper
- java.lang.Object
-
- org.benf.cfr.reader.bytecode.analysis.types.DeclarationAnnotationHelper
-
public class DeclarationAnnotationHelper extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
DeclarationAnnotationHelper.ArrayCountingIterator
static class
DeclarationAnnotationHelper.DeclarationAnnotationsInfo
Represents information about where to place declaration andElementType.TYPE_USE
annotations for a place where both can occur.private static class
DeclarationAnnotationHelper.NestedCountingIterator
private static class
DeclarationAnnotationHelper.SinglePartTypeIterator
-
Field Summary
Fields Modifier and Type Field Description private static DecompilerComments
EMPTY_DECOMPILER_COMMENTS
-
Constructor Summary
Constructors Modifier Constructor Description private
DeclarationAnnotationHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static boolean
areAnnotationsEqual(java.util.List<AnnotationTableEntry> declAnnotations, java.util.List<AnnotationTableTypeEntry> typeAnnotations)
private static boolean
canTypeAnnotationBeMovedToDecl(JavaTypeInstance annotatedType, AnnotationTableTypeEntry typeAnnotation, java.lang.Integer commonInnerAnnotationIndex)
Returns whether the type annotation can be moved to the declaration.private static java.lang.Integer
getCommonInnerClassAnnotationIndex(java.util.List<AnnotationTableTypeEntry> typeAnnotations)
Returns for the annotations the common inner class annotation index, ornull
if there is no common index.private static java.util.Set<JavaTypeInstance>
getDeclAndTypeUseAnnotationTypes(java.util.List<AnnotationTableEntry> declAnnotations, java.util.List<AnnotationTableTypeEntry> typeAnnotations)
static DeclarationAnnotationHelper.DeclarationAnnotationsInfo
getDeclarationInfo(JavaTypeInstance nullableAnnotatedType, java.util.List<AnnotationTableEntry> declarationAnnotations, java.util.List<AnnotationTableTypeEntry> typeAnnotations)
Calculates information about where to place declaration andElementType.TYPE_USE
annotations for a place where both can occur.
-
-
-
Field Detail
-
EMPTY_DECOMPILER_COMMENTS
private static final DecompilerComments EMPTY_DECOMPILER_COMMENTS
-
-
Method Detail
-
getDeclAndTypeUseAnnotationTypes
private static java.util.Set<JavaTypeInstance> getDeclAndTypeUseAnnotationTypes(java.util.List<AnnotationTableEntry> declAnnotations, java.util.List<AnnotationTableTypeEntry> typeAnnotations)
-
getCommonInnerClassAnnotationIndex
private static java.lang.Integer getCommonInnerClassAnnotationIndex(java.util.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:{@code
- 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, java.lang.Integer commonInnerAnnotationIndex)
Returns whether the type annotation can be moved to the declaration. For example:{@code // Can be moved public @TypeUse String[] f; // when moved:
- 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(java.util.List<AnnotationTableEntry> declAnnotations, java.util.List<AnnotationTableTypeEntry> typeAnnotations)
-
getDeclarationInfo
public static DeclarationAnnotationHelper.DeclarationAnnotationsInfo getDeclarationInfo(JavaTypeInstance nullableAnnotatedType, java.util.List<AnnotationTableEntry> declarationAnnotations, java.util.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
-
-