Merge branch '7.0.x' into java-grammar

This commit is contained in:
Clément Fournier
2020-01-10 21:25:00 +01:00
57 changed files with 193 additions and 170 deletions

View File

@ -4,6 +4,8 @@
package net.sourceforge.pmd.lang.apex.ast;
import net.sourceforge.pmd.lang.LanguageVersion;
import net.sourceforge.pmd.lang.LanguageVersionHandler;
import net.sourceforge.pmd.lang.apex.ApexLanguageModule;
import net.sourceforge.pmd.lang.ast.RootNode;
import net.sourceforge.pmd.lang.ast.test.BaseParsingHelper;
@ -22,4 +24,9 @@ public class ApexParsingHelper extends BaseParsingHelper<ApexParsingHelper, Root
return new ApexParsingHelper(params);
}
@Override
protected void postProcessing(LanguageVersionHandler handler, LanguageVersion lversion, RootNode rootNode) {
super.postProcessing(handler, lversion, rootNode);
handler.getMultifileFacade().start(rootNode);
}
}

View File

@ -9,8 +9,8 @@
<property name="base-ast-package" value="net.sourceforge.pmd.lang.ast" />
<property name="base-ast-package.dir" value="${target}/net/sourceforge/pmd/lang/ast" />
<property name="target-package" value="${base-ast-package}.impl.javacc" />
<property name="target-package.dir" value="${base-ast-package.dir}/impl/javacc" />
<property name="target-package" value="${base-ast-package}" />
<property name="target-package.dir" value="${base-ast-package.dir}" />
<target name="alljavacc"
@ -114,7 +114,7 @@
<replace file="${tmp-package.dir}/TokenMgrError.java">
<replacetoken><![CDATA["Lexical error at line "]]></replacetoken>
<replacevalue>&quot;Lexical error in file &quot; + net.sourceforge.pmd.lang.ast.impl.javacc.AbstractTokenManager.getFileName() + &quot; at line &quot;</replacevalue>
<replacevalue>&quot;Lexical error in file &quot; + net.sourceforge.pmd.lang.ast.AbstractTokenManager.getFileName() + &quot; at line &quot;</replacevalue>
</replace>
<move overwrite="true"

View File

@ -2,7 +2,7 @@
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.ast.impl.javacc;
package net.sourceforge.pmd.lang.ast;
import java.util.HashMap;
import java.util.Map;

View File

@ -2,7 +2,7 @@
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.ast.impl.javacc;
package net.sourceforge.pmd.lang.ast;
import java.io.IOException;
import java.io.Reader;
@ -11,6 +11,7 @@ import java.io.StringReader;
import org.apache.commons.io.IOUtils;
import net.sourceforge.pmd.lang.ast.impl.TokenDocument;
import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken;
/**
* This stream buffers the whole file in memory before parsing,
@ -18,6 +19,8 @@ import net.sourceforge.pmd.lang.ast.impl.TokenDocument;
* The buffer is assumed to be composed of only ASCII characters,
* and the stream unescapes Unicode escapes. The {@link #getTokenDocument() token document}
* stores the original file with escapes and all.
*
* TODO this is to be moved into the impl.javacc subpackage
*/
public class JavaCharStream extends JavaCharStreamBase {

View File

@ -0,0 +1,68 @@
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.ast.impl.javacc;
import java.io.IOException;
import java.io.Reader;
import java.util.function.Function;
import org.apache.commons.io.IOUtils;
import net.sourceforge.pmd.lang.ast.CharStream;
import net.sourceforge.pmd.lang.ast.JavaCharStream;
import net.sourceforge.pmd.lang.ast.SimpleCharStream;
import net.sourceforge.pmd.lang.ast.impl.TokenDocument;
@SuppressWarnings("PMD.UnusedFormalParameter") // for later
public final class CharStreamFactory {
private CharStreamFactory() {
// util class
}
/**
* A char stream that doesn't perform any escape translation.
*/
public static CharStream simpleCharStream(Reader input) {
return simpleCharStream(input, TokenDocument::new);
}
/**
* A char stream that doesn't perform any escape translation.
*/
public static CharStream simpleCharStream(Reader input, Function<? super String, ? extends TokenDocument> documentMaker) {
return new SimpleCharStream(input);
}
/**
* A char stream that translates java unicode sequences.
*/
public static CharStream javaCharStream(Reader input) {
return javaCharStream(input, TokenDocument::new);
}
/**
* A char stream that translates java unicode sequences.
*/
public static CharStream javaCharStream(Reader input, Function<? super String, ? extends TokenDocument> documentMaker) {
String source = toString(input);
return new JavaCharStream(source);
}
/**
* @deprecated This shouldn't be used. IOExceptions should be handled properly,
* ie it should be expected that creating a parse may throw an IOException,
* in both CPD and PMD
*/
@Deprecated
public static String toString(Reader dstream) {
try (Reader r = dstream) {
return IOUtils.toString(r);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}

View File

@ -32,7 +32,7 @@ options {
PARSER_BEGIN(CppParser)
package net.sourceforge.pmd.lang.cpp.ast;
import net.sourceforge.pmd.lang.ast.impl.javacc.CharStream;
import net.sourceforge.pmd.lang.ast.CharStream;
import net.sourceforge.pmd.lang.ast.TokenMgrError;
public final class CppParser {

View File

@ -36,7 +36,7 @@
javacchome="${javacc-home.path}" />
<replace file="${target}/net/sourceforge/pmd/lang/cpp/ast/CppParserTokenManager.java"
token="class CppParserTokenManager"
value="class CppParserTokenManager extends net.sourceforge.pmd.lang.ast.impl.javacc.AbstractTokenManager" />
value="class CppParserTokenManager extends net.sourceforge.pmd.lang.ast.AbstractTokenManager" />
<delete file="${target}/net/sourceforge/pmd/lang/cpp/ast/CharStream.java" />
<delete file="${target}/net/sourceforge/pmd/lang/cpp/ast/ParseException.java" />
<delete file="${target}/net/sourceforge/pmd/lang/cpp/ast/TokenMgrError.java" />

View File

@ -8,7 +8,7 @@ import java.io.IOException;
import java.io.Reader;
import java.util.regex.Pattern;
import net.sourceforge.pmd.lang.ast.impl.javacc.SimpleCharStream;
import net.sourceforge.pmd.lang.ast.SimpleCharStream;
/**
* A SimpleCharStream, that supports the continuation of lines via backslash+newline,

View File

@ -250,7 +250,7 @@ package net.sourceforge.pmd.lang.java.ast;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import net.sourceforge.pmd.lang.ast.impl.javacc.CharStream;
import net.sourceforge.pmd.lang.ast.CharStream;
import net.sourceforge.pmd.lang.ast.GenericToken;
import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken;
import net.sourceforge.pmd.lang.ast.TokenMgrError;
@ -394,7 +394,7 @@ TOKEN_MGR_DECLS :
SPECIAL_TOKEN :
{
// those are private, just for code organisation
// those are private, just for code organisation
< #HORIZONTAL_WHITESPACE: [" ", "\t", "\f"] >
| < #LINE_TERMINATOR: "\n" | "\r" | "\r\n" >
// this one is pushed, notice the (..)+ construct, to avoid
@ -1551,7 +1551,7 @@ ASTCompilationUnit CompilationUnit() :
<EOF>
{
jjtThis.setComments(token_source.comments);
jjtThis.setTokenDocument(((net.sourceforge.pmd.lang.ast.impl.javacc.JavaCharStream) token_source.input_stream).getTokenDocument());
jjtThis.setTokenDocument(((net.sourceforge.pmd.lang.ast.JavaCharStream) token_source.input_stream).getTokenDocument());
return jjtThis;
}
}
@ -3003,15 +3003,15 @@ void AssertStatement() :
void RUNSIGNEDSHIFT() #void:
{}
{
LOOKAHEAD({ JavaTokenFactory.getRealKind(getToken(1)) == RUNSIGNEDSHIFT})
">" ">" ">"
LOOKAHEAD({ JavaTokenFactory.getRealKind(getToken(1)) == RUNSIGNEDSHIFT})
">" ">" ">"
}
void RSIGNEDSHIFT() #void:
{}
{
LOOKAHEAD({ JavaTokenFactory.getRealKind(getToken(1)) == RSIGNEDSHIFT})
">" ">"
LOOKAHEAD({ JavaTokenFactory.getRealKind(getToken(1)) == RSIGNEDSHIFT})
">" ">"
}
/* Annotation syntax follows. */

View File

@ -15,6 +15,10 @@
<property name="generic-sideeffect-visitor-interface-file"
value="${target-package-dir}/${generic-sideeffect-visitor-interface-name}.java" />
<property name="ast-core-package" value="net.sourceforge.pmd.lang.ast" />
<property name="ast-impl-package" value="${ast-core-package}.impl.javacc" />
<!-- TARGETS -->
<target name="alljavacc"
@ -123,25 +127,18 @@
</replacevalue>
</replace>
<replace token="new Token()" value="net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken.undefined()">
<fileset dir="${target-package-dir}"/>
<replace token="new Token()" value="${ast-impl-package}.JavaccToken.undefined()">
<fileset dir="${target-package-dir}" />
</replace>
<replace token=" Token " value=" net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken ">
<fileset dir="${target-package-dir}"/>
</replace>
<!-- Map Javacc names to our names -->
<replace token="(Token " value="(net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken ">
<fileset dir="${target-package-dir}"/>
</replace>
<replace token=" Token(" value=" net.sourceforge.pmd.lang.ast.impl.JavaccToken(">
<fileset dir="${target-package-dir}"/>
</replace>
<replace token=";Token " value=";net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken ">
<fileset dir="${target-package-dir}"/>
</replace>
<replaceregexp flags="g">
<regexp pattern="\bToken\b" />
<substitution expression="${ast-impl-package}.JavaccToken" />
<fileset dir="${target-package-dir}" />
</replaceregexp>
<replace file="${target-package-dir}/JavaParserTokenManager.java">
@ -177,8 +174,8 @@
<replace file="${target-package-dir}/JavaParserTokenManager.java"
token="public class JavaParserTokenManager"
value="import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken; public class JavaParserTokenManager extends net.sourceforge.pmd.lang.ast.impl.javacc.AbstractTokenManager" />
token="class JavaParserTokenManager"
value="class JavaParserTokenManager extends net.sourceforge.pmd.lang.ast.AbstractTokenManager" />
<replace file="${target-package-dir}/JavaParser.java"
token="throw new Error"
value="throw new RuntimeException" />
@ -193,8 +190,6 @@
<!-- We perform most changes like adding default methods, etc on this one -->
<!-- Changes are then copied on other visitors -->
<replace file="${base-visitor-interface-file}">
<replacefilter token="public interface" value="
public interface" />
<replacefilter token="JavaParserVisitor" value="${base-visitor-interface-name}" />
<replacefilter token="SimpleNode" value="JavaNode" />
<!-- Default methods -->

View File

@ -7,7 +7,7 @@ package net.sourceforge.pmd.lang.java;
import java.io.Reader;
import net.sourceforge.pmd.lang.TokenManager;
import net.sourceforge.pmd.lang.ast.impl.javacc.JavaCharStream;
import net.sourceforge.pmd.lang.ast.impl.javacc.CharStreamFactory;
import net.sourceforge.pmd.lang.java.ast.JavaParserTokenManager;
/**
@ -17,7 +17,7 @@ public class JavaTokenManager implements TokenManager {
private final JavaParserTokenManager tokenManager;
public JavaTokenManager(Reader source) {
tokenManager = new JavaParserTokenManager(new JavaCharStream(source));
tokenManager = new JavaParserTokenManager(CharStreamFactory.javaCharStream(source));
}
@Override

View File

@ -7,10 +7,14 @@ package net.sourceforge.pmd.lang.java.ast;
import org.apache.commons.lang3.ArrayUtils;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.NonNull;
import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.ast.AbstractNode;
import net.sourceforge.pmd.lang.ast.Node;
import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken;
import net.sourceforge.pmd.lang.java.symbols.table.JSymbolTable;
import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken;
import net.sourceforge.pmd.lang.symboltable.Scope;
abstract class AbstractJavaNode extends AbstractNode implements JavaNode {
@ -58,6 +62,7 @@ abstract class AbstractJavaNode extends AbstractNode implements JavaNode {
}
}
@Override
public JavaNode jjtGetParent() {
return (JavaNode) super.jjtGetParent();
@ -105,7 +110,6 @@ abstract class AbstractJavaNode extends AbstractNode implements JavaNode {
return scope;
}
@Override
public CharSequence getText() {
if (text == null) {
@ -295,7 +299,7 @@ abstract class AbstractJavaNode extends AbstractNode implements JavaNode {
}
@Override
public String getXPathNodeName() {
public final String getXPathNodeName() {
return JavaParserTreeConstants.jjtNodeName[id];
}

View File

@ -14,7 +14,7 @@ import org.apache.commons.lang3.StringUtils;
import net.sourceforge.pmd.PMD;
import net.sourceforge.pmd.lang.ast.AbstractNode;
import net.sourceforge.pmd.lang.ast.GenericToken;
import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken;
public abstract class Comment extends AbstractNode {
// single regex, that captures: the start of a multi-line comment (/**|/*), the start of a single line comment (//)
@ -24,10 +24,12 @@ public abstract class Comment extends AbstractNode {
// Same as "\\R" - but \\R is only available with java8+
static final Pattern NEWLINES_PATTERN = Pattern.compile("\\u000D\\u000A|[\\u000A\\u000B\\u000C\\u000D\\u0085\\u2028\\u2029]");
protected Comment(GenericToken t) {
protected Comment(JavaccToken t) {
super(-1);
setImage(t.getImage());
jjtSetFirstToken(t);
jjtSetLastToken(t);
}
@Override
@ -35,6 +37,7 @@ public abstract class Comment extends AbstractNode {
return getImage();
}
/**
* Filters the comment by removing the leading comment marker (like {@code *}) of each line
* as well as the start markers ({@code //}, {@code /*} or {@code /**}

View File

@ -26,16 +26,13 @@ public class DummyJavaNode extends AbstractJavaNode {
super(parser, id);
}
@Override
public Object jjtAccept(JavaParserVisitor visitor, Object data) {
return visitor.visit(this, data);
return data;
}
@Override
public <T> void jjtAccept(SideEffectingVisitor<T> visitor, T data) {
visitor.visit(this, data);
// do nothing
}
}

View File

@ -9,15 +9,15 @@ import java.util.Collection;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.sourceforge.pmd.lang.ast.GenericToken;
import net.sourceforge.pmd.lang.ast.Node;
import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken;
import net.sourceforge.pmd.lang.java.javadoc.JavadocTag;
public class FormalComment extends Comment {
private static final Pattern JAVADOC_TAG = Pattern.compile("@([A-Za-z0-9]+)");
public FormalComment(GenericToken t) {
public FormalComment(JavaccToken t) {
super(t);
findJavadocs();

View File

@ -8,8 +8,8 @@ import java.io.Reader;
import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.ParserOptions;
import net.sourceforge.pmd.lang.ast.impl.javacc.AbstractTokenManager;
import net.sourceforge.pmd.lang.ast.impl.javacc.JavaCharStream;
import net.sourceforge.pmd.lang.ast.AbstractTokenManager;
import net.sourceforge.pmd.lang.ast.impl.javacc.CharStreamFactory;
import net.sourceforge.pmd.lang.java.ast.internal.LanguageLevelChecker;
import net.sourceforge.pmd.lang.java.qname.JavaOperationQualifiedName;
import net.sourceforge.pmd.lang.java.qname.JavaTypeQualifiedName;
@ -69,7 +69,7 @@ public final class InternalApiBridge {
}
public static ASTCompilationUnit parseInternal(String fileName, Reader source, LanguageLevelChecker<?> checker, ParserOptions options) {
JavaParser parser = new JavaParser(new JavaCharStream(source));
JavaParser parser = new JavaParser(CharStreamFactory.javaCharStream(source));
String suppressMarker = options.getSuppressMarker();
if (suppressMarker != null) {
parser.setSuppressMarker(suppressMarker);

View File

@ -5,8 +5,8 @@
package net.sourceforge.pmd.lang.java.ast;
import net.sourceforge.pmd.lang.ast.impl.TokenDocument;
import net.sourceforge.pmd.lang.ast.impl.javacc.CharStream;
import net.sourceforge.pmd.lang.ast.impl.javacc.JavaCharStream;
import net.sourceforge.pmd.lang.ast.CharStream;
import net.sourceforge.pmd.lang.ast.JavaCharStream;
import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken;
/**

View File

@ -4,11 +4,11 @@
package net.sourceforge.pmd.lang.java.ast;
import net.sourceforge.pmd.lang.ast.GenericToken;
import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken;
public class MultiLineComment extends Comment {
public MultiLineComment(GenericToken t) {
public MultiLineComment(JavaccToken t) {
super(t);
}

View File

@ -4,11 +4,11 @@
package net.sourceforge.pmd.lang.java.ast;
import net.sourceforge.pmd.lang.ast.GenericToken;
import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken;
public class SingleLineComment extends Comment {
public SingleLineComment(GenericToken t) {
public SingleLineComment(JavaccToken t) {
super(t);
}

View File

@ -16,6 +16,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import net.sourceforge.pmd.lang.ast.ParseException;
import net.sourceforge.pmd.lang.java.JavaParsingHelper;
import net.sourceforge.pmd.lang.symboltable.NameDeclaration;
import net.sourceforge.pmd.lang.symboltable.NameOccurrence;
@ -24,7 +25,7 @@ public class ParserCornersTest {
private static final String MULTICATCH = "public class Foo { public void bar() { "
+ "try { System.out.println(); } catch (RuntimeException | IOException e) {} } }";
private final JavaParsingHelper java = JavaParsingHelper.JUST_PARSE.withResourceContext(ParserCornersTest.class);
private final JavaParsingHelper java = JavaParsingHelper.WITH_PROCESSING.withResourceContext(ParserCornersTest.class);
private final JavaParsingHelper java8 = java.withDefaultVersion("1.8");
private final JavaParsingHelper java4 = java.withDefaultVersion("1.4");
private final JavaParsingHelper java5 = java.withDefaultVersion("1.5");

View File

@ -10,19 +10,19 @@ import org.junit.Ignore;
import org.junit.Test;
import net.sourceforge.pmd.lang.LanguageRegistry;
import net.sourceforge.pmd.lang.ast.Node;
import net.sourceforge.pmd.lang.dfa.Structure;
import net.sourceforge.pmd.lang.java.JavaLanguageModule;
import net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration;
import net.sourceforge.pmd.lang.java.symboltable.BaseNonParserTest;
@Ignore
public class StructureTest {
public class StructureTest extends BaseNonParserTest {
@Test
public void testAddResultsinDFANodeContainingAddedNode() {
ASTMethodDeclaration n = java.parse("class Foo { void foo() { } }").descendants(ASTMethodDeclaration.class).first();
Structure s = new Structure(LanguageRegistry.getLanguage(JavaLanguageModule.NAME).getDefaultVersion()
.getLanguageVersionHandler().getDataFlowHandler());
Node n = new ASTMethodDeclaration(1);
.getLanguageVersionHandler().getDataFlowHandler());
assertEquals(n, s.createNewNode(n).getNode());
}

View File

@ -15,7 +15,7 @@ options {
PARSER_BEGIN(Ecmascript5Parser)
package net.sourceforge.pmd.lang.ecmascript5.ast;
import net.sourceforge.pmd.lang.ast.impl.javacc.CharStream;
import net.sourceforge.pmd.lang.ast.CharStream;
import net.sourceforge.pmd.lang.ast.TokenMgrError;
public class Ecmascript5Parser {

View File

@ -36,7 +36,7 @@
javacchome="${javacc-home.path}" />
<replace file="${target}/net/sourceforge/pmd/lang/ecmascript5/ast/Ecmascript5ParserTokenManager.java"
token="class Ecmascript5ParserTokenManager"
value="class Ecmascript5ParserTokenManager extends net.sourceforge.pmd.lang.ast.impl.javacc.AbstractTokenManager" />
value="class Ecmascript5ParserTokenManager extends net.sourceforge.pmd.lang.ast.AbstractTokenManager" />
<delete file="${target}/net/sourceforge/pmd/lang/ecmascript5/ast/CharStream.java" />
<delete file="${target}/net/sourceforge/pmd/lang/ecmascript5/ast/ParseException.java" />
<delete file="${target}/net/sourceforge/pmd/lang/ecmascript5/ast/TokenMgrError.java" />

View File

@ -7,7 +7,7 @@ package net.sourceforge.pmd.lang.ecmascript5;
import java.io.Reader;
import net.sourceforge.pmd.lang.TokenManager;
import net.sourceforge.pmd.lang.ast.impl.javacc.SimpleCharStream;
import net.sourceforge.pmd.lang.ast.impl.javacc.CharStreamFactory;
import net.sourceforge.pmd.lang.ecmascript5.ast.Ecmascript5ParserTokenManager;
/**
@ -23,7 +23,7 @@ public class Ecmascript5TokenManager implements TokenManager {
* the source code
*/
public Ecmascript5TokenManager(Reader source) {
tokenManager = new Ecmascript5ParserTokenManager(new SimpleCharStream(source));
tokenManager = new Ecmascript5ParserTokenManager(CharStreamFactory.simpleCharStream(source));
}
@Override

View File

@ -31,7 +31,7 @@ options {
PARSER_BEGIN(JspParser)
package net.sourceforge.pmd.lang.jsp.ast;
import net.sourceforge.pmd.lang.ast.impl.javacc.CharStream;
import net.sourceforge.pmd.lang.ast.CharStream;
import net.sourceforge.pmd.lang.ast.TokenMgrError;
/**

View File

@ -45,7 +45,7 @@
<delete file="${target}/net/sourceforge/pmd/lang/jsp/ast/TokenMgrError.java" />
<replace file="${target}/net/sourceforge/pmd/lang/jsp/ast/JspParserTokenManager.java"
token="class JspParserTokenManager"
value="class JspParserTokenManager extends net.sourceforge.pmd.lang.ast.impl.javacc.AbstractTokenManager" />
value="class JspParserTokenManager extends net.sourceforge.pmd.lang.ast.AbstractTokenManager" />
<replace file="${target}/net/sourceforge/pmd/lang/jsp/ast/JspParser.java"
token="throw new Error"
value="throw new RuntimeException" />

View File

@ -11,8 +11,8 @@ import net.sourceforge.pmd.lang.ParserOptions;
import net.sourceforge.pmd.lang.TokenManager;
import net.sourceforge.pmd.lang.ast.Node;
import net.sourceforge.pmd.lang.ast.ParseException;
import net.sourceforge.pmd.lang.ast.impl.javacc.AbstractTokenManager;
import net.sourceforge.pmd.lang.ast.impl.javacc.SimpleCharStream;
import net.sourceforge.pmd.lang.ast.AbstractTokenManager;
import net.sourceforge.pmd.lang.ast.impl.javacc.CharStreamFactory;
/**
* Adapter for the JspParser.
@ -31,7 +31,7 @@ public class JspParser extends AbstractParser {
@Override
public Node parse(String fileName, Reader source) throws ParseException {
AbstractTokenManager.setFileName(fileName);
return new net.sourceforge.pmd.lang.jsp.ast.JspParser(new SimpleCharStream(source)).CompilationUnit();
return new net.sourceforge.pmd.lang.jsp.ast.JspParser(CharStreamFactory.simpleCharStream(source)).CompilationUnit();
}
}

View File

@ -7,7 +7,7 @@ package net.sourceforge.pmd.lang.jsp;
import java.io.Reader;
import net.sourceforge.pmd.lang.TokenManager;
import net.sourceforge.pmd.lang.ast.impl.javacc.JavaCharStream;
import net.sourceforge.pmd.lang.ast.impl.javacc.CharStreamFactory;
import net.sourceforge.pmd.lang.jsp.ast.JspParserTokenManager;
/**
@ -17,7 +17,7 @@ public class JspTokenManager implements TokenManager {
private final JspParserTokenManager tokenManager;
public JspTokenManager(Reader source) {
tokenManager = new JspParserTokenManager(new JavaCharStream(source));
tokenManager = new JspParserTokenManager(CharStreamFactory.javaCharStream(source));
}
@Override

View File

@ -128,7 +128,7 @@ abstract class BaseParsingHelper<Self : BaseParsingHelper<Self, T>, T : RootNode
/**
* Called only if [Params.doProcess] is true.
*/
protected open fun postProcessing(handler: LanguageVersionHandler, lversion: LanguageVersion, rootNode: T?) {
protected open fun postProcessing(handler: LanguageVersionHandler, lversion: LanguageVersion, rootNode: T) {
val astAnalysisContext = object : AstAnalysisContext {
override fun getTypeResolutionClassLoader(): ClassLoader = javaClass.classLoader

View File

@ -21,7 +21,7 @@ options {
PARSER_BEGIN(MatlabParser)
package net.sourceforge.pmd.lang.matlab.ast;
import net.sourceforge.pmd.lang.ast.impl.javacc.CharStream;
import net.sourceforge.pmd.lang.ast.CharStream;
import net.sourceforge.pmd.lang.ast.TokenMgrError;
public class MatlabParser {

Some files were not shown because too many files have changed in this diff Show More