Skip to content

Commit 8e4461e

Browse files
Built-in UCT development
1 parent 7eeb20f commit 8e4461e

30 files changed

+2164
-3
lines changed

resources/META-INF/plugin.xml

+31
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,20 @@
109109
description="Copies Magento's path of file depending on file type">
110110
<add-to-group group-id="CopyFileReference" anchor="last"/>
111111
</action>
112+
<group id="UctReindexMenu">
113+
<separator/>
114+
<action id="com.magento.idea.magento2uct.actions.ReindexVersionedIndexesAction"
115+
class="com.magento.idea.magento2uct.actions.ReindexVersionedIndexesAction"
116+
text="ReindexVersionedIndexesAction"/>
117+
<add-to-group group-id="ProjectViewPopupMenu" anchor="last"/>
118+
</group>
119+
<group id="UctRunMenu">
120+
<separator/>
121+
<action id="com.magento.idea.magento2uct.actions.RunUpgradeCompatibilityToolAction"
122+
class="com.magento.idea.magento2uct.actions.RunUpgradeCompatibilityToolAction"
123+
text="Run The Upgrade Compatibility Tool Action"/>
124+
<add-to-group group-id="RunMenu" anchor="last"/>
125+
</group>
112126
</actions>
113127

114128
<extensions defaultExtensionNs="com.intellij">
@@ -237,6 +251,23 @@
237251
enabledByDefault="true" level="WARNING"
238252
implementationClass="com.magento.idea.magento2plugin.inspections.xml.PluginAttributeTypeInspection"/>
239253

254+
<!-- UCT inspection -->
255+
<localInspection language="PHP" groupPath="UCT"
256+
shortName="ExtendingDeprecatedClass"
257+
bundle="uct.bundle.inspection" key="inspection.displayName.ExtendingDeprecatedClass"
258+
groupBundle="uct.bundle.inspection" groupKey="inspection.deprecation.group.name"
259+
enabledByDefault="true"
260+
level="WARNING"
261+
implementationClass="com.magento.idea.magento2uct.inspections.php.deprecation.ExtendingDeprecatedClass"/>
262+
<localInspection language="PHP" groupPath="UCT"
263+
shortName="ImportingDeprecatedType"
264+
bundle="uct.bundle.inspection" key="inspection.displayName.ImportingDeprecatedType"
265+
groupBundle="uct.bundle.inspection" groupKey="inspection.deprecation.group.name"
266+
enabledByDefault="true"
267+
level="WARNING"
268+
implementationClass="com.magento.idea.magento2uct.inspections.php.deprecation.ImportingDeprecatedType"/>
269+
<!-- \UCT inspection -->
270+
240271
<internalFileTemplate name="Magento Composer JSON"/>
241272
<internalFileTemplate name="Magento Registration PHP"/>
242273
<internalFileTemplate name="Magento Module XML"/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<html>
2+
<body>
3+
<p>[1131] Extending from Adobe Commerce @deprecated class: The extended class will be removed in upcoming versions. Inheritance is not recommended way of extending Adobe Commerce functionality. Update code to use a class marked as @api.</p>
4+
<!-- tooltip end -->
5+
<p>Text after this comment will only be shown in the settings of the inspection.</p>
6+
</body>
7+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<html>
2+
<body>
3+
<p>[1132] Importing Adobe Commerce @deprecated class: The extended class will be removed in upcoming versions. Consider using Adobe Commerce class marked as @api instead.</p>
4+
<p>[1332] Imported Adobe Commerce @deprecated interface: The deprecated interface will be removed in upcoming versions. Consider using an interface or class marked as @api instead.</p>
5+
<!-- tooltip end -->
6+
<p>Text after this comment will only be shown in the settings of the inspection.</p>
7+
</body>
8+
</html>
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
inspection.deprecation.group.name=Deprecation Inspections
2+
inspection.displayName.ExtendingDeprecatedClass=Extending from Adobe Commerce @deprecated class
3+
inspection.displayName.ImportingDeprecatedType=Importing Adobe Commerce @deprecated class/interface
4+
customCode.warnings.deprecated.1131=[1131] Extending from @deprecated class ''{0}''
5+
customCode.warnings.deprecated.1132=[1132] Importing @deprecated class ''{0}''
6+
customCode.warnings.deprecated.1133=[1133] Loading Adobe Commerce @deprecated class {0} in {1}. The extended class will be removed in upcoming versions. Consider using Adobe Commerce class marked as @api instead.
7+
customCode.warnings.deprecated.1134=[1134] Using Adobe Commerce @deprecated class {0} in {1}::{2}. The extended class will be removed in upcoming versions. Consider using Adobe Commerce class marked as @api instead.
8+
customCode.warnings.deprecated.1234=[1234] Using Adobe Commerce @deprecated constant {0}::{1} in {2}. The deprecated constant will be removed in upcoming versions. Consider using a constant marked as @api or a private constant within your implementation instead.
9+
customCode.warnings.deprecated.1235=[1235] Overriding Adobe Commerce @deprecated constant {0}::{1} in {2}. The deprecated constant will be removed in upcoming versions. Consider using a constant marked as @api or a private constant within your implementation instead.
10+
customCode.warnings.deprecated.1236=[1236] Assignation of Adobe Commerce @deprecated constant {0}::{1} in {2}. The deprecated constant will be removed in upcoming versions. Consider using a constant marked as @api or a private constant within your implementation instead.
11+
customCode.warnings.deprecated.1332=[1332] Imported @deprecated interface ''{0}''
12+
customCode.warnings.deprecated.1334=[1334] Used Adobe Commerce @deprecated interface {0} in {1}::{2}. The deprecated interface will be removed in upcoming versions. Consider using an interface or class marked as @api instead.
13+
customCode.warnings.deprecated.1337=[1337] Inherited from Adobe Commerce @deprecated interface {0} in {1}. The deprecated interface will be removed in upcoming versions. Consider removing the interface inheritance, using an interface marked as @api or an interface introduced within your implementation instead.
14+
customCode.warnings.deprecated.1338=[1338] Implemented Adobe Commerce @deprecated interface {0} in {1}. The deprecated interface will be removed in upcoming versions. Consider removing the interface inheritance, using an interface marked as @api or an interface introduced within your implementation instead.
15+
customCode.warnings.deprecated.1430=[1430] Call not declared dataobject method. The magic methods that are not declared may be changed. Consider relying on interface methods instead.
16+
customCode.warnings.deprecated.1439=[1439] Call Adobe Commerce @deprecated method. The deprecated method will be removed in upcoming versions. Consider relying on methods declared in API interfaces instead.
17+
customCode.warnings.deprecated.1534=[1534] Using Adobe Commerce @deprecated property. The deprecated method will be removed in upcoming versions. Consider relying on methods declared in API interfaces instead.
18+
customCode.warnings.deprecated.1535=[1535] Overriding Adobe Commerce @deprecated property {0}::{1} in {2}. The deprecated property will be removed in upcoming versions. Consider relying on methods declared in API interfaces or using a private property within your implementation instead.
19+
customCode.warnings.deprecated.1536=[1536] Assignation of Adobe Commerce @deprecated property. The deprecated method will be removed in upcoming versions. Consider relying on methods declared in API interfaces instead.

