From 904d06bbbc2ad8f22d798b7d8e0dcef9fe58a85c Mon Sep 17 00:00:00 2001 From: Tagir Valeev Date: Wed, 1 Feb 2023 15:32:25 +0100 Subject: [PATCH] [java-completion] VmOptionsCompletionContributorTest: hardcode documentation for standard options GitOrigin-RevId: fe9c95b84ff376bece8e07254d4b399845bf7acb --- .../ui/VmOptionsCompletionContributor.java | 27 ++++++++++++++----- .../intellij/execution/vmOptions/VMOption.kt | 7 +++-- .../resources/messages/JavaBundle.properties | 1 + 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/java/execution/impl/src/com/intellij/execution/ui/VmOptionsCompletionContributor.java b/java/execution/impl/src/com/intellij/execution/ui/VmOptionsCompletionContributor.java index 33b02baa7d4e..dae5fa6da76b 100644 --- a/java/execution/impl/src/com/intellij/execution/ui/VmOptionsCompletionContributor.java +++ b/java/execution/impl/src/com/intellij/execution/ui/VmOptionsCompletionContributor.java @@ -36,6 +36,24 @@ public class VmOptionsCompletionContributor extends CompletionContributor implem private static final Pattern OPTION_SEPARATOR = Pattern.compile("\\s+"); private static final Pattern OPTION_MATCHER = Pattern.compile("^-XX:[+\\-]?(\\w+)(=.+)?$"); + private static final VMOption[] STANDARD_OPTIONS = { + opt("ea", "enable assertions with specified granularity"), + opt("enableassertions", "enable assertions with specified granularity"), + opt("da", "disable assertions with specified granularity"), + opt("disableassertions", "disable assertions with specified granularity"), + opt("esa", "enable system assertions"), + opt("dsa", "disable system assertions"), + opt("agentpath:", "load native agent library by full pathname"), + opt("agentlib:", "load native agent library , e.g. -agentlib:jdwp"), + opt("javaagent:", "load Java programming language agent"), + opt("D", "set a system property in format ="), + opt("XX:", "specify non-standard JVM-specific option"), + }; + + private static VMOption opt(@NotNull String name, @NotNull String doc) { + return new VMOption(name, null, null, VMOptionKind.Standard, doc, VMOptionVariant.DASH); + } + @Override public void fillCompletionVariants(@NotNull CompletionParameters parameters, @NotNull CompletionResultSet result) { Document document = parameters.getEditor().getDocument(); @@ -69,12 +87,9 @@ public class VmOptionsCompletionContributor extends CompletionContributor implem } private static void addDashOptions(@NotNull CompletionResultSet result, @NotNull JdkOptionsData data, String prefix) { - String[] options = {"ea", "enableassertions", "da", "disableassertions", "esa", "dsa", "agentpath:", "agentlib:", - "javaagent:", "XX:", "D"}; - Stream stream = Stream.concat( - data.getOptions().stream().filter(option -> option.getVariant() != VMOptionVariant.XX), - Stream.of(options).map(opt -> new VMOption(opt, null, null, VMOptionKind.Product, null, VMOptionVariant.DASH))); - stream.forEach(option -> { + Stream.concat( + data.getOptions().stream().filter(option1 -> option1.getVariant() != VMOptionVariant.XX), + Stream.of(STANDARD_OPTIONS)).forEach(option -> { String fullLookup = option.getVariant().prefix() + option.getOptionName(); if (!fullLookup.startsWith(prefix)) return; String lookup = fullLookup.substring(prefix.length()); diff --git a/java/execution/impl/src/com/intellij/execution/vmOptions/VMOption.kt b/java/execution/impl/src/com/intellij/execution/vmOptions/VMOption.kt index 34e58b1496d6..b1793b480302 100644 --- a/java/execution/impl/src/com/intellij/execution/vmOptions/VMOption.kt +++ b/java/execution/impl/src/com/intellij/execution/vmOptions/VMOption.kt @@ -72,23 +72,26 @@ enum class VMOptionVariant { } enum class VMOptionKind { + Standard, Product, Diagnostic, Experimental; fun presentation(): @Nls String = when (this) { + Standard -> JavaBundle.message("vm.option.description.standard") Product -> JavaBundle.message("vm.option.description.product") Diagnostic -> JavaBundle.message("vm.option.description.diagnostic") Experimental -> JavaBundle.message("vm.option.description.experimental") } fun unlockOption(): @NlsSafe String? = when (this) { - Product -> null + Product, Standard -> null Diagnostic -> "-XX:+UnlockDiagnosticVMOptions" Experimental -> "-XX:+UnlockExperimentalVMOptions" } - fun icon(): Icon = when (this) { + fun icon(): Icon? = when (this) { + Standard -> null Product -> AllIcons.Actions.ArrowExpand Diagnostic -> AllIcons.General.ShowInfos Experimental -> AllIcons.General.Warning diff --git a/java/openapi/resources/messages/JavaBundle.properties b/java/openapi/resources/messages/JavaBundle.properties index 1f77aaec7f4a..8f26edea38c4 100644 --- a/java/openapi/resources/messages/JavaBundle.properties +++ b/java/openapi/resources/messages/JavaBundle.properties @@ -1810,6 +1810,7 @@ vm.option.description.category=Category: vm.option.description.type=Type: vm.option.description.default.value=Default value: vm.option.description.description=Description: +vm.option.description.standard=Standard vm.option.description.product=Product vm.option.description.diagnostic=Diagnostic vm.option.description.experimental=Experimental