Mark used parameters as disabled in parameter info popup

When using named arguments the IDE might be unable to map the current
argument to a parameter. In that case mark already used parameters as
disabled. That way developers can easily see which parameters have not
been used yet.

^KTIJ-128 Fixed
This commit is contained in:
cketti
2020-09-03 20:25:11 +02:00
committed by Vladimir Dolzhenko
parent 81339d54eb
commit 7755d9fe24
5 changed files with 60 additions and 12 deletions
@@ -27,22 +27,36 @@ public class MockParameterInfoUIContext implements ParameterInfoUIContext {
public String setupUIComponentPresentation(String text, int highlightStartOffset, int highlightEndOffset,
boolean isDisabled, boolean strikeout,
boolean isDisabledBeforeHighlight, Color background) {
String highlightedText;
String taggedText;
if (highlightStartOffset != -1 && highlightEndOffset != -1) {
highlightedText = text.substring(0, highlightStartOffset)
+ "<highlight>"
+ text.substring(highlightStartOffset, highlightEndOffset)
+ "</highlight>"
+ text.substring(highlightEndOffset);
StringBuilder sb = new StringBuilder();
if (isDisabledBeforeHighlight) {
sb.append("<disabled>");
}
sb.append(text, 0, highlightStartOffset);
if (isDisabledBeforeHighlight) {
sb.append("</disabled>");
}
sb.append("<highlight>");
sb.append(text, highlightStartOffset, highlightEndOffset);
sb.append("</highlight>");
sb.append(text, highlightEndOffset, text.length());
taggedText = sb.toString();
}
else {
highlightedText = text;
taggedText = text;
}
String resultText = "Text: (" + highlightedText + "), " +
String resultText = "Text: (" + taggedText + "), " +
"Disabled: " + isDisabled + ", " +
"Strikeout: " + strikeout + ", " +
"Green: " + KotlinParameterInfoWithCallHandlerBase.GREEN_BACKGROUND.equals(background);
result.add(resultText);
// return value not used, just return something
@@ -226,6 +226,11 @@ public class ParameterInfoTestGenerated extends AbstractParameterInfoTest {
runTest("idea/testData/parameterInfo/functionCall/NamedParameter3.kt");
}
@TestMetadata("NamedParameter4.kt")
public void testNamedParameter4() throws Exception {
runTest("idea/testData/parameterInfo/functionCall/NamedParameter4.kt");
}
@TestMetadata("NoAnnotations.kt")
public void testNoAnnotations() throws Exception {
runTest("idea/testData/parameterInfo/functionCall/NoAnnotations.kt");