-
Notifications
You must be signed in to change notification settings - Fork 1
Adding missing @Override annotations (part 3). Adding RRA/RWA/RUI annotations. Some localization and refactoring #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,14 +8,13 @@ | |
| import com.intellij.aop.psi.AopPointcutExpressionFile; | ||
| import com.intellij.java.language.psi.PsiClass; | ||
| import com.intellij.java.language.psi.PsiLiteralExpression; | ||
| import com.intellij.java.language.psi.PsiMethod; | ||
| import com.intellij.java.language.psi.PsiModifier; | ||
| import com.intellij.java.language.psi.PsiMember; | ||
| import consulo.annotation.access.RequiredReadAction; | ||
| import consulo.annotation.component.ExtensionImpl; | ||
| import consulo.aop.localize.AopLocalize; | ||
| import consulo.document.util.TextRange; | ||
| import consulo.language.editor.inspection.LocalQuickFix; | ||
| import consulo.language.editor.inspection.ProblemDescriptor; | ||
| import consulo.language.editor.inspection.ProblemHighlightType; | ||
| import consulo.language.editor.inspection.ProblemsHolder; | ||
| import consulo.language.editor.rawHighlight.HighlightDisplayLevel; | ||
| import consulo.language.inject.InjectedLanguageManager; | ||
|
|
@@ -27,13 +26,11 @@ | |
| import consulo.logging.Logger; | ||
| import consulo.project.Project; | ||
| import consulo.util.collection.ContainerUtil; | ||
| import consulo.util.lang.function.Condition; | ||
| import consulo.virtualFileSystem.ReadonlyStatusHandler; | ||
| import consulo.xml.editor.XmlSuppressableInspectionTool; | ||
| import consulo.xml.language.psi.XmlAttributeValue; | ||
| import consulo.xml.language.psi.XmlElement; | ||
| import jakarta.annotation.Nonnull; | ||
| import org.jetbrains.annotations.NonNls; | ||
|
|
||
| /** | ||
| * @author peter | ||
|
|
@@ -42,11 +39,13 @@ | |
| public class DeclareParentsInspection extends XmlSuppressableInspectionTool { | ||
| private static final Logger LOG = Logger.getInstance(DeclareParentsInspection.class); | ||
|
|
||
| @Override | ||
| public boolean isEnabledByDefault() { | ||
| return true; | ||
| } | ||
|
|
||
| @Nonnull | ||
| @Override | ||
| public HighlightDisplayLevel getDefaultLevel() { | ||
| return HighlightDisplayLevel.ERROR; | ||
| } | ||
|
|
@@ -64,9 +63,11 @@ public String getShortName() { | |
| } | ||
|
|
||
| @Nonnull | ||
| @Override | ||
| public PsiElementVisitor buildVisitor(@Nonnull final ProblemsHolder holder, boolean isOnTheFly) { | ||
| return new PsiElementVisitor() { | ||
| @Override | ||
| @RequiredReadAction | ||
| public void visitElement(PsiElement element) { | ||
| if (element instanceof PsiLiteralExpression || element instanceof XmlAttributeValue) { | ||
| PsiElement injectedElement = | ||
|
|
@@ -76,9 +77,8 @@ public void visitElement(PsiElement element) { | |
| ); | ||
|
|
||
| PsiFile file = injectedElement == null ? null : injectedElement.getContainingFile(); | ||
| if (file instanceof AopPointcutExpressionFile) { | ||
| final IntroductionManipulator manipulator = | ||
| ((AopPointcutExpressionFile) file).getAopModel().getIntroductionManipulator(); | ||
| if (file instanceof AopPointcutExpressionFile pointcutExpressionFile) { | ||
| final IntroductionManipulator manipulator = pointcutExpressionFile.getAopModel().getIntroductionManipulator(); | ||
| if (manipulator == null) { | ||
| return; | ||
| } | ||
|
|
@@ -90,7 +90,7 @@ public void visitElement(PsiElement element) { | |
| PsiClass intf = introduction.getImplementInterface().getValue(); | ||
| if (intf == null && introduction.getImplementInterface().getStringValue() != null | ||
| || intf != null && !intf.isInterface()) { | ||
| registerProblem(manipulator.getInterfaceElement(), AopLocalize.errorInterfaceExpected().get(), holder); | ||
| registerProblem(manipulator.getInterfaceElement(), AopLocalize.errorInterfaceExpected(), holder); | ||
| return; | ||
| } | ||
| if (intf == null) { | ||
|
|
@@ -99,14 +99,8 @@ public void visitElement(PsiElement element) { | |
|
|
||
| PsiClass defaultImpl = introduction.getDefaultImpl().getValue(); | ||
| if (defaultImpl == null) { | ||
| if (!(element instanceof XmlElement) && !ContainerUtil.findAll( | ||
| intf.getAllMethods(), | ||
| new Condition<PsiMethod>() { | ||
| public boolean value(PsiMethod method) { | ||
| return method.hasModifierProperty(PsiModifier.ABSTRACT); | ||
| } | ||
| } | ||
| ).isEmpty()) { | ||
| if (!(element instanceof XmlElement) | ||
| && !ContainerUtil.findAll(intf.getAllMethods(), PsiMember::isAbstract).isEmpty()) { | ||
| holder.newProblem(AopLocalize.errorDefaultImplementationClassShouldBeSpecified()) | ||
| .range(manipulator.getCommonProblemElement()) | ||
| .withFix(new LocalQuickFix() { | ||
|
|
@@ -116,6 +110,7 @@ public LocalizeValue getName() { | |
| return AopLocalize.quickfixNameDefineAttribute(manipulator.getDefaultImplAttributeName()); | ||
| } | ||
|
|
||
| @Override | ||
| public void applyFix(@Nonnull Project project, @Nonnull ProblemDescriptor descriptor) { | ||
| try { | ||
| if (ReadonlyStatusHandler.getInstance(project) | ||
|
|
@@ -137,12 +132,12 @@ public void applyFix(@Nonnull Project project, @Nonnull ProblemDescriptor descri | |
| } | ||
| return; | ||
| } | ||
| if (defaultImpl.hasModifierProperty(PsiModifier.ABSTRACT) || !defaultImpl.isInheritor(intf, true)) { | ||
| if (defaultImpl.isAbstract() || !defaultImpl.isInheritor(intf, true)) { | ||
| PsiElement defaultImplElement = manipulator.getDefaultImplElement(); | ||
| assert defaultImplElement != null; | ||
| registerProblem( | ||
| defaultImplElement, | ||
| AopLocalize.errorNonAbstractClassImplemention0Expected(intf.getQualifiedName()).get(), | ||
| AopLocalize.errorNonAbstractClassImplemention0Expected(intf.getQualifiedName()), | ||
| holder | ||
| ); | ||
| } | ||
|
|
@@ -152,16 +147,12 @@ public void applyFix(@Nonnull Project project, @Nonnull ProblemDescriptor descri | |
| }; | ||
| } | ||
|
|
||
| private static void registerProblem(PsiElement element, String descriptionTemplate, ProblemsHolder holder) { | ||
| @RequiredReadAction | ||
| private static void registerProblem(PsiElement element, LocalizeValue descriptionTemplate, ProblemsHolder holder) { | ||
| int startOffset = element.getTextRange().getStartOffset(); | ||
| int quotes = element.getText().startsWith("\"") ? 1 : 0; | ||
| TextRange range = TextRange.from(quotes, Math.max(element.getTextLength() - 2 * quotes, 1)); | ||
| holder.registerProblem(holder.getManager().createProblemDescriptor( | ||
| element, | ||
| range, | ||
| descriptionTemplate, | ||
| ProblemHighlightType.GENERIC_ERROR_OR_WARNING | ||
| )); | ||
| holder.registerProblem(holder.getManager().newProblemDescriptor(descriptionTemplate).range(element, range).create()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @.claude-review-dp.md |
||
| } | ||
|
|
||
| @Nonnull | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The old implementation passed
ProblemHighlightType.GENERIC_ERROR_OR_WARNINGexplicitly.newProblemDescriptor(...).range(...).create()relies on the builder's default highlight type. Please confirm that default is stillGENERIC_ERROR_OR_WARNING, otherwise the severity/appearance of this reported problem changes silently.