KT-9478 No override completion for second parameter in primary constructor
#KT-9478 Fixed #KT-9386 Fixed
This commit is contained in:
+29
-12
@@ -122,37 +122,44 @@ object KeywordCompletion {
|
|||||||
var parent = position.getParent()
|
var parent = position.getParent()
|
||||||
var prevParent = position
|
var prevParent = position
|
||||||
while (parent != null) {
|
while (parent != null) {
|
||||||
val _parent = parent
|
when (parent) {
|
||||||
when (_parent) {
|
|
||||||
is JetBlockExpression -> {
|
is JetBlockExpression -> {
|
||||||
return buildFilterWithContext("fun foo() { ", prevParent, position)
|
return buildFilterWithContext("fun foo() { ", prevParent, position)
|
||||||
}
|
}
|
||||||
|
|
||||||
is JetWithExpressionInitializer -> {
|
is JetWithExpressionInitializer -> {
|
||||||
val initializer = _parent.getInitializer()
|
val initializer = parent.getInitializer()
|
||||||
if (prevParent == initializer) {
|
if (prevParent == initializer) {
|
||||||
return buildFilterWithContext("val v = ", initializer!!, position)
|
return buildFilterWithContext("val v = ", initializer!!, position)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
is JetParameter -> {
|
is JetParameter -> {
|
||||||
val default = _parent.getDefaultValue()
|
val default = parent.getDefaultValue()
|
||||||
if (prevParent == default) {
|
if (prevParent == default) {
|
||||||
return buildFilterWithContext("val v = ", default!!, position)
|
return buildFilterWithContext("val v = ", default!!, position)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_parent is JetDeclaration) {
|
if (parent is JetDeclaration) {
|
||||||
val scope = _parent.getParent()
|
val scope = parent.parent
|
||||||
when (scope) {
|
when (scope) {
|
||||||
is JetClassOrObject -> return buildFilterWithReducedContext("class X { ", _parent, position)
|
is JetClassOrObject -> {
|
||||||
is JetFile -> return buildFilterWithReducedContext("", _parent, position)
|
if (parent is JetPrimaryConstructor) {
|
||||||
|
return buildFilterWithReducedContext("class X ", parent, position)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return buildFilterWithReducedContext("class X { ", parent, position)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
is JetFile -> return buildFilterWithReducedContext("", parent, position)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
prevParent = _parent
|
prevParent = parent
|
||||||
parent = _parent.getParent()
|
parent = parent.parent
|
||||||
}
|
}
|
||||||
|
|
||||||
return buildFilterWithReducedContext("", null, position)
|
return buildFilterWithReducedContext("", null, position)
|
||||||
@@ -193,11 +200,21 @@ object KeywordCompletion {
|
|||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
if (elementAt.parent !is JetModifierList) return true
|
if (elementAt.parent !is JetModifierList) return true
|
||||||
val possibleTargets = when (elementAt.parent.parent) {
|
val declaration = elementAt.parent.parent
|
||||||
is JetParameter -> listOf(VALUE_PARAMETER)
|
val possibleTargets = when (declaration) {
|
||||||
|
is JetParameter -> {
|
||||||
|
if (declaration.ownerFunction is JetPrimaryConstructor)
|
||||||
|
listOf(VALUE_PARAMETER, MEMBER_PROPERTY)
|
||||||
|
else
|
||||||
|
listOf(VALUE_PARAMETER)
|
||||||
|
}
|
||||||
|
|
||||||
is JetTypeParameter -> listOf(TYPE_PARAMETER)
|
is JetTypeParameter -> listOf(TYPE_PARAMETER)
|
||||||
|
|
||||||
is JetClassBody -> listOf(CLASS_ONLY, INTERFACE, OBJECT, ENUM_CLASS, ANNOTATION_CLASS, INNER_CLASS, MEMBER_FUNCTION, MEMBER_PROPERTY, FUNCTION, PROPERTY)
|
is JetClassBody -> listOf(CLASS_ONLY, INTERFACE, OBJECT, ENUM_CLASS, ANNOTATION_CLASS, INNER_CLASS, MEMBER_FUNCTION, MEMBER_PROPERTY, FUNCTION, PROPERTY)
|
||||||
|
|
||||||
is JetFile -> listOf(CLASS_ONLY, INTERFACE, OBJECT, ENUM_CLASS, ANNOTATION_CLASS, TOP_LEVEL_FUNCTION, TOP_LEVEL_PROPERTY, FUNCTION, PROPERTY)
|
is JetFile -> listOf(CLASS_ONLY, INTERFACE, OBJECT, ENUM_CLASS, ANNOTATION_CLASS, TOP_LEVEL_FUNCTION, TOP_LEVEL_PROPERTY, FUNCTION, PROPERTY)
|
||||||
|
|
||||||
else -> return true
|
else -> return true
|
||||||
}
|
}
|
||||||
val modifierTargets = ModifierCheckerCore.possibleTargetMap[keywordTokenType] ?: return true
|
val modifierTargets = ModifierCheckerCore.possibleTargetMap[keywordTokenType] ?: return true
|
||||||
|
|||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
interface Foo {
|
||||||
|
val foo: Int
|
||||||
|
val bar: Int
|
||||||
|
}
|
||||||
|
|
||||||
|
class A(override val bar: Int, overr<caret>): Foo
|
||||||
|
|
||||||
|
// EXIST: { lookupString: "override", itemText: "override" }
|
||||||
|
// EXIST: { itemText: "override val foo: Int", tailText: null, typeText: "Foo" }
|
||||||
|
// EXIST_JAVA_ONLY: { itemText: "override: Override", tailText: " (java.lang)" }
|
||||||
|
// NOTHING_ELSE
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package TestData
|
||||||
|
|
||||||
|
class TestSample(<caret>)
|
||||||
|
|
||||||
|
// EXIST: vararg
|
||||||
|
// EXIST: noinline
|
||||||
|
// EXIST: crossinline
|
||||||
|
// EXIST: val
|
||||||
|
// EXIST: var
|
||||||
|
// EXIST: override
|
||||||
|
// EXIST: open
|
||||||
|
// EXIST: final
|
||||||
|
// EXIST: public
|
||||||
|
// EXIST: private
|
||||||
|
// EXIST: protected
|
||||||
|
// EXIST: internal
|
||||||
|
|
||||||
|
/* TODO: keywords below should not be here*/
|
||||||
|
// EXIST: abstract
|
||||||
|
// EXIST: const
|
||||||
|
// EXIST: lateinit
|
||||||
|
// NOTHING_ELSE
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
annotation class Ann
|
||||||
|
|
||||||
|
class Completion(@get:Ann val p1: String, @<caret>)
|
||||||
|
|
||||||
|
// EXIST: get
|
||||||
|
// EXIST: set
|
||||||
|
// EXIST: field
|
||||||
|
// EXIST: param
|
||||||
|
// EXIST: setparam
|
||||||
|
// EXIST: property
|
||||||
|
|
||||||
|
/*TODO: keywords below should not be here*/
|
||||||
|
// EXIST: val
|
||||||
|
// EXIST: var
|
||||||
|
// EXIST: receiver
|
||||||
|
// NOTHING_ELSE
|
||||||
+6
@@ -1635,6 +1635,12 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("SecondConstructorParameter.kt")
|
||||||
|
public void testSecondConstructorParameter() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/override/SecondConstructorParameter.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("Simple.kt")
|
@TestMetadata("Simple.kt")
|
||||||
public void testSimple() throws Exception {
|
public void testSimple() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/override/Simple.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/override/Simple.kt");
|
||||||
|
|||||||
+6
@@ -1635,6 +1635,12 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("SecondConstructorParameter.kt")
|
||||||
|
public void testSecondConstructorParameter() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/override/SecondConstructorParameter.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("Simple.kt")
|
@TestMetadata("Simple.kt")
|
||||||
public void testSimple() throws Exception {
|
public void testSimple() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/override/Simple.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/override/Simple.kt");
|
||||||
|
|||||||
+12
@@ -227,6 +227,12 @@ public class KeywordCompletionTestGenerated extends AbstractKeywordCompletionTes
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("InPrimaryConstructorParametersList.kt")
|
||||||
|
public void testInPrimaryConstructorParametersList() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/keywords/InPrimaryConstructorParametersList.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("InPropertyInitializer.kt")
|
@TestMetadata("InPropertyInitializer.kt")
|
||||||
public void testInPropertyInitializer() throws Exception {
|
public void testInPropertyInitializer() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/keywords/InPropertyInitializer.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/keywords/InPropertyInitializer.kt");
|
||||||
@@ -472,4 +478,10 @@ public class KeywordCompletionTestGenerated extends AbstractKeywordCompletionTes
|
|||||||
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/keywords/TopScope.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/keywords/TopScope.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("UseSiteTargetForPrimaryConstructorParameter.kt")
|
||||||
|
public void testUseSiteTargetForPrimaryConstructorParameter() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/keywords/UseSiteTargetForPrimaryConstructorParameter.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user