Keyword correction: smaller file text
This commit is contained in:
@@ -179,7 +179,7 @@ object KeywordCompletion {
|
|||||||
while (child != position) {
|
while (child != position) {
|
||||||
if (child is JetDeclaration) {
|
if (child is JetDeclaration) {
|
||||||
if (child == prevDeclaration) {
|
if (child == prevDeclaration) {
|
||||||
builder.append(child!!.getText()) //TODO: skip code blocks, class body inside,
|
builder.appendReducedText(child!!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
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 {
|
private fun PsiElement.getStartOffsetInAncestor(ancestor: PsiElement): Int {
|
||||||
val parent = getParent()!!
|
val parent = getParent()!!
|
||||||
return if (parent == ancestor)
|
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);
|
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")
|
@TestMetadata("AfterDot.kt")
|
||||||
public void testAfterDot() throws Exception {
|
public void testAfterDot() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/keywords/AfterDot.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/keywords/AfterDot.kt");
|
||||||
doTest(fileName);
|
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")
|
@TestMetadata("AfterSafeDot.kt")
|
||||||
public void testAfterSafeDot() throws Exception {
|
public void testAfterSafeDot() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/keywords/AfterSafeDot.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/keywords/AfterSafeDot.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user