KT-20706: Fix auto-popup completion after digit in KDoc

#KT-20706 Fixed
This commit is contained in:
Simon Ogorodnik
2018-12-12 00:02:25 +03:00
parent c607b8e556
commit 1f6fde4bc2
9 changed files with 48 additions and 4 deletions
@@ -133,11 +133,13 @@ object KDocTagCompletionProvider : CompletionProvider<CompletionParameters>() {
override fun addCompletions(parameters: CompletionParameters, context: ProcessingContext, result: CompletionResultSet) {
// findIdentifierPrefix() requires identifier part characters to be a superset of identifier start characters
val prefix = CompletionUtil.findIdentifierPrefix(
parameters.position.containingFile,
parameters.offset,
StandardPatterns.character().javaIdentifierPart() or singleCharPattern('@'),
StandardPatterns.character().javaIdentifierStart() or singleCharPattern('@'))
parameters.position.containingFile,
parameters.offset,
StandardPatterns.character().javaIdentifierPart() or singleCharPattern('@'),
StandardPatterns.character().javaIdentifierStart() or singleCharPattern('@')
)
if (parameters.isAutoPopup && prefix.isEmpty()) return
if (prefix.isNotEmpty() && !prefix.startsWith('@')) {
return
}
@@ -0,0 +1,8 @@
/**
* @<caret>
*/
fun some() {}
// INVOCATION_COUNT: 0
// EXIST: @return
@@ -0,0 +1,8 @@
/**
* 0<caret>
*/
fun some() {}
// INVOCATION_COUNT: 0
// NOTHING_ELSE
+1
View File
@@ -8,3 +8,4 @@ fun f(x: Int): Int {
// EXIST: @return
// EXIST: @suppress
// ABSENT: @receiver
// INVOCATION_COUNT: 1
+1
View File
@@ -10,3 +10,4 @@ class C<T> {
// EXIST: @property
// ABSENT: @return
// ABSENT: @receiver
// INVOCATION_COUNT: 1
@@ -10,3 +10,4 @@ fun Int.f(): Int {
// EXIST: @receiver
// ABSENT: @constructor
// ABSENT: @property
// INVOCATION_COUNT: 1
+1
View File
@@ -4,3 +4,4 @@ fun f(x: Int): Int {
// EXIST: @param
// EXIST: @return
// INVOCATION_COUNT: 1
@@ -34,6 +34,11 @@ public class KDocCompletionTestGenerated extends AbstractJvmBasicCompletionTest
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/idea-completion/testData/kdoc"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("AutoPopupAfterAtInKDoc.kt")
public void testAutoPopupAfterAtInKDoc() throws Exception {
runTest("idea/idea-completion/testData/kdoc/AutoPopupAfterAtInKDoc.kt");
}
@TestMetadata("ExtensionsFQLink.kt")
public void testExtensionsFQLink() throws Exception {
runTest("idea/idea-completion/testData/kdoc/ExtensionsFQLink.kt");
@@ -79,6 +84,11 @@ public class KDocCompletionTestGenerated extends AbstractJvmBasicCompletionTest
runTest("idea/idea-completion/testData/kdoc/MemberLink.kt");
}
@TestMetadata("NoAutoPopupAfterDigitInKDoc.kt")
public void testNoAutoPopupAfterDigitInKDoc() throws Exception {
runTest("idea/idea-completion/testData/kdoc/NoAutoPopupAfterDigitInKDoc.kt");
}
@TestMetadata("NoCompletionAfterFunName.kt")
public void testNoCompletionAfterFunName() throws Exception {
runTest("idea/idea-completion/testData/kdoc/NoCompletionAfterFunName.kt");