Skip to content

Commit

Permalink
removed deprecated code usages
Browse files Browse the repository at this point in the history
  • Loading branch information
Haehnchen committed Jun 15, 2019
1 parent 7d7c400 commit d5dd9b9
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}


}



}

Original file line number Diff line number Diff line change
Expand Up @@ -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 <daniel@espendiller.net>
Expand Down Expand Up @@ -58,28 +60,25 @@ public void invoke(@NotNull Project project, @NotNull PsiFile psiFile, @Nullable
return;
}

JBList<String> list = new JBList<>(this.classes);

// single item, directly run it
if(this.classes.size() == 1) {
invoke(startElement, classes.iterator().next());
return;
}

// strip first "\"
List<String> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,23 @@
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;
import org.apache.commons.lang.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Collection;

/**
* @author Daniel Espendiller <daniel@espendiller.net>
*/
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
</change-notes>

<!-- please see http://confluence.jetbrains.net/display/IDEADEV/Build+Number+Ranges for description -->
<idea-version since-build="181.3741"/>
<idea-version since-build="191"/>

<!-- please see http://confluence.jetbrains.net/display/IDEADEV/Plugin+Compatibility+with+IntelliJ+Platform+Products
on how to target different products -->
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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();
}
}

0 comments on commit d5dd9b9

Please sign in to comment.