Plugin not work properly in Android Studio

Hi,

I wrote a plugin and worked well in Intellij IDEA.

But when I put it in Android Studio, something strange happened.

There is a feature in my plugin, I will show a class chooser and set a default selected class if exist.

But select method is not working, the folder is collpased.



Here is my code for select class:

GlobalSearchScope scope = module!=null?GlobalSearchScope.moduleScope(module):GlobalSearchScope.projectScope(project);
PsiClass psiClass = JavaPsiFacade.getInstance(project).findClass(defaultName, scope);
//psiClass is not null
if(psiClass!=null){
classChooser = TreeClassChooserFactory.getInstance(project).
createNoInnerClassesScopeChooser("Select Presenter Class", GlobalSearchScope.projectScope(project),
aClass -> true,psiClass);
classChooser.select(psiClass);
}else {
classChooser = initDefaultClassChooser(module);
}

0
4 comments

Which builds of IntelliJ IDEA and Android Studio have you checked?

0

Hi Peter,

Intellij:

IntelliJ IDEA 2018.1.2 (Community Edition)
Build #IC-181.4668.68, built on April 24, 2018
JRE: 1.8.0_152-release-1136-b29 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.13.1

Android Studio:

Android Studio 3.1.2
Build #AI-173.4720617, built on April 14, 2018
JRE: 1.8.0_152-release-1024-b01 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.13.1

0

That's due to a bug in 173.* builds, fixed in 181.*. As a workaround, you could try to do

ApplicationManager.getApplication().invokeLater(() -> classChooser.select(psiClass), ModalityState.any())
0

The workaround is fine, thanks!

0

Please sign in to leave a comment.