Search in sources :

Example 6 with RecordComponentBinding

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

the class ClassFile method addComponentAttributes.

private int addComponentAttributes(RecordComponentBinding recordComponentBinding, int componetAttributeOffset) {
    // See JVMS 14 Table 4.7-C - Record Preview for allowed attributes
    int attributesNumber = 0;
    // add signature attribute
    char[] genericSignature = recordComponentBinding.genericSignature();
    if (genericSignature != null) {
        attributesNumber += generateSignatureAttribute(genericSignature);
    }
    RecordComponent recordComponent = recordComponentBinding.sourceRecordComponent();
    if (recordComponent != null) {
        Annotation[] annotations = recordComponent.annotations;
        if (annotations != null) {
            attributesNumber += generateRuntimeAnnotations(annotations, TagBits.AnnotationForRecordComponent);
        }
        if ((this.produceAttributes & ClassFileConstants.ATTR_TYPE_ANNOTATION) != 0) {
            List<AnnotationContext> allTypeAnnotationContexts = new ArrayList<>();
            if (annotations != null && (recordComponent.bits & ASTNode.HasTypeAnnotations) != 0) {
                recordComponent.getAllAnnotationContexts(AnnotationTargetTypeConstants.FIELD, allTypeAnnotationContexts);
            }
            TypeReference recordComponentType = recordComponent.type;
            if (recordComponentType != null && ((recordComponentType.bits & ASTNode.HasTypeAnnotations) != 0)) {
                recordComponentType.getAllAnnotationContexts(AnnotationTargetTypeConstants.RECORD_COMPONENT, allTypeAnnotationContexts);
            }
            int size = allTypeAnnotationContexts.size();
            attributesNumber = completeRuntimeTypeAnnotations(attributesNumber, null, (node) -> size > 0, () -> allTypeAnnotationContexts);
        }
    }
    if ((recordComponentBinding.tagBits & TagBits.HasMissingType) != 0) {
        this.missingTypes = recordComponentBinding.type.collectMissingTypes(this.missingTypes);
    }
    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) ArrayList(java.util.ArrayList) TypeReference(org.eclipse.jdt.internal.compiler.ast.TypeReference) AnnotationContext(org.eclipse.jdt.internal.compiler.codegen.AnnotationContext) SingleMemberAnnotation(org.eclipse.jdt.internal.compiler.ast.SingleMemberAnnotation) NormalAnnotation(org.eclipse.jdt.internal.compiler.ast.NormalAnnotation) Annotation(org.eclipse.jdt.internal.compiler.ast.Annotation) RecordComponent(org.eclipse.jdt.internal.compiler.ast.RecordComponent)

Example 7 with RecordComponentBinding

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

the class AnnotationDiscoveryVisitor method visit.

@Override
public boolean visit(RecordComponent recordComponent, BlockScope scope) {
    Annotation[] annotations = recordComponent.annotations;
    if (annotations != null) {
        RecordComponentBinding recordComponentBinding = recordComponent.binding;
        if (recordComponentBinding == null) {
            return false;
        }
        ((SourceTypeBinding) recordComponentBinding.declaringRecord).resolveTypeFor(recordComponentBinding);
        if (recordComponent.binding == null) {
            return false;
        }
        this.resolveAnnotations(scope, annotations, recordComponentBinding);
    }
    return false;
}
Also used : RecordComponentBinding(org.eclipse.jdt.internal.compiler.lookup.RecordComponentBinding) SourceTypeBinding(org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding) Annotation(org.eclipse.jdt.internal.compiler.ast.Annotation)

Example 8 with RecordComponentBinding

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

the class ClassFile method getRecordComponent.

private RecordComponent getRecordComponent(ReferenceBinding declaringClass, char[] name) {
    if (declaringClass instanceof SourceTypeBinding) {
        SourceTypeBinding sourceTypeBinding = (SourceTypeBinding) declaringClass;
        RecordComponentBinding rcb = sourceTypeBinding.getRecordComponent(name);
        if (rcb != null) {
            RecordComponent recordComponent = rcb.sourceRecordComponent();
            return recordComponent;
        }
    }
    return null;
}
Also used : RecordComponentBinding(org.eclipse.jdt.internal.compiler.lookup.RecordComponentBinding) SourceTypeBinding(org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding) RecordComponent(org.eclipse.jdt.internal.compiler.ast.RecordComponent)

Aggregations

RecordComponentBinding (org.eclipse.jdt.internal.compiler.lookup.RecordComponentBinding)8 SourceTypeBinding (org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding)8 ReferenceBinding (org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding)5 FieldBinding (org.eclipse.jdt.internal.compiler.lookup.FieldBinding)4 LocalVariableBinding (org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding)4 MethodBinding (org.eclipse.jdt.internal.compiler.lookup.MethodBinding)4 RecordComponent (org.eclipse.jdt.internal.compiler.ast.RecordComponent)3 ParameterizedGenericMethodBinding (org.eclipse.jdt.internal.compiler.lookup.ParameterizedGenericMethodBinding)3 ParameterizedMethodBinding (org.eclipse.jdt.internal.compiler.lookup.ParameterizedMethodBinding)3 ProblemMethodBinding (org.eclipse.jdt.internal.compiler.lookup.ProblemMethodBinding)3 TypeBinding (org.eclipse.jdt.internal.compiler.lookup.TypeBinding)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Annotation (org.eclipse.jdt.internal.compiler.ast.Annotation)2 Argument (org.eclipse.jdt.internal.compiler.ast.Argument)2 AnnotationBinding (org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding)2 ArrayBinding (org.eclipse.jdt.internal.compiler.lookup.ArrayBinding)2 Binding (org.eclipse.jdt.internal.compiler.lookup.Binding)2 ModuleBinding (org.eclipse.jdt.internal.compiler.lookup.ModuleBinding)2 PackageBinding (org.eclipse.jdt.internal.compiler.lookup.PackageBinding)2