Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace some deprecated usages #2304

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pluginVersion = 2022.1.264
# See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
# for insight into build numbers and IntelliJ Platform versions.
# we are able to support a minimum version having at least "TwigElementTypes.ARRAY_LITERAL"
pluginSinceBuild = 233
pluginSinceBuild = 233.11799.241
pluginUntilBuild =

# IntelliJ Platform Properties -> https://github.com/JetBrains/gradle-intellij-plugin#intellij-platform-properties
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package fr.adrienbrault.idea.symfony2plugin;

import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.intellij.openapi.project.Project;
Expand Down Expand Up @@ -98,7 +97,7 @@ public class Settings implements PersistentStateComponent<Settings> {
public List<MethodSignatureSetting> methodSignatureSettings = new ArrayList<>();

public static Settings getInstance(Project project) {
return ServiceManager.getService(project, Settings.class);
return project.getService(Settings.class);
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package fr.adrienbrault.idea.symfony2plugin;

import com.intellij.openapi.util.IconLoader;
import com.intellij.util.ui.UIUtil;
import com.intellij.util.ui.ImageUtil;

import javax.swing.*;
import java.awt.*;
Expand Down Expand Up @@ -84,7 +84,7 @@ public static Image getImage(Icon icon) {

int width = icon.getIconWidth();
int height = icon.getIconHeight();
BufferedImage image = UIUtil.createImage(width, height, BufferedImage.TYPE_INT_ARGB);
BufferedImage image = ImageUtil.createImage(width, height, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2 = (Graphics2D) image.getGraphics();
icon.paintIcon(null, g2, 0, 0);
return image;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package fr.adrienbrault.idea.symfony2plugin.action;

import com.intellij.openapi.actionSystem.ActionUpdateThread;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.editor.Editor;
Expand Down Expand Up @@ -31,6 +32,10 @@ public SymfonyContainerServiceBuilder() {
super("Create Service", "Generate a new Service definition from class name", Symfony2Icons.SYMFONY);
}

public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.BGT;
}

public void update(AnActionEvent event) {
Project project = event.getData(PlatformDataKeys.PROJECT);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,13 +262,13 @@ public void processElementsWithName(@NotNull String name, @NotNull Processor<? s

@NotNull
@Override
public String[] getNames(Project project, boolean includeNonProjectItems) {
public String @NotNull [] getNames(Project project, boolean includeNonProjectItems) {
return new String[0];
}

@NotNull
@Override
public NavigationItem[] getItemsByName(String name, String pattern, Project project, boolean includeNonProjectItems) {
public NavigationItem @NotNull [] getItemsByName(String name, String pattern, Project project, boolean includeNonProjectItems) {
return new NavigationItem[0];
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package fr.adrienbrault.idea.symfony2plugin.action;

import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.openapi.actionSystem.ActionUpdateThread;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.application.ApplicationManager;
Expand All @@ -23,6 +24,7 @@
import fr.adrienbrault.idea.symfony2plugin.translation.form.TranslatorKeyExtractorDialog;
import fr.adrienbrault.idea.symfony2plugin.translation.util.TranslationInsertUtil;
import fr.adrienbrault.idea.symfony2plugin.util.IdeHelper;
import org.jetbrains.annotations.NotNull;

import java.awt.*;
import java.util.*;
Expand All @@ -38,6 +40,11 @@ public TwigExtractLanguageAction() {
super("Extract Translation", "Extract Translation Key", Symfony2Icons.SYMFONY);
}

@Override
public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.BGT;
}

public void update(AnActionEvent event) {
Project project = event.getData(PlatformDataKeys.PROJECT);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ private void classNameMarker(@NotNull Project project, @NotNull PsiElement psiEl
// via resource include
Pair<ClassServiceDefinitionTargetLazyValue, Collection<ContainerService>> serviceDefinitionsOfResource = ServiceIndexUtil.findServiceDefinitionsOfResourceLazy((PhpClass) phpClassContext);
if (serviceDefinitionsOfResource != null) {
LayeredIcon serviceLineMarkerLayer = new LayeredIcon(serviceLineMarker, AllIcons.Modules.SourceRootFileLayer);
LayeredIcon serviceLineMarkerLayer = LayeredIcon.layeredIcon(new Icon[]{serviceLineMarker, AllIcons.Modules.SourceRootFileLayer});
serviceLineMarkerLayer.setIcon(AllIcons.Modules.SourceRootFileLayer, 1, SwingConstants.CENTER);

serviceLineMarker = serviceLineMarkerLayer;
Expand All @@ -143,7 +143,7 @@ private void classNameMarker(@NotNull Project project, @NotNull PsiElement psiEl
}

if (!tags.isEmpty()) {
LayeredIcon serviceLineMarkerLayer = new LayeredIcon(serviceLineMarker, AllIcons.Nodes.TabPin);
LayeredIcon serviceLineMarkerLayer = LayeredIcon.layeredIcon(new Icon[] {serviceLineMarker, AllIcons.Nodes.TabPin});
serviceLineMarkerLayer.setIcon(AllIcons.Nodes.TabPin, 1, SwingConstants.CENTER);

serviceLineMarker = serviceLineMarkerLayer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
import fr.adrienbrault.idea.symfony2plugin.Symfony2ProjectComponent;
import fr.adrienbrault.idea.symfony2plugin.util.completion.PhpClassReferenceInsertHandler;
import fr.adrienbrault.idea.symfony2plugin.util.service.ServiceXmlParserFactory;
import gnu.trove.THashSet;
import one.util.streamex.StreamEx;
import org.jetbrains.annotations.NotNull;

import java.util.Collection;
import java.util.HashSet;
import java.util.Map;

/**
Expand Down Expand Up @@ -58,6 +58,6 @@ public void addCompletions(@NotNull CompletionParameters parameters, ProcessingC
*/
public static Collection<PhpClass> filterByNamespace(@NotNull Collection<PhpClass> classes, @NotNull String namespaceFQN) {
PhpContractUtil.assertFqn(namespaceFQN);
return StreamEx.of(classes).filter((aClass) -> PhpLangUtil.equalsClassNames(namespaceFQN, StringUtil.trimEnd(aClass.getNamespaceName(), "\\"))).toCollection(THashSet::new);
return StreamEx.of(classes).filter((aClass) -> PhpLangUtil.equalsClassNames(namespaceFQN, StringUtil.trimEnd(aClass.getNamespaceName(), "\\"))).toCollection(HashSet::new);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

import com.intellij.util.io.DataExternalizer;
import com.intellij.util.io.EnumeratorStringDescriptor;
import gnu.trove.THashSet;
import org.jetbrains.annotations.NotNull;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;

/**
Expand All @@ -29,7 +29,7 @@ public synchronized void save(@NotNull DataOutput out, Set<String> value) throws
}

public synchronized Set<String> read(@NotNull DataInput in) throws IOException {
Set<String> set = new THashSet<>();
Set<String> set = new HashSet<>();

for(int r = in.readInt(); r > 0; --r) {
set.add(EnumeratorStringDescriptor.INSTANCE.read(in));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.intellij.icons.AllIcons;
import com.intellij.ide.highlighter.XmlFileType;
import com.intellij.openapi.actionSystem.ActionUpdateThread;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ConfigurationException;
Expand Down Expand Up @@ -154,6 +155,10 @@ public void success(@NotNull WebServerConfig server, @NotNull WebServerConfig.Re
}
});
}

public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.BGT;
}
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package fr.adrienbrault.idea.symfony2plugin.ui;

import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.ActionUpdateThread;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ConfigurationException;
Expand Down Expand Up @@ -145,7 +146,7 @@ public boolean canCreateElement() {
private void addWebDeploymentButton(ToolbarDecorator tablePanel) {
tablePanel.addExtraAction(new AnActionButton("Remote", AllIcons.Actions.Download) {
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
public void actionPerformed(@NotNull AnActionEvent anActionEvent) {
UiSettingsUtil.openFileDialogForDefaultWebServerConnection(project, new WebServerFileDialogExtensionCallback("php") {
@Override
public void success(@NotNull WebServerConfig server, @NotNull WebServerConfig.RemotePath remotePath) {
Expand All @@ -157,6 +158,10 @@ public void success(@NotNull WebServerConfig server, @NotNull WebServerConfig.Re
}
});
}

public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.BGT;
}
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package fr.adrienbrault.idea.symfony2plugin.webDeployment.actions;

import com.intellij.openapi.actionSystem.ActionUpdateThread;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.progress.ProgressIndicator;
Expand All @@ -23,6 +24,10 @@ public SymfonyWebDeploymentDownloadAction() {
super("Download dev files", "Download Symfony files from dev folder", Symfony2Icons.SYMFONY);
}

public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.BGT;
}

public void update(AnActionEvent e) {
final Project project = CommonDataKeys.PROJECT.getData(e.getDataContext());
if (project == null || project.isDisposed() || project.isDefault()) {
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 @@ -107,7 +107,7 @@
]]></description>

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

<extensions defaultExtensionNs="com.jetbrains.php">
<typeProvider4 implementation="fr.adrienbrault.idea.symfony2plugin.dic.SymfonyContainerTypeProvider"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ public void assertNavigationContains(PsiElement psiElement, String targetShortcu

Set<String> classTargets = new HashSet<>();

for (GotoDeclarationHandler gotoDeclarationHandler : Extensions.getExtensions(GotoDeclarationHandler.EP_NAME)) {
for (GotoDeclarationHandler gotoDeclarationHandler : GotoDeclarationHandler.EP_NAME.getExtensionList()) {
PsiElement[] gotoDeclarationTargets = gotoDeclarationHandler.getGotoDeclarationTargets(psiElement, 0, myFixture.getEditor());
if(gotoDeclarationTargets != null && gotoDeclarationTargets.length > 0) {
if(gotoDeclarationTargets != null) {

for (PsiElement gotoDeclarationTarget : gotoDeclarationTargets) {
if(gotoDeclarationTarget instanceof Method) {
Expand Down Expand Up @@ -236,7 +236,7 @@ public void assertNavigationIsEmpty(String content, String configureByText) {

private void assertNavigationIsEmpty() {
PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset());
for (GotoDeclarationHandler gotoDeclarationHandler : Extensions.getExtensions(GotoDeclarationHandler.EP_NAME)) {
for (GotoDeclarationHandler gotoDeclarationHandler : GotoDeclarationHandler.EP_NAME.getExtensionList()) {
PsiElement[] gotoDeclarationTargets = gotoDeclarationHandler.getGotoDeclarationTargets(psiElement, 0, myFixture.getEditor());
if(gotoDeclarationTargets != null && gotoDeclarationTargets.length > 0) {
fail(String.format("failed that PsiElement (%s) navigate is empty; found target in '%s'", psiElement.toString(), gotoDeclarationHandler.getClass()));
Expand All @@ -250,10 +250,10 @@ private void assertNavigationMatch(ElementPattern<?> pattern) {

Set<String> targetStrings = new HashSet<>();

for (GotoDeclarationHandler gotoDeclarationHandler : Extensions.getExtensions(GotoDeclarationHandler.EP_NAME)) {
for (GotoDeclarationHandler gotoDeclarationHandler : GotoDeclarationHandler.EP_NAME.getExtensionList()) {

PsiElement[] gotoDeclarationTargets = gotoDeclarationHandler.getGotoDeclarationTargets(psiElement, myFixture.getCaretOffset(), myFixture.getEditor());
if(gotoDeclarationTargets == null || gotoDeclarationTargets.length == 0) {
if(gotoDeclarationTargets == null) {
continue;
}

Expand All @@ -265,7 +265,7 @@ private void assertNavigationMatch(ElementPattern<?> pattern) {
}
}

fail(String.format("failed that PsiElement (%s) navigate matches one of %s", psiElement.toString(), targetStrings.toString()));
fail(String.format("failed that PsiElement (%s) navigate matches one of %s", psiElement.toString(), targetStrings));
}

public void assertNavigationContainsFile(LanguageFileType languageFileType, String configureByText, String targetShortcut) {
Expand All @@ -274,7 +274,7 @@ public void assertNavigationContainsFile(LanguageFileType languageFileType, Stri

Set<String> targets = new HashSet<>();

for (GotoDeclarationHandler gotoDeclarationHandler : Extensions.getExtensions(GotoDeclarationHandler.EP_NAME)) {
for (GotoDeclarationHandler gotoDeclarationHandler : GotoDeclarationHandler.EP_NAME.getExtensionList()) {
PsiElement[] gotoDeclarationTargets = gotoDeclarationHandler.getGotoDeclarationTargets(psiElement, 0, myFixture.getEditor());
if (gotoDeclarationTargets != null && gotoDeclarationTargets.length > 0) {
for (PsiElement gotoDeclarationTarget : gotoDeclarationTargets) {
Expand Down
Loading