When no hints are specified on the command line, run all hints that are enabled by default.
authorJan Lahoda <jlahoda@netbeans.org>
Tue, 01 Nov 2011 19:35:51 +0100
changeset 7072e36f1dcae53
parent 706 c1f1e5a21269
child 708 b2e182ed9f43
When no hints are specified on the command line, run all hints that are enabled by default.
cmdline/tool/src/org/netbeans/modules/jackpot30/cmdline/Main.java
     1.1 --- a/cmdline/tool/src/org/netbeans/modules/jackpot30/cmdline/Main.java	Fri Oct 28 20:31:15 2011 +0200
     1.2 +++ b/cmdline/tool/src/org/netbeans/modules/jackpot30/cmdline/Main.java	Tue Nov 01 19:35:51 2011 +0100
     1.3 @@ -82,6 +82,7 @@
     1.4  import org.netbeans.modules.java.hints.jackpot.impl.batch.Scopes;
     1.5  import org.netbeans.modules.java.hints.jackpot.spi.HintDescription;
     1.6  import org.netbeans.modules.java.hints.jackpot.spi.HintMetadata;
     1.7 +import org.netbeans.modules.java.hints.jackpot.spi.HintMetadata.Kind;
     1.8  import org.netbeans.modules.java.hints.options.HintsSettings;
     1.9  import org.netbeans.modules.java.source.parsing.JavaPathRecognizer;
    1.10  import org.netbeans.modules.parsing.impl.indexing.CacheFolder;
    1.11 @@ -119,7 +120,7 @@
    1.12          ArgumentAcceptingOptionSpec<File> classpath = parser.accepts("classpath", "classpath").withRequiredArg().withValuesSeparatedBy(File.pathSeparatorChar).ofType(File.class);
    1.13          ArgumentAcceptingOptionSpec<File> bootclasspath = parser.accepts("bootclasspath", "bootclasspath").withRequiredArg().withValuesSeparatedBy(File.pathSeparatorChar).ofType(File.class);
    1.14          ArgumentAcceptingOptionSpec<File> sourcepath = parser.accepts("sourcepath", "sourcepath").withRequiredArg().withValuesSeparatedBy(File.pathSeparatorChar).ofType(File.class);
    1.15 -        ArgumentAcceptingOptionSpec<File> cache = parser.accepts("cache", "source directory").withRequiredArg().ofType(File.class);
    1.16 +        ArgumentAcceptingOptionSpec<File> cache = parser.accepts("cache", "a cache directory to store working data").withRequiredArg().ofType(File.class);
    1.17          ArgumentAcceptingOptionSpec<File> out = parser.accepts("out", "output diff").withRequiredArg().ofType(File.class);
    1.18          ArgumentAcceptingOptionSpec<String> hint = parser.accepts("hint", "hint name").withRequiredArg().ofType(String.class);
    1.19          ArgumentAcceptingOptionSpec<String> config = parser.accepts("config", "configurations").withRequiredArg().ofType(String.class);
    1.20 @@ -204,13 +205,24 @@
    1.21                  return 1;
    1.22              }
    1.23  
    1.24 -            Iterable<? extends HintDescription> hints = findHints(parsed.valueOf(hint));
    1.25 +            Iterable<? extends HintDescription> hints;
    1.26 +            
    1.27 +            if (parsed.has(hint)) {
    1.28 +                hints = findHints(parsed.valueOf(hint));
    1.29 +            } else {
    1.30 +                hints = allHints();
    1.31 +            }
    1.32  
    1.33              if (!hints.iterator().hasNext()) {
    1.34                  System.err.println("no hints specified");
    1.35                  return 1;
    1.36              }
    1.37  
    1.38 +            if (parsed.has(config) && !parsed.has(hint)) {
    1.39 +                System.err.println("--config cannot specified when no hint is specified");
    1.40 +                return 1;
    1.41 +            }
    1.42 +
    1.43              if (parsed.has(config)) {
    1.44                  Iterator<? extends HintDescription> hit = hints.iterator();
    1.45                  HintDescription hd = hit.next();
    1.46 @@ -293,6 +305,18 @@
    1.47          return descs;
    1.48      }
    1.49  
    1.50 +    private static Iterable<? extends HintDescription> allHints() {
    1.51 +        List<HintDescription> descs = new LinkedList<HintDescription>();
    1.52 +
    1.53 +        for (Entry<HintMetadata, Collection<? extends HintDescription>> e : RulesManager.getInstance().allHints.entrySet()) {
    1.54 +            if (e.getKey().kind != Kind.HINT) continue;
    1.55 +            if (!e.getKey().enabled) continue;
    1.56 +            descs.addAll(e.getValue());
    1.57 +        }
    1.58 +
    1.59 +        return descs;
    1.60 +    }
    1.61 +
    1.62      private static final Logger TOP_LOGGER = Logger.getLogger("");
    1.63  
    1.64      private static void prepareLoggers() {