This commit is contained in:
Clément Fournier
2022-03-07 19:59:50 +01:00
parent dee330293f
commit 3b8d7a32a7
8 changed files with 119 additions and 104 deletions

View File

@@ -86,7 +86,7 @@ public class CPPTokenizer extends JavaCCTokenizer {
@Override
protected CharStream makeCharStream(Reader sourceCode) {
protected CharStream makeCharStream(Reader sourceCode) throws IOException {
return CppCharStream.newCppCharStream(sourceCode);
}

View File

@@ -8,9 +8,9 @@ import java.io.IOException;
import java.io.Reader;
import java.util.regex.Pattern;
import org.apache.commons.io.IOUtils;
import org.checkerframework.checker.nullness.qual.Nullable;
import net.sourceforge.pmd.lang.ast.impl.javacc.CharStreamFactory;
import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccTokenDocument;
import net.sourceforge.pmd.lang.ast.impl.javacc.SimpleCharStream;
import net.sourceforge.pmd.lang.document.CpdCompat;
@@ -67,8 +67,8 @@ public class CppCharStream extends SimpleCharStream {
return CONTINUATION.matcher(image).replaceAll("");
}
public static CppCharStream newCppCharStream(Reader dstream) {
String source = CharStreamFactory.toString(dstream);
public static CppCharStream newCppCharStream(Reader dstream) throws IOException {
String source = IOUtils.toString(dstream);
JavaccTokenDocument document = new JavaccTokenDocument(TextDocument.readOnlyString(source, CpdCompat.dummyVersion())) {
@Override
protected @Nullable String describeKindImpl(int kind) {