|
@@ -31,6 +31,7 @@ import (
|
|
|
"os"
|
|
|
"os/exec"
|
|
|
"regexp"
|
|
|
+ "strconv"
|
|
|
"syscall"
|
|
|
)
|
|
|
|
|
@@ -80,10 +81,11 @@ func Main(out io.Writer, name string, args []string) (int, error) {
|
|
|
|
|
|
pw.Close()
|
|
|
|
|
|
+ proc := processor{}
|
|
|
// Process subprocess stdout asynchronously
|
|
|
errCh := make(chan error)
|
|
|
go func() {
|
|
|
- errCh <- process(pr, out)
|
|
|
+ errCh <- proc.process(pr, out)
|
|
|
}()
|
|
|
|
|
|
// Wait for subprocess to finish
|
|
@@ -117,14 +119,18 @@ func Main(out io.Writer, name string, args []string) (int, error) {
|
|
|
return 0, nil
|
|
|
}
|
|
|
|
|
|
-func process(r io.Reader, w io.Writer) error {
|
|
|
+type processor struct {
|
|
|
+ silencedWarnings int
|
|
|
+}
|
|
|
+
|
|
|
+func (proc *processor) process(r io.Reader, w io.Writer) error {
|
|
|
scanner := bufio.NewScanner(r)
|
|
|
// Some javac wrappers output the entire list of java files being
|
|
|
// compiled on a single line, which can be very large, set the maximum
|
|
|
// buffer size to 2MB.
|
|
|
scanner.Buffer(nil, 2*1024*1024)
|
|
|
for scanner.Scan() {
|
|
|
- processLine(w, scanner.Text())
|
|
|
+ proc.processLine(w, scanner.Text())
|
|
|
}
|
|
|
err := scanner.Err()
|
|
|
if err != nil {
|
|
@@ -133,12 +139,32 @@ func process(r io.Reader, w io.Writer) error {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
-func processLine(w io.Writer, line string) {
|
|
|
+func (proc *processor) processLine(w io.Writer, line string) {
|
|
|
+ for _, f := range warningFilters {
|
|
|
+ if f.MatchString(line) {
|
|
|
+ proc.silencedWarnings++
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
for _, f := range filters {
|
|
|
if f.MatchString(line) {
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
+ if match := warningCount.FindStringSubmatch(line); match != nil {
|
|
|
+ c, err := strconv.Atoi(match[1])
|
|
|
+ if err == nil {
|
|
|
+ c -= proc.silencedWarnings
|
|
|
+ if c == 0 {
|
|
|
+ return
|
|
|
+ } else {
|
|
|
+ line = fmt.Sprintf("%d warning", c)
|
|
|
+ if c > 1 {
|
|
|
+ line += "s"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
for _, p := range colorPatterns {
|
|
|
var matched bool
|
|
|
if line, matched = applyColor(line, p.color, p.re); matched {
|
|
@@ -170,12 +196,17 @@ var colorPatterns = []struct {
|
|
|
{markerRe, green},
|
|
|
}
|
|
|
|
|
|
+var warningCount = regexp.MustCompile(`^([0-9]+) warning(s)?$`)
|
|
|
+
|
|
|
+var warningFilters = []*regexp.Regexp{
|
|
|
+ regexp.MustCompile(`bootstrap class path not set in conjunction with -source`),
|
|
|
+}
|
|
|
+
|
|
|
var filters = []*regexp.Regexp{
|
|
|
regexp.MustCompile(`Note: (Some input files|.*\.java) uses? or overrides? a deprecated API.`),
|
|
|
regexp.MustCompile(`Note: Recompile with -Xlint:deprecation for details.`),
|
|
|
regexp.MustCompile(`Note: (Some input files|.*\.java) uses? unchecked or unsafe operations.`),
|
|
|
regexp.MustCompile(`Note: Recompile with -Xlint:unchecked for details.`),
|
|
|
- regexp.MustCompile(`bootstrap class path not set in conjunction with -source`),
|
|
|
|
|
|
regexp.MustCompile(`javadoc: warning - The old Doclet and Taglet APIs in the packages`),
|
|
|
regexp.MustCompile(`com.sun.javadoc, com.sun.tools.doclets and their implementations`),
|