src/com/magento/idea/magento2plugin/bundles/AbstractBundle.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import com.intellij.CommonBundle;
99
import java.util.ResourceBundle;
1010

11-
abstract class AbstractBundle {
11+
public abstract class AbstractBundle {
1212

1313
abstract public String getBundleName();
1414

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
package com.magento.idea.magento2uct.actions;
7+
8+
import com.intellij.icons.AllIcons;
9+
import com.intellij.ide.IdeView;
10+
import com.intellij.openapi.actionSystem.AnAction;
11+
import com.intellij.openapi.actionSystem.AnActionEvent;
12+
import com.intellij.openapi.actionSystem.LangDataKeys;
13+
import com.intellij.openapi.application.ApplicationManager;
14+
import com.intellij.openapi.project.Project;
15+
import com.intellij.psi.PsiDirectory;
16+
import com.intellij.psi.PsiFile;
17+
import com.magento.idea.magento2plugin.project.Settings;
18+
import com.magento.idea.magento2uct.versioning.IndexRegistry;
19+
import com.magento.idea.magento2uct.versioning.IndexRepository;
20+
import com.magento.idea.magento2uct.versioning.processors.DeprecationIndexProcessor;
21+
import com.magento.idea.magento2uct.versioning.scanner.ModuleFilesScanner;
22+
import com.magento.idea.magento2uct.versioning.scanner.ModuleScanner;
23+
import com.magento.idea.magento2uct.versioning.scanner.data.ComponentData;
24+
import java.util.HashMap;
25+
import java.util.Map;
26+
import org.jetbrains.annotations.NotNull;
27+
28+
public class ReindexVersionedIndexesAction extends AnAction {
29+
30+
public static final String ACTION_NAME = "Reindex the UCT versioned indexes";
31+
public static final String ACTION_DESCRIPTION =
32+
"Action provides reindexing feature for the internal UCT framework";
33+
34+
/**
35+
* Action constructor.
36+
*/
37+
public ReindexVersionedIndexesAction() {
38+
super(ACTION_NAME, ACTION_DESCRIPTION, AllIcons.Actions.Execute);
39+
}
40+
41+
@Override
42+
public void update(final @NotNull AnActionEvent event) {
43+
setIsAvailableForEvent(event, false);
44+
final Project project = event.getProject();
45+
46+
if (project == null
47+
|| !Settings.isEnabled(project)
48+
|| !ApplicationManager.getApplication().isInternal()) {
49+
return;
50+
}
51+
setIsAvailableForEvent(event, true);
52+
}
53+
54+
@Override
55+
public void actionPerformed(final @NotNull AnActionEvent event) {
56+
final Project project = event.getProject();
57+
final IdeView ideView = LangDataKeys.IDE_VIEW.getData(event.getDataContext());
58+
59+
if (project == null || ideView == null) {
60+
return;
61+
}
62+
final PsiDirectory directory = ideView.getOrChooseDirectory();
63+
64+
if (directory == null) {
65+
return;
66+
}
67+
final IndexRepository<String, Boolean> storage =
68+
new IndexRepository<>(project.getBasePath(), IndexRegistry.DEPRECATION);
69+
final Map<String, Boolean> deprecationData = new HashMap<>();
70+
71+
for (final ComponentData componentData : new ModuleScanner(directory)) {
72+
for (final PsiFile psiFile : new ModuleFilesScanner(componentData)) {
73+
deprecationData.putAll(new DeprecationIndexProcessor().process(psiFile));
74+
}
75+
}
76+
77+
if (!deprecationData.isEmpty()) {
78+
storage.put(deprecationData, "2.3.0");
79+
}
80+
81+
System.out.println(ACTION_NAME + " is run!!!!!!");
82+
}
83+
84+
/**
85+
* Set is action available for event.
86+
*
87+
* @param event AnActionEvent
88+
* @param isAvailable boolean
89+
*/
90+
private void setIsAvailableForEvent(
91+
final @NotNull AnActionEvent event,
92+
final boolean isAvailable
93+
) {
94+
event.getPresentation().setVisible(isAvailable);
95+
event.getPresentation().setEnabled(isAvailable);
96+
}
97+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
package com.magento.idea.magento2uct.actions;
7+
8+
import com.intellij.icons.AllIcons;
9+
import com.intellij.openapi.actionSystem.AnAction;
10+
import com.intellij.openapi.actionSystem.AnActionEvent;
11+
import com.intellij.openapi.diagnostic.Logger;
12+
import com.intellij.openapi.project.Project;
13+
import com.magento.idea.magento2plugin.project.Settings;
14+
import com.magento.idea.magento2uct.execution.RunAnalysisExecutor;
15+
import com.magento.idea.magento2uct.execution.process.DefaultAnalysisHandler;
16+
import org.jetbrains.annotations.NotNull;
17+
18+
public class RunUpgradeCompatibilityToolAction extends AnAction {
19+
20+
public static final String ACTION_NAME = "Run The Upgrade Compatibility Tool";
21+
public static final String ACTION_DESCRIPTION = "Magento 2 Upgrade Compatibility Tool";
22+
private static final Logger LOG = Logger.getInstance(RunUpgradeCompatibilityToolAction.class);
23+
24+
/**
25+
* An action constructor.
26+
*/
27+
public RunUpgradeCompatibilityToolAction() {
28+
super(ACTION_NAME, ACTION_DESCRIPTION, AllIcons.Actions.Execute);
29+
}
30+
31+
@Override
32+
public void update(final @NotNull AnActionEvent event) {
33+
setIsAvailableForEvent(event, false);
34+
final Project project = event.getProject();
35+
36+
if (project == null || !Settings.isEnabled(project)) {
37+
return;
38+
}
39+
setIsAvailableForEvent(event, true);
40+
}
41+
42+
@Override
43+
public void actionPerformed(final @NotNull AnActionEvent event) {
44+
final Project project = event.getProject();
45+
46+
if (project == null) {
47+
return;
48+
}
49+
System.out.println("!!!...Action Performing Start...!!!");
50+
51+
final RunAnalysisExecutor executor = new RunAnalysisExecutor(
52+
project,
53+
new DefaultAnalysisHandler(project)
54+
);
55+
executor.run();
56+
57+
System.out.println("!!!...Action Performing End...!!!");
58+
}
59+
60+
/**
61+
* Set is action available for event.
62+
*
63+
* @param event AnActionEvent
64+
* @param isAvailable boolean
65+
*/
66+
private void setIsAvailableForEvent(
67+
final @NotNull AnActionEvent event,
68+
final boolean isAvailable
69+
) {
70+
event.getPresentation().setVisible(isAvailable);
71+
event.getPresentation().setEnabled(isAvailable);
72+
}
73+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
package com.magento.idea.magento2uct.bundles;
7+
8+
import com.magento.idea.magento2plugin.bundles.AbstractBundle;
9+
10+
public class UctInspectionBundle extends AbstractBundle {
11+
12+
private static final String BUNDLE_NAME = "uct.bundle.inspection";
13+
14+
@Override
15+
public String getBundleName() {
16+
return BUNDLE_NAME;
17+
}
18+
}

0 commit comments

Comments
 (0)