[java] Fix compile errors
This commit is contained in:
@ -294,7 +294,7 @@ class JavaParserImpl {
|
||||
private boolean inSwitchExprBlock = false;
|
||||
|
||||
private boolean isYieldStart() {
|
||||
return inSwitchExprBlock && isJava13PreviewOr14()
|
||||
return inSwitchExprBlock
|
||||
&& isKeyword("yield")
|
||||
&& mayStartExprAfterYield(2);
|
||||
}
|
||||
|
@ -87,12 +87,6 @@ public class ASTCompilationUnit extends AbstractJavaTypeNode implements RootNode
|
||||
return classTypeResolver;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ASTCompilationUnit getRoot() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@InternalApi
|
||||
@Deprecated
|
||||
public void setClassTypeResolver(ClassTypeResolver classTypeResolver) {
|
||||
|
@ -44,14 +44,6 @@ public abstract class AbstractJavaNode extends AbstractJjtreeNode<JavaNode> impl
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ASTCompilationUnit getRoot() {
|
||||
if (root == null) {
|
||||
root = getParent().getRoot();
|
||||
}
|
||||
return root;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Scope getScope() {
|
||||
if (scope == null) {
|
||||
|
@ -46,7 +46,6 @@ public interface JavaNode extends ScopedNode, TextAvailableNode {
|
||||
@Deprecated
|
||||
Object childrenAccept(JavaParserVisitor visitor, Object data);
|
||||
|
||||
ASTCompilationUnit getRoot();
|
||||
|
||||
/**
|
||||
* Calls back the visitor's visit method corresponding to the runtime type of this Node.
|
||||
|
@ -8,6 +8,7 @@ package net.sourceforge.pmd.lang.java.ast;
|
||||
import static org.hamcrest.CoreMatchers.instanceOf;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Assert;
|
||||
@ -94,15 +95,16 @@ public class Java14Test {
|
||||
|
||||
private void checkYieldStatements(JavaParsingHelper parser) {
|
||||
ASTCompilationUnit compilationUnit = parser.parseResource("YieldStatements.java");
|
||||
List<JavaNode> stmts = compilationUnit.<JavaNode>findDescendantsOfType(ASTBlockStatement.class);
|
||||
List<ASTBlockStatement> blockStmts = compilationUnit.findDescendantsOfType(ASTBlockStatement.class);
|
||||
List<JavaNode> stmts = new ArrayList<>();
|
||||
// fetch the interesting node, on the java-grammar branch this is not needed
|
||||
for (int i = 0; i < stmts.size(); i++) {
|
||||
JavaNode child = stmts.get(i).getChild(0);
|
||||
for (int i = 0; i < blockStmts.size(); i++) {
|
||||
JavaNode child = blockStmts.get(i).getChild(0);
|
||||
|
||||
if (child instanceof ASTStatement) {
|
||||
stmts.set(i, child.getChild(0));
|
||||
stmts.add(child.getChild(0));
|
||||
} else {
|
||||
stmts.set(i, child);
|
||||
stmts.add(child);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user