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 @@ -51,11 +51,10 @@ public SuppressFix(@Nonnull String ID) {
super(ID, false);
}

@Override
@Nonnull
@Override
public LocalizeValue getText() {
LocalizeValue text = super.getText();
return text == LocalizeValue.of() ? LocalizeValue.localizeTODO("Suppress for member") : text;
return super.getText().orIfEmpty(LocalizeValue.localizeTODO("Suppress for member"));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ else if (isAnnotationRepeatedTwice(owner, annotationType.getQualifiedName())) {
}

LocalizeValue explanation = doCheckRepeatableAnnotation(metaAnno);
if (explanation != LocalizeValue.empty()) {
if (explanation.isNotEmpty()) {
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR)
.range(element)
.descriptionAndTooltip(JavaCompilationErrorLocalize.annotationDuplicateExplained(explanation));
Expand Down Expand Up @@ -676,7 +676,7 @@ public static HighlightInfo.Builder checkFunctionalInterface(@Nonnull PsiAnnotat
psiClass,
JavaCompilationErrorLocalize.lambdaNotAFunctionalInterface(psiClass.getName())
);
if (errorMessage != LocalizeValue.empty()) {
if (errorMessage.isNotEmpty()) {
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR)
.range(annotation)
.descriptionAndTooltip(errorMessage);
Expand All @@ -694,7 +694,7 @@ public static HighlightInfo.Builder checkRepeatableAnnotation(PsiAnnotation anno
}

LocalizeValue description = doCheckRepeatableAnnotation(annotation);
if (description != LocalizeValue.empty()) {
if (description.isNotEmpty()) {
PsiAnnotationMemberValue containerRef = PsiImplUtil.findAttributeValue(annotation, null);
if (containerRef != null) {
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ && detectExpectedType(referenceParameterList) instanceof PsiClassType expectedCl
description = JavaCompilationErrorLocalize.typeParameterCountMismatch(refParametersNum, targetParametersNum);
}

if (description != LocalizeValue.empty()) {
if (description.isNotEmpty()) {
HighlightInfo.Builder hlBuilder = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR)
.range(referenceParameterList)
.descriptionAndTooltip(description);
Expand Down Expand Up @@ -1764,10 +1764,10 @@ public static HighlightInfo.Builder areSupersAccessible(@Nonnull PsiClass aClass
PsiSubstitutor substitutor = resolveResult.getSubstitutor();

message = isSuperTypeAccessible(substitutor.substitute(method.getReturnType()), classes, false, resolveScope, facade);
if (message == LocalizeValue.empty()) {
if (message.isEmpty()) {
for (PsiType type : method.getSignature(substitutor).getParameterTypes()) {
message = isSuperTypeAccessible(type, classes, false, resolveScope, facade);
if (message != LocalizeValue.empty()) {
if (message.isNotEmpty()) {
break;
}
}
Expand All @@ -1784,7 +1784,7 @@ else if (ref.resolve() instanceof PsiField field) {
);
}

if (message != LocalizeValue.empty()) {
if (message.isNotEmpty()) {
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR)
.descriptionAndTooltip(message)
.range(ref.getTextRange());
Expand All @@ -1804,7 +1804,7 @@ private static HighlightInfo.Builder areSupersAccessible(
for (PsiClassType superType : aClass.getSuperTypes()) {
LocalizeValue notAccessibleErrorMessage =
isSuperTypeAccessible(superType, new HashSet<>(), checkParameters, resolveScope, factory);
if (notAccessibleErrorMessage != LocalizeValue.empty()) {
if (notAccessibleErrorMessage.isNotEmpty()) {
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR)
.descriptionAndTooltip(notAccessibleErrorMessage)
.range(range);
Expand Down Expand Up @@ -1843,15 +1843,15 @@ private static LocalizeValue isSuperTypeAccessible(
if (superType instanceof PsiClassType classType) {
for (PsiType psiType : classType.getParameters()) {
LocalizeValue notAccessibleMessage = isSuperTypeAccessible(psiType, classes, true, resolveScope, factory);
if (notAccessibleMessage != LocalizeValue.empty()) {
if (notAccessibleMessage.isNotEmpty()) {
return notAccessibleMessage;
}
}
}

for (PsiClassType type : aClass.getSuperTypes()) {
LocalizeValue notAccessibleMessage = isSuperTypeAccessible(type, classes, !isInLibrary, resolveScope, factory);
if (notAccessibleMessage != LocalizeValue.empty()) {
if (notAccessibleMessage.isNotEmpty()) {
return notAccessibleMessage;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ else if (candidateInfo != null && !candidateInfo.isApplicable()) {
LocalizeValue toolTip;
if (parent instanceof PsiClass) {
toolTip = buildOneLineMismatchDescription(list, candidateInfo, elementToHighlight);
if (toolTip == LocalizeValue.empty()) {
if (toolTip.isEmpty()) {
toolTip = createMismatchedArgumentsHtmlTooltip(candidateInfo, list);
}
}
Expand Down Expand Up @@ -1829,27 +1829,27 @@ public static HighlightInfo.Builder checkOverrideEquivalentInheritedMethods(
continue;
}

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

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

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

if (description != LocalizeValue.empty()) {
if (description.isNotEmpty()) {
// show error info at the class level
HighlightInfo.Builder hlBuilder = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR)
.range(HighlightNamesUtil.getClassDeclarationTextRange(aClass))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3831,7 +3831,7 @@ private static LocalizeValue getUnsupportedFeatureMessage(PsiElement element, Ja
if (pusher instanceof JavaLanguageLevelPusher languageLevelPusher) {
LocalizeValue newMessage =
languageLevelPusher.getInconsistencyLanguageLevelMessage(message, element, level, file);
if (newMessage != LocalizeValue.empty()) {
if (newMessage.isNotEmpty()) {
return newMessage;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ public void visitLambdaExpression(@Nonnull PsiLambdaExpression expression) {
functionalInterfaceType = expression.getFunctionalInterfaceType();
if (functionalInterfaceType != null) {
LocalizeValue notFunctionalMessage = LambdaHighlightingUtil.checkInterfaceFunctional(functionalInterfaceType);
if (notFunctionalMessage != LocalizeValue.empty()) {
if (notFunctionalMessage.isNotEmpty()) {
myHolder.add(HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR)
.range(expression)
.descriptionAndTooltip(notFunctionalMessage)
Expand Down Expand Up @@ -1760,7 +1760,7 @@ public void visitMethodReferenceExpression(@Nonnull PsiMethodReferenceExpression

if (!myHolder.hasErrorResults() && functionalInterfaceType != null) {
LocalizeValue errorMessage = PsiMethodReferenceUtil.checkMethodReferenceContext(expression);
if (errorMessage != LocalizeValue.empty()) {
if (errorMessage.isNotEmpty()) {
HighlightInfo.Builder info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR)
.range(expression)
.descriptionAndTooltip(errorMessage);
Expand All @@ -1785,7 +1785,7 @@ public void visitMethodReferenceExpression(@Nonnull PsiMethodReferenceExpression
}
else {
LocalizeValue wildcardMessage = PsiMethodReferenceUtil.checkTypeArguments(typeElem, psiType);
if (wildcardMessage != LocalizeValue.empty()) {
if (wildcardMessage.isNotEmpty()) {
add(
HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR)
.range(typeElem)
Expand All @@ -1805,7 +1805,7 @@ public void visitMethodReferenceExpression(@Nonnull PsiMethodReferenceExpression

if (!myHolder.hasErrorResults()) {
LocalizeValue badReturnTypeMessage = PsiMethodReferenceUtil.checkReturnType(expression, result, functionalInterfaceType);
if (badReturnTypeMessage != LocalizeValue.empty()) {
if (badReturnTypeMessage.isNotEmpty()) {
myHolder.add(HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR)
.range(expression)
.descriptionAndTooltip(badReturnTypeMessage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public static LocalizeValue checkInterfaceFunctional(PsiType functionalInterface
if (functionalInterfaceType instanceof PsiIntersectionType) {
Set<MethodSignature> signatures = new HashSet<>();
for (PsiType type : ((PsiIntersectionType) functionalInterfaceType).getConjuncts()) {
if (checkInterfaceFunctional(type) == LocalizeValue.empty()) {
if (checkInterfaceFunctional(type).isEmpty()) {
MethodSignature signature = LambdaUtil.getFunction(PsiUtil.resolveClassInType(type));
LOG.assertTrue(signature != null, type.getCanonicalText());
signatures.add(signature);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class DeleteElementFix extends LocalQuickFixAndIntentionActionOnPsiElemen

public DeleteElementFix(@Nonnull PsiElement element) {
super(element);
myText = LocalizeValue.of();
myText = LocalizeValue.empty();
}

public DeleteElementFix(@Nonnull PsiElement element, @Nonnull LocalizeValue text) {
Expand All @@ -44,7 +44,7 @@ public DeleteElementFix(@Nonnull PsiElement element, @Nonnull LocalizeValue text
@Nonnull
@Override
public LocalizeValue getText() {
return myText == LocalizeValue.of() ? JavaQuickFixLocalize.deleteElementFixText() : myText;
return myText.orIfEmpty(JavaQuickFixLocalize.deleteElementFixText());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ public abstract class QualifyThisOrSuperArgumentFix implements SyntheticIntentio
protected static final Logger LOG = Logger.getInstance(QualifyThisOrSuperArgumentFix.class);
protected final PsiExpression myExpression;
protected final PsiClass myPsiClass;
private LocalizeValue myText = LocalizeValue.of();

private LocalizeValue myText = LocalizeValue.empty();

public QualifyThisOrSuperArgumentFix(@Nonnull PsiExpression expression, @Nonnull PsiClass psiClass) {
myExpression = expression;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ else if (operand instanceof PsiReferenceExpression operandRefExpr) {
}
}
LocalizeValue explanation = LocalizeValue.ofNullable(constraint.getAssignabilityExplanation(wanted, isInstance, name.get()));
if (explanation != LocalizeValue.empty()) {
if (explanation.isNotEmpty()) {
if (constraint.equals(wanted)) {
explanation = JavaAnalysisLocalize.dfaFindCauseTypeKnown(name, constraint.toShortString());
}
Expand All @@ -897,7 +897,7 @@ else if (operand instanceof PsiReferenceExpression operandRefExpr) {
isInstance,
JavaAnalysisLocalize.dfaFindCauseObjectKindGeneric().get()
));
while (explanation != LocalizeValue.empty()) {
while (explanation.isNotEmpty()) {
MemoryStateChange causeLocation = fact.myChange;
if (causeLocation == null) {
break;
Expand All @@ -913,7 +913,7 @@ else if (operand instanceof PsiReferenceExpression operandRefExpr) {
isInstance,
JavaAnalysisLocalize.dfaFindCauseObjectKindGeneric().get()
));
if (prevExplanation == LocalizeValue.empty()) {
if (prevExplanation.isEmpty()) {
if (causeLocation.myInstruction instanceof AssignInstruction assignInsn && causeLocation.myTopOfStack == operandValue) {
PsiExpression rExpression = assignInsn.getRExpression();
if (rExpression != null) {
Expand Down Expand Up @@ -1258,7 +1258,7 @@ private CauseItem findNullabilityCause(MemoryStateChange factUse, DfaNullability
MemoryStateChange factDef = info.myFact == nullability ? info.myChange : null;
if (nullability == DfaNullability.NOT_NULL) {
LocalizeValue explanation = getObviouslyNonNullExplanation(expression);
if (explanation != LocalizeValue.empty()) {
if (explanation.isNotEmpty()) {
return new CauseItem(JavaAnalysisLocalize.dfaFindCauseObviouslyNonNullExpression(explanation), expression);
}
if (factDef != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public LocalizeValue getDisplayName() {
@Nonnull
@Override
public LocalizeValue getGroupDisplayName() {
return LocalizeValue.of();
return LocalizeValue.empty();
}

@Nonnull
Expand Down
5 changes: 3 additions & 2 deletions java-analysis-impl/test/com/siyeh/igtest/style/One.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@ protected String buildErrorString(Object... infos) {
return null;
}

@Nonnull
@Override
public LocalizeValue getDisplayName() {
return LocalizeValue.of();
return LocalizeValue.empty();
}

private static class Inner {
private static boolean test() {
return false;
}

}
}
class TestVariableScope {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ public LocalizeValue getStateDescription() {
case DISPOSED:
return JavaDebuggerLocalize.statusDebugStopped();
}
return LocalizeValue.of();
return LocalizeValue.empty();
}

/* Stepping */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ public NodeManagerImpl getNodeManager() {
@Override
public LocalizeValue getCurrentStateMessage() {
LocalizeValue description = myJavaSession.getStateDescription();
return description != LocalizeValue.empty() ? description : super.getCurrentStateMessage();
return description.isNotEmpty() ? description : super.getCurrentStateMessage();
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,11 @@ protected Component createLayout(@Nonnull PropertyBuilder propertyBuilder,
return LocalizeValue.empty();
}

switch (value) {
case DebuggerSettings.SOCKET_TRANSPORT:
return JavaDebuggerLocalize.transportNameSocket();
case DebuggerSettings.SHMEM_TRANSPORT:
return JavaDebuggerLocalize.transportNameSharedMemory();
default:
return LocalizeValue.of(String.valueOf(value));
}
return switch (value) {
case DebuggerSettings.SOCKET_TRANSPORT -> JavaDebuggerLocalize.transportNameSocket();
case DebuggerSettings.SHMEM_TRANSPORT -> JavaDebuggerLocalize.transportNameSharedMemory();
default -> LocalizeValue.of(String.valueOf(value));
};
});
layout.add(LabeledBuilder.sided(JavaDebuggerLocalize.labelDebuggerLaunchingConfigurableDebuggerTransport(), transportBox));
propertyBuilder.add(transportBox, () -> settings.DEBUGGER_TRANSPORT, it -> settings.DEBUGGER_TRANSPORT = it);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,42 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* @author Eugene Zhuravlev
*/
package com.intellij.java.debugger.impl.ui.impl.watch;

import com.intellij.java.debugger.impl.engine.evaluation.EvaluationContextImpl;
import com.intellij.java.debugger.impl.ui.tree.render.DescriptorLabelListener;
import consulo.localize.LocalizeValue;
import consulo.logging.Logger;
import jakarta.annotation.Nonnull;


/**
* @author Eugene Zhuravlev
*/
public final class DefaultNodeDescriptor extends NodeDescriptorImpl{
private static final Logger LOG = Logger.getInstance(DefaultNodeDescriptor.class);
public boolean equals(Object obj) {
return obj instanceof DefaultNodeDescriptor;
}

public int hashCode() {
return 0;
}

public boolean isExpandable() {
return true;
}

public void setContext(EvaluationContextImpl context) {
}

protected LocalizeValue calcRepresentation(EvaluationContextImpl context, DescriptorLabelListener labelListener) {
LOG.assertTrue(false);
return LocalizeValue.of();
}
@Override
public boolean equals(Object obj) {
return obj instanceof DefaultNodeDescriptor;
}

@Override
public int hashCode() {
return 0;
}

@Override
public boolean isExpandable() {
return true;
}

@Override
public void setContext(EvaluationContextImpl context) {
}

@Nonnull
@Override
protected LocalizeValue calcRepresentation(EvaluationContextImpl context, DescriptorLabelListener labelListener) {
LOG.assertTrue(false);
return LocalizeValue.empty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public void disposeUIResources() {
myPanel = null;
}

@Nonnull
@Override
public LocalizeValue getDisplayName() {
return LocalizeValue.localizeTODO("Advanced");
Expand Down
Loading
Loading