Skip to content

Commit

Permalink
Merge pull request #29 from nexusunited/maintenance/replace_deprecate…
Browse files Browse the repository at this point in the history
…d_api_calls

Replaced deprecated api calls and fixed ArrayIndexOutOfBoundsException
  • Loading branch information
HaukeBST authored Apr 21, 2023
2 parents b251e67 + 5948446 commit 38f433c
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 36 deletions.
23 changes: 0 additions & 23 deletions .run/Run IDE with Plugin.run.xml

This file was deleted.

22 changes: 22 additions & 0 deletions .run/Run Plugin.run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,26 @@
<ForceTestExec>false</ForceTestExec>
<method v="2" />
</configuration>
<configuration default="false" name="Run Plugin" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="--stacktrace" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="runIde" />
</list>
</option>
<option name="vmOptions" value="-Xmx2024m -Xms512m -ea" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<ForceTestExec>false</ForceTestExec>
<method v="2" />
</configuration>
</component>
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
<!-- Keep a Changelog guide -> https://keepachangelog.com -->

# intellij_spryker_plugin Changelog
## [1.0.11]
- replaced deprecated API calls
- PhpPsiUtil.getParentByCondition
- fixed ArrayOutOfBoundsException in SprykerModuleAction

## [1.0.10]
- skipped

## [1.0.9] - 2023.04.03
- updated org.jetbrains.intellij
- updated pipeline
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

pluginGroup = com.github.patrickjaja.intellijsprykerplugin
pluginName = intellij_spryker_plugin
pluginVersion = 1.0.9
pluginVersion = 1.0.11
pluginSinceBuild = 223
pluginUntilBuild =
# pluginUntilBuild = 221.*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import com.valantic.cec.sprykerplugin.command.CreateMethodCommand;
import com.valantic.cec.sprykerplugin.model.Context;
import com.valantic.cec.sprykerplugin.model.TwigTreeNode;
import com.valantic.cec.sprykerplugin.services.TwigResources;
import com.valantic.cec.sprykerplugin.services.ContextBuilderInterface;
import com.valantic.cec.sprykerplugin.services.TwigResourcesInterface;
import org.jetbrains.annotations.NotNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction;
import com.intellij.codeInspection.util.IntentionFamilyName;
import com.intellij.codeInspection.util.IntentionName;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
Expand All @@ -21,18 +20,13 @@ public class CreateMissingFactoryMethodsIntentionAction extends PsiElementBaseIn

@Override
public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException {
CommandProcessor.getInstance().executeCommand(project, new Runnable() {
@Override
public void run() {
CreateMethodCommand command = project.getService(CreateMethodCommand.class);
command.createFactoryMethods(project, element);
}
},"Create missing Spryker Factory Methods", null);
CreateMethodCommand command = project.getService(CreateMethodCommand.class);
command.createFactoryMethods(project, element);
}

@Override
public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) {
PhpClass phpClass = PhpPsiUtil.getParentByCondition(element, PhpClass.INSTANCEOF);
PhpClass phpClass = PhpPsiUtil.getParentOfClass(element, PhpClass.class);
if (phpClass == null) return false;
return this.isFactoryClass(phpClass);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void createFactoryMethods(Project project, PsiElement element) {
return;
}

PhpClass mainClass = PhpPsiUtil.getParentByCondition(element, PhpClass.INSTANCEOF);
PhpClass mainClass = PhpPsiUtil.getParentOfClass(element, com.jetbrains.php.lang.psi.elements.PhpClass.class);
if (mainClass == null) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ private String getConstructorCallString(Method constructor, PhpClass phpClass) {
private String extractModuleNamespace(String namespaceName) {
String preparedNamespace = namespaceName.replaceAll("^\\\\", "");
String[] namespaceSegments = preparedNamespace.split("\\\\");
if (namespaceSegments.length < 3) {
return "";
}
String appName = namespaceSegments[1];
int occurence = 3;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<html lang="en">
<body>
<p>creates the missing factory methods that create the needed objects for the module.</p>
<p>Creates the missing factory methods that create the needed objects for the module.</p>

<!-- tooltip end -->
<p>Text after this comment will only be shown in the settings of the inspection.</p>
Expand Down

0 comments on commit 38f433c

Please sign in to comment.