Print hint display name as a warning category.
authorJan Lahoda <jlahoda@netbeans.org>
Fri, 21 Sep 2012 20:48:10 +0200
changeset 875d890cdbd7bec
parent 874 32f5a10feaf5
child 876 cf176088c0fe
Print hint display name as a warning category.
cmdline/tool/src/org/netbeans/modules/jackpot30/cmdline/Main.java
     1.1 --- a/cmdline/tool/src/org/netbeans/modules/jackpot30/cmdline/Main.java	Tue Sep 18 08:00:09 2012 +0200
     1.2 +++ b/cmdline/tool/src/org/netbeans/modules/jackpot30/cmdline/Main.java	Fri Sep 21 20:48:10 2012 +0200
     1.3 @@ -487,6 +487,14 @@
     1.4      }
     1.5      
     1.6      private static void findOccurrences(Iterable<? extends HintDescription> descs, Folder[] sourceRoot, ProgressHandleWrapper progress, File out) throws IOException {
     1.7 +        final Map<String, String> id2DisplayName = new HashMap<String, String>();
     1.8 +
     1.9 +        for (HintDescription hd : descs) {
    1.10 +            if (hd.getMetadata() != null) {
    1.11 +                id2DisplayName.put(hd.getMetadata().id, hd.getMetadata().displayName);
    1.12 +            }
    1.13 +        }
    1.14 +
    1.15          ProgressHandleWrapper w = progress.startNextPartWithEmbedding(1, 1);
    1.16          BatchResult occurrences = BatchSearch.findOccurrences(descs, Scopes.specifiedFoldersScope(sourceRoot), w);
    1.17  
    1.18 @@ -495,7 +503,7 @@
    1.19              @Override public void groupStarted() {}
    1.20              @Override public boolean spansVerified(CompilationController wc, Resource r, Collection<? extends ErrorDescription> hints) throws Exception {
    1.21                  for (ErrorDescription ed : hints) {
    1.22 -                    print(ed);
    1.23 +                    print(ed, id2DisplayName);
    1.24                  }
    1.25                  return true;
    1.26              }
    1.27 @@ -506,7 +514,7 @@
    1.28          }, problems, new AtomicBoolean());
    1.29      }
    1.30  
    1.31 -    private static void print(ErrorDescription error) throws IOException {
    1.32 +    private static void print(ErrorDescription error, Map<String, String> id2DisplayName) throws IOException {
    1.33          int lineNumber = error.getRange().getBegin().getLine();
    1.34          String line = error.getFile().asLines().get(lineNumber);
    1.35          int column = error.getRange().getBegin().getColumn();
    1.36 @@ -522,7 +530,21 @@
    1.37  
    1.38          b.append('^');
    1.39  
    1.40 -        System.out.println(FileUtil.getFileDisplayName(error.getFile()) + ":" + (lineNumber + 1) + ": warning: " + error.getDescription());
    1.41 +        String id = error.getId();
    1.42 +
    1.43 +        if (id != null && id.startsWith("text/x-java:")) {
    1.44 +            id = id.substring("text/x-java:".length());
    1.45 +        }
    1.46 +
    1.47 +        String idDisplayName = id2DisplayName.get(id);
    1.48 +
    1.49 +        if (idDisplayName == null) {
    1.50 +            idDisplayName = "unknown";
    1.51 +        }
    1.52 +
    1.53 +        idDisplayName = "[" + idDisplayName.replace(' ', '_').replace('.', '_').replace("(", "").replace(")", "") + "] ";
    1.54 +
    1.55 +        System.out.println(FileUtil.getFileDisplayName(error.getFile()) + ":" + (lineNumber + 1) + ": warning: " + idDisplayName + error.getDescription());
    1.56          System.out.println(line);
    1.57          System.out.println(b);
    1.58      }