1 /* |
1 /* |
2 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
31 import java.io.OutputStream; |
31 import java.io.OutputStream; |
32 import java.net.URI; |
32 import java.net.URI; |
33 import javax.tools.JavaFileObject; |
33 import javax.tools.JavaFileObject; |
34 import javax.tools.SimpleJavaFileObject; |
34 import javax.tools.SimpleJavaFileObject; |
35 import com.sun.tools.javac.file.JavacFileManager; |
35 import com.sun.tools.javac.file.JavacFileManager; |
|
36 import com.sun.tools.javac.parser.EndPosTable; |
36 import com.sun.tools.javac.parser.Parser; |
37 import com.sun.tools.javac.parser.Parser; |
37 import com.sun.tools.javac.parser.ParserFactory; |
38 import com.sun.tools.javac.parser.ParserFactory; |
38 import com.sun.tools.javac.tree.JCTree; |
39 import com.sun.tools.javac.tree.JCTree; |
39 import com.sun.tools.javac.tree.TreeScanner; |
40 import com.sun.tools.javac.tree.TreeScanner; |
40 import com.sun.tools.javac.util.Context; |
41 import com.sun.tools.javac.util.Context; |
95 throw new IllegalStateException("test failed"); |
96 throw new IllegalStateException("test failed"); |
96 } |
97 } |
97 } |
98 } |
98 |
99 |
99 private static class LogTester extends TreeScanner { |
100 private static class LogTester extends TreeScanner { |
100 LogTester(Log log, java.util.Map<JCTree, Integer> endPositions) { |
101 LogTester(Log log, EndPosTable endPosTable) { |
101 this.log = log; |
102 this.log = log; |
102 this.endPositions = endPositions; |
103 this.endPosTable = endPosTable; |
103 } |
104 } |
104 |
105 |
105 public void visitIf(JCTree.JCIf tree) { |
106 public void visitIf(JCTree.JCIf tree) { |
106 JCDiagnostic.DiagnosticPosition nil = null; |
107 JCDiagnostic.DiagnosticPosition nil = null; |
107 // generate dummy messages to exercise the log API |
108 // generate dummy messages to exercise the log API |
115 log.warning(tree.pos(), "div.zero"); |
116 log.warning(tree.pos(), "div.zero"); |
116 log.warning(nil, "div.zero"); |
117 log.warning(nil, "div.zero"); |
117 } |
118 } |
118 |
119 |
119 private Log log; |
120 private Log log; |
120 private java.util.Map<JCTree, Integer> endPositions; |
121 private EndPosTable endPosTable; |
121 } |
122 } |
122 |
123 |
123 private static class StringJavaFileObject extends SimpleJavaFileObject { |
124 private static class StringJavaFileObject extends SimpleJavaFileObject { |
124 StringJavaFileObject(String name, String text) { |
125 StringJavaFileObject(String name, String text) { |
125 super(URI.create(name), JavaFileObject.Kind.SOURCE); |
126 super(URI.create(name), JavaFileObject.Kind.SOURCE); |