Merge
This commit is contained in:
commit
ccc8319e5f
@ -1143,49 +1143,49 @@ public class JavacParser implements Parser {
|
|||||||
// typeArgs saved for next loop iteration.
|
// typeArgs saved for next loop iteration.
|
||||||
t = toP(F.at(pos).Select(t, ident()));
|
t = toP(F.at(pos).Select(t, ident()));
|
||||||
break;
|
break;
|
||||||
case LT:
|
// case LT:
|
||||||
if ((mode & (TYPE | NOPARAMS)) == 0) {
|
// if ((mode & (TYPE | NOPARAMS)) == 0) {
|
||||||
//could be an unbound method reference whose qualifier
|
// //could be an unbound method reference whose qualifier
|
||||||
//is a generic type i.e. A<S>#m
|
// //is a generic type i.e. A<S>#m
|
||||||
mode = EXPR | TYPE;
|
// mode = EXPR | TYPE;
|
||||||
JCTree.Tag op = JCTree.Tag.LT;
|
// JCTree.Tag op = JCTree.Tag.LT;
|
||||||
int pos1 = token.pos;
|
// int pos1 = token.pos;
|
||||||
nextToken();
|
// nextToken();
|
||||||
mode |= EXPR | TYPE | TYPEARG;
|
// mode |= EXPR | TYPE | TYPEARG;
|
||||||
JCExpression t1 = term3();
|
// JCExpression t1 = term3();
|
||||||
if ((mode & TYPE) != 0 &&
|
// if ((mode & TYPE) != 0 &&
|
||||||
(token.kind == COMMA || token.kind == GT)) {
|
// (token.kind == COMMA || token.kind == GT)) {
|
||||||
mode = TYPE;
|
// mode = TYPE;
|
||||||
ListBuffer<JCExpression> args = new ListBuffer<JCExpression>();
|
// ListBuffer<JCExpression> args = new ListBuffer<JCExpression>();
|
||||||
args.append(t1);
|
// args.append(t1);
|
||||||
while (token.kind == COMMA) {
|
// while (token.kind == COMMA) {
|
||||||
nextToken();
|
// nextToken();
|
||||||
args.append(typeArgument());
|
// args.append(typeArgument());
|
||||||
}
|
// }
|
||||||
accept(GT);
|
// accept(GT);
|
||||||
t = toP(F.at(pos1).TypeApply(t, args.toList()));
|
// t = toP(F.at(pos1).TypeApply(t, args.toList()));
|
||||||
checkGenerics();
|
// checkGenerics();
|
||||||
while (token.kind == DOT) {
|
// while (token.kind == DOT) {
|
||||||
nextToken();
|
// nextToken();
|
||||||
mode = TYPE;
|
// mode = TYPE;
|
||||||
t = toP(F.at(token.pos).Select(t, ident()));
|
// t = toP(F.at(token.pos).Select(t, ident()));
|
||||||
t = typeArgumentsOpt(t);
|
// t = typeArgumentsOpt(t);
|
||||||
}
|
// }
|
||||||
if (token.kind != HASH) {
|
// if (token.kind != HASH) {
|
||||||
//method reference expected here
|
// //method reference expected here
|
||||||
t = illegal();
|
// t = illegal();
|
||||||
}
|
// }
|
||||||
mode = EXPR;
|
// mode = EXPR;
|
||||||
break;
|
// break;
|
||||||
} else if ((mode & EXPR) != 0) {
|
// } else if ((mode & EXPR) != 0) {
|
||||||
//rollback - it was a binary expression
|
// //rollback - it was a binary expression
|
||||||
mode = EXPR;
|
// mode = EXPR;
|
||||||
JCExpression e = term2Rest(t1, TreeInfo.shiftPrec);
|
// JCExpression e = term2Rest(t1, TreeInfo.shiftPrec);
|
||||||
t = F.at(pos1).Binary(op, t, e);
|
// t = F.at(pos1).Binary(op, t, e);
|
||||||
t = termRest(term1Rest(term2Rest(t, TreeInfo.orPrec)));
|
// t = termRest(term1Rest(term2Rest(t, TreeInfo.orPrec)));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
break loop;
|
// break loop;
|
||||||
default:
|
default:
|
||||||
break loop;
|
break loop;
|
||||||
}
|
}
|
||||||
@ -2604,7 +2604,7 @@ public class JavacParser implements Parser {
|
|||||||
* @param mods The modifiers starting the class declaration
|
* @param mods The modifiers starting the class declaration
|
||||||
* @param dc The documentation comment for the class, or null.
|
* @param dc The documentation comment for the class, or null.
|
||||||
*/
|
*/
|
||||||
JCClassDecl classDeclaration(JCModifiers mods, String dc) {
|
protected JCClassDecl classDeclaration(JCModifiers mods, String dc) {
|
||||||
int pos = token.pos;
|
int pos = token.pos;
|
||||||
accept(CLASS);
|
accept(CLASS);
|
||||||
Name name = ident();
|
Name name = ident();
|
||||||
@ -2633,7 +2633,7 @@ public class JavacParser implements Parser {
|
|||||||
* @param mods The modifiers starting the interface declaration
|
* @param mods The modifiers starting the interface declaration
|
||||||
* @param dc The documentation comment for the interface, or null.
|
* @param dc The documentation comment for the interface, or null.
|
||||||
*/
|
*/
|
||||||
JCClassDecl interfaceDeclaration(JCModifiers mods, String dc) {
|
protected JCClassDecl interfaceDeclaration(JCModifiers mods, String dc) {
|
||||||
int pos = token.pos;
|
int pos = token.pos;
|
||||||
accept(INTERFACE);
|
accept(INTERFACE);
|
||||||
Name name = ident();
|
Name name = ident();
|
||||||
@ -2656,7 +2656,7 @@ public class JavacParser implements Parser {
|
|||||||
* @param mods The modifiers starting the enum declaration
|
* @param mods The modifiers starting the enum declaration
|
||||||
* @param dc The documentation comment for the enum, or null.
|
* @param dc The documentation comment for the enum, or null.
|
||||||
*/
|
*/
|
||||||
JCClassDecl enumDeclaration(JCModifiers mods, String dc) {
|
protected JCClassDecl enumDeclaration(JCModifiers mods, String dc) {
|
||||||
int pos = token.pos;
|
int pos = token.pos;
|
||||||
accept(ENUM);
|
accept(ENUM);
|
||||||
Name name = ident();
|
Name name = ident();
|
||||||
@ -2878,7 +2878,7 @@ public class JavacParser implements Parser {
|
|||||||
* ConstructorDeclaratorRest =
|
* ConstructorDeclaratorRest =
|
||||||
* "(" FormalParameterListOpt ")" [THROWS TypeList] MethodBody
|
* "(" FormalParameterListOpt ")" [THROWS TypeList] MethodBody
|
||||||
*/
|
*/
|
||||||
JCTree methodDeclaratorRest(int pos,
|
protected JCTree methodDeclaratorRest(int pos,
|
||||||
JCModifiers mods,
|
JCModifiers mods,
|
||||||
JCExpression type,
|
JCExpression type,
|
||||||
Name name,
|
Name name,
|
||||||
|
34
langtools/test/tools/javac/T7120266.java
Normal file
34
langtools/test/tools/javac/T7120266.java
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* 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 7120266
|
||||||
|
* @summary javac fails to compile hotspot code
|
||||||
|
* @compile T7120266.java
|
||||||
|
*/
|
||||||
|
|
||||||
|
class T7120266 {
|
||||||
|
void test(int i, int len) { that(i < len, "oopmap"); }
|
||||||
|
void that(boolean b, String s) { };
|
||||||
|
}
|
@ -24,6 +24,7 @@
|
|||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 7115052
|
* @bug 7115052
|
||||||
|
* @ignore 7120266
|
||||||
* @summary Add parser support for method references
|
* @summary Add parser support for method references
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -25,13 +25,14 @@
|
|||||||
* @test
|
* @test
|
||||||
* @bug 7073631
|
* @bug 7073631
|
||||||
* @summary tests error and diagnostics positions
|
* @summary tests error and diagnostics positions
|
||||||
* @author jan.lahoda@oracle.com
|
* @author Jan Lahoda
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import com.sun.source.tree.BinaryTree;
|
import com.sun.source.tree.BinaryTree;
|
||||||
import com.sun.source.tree.BlockTree;
|
import com.sun.source.tree.BlockTree;
|
||||||
import com.sun.source.tree.ClassTree;
|
import com.sun.source.tree.ClassTree;
|
||||||
import com.sun.source.tree.CompilationUnitTree;
|
import com.sun.source.tree.CompilationUnitTree;
|
||||||
|
import com.sun.source.tree.ErroneousTree;
|
||||||
import com.sun.source.tree.ExpressionStatementTree;
|
import com.sun.source.tree.ExpressionStatementTree;
|
||||||
import com.sun.source.tree.ExpressionTree;
|
import com.sun.source.tree.ExpressionTree;
|
||||||
import com.sun.source.tree.MethodInvocationTree;
|
import com.sun.source.tree.MethodInvocationTree;
|
||||||
@ -49,6 +50,7 @@ import com.sun.tools.javac.api.JavacTaskImpl;
|
|||||||
import com.sun.tools.javac.tree.JCTree;
|
import com.sun.tools.javac.tree.JCTree;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -81,6 +83,34 @@ public class JavacParserTest extends TestCase {
|
|||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* converts Windows to Unix style LFs for comparing strings
|
||||||
|
*/
|
||||||
|
private String normalize(String in) {
|
||||||
|
return in.replace(System.getProperty("line.separator"), "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompilationUnitTree getCompilationUnitTree(String code) throws IOException {
|
||||||
|
|
||||||
|
JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
|
||||||
|
null, Arrays.asList(new MyFileObject(code)));
|
||||||
|
CompilationUnitTree cut = ct.parse().iterator().next();
|
||||||
|
return cut;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getErroneousTreeValues(ErroneousTree node) {
|
||||||
|
|
||||||
|
List<String> values = new ArrayList<>();
|
||||||
|
if (node.getErrorTrees() != null) {
|
||||||
|
for (Tree t : node.getErrorTrees()) {
|
||||||
|
values.add(t.toString());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new RuntimeException("ERROR: No Erroneous tree "
|
||||||
|
+ "has been created.");
|
||||||
|
}
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
public void testPositionForSuperConstructorCalls() throws IOException {
|
public void testPositionForSuperConstructorCalls() throws IOException {
|
||||||
assert tool != null;
|
assert tool != null;
|
||||||
@ -97,22 +127,28 @@ public class JavacParserTest extends TestCase {
|
|||||||
ExpressionStatementTree es =
|
ExpressionStatementTree es =
|
||||||
(ExpressionStatementTree) method.getBody().getStatements().get(0);
|
(ExpressionStatementTree) method.getBody().getStatements().get(0);
|
||||||
|
|
||||||
|
final int esStartPos = code.indexOf(es.toString());
|
||||||
|
final int esEndPos = esStartPos + es.toString().length();
|
||||||
assertEquals("testPositionForSuperConstructorCalls",
|
assertEquals("testPositionForSuperConstructorCalls",
|
||||||
72 - 24, pos.getStartPosition(cut, es));
|
esStartPos, pos.getStartPosition(cut, es));
|
||||||
assertEquals("testPositionForSuperConstructorCalls",
|
assertEquals("testPositionForSuperConstructorCalls",
|
||||||
80 - 24, pos.getEndPosition(cut, es));
|
esEndPos, pos.getEndPosition(cut, es));
|
||||||
|
|
||||||
MethodInvocationTree mit = (MethodInvocationTree) es.getExpression();
|
MethodInvocationTree mit = (MethodInvocationTree) es.getExpression();
|
||||||
|
|
||||||
|
final int mitStartPos = code.indexOf(mit.toString());
|
||||||
|
final int mitEndPos = mitStartPos + mit.toString().length();
|
||||||
assertEquals("testPositionForSuperConstructorCalls",
|
assertEquals("testPositionForSuperConstructorCalls",
|
||||||
72 - 24, pos.getStartPosition(cut, mit));
|
mitStartPos, pos.getStartPosition(cut, mit));
|
||||||
assertEquals("testPositionForSuperConstructorCalls",
|
assertEquals("testPositionForSuperConstructorCalls",
|
||||||
79 - 24, pos.getEndPosition(cut, mit));
|
mitEndPos, pos.getEndPosition(cut, mit));
|
||||||
|
|
||||||
|
final int methodStartPos = mitStartPos;
|
||||||
|
final int methodEndPos = methodStartPos + mit.getMethodSelect().toString().length();
|
||||||
assertEquals("testPositionForSuperConstructorCalls",
|
assertEquals("testPositionForSuperConstructorCalls",
|
||||||
72 - 24, pos.getStartPosition(cut, mit.getMethodSelect()));
|
methodStartPos, pos.getStartPosition(cut, mit.getMethodSelect()));
|
||||||
assertEquals("testPositionForSuperConstructorCalls",
|
assertEquals("testPositionForSuperConstructorCalls",
|
||||||
77 - 24, pos.getEndPosition(cut, mit.getMethodSelect()));
|
methodEndPos, pos.getEndPosition(cut, mit.getMethodSelect()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,24 +194,21 @@ public class JavacParserTest extends TestCase {
|
|||||||
|
|
||||||
public void testPreferredPositionForBinaryOp() throws IOException {
|
public void testPreferredPositionForBinaryOp() throws IOException {
|
||||||
|
|
||||||
String code = "package test; public class Test {" +
|
String code = "package test; public class Test {"
|
||||||
"private void test() {" +
|
+ "private void test() {"
|
||||||
"Object o = null; boolean b = o != null && o instanceof String;" +
|
+ "Object o = null; boolean b = o != null && o instanceof String;"
|
||||||
"} private Test() {}}";
|
+ "} private Test() {}}";
|
||||||
|
|
||||||
JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
|
|
||||||
null, Arrays.asList(new MyFileObject(code)));
|
|
||||||
CompilationUnitTree cut = ct.parse().iterator().next();
|
|
||||||
|
|
||||||
|
CompilationUnitTree cut = getCompilationUnitTree(code);
|
||||||
ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
|
ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
|
||||||
MethodTree method = (MethodTree) clazz.getMembers().get(0);
|
MethodTree method = (MethodTree) clazz.getMembers().get(0);
|
||||||
VariableTree condSt = (VariableTree) method.getBody().getStatements().get(1);
|
VariableTree condSt = (VariableTree) method.getBody().getStatements().get(1);
|
||||||
BinaryTree cond = (BinaryTree) condSt.getInitializer();
|
BinaryTree cond = (BinaryTree) condSt.getInitializer();
|
||||||
|
|
||||||
JCTree condJC = (JCTree) cond;
|
JCTree condJC = (JCTree) cond;
|
||||||
|
int condStartPos = code.indexOf("&&");
|
||||||
assertEquals("testNewClassWithEnclosing",
|
assertEquals("testPreferredPositionForBinaryOp",
|
||||||
117 - 24, condJC.pos);
|
condStartPos, condJC.pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPositionBrokenSource126732a() throws IOException {
|
public void testPositionBrokenSource126732a() throws IOException {
|
||||||
@ -599,9 +632,7 @@ public class JavacParserTest extends TestCase {
|
|||||||
final String code = "package t; class Test { " +
|
final String code = "package t; class Test { " +
|
||||||
"{ try (java.io.InputStream in = null) { } } }";
|
"{ try (java.io.InputStream in = null) { } } }";
|
||||||
|
|
||||||
JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
|
CompilationUnitTree cut = getCompilationUnitTree(code);
|
||||||
null, Arrays.asList(new MyFileObject(code)));
|
|
||||||
CompilationUnitTree cut = ct.parse().iterator().next();
|
|
||||||
|
|
||||||
new TreeScanner<Void, Void>() {
|
new TreeScanner<Void, Void>() {
|
||||||
@Override
|
@Override
|
||||||
@ -622,9 +653,7 @@ public class JavacParserTest extends TestCase {
|
|||||||
final String code = "package t; class Test { " +
|
final String code = "package t; class Test { " +
|
||||||
"{ java.io.InputStream in = null; } }";
|
"{ java.io.InputStream in = null; } }";
|
||||||
|
|
||||||
JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
|
CompilationUnitTree cut = getCompilationUnitTree(code);
|
||||||
null, Arrays.asList(new MyFileObject(code)));
|
|
||||||
CompilationUnitTree cut = ct.parse().iterator().next();
|
|
||||||
|
|
||||||
new TreeScanner<Void, Void>() {
|
new TreeScanner<Void, Void>() {
|
||||||
|
|
||||||
@ -640,6 +669,138 @@ public class JavacParserTest extends TestCase {
|
|||||||
}.scan(cut, null);
|
}.scan(cut, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// expected erroneous tree: int x = y;(ERROR);
|
||||||
|
public void testOperatorMissingError() throws IOException {
|
||||||
|
|
||||||
|
String code = "package test; public class ErrorTest { "
|
||||||
|
+ "void method() { int x = y z } }";
|
||||||
|
CompilationUnitTree cut = getCompilationUnitTree(code);
|
||||||
|
final List<String> values = new ArrayList<>();
|
||||||
|
final List<String> expectedValues =
|
||||||
|
new ArrayList<>(Arrays.asList("[z]"));
|
||||||
|
|
||||||
|
new TreeScanner<Void, Void>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Void visitErroneous(ErroneousTree node, Void p) {
|
||||||
|
|
||||||
|
values.add(getErroneousTreeValues(node).toString());
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
}.scan(cut, null);
|
||||||
|
|
||||||
|
assertEquals("testSwitchError: The Erroneous tree "
|
||||||
|
+ "error values: " + values
|
||||||
|
+ " do not match expected error values: "
|
||||||
|
+ expectedValues, values, expectedValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
//expected erroneous tree: String s = (ERROR);
|
||||||
|
public void testMissingParenthesisError() throws IOException {
|
||||||
|
|
||||||
|
String code = "package test; public class ErrorTest { "
|
||||||
|
+ "void f() {String s = new String; } }";
|
||||||
|
CompilationUnitTree cut = getCompilationUnitTree(code);
|
||||||
|
final List<String> values = new ArrayList<>();
|
||||||
|
final List<String> expectedValues =
|
||||||
|
new ArrayList<>(Arrays.asList("[new String()]"));
|
||||||
|
|
||||||
|
new TreeScanner<Void, Void>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Void visitErroneous(ErroneousTree node, Void p) {
|
||||||
|
|
||||||
|
values.add(getErroneousTreeValues(node).toString());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}.scan(cut, null);
|
||||||
|
|
||||||
|
assertEquals("testSwitchError: The Erroneous tree "
|
||||||
|
+ "error values: " + values
|
||||||
|
+ " do not match expected error values: "
|
||||||
|
+ expectedValues, values, expectedValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
//expected erroneous tree: package test; (ERROR)(ERROR)
|
||||||
|
public void testMissingClassError() throws IOException {
|
||||||
|
|
||||||
|
String code = "package Test; clas ErrorTest { "
|
||||||
|
+ "void f() {String s = new String(); } }";
|
||||||
|
CompilationUnitTree cut = getCompilationUnitTree(code);
|
||||||
|
final List<String> values = new ArrayList<>();
|
||||||
|
final List<String> expectedValues =
|
||||||
|
new ArrayList<>(Arrays.asList("[, clas]", "[]"));
|
||||||
|
|
||||||
|
new TreeScanner<Void, Void>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Void visitErroneous(ErroneousTree node, Void p) {
|
||||||
|
|
||||||
|
values.add(getErroneousTreeValues(node).toString());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}.scan(cut, null);
|
||||||
|
|
||||||
|
assertEquals("testSwitchError: The Erroneous tree "
|
||||||
|
+ "error values: " + values
|
||||||
|
+ " do not match expected error values: "
|
||||||
|
+ expectedValues, values, expectedValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
//expected erroneous tree: void m1(int i) {(ERROR);{(ERROR);}
|
||||||
|
public void testSwitchError() throws IOException {
|
||||||
|
|
||||||
|
String code = "package test; public class ErrorTest { "
|
||||||
|
+ "int numDays; void m1(int i) { switchh {i} { case 1: "
|
||||||
|
+ "numDays = 31; break; } } }";
|
||||||
|
CompilationUnitTree cut = getCompilationUnitTree(code);
|
||||||
|
final List<String> values = new ArrayList<>();
|
||||||
|
final List<String> expectedValues =
|
||||||
|
new ArrayList<>(Arrays.asList("[switchh]", "[i]"));
|
||||||
|
|
||||||
|
new TreeScanner<Void, Void>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Void visitErroneous(ErroneousTree node, Void p) {
|
||||||
|
|
||||||
|
values.add(getErroneousTreeValues(node).toString());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}.scan(cut, null);
|
||||||
|
|
||||||
|
assertEquals("testSwitchError: The Erroneous tree "
|
||||||
|
+ "error values: " + values
|
||||||
|
+ " do not match expected error values: "
|
||||||
|
+ expectedValues, values, expectedValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
//expected erroneous tree: class ErrorTest {(ERROR)
|
||||||
|
public void testMethodError() throws IOException {
|
||||||
|
|
||||||
|
String code = "package Test; class ErrorTest { "
|
||||||
|
+ "static final void f) {String s = new String(); } }";
|
||||||
|
CompilationUnitTree cut = getCompilationUnitTree(code);
|
||||||
|
final List<String> values = new ArrayList<>();
|
||||||
|
final List<String> expectedValues =
|
||||||
|
new ArrayList<>(Arrays.asList("[\nstatic final void f();]"));
|
||||||
|
|
||||||
|
new TreeScanner<Void, Void>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Void visitErroneous(ErroneousTree node, Void p) {
|
||||||
|
|
||||||
|
values.add(normalize(getErroneousTreeValues(node).toString()));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}.scan(cut, null);
|
||||||
|
|
||||||
|
assertEquals("testMethodError: The Erroneous tree "
|
||||||
|
+ "error value: " + values
|
||||||
|
+ " does not match expected error values: "
|
||||||
|
+ expectedValues, values, expectedValues);
|
||||||
|
}
|
||||||
|
|
||||||
void testsNotWorking() throws IOException {
|
void testsNotWorking() throws IOException {
|
||||||
|
|
||||||
// Fails with nb-javac, needs further investigation
|
// Fails with nb-javac, needs further investigation
|
||||||
@ -661,7 +822,13 @@ public class JavacParserTest extends TestCase {
|
|||||||
testStartPositionForMethodWithoutModifiers();
|
testStartPositionForMethodWithoutModifiers();
|
||||||
testVarPos();
|
testVarPos();
|
||||||
testVariableInIfThen3();
|
testVariableInIfThen3();
|
||||||
|
testMissingExponent();
|
||||||
testTryResourcePos();
|
testTryResourcePos();
|
||||||
|
testOperatorMissingError();
|
||||||
|
testMissingParenthesisError();
|
||||||
|
testMissingClassError();
|
||||||
|
testSwitchError();
|
||||||
|
testMethodError();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String... args) throws IOException {
|
public static void main(String... args) throws IOException {
|
Loading…
x
Reference in New Issue
Block a user