diff --git a/src/main/java/de/espend/idea/php/annotation/annotator/AnnotationDocTagAnnotator.java b/src/main/java/de/espend/idea/php/annotation/annotator/AnnotationDocTagAnnotator.java index 851dca02..f8528708 100644 --- a/src/main/java/de/espend/idea/php/annotation/annotator/AnnotationDocTagAnnotator.java +++ b/src/main/java/de/espend/idea/php/annotation/annotator/AnnotationDocTagAnnotator.java @@ -46,11 +46,6 @@ public void annotate(@NotNull PsiElement psiElement, @NotNull AnnotationHolder h for(PhpAnnotationDocTagAnnotator annotator: AnnotationUtil.EP_DOC_TAG_ANNOTATOR.getExtensions()) { annotator.annotate(parameter); } - - } - - - } diff --git a/src/main/java/de/espend/idea/php/annotation/inspection/ImportUseForAnnotationQuickFix.java b/src/main/java/de/espend/idea/php/annotation/inspection/ImportUseForAnnotationQuickFix.java index 397ffbd2..f701fa92 100644 --- a/src/main/java/de/espend/idea/php/annotation/inspection/ImportUseForAnnotationQuickFix.java +++ b/src/main/java/de/espend/idea/php/annotation/inspection/ImportUseForAnnotationQuickFix.java @@ -8,15 +8,17 @@ import com.intellij.openapi.ui.popup.JBPopupFactory; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; -import com.intellij.ui.components.JBList; import com.jetbrains.php.codeInsight.PhpCodeInsightUtil; import com.jetbrains.php.lang.documentation.phpdoc.psi.tags.PhpDocTag; import com.jetbrains.php.lang.psi.elements.PhpPsiElement; import com.jetbrains.php.refactoring.PhpAliasImporter; +import org.apache.commons.lang.StringUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Collection; +import java.util.List; +import java.util.stream.Collectors; /** * @author Daniel Espendiller @@ -58,28 +60,25 @@ public void invoke(@NotNull Project project, @NotNull PsiFile psiFile, @Nullable return; } - JBList list = new JBList<>(this.classes); - // single item, directly run it if(this.classes.size() == 1) { invoke(startElement, classes.iterator().next()); return; } + // strip first "\" + List classes = this.classes.stream().map(s -> + StringUtils.stripStart(s, "\\")).collect(Collectors.toList() + ); + // suggestion possible import - JBPopupFactory.getInstance().createListPopupBuilder(list) + JBPopupFactory.getInstance().createPopupChooserBuilder(classes) .setTitle("Import: Annotation Suggestion") - .setItemChoosenCallback(() -> { - String selectedValue = list.getSelectedValue(); - - // sub thread run our own action - new WriteCommandAction.Simple(editor.getProject(), "Import: " + selectedValue) { - @Override - protected void run() { - invoke(startElement, selectedValue); - } - }.execute(); - }) + .setItemChosenCallback(selected -> + WriteCommandAction.writeCommandAction(editor.getProject()) + .withName("Import: " + selected) + .run(() -> invoke(startElement, selected)) + ) .createPopup() .showInBestPositionFor(editor); } diff --git a/src/main/java/de/espend/idea/php/annotation/reference/DocTagNameAnnotationReferenceContributor.java b/src/main/java/de/espend/idea/php/annotation/reference/DocTagNameAnnotationReferenceContributor.java index 868958da..e06d59c5 100644 --- a/src/main/java/de/espend/idea/php/annotation/reference/DocTagNameAnnotationReferenceContributor.java +++ b/src/main/java/de/espend/idea/php/annotation/reference/DocTagNameAnnotationReferenceContributor.java @@ -3,15 +3,16 @@ import com.intellij.openapi.util.TextRange; import com.intellij.patterns.PlatformPatterns; import com.intellij.psi.*; -import com.intellij.psi.util.PsiTreeUtil; import com.intellij.util.ProcessingContext; -import com.intellij.util.containers.ContainerUtil; import com.jetbrains.php.lang.documentation.phpdoc.lexer.PhpDocTokenTypes; import com.jetbrains.php.lang.documentation.phpdoc.parser.PhpDocElementTypes; import com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocToken; import com.jetbrains.php.lang.documentation.phpdoc.psi.tags.PhpDocTag; import com.jetbrains.php.lang.psi.PhpPsiUtil; -import com.jetbrains.php.lang.psi.elements.*; +import com.jetbrains.php.lang.psi.elements.PhpClass; +import com.jetbrains.php.lang.psi.elements.PhpNamedElement; +import com.jetbrains.php.lang.psi.elements.PhpUse; +import com.jetbrains.php.lang.psi.elements.Variable; import de.espend.idea.php.annotation.util.AnnotationUtil; import de.espend.idea.php.annotation.util.PhpDocUtil; import de.espend.idea.php.annotation.util.PhpElementsUtil; @@ -19,8 +20,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.Collection; - /** * @author Daniel Espendiller */ diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 88052819..df6803a5 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -60,7 +60,7 @@ - + diff --git a/src/test/java/de/espend/idea/php/annotation/tests/reference/DocTagNameAnnotationReferenceContributorTest.java b/src/test/java/de/espend/idea/php/annotation/tests/reference/DocTagNameAnnotationReferenceContributorTest.java index a78a05c7..1bc880f3 100644 --- a/src/test/java/de/espend/idea/php/annotation/tests/reference/DocTagNameAnnotationReferenceContributorTest.java +++ b/src/test/java/de/espend/idea/php/annotation/tests/reference/DocTagNameAnnotationReferenceContributorTest.java @@ -1,6 +1,5 @@ package de.espend.idea.php.annotation.tests.reference; -import com.intellij.openapi.application.Result; import com.intellij.openapi.command.WriteCommandAction; import com.intellij.psi.PsiFile; import com.jetbrains.php.codeInsight.PhpImportOptimizer; @@ -200,19 +199,7 @@ public void testPhpDocTagsShouldNotBindToVariables() { @NotNull private String optimizeImports(@NotNull String content) { PsiFile psiFile = myFixture.configureByText(PhpFileType.INSTANCE, content); - - new WriteCommandAction(getProject()) { - @Override - protected void run(@NotNull Result result) throws Throwable { - new PhpImportOptimizer().processFile(psiFile).run(); - } - - @Override - public String getGroupID() { - return "Optimize Imports"; - } - }.execute(); - + WriteCommandAction.runWriteCommandAction(getProject(), () -> new PhpImportOptimizer().processFile(psiFile).run()); return psiFile.getText(); } }