Keyword correction: smaller file text
This commit is contained in:
@@ -179,7 +179,7 @@ object KeywordCompletion {
|
||||
while (child != position) {
|
||||
if (child is JetDeclaration) {
|
||||
if (child == prevDeclaration) {
|
||||
builder.append(child!!.getText()) //TODO: skip code blocks, class body inside,
|
||||
builder.appendReducedText(child!!)
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -190,6 +190,23 @@ object KeywordCompletion {
|
||||
}
|
||||
}
|
||||
|
||||
private fun StringBuilder.appendReducedText(element: PsiElement) {
|
||||
var child = element.getFirstChild()
|
||||
if (child == null) {
|
||||
append(element.getText()!!)
|
||||
}
|
||||
else {
|
||||
while (child != null) {
|
||||
when (child) {
|
||||
is JetBlockExpression, is JetClassBody -> append("{}")
|
||||
else -> appendReducedText(child)
|
||||
}
|
||||
|
||||
child = child.getNextSibling()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun PsiElement.getStartOffsetInAncestor(ancestor: PsiElement): Int {
|
||||
val parent = getParent()!!
|
||||
return if (parent == ancestor)
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
class A {
|
||||
fun foo() {
|
||||
bar()
|
||||
}
|
||||
}
|
||||
|
||||
class B {
|
||||
fun bar() {
|
||||
foo()
|
||||
}
|
||||
}
|
||||
|
||||
<caret>
|
||||
|
||||
// EXIST: abstract
|
||||
// EXIST: annotation
|
||||
// EXIST: class
|
||||
// EXIST: enum
|
||||
// EXIST: final
|
||||
// EXIST: fun
|
||||
// EXIST: in
|
||||
/*why?*/
|
||||
// EXIST: inner
|
||||
// EXIST: internal
|
||||
// EXIST: object
|
||||
// EXIST: open
|
||||
// EXIST: out
|
||||
/*why?*/
|
||||
// EXIST: override
|
||||
// EXIST: private
|
||||
// EXIST: protected
|
||||
// EXIST: public
|
||||
// EXIST: trait
|
||||
// EXIST: val
|
||||
// EXIST: var
|
||||
// EXIST: vararg
|
||||
/*why?*/
|
||||
// NUMBER: 20
|
||||
@@ -0,0 +1,36 @@
|
||||
class A {
|
||||
fun foo() {
|
||||
bar()
|
||||
}
|
||||
|
||||
fun bar() {
|
||||
fun()
|
||||
}
|
||||
|
||||
<caret>
|
||||
}
|
||||
|
||||
// EXIST: abstract
|
||||
// EXIST: annotation
|
||||
// EXIST: class
|
||||
// EXIST: enum
|
||||
// EXIST: final
|
||||
// EXIST: fun
|
||||
// EXIST: in
|
||||
/*why?*/
|
||||
// EXIST: inner
|
||||
// EXIST: internal
|
||||
// EXIST: object
|
||||
// EXIST: open
|
||||
// EXIST: out
|
||||
/*why?*/
|
||||
// EXIST: override
|
||||
// EXIST: private
|
||||
// EXIST: protected
|
||||
// EXIST: public
|
||||
// EXIST: trait
|
||||
// EXIST: val
|
||||
// EXIST: var
|
||||
// EXIST: vararg
|
||||
/*why?*/
|
||||
// NUMBER: 20
|
||||
@@ -42,12 +42,24 @@ public class KeywordCompletionTestGenerated extends AbstractKeywordCompletionTes
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("AfterClasses.kt")
|
||||
public void testAfterClasses() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/keywords/AfterClasses.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("AfterDot.kt")
|
||||
public void testAfterDot() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/keywords/AfterDot.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("AfterFuns.kt")
|
||||
public void testAfterFuns() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/keywords/AfterFuns.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("AfterSafeDot.kt")
|
||||
public void testAfterSafeDot() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/keywords/AfterSafeDot.kt");
|
||||
|
||||
Reference in New Issue
Block a user