use of com.intellij.psi.impl.source.PsiMethodImpl in project android by JetBrains.
the class OnClickEnumSupport method getAllValues.
@Override
@NotNull
public List<ValueWithDisplayString> getAllValues() {
Module module = myProperty.getModel().getModule();
Configuration configuration = myProperty.getModel().getConfiguration();
String activityClassName = configuration.getActivity();
JavaPsiFacade facade = JavaPsiFacade.getInstance(module.getProject());
Collection<PsiClass> classes;
if (activityClassName != null) {
if (activityClassName.startsWith(".")) {
MergedManifest manifest = MergedManifest.get(module);
String pkg = StringUtil.notNullize(manifest.getPackage());
activityClassName = pkg + activityClassName;
}
PsiClass activityClass = facade.findClass(activityClassName, module.getModuleScope());
if (activityClass != null) {
classes = Collections.singletonList(activityClass);
} else {
classes = Collections.emptyList();
}
} else {
GlobalSearchScope scope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module, false);
PsiClass activityClass = facade.findClass(CLASS_ACTIVITY, scope);
if (activityClass != null) {
classes = ClassInheritorsSearch.search(activityClass, scope, true).findAll();
} else {
classes = Collections.emptyList();
}
}
List<ValueWithDisplayString> values = new ArrayList<>();
Set<String> found = new HashSet<>();
for (PsiClass psiClass : classes) {
for (PsiMethod method : psiClass.getAllMethods()) {
if (OnClickConverter.CONVERTER_FOR_LAYOUT.checkSignature(method) && found.add(method.getName()) && method instanceof PsiMethodImpl) {
values.add(new ValueWithDisplayString(method.getName(), method.getName(), psiClass.getName()));
}
}
}
return values;
}
Aggregations