Search in sources :

Example 1 with TypeAnnotationCodeStream

use of org.eclipse.jdt.internal.compiler.codegen.TypeAnnotationCodeStream in project bazel-jdt-java-toolchain by salesforce.

the class ClassFile method generateTypeAnnotationsOnCodeAttribute.

public int generateTypeAnnotationsOnCodeAttribute() {
    int attributesNumber = 0;
    List<AnnotationContext> allTypeAnnotationContexts = ((TypeAnnotationCodeStream) this.codeStream).allTypeAnnotationContexts;
    for (int i = 0, max = this.codeStream.allLocalsCounter; i < max; i++) {
        LocalVariableBinding localVariable = this.codeStream.locals[i];
        if (localVariable.isCatchParameter())
            continue;
        LocalDeclaration declaration = localVariable.declaration;
        if (declaration == null || (declaration.isArgument() && ((declaration.bits & ASTNode.IsUnionType) == 0)) || (localVariable.initializationCount == 0) || ((declaration.bits & ASTNode.HasTypeAnnotations) == 0)) {
            continue;
        }
        int targetType = ((localVariable.tagBits & TagBits.IsResource) == 0) ? AnnotationTargetTypeConstants.LOCAL_VARIABLE : AnnotationTargetTypeConstants.RESOURCE_VARIABLE;
        declaration.getAllAnnotationContexts(targetType, localVariable, allTypeAnnotationContexts);
    }
    ExceptionLabel[] exceptionLabels = this.codeStream.exceptionLabels;
    for (int i = 0, max = this.codeStream.exceptionLabelsCounter; i < max; i++) {
        ExceptionLabel exceptionLabel = exceptionLabels[i];
        if (exceptionLabel.exceptionTypeReference != null && (exceptionLabel.exceptionTypeReference.bits & ASTNode.HasTypeAnnotations) != 0) {
            exceptionLabel.exceptionTypeReference.getAllAnnotationContexts(AnnotationTargetTypeConstants.EXCEPTION_PARAMETER, i, allTypeAnnotationContexts, exceptionLabel.se7Annotations);
        }
    }
    int size = allTypeAnnotationContexts.size();
    attributesNumber = completeRuntimeTypeAnnotations(attributesNumber, null, (node) -> size > 0, () -> allTypeAnnotationContexts);
    return attributesNumber;
}
Also used : TypeAnnotationCodeStream(org.eclipse.jdt.internal.compiler.codegen.TypeAnnotationCodeStream) Arrays(java.util.Arrays) QualifiedNameReference(org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference) OpensStatement(org.eclipse.jdt.internal.compiler.ast.OpensStatement) ClassLiteralAccess(org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess) Receiver(org.eclipse.jdt.internal.compiler.ast.Receiver) LocalVariableBinding(org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding) ProblemSeverities(org.eclipse.jdt.internal.compiler.problem.ProblemSeverities) FieldBinding(org.eclipse.jdt.internal.compiler.lookup.FieldBinding) ModuleBinding(org.eclipse.jdt.internal.compiler.lookup.ModuleBinding) AnnotationMethodDeclaration(org.eclipse.jdt.internal.compiler.ast.AnnotationMethodDeclaration) MethodScope(org.eclipse.jdt.internal.compiler.lookup.MethodScope) PolymorphicMethodBinding(org.eclipse.jdt.internal.compiler.lookup.PolymorphicMethodBinding) MemberValuePair(org.eclipse.jdt.internal.compiler.ast.MemberValuePair) ShouldNotImplement(org.eclipse.jdt.internal.compiler.problem.ShouldNotImplement) Expression(org.eclipse.jdt.internal.compiler.ast.Expression) TagBits(org.eclipse.jdt.internal.compiler.lookup.TagBits) Map(java.util.Map) TypeBinding(org.eclipse.jdt.internal.compiler.lookup.TypeBinding) VerificationTypeInfo(org.eclipse.jdt.internal.compiler.codegen.VerificationTypeInfo) FieldDeclaration(org.eclipse.jdt.internal.compiler.ast.FieldDeclaration) Messages(org.eclipse.jdt.internal.compiler.util.Messages) MethodBinding(org.eclipse.jdt.internal.compiler.lookup.MethodBinding) Argument(org.eclipse.jdt.internal.compiler.ast.Argument) Predicate(java.util.function.Predicate) ProblemReasons(org.eclipse.jdt.internal.compiler.lookup.ProblemReasons) CategorizedProblem(org.eclipse.jdt.core.compiler.CategorizedProblem) SyntheticMethodBinding(org.eclipse.jdt.internal.compiler.lookup.SyntheticMethodBinding) Set(java.util.Set) RecordComponent(org.eclipse.jdt.internal.compiler.ast.RecordComponent) TypeReference(org.eclipse.jdt.internal.compiler.ast.TypeReference) Collectors(java.util.stream.Collectors) CaseStatement(org.eclipse.jdt.internal.compiler.ast.CaseStatement) SingleMemberAnnotation(org.eclipse.jdt.internal.compiler.ast.SingleMemberAnnotation) NormalAnnotation(org.eclipse.jdt.internal.compiler.ast.NormalAnnotation) TypeParameter(org.eclipse.jdt.internal.compiler.ast.TypeParameter) ArrayBinding(org.eclipse.jdt.internal.compiler.lookup.ArrayBinding) List(java.util.List) Constant(org.eclipse.jdt.internal.compiler.impl.Constant) TypeIds(org.eclipse.jdt.internal.compiler.lookup.TypeIds) Util(org.eclipse.jdt.internal.compiler.util.Util) SingleNameReference(org.eclipse.jdt.internal.compiler.ast.SingleNameReference) Annotation(org.eclipse.jdt.internal.compiler.ast.Annotation) IProblem(org.eclipse.jdt.core.compiler.IProblem) TypeDeclaration(org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) CompilerOptions(org.eclipse.jdt.internal.compiler.impl.CompilerOptions) AnnotationContext(org.eclipse.jdt.internal.compiler.codegen.AnnotationContext) CompilationUnitDeclaration(org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration) ClassFileConstants(org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants) AnnotationTargetTypeConstants(org.eclipse.jdt.internal.compiler.codegen.AnnotationTargetTypeConstants) StringLiteral(org.eclipse.jdt.internal.compiler.ast.StringLiteral) SourceTypeBinding(org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding) LambdaExpression(org.eclipse.jdt.internal.compiler.ast.LambdaExpression) HashMap(java.util.HashMap) ASTNode(org.eclipse.jdt.internal.compiler.ast.ASTNode) RequiresStatement(org.eclipse.jdt.internal.compiler.ast.RequiresStatement) Opcodes(org.eclipse.jdt.internal.compiler.codegen.Opcodes) AbortType(org.eclipse.jdt.internal.compiler.problem.AbortType) SyntheticArgumentBinding(org.eclipse.jdt.internal.compiler.lookup.SyntheticArgumentBinding) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) StackMapFrame(org.eclipse.jdt.internal.compiler.codegen.StackMapFrame) Binding(org.eclipse.jdt.internal.compiler.lookup.Binding) ExceptionLabel(org.eclipse.jdt.internal.compiler.codegen.ExceptionLabel) FunctionalExpression(org.eclipse.jdt.internal.compiler.ast.FunctionalExpression) ReferenceExpression(org.eclipse.jdt.internal.compiler.ast.ReferenceExpression) AttributeNamesConstants(org.eclipse.jdt.internal.compiler.codegen.AttributeNamesConstants) MethodDeclaration(org.eclipse.jdt.internal.compiler.ast.MethodDeclaration) SwitchStatement(org.eclipse.jdt.internal.compiler.ast.SwitchStatement) ExceptionMarker(org.eclipse.jdt.internal.compiler.codegen.StackMapFrameCodeStream.ExceptionMarker) LookupEnvironment(org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment) TypeVariableBinding(org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding) Scope(org.eclipse.jdt.internal.compiler.lookup.Scope) Iterator(java.util.Iterator) ArrayInitializer(org.eclipse.jdt.internal.compiler.ast.ArrayInitializer) ReferenceBinding(org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding) ModuleDeclaration(org.eclipse.jdt.internal.compiler.ast.ModuleDeclaration) CodeStream(org.eclipse.jdt.internal.compiler.codegen.CodeStream) LocalTypeBinding(org.eclipse.jdt.internal.compiler.lookup.LocalTypeBinding) ProblemReferenceBinding(org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding) LocalDeclaration(org.eclipse.jdt.internal.compiler.ast.LocalDeclaration) CharOperation(org.eclipse.jdt.core.compiler.CharOperation) StackMapFrameCodeStream(org.eclipse.jdt.internal.compiler.codegen.StackMapFrameCodeStream) ExportsStatement(org.eclipse.jdt.internal.compiler.ast.ExportsStatement) TypeConstants(org.eclipse.jdt.internal.compiler.lookup.TypeConstants) AbortMethod(org.eclipse.jdt.internal.compiler.problem.AbortMethod) StringConstant(org.eclipse.jdt.internal.compiler.impl.StringConstant) AbstractMethodDeclaration(org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration) Comparator(java.util.Comparator) Collections(java.util.Collections) ConstantPool(org.eclipse.jdt.internal.compiler.codegen.ConstantPool) RecordComponentBinding(org.eclipse.jdt.internal.compiler.lookup.RecordComponentBinding) LocalDeclaration(org.eclipse.jdt.internal.compiler.ast.LocalDeclaration) ExceptionLabel(org.eclipse.jdt.internal.compiler.codegen.ExceptionLabel) TypeAnnotationCodeStream(org.eclipse.jdt.internal.compiler.codegen.TypeAnnotationCodeStream) AnnotationContext(org.eclipse.jdt.internal.compiler.codegen.AnnotationContext) LocalVariableBinding(org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding)

Aggregations

ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Predicate (java.util.function.Predicate)1 Supplier (java.util.function.Supplier)1 Collectors (java.util.stream.Collectors)1 CategorizedProblem (org.eclipse.jdt.core.compiler.CategorizedProblem)1 CharOperation (org.eclipse.jdt.core.compiler.CharOperation)1 IProblem (org.eclipse.jdt.core.compiler.IProblem)1 ASTNode (org.eclipse.jdt.internal.compiler.ast.ASTNode)1 AbstractMethodDeclaration (org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration)1 Annotation (org.eclipse.jdt.internal.compiler.ast.Annotation)1 AnnotationMethodDeclaration (org.eclipse.jdt.internal.compiler.ast.AnnotationMethodDeclaration)1