mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[parameter hints] migrate from kotlin interface to java interface, to preserve compatibility with java implementations when adding new default methods
This commit is contained in:
+3
-1
@@ -53,7 +53,9 @@ class JavaInlayParameterHintsProvider : InlayParameterHintsProvider {
|
||||
return MethodInfo(fullMethodName, paramNames)
|
||||
}
|
||||
|
||||
override val defaultBlackList = setOf(
|
||||
override fun getDefaultBlackList() = defaultBlackList
|
||||
|
||||
private val defaultBlackList = setOf(
|
||||
"(begin*, end*)",
|
||||
"(start*, end*)",
|
||||
"(first*, last*)",
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.codeInsight.hints;
|
||||
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@ApiStatus.Experimental
|
||||
public interface InlayParameterHintsProvider {
|
||||
|
||||
/**
|
||||
* Hints for params to be shown
|
||||
*/
|
||||
@NotNull
|
||||
List<InlayInfo> getParameterHints(PsiElement element);
|
||||
|
||||
/**
|
||||
* Provides hint info, for alt-enter action (can be MethodInfo or OptionInfo)
|
||||
*
|
||||
* MethodInfo: provides fully qualified method name (e.g. "java.util.Map.put") and list of it's parameter names.
|
||||
* Used to match method with blacklist, and to add method into blacklist
|
||||
*
|
||||
* OptionInfo: provides option to disable/enable by alt-enter
|
||||
*/
|
||||
@Nullable
|
||||
HintInfo getHintInfo(PsiElement element);
|
||||
|
||||
/**
|
||||
* Default list of patterns for which hints should not be shown
|
||||
*/
|
||||
@NotNull
|
||||
Set<String> getDefaultBlackList();
|
||||
|
||||
/**
|
||||
* Returns language which blacklist will be appended to the resulting one
|
||||
* E.g. to prevent possible Groovy and Kotlin extensions from showing hints for blacklisted java methods.
|
||||
*/
|
||||
@Nullable
|
||||
default Language getBlackListDependencyLanguage() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* List of supported options, shown in settings dialog
|
||||
*/
|
||||
@NotNull
|
||||
default List<Option> getSupportedOptions() {
|
||||
return ContainerUtil.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* If false no blacklist panel will be shown in "Parameter Name Hints Settings"
|
||||
*/
|
||||
default boolean isBlackListSupported() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
+1
-44
@@ -16,54 +16,11 @@
|
||||
package com.intellij.codeInsight.hints
|
||||
|
||||
import com.intellij.codeInsight.hints.settings.ParameterNameHintsSettings
|
||||
import com.intellij.lang.Language
|
||||
import com.intellij.lang.LanguageExtension
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
|
||||
object InlayParameterHintsExtension: LanguageExtension<InlayParameterHintsProvider>("com.intellij.codeInsight.parameterNameHints")
|
||||
|
||||
@ApiStatus.Experimental
|
||||
interface InlayParameterHintsProvider {
|
||||
|
||||
/**
|
||||
* Hints for params to be shown
|
||||
*/
|
||||
fun getParameterHints(element: PsiElement): List<InlayInfo>
|
||||
|
||||
/**
|
||||
* Provides hint info, for alt-enter action (can be MethodInfo or OptionInfo)
|
||||
*
|
||||
* MethodInfo: provides fully qualified method name (e.g. "java.util.Map.put") and list of it's parameter names.
|
||||
* Used to match method with blacklist, and to add method into blacklist
|
||||
*
|
||||
* OptionInfo: provides option to disable/enable by alt-enter
|
||||
*/
|
||||
fun getHintInfo(element: PsiElement): HintInfo?
|
||||
|
||||
/**
|
||||
* Default list of patterns for which hints should not be shown
|
||||
*/
|
||||
val defaultBlackList: Set<String>
|
||||
|
||||
/**
|
||||
* Returns language which blacklist will be appended to the resulting one
|
||||
* E.g. to prevent possible Groovy and Kotlin extensions from showing hints for blacklisted java methods.
|
||||
*/
|
||||
fun getBlackListDependencyLanguage(): Language? = null
|
||||
|
||||
/**
|
||||
* List of supported options, shown in settings dialog
|
||||
*/
|
||||
fun getSupportedOptions(): List<Option> = emptyList()
|
||||
|
||||
/**
|
||||
* If false no blacklist panel will be shown in "Parameter Name Hints Settings"
|
||||
*/
|
||||
fun isBlackListSupported() = true
|
||||
|
||||
}
|
||||
|
||||
|
||||
data class InlayInfo(val text: String, val offset: Int)
|
||||
|
||||
|
||||
+2
-4
@@ -23,12 +23,10 @@ import junit.framework.TestCase
|
||||
import org.jdom.Element
|
||||
|
||||
|
||||
class MockInlayProvider(override val defaultBlackList: Set<String>): InlayParameterHintsProvider {
|
||||
|
||||
class MockInlayProvider(private val defaultBlackList: Set<String>): InlayParameterHintsProvider {
|
||||
override fun getParameterHints(element: PsiElement) = emptyList<InlayInfo>()
|
||||
|
||||
override fun getHintInfo(element: PsiElement) = null
|
||||
|
||||
override fun getDefaultBlackList() = defaultBlackList
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -87,7 +87,7 @@ class GroovyInlayParameterHintsProvider : InlayParameterHintsProvider {
|
||||
return MethodInfo(fullMethodName, paramNames)
|
||||
}
|
||||
|
||||
override val defaultBlackList: Set<String> get() = blackList
|
||||
override fun getDefaultBlackList(): Set<String> = blackList
|
||||
|
||||
override fun getBlackListDependencyLanguage() = JavaLanguage.INSTANCE
|
||||
}
|
||||
Reference in New Issue
Block a user