/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 7073631
* @summary tests error and diagnostics positions
* @author jan.lahoda@oracle.com
*/
}
}
return text;
}
}
assertEquals("testPositionForSuperConstructorCalls",
assertEquals("testPositionForSuperConstructorCalls",
assertEquals("testPositionForSuperConstructorCalls",
assertEquals("testPositionForSuperConstructorCalls",
assertEquals("testPositionForSuperConstructorCalls",
assertEquals("testPositionForSuperConstructorCalls",
}
assertEquals("testPositionForEnumModifiers",
assertEquals("testPositionForEnumModifiers",
}
"class d {} private void method() { " +
"Object o = Test.this.new d(); } }";
((VariableTree) ((MethodTree) clazz.getMembers().get(1)).getBody().getStatements().get(0)).getInitializer();
assertEquals("testNewClassWithEnclosing",
assertEquals("testNewClassWithEnclosing",
}
"private void test() {" +
"Object o = null; boolean b = o != null && o instanceof String;" +
"} private Test() {}}";
assertEquals("testNewClassWithEnclosing",
}
"return Runnable()",
"do { } while (true)",
"throw UnsupportedOperationException()",
"assert true",
"1 + 1",};
+ "public class Test {\n"
+ " public static void test() {\n"
+ " new Runnable() {\n"
+ " };\n"
+ " }\n"
+ "}";
}
}
"break",
"break A",
"continue ",
"continue A",};
+ "public class Test {\n"
+ " public static void test() {\n"
+ " while (true) {\n"
+ " new Runnable() {\n"
+ " };\n"
+ " }\n"
+ " }\n"
+ "}";
((BlockTree) ((WhileLoopTree) method.getBody().getStatements().get(0)).getStatement()).getStatements();
}
}
"private void method() { " +
"java.util.Set<String> s = null; for (a : s) {} } }";
new DiagnosticListener<JavaFileObject>() {
}
assertEquals("testErrorRecoveryForEnhancedForLoop142381",
}
assertEquals("testPositionAnnotationNoPackage187551",
}
performPositionsSanityTest("package test; class Test { " +
"private void method() { " +
"java.util.List<? extends java.util.List<? extends String>> l; " +
"} }");
performPositionsSanityTest("package test; class Test { " +
"private void method() { " +
"java.util.List<? super java.util.List<? super String>> l; " +
"} }");
performPositionsSanityTest("package test; class Test { " +
"private void method() { " +
"java.util.List<? super java.util.List<?>> l; } }");
}
new DiagnosticListener<JavaFileObject>() {
}
private long parentStart = 0;
return null;
}
if (start == (-1)) {
return null; //synthetic tree
}
parentStart <= start);
long prevParentStart = parentStart;
parentStart = start;
long prevParentEnd = parentEnd;
return null;
}
}
}
performWildcardPositionsTest("package test; import java.util.List; " +
"class Test { private void method() { List<? extends List<? extends String>> l; } }",
"List<? extends List<? extends String>>",
"List",
"? extends List<? extends String>",
"List<? extends String>",
"List",
"? extends String",
"String"));
performWildcardPositionsTest("package test; import java.util.List; " +
"class Test { private void method() { List<? super List<? super String>> l; } }",
"List<? super List<? super String>>",
"List",
"? super List<? super String>",
"List<? super String>",
"List",
"? super String",
"String"));
performWildcardPositionsTest("package test; import java.util.List; " +
"class Test { private void method() { List<? super List<?>> l; } }",
"List<? super List<?>>",
"List",
"? super List<?>",
"List<?>",
"List",
"?"));
performWildcardPositionsTest("package test; import java.util.List; " +
"class Test { private void method() { " +
"List<? extends List<? extends List<? extends String>>> l; } }",
"List<? extends List<? extends List<? extends String>>>",
"List",
"? extends List<? extends List<? extends String>>",
"List<? extends List<? extends String>>",
"List",
"? extends List<? extends String>",
"List<? extends String>",
"List",
"? extends String",
"String"));
performWildcardPositionsTest("package test; import java.util.List; " +
"class Test { private void method() { " +
"List<? extends List<? extends List<? extends String >>> l; } }",
"List<? extends List<? extends List<? extends String >>>",
"List",
"? extends List<? extends List<? extends String >>",
"List<? extends List<? extends String >>",
"List",
"? extends List<? extends String >",
"List<? extends String >",
"List",
"? extends String",
"String"));
}
new DiagnosticListener<JavaFileObject>() {
}
return null;
}
if (start == (-1)) {
return null; //synthetic tree
}
}
}.scan(((MethodTree) ((ClassTree) cut.getTypeDecls().get(0)).getMembers().get(0)).getBody().getStatements().get(0), null);
}
assertEquals("testStartPositionForMethodWithoutModifiers",
}
}
"private static void t(String name) { " +
"if (name != null) String nn = name.trim(); } }";
new DiagnosticCollector<JavaFileObject>();
}
assertEquals("testVariableInIfThen1",
codes);
}
"private static void t(String name) { " +
"if (name != null) class X {} } }";
new DiagnosticCollector<JavaFileObject>();
}
assertEquals("testVariableInIfThen2",
}
"private static void t(String name) { " +
"if (name != null) abstract } }";
new DiagnosticCollector<JavaFileObject>();
}
assertEquals("testVariableInIfThen3",
codes);
}
//see javac bug #6882235, NB bug #98234:
}
"{ try (java.io.InputStream in = null) { } } }";
}
return super.visitVariable(node, p);
}
}
"{ java.io.InputStream in = null; } }";
}
return super.visitVariable(node, p);
}
}
// Fails with nb-javac, needs further investigation
// Fails, these tests yet to be addressed
}
testVarPos();
}
jpt.testPositions();
}
}
abstract class TestCase {
if (i != pos) {
}
}
throw new UnsupportedOperationException("Not yet implemented");
}
if (i != l) {
}
}
}
}
}
if (o == null) {
fail();
}
}
void fail() {
fail("test failed");
}
throw new RuntimeException(message);
}
}