mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-126753 Parameters names hints not shown for negative numbers
This commit is contained in:
+17
-2
@@ -48,6 +48,7 @@ import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.text.CharArrayUtil;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -703,7 +704,7 @@ public abstract class JavaFoldingBuilderBase extends CustomFoldingBuilder implem
|
||||
else if (element instanceof PsiComment) {
|
||||
return settings.isCollapseEndOfLineComments();
|
||||
}
|
||||
else if (element instanceof PsiLiteralExpression
|
||||
else if (isLiteralExpression(element)
|
||||
&& element.getParent() instanceof PsiExpressionList
|
||||
&& (element.getParent().getParent() instanceof PsiCallExpression
|
||||
|| element.getParent().getParent() instanceof PsiAnonymousClass)) {
|
||||
@@ -775,7 +776,7 @@ public abstract class JavaFoldingBuilderBase extends CustomFoldingBuilder implem
|
||||
for (int i = 0; i < callArguments.length; i++) {
|
||||
PsiExpression callArgument = callArguments[i];
|
||||
|
||||
if (callArgument instanceof PsiLiteralExpression) {
|
||||
if (isLiteralExpression(callArgument)) {
|
||||
if (!isResolved) {
|
||||
PsiMethod method = expression.resolveMethod();
|
||||
isResolved = true;
|
||||
@@ -799,6 +800,20 @@ public abstract class JavaFoldingBuilderBase extends CustomFoldingBuilder implem
|
||||
}
|
||||
}
|
||||
|
||||
@Contract("null -> false")
|
||||
private static boolean isLiteralExpression(@Nullable PsiElement callArgument) {
|
||||
if (callArgument instanceof PsiLiteralExpression)
|
||||
return true;
|
||||
|
||||
if (callArgument instanceof PsiPrefixExpression) {
|
||||
PsiPrefixExpression expr = (PsiPrefixExpression)callArgument;
|
||||
IElementType tokenType = expr.getOperationTokenType();
|
||||
return JavaTokenType.MINUS.equals(tokenType) && expr.getOperand() instanceof PsiLiteralExpression;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean addClosureFolding(final PsiClass aClass, final Document document, final List<FoldingDescriptor> foldElements,
|
||||
@NotNull Set<PsiElement> processedComments, final boolean quick) {
|
||||
if (!JavaCodeFoldingSettings.getInstance().isCollapseLambdas()) {
|
||||
|
||||
@@ -698,6 +698,29 @@ public class CharSymbol {
|
||||
assert regions[2].placeholderText == "fast: false"
|
||||
}
|
||||
|
||||
public void "test inline negative numbers (IDEA-126753)"() {
|
||||
def text = """
|
||||
public class CharSymbol {
|
||||
|
||||
public void main() {
|
||||
Object obj = new Object();
|
||||
count(-1, obj);
|
||||
}
|
||||
|
||||
public void count(int test, Object obj) {
|
||||
Object tmp = obj;
|
||||
boolean isFast = false;
|
||||
}
|
||||
}
|
||||
"""
|
||||
configure text
|
||||
def regions = myFixture.editor.foldingModel.allFoldRegions.sort { it.startOffset }
|
||||
assert regions.size() == 3
|
||||
|
||||
checkRangeOffsetByPositionInText(regions[1], text, "-1")
|
||||
assert regions[1].placeholderText == "test: -1"
|
||||
}
|
||||
|
||||
public void "test inline constructor literal arguments names"() {
|
||||
def text = """
|
||||
public class Test {
|
||||
|
||||
Reference in New Issue
Block a user