Skip to content

Commit 93fed17

Browse files
authored
Merge pull request #2071 from piotrkwiecinski/idea-2024-1-compatibility
plugin compatibility for 2024.1
2 parents 75ffe6e + f3efc91 commit 93fed17

File tree

14 files changed

+104
-64
lines changed

14 files changed

+104
-64
lines changed

build.gradle

+9-7
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
*/
55

66
plugins {
7-
id 'org.jetbrains.intellij' version '1.13.3'
7+
id 'org.jetbrains.intellij' version '1.17.3'
88
id 'checkstyle'
99
id 'pmd'
10-
id 'org.jetbrains.changelog' version '2.0.0'
10+
id 'org.jetbrains.changelog' version '2.2.0'
1111
}
1212

1313
repositories {
@@ -23,12 +23,14 @@ apply plugin: 'idea'
2323
apply plugin: 'groovy'
2424
apply plugin: 'org.jetbrains.changelog'
2525

26-
def phpPluginVersion = System.getProperty("phpPluginVersion", "231.8109.199")
27-
def ideaVersion = System.getProperty("ideaVersion", "2023.1")
26+
def phpPluginVersion = System.getProperty("phpPluginVersion", "241.14494.158")
27+
def ideaVersion = System.getProperty("ideaVersion", "2024.1")
2828
def javaVersion = 17
2929

30-
sourceCompatibility = javaVersion
31-
targetCompatibility = javaVersion
30+
java {
31+
sourceCompatibility = javaVersion
32+
targetCompatibility = javaVersion
33+
}
3234

3335
intellij {
3436
version = ideaVersion
@@ -41,7 +43,7 @@ intellij {
4143
'properties',
4244
'com.intellij.css',
4345
'JavaScript',
44-
'com.intellij.lang.jsgraphql:3.4.0',
46+
'com.intellij.lang.jsgraphql:241.14494.150',
4547
'platform-images',
4648
'copyright'
4749
]

gradle-tasks/staticChecks.gradle

+6-6
Original file line numberDiff line numberDiff line change
@@ -23,34 +23,34 @@ pmd {
2323
ruleSets = []
2424
}
2525

26-
tasks.withType(Checkstyle) {
26+
tasks.withType(Checkstyle).configureEach {
2727
// Specify all files that should be checked
2828
classpath = files()
2929
source "${project.rootDir}"
3030
}
3131

3232
// Execute Checkstyle on all files
33-
task checkstyle(type: Checkstyle) {
33+
tasks.register('checkstyle', Checkstyle) {
3434
}
3535

3636
// Execute Checkstyle on all modified files
37-
task checkstyleCI(type: Checkstyle) {
37+
tasks.register('checkstyleCI', Checkstyle) {
3838
def changedFiles = getChangedFiles()
3939
include changedFiles
4040
}
4141

42-
tasks.withType(Pmd) {
42+
tasks.withType(Pmd).configureEach {
4343
// Specify all files that should be checked
4444
classpath = files()
4545
source "${project.rootDir}"
4646
}
4747

4848
// Execute Checkstyle on all files
49-
task pmd(type: Pmd) {
49+
tasks.register('pmd', Pmd) {
5050
}
5151

5252
// Execute Checkstyle on all modified files
53-
task pmdCI(type: Pmd) {
53+
tasks.register('pmdCI', Pmd) {
5454
def changedFiles = getChangedFiles()
5555
include changedFiles
5656
}

resources/META-INF/plugin.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
</change-notes>
2525

2626
<!-- please see http://confluence.jetbrains.com/display/IDEADEV/Build+Number+Ranges for description -->
27-
<idea-version since-build="231.8109.175"/>
27+
<idea-version since-build="241.14494.158"/>
2828

2929
<!-- please see http://confluence.jetbrains.com/display/IDEADEV/Plugin+Compatibility+with+IntelliJ+Platform+Products
3030
on how to target different products -->

src/com/magento/idea/magento2plugin/actions/generation/data/code/ClassPropertyData.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import java.util.ArrayList;
99
import java.util.List;
10-
import org.apache.commons.lang.StringUtils;
10+
import org.apache.commons.lang3.StringUtils;
1111

1212
public class ClassPropertyData {
1313
private final List<String> data = new ArrayList<>();

src/com/magento/idea/magento2plugin/actions/generation/dialog/NewEntityDialog.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
import javax.swing.KeyStroke;
8484
import javax.swing.event.DocumentEvent;
8585
import javax.swing.table.DefaultTableModel;
86-
import org.apache.commons.lang.StringUtils;
86+
import org.apache.commons.lang3.StringUtils;
8787
import org.jetbrains.annotations.NotNull;
8888

8989
@SuppressWarnings({

src/com/magento/idea/magento2plugin/actions/generation/dialog/NewModuleDialog.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
import javax.swing.KeyStroke;
4949
import javax.swing.event.ListSelectionEvent;
5050
import javax.swing.event.ListSelectionListener;
51-
import org.apache.commons.lang.ArrayUtils;
51+
import org.apache.commons.lang3.ArrayUtils;
5252
import org.jetbrains.annotations.NotNull;
5353

5454
@SuppressWarnings({"PMD.TooManyFields", "PMD.DataClass", "PMD.UnusedPrivateMethod"})

src/com/magento/idea/magento2plugin/actions/generation/dialog/util/ClassPropertyFormatterUtil.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import java.util.ArrayList;
1212
import java.util.List;
1313
import javax.swing.table.DefaultTableModel;
14-
import org.apache.commons.lang.StringUtils;
14+
import org.apache.commons.lang3.StringUtils;
1515

1616
public final class ClassPropertyFormatterUtil {
1717

src/com/magento/idea/magento2plugin/linemarker/php/PluginLineMarkerProvider.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import java.util.List;
2929
import java.util.Map;
3030
import java.util.Set;
31-
import org.apache.commons.lang.WordUtils;
31+
import org.apache.commons.lang3.StringUtils;
3232
import org.jetbrains.annotations.NotNull;
3333
import org.jetbrains.annotations.Nullable;
3434

@@ -236,7 +236,7 @@ public List<Method> collect(final @NotNull Method psiElement) {
236236

237237
final List<PluginData> pluginDataList = pluginClassCache.getPluginsForClass(methodClass);
238238
final List<PluginMethodData> pluginMethods = pluginClassCache.getPluginMethods(pluginDataList);
239-
final String classMethodName = WordUtils.capitalize(psiElement.getName());
239+
final String classMethodName = StringUtils.capitalize(psiElement.getName());
240240

241241
pluginMethods.removeIf(pluginMethod -> !isPluginMethodName(pluginMethod.getMethodName(), classMethodName));
242242
sortMethods(pluginMethods, results);

src/com/magento/idea/magento2plugin/magento/packages/ComposerPackageModel.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
* Copyright © Magento, Inc. All rights reserved.
33
* See COPYING.txt for license details.
44
*/
5+
56
package com.magento.idea.magento2plugin.magento.packages;
67

7-
import org.jetbrains.annotations.Nullable;
8+
import com.intellij.json.psi.JsonValue;
89
import java.util.Map;
10+
import org.jetbrains.annotations.NotNull;
11+
import org.jetbrains.annotations.Nullable;
912

1013
public interface ComposerPackageModel {
1114
@Nullable
@@ -25,4 +28,7 @@ public interface ComposerPackageModel {
2528

2629
@Nullable
2730
Map<String, String> getAutoloadPsr4();
31+
32+
<T extends JsonValue> T getPropertyValueOfType(String propertyName,
33+
@NotNull Class<T> thisClass);
2834
}

src/com/magento/idea/magento2plugin/magento/packages/ComposerPackageModelImpl.java

+52-40
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,25 @@
22
* Copyright © Magento, Inc. All rights reserved.
33
* See COPYING.txt for license details.
44
*/
5+
56
package com.magento.idea.magento2plugin.magento.packages;
67

7-
import com.intellij.json.psi.*;
8-
import org.apache.commons.lang.StringUtils;
9-
import org.jetbrains.annotations.NotNull;
10-
import org.jetbrains.annotations.Nullable;
8+
import com.intellij.json.psi.JsonArray;
9+
import com.intellij.json.psi.JsonObject;
10+
import com.intellij.json.psi.JsonProperty;
11+
import com.intellij.json.psi.JsonStringLiteral;
12+
import com.intellij.json.psi.JsonValue;
1113
import java.util.ArrayList;
1214
import java.util.HashMap;
1315
import java.util.List;
1416
import java.util.Map;
17+
import org.apache.commons.lang3.StringUtils;
18+
import org.jetbrains.annotations.NotNull;
19+
import org.jetbrains.annotations.Nullable;
1520

1621
public class ComposerPackageModelImpl implements ComposerPackageModel {
17-
private JsonObject sourceComposerJson;
22+
private final JsonObject sourceComposerJson;
23+
private static final int VENDOR_AND_PACKAGE_PARTS_LENGTH = 2;
1824

1925
public static final String NAME = "name";
2026
public static final String TYPE = "type";
@@ -23,7 +29,7 @@ public class ComposerPackageModelImpl implements ComposerPackageModel {
2329
public static final String PSR4 = "psr4";
2430
public static final String FILES = "file";
2531

26-
public ComposerPackageModelImpl(@NotNull JsonObject sourceComposerJson) {
32+
public ComposerPackageModelImpl(@NotNull final JsonObject sourceComposerJson) {
2733
this.sourceComposerJson = sourceComposerJson;
2834
}
2935

@@ -42,10 +48,10 @@ public String getType() {
4248
@Nullable
4349
@Override
4450
public String getVendor() {
45-
String nameProperty = getStringPropertyValue(NAME);
51+
final String nameProperty = getStringPropertyValue(NAME);
4652
if (nameProperty != null) {
47-
String[] vendorAndPackage = nameProperty.split("/");
48-
if (vendorAndPackage.length == 2) {
53+
final String[] vendorAndPackage = nameProperty.split("/");
54+
if (vendorAndPackage.length == VENDOR_AND_PACKAGE_PARTS_LENGTH) {
4955
return vendorAndPackage[0];
5056
}
5157
}
@@ -62,63 +68,69 @@ public String getVersion() {
6268
@Nullable
6369
@Override
6470
public String[] getAutoloadFiles() {
65-
JsonObject autoloadObject = getPropertyValueOfType(AUTOLOAD, JsonObject.class);
71+
final JsonObject autoloadObject = getPropertyValueOfType(AUTOLOAD, JsonObject.class);
6672
if (autoloadObject != null) {
67-
JsonArray jsonArray = getPropertyValueOfType(FILES, JsonArray.class);
68-
if (jsonArray != null) {
69-
List<String> files = new ArrayList<>();
70-
for(JsonValue value: jsonArray.getValueList()) {
71-
if (value instanceof JsonStringLiteral) {
72-
files.add(StringUtils.strip(value.getText(), "\""));
73-
}
73+
return new String[0];
74+
}
75+
76+
final JsonArray jsonArray = getPropertyValueOfType(FILES, JsonArray.class);
77+
if (jsonArray != null) {
78+
final List<String> files = new ArrayList<>();
79+
for (final JsonValue value : jsonArray.getValueList()) {
80+
if (value instanceof JsonStringLiteral) {
81+
files.add(StringUtils.strip(value.getText(), "\""));
7482
}
75-
return files.size() > 0 ? files.toArray(new String[files.size()]) : null;
7683
}
84+
return files.isEmpty() ? new String[0] : files.toArray(new String[0]);
7785
}
7886

79-
return null;
87+
return new String[0];
8088
}
8189

8290
@Nullable
8391
@Override
8492
public Map<String, String> getAutoloadPsr4() {
85-
JsonObject autoloadObject = getPropertyValueOfType(AUTOLOAD, JsonObject.class);
86-
if (autoloadObject != null) {
87-
JsonObject jsonObject = getPropertyValueOfType(PSR4, JsonObject.class);
88-
if (jsonObject != null) {
89-
Map <String, String> map = new HashMap<String, String>();
90-
for (JsonProperty property: jsonObject.getPropertyList()) {
91-
JsonValue value = property.getValue();
92-
93-
if (value != null && value instanceof JsonStringLiteral) {
94-
map.put(property.getName(), StringUtils.strip(value.getText(), "\""));
95-
}
96-
}
93+
final JsonObject autoloadObject = getPropertyValueOfType(AUTOLOAD, JsonObject.class);
94+
final Map<String, String> map = new HashMap<>();
95+
if (autoloadObject == null) {
96+
return map;
97+
}
9798

98-
return map.size() > 0 ? map : null;
99+
final JsonObject jsonObject = getPropertyValueOfType(PSR4, JsonObject.class);
100+
if (jsonObject != null) {
101+
for (final JsonProperty property : jsonObject.getPropertyList()) {
102+
final JsonValue value = property.getValue();
103+
if (value instanceof JsonStringLiteral) {
104+
map.put(property.getName(), StringUtils.strip(value.getText(), "\""));
105+
}
99106
}
100107
}
101108

102-
return null;
109+
return map;
103110
}
104111

105112
@Nullable
106-
public <T extends JsonValue> T getPropertyValueOfType(String propertyName, @NotNull Class<T> aClass) {
107-
JsonProperty property = sourceComposerJson.findProperty(propertyName);
113+
@Override
114+
public <T extends JsonValue> T getPropertyValueOfType(final String propertyName,
115+
@NotNull final Class<T> thisClass) {
116+
final JsonProperty property = sourceComposerJson.findProperty(propertyName);
108117
if (property == null) {
109118
return null;
110119
}
111-
JsonValue value = property.getValue();
112-
if (value != null && aClass.isInstance(value)) {
113-
return aClass.cast(value);
120+
final JsonValue value = property.getValue();
121+
if (thisClass.isInstance(value)) {
122+
return thisClass.cast(value);
114123
}
115124

116125
return null;
117126
}
118127

119128
@Nullable
120-
private String getStringPropertyValue(String propertyName) {
121-
JsonStringLiteral stringLiteral = getPropertyValueOfType(propertyName, JsonStringLiteral.class);
129+
private String getStringPropertyValue(final String propertyName) {
130+
final JsonStringLiteral stringLiteral = getPropertyValueOfType(
131+
propertyName,
132+
JsonStringLiteral.class
133+
);
122134

123135
if (stringLiteral != null) {
124136
return StringUtils.strip(stringLiteral.getText(), "\"");

src/com/magento/idea/magento2plugin/project/startup/CheckIfMagentoPathIsValidActivity.java

+17-1
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,32 @@
66
package com.magento.idea.magento2plugin.project.startup;
77

88
import com.intellij.openapi.project.Project;
9+
import com.intellij.openapi.startup.ProjectActivity;
910
import com.intellij.openapi.startup.StartupActivity;
1011
import com.magento.idea.magento2plugin.init.ConfigurationManager;
1112
import com.magento.idea.magento2plugin.project.Settings;
1213
import com.magento.idea.magento2plugin.util.magento.MagentoBasePathUtil;
14+
import kotlin.Unit;
15+
import kotlin.coroutines.Continuation;
1316
import org.jetbrains.annotations.NotNull;
17+
import org.jetbrains.annotations.Nullable;
1418

15-
public class CheckIfMagentoPathIsValidActivity implements StartupActivity {
19+
public class CheckIfMagentoPathIsValidActivity implements StartupActivity, ProjectActivity {
1620

1721
@Override
1822
public void runActivity(final @NotNull Project project) {
23+
registerSettings(project);
24+
}
25+
26+
@Nullable
27+
@Override
28+
public Object execute(@NotNull final Project project,
29+
@NotNull final Continuation<? super Unit> continuation) {
30+
registerSettings(project);
31+
return null;
32+
}
33+
34+
private void registerSettings(final @NotNull Project project) {
1935
final Settings settings = Settings.getInstance(project);
2036
final String path = settings.magentoPath;
2137
if (settings.pluginEnabled && (path == null || path.isEmpty())) {

src/com/magento/idea/magento2plugin/project/util/GetMagentoVersionUtil.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import java.util.HashMap;
1616
import java.util.List;
1717
import java.util.Map;
18-
import org.apache.commons.lang.StringUtils;
18+
import org.apache.commons.lang3.StringUtils;
1919
import org.jetbrains.annotations.NotNull;
2020
import org.jetbrains.annotations.Nullable;
2121

src/com/magento/idea/magento2plugin/util/php/PhpTypeMetadataParserUtil.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import java.util.regex.Matcher;
2828
import java.util.regex.Pattern;
2929
import java.util.stream.Collectors;
30-
import org.apache.commons.lang.StringUtils;
30+
import org.apache.commons.lang3.StringUtils;
3131
import org.jetbrains.annotations.NotNull;
3232

3333
@SuppressWarnings("PMD.GodClass")

0 commit comments

Comments
 (0)