Even more generic way to strip unwanted characters from the hint description.
authorJan Lahoda <jlahoda@netbeans.org>
Wed, 26 Sep 2012 18:52:44 +0200
changeset 883da2b1feac144
parent 882 cbe09579995a
child 884 90c118cdf459
Even more generic way to strip unwanted characters from the hint description.
cmdline/tool/src/org/netbeans/modules/jackpot30/cmdline/Main.java
cmdline/tool/test/unit/src/org/netbeans/modules/jackpot30/cmdline/MainTest.java
     1.1 --- a/cmdline/tool/src/org/netbeans/modules/jackpot30/cmdline/Main.java	Wed Sep 26 15:49:23 2012 +0200
     1.2 +++ b/cmdline/tool/src/org/netbeans/modules/jackpot30/cmdline/Main.java	Wed Sep 26 18:52:44 2012 +0200
     1.3 @@ -550,10 +550,12 @@
     1.4          }
     1.5  
     1.6          for (Entry<String, String> remap : toIdRemap.entrySet()) {
     1.7 -            idDisplayName.replace(remap.getKey(), remap.getValue());
     1.8 +            idDisplayName = idDisplayName.replace(remap.getKey(), remap.getValue());
     1.9          }
    1.10  
    1.11 -        idDisplayName = "[" + idDisplayName.replaceAll("_+", "_") + "] ";
    1.12 +        idDisplayName = idDisplayName.replaceAll("[^A-Za-z0-9]", "_").replaceAll("_+", "_");
    1.13 +
    1.14 +        idDisplayName = "[" + idDisplayName + "] ";
    1.15  
    1.16          System.out.println(FileUtil.getFileDisplayName(error.getFile()) + ":" + (lineNumber + 1) + ": warning: " + idDisplayName + error.getDescription());
    1.17          System.out.println(line);
    1.18 @@ -561,11 +563,6 @@
    1.19      }
    1.20  
    1.21      private static final Map<String, String> toIdRemap = new HashMap<String, String>() {{
    1.22 -        put(" ", "_");
    1.23 -        put("-", "_");
    1.24 -        put(".", "_");
    1.25 -        put("(", "");
    1.26 -        put(")", "");
    1.27          put("==", "equals");
    1.28          put("!=", "not_equals");
    1.29      }};
     2.1 --- a/cmdline/tool/test/unit/src/org/netbeans/modules/jackpot30/cmdline/MainTest.java	Wed Sep 26 15:49:23 2012 +0200
     2.2 +++ b/cmdline/tool/test/unit/src/org/netbeans/modules/jackpot30/cmdline/MainTest.java	Wed Sep 26 18:52:44 2012 +0200
     2.3 @@ -103,10 +103,10 @@
     2.4              "}\n";
     2.5  
     2.6          doRunCompiler(golden,
     2.7 -                      "${workdir}/src/test/Test.java:4: warning: Usage of .size() == 0 can be replaced with .isEmpty()\n" +
     2.8 +                      "${workdir}/src/test/Test.java:4: warning: [Usage_of_size_equals_0] Usage of .size() == 0 can be replaced with .isEmpty()\n" +
     2.9                        "        boolean b1 = c.size() == 0;\n" +
    2.10                        "                     ^\n" +
    2.11 -                      "${workdir}/src/test/Test.java:5: warning: Usage of .size() == 0 can be replaced with .isEmpty()\n" +
    2.12 +                      "${workdir}/src/test/Test.java:5: warning: [Usage_of_size_equals_0] Usage of .size() == 0 can be replaced with .isEmpty()\n" +
    2.13                        "\tboolean b2 = c.size() == 0;\n" +
    2.14                        "\t             ^\n",
    2.15                        null,
    2.16 @@ -232,7 +232,7 @@
    2.17              "}\n";
    2.18  
    2.19          doRunCompiler(golden,
    2.20 -                      "${workdir}/src/test/Test.java:4: warning: Usage of .size() == 0 can be replaced with .isEmpty()\n" +
    2.21 +                      "${workdir}/src/test/Test.java:4: warning: [Usage_of_size_equals_0] Usage of .size() == 0 can be replaced with .isEmpty()\n" +
    2.22                        "        boolean b = c.size() == 0;\n" +
    2.23                        "                    ^\n",
    2.24                        null,