reflection fix + tests

This commit is contained in:
Konstantin Bulenkov
2012-03-23 18:06:28 +01:00
parent 3f8e4814ae
commit ab3a58a664
12 changed files with 362 additions and 2 deletions
@@ -96,10 +96,20 @@ public class JavaLangClassMemberReference extends PsiReferenceBase<PsiLiteralExp
if (psiClass != null && type != null) {
if (type == Type.DECLARED_FIELD) {
return psiClass.getFields();
} else if (type == Type.DECLARED_METHOD) {
} else if (type == Type.FIELD) {
final List<PsiField> fields = new ArrayList<PsiField>();
for (PsiField field : psiClass.getFields()) {
if (isPublic(field)) {
fields.add(field);
}
}
return fields.toArray();
} else if (type == Type.DECLARED_METHOD || type == Type.METHOD) {
final List<LookupElementBuilder> elements = new ArrayList<LookupElementBuilder>();
for (PsiMethod method : psiClass.getMethods()) {
elements.add(JavaLookupElementBuilder.forMethod(method, PsiSubstitutor.EMPTY).setInsertHandler(this));
if (type == Type.DECLARED_METHOD || isPublic(method)) {
elements.add(JavaLookupElementBuilder.forMethod(method, PsiSubstitutor.EMPTY).setInsertHandler(this));
}
}
return elements.toArray();
}
@@ -126,6 +136,10 @@ public class JavaLangClassMemberReference extends PsiReferenceBase<PsiLiteralExp
}
}
private static boolean isPublic(final PsiMember psiField) {
return psiField.hasModifierProperty(PsiModifier.PUBLIC);
}
private static String getMethodTypes(PsiMethod method) {
final StringBuilder buf = new StringBuilder();
for (PsiParameter parameter : method.getParameterList().getParameters()) {