Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .claude/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extraKnownMarketplaces": {
"consulo-skills": {
"source": {
"source": "github",
"repo": "consulo/claude-skills"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="consulo:run-desktop-awt" type="MavenRunConfiguration" factoryName="Maven" singleton="true">
<configuration default="false" name="consulo:run-desktop-awt-fork" type="MavenRunConfiguration" factoryName="Maven" singleton="true">
<MavenSettings>
<option name="myGeneralSettings" />
<option name="myRunnerSettings">
Expand All @@ -14,7 +14,7 @@
<option name="passParentEnv" value="true" />
<option name="runMavenInBackground" value="true" />
<option name="skipTests" value="false" />
<option name="vmOptions" value="--add-opens=java.desktop/sun.awt=ALL-UNNAMED --add-opens=java.desktop/sun.swing=ALL-UNNAMED --add-opens=java.desktop/sun.awt.image=ALL-UNNAMED --add-opens=java.desktop/sun.java2d=ALL-UNNAMED --add-opens=java.desktop/sun.font=ALL-UNNAMED --add-opens=java.desktop/java.awt=ALL-UNNAMED --add-opens=java.desktop/javax.swing=ALL-UNNAMED --add-opens=java.desktop/javax.swing.plaf.basic=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.desktop/javax.swing.text.html=ALL-UNNAMED --add-opens=java.desktop/java.awt.peer=ALL-UNNAMED --add-opens=java.desktop/java.awt.event=ALL-UNNAMED" />
<option name="vmOptions" value="" />
</MavenRunnerSettings>
</option>
<option name="myRunnerParameters">
Expand All @@ -24,7 +24,7 @@
</option>
<option name="goals">
<list>
<option value="consulo:run-desktop-awt" />
<option value="consulo:run-desktop-awt-fork" />
<option value="-pl" />
<option value=":consulo.java" />
</list>
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
/target
target/
dependency-reduced-pom.xml
plugin/sandbox
plugin/sandbox
.claude/settings.local.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ add.explicit.type.arguments:
text: Add explicit type arguments
annotate.as.safevarargs:
text: Annotate as @SafeVarargs
annotation.on.static.member.qualifying.type.family.name:
text: Move annotation
annotate.overridden.methods.parameters:
text: Annotate overridden method parameters as ''@{0}''
annotate.overridden.methods.parameters.family.name:
Expand All @@ -30,6 +32,8 @@ change.visibility.level:
text: Make {0} {1}
comparision.between.object.and.primitive:
text: Comparision between Object and primitive is illegal and is accepted in java 7 only
conflicting.nullability.annotations:
text: Conflicting nullability annotations
contract.return.validator.incompatible.return.parameter.type:
text: return type ''{0}'' must be convertible from parameter type ''{1}''
contract.return.validator.method.return.incompatible.with.method.containing.class:
Expand Down Expand Up @@ -686,12 +690,46 @@ inspection.nullable.problems.annotated.field.setter.parameter.conflict:
text: Setter parameter for @{0} field is annotated @{1}
inspection.nullable.problems.annotated.field.setter.parameter.not.annotated:
text: Setter parameter for @{0} field might be annotated @{0} itself
inspection.nullable.problems.applied.to.package:
text: Annotation on fully-qualified name must be placed before the last component
inspection.nullable.problems.at.class:
text: Nullability annotation is not applicable to classes
inspection.nullable.problems.at.constructor:
text: Nullability annotation is not applicable to constructors
inspection.nullable.problems.at.enum.constant:
text: Nullability annotation is not applicable to enum constants
inspection.nullable.problems.at.local.variable:
text: Nullability annotation is not applicable to local variables
inspection.nullable.problems.at.reference.list:
text: Nullability annotation is not applicable to extends/implements clause
inspection.nullable.problems.at.throws:
text: Nullability annotation is not applicable to 'throws' clause
inspection.nullable.problems.at.type.parameter:
text: Nullability annotation is not applicable to type parameters
inspection.nullable.problems.at.wildcard:
text: Nullability annotation is not applicable to wildcard type
inspection.nullable.problems.constructor.not.compatible.non.null.type.argument:
text: Constructor is not compatible with a non-null type argument
inspection.nullable.problems.method.overrides.NotNull:
text: Not annotated method overrides method annotated with @{0}
inspection.nullable.problems.nullable.instantiation.of.notnull:
text: Non-null type parameter ''{0}'' cannot be instantiated with @{1} type
inspection.nullable.problems.nullable.instantiation.of.notnull.container:
text: Non-null type parameter ''{0}'' cannot be instantiated under @{1}
inspection.nullable.problems.outer.type:
text: Outer type is inherently non-null
inspection.nullable.problems.parameter.overrides.NotNull:
text: Not annotated parameter overrides @{0} parameter
inspection.nullable.problems.primitive.type.annotation:
text: Primitive type members cannot be annotated
inspection.nullable.problems.receiver.annotation:
text: Receiver parameter is inherently non-null
inspection.nullable.problems.redundant.annotation.inherited.notnull:
text: 'Redundant nullability annotation: type parameter upper bound is already non-null'
inspection.nullable.problems.redundant.annotation.under.container:
text: Redundant nullability annotation in the scope of @{0}
inspection.nullable.problems.turn.off.redundant.annotation.under.container:
text: Don't report redundant nullability annotation in the scope of annotated container
inspection.numeric.overflow.display.name:
text: Numeric overflow
inspection.objects.equals.can.be.simplified.display.name:
Expand Down Expand Up @@ -816,6 +854,12 @@ instance.member.guarded.by.static.ref.loc:
text: 'Instance member guarded by static #ref #loc'
intention.add.annotation.family:
text: Add annotation
intention.add.type.annotation.family:
text: Add type annotation
intention.family.name.move.annotation.to.array:
text: Move annotation to array type
intention.family.name.move.annotation.to.upper.bound:
text: Move annotation to upper bound
intention.name.qualify.expression:
text: Qualify {0} expression with ''{1}''
intention.text.remove.annotation:
Expand Down Expand Up @@ -1068,3 +1112,17 @@ vararg.method.call.with.50.poly.arguments:
text: Vararg method call with 50+ poly arguments may cause compilation and analysis slowdown
visible.for.testing.makes.little.sense.on.test.only.code:
text: '@VisibleForTesting makes little sense on @TestOnly code'
complex.problem.with.nullability:
text: <html><body>Incompatible type arguments due to nullability{0}</body></html>
assigning.a.class.with.nullable.elements:
text: <html><body>Assigning a class with nullable type arguments when a class with not-null type arguments is expected{0}</body></html>
assigning.a.class.with.notnull.elements:
text: <html><body>Assigning a class with not-null type arguments when a class with nullable type arguments is expected{0}</body></html>
overriding.a.class.with.nullable.elements:
text: <html><body>Overriding a class with nullable type arguments when a class with not-null type arguments is expected{0}</body></html>
overriding.a.class.with.notnull.elements:
text: <html><body>Overriding a class with not-null type arguments when a class with nullable type arguments is expected{0}</body></html>
returning.a.class.with.nullable.arguments:
text: <html><body>Returning a class with nullable type arguments when a class with not-null type arguments is expected{0}</body></html>
returning.a.class.with.notnull.arguments:
text: <html><body>Returning a class with not-null type arguments when a class with nullable type arguments is expected{0}</body></html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
/*
* Copyright 2013-2026 consulo.io
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.java.analysis.impl.codeInsight.daemon.impl.quickfix;

import com.intellij.java.language.psi.*;
import com.siyeh.ig.psiutils.CommentTracker;
import consulo.java.analysis.localize.JavaAnalysisLocalize;
import consulo.language.editor.inspection.LocalQuickFix;
import consulo.language.editor.inspection.ProblemDescriptor;
import consulo.language.psi.PsiElement;
import consulo.language.psi.util.PsiTreeUtil;
import consulo.localize.LocalizeValue;
import consulo.project.Project;
import org.jspecify.annotations.Nullable;

public class MoveAnnotationOnStaticMemberQualifyingTypeFix implements LocalQuickFix {
@Override
public LocalizeValue getName() {
return JavaAnalysisLocalize.annotationOnStaticMemberQualifyingTypeFamilyName();
}

@Override
public void applyFix(Project project, ProblemDescriptor descriptor) {
PsiAnnotation annotation = descriptor.getPsiElement() instanceof PsiAnnotation a ? a : null;
if (annotation == null) return;

PsiTypeElement psiTypeElement = getTypeElement(annotation);
if (psiTypeElement == null) return;

PsiJavaCodeReferenceElement innermostParent = psiTypeElement.getInnermostComponentReferenceElement();
if (innermostParent == null) return;

PsiElement rightmostDot = getRightmostDot(innermostParent.getLastChild());
if (rightmostDot == null) return;

innermostParent.addAfter(annotation, rightmostDot);

CommentTracker ct = new CommentTracker();
ct.markUnchanged(annotation);
ct.deleteAndRestoreComments(annotation);
}

private static @Nullable PsiElement getRightmostDot(@Nullable PsiElement element) {
if (element == null) {
return null;
}
PsiElement sibling = element.getPrevSibling();
while (sibling != null) {
if (sibling.getNode() != null && sibling.getNode().getElementType() == JavaTokenType.DOT) {
return sibling;
}
sibling = sibling.getPrevSibling();
}
return null;
}

private static @Nullable PsiTypeElement getTypeElement(PsiElement startElement) {
PsiElement parent = PsiTreeUtil.getParentOfType(startElement, PsiTypeElement.class, PsiVariable.class, PsiMethod.class);
if (parent instanceof PsiTypeElement typeElement) {
return typeElement;
}
if (parent instanceof PsiVariable variable) {
return variable.getTypeElement();
}
if (parent instanceof PsiMethod method) {
return method.getReturnTypeElement();
}
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
/*
* Copyright 2013-2026 consulo.io
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.java.analysis.impl.codeInsight.intention;

import com.intellij.java.language.psi.PsiAnnotation;
import com.intellij.java.language.psi.PsiTypeElement;
import com.intellij.java.language.psi.codeStyle.JavaCodeStyleManager;
import consulo.java.analysis.localize.JavaAnalysisLocalize;
import consulo.language.editor.inspection.LocalQuickFix;
import consulo.language.editor.inspection.ProblemDescriptor;
import consulo.language.psi.PsiElement;
import consulo.language.psi.SmartPointerManager;
import consulo.language.psi.SmartPsiElementPointer;
import consulo.localize.LocalizeValue;
import consulo.project.Project;
import consulo.util.lang.StringUtil;

import java.util.Collection;

public class AddTypeAnnotationFix implements LocalQuickFix {
private final SmartPsiElementPointer<PsiTypeElement> myElement;
private final String myAnnotationToAdd;
private final Collection<String> myAnnotationsToRemove;

public AddTypeAnnotationFix(PsiTypeElement element, String annotationToAdd, Collection<String> annotationsToRemove) {
myElement = SmartPointerManager.createPointer(element);
myAnnotationToAdd = annotationToAdd;
myAnnotationsToRemove = annotationsToRemove;
}

@Override
public LocalizeValue getName() {
return JavaAnalysisLocalize.inspectionI18nQuickfixAnnotateAs(StringUtil.getShortName(myAnnotationToAdd));
}

@Override
public void applyFix(Project project, ProblemDescriptor descriptor) {
PsiTypeElement typeElement = myElement.getElement();
if (typeElement == null || !typeElement.acceptsAnnotations()) return;

for (PsiAnnotation annotation : typeElement.getAnnotations()) {
if (myAnnotationsToRemove.contains(annotation.getQualifiedName())) {
annotation.delete();
}
}
JavaCodeStyleManager.getInstance(project).shortenClassReferences(typeElement.addAnnotation(myAnnotationToAdd));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,40 +22,61 @@
import consulo.language.editor.inspection.LocalQuickFix;
import consulo.language.editor.inspection.ProblemDescriptor;
import consulo.language.editor.localize.CodeInsightLocalize;
import consulo.language.psi.SmartPointerManager;
import consulo.language.psi.SmartPsiElementPointer;
import consulo.language.util.IncorrectOperationException;
import consulo.localize.LocalizeValue;
import consulo.logging.Logger;
import consulo.project.Project;
import org.jetbrains.annotations.NotNull;
import org.jspecify.annotations.Nullable;

/**
* @author yole
*/
public class RemoveAnnotationQuickFix implements LocalQuickFix {
private static final Logger LOG = Logger.getInstance(RemoveAnnotationQuickFix.class);
private final PsiAnnotation myAnnotation;
private final PsiModifierListOwner myListOwner;
private static final Logger LOG = Logger.getInstance(RemoveAnnotationQuickFix.class);
private final SmartPsiElementPointer<PsiAnnotation> myAnnotation;
private final SmartPsiElementPointer<PsiModifierListOwner> myListOwner;
private final boolean myRemoveInheritors;

public RemoveAnnotationQuickFix(PsiAnnotation annotation, final PsiModifierListOwner listOwner) {
myAnnotation = annotation;
myListOwner = listOwner;
}
public RemoveAnnotationQuickFix(@NotNull PsiAnnotation annotation, @Nullable PsiModifierListOwner listOwner) {
this(annotation, listOwner, false);
}

public RemoveAnnotationQuickFix(@NotNull PsiAnnotation annotation, @Nullable PsiModifierListOwner listOwner, boolean removeInheritors) {
Project project = annotation.getProject();
SmartPointerManager pm = SmartPointerManager.getInstance(project);
myAnnotation = pm.createSmartPsiElementPointer(annotation);
myListOwner = listOwner == null ? null : pm.createSmartPsiElementPointer(listOwner);
myRemoveInheritors = removeInheritors;
}

@Override
public LocalizeValue getName() {
return CodeInsightLocalize.removeAnnotation();
}

@Override
public LocalizeValue getName() {
return CodeInsightLocalize.removeAnnotation();
}
@Override
public void applyFix(Project project, ProblemDescriptor descriptor) {
PsiAnnotation annotation = myAnnotation.getElement();
if (annotation == null) {
return;
}

@Override
public void applyFix(Project project, ProblemDescriptor descriptor) {
if (myAnnotation.isPhysical()) {
try {
if (!FileModificationService.getInstance().preparePsiElementForWrite(myAnnotation)) return;
myAnnotation.delete();
} catch (IncorrectOperationException e) {
LOG.error(e);
}
} else {
ExternalAnnotationsManager.getInstance(project).deannotate(myListOwner, myAnnotation.getQualifiedName());
if (annotation.isPhysical()) {
try {
if (!FileModificationService.getInstance().preparePsiElementForWrite(annotation)) {
return;
}
annotation.delete();
}
catch (IncorrectOperationException e) {
LOG.error(e);
}
}
else {
ExternalAnnotationsManager.getInstance(project).deannotate(myListOwner.getElement(), annotation.getQualifiedName());
}
}
}
}
Loading
Loading