mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[InlayParameterHints] show param name for this argument
This commit is contained in:
+8
-4
@@ -59,7 +59,7 @@ public class ParameterNameHintsManager {
|
||||
myDescriptors = descriptors;
|
||||
}
|
||||
|
||||
static boolean isLiteralExpression(@Nullable PsiElement callArgument) {
|
||||
static boolean isUnclearExpression(@Nullable PsiElement callArgument) {
|
||||
if (callArgument instanceof PsiLiteralExpression)
|
||||
return true;
|
||||
|
||||
@@ -70,6 +70,10 @@ public class ParameterNameHintsManager {
|
||||
|| JavaTokenType.PLUS.equals(tokenType)) && expr.getOperand() instanceof PsiLiteralExpression;
|
||||
}
|
||||
|
||||
if (callArgument instanceof PsiThisExpression) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -150,7 +154,7 @@ public class ParameterNameHintsManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isLiteralExpression(argument)) {
|
||||
if (isUnclearExpression(argument)) {
|
||||
PsiType parameterType = resolveResult.getSubstitutor().substitute(paramType);
|
||||
return TypeConversionUtil.isAssignable(parameterType, argType);
|
||||
}
|
||||
@@ -166,7 +170,7 @@ public class ParameterNameHintsManager {
|
||||
private static boolean hasLiteralInVarargs(int index, PsiExpression[] callArguments) {
|
||||
for (int i = index; i < callArguments.length; i++) {
|
||||
PsiExpression arg = callArguments[i];
|
||||
if (isLiteralExpression(arg)) return true;
|
||||
if (isUnclearExpression(arg)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -178,7 +182,7 @@ public class ParameterNameHintsManager {
|
||||
|
||||
private static boolean hasLiteralExpression(@NotNull PsiExpression[] arguments) {
|
||||
for (PsiExpression argument : arguments) {
|
||||
if (isLiteralExpression(argument)) return true;
|
||||
if (isUnclearExpression(argument)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
+18
@@ -424,6 +424,24 @@ public class VarArgTest {
|
||||
onLineStartingWith("check(")
|
||||
.assertInlays("beginIndex->10", "endIndex->1000", """x->"su"""" )
|
||||
}
|
||||
|
||||
fun `test inline this`() {
|
||||
setup("""
|
||||
public class VarArgTest {
|
||||
|
||||
public void main() {
|
||||
check(this, 1000);
|
||||
}
|
||||
|
||||
public void check(VarArgTest test, int endIndex) {
|
||||
}
|
||||
|
||||
}
|
||||
""")
|
||||
|
||||
onLineStartingWith("check(t")
|
||||
.assertInlays("test->this", "endIndex->1000")
|
||||
}
|
||||
|
||||
|
||||
private fun onLineStartingWith(text: String): InlayAssert {
|
||||
|
||||
Reference in New Issue
Block a user