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
Original file line number Diff line number Diff line change
Expand Up @@ -1776,7 +1776,7 @@ public static HighlightInfo.Builder checkOverrideEquivalentInheritedMethods(
PsiFile containingFile,
@Nonnull LanguageLevel languageLevel
) {
String description = null;
LocalizeValue description = LocalizeValue.empty();
boolean appendImplementMethodFix = true;
Collection<HierarchicalMethodSignature> visibleSignatures = aClass.getVisibleSignatures();
PsiResolveHelper resolveHelper = JavaPsiFacade.getInstance(aClass.getProject()).getResolveHelper();
Expand Down Expand Up @@ -1821,35 +1821,35 @@ public static HighlightInfo.Builder checkOverrideEquivalentInheritedMethods(
HighlightUtil.formatClass(containingClass),
JavaHighlightUtil.formatMethod(superMethod),
HighlightUtil.formatClass(superMethod.getContainingClass())
).get();
);
appendImplementMethodFix = false;
break Ultimate;
}
}
continue;
}

if (description == null) {
if (description == LocalizeValue.empty()) {
highlightInfo = checkMethodIncompatibleThrows(signature, superSignatures, false, aClass);
if (highlightInfo != null) {
description = highlightInfo.getDescription();
}
}

if (description == null) {
if (description == LocalizeValue.empty()) {
HighlightInfo.Builder hlBuilder = checkMethodWeakerPrivileges(signature, superSignatures, false, containingFile);
highlightInfo = hlBuilder == null ? null : hlBuilder.create();
if (highlightInfo != null) {
description = highlightInfo.getDescription();
}
}

if (description != null) {
if (description != LocalizeValue.empty()) {
break;
}
}

if (description != null) {
if (description != LocalizeValue.empty()) {
// show error info at the class level
HighlightInfo.Builder hlBuilder = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR)
.range(HighlightNamesUtil.getClassDeclarationTextRange(aClass))
Expand Down Expand Up @@ -2321,22 +2321,10 @@ private static void registerChangeMethodSignatureFromUsageIntention(
PsiSubstitutor substitutor = candidate.getSubstitutor();
if (method != null && context.getManager().isInProject(method)) {
QuickFixFactory factory = QuickFixFactory.getInstance();
hlBuilder.newFix(factory.createChangeMethodSignatureFromUsageFix(
method,
expressions,
substitutor,
context,
false,
2
)).fixRange(fixRange).register()
.newFix(factory.createChangeMethodSignatureFromUsageReverseOrderFix(
method,
expressions,
substitutor,
context,
false,
2
)).fixRange(fixRange).register();
hlBuilder.newFix(factory.createChangeMethodSignatureFromUsageFix(method, expressions, substitutor, context, false, 2))
.fixRange(fixRange).register()
.newFix(factory.createChangeMethodSignatureFromUsageReverseOrderFix(method, expressions, substitutor, context, false, 2))
.fixRange(fixRange).register();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2732,10 +2732,11 @@ public static HighlightInfo.Builder checkMemberReferencedBeforeConstructorCalled
referencedClass = PsiUtil.resolveClassInType(type);
}
else if (qualifier == null) {
resolved = PsiTreeUtil.getParentOfType(expression, PsiMethod.class, true, PsiMember.class);
if (resolved != null) {
referencedClass = ((PsiMethod) resolved).getContainingClass();
PsiMethod method = PsiTreeUtil.getParentOfType(expression, PsiMethod.class, true, PsiMember.class);
if (method != null) {
referencedClass = method.getContainingClass();
}
resolved = method;
}
else if (qualifier instanceof PsiThisExpression thisExpr) {
referencedClass = PsiUtil.resolveClassInType(thisExpr.getType());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import consulo.language.util.IncorrectOperationException;
import consulo.logging.Logger;
import consulo.util.lang.Comparing;
import jakarta.annotation.Nonnull;
import jakarta.annotation.Nullable;

import java.util.*;
Expand All @@ -38,7 +39,7 @@ public abstract class ArgumentFixerActionFactory {
protected abstract PsiExpression getModifiedArgument(PsiExpression expression, PsiType toType) throws IncorrectOperationException;

@RequiredWriteAction
public void registerCastActions(CandidateInfo[] candidates, PsiCall call, HighlightInfo.Builder hlBuilder, TextRange fixRange) {
public void registerCastActions(CandidateInfo[] candidates, PsiCall call, HighlightInfo.Builder hlBuilder, @Nonnull TextRange fixRange) {
if (candidates.length == 0) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static void registerFixActions(
@Nonnull PsiJavaCodeReferenceElement ctrRef,
PsiConstructorCall constructorCall,
@Nonnull HighlightInfo.Builder highlightInfo,
TextRange fixRange
@Nonnull TextRange fixRange
) {
JavaResolveResult resolved = ctrRef.advancedResolve(false);
PsiClass aClass = (PsiClass)resolved.getElement();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,12 @@ public void invoke(@Nonnull Project project, Editor editor, PsiFile file) throws
}

@RequiredReadAction
public static void registerFix(HighlightInfo.Builder hlBuilder, PsiCall callExpression, CandidateInfo[] candidates, TextRange fixRange) {
public static void registerFix(
HighlightInfo.Builder hlBuilder,
PsiCall callExpression,
CandidateInfo[] candidates,
@Nonnull TextRange fixRange
) {
PsiExpression[] expressions = callExpression.getArgumentList().getExpressions();
if (hlBuilder == null || expressions.length < 2) {
return;
Expand All @@ -87,7 +92,7 @@ public static void registerFix(HighlightInfo.Builder hlBuilder, PsiCall callExpr

for (CandidateInfo candidate : candidates) {
if (candidate instanceof MethodCandidateInfo) {
MethodCandidateInfo methodCandidate = (MethodCandidateInfo)candidate;
MethodCandidateInfo methodCandidate = (MethodCandidateInfo) candidate;
PsiMethod method = methodCandidate.getElement();
PsiSubstitutor substitutor = methodCandidate.getSubstitutor();

Expand Down Expand Up @@ -158,7 +163,7 @@ private static void registerShiftFixes(
{
ArrayUtil.rotateLeft(expressions, i, j);
if (PsiUtil.isApplicable(method, substitutor, expressions)) {
PsiCall copy = (PsiCall)callExpression.copy();
PsiCall copy = (PsiCall) callExpression.copy();
PsiExpression[] copyExpressions = copy.getArgumentList().getExpressions();
for (int k = i; k < copyExpressions.length; k++) {
copyExpressions[k].replace(expressions[k]);
Expand All @@ -178,7 +183,7 @@ private static void registerShiftFixes(
{
ArrayUtil.rotateRight(expressions, i, j);
if (PsiUtil.isApplicable(method, substitutor, expressions)) {
PsiCall copy = (PsiCall)callExpression.copy();
PsiCall copy = (PsiCall) callExpression.copy();
PsiExpression[] copyExpressions = copy.getArgumentList().getExpressions();
for (int k = i; k < copyExpressions.length; k++) {
copyExpressions[k].replace(expressions[k]);
Expand Down Expand Up @@ -218,7 +223,7 @@ private static void registerSwapFixes(
for (int j = i + 1; j <= maxIncompatibleIndex; j++) {
ArrayUtil.swap(expressions, i, j);
if (PsiUtil.isApplicable(method, substitutor, expressions)) {
PsiCall copy = (PsiCall)callExpression.copy();
PsiCall copy = (PsiCall) callExpression.copy();
PsiExpression[] copyExpressions = copy.getArgumentList().getExpressions();
copyExpressions[i].replace(expressions[i]);
copyExpressions[j].replace(expressions[j]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public static void registerQuickFixAction(
CandidateInfo[] candidates,
PsiCall call,
HighlightInfo.Builder highlightInfo,
TextRange fixRange
@Nonnull TextRange fixRange
) {
if (candidates.length == 0) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public static void registerIntentions(
@Nonnull JavaResolveResult[] candidates,
@Nonnull PsiExpressionList arguments,
@Nullable HighlightInfo.Builder hlBuilder,
TextRange fixRange
@Nonnull TextRange fixRange
) {
if (hlBuilder == null) {
return;
Expand All @@ -140,7 +140,7 @@ public static void registerIntentions(
private static void registerIntention(
@Nonnull PsiExpressionList arguments,
@Nonnull HighlightInfo.Builder hlBuilder,
TextRange fixRange,
@Nonnull TextRange fixRange,
@Nonnull JavaResolveResult candidate,
@Nonnull PsiElement context
) {
Expand Down
Loading