public JavaSymbol(int kind, int flags, @Nullable String name, @Nullable JavaSymbol owner) { this.kind = kind; this.flags = flags; this.name = name; this.owner = owner; this.symbolMetadata = new SymbolMetadataResolve(); this.usagesBuilder = ImmutableList.builder(); }
@CheckForNull private static List<SymbolMetadata.AnnotationValue> valuesForGlobalAnnotation(JavaSymbol method, String annotation) { return Arrays.asList(method, method.enclosingClass(), method.packge()).stream() .map(symbol -> symbol.metadata().valuesForAnnotation(annotation)) .filter(Objects::nonNull) .findFirst() .orElse(null); }
private static boolean differentAnnotations(SymbolMetadataResolve methodMetadata, SymbolMetadataResolve overrideeMetadata) { for (AnnotationInstance annotation : methodMetadata.annotations()) { Type type = annotation.symbol().type(); if (!type.is("java.lang.Override") && !overrideeMetadata.isAnnotatedWith(type.fullyQualifiedName())) { return true; } } return false; } }
@Override public AnnotationVisitor visitAnnotation(String desc, boolean visible) { JavaType annotationType = bytecodeVisitor.convertAsmType(org.objectweb.asm.Type.getType(desc)); AnnotationInstanceResolve annotationInstance = new AnnotationInstanceResolve(annotationType.getSymbol()); methodSymbol.metadata().addAnnotation(annotationInstance); return new BytecodeAnnotationVisitor(annotationInstance, bytecodeVisitor); }
public List<Symbol> metaAnnotations() { return metaAnnotations(new HashSet<>()); }
@Override public AnnotationVisitor visitAnnotation(String desc, boolean visible) { JavaType annotationType = bytecodeVisitor.convertAsmType(org.objectweb.asm.Type.getType(desc), Flags.ANNOTATION); AnnotationInstanceResolve annotationInstance = new AnnotationInstanceResolve(annotationType.getSymbol()); fieldSymbol.metadata().addAnnotation(annotationInstance); return new BytecodeAnnotationVisitor(annotationInstance, bytecodeVisitor); }
public List<Symbol> metaAnnotations() { return metaAnnotations(new HashSet<>()); }
@Override public AnnotationVisitor visitAnnotation(String desc, boolean visible) { JavaType annotationType = bytecodeVisitor.convertAsmType(org.objectweb.asm.Type.getType(desc), Flags.ANNOTATION); AnnotationInstanceResolve annotationInstance = new AnnotationInstanceResolve(annotationType.getSymbol()); methodSymbol.metadata().addAnnotation(annotationInstance); return new BytecodeAnnotationVisitor(annotationInstance, bytecodeVisitor); }
@CheckForNull private static List<SymbolMetadata.AnnotationValue> valuesForGlobalAnnotation(JavaSymbol method, String annotation) { return Arrays.asList(method, method.enclosingClass(), method.packge()).stream() .map(symbol -> symbol.metadata().valuesForAnnotation(annotation)) .filter(Objects::nonNull) .findFirst() .orElse(null); }
public JavaSymbol(int kind, int flags, @Nullable String name, @Nullable JavaSymbol owner) { this.kind = kind; this.flags = flags; this.name = name; this.owner = owner; this.symbolMetadata = new SymbolMetadataResolve(); this.usages = Lists.newArrayList(); }
private static boolean differentAnnotations(SymbolMetadataResolve methodMetadata, SymbolMetadataResolve overrideeMetadata) { for (AnnotationInstance annotation : methodMetadata.annotations()) { Type type = annotation.symbol().type(); if (!type.is("java.lang.Override") && !overrideeMetadata.isAnnotatedWith(type.fullyQualifiedName())) { return true; } } return false; } }
private List<Symbol> metaAnnotations(Set<Type> knownTypes) { List<Symbol> result = new ArrayList<>(); for (AnnotationInstance annotationInstance : annotations) { Symbol annotationSymbol = annotationInstance.symbol(); Type annotationType = annotationSymbol.type(); if (!knownTypes.contains(annotationType)) { knownTypes.add(annotationType); result.add(annotationSymbol); result.addAll(((SymbolMetadataResolve) annotationSymbol.metadata()).metaAnnotations(knownTypes)); } } return new ArrayList<>(result); }
@Override public AnnotationVisitor visitAnnotation(String desc, boolean visible) { JavaType annotationType = convertAsmType(org.objectweb.asm.Type.getType(desc), Flags.ANNOTATION); AnnotationInstanceResolve annotationInstance = new AnnotationInstanceResolve(annotationType.getSymbol()); classSymbol.metadata().addAnnotation(annotationInstance); return new BytecodeAnnotationVisitor(annotationInstance, this); }
private static boolean hasSuppressWarningAnnotation(TypeJavaSymbol symbol) { List<SymbolMetadata.AnnotationValue> annotations = symbol.metadata().valuesForAnnotation("java.lang.SuppressWarnings"); if (annotations != null) { for (SymbolMetadata.AnnotationValue annotationValue : annotations) { if ("serial".equals(stringLiteralValue(annotationValue.value()))) { return true; } } } return false; }
public JavaSymbol(int kind, int flags, @Nullable String name, @Nullable JavaSymbol owner) { this.kind = kind; this.flags = flags; this.name = name; this.owner = owner; this.symbolMetadata = new SymbolMetadataResolve(); this.usagesBuilder = ImmutableList.builder(); }
public static boolean isAnnotatedNullable(Symbol symbol) { return isUsingNullable(symbol) || ((SymbolMetadataResolve) symbol.metadata()).metaAnnotations().stream().anyMatch(NullableAnnotationUtils::isUsingNullable); }
@Override public AnnotationVisitor visitAnnotation(String desc, boolean visible) { JavaType annotationType = convertAsmType(org.objectweb.asm.Type.getType(desc), Flags.ANNOTATION); AnnotationInstanceResolve annotationInstance = new AnnotationInstanceResolve(annotationType.getSymbol()); classSymbol.metadata().addAnnotation(annotationInstance); return new BytecodeAnnotationVisitor(annotationInstance, this); }
private boolean hasSuppressWarningAnnotation(TypeJavaSymbol symbol) { List<SymbolMetadata.AnnotationValue> annotations = symbol.metadata().valuesForAnnotation("java.lang.SuppressWarnings"); if (annotations != null) { for (SymbolMetadata.AnnotationValue annotationValue : annotations) { if ("serial".equals(stringLiteralValue(annotationValue.value()))) { return true; } } } return false; }
public JavaSymbol(int kind, int flags, @Nullable String name, @Nullable JavaSymbol owner) { this.kind = kind; this.flags = flags; this.name = name; this.owner = owner; this.symbolMetadata = new SymbolMetadataResolve(); this.usagesBuilder = ImmutableList.builder(); }
private List<Symbol> metaAnnotations(Set<Type> knownTypes) { List<Symbol> result = new ArrayList<>(); for (AnnotationInstance annotationInstance : annotations) { Symbol annotationSymbol = annotationInstance.symbol(); Type annotationType = annotationSymbol.type(); if (!knownTypes.contains(annotationType)) { knownTypes.add(annotationType); result.add(annotationSymbol); result.addAll(((SymbolMetadataResolve) annotationSymbol.metadata()).metaAnnotations(knownTypes)); } } return new ArrayList<>(result); }