@Override public void visit(Field obj) { super.visit(obj); FieldAnnotation f = FieldAnnotation.fromVisitedField(this); declaredFields.add(f); }
@Nonnull public BugInstance addField(PreorderVisitor visitor) { FieldAnnotation fieldAnnotation = FieldAnnotation.fromVisitedField(visitor); return addField(fieldAnnotation); }
/** * Add a field annotation for the field which is being visited by given * visitor. * * @param visitor * the visitor * @return this object */ @Nonnull public BugInstance addVisitedField(PreorderVisitor visitor) { FieldAnnotation f = FieldAnnotation.fromVisitedField(visitor); addField(f); return this; }
@Override public void visitAnnotation(String annotationClass, Map<String, ElementValue> map, boolean runtimeVisible) { if (!visitingField()) { return; } if (UnreadFields.isInjectionAttribute(annotationClass)) { containerFields.add(FieldAnnotation.fromVisitedField(this)); } }
private void suppressWarning(String pattern) { String className = getDottedClassName(); ClassAnnotation clazz = new ClassAnnotation(className); if (className.endsWith(".package-info")) { suppressionMatcher.addPackageSuppressor(new PackageWarningSuppressor(pattern, getPackageName().replace('/', '.'))); } else if (visitingMethod()) { suppressionMatcher .addSuppressor(new MethodWarningSuppressor(pattern, clazz, MethodAnnotation.fromVisitedMethod(this))); } else if (visitingField()) { suppressionMatcher.addSuppressor(new FieldWarningSuppressor(pattern, clazz, FieldAnnotation.fromVisitedField(this))); } else { suppressionMatcher.addSuppressor(new ClassWarningSuppressor(pattern, clazz)); } }
@Nonnull public BugInstance addField(PreorderVisitor visitor) { FieldAnnotation fieldAnnotation = FieldAnnotation.fromVisitedField(visitor); return addField(fieldAnnotation); }
@Override public void visit(Field obj) { super.visit(obj); FieldAnnotation f = FieldAnnotation.fromVisitedField(this); declaredFields.add(f); }
/** * Add a field annotation for the field which is being visited by given * visitor. * * @param visitor * the visitor * @return this object */ @Nonnull public BugInstance addVisitedField(PreorderVisitor visitor) { FieldAnnotation f = FieldAnnotation.fromVisitedField(visitor); addField(f); return this; }
@Override public void visitAnnotation(String annotationClass, Map<String, ElementValue> map, boolean runtimeVisible) { if (!visitingField()) { return; } if (UnreadFields.isInjectionAttribute(annotationClass)) { containerFields.add(FieldAnnotation.fromVisitedField(this)); } }
/** * looks for fields that are JLabels and stores them in a set * * @param obj * the field object of the current field */ @Override public void visitField(Field obj) { String fieldSig = obj.getSignature(); if ("Ljavax/swing/JLabel;".equals(fieldSig)) { FieldAnnotation fa = FieldAnnotation.fromVisitedField(this); fieldLabels.add(XFactory.createXField(fa)); } }
/** * looks for fields that are JLabels and stores them in a set * * @param obj * the field object of the current field */ @Override public void visitField(Field obj) { String fieldSig = obj.getSignature(); if ("Ljavax/swing/JLabel;".equals(fieldSig)) { FieldAnnotation fa = FieldAnnotation.fromVisitedField(this); fieldLabels.add(XFactory.createXField(fa)); } }
/** * implements the visitor to find collection fields * * @param obj * the context object of the currently parse field */ @Override public void visitField(Field obj) { if (obj.isPrivate()) { String signature = obj.getSignature(); if (signature.startsWith(Values.SIG_QUALIFIED_CLASS_PREFIX)) { try { JavaClass cls = Repository.lookupClass(SignatureUtils.stripSignature(signature)); if (cls.implementationOf(collectionClass) || cls.implementationOf(mapClass)) { FieldAnnotation fa = FieldAnnotation.fromVisitedField(this); collectionFields.put(fa.getFieldName(), new FieldInfo(fa)); } } catch (ClassNotFoundException cnfe) { bugReporter.reportMissingClass(cnfe); } } } }
/** * implements the visitor to find collection fields * * @param obj * the context object of the currently parse field */ @Override public void visitField(Field obj) { if (obj.isPrivate()) { String signature = obj.getSignature(); if (signature.startsWith(Values.SIG_QUALIFIED_CLASS_PREFIX)) { try { JavaClass cls = Repository.lookupClass(SignatureUtils.stripSignature(signature)); if (cls.implementationOf(collectionClass) || cls.implementationOf(mapClass)) { FieldAnnotation fa = FieldAnnotation.fromVisitedField(this); collectionFields.put(fa.getFieldName(), new FieldInfo(fa)); } } catch (ClassNotFoundException cnfe) { bugReporter.reportMissingClass(cnfe); } } } }
private void suppressWarning(String pattern) { String className = getDottedClassName(); ClassAnnotation clazz = new ClassAnnotation(className); if (className.endsWith(".package-info")) { suppressionMatcher.addPackageSuppressor(new PackageWarningSuppressor(pattern, getPackageName().replace('/', '.'))); } else if (visitingMethod()) { suppressionMatcher .addSuppressor(new MethodWarningSuppressor(pattern, clazz, MethodAnnotation.fromVisitedMethod(this))); } else if (visitingField()) { suppressionMatcher.addSuppressor(new FieldWarningSuppressor(pattern, clazz, FieldAnnotation.fromVisitedField(this))); } else { suppressionMatcher.addSuppressor(new ClassWarningSuppressor(pattern, clazz)); } }