mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[parameter hints] allow to provide hints which will not be matched by blacklist
This commit is contained in:
+13
-9
@@ -20,13 +20,17 @@ import com.intellij.lang.Language
|
||||
import com.intellij.lang.LanguageExtension
|
||||
|
||||
|
||||
object InlayParameterHintsExtension: LanguageExtension<InlayParameterHintsProvider>("com.intellij.codeInsight.parameterNameHints")
|
||||
object InlayParameterHintsExtension : LanguageExtension<InlayParameterHintsProvider>("com.intellij.codeInsight.parameterNameHints")
|
||||
|
||||
|
||||
class InlayInfo(val text: String, val offset: Int, val isShowOnlyIfExistedBefore: Boolean) {
|
||||
|
||||
constructor(text: String, offset: Int): this(text, offset, false)
|
||||
|
||||
class InlayInfo(val text: String,
|
||||
val offset: Int,
|
||||
val isShowOnlyIfExistedBefore: Boolean,
|
||||
val isFilterByBlacklist: Boolean) {
|
||||
|
||||
constructor(text: String, offset: Int, isShowOnlyIfExistedBefore: Boolean) : this(text, offset, isShowOnlyIfExistedBefore, true)
|
||||
constructor(text: String, offset: Int) : this(text, offset, false, true)
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other?.javaClass != javaClass) return false
|
||||
@@ -54,7 +58,7 @@ sealed class HintInfo {
|
||||
* @language in case you want to put this method into blacklist of another language
|
||||
*/
|
||||
open class MethodInfo(val fullyQualifiedName: String, val paramNames: List<String>, val language: Language?) : HintInfo() {
|
||||
constructor(fullyQualifiedName: String, paramNames: List<String>): this(fullyQualifiedName, paramNames, null)
|
||||
constructor(fullyQualifiedName: String, paramNames: List<String>) : this(fullyQualifiedName, paramNames, null)
|
||||
|
||||
open fun getMethodName(): String {
|
||||
val start = fullyQualifiedName.lastIndexOf('.') + 1
|
||||
@@ -63,15 +67,15 @@ sealed class HintInfo {
|
||||
}
|
||||
|
||||
open class OptionInfo(protected val option: Option) : HintInfo() {
|
||||
|
||||
|
||||
open fun disable() = alternate()
|
||||
open fun enable() = alternate()
|
||||
|
||||
|
||||
private fun alternate() {
|
||||
val current = option.get()
|
||||
option.set(!current)
|
||||
}
|
||||
|
||||
|
||||
open val optionName = option.name
|
||||
|
||||
fun isOptionEnabled(): Boolean = option.isEnabled()
|
||||
|
||||
@@ -31,6 +31,7 @@ import gnu.trove.TIntObjectHashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static com.intellij.codeInsight.hints.ParameterHintsPassFactory.putCurrentPsiModificationStamp;
|
||||
|
||||
@@ -71,18 +72,24 @@ public class ParameterHintsPass extends EditorBoundHighlightingPass {
|
||||
List<InlayInfo> hints = provider.getParameterHints(element);
|
||||
if (hints.isEmpty()) return;
|
||||
HintInfo info = provider.getHintInfo(element);
|
||||
if (info == null || myHintInfoFilter.showHint(info)) {
|
||||
hints.forEach((hint) -> {
|
||||
String presentation = provider.getInlayPresentation(hint.getText());
|
||||
int offset = hint.getOffset();
|
||||
if (hint.isShowOnlyIfExistedBefore()) {
|
||||
myShowOnlyIfExistedBeforeHints.put(offset, presentation);
|
||||
}
|
||||
else {
|
||||
myHints.put(offset, presentation);
|
||||
}
|
||||
});
|
||||
|
||||
boolean showHints = info == null || info instanceof HintInfo.OptionInfo || myHintInfoFilter.showHint(info);
|
||||
|
||||
Stream<InlayInfo> inlays = hints.stream();
|
||||
if (!showHints) {
|
||||
inlays = inlays.filter((inlayInfo -> !inlayInfo.isFilterByBlacklist()));
|
||||
}
|
||||
|
||||
inlays.forEach((hint) -> {
|
||||
String presentation = provider.getInlayPresentation(hint.getText());
|
||||
int offset = hint.getOffset();
|
||||
if (hint.isShowOnlyIfExistedBefore()) {
|
||||
myShowOnlyIfExistedBeforeHints.put(offset, presentation);
|
||||
}
|
||||
else {
|
||||
myHints.put(offset, presentation);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user