[Inline Param Name Hints] hints shown for single parameter methods, except setters and well know method names like "println", "get", "contains"...

This commit is contained in:
Yaroslav Lepenkin
2016-09-28 17:03:19 +03:00
parent 1382f2f474
commit 669e4e1c4d
2 changed files with 83 additions and 23 deletions
@@ -140,7 +140,7 @@ public class VarArgTest {
}
""")
onLineStartingWith("testBooleanVarargs").assertNoInlays()
onLineStartingWith("testBooleanVarargs").assertInlays("test->13")
}
fun `test multiple vararg hint`() {
@@ -179,7 +179,7 @@ public class CharSymbol {
}
""")
onLineStartingWith("count").assertNoInlays()
onLineStartingWith("count").assertInlays("t->1", "fa->false")
}
fun `test do not inline known subsequent parameter names`() {
@@ -274,12 +274,44 @@ public class Test {
""")
onLineStartingWith("System")
.assertInlays("""x->"AAA"""")
.assertNoInlays()
onLineStartingWith("main(t")
.assertInlays("isActive->true", "requestFocus->false", "xoo->2")
}
fun `test ignored methods`() {
setup("""
public class Test {
public void main() {
println("A");
print("A");
get(1);
set(1, new Object());
setNewIndex(10);
"sss".contains("s");
append("sdfsdf");
clearStatus(false);
}
void print(String s) {}
void println(String s) {}
void get(int index) {}
void set(int index, Object object) {}
void append(String s) {}
void clearStatus(boolean updatedRecently) {}
}
""")
val inlays = getInlays()
assertThat(inlays).hasSize(1)
assertThat(inlays[0].offset).isEqualTo(myFixture.editor.document.text.indexOf("false"))
}
fun `test hints for generic arguments`() {
val settings = EditorSettingsExternalizable.getInstance()
settings.minArgsToShow = 1
@@ -443,6 +475,10 @@ public class VarArgTest {
.assertInlays("test->this", "endIndex->1000")
}
private fun getInlays(): List<Inlay> {
val editor = myFixture.editor
return editor.inlayModel.getInlineElementsInRange(0, editor.document.textLength)
}
private fun onLineStartingWith(text: String): InlayAssert {
val range = getLineRangeStartingWith(text)