45 import com.sun.tools.javac.tree.JCTree; |
45 import com.sun.tools.javac.tree.JCTree; |
46 import com.sun.tools.javac.tree.JCTree.JCCompilationUnit; |
46 import com.sun.tools.javac.tree.JCTree.JCCompilationUnit; |
47 import com.sun.tools.javac.util.Context; |
47 import com.sun.tools.javac.util.Context; |
48 |
48 |
49 public class MissingSemicolonTest { |
49 public class MissingSemicolonTest { |
50 public static void main(String... args) { |
50 public static void main(String... args) throws IOException { |
51 String testSrc = System.getProperty("test.src"); |
51 String testSrc = System.getProperty("test.src"); |
52 File baseDir = new File(testSrc); |
52 File baseDir = new File(testSrc); |
53 boolean ok = new MissingSemicolonTest().run(baseDir, args); |
53 boolean ok = new MissingSemicolonTest().run(baseDir, args); |
54 if (!ok) { |
54 if (!ok) { |
55 throw new Error("failed"); |
55 throw new Error("failed"); |
56 } |
56 } |
57 } |
57 } |
58 |
58 |
59 boolean run(File baseDir, String... args) { |
59 boolean run(File baseDir, String... args) throws IOException { |
60 if (args.length == 0) { |
60 try { |
61 throw new IllegalStateException("Needs input files."); |
61 if (args.length == 0) { |
62 } |
62 throw new IllegalStateException("Needs input files."); |
63 |
63 } |
64 for (String arg : args) { |
64 |
65 File file = new File(baseDir, arg); |
65 for (String arg : args) { |
66 if (file.exists()) |
66 File file = new File(baseDir, arg); |
67 test(file); |
67 if (file.exists()) |
68 else |
68 test(file); |
69 error("File not found: " + file); |
69 else |
70 } |
70 error("File not found: " + file); |
71 |
71 } |
72 System.err.println(fileCount + " files read"); |
72 |
73 if (errors > 0) |
73 System.err.println(fileCount + " files read"); |
74 System.err.println(errors + " errors"); |
74 if (errors > 0) |
75 |
75 System.err.println(errors + " errors"); |
76 return errors == 0; |
76 |
|
77 return errors == 0; |
|
78 } finally { |
|
79 fm.close(); |
|
80 } |
77 } |
81 } |
78 |
82 |
79 void test(File file) { |
83 void test(File file) { |
80 if (file.isFile() && file.getName().endsWith(".java")) { |
84 if (file.isFile() && file.getName().endsWith(".java")) { |
81 try { |
85 try { |