private boolean existsFieldWithName(String name) { final PsiField[] allFields = sourceClass.getAllFields(); for (PsiField field : allFields) { if (name.equals(field.getName()) && !fields.contains(field)) { return true; } } return false; }
@Nullable public static PsiField findPropertyField( Project project, PsiClass aClass, String propertyName, boolean isStatic) { PsiField[] fields = aClass.getAllFields(); for (PsiField field : fields) { if (field.hasModifierProperty(PsiModifier.STATIC) != isStatic) continue; if (propertyName.equals(suggestPropertyName(project, field))) return field; } return null; }
private static void addFieldsUsages( final PsiClass aClass, final Processor<UsageInfo> results, final JavaClassFindUsagesOptions options) { if (options.isIncludeInherited) { final PsiManager manager = aClass.getManager(); PsiField[] fields = aClass.getAllFields(); FieldsLoop: for (int i = 0; i < fields.length; i++) { final PsiField field = fields[i]; // filter hidden fields for (int j = 0; j < i; j++) { if (Comparing.strEqual(field.getName(), fields[j].getName())) continue FieldsLoop; } final PsiClass fieldClass = field.getContainingClass(); if (manager.areElementsEquivalent(fieldClass, aClass)) { addElementUsages(fields[i], results, options); } else { ReferencesSearch.search( new ReferencesSearch.SearchParameters( field, options.searchScope, false, options.fastTrack)) .forEach( new ReadActionProcessor<PsiReference>() { @Override public boolean processInReadAction(final PsiReference reference) { addResultFromReference( reference, fieldClass, manager, aClass, results, options); return true; } }); } } } else { PsiField[] fields = ApplicationManager.getApplication() .runReadAction( new Computable<PsiField[]>() { @Override public PsiField[] compute() { return aClass.getFields(); } }); for (PsiField field : fields) { addElementUsages(field, results, options); } } }