IJP-1077 Inlay hints: new settings UI

more previews

GitOrigin-RevId: 2b11574f5a36a96077ecaaf797f450d164bc967a
This commit is contained in:
Dmitry Avdeev
2021-09-30 16:47:17 +00:00
committed by intellij-monorepo-bot
parent 6c66b1be7e
commit 25c2402bea
10 changed files with 37 additions and 6 deletions
@@ -0,0 +1,2 @@
class Button { }
class AnimatedButton extends Button { }
@@ -0,0 +1,9 @@
class Button { }
class AnimatedButton extends Button { }
class UI {
public static void main(String[] args) {
Button b = new Button();
}
}
@@ -0,0 +1,3 @@
class Button {
void actionPerformed() {}
}
@@ -255,4 +255,11 @@ public class JavaCodeVisionProvider implements InlayHintsProvider<JavaCodeVision
public boolean isVisibleInSettings() {
return true;
}
@Nls
@Nullable
@Override
public String getProperty(@NotNull String key) {
return JavaBundle.message(key);
}
}
@@ -170,6 +170,13 @@ public class ProjectProblemHintProvider implements InlayHintsProvider<NoSettings
return null;
}
@Nls
@Nullable
@Override
public String getProperty(@NotNull String key) {
return JavaBundle.message(key);
}
@NotNull
@Override
public ImmediateConfigurable createConfigurable(@NotNull NoSettings settings) {
@@ -1193,7 +1193,10 @@ inlay.parameters.java.simple.sequentially.numbered=Methods that take multiple pa
inlay.parameters.java.enums=Enum constant declarations that use a parametrized constructor.
inlay.parameters.java.new.expr=Calls to parametrized constructors.
inlay.parameters.java.clear.expression.type=Method calls that use a complex expression as an argument, for example, the ternary operator or a Java 13 switch statement.
inlay.JavaLens.usages=The number of usages of the class or method in the project. Click the hint to navigate to usages.
inlay.JavaLens.inheritors=The number of descendants the class or interface has. Click the hint to navigate to the code that inherits from this class or interface.
inlay.MethodChainsInlayProvider.description=Method return types in call chains.
inlay.RelatedProblems.description=The number of problems in the project related to the class or member signature. For example: missing parameters, wrong return type, and so on.<br><br>The hint does not appear for the problems within the same file.
show.import.popup.for.classes=&Classes
show.import.popup.for.static.methods.and.fields=&Static methods and fields
exclude.import.wildcard.comment=Use the * wildcard to exclude all members of a specified class or package
@@ -57,7 +57,7 @@ abstract class InlayProviderSettingsModel(var isEnabled: Boolean, val id: String
*/
abstract val previewText: String?
abstract fun getCasePreview(case: ImmediateConfigurable.Case): String?
abstract fun getCasePreview(case: ImmediateConfigurable.Case?): String?
@Nls
abstract fun getCaseDescription(case: ImmediateConfigurable.Case): String?
@@ -131,7 +131,7 @@ class InlaySettingsPanel(val project: Project): JPanel(BorderLayout()) {
addDescription(item.description)
item.component.border = JBUI.Borders.empty()
rightPanel.add(item.component)
addPreview(item.previewText, item.language)
addPreview(item.getCasePreview(null) ?: item.previewText, item.language)
}
is ImmediateConfigurable.Case -> {
val parent = treeNode.parent as CheckedTreeNode
@@ -51,7 +51,7 @@ class NewInlayProviderSettingsModel<T : Any>(
override val previewText: String?
get() = providerWithSettings.provider.previewText
override fun getCasePreview(case: ImmediateConfigurable.Case): String? {
override fun getCasePreview(case: ImmediateConfigurable.Case?): String? {
return getCasePreview(providerWithSettings.language, providerWithSettings.provider, case)
}
@@ -85,10 +85,10 @@ class NewInlayProviderSettingsModel<T : Any>(
}
}
fun getCasePreview(language: Language, provider: Any, case: ImmediateConfigurable.Case): String? {
fun getCasePreview(language: Language, provider: Any, case: ImmediateConfigurable.Case?): String? {
val key = (provider as? InlayHintsProvider<*>)?.key?.id ?: "Parameters"
val fileType = language.associatedFileType ?: PlainTextFileType.INSTANCE
val path = "inlayProviders/" + key + "/" + case.id + "." + fileType.defaultExtension
val path = "inlayProviders/" + key + "/" + (case?.id ?: "preview") + "." + fileType.defaultExtension
val stream = provider.javaClass.classLoader.getResourceAsStream(path)
return if (stream != null) ResourceUtil.loadText(stream) else null
}
@@ -22,7 +22,7 @@ class ParameterInlayProviderSettingsModel(
override val previewText: String?
get() = null
override fun getCasePreview(case: ImmediateConfigurable.Case): String? {
override fun getCasePreview(case: ImmediateConfigurable.Case?): String? {
return getCasePreview(language, provider, case)
}