diff --git a/build.gradle b/build.gradle
index 79d1a1be2..3e824de7d 100644
--- a/build.gradle
+++ b/build.gradle
@@ -4,10 +4,10 @@
*/
plugins {
- id 'org.jetbrains.intellij' version '1.13.3'
+ id 'org.jetbrains.intellij' version '1.17.3'
id 'checkstyle'
id 'pmd'
- id 'org.jetbrains.changelog' version '2.0.0'
+ id 'org.jetbrains.changelog' version '2.2.0'
}
repositories {
@@ -23,12 +23,14 @@ apply plugin: 'idea'
apply plugin: 'groovy'
apply plugin: 'org.jetbrains.changelog'
-def phpPluginVersion = System.getProperty("phpPluginVersion", "231.8109.199")
-def ideaVersion = System.getProperty("ideaVersion", "2023.1")
+def phpPluginVersion = System.getProperty("phpPluginVersion", "241.14494.158")
+def ideaVersion = System.getProperty("ideaVersion", "2024.1")
def javaVersion = 17
-sourceCompatibility = javaVersion
-targetCompatibility = javaVersion
+java {
+ sourceCompatibility = javaVersion
+ targetCompatibility = javaVersion
+}
intellij {
version = ideaVersion
@@ -41,7 +43,7 @@ intellij {
'properties',
'com.intellij.css',
'JavaScript',
- 'com.intellij.lang.jsgraphql:3.4.0',
+ 'com.intellij.lang.jsgraphql:241.14494.150',
'platform-images',
'copyright'
]
diff --git a/gradle-tasks/staticChecks.gradle b/gradle-tasks/staticChecks.gradle
index 60408bd0a..0478284c4 100644
--- a/gradle-tasks/staticChecks.gradle
+++ b/gradle-tasks/staticChecks.gradle
@@ -23,34 +23,34 @@ pmd {
ruleSets = []
}
-tasks.withType(Checkstyle) {
+tasks.withType(Checkstyle).configureEach {
// Specify all files that should be checked
classpath = files()
source "${project.rootDir}"
}
// Execute Checkstyle on all files
-task checkstyle(type: Checkstyle) {
+tasks.register('checkstyle', Checkstyle) {
}
// Execute Checkstyle on all modified files
-task checkstyleCI(type: Checkstyle) {
+tasks.register('checkstyleCI', Checkstyle) {
def changedFiles = getChangedFiles()
include changedFiles
}
-tasks.withType(Pmd) {
+tasks.withType(Pmd).configureEach {
// Specify all files that should be checked
classpath = files()
source "${project.rootDir}"
}
// Execute Checkstyle on all files
-task pmd(type: Pmd) {
+tasks.register('pmd', Pmd) {
}
// Execute Checkstyle on all modified files
-task pmdCI(type: Pmd) {
+tasks.register('pmdCI', Pmd) {
def changedFiles = getChangedFiles()
include changedFiles
}
diff --git a/resources/META-INF/plugin.xml b/resources/META-INF/plugin.xml
index 82a189afe..a07d7276a 100644
--- a/resources/META-INF/plugin.xml
+++ b/resources/META-INF/plugin.xml
@@ -24,7 +24,7 @@
-
+
diff --git a/src/com/magento/idea/magento2plugin/actions/generation/data/code/ClassPropertyData.java b/src/com/magento/idea/magento2plugin/actions/generation/data/code/ClassPropertyData.java
index 9c703dada..470466fae 100644
--- a/src/com/magento/idea/magento2plugin/actions/generation/data/code/ClassPropertyData.java
+++ b/src/com/magento/idea/magento2plugin/actions/generation/data/code/ClassPropertyData.java
@@ -7,7 +7,7 @@
import java.util.ArrayList;
import java.util.List;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
public class ClassPropertyData {
private final List data = new ArrayList<>();
diff --git a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewEntityDialog.java b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewEntityDialog.java
index 04f2c931f..c30c64a12 100644
--- a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewEntityDialog.java
+++ b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewEntityDialog.java
@@ -83,7 +83,7 @@
import javax.swing.KeyStroke;
import javax.swing.event.DocumentEvent;
import javax.swing.table.DefaultTableModel;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
@SuppressWarnings({
diff --git a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewModuleDialog.java b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewModuleDialog.java
index 4bb917356..729d2d0c8 100644
--- a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewModuleDialog.java
+++ b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewModuleDialog.java
@@ -48,7 +48,7 @@
import javax.swing.KeyStroke;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
-import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang3.ArrayUtils;
import org.jetbrains.annotations.NotNull;
@SuppressWarnings({"PMD.TooManyFields", "PMD.DataClass", "PMD.UnusedPrivateMethod"})
diff --git a/src/com/magento/idea/magento2plugin/actions/generation/dialog/util/ClassPropertyFormatterUtil.java b/src/com/magento/idea/magento2plugin/actions/generation/dialog/util/ClassPropertyFormatterUtil.java
index 08ab105c0..c7ae405cd 100644
--- a/src/com/magento/idea/magento2plugin/actions/generation/dialog/util/ClassPropertyFormatterUtil.java
+++ b/src/com/magento/idea/magento2plugin/actions/generation/dialog/util/ClassPropertyFormatterUtil.java
@@ -11,7 +11,7 @@
import java.util.ArrayList;
import java.util.List;
import javax.swing.table.DefaultTableModel;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
public final class ClassPropertyFormatterUtil {
diff --git a/src/com/magento/idea/magento2plugin/linemarker/php/PluginLineMarkerProvider.java b/src/com/magento/idea/magento2plugin/linemarker/php/PluginLineMarkerProvider.java
index ff3a7af95..e081715ab 100644
--- a/src/com/magento/idea/magento2plugin/linemarker/php/PluginLineMarkerProvider.java
+++ b/src/com/magento/idea/magento2plugin/linemarker/php/PluginLineMarkerProvider.java
@@ -28,7 +28,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-import org.apache.commons.lang.WordUtils;
+import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -236,7 +236,7 @@ public List collect(final @NotNull Method psiElement) {
final List pluginDataList = pluginClassCache.getPluginsForClass(methodClass);
final List pluginMethods = pluginClassCache.getPluginMethods(pluginDataList);
- final String classMethodName = WordUtils.capitalize(psiElement.getName());
+ final String classMethodName = StringUtils.capitalize(psiElement.getName());
pluginMethods.removeIf(pluginMethod -> !isPluginMethodName(pluginMethod.getMethodName(), classMethodName));
sortMethods(pluginMethods, results);
diff --git a/src/com/magento/idea/magento2plugin/magento/packages/ComposerPackageModel.java b/src/com/magento/idea/magento2plugin/magento/packages/ComposerPackageModel.java
index afc0fb71d..bb0874b33 100644
--- a/src/com/magento/idea/magento2plugin/magento/packages/ComposerPackageModel.java
+++ b/src/com/magento/idea/magento2plugin/magento/packages/ComposerPackageModel.java
@@ -2,10 +2,13 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
package com.magento.idea.magento2plugin.magento.packages;
-import org.jetbrains.annotations.Nullable;
+import com.intellij.json.psi.JsonValue;
import java.util.Map;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
public interface ComposerPackageModel {
@Nullable
@@ -25,4 +28,7 @@ public interface ComposerPackageModel {
@Nullable
Map getAutoloadPsr4();
+
+ T getPropertyValueOfType(String propertyName,
+ @NotNull Class thisClass);
}
diff --git a/src/com/magento/idea/magento2plugin/magento/packages/ComposerPackageModelImpl.java b/src/com/magento/idea/magento2plugin/magento/packages/ComposerPackageModelImpl.java
index 96a8ed730..42b83ef93 100644
--- a/src/com/magento/idea/magento2plugin/magento/packages/ComposerPackageModelImpl.java
+++ b/src/com/magento/idea/magento2plugin/magento/packages/ComposerPackageModelImpl.java
@@ -2,19 +2,25 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
package com.magento.idea.magento2plugin.magento.packages;
-import com.intellij.json.psi.*;
-import org.apache.commons.lang.StringUtils;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
+import com.intellij.json.psi.JsonArray;
+import com.intellij.json.psi.JsonObject;
+import com.intellij.json.psi.JsonProperty;
+import com.intellij.json.psi.JsonStringLiteral;
+import com.intellij.json.psi.JsonValue;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.apache.commons.lang3.StringUtils;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
public class ComposerPackageModelImpl implements ComposerPackageModel {
- private JsonObject sourceComposerJson;
+ private final JsonObject sourceComposerJson;
+ private static final int VENDOR_AND_PACKAGE_PARTS_LENGTH = 2;
public static final String NAME = "name";
public static final String TYPE = "type";
@@ -23,7 +29,7 @@ public class ComposerPackageModelImpl implements ComposerPackageModel {
public static final String PSR4 = "psr4";
public static final String FILES = "file";
- public ComposerPackageModelImpl(@NotNull JsonObject sourceComposerJson) {
+ public ComposerPackageModelImpl(@NotNull final JsonObject sourceComposerJson) {
this.sourceComposerJson = sourceComposerJson;
}
@@ -42,10 +48,10 @@ public String getType() {
@Nullable
@Override
public String getVendor() {
- String nameProperty = getStringPropertyValue(NAME);
+ final String nameProperty = getStringPropertyValue(NAME);
if (nameProperty != null) {
- String[] vendorAndPackage = nameProperty.split("/");
- if (vendorAndPackage.length == 2) {
+ final String[] vendorAndPackage = nameProperty.split("/");
+ if (vendorAndPackage.length == VENDOR_AND_PACKAGE_PARTS_LENGTH) {
return vendorAndPackage[0];
}
}
@@ -62,63 +68,69 @@ public String getVersion() {
@Nullable
@Override
public String[] getAutoloadFiles() {
- JsonObject autoloadObject = getPropertyValueOfType(AUTOLOAD, JsonObject.class);
+ final JsonObject autoloadObject = getPropertyValueOfType(AUTOLOAD, JsonObject.class);
if (autoloadObject != null) {
- JsonArray jsonArray = getPropertyValueOfType(FILES, JsonArray.class);
- if (jsonArray != null) {
- List files = new ArrayList<>();
- for(JsonValue value: jsonArray.getValueList()) {
- if (value instanceof JsonStringLiteral) {
- files.add(StringUtils.strip(value.getText(), "\""));
- }
+ return new String[0];
+ }
+
+ final JsonArray jsonArray = getPropertyValueOfType(FILES, JsonArray.class);
+ if (jsonArray != null) {
+ final List files = new ArrayList<>();
+ for (final JsonValue value : jsonArray.getValueList()) {
+ if (value instanceof JsonStringLiteral) {
+ files.add(StringUtils.strip(value.getText(), "\""));
}
- return files.size() > 0 ? files.toArray(new String[files.size()]) : null;
}
+ return files.isEmpty() ? new String[0] : files.toArray(new String[0]);
}
- return null;
+ return new String[0];
}
@Nullable
@Override
public Map getAutoloadPsr4() {
- JsonObject autoloadObject = getPropertyValueOfType(AUTOLOAD, JsonObject.class);
- if (autoloadObject != null) {
- JsonObject jsonObject = getPropertyValueOfType(PSR4, JsonObject.class);
- if (jsonObject != null) {
- Map map = new HashMap();
- for (JsonProperty property: jsonObject.getPropertyList()) {
- JsonValue value = property.getValue();
-
- if (value != null && value instanceof JsonStringLiteral) {
- map.put(property.getName(), StringUtils.strip(value.getText(), "\""));
- }
- }
+ final JsonObject autoloadObject = getPropertyValueOfType(AUTOLOAD, JsonObject.class);
+ final Map map = new HashMap<>();
+ if (autoloadObject == null) {
+ return map;
+ }
- return map.size() > 0 ? map : null;
+ final JsonObject jsonObject = getPropertyValueOfType(PSR4, JsonObject.class);
+ if (jsonObject != null) {
+ for (final JsonProperty property : jsonObject.getPropertyList()) {
+ final JsonValue value = property.getValue();
+ if (value instanceof JsonStringLiteral) {
+ map.put(property.getName(), StringUtils.strip(value.getText(), "\""));
+ }
}
}
- return null;
+ return map;
}
@Nullable
- public T getPropertyValueOfType(String propertyName, @NotNull Class aClass) {
- JsonProperty property = sourceComposerJson.findProperty(propertyName);
+ @Override
+ public T getPropertyValueOfType(final String propertyName,
+ @NotNull final Class thisClass) {
+ final JsonProperty property = sourceComposerJson.findProperty(propertyName);
if (property == null) {
return null;
}
- JsonValue value = property.getValue();
- if (value != null && aClass.isInstance(value)) {
- return aClass.cast(value);
+ final JsonValue value = property.getValue();
+ if (thisClass.isInstance(value)) {
+ return thisClass.cast(value);
}
return null;
}
@Nullable
- private String getStringPropertyValue(String propertyName) {
- JsonStringLiteral stringLiteral = getPropertyValueOfType(propertyName, JsonStringLiteral.class);
+ private String getStringPropertyValue(final String propertyName) {
+ final JsonStringLiteral stringLiteral = getPropertyValueOfType(
+ propertyName,
+ JsonStringLiteral.class
+ );
if (stringLiteral != null) {
return StringUtils.strip(stringLiteral.getText(), "\"");
diff --git a/src/com/magento/idea/magento2plugin/project/startup/CheckIfMagentoPathIsValidActivity.java b/src/com/magento/idea/magento2plugin/project/startup/CheckIfMagentoPathIsValidActivity.java
index b6413535c..7d1ebeee1 100644
--- a/src/com/magento/idea/magento2plugin/project/startup/CheckIfMagentoPathIsValidActivity.java
+++ b/src/com/magento/idea/magento2plugin/project/startup/CheckIfMagentoPathIsValidActivity.java
@@ -6,16 +6,32 @@
package com.magento.idea.magento2plugin.project.startup;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.startup.ProjectActivity;
import com.intellij.openapi.startup.StartupActivity;
import com.magento.idea.magento2plugin.init.ConfigurationManager;
import com.magento.idea.magento2plugin.project.Settings;
import com.magento.idea.magento2plugin.util.magento.MagentoBasePathUtil;
+import kotlin.Unit;
+import kotlin.coroutines.Continuation;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
-public class CheckIfMagentoPathIsValidActivity implements StartupActivity {
+public class CheckIfMagentoPathIsValidActivity implements StartupActivity, ProjectActivity {
@Override
public void runActivity(final @NotNull Project project) {
+ registerSettings(project);
+ }
+
+ @Nullable
+ @Override
+ public Object execute(@NotNull final Project project,
+ @NotNull final Continuation super Unit> continuation) {
+ registerSettings(project);
+ return null;
+ }
+
+ private void registerSettings(final @NotNull Project project) {
final Settings settings = Settings.getInstance(project);
final String path = settings.magentoPath;
if (settings.pluginEnabled && (path == null || path.isEmpty())) {
diff --git a/src/com/magento/idea/magento2plugin/project/util/GetMagentoVersionUtil.java b/src/com/magento/idea/magento2plugin/project/util/GetMagentoVersionUtil.java
index 001db0b18..f5fc10444 100644
--- a/src/com/magento/idea/magento2plugin/project/util/GetMagentoVersionUtil.java
+++ b/src/com/magento/idea/magento2plugin/project/util/GetMagentoVersionUtil.java
@@ -15,7 +15,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
diff --git a/src/com/magento/idea/magento2plugin/util/php/PhpTypeMetadataParserUtil.java b/src/com/magento/idea/magento2plugin/util/php/PhpTypeMetadataParserUtil.java
index 9ea2c4941..6eac53738 100644
--- a/src/com/magento/idea/magento2plugin/util/php/PhpTypeMetadataParserUtil.java
+++ b/src/com/magento/idea/magento2plugin/util/php/PhpTypeMetadataParserUtil.java
@@ -27,7 +27,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
@SuppressWarnings("PMD.GodClass")
diff --git a/tests/com/magento/idea/magento2plugin/BaseProjectTestCase.java b/tests/com/magento/idea/magento2plugin/BaseProjectTestCase.java
index e25b5ccf4..427237113 100644
--- a/tests/com/magento/idea/magento2plugin/BaseProjectTestCase.java
+++ b/tests/com/magento/idea/magento2plugin/BaseProjectTestCase.java
@@ -6,6 +6,7 @@
package com.magento.idea.magento2plugin;
import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.testFramework.IndexingTestUtil;
import com.intellij.testFramework.PlatformTestUtil;
import com.intellij.testFramework.fixtures.BasePlatformTestCase;
import com.magento.idea.magento2plugin.indexes.IndexManager;
@@ -50,6 +51,7 @@ protected void enablePluginAndReindex() {
settings.mftfSupportEnabled = true;
IndexManager.manualReindex();
PlatformTestUtil.dispatchAllEventsInIdeEventQueue();
+ IndexingTestUtil.waitUntilIndexesAreReady(myFixture.getProject());
}
protected void disablePluginAndReindex() {
@@ -57,6 +59,7 @@ protected void disablePluginAndReindex() {
settings.pluginEnabled = false;
IndexManager.manualReindex();
PlatformTestUtil.dispatchAllEventsInIdeEventQueue();
+ IndexingTestUtil.waitUntilIndexesAreReady(myFixture.getProject());
}
protected void disableMftfSupportAndReindex() {
@@ -64,6 +67,7 @@ protected void disableMftfSupportAndReindex() {
settings.mftfSupportEnabled = false;
IndexManager.manualReindex();
PlatformTestUtil.dispatchAllEventsInIdeEventQueue();
+ IndexingTestUtil.waitUntilIndexesAreReady(myFixture.getProject());
}
protected String prepareFixturePath(