Skip to content

Commit d394c18

Browse files
UCT-719: Added Inherited from non API interface inspection
1 parent 1a7f3ec commit d394c18

File tree

5 files changed

+69
-0
lines changed

5 files changed

+69
-0
lines changed

resources/META-INF/plugin.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,13 @@
487487
enabledByDefault="false"
488488
level="WARNING"
489489
implementationClass="com.magento.idea.magento2uct.inspections.php.api.ExtendedNonApiClass"/>
490+
<localInspection language="PHP" groupPath="UCT"
491+
shortName="InheritedNonApiInterface"
492+
bundle="uct.bundle.inspection" key="inspection.displayName.InheritedNonApiInterface"
493+
groupBundle="uct.bundle.inspection" groupKey="inspection.api.group.name"
494+
enabledByDefault="false"
495+
level="WARNING"
496+
implementationClass="com.magento.idea.magento2uct.inspections.php.api.InheritedNonApiInterface"/>
490497
<!-- \UCT inspection -->
491498

492499
<internalFileTemplate name="Magento Composer JSON"/>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<html>
2+
<body>
3+
<p>[1327] The inherited interface is not marked as an API.</p>
4+
<!-- tooltip end -->
5+
</body>
6+
</html>

resources/uct/bundle/inspection.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ inspection.displayName.UsedNonApiProperty=Used non Adobe Commerce API property
3535
inspection.displayName.UsedNonApiType=Used non Adobe Commerce API type
3636
inspection.displayName.ImplementedNonApiInterface=Implemented non Adobe Commerce API interface
3737
inspection.displayName.ExtendedNonApiClass=Extended non Adobe Commerce API class
38+
inspection.displayName.InheritedNonApiInterface=Inherited non Adobe Commerce API interface
3839
customCode.warnings.deprecated.1131=[1131] Extended class ''{0}'' that is @deprecated in the ''{1}''
3940
customCode.warnings.deprecated.1132=[1132] Imported class ''{0}'' that is @deprecated in the ''{1}''
4041
customCode.warnings.deprecated.1134=[1134] Used class ''{0}'' that is @deprecated in the ''{1}''
@@ -68,3 +69,4 @@ customCode.errors.api.1524=[1524] Used property ''{0}'' is not marked as an API
6869
customCode.errors.api.1124=[1124] Used type ''{0}'' is not marked as an API
6970
customCode.errors.api.1328=[1328] Implemented interface ''{0}'' is not marked as an API
7071
customCode.errors.api.1121=[1121] Extended class ''{0}'' is not marked as an API
72+
customCode.errors.api.1327=[1327] Inherited interface ''{0}'' is not marked as an API
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
package com.magento.idea.magento2uct.inspections.php.api;
7+
8+
import com.intellij.codeInspection.ProblemHighlightType;
9+
import com.intellij.codeInspection.ProblemsHolder;
10+
import com.intellij.openapi.project.Project;
11+
import com.jetbrains.php.lang.psi.elements.ClassReference;
12+
import com.magento.idea.magento2uct.inspections.UctProblemsHolder;
13+
import com.magento.idea.magento2uct.inspections.php.InheritedInterfaceInspection;
14+
import com.magento.idea.magento2uct.packages.IssueSeverityLevel;
15+
import com.magento.idea.magento2uct.packages.SupportedIssue;
16+
import com.magento.idea.magento2uct.versioning.VersionStateManager;
17+
import org.jetbrains.annotations.NotNull;
18+
19+
public class InheritedNonApiInterface extends InheritedInterfaceInspection {
20+
21+
@Override
22+
protected void execute(
23+
final Project project,
24+
final @NotNull ProblemsHolder problemsHolder,
25+
final ClassReference reference,
26+
final String interfaceFqn
27+
) {
28+
if (VersionStateManager.getInstance(project).isApi(interfaceFqn)) {
29+
return;
30+
}
31+
final String message = SupportedIssue.INHERITED_NON_API_INTERFACE.getMessage(
32+
interfaceFqn
33+
);
34+
35+
if (problemsHolder instanceof UctProblemsHolder) {
36+
((UctProblemsHolder) problemsHolder).setReservedErrorCode(
37+
SupportedIssue.INHERITED_NON_API_INTERFACE.getCode()
38+
);
39+
}
40+
problemsHolder.registerProblem(reference, message, ProblemHighlightType.WARNING);
41+
}
42+
43+
@Override
44+
protected IssueSeverityLevel getSeverityLevel() {
45+
return SupportedIssue.INHERITED_NON_API_INTERFACE.getLevel();
46+
}
47+
}

src/com/magento/idea/magento2uct/packages/SupportedIssue.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import com.magento.idea.magento2uct.inspections.php.api.ImplementedNonApiInterface;
1515
import com.magento.idea.magento2uct.inspections.php.api.ImportedNonApiClass;
1616
import com.magento.idea.magento2uct.inspections.php.api.ImportedNonApiInterface;
17+
import com.magento.idea.magento2uct.inspections.php.api.InheritedNonApiInterface;
1718
import com.magento.idea.magento2uct.inspections.php.api.OverriddenNonApiConstant;
1819
import com.magento.idea.magento2uct.inspections.php.api.OverriddenNonApiProperty;
1920
import com.magento.idea.magento2uct.inspections.php.api.UsedNonApiConstant;
@@ -247,6 +248,12 @@ public enum SupportedIssue {
247248
IssueSeverityLevel.ERROR,
248249
"customCode.errors.api.1121",
249250
ExtendedNonApiClass.class
251+
),
252+
INHERITED_NON_API_INTERFACE(
253+
1327,
254+
IssueSeverityLevel.ERROR,
255+
"customCode.errors.api.1327",
256+
InheritedNonApiInterface.class
250257
);
251258

252259
private final int code;

0 commit comments

Comments
 (0)