< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.options/src/org/graalvm/compiler/options/OptionValues.java

Print this page




 196      * @param out
 197      * @param namePrefix
 198      */
 199     public void printHelp(Iterable<OptionDescriptors> loader, PrintStream out, String namePrefix) {
 200         SortedMap<String, OptionDescriptor> sortedOptions = new TreeMap<>();
 201         for (OptionDescriptors opts : loader) {
 202             for (OptionDescriptor desc : opts) {
 203                 String name = desc.getName();
 204                 OptionDescriptor existing = sortedOptions.put(name, desc);
 205                 assert existing == null || existing == desc : "Option named \"" + name + "\" has multiple definitions: " + existing.getLocation() + " and " + desc.getLocation();
 206             }
 207         }
 208         for (Map.Entry<String, OptionDescriptor> e : sortedOptions.entrySet()) {
 209             OptionDescriptor desc = e.getValue();
 210             Object value = desc.getOptionKey().getValue(this);
 211             if (value instanceof String) {
 212                 value = '"' + String.valueOf(value) + '"';
 213             }
 214 
 215             String name = namePrefix + e.getKey();
 216             String assign = containsKey(desc.optionKey) ? ":=" : "=";
 217             String typeName = desc.getOptionKey() instanceof EnumOptionKey ? "String" : desc.getOptionValueType().getSimpleName();
 218             String linePrefix = String.format("%s %s %s ", name, assign, value);
 219             int typeStartPos = PROPERTY_LINE_WIDTH - typeName.length();
 220             int linePad = typeStartPos - linePrefix.length();
 221             if (linePad > 0) {
 222                 out.printf("%s%-" + linePad + "s[%s]%n", linePrefix, "", typeName);
 223             } else {
 224                 out.printf("%s[%s]%n", linePrefix, typeName);
 225             }
 226 
 227             List<String> helpLines;
 228             String help = desc.getHelp();
 229             if (help.length() != 0) {
 230                 helpLines = wrap(help, PROPERTY_LINE_WIDTH - PROPERTY_HELP_INDENT);
 231                 helpLines.addAll(desc.getExtraHelp());
 232             } else {
 233                 helpLines = desc.getExtraHelp();
 234             }
 235             for (String line : helpLines) {
 236                 out.printf("%" + PROPERTY_HELP_INDENT + "s%s%n", "", line);


 196      * @param out
 197      * @param namePrefix
 198      */
 199     public void printHelp(Iterable<OptionDescriptors> loader, PrintStream out, String namePrefix) {
 200         SortedMap<String, OptionDescriptor> sortedOptions = new TreeMap<>();
 201         for (OptionDescriptors opts : loader) {
 202             for (OptionDescriptor desc : opts) {
 203                 String name = desc.getName();
 204                 OptionDescriptor existing = sortedOptions.put(name, desc);
 205                 assert existing == null || existing == desc : "Option named \"" + name + "\" has multiple definitions: " + existing.getLocation() + " and " + desc.getLocation();
 206             }
 207         }
 208         for (Map.Entry<String, OptionDescriptor> e : sortedOptions.entrySet()) {
 209             OptionDescriptor desc = e.getValue();
 210             Object value = desc.getOptionKey().getValue(this);
 211             if (value instanceof String) {
 212                 value = '"' + String.valueOf(value) + '"';
 213             }
 214 
 215             String name = namePrefix + e.getKey();
 216             String assign = containsKey(desc.getOptionKey()) ? ":=" : "=";
 217             String typeName = desc.getOptionKey() instanceof EnumOptionKey ? "String" : desc.getOptionValueType().getSimpleName();
 218             String linePrefix = String.format("%s %s %s ", name, assign, value);
 219             int typeStartPos = PROPERTY_LINE_WIDTH - typeName.length();
 220             int linePad = typeStartPos - linePrefix.length();
 221             if (linePad > 0) {
 222                 out.printf("%s%-" + linePad + "s[%s]%n", linePrefix, "", typeName);
 223             } else {
 224                 out.printf("%s[%s]%n", linePrefix, typeName);
 225             }
 226 
 227             List<String> helpLines;
 228             String help = desc.getHelp();
 229             if (help.length() != 0) {
 230                 helpLines = wrap(help, PROPERTY_LINE_WIDTH - PROPERTY_HELP_INDENT);
 231                 helpLines.addAll(desc.getExtraHelp());
 232             } else {
 233                 helpLines = desc.getExtraHelp();
 234             }
 235             for (String line : helpLines) {
 236                 out.printf("%" + PROPERTY_HELP_INDENT + "s%s%n", "", line);
< prev index next >