Inlay parameter hints: add hints for enum constructors and new expressions: IDEA-195733

This commit is contained in:
Roman.Ivanov
2018-07-20 16:45:09 +07:00
parent 1d0448eba0
commit 0e2e2c7255
4 changed files with 109 additions and 14 deletions
@@ -1066,6 +1066,92 @@ class Test {
""")
}
fun `test enum parameter names`() {
check("""
public enum Thingy {
ONE(<hint text="green:"/>false, <hint text="striped:"/>true),
TWO(<hint text="green:"/>false, <hint text="striped:"/>false),
THREE(<hint text="...x:"/>12,32,3,2,32,3,2,3,23);
private boolean green;
private boolean striped;
Thingy(final boolean green, final boolean striped) {
this.green = green;
this.striped = striped;
}
Thingy(int... x) {
}
}""")
}
fun `test enum parameter names disabled`() {
JavaInlayParameterHintsProvider.getInstance().isShowHintsForEnumConstants.set(false)
check("""
public enum Thingy {
ONE(false, true),
TWO(false, false),
THREE(12,32,3,2,32,3,2,3,23);
private boolean green;
private boolean striped;
Thingy(final boolean green, final boolean striped) {
this.green = green;
this.striped = striped;
}
Thingy(int... x) {
}
}""")
}
fun `test constructor call`() {
JavaInlayParameterHintsProvider.getInstance().isShowHintsForNewExpressions.set(true)
check("""
public class Test {
static class A {
A(boolean hardName){}
}
void foo() {
new A(<hint text="hardName:"/>true);
}
}""")
}
fun `test constructor call disabled`() {
JavaInlayParameterHintsProvider.getInstance().isShowHintsForNewExpressions.set(false)
check("""
public class Test {
static class A {
A(boolean hardName){}
}
void foo() {
new A(true);
}
}""")
}
fun `test constructor call with other features`() {
JavaInlayParameterHintsProvider.getInstance().isShowHintsForNewExpressions.set(true)
JavaInlayParameterHintsProvider.getInstance().ignoreOneCharOneDigitHints.set(true)
check("""
public class Test {
static class A {
A(boolean a1, boolean a2){}
}
void foo() {
new A(true, false);
}
}""")
}
fun getHints(): List<String> {
val document = myFixture.getDocument(myFixture.file)
val manager = ParameterHintsPresentationManager.getInstance()
@@ -1074,7 +1160,7 @@ class Test {
.getInlineElementsInRange(0, document.textLength)
.mapNotNull { manager.getHintText(it) }
}
fun assertSingleInlayWithText(expectedText: String) {
val inlays = myFixture.editor.inlayModel.getInlineElementsInRange(0, editor.document.textLength)