Render flexible types with enhancement as enhanced in IDE (KT-25622)

Main targets for the fix is completion, parameters info, inlay hints and
override/implement.

Other IDE functions might be affected.

 #KT-24911 Fixed
 #KT-25616 Fixed
 #KT-25622 Fixed
This commit is contained in:
Nikolay Krasko
2018-08-01 17:10:04 +03:00
parent 653d1d00de
commit 759ffafb0a
18 changed files with 95 additions and 3 deletions
@@ -31,6 +31,7 @@ import org.jetbrains.kotlin.idea.completion.handlers.KotlinFunctionInsertHandler
import org.jetbrains.kotlin.idea.core.completion.DeclarationLookupObject
import org.jetbrains.kotlin.idea.core.completion.PackageLookupObject
import org.jetbrains.kotlin.idea.highlighter.dsl.DslHighlighterExtension
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
import org.jetbrains.kotlin.load.java.JvmAbi
import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor
import org.jetbrains.kotlin.name.FqName
@@ -50,7 +51,10 @@ class BasicLookupElementFactory(
) {
companion object {
// we skip parameter names in functional types in most of cases for shortness
val SHORT_NAMES_RENDERER = DescriptorRenderer.SHORT_NAMES_IN_TYPES.withOptions { parameterNamesInFunctionalTypes = false }
val SHORT_NAMES_RENDERER = DescriptorRenderer.SHORT_NAMES_IN_TYPES.withOptions {
enhancedTypes = true
parameterNamesInFunctionalTypes = false
}
}
fun createLookupElement(
@@ -0,0 +1,12 @@
import androidx.annotation.RecentlyNonNull;
import androidx.annotation.RecentlyNullable;
public class EnhancementFlexibleTypes {
public static void testNullable(@RecentlyNullable String string) {
}
public static void testNotNull(@RecentlyNonNull String string) {
}
}
@@ -0,0 +1,6 @@
fun temp() {
EnhancementFlexibleTypes.test<caret>
}
// EXIST: { lookupString: "testNotNull", tailText:"(string: String)" }
// EXIST: { lookupString: "testNullable", tailText:"(string: String?)" }
@@ -0,0 +1,8 @@
package androidx.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
@Target({ElementType.PARAMETER, ElementType.TYPE})
public @interface RecentlyNonNull {
}
@@ -0,0 +1,9 @@
package androidx.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
import java.lang.reflect.Parameter;
@Target({ElementType.PARAMETER, ElementType.TYPE})
public @interface RecentlyNullable {
}
@@ -74,6 +74,11 @@ public class MultiFileJvmBasicCompletionTestGenerated extends AbstractMultiFileJ
runTest("idea/idea-completion/testData/basic/multifile/DoNotCompleteWithConstraints/");
}
@TestMetadata("EnhancementFlexibleTypes")
public void testEnhancementFlexibleTypes() throws Exception {
runTest("idea/idea-completion/testData/basic/multifile/EnhancementFlexibleTypes/");
}
@TestMetadata("EntriesOfNotImportedEnumFromKotlin")
public void testEntriesOfNotImportedEnumFromKotlin() throws Exception {
runTest("idea/idea-completion/testData/basic/multifile/EntriesOfNotImportedEnumFromKotlin/");