forked from phoedos/pmd
parent
2e7263af69
commit
55d91791c3
@ -159,6 +159,11 @@ The following previously deprecated classes have been removed:
|
|||||||
If the current version is needed, then `Node.getTextDocument().getLanguageVersion()` can be used. This
|
If the current version is needed, then `Node.getTextDocument().getLanguageVersion()` can be used. This
|
||||||
is the version that has been selected via CLI `--use-version` parameter.
|
is the version that has been selected via CLI `--use-version` parameter.
|
||||||
|
|
||||||
|
**Renamed classes**
|
||||||
|
|
||||||
|
* pmd-core
|
||||||
|
* {%jdoc_old core::lang.ast.TokenMgrError %} has been renamed to {% jdoc core::lang.ast.LexException %}
|
||||||
|
|
||||||
#### External Contributions
|
#### External Contributions
|
||||||
* [#4640](https://github.com/pmd/pmd/pull/4640): \[cli] Launch script fails if run via "bash pmd" - [Shai Bennathan](https://github.com/shai-bennathan) (@shai-bennathan)
|
* [#4640](https://github.com/pmd/pmd/pull/4640): \[cli] Launch script fails if run via "bash pmd" - [Shai Bennathan](https://github.com/shai-bennathan) (@shai-bennathan)
|
||||||
* [#4673](https://github.com/pmd/pmd/pull/4673): \[javascript] CPD: Added support for decorator notation - [Wener](https://github.com/wener-tiobe) (@wener-tiobe)
|
* [#4673](https://github.com/pmd/pmd/pull/4673): \[javascript] CPD: Added support for decorator notation - [Wener](https://github.com/wener-tiobe) (@wener-tiobe)
|
||||||
|
@ -280,6 +280,13 @@
|
|||||||
<file name="${tokenmgr-file}" />
|
<file name="${tokenmgr-file}" />
|
||||||
</replaceregexp>
|
</replaceregexp>
|
||||||
|
|
||||||
|
<!-- Use own LexException instead of JavaCC's TokenMgrError -->
|
||||||
|
<replaceregexp>
|
||||||
|
<regexp pattern='throw new TokenMgrError\(EOFSeen' />
|
||||||
|
<substitution expression='throw new net.sourceforge.pmd.lang.ast.LexException(EOFSeen' />
|
||||||
|
<file name="${tokenmgr-file}" />
|
||||||
|
</replaceregexp>
|
||||||
|
|
||||||
<!-- Useless argument, also replace lex state ID with its name -->
|
<!-- Useless argument, also replace lex state ID with its name -->
|
||||||
<replaceregexp>
|
<replaceregexp>
|
||||||
<regexp pattern='curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR\)' />
|
<regexp pattern='curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR\)' />
|
||||||
|
@ -23,7 +23,7 @@ import net.sourceforge.pmd.internal.util.IOUtil;
|
|||||||
import net.sourceforge.pmd.lang.Language;
|
import net.sourceforge.pmd.lang.Language;
|
||||||
import net.sourceforge.pmd.lang.LanguagePropertyBundle;
|
import net.sourceforge.pmd.lang.LanguagePropertyBundle;
|
||||||
import net.sourceforge.pmd.lang.ast.FileAnalysisException;
|
import net.sourceforge.pmd.lang.ast.FileAnalysisException;
|
||||||
import net.sourceforge.pmd.lang.ast.TokenMgrError;
|
import net.sourceforge.pmd.lang.ast.LexException;
|
||||||
import net.sourceforge.pmd.lang.document.FileCollector;
|
import net.sourceforge.pmd.lang.document.FileCollector;
|
||||||
import net.sourceforge.pmd.lang.document.FileId;
|
import net.sourceforge.pmd.lang.document.FileId;
|
||||||
import net.sourceforge.pmd.lang.document.TextDocument;
|
import net.sourceforge.pmd.lang.document.TextDocument;
|
||||||
@ -137,7 +137,7 @@ public final class CpdAnalysis implements AutoCloseable {
|
|||||||
this.listener = cpdListener;
|
this.listener = cpdListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int doTokenize(TextDocument document, Tokenizer tokenizer, Tokens tokens) throws IOException, TokenMgrError {
|
private int doTokenize(TextDocument document, Tokenizer tokenizer, Tokens tokens) throws IOException, LexException {
|
||||||
LOGGER.trace("Tokenizing {}", document.getFileId().getAbsolutePath());
|
LOGGER.trace("Tokenizing {}", document.getFileId().getAbsolutePath());
|
||||||
int lastTokenSize = tokens.size();
|
int lastTokenSize = tokens.size();
|
||||||
Tokenizer.tokenize(tokenizer, document, tokens);
|
Tokenizer.tokenize(tokenizer, document, tokens);
|
||||||
@ -170,7 +170,7 @@ public final class CpdAnalysis implements AutoCloseable {
|
|||||||
int newTokens = doTokenize(textDocument, tokenizers.get(textFile.getLanguageVersion().getLanguage()), tokens);
|
int newTokens = doTokenize(textDocument, tokenizers.get(textFile.getLanguageVersion().getLanguage()), tokens);
|
||||||
numberOfTokensPerFile.put(textDocument.getFileId(), newTokens);
|
numberOfTokensPerFile.put(textDocument.getFileId(), newTokens);
|
||||||
listener.addedFile(1);
|
listener.addedFile(1);
|
||||||
} catch (TokenMgrError | IOException e) {
|
} catch (LexException | IOException e) {
|
||||||
if (e instanceof FileAnalysisException) { // NOPMD
|
if (e instanceof FileAnalysisException) { // NOPMD
|
||||||
((FileAnalysisException) e).setFileId(textFile.getFileId());
|
((FileAnalysisException) e).setFileId(textFile.getFileId());
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ package net.sourceforge.pmd.cpd;
|
|||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
import net.sourceforge.pmd.lang.ast.TokenMgrError;
|
import net.sourceforge.pmd.lang.ast.LexException;
|
||||||
import net.sourceforge.pmd.lang.document.FileLocation;
|
import net.sourceforge.pmd.lang.document.FileLocation;
|
||||||
import net.sourceforge.pmd.lang.document.TextDocument;
|
import net.sourceforge.pmd.lang.document.TextDocument;
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ public interface TokenFactory extends AutoCloseable {
|
|||||||
recordToken(image, location.getStartLine(), location.getStartColumn(), location.getEndLine(), location.getEndColumn());
|
recordToken(image, location.getStartLine(), location.getStartColumn(), location.getEndLine(), location.getEndColumn());
|
||||||
}
|
}
|
||||||
|
|
||||||
TokenMgrError makeLexException(int line, int column, String message, @Nullable Throwable cause);
|
LexException makeLexException(int line, int column, String message, @Nullable Throwable cause);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the image of an existing token entry.
|
* Sets the image of an existing token entry.
|
||||||
|
@ -14,7 +14,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
import net.sourceforge.pmd.annotation.InternalApi;
|
import net.sourceforge.pmd.annotation.InternalApi;
|
||||||
import net.sourceforge.pmd.lang.ast.TokenMgrError;
|
import net.sourceforge.pmd.lang.ast.LexException;
|
||||||
import net.sourceforge.pmd.lang.document.FileId;
|
import net.sourceforge.pmd.lang.document.FileId;
|
||||||
import net.sourceforge.pmd.lang.document.TextDocument;
|
import net.sourceforge.pmd.lang.document.TextDocument;
|
||||||
|
|
||||||
@ -117,8 +117,8 @@ public class Tokens {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TokenMgrError makeLexException(int line, int column, String message, @Nullable Throwable cause) {
|
public LexException makeLexException(int line, int column, String message, @Nullable Throwable cause) {
|
||||||
return new TokenMgrError(line, column, fileId, message, cause);
|
return new LexException(line, column, fileId, message, cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -16,7 +16,7 @@ import net.sourceforge.pmd.lang.document.FileLocation;
|
|||||||
/**
|
/**
|
||||||
* An exception that occurs while processing a file. Subtypes include
|
* An exception that occurs while processing a file. Subtypes include
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>{@link TokenMgrError}: lexical syntax errors
|
* <li>{@link LexException}: lexical syntax errors
|
||||||
* <li>{@link ParseException}: syntax errors
|
* <li>{@link ParseException}: syntax errors
|
||||||
* <li>{@link SemanticException}: exceptions occurring after the parsing
|
* <li>{@link SemanticException}: exceptions occurring after the parsing
|
||||||
* phase, because the source code is semantically invalid
|
* phase, because the source code is semantically invalid
|
||||||
|
@ -16,8 +16,10 @@ import net.sourceforge.pmd.util.StringUtil;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* An error thrown during lexical analysis of a file.
|
* An error thrown during lexical analysis of a file.
|
||||||
|
*
|
||||||
|
* <p>Note: This exception has been called TokenMgrError in PMD 6.</p>
|
||||||
*/
|
*/
|
||||||
public final class TokenMgrError extends FileAnalysisException {
|
public final class LexException extends FileAnalysisException {
|
||||||
|
|
||||||
private final int line;
|
private final int line;
|
||||||
private final int column;
|
private final int column;
|
||||||
@ -31,7 +33,7 @@ public final class TokenMgrError extends FileAnalysisException {
|
|||||||
* @param message Message of the error
|
* @param message Message of the error
|
||||||
* @param cause Cause of the error, if any
|
* @param cause Cause of the error, if any
|
||||||
*/
|
*/
|
||||||
public TokenMgrError(int line, int column, @Nullable FileId filename, String message, @Nullable Throwable cause) {
|
public LexException(int line, int column, @Nullable FileId filename, String message, @Nullable Throwable cause) {
|
||||||
super(message, cause);
|
super(message, cause);
|
||||||
this.line = max(line, 1);
|
this.line = max(line, 1);
|
||||||
this.column = max(column, 1);
|
this.column = max(column, 1);
|
||||||
@ -44,7 +46,7 @@ public final class TokenMgrError extends FileAnalysisException {
|
|||||||
* Constructor called by JavaCC.
|
* Constructor called by JavaCC.
|
||||||
*/
|
*/
|
||||||
@InternalApi
|
@InternalApi
|
||||||
public TokenMgrError(boolean eofSeen, String lexStateName, int errorLine, int errorColumn, String errorAfter, char curChar) {
|
public LexException(boolean eofSeen, String lexStateName, int errorLine, int errorColumn, String errorAfter, char curChar) {
|
||||||
super(makeReason(eofSeen, lexStateName, errorAfter, curChar));
|
super(makeReason(eofSeen, lexStateName, errorAfter, curChar));
|
||||||
line = max(errorLine, 1);
|
line = max(errorLine, 1);
|
||||||
column = max(errorColumn, 1);
|
column = max(errorColumn, 1);
|
||||||
@ -76,7 +78,7 @@ public final class TokenMgrError extends FileAnalysisException {
|
|||||||
* @return A new exception
|
* @return A new exception
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public TokenMgrError setFileId(FileId fileId) {
|
public LexException setFileId(FileId fileId) {
|
||||||
super.setFileId(fileId);
|
super.setFileId(fileId);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
@ -10,7 +10,7 @@ import org.antlr.v4.runtime.RecognitionException;
|
|||||||
import org.antlr.v4.runtime.Recognizer;
|
import org.antlr.v4.runtime.Recognizer;
|
||||||
|
|
||||||
import net.sourceforge.pmd.lang.TokenManager;
|
import net.sourceforge.pmd.lang.TokenManager;
|
||||||
import net.sourceforge.pmd.lang.ast.TokenMgrError;
|
import net.sourceforge.pmd.lang.ast.LexException;
|
||||||
import net.sourceforge.pmd.lang.document.TextDocument;
|
import net.sourceforge.pmd.lang.document.TextDocument;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -63,7 +63,7 @@ public class AntlrTokenManager implements TokenManager<AntlrToken> {
|
|||||||
final int charPositionInLine,
|
final int charPositionInLine,
|
||||||
final String msg,
|
final String msg,
|
||||||
final RecognitionException ex) {
|
final RecognitionException ex) {
|
||||||
throw new TokenMgrError(line, charPositionInLine, textDoc.getFileId(), msg, ex);
|
throw new LexException(line, charPositionInLine, textDoc.getFileId(), msg, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,30 +8,30 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
|||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
class TokenMgrErrorTest {
|
class LexExceptionTest {
|
||||||
@Test
|
@Test
|
||||||
void invalidLocation() {
|
void invalidLocation() {
|
||||||
TokenMgrError error = new TokenMgrError(2, 0, null, "test", null);
|
LexException error = new LexException(2, 0, null, "test", null);
|
||||||
// this shouldn't throw a IllegalArgumentException
|
// this shouldn't throw a IllegalArgumentException
|
||||||
assertEquals("line 2, column 1", error.location().startPosToString());
|
assertEquals("line 2, column 1", error.location().startPosToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void invalidLocationJavaCC() {
|
void invalidLocationJavaCC() {
|
||||||
TokenMgrError error = new TokenMgrError(false, "DEFAULT", 2, 0, "}", '\n');
|
LexException error = new LexException(false, "DEFAULT", 2, 0, "}", '\n');
|
||||||
// this shouldn't throw a IllegalArgumentException
|
// this shouldn't throw a IllegalArgumentException
|
||||||
assertEquals("line 2, column 1", error.location().startPosToString());
|
assertEquals("line 2, column 1", error.location().startPosToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void validLocation() {
|
void validLocation() {
|
||||||
TokenMgrError error = new TokenMgrError(1, 1, null, "test", null);
|
LexException error = new LexException(1, 1, null, "test", null);
|
||||||
assertEquals("line 1, column 1", error.location().startPosToString());
|
assertEquals("line 1, column 1", error.location().startPosToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void validLocationJavaCC() {
|
void validLocationJavaCC() {
|
||||||
TokenMgrError error = new TokenMgrError(false, "DEFAULT", 1, 1, "}", '\n');
|
LexException error = new LexException(false, "DEFAULT", 1, 1, "}", '\n');
|
||||||
assertEquals("line 1, column 1", error.location().startPosToString());
|
assertEquals("line 1, column 1", error.location().startPosToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -32,9 +32,6 @@ options {
|
|||||||
PARSER_BEGIN(CppParserImpl)
|
PARSER_BEGIN(CppParserImpl)
|
||||||
package net.sourceforge.pmd.lang.cpp.ast;
|
package net.sourceforge.pmd.lang.cpp.ast;
|
||||||
|
|
||||||
import net.sourceforge.pmd.lang.ast.impl.javacc.CharStream;
|
|
||||||
import net.sourceforge.pmd.lang.ast.TokenMgrError;
|
|
||||||
|
|
||||||
public final class CppParserImpl {
|
public final class CppParserImpl {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ class CPPTokenizerTest extends CpdTextComparisonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testWrongUnicodeInIdentifier() {
|
void testWrongUnicodeInIdentifier() {
|
||||||
expectTokenMgrError(" void main() { int ⚜ = __; }");
|
expectLexException(" void main() { int ⚜ = __; }");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -107,7 +107,7 @@ class CPPTokenizerTest extends CpdTextComparisonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testLexicalErrorFilename() {
|
void testLexicalErrorFilename() {
|
||||||
expectTokenMgrError(sourceText("issue-1559"), dontSkipBlocks());
|
expectLexException(sourceText("issue-1559"), dontSkipBlocks());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ import org.junit.jupiter.api.Test;
|
|||||||
import net.sourceforge.pmd.cpd.CpdLanguageProperties;
|
import net.sourceforge.pmd.cpd.CpdLanguageProperties;
|
||||||
import net.sourceforge.pmd.cpd.test.CpdTextComparisonTest;
|
import net.sourceforge.pmd.cpd.test.CpdTextComparisonTest;
|
||||||
import net.sourceforge.pmd.cpd.test.LanguagePropertyConfig;
|
import net.sourceforge.pmd.cpd.test.LanguagePropertyConfig;
|
||||||
import net.sourceforge.pmd.lang.ast.TokenMgrError;
|
import net.sourceforge.pmd.lang.ast.LexException;
|
||||||
|
|
||||||
class CsTokenizerTest extends CpdTextComparisonTest {
|
class CsTokenizerTest extends CpdTextComparisonTest {
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ class CsTokenizerTest extends CpdTextComparisonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testOpenString() {
|
void testOpenString() {
|
||||||
assertThrows(TokenMgrError.class, () -> doTest("unlexable_string"));
|
assertThrows(LexException.class, () -> doTest("unlexable_string"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -7,7 +7,7 @@ package net.sourceforge.pmd.lang.groovy.ast.impl.antlr4;
|
|||||||
import org.apache.groovy.parser.antlr4.GroovyLexer;
|
import org.apache.groovy.parser.antlr4.GroovyLexer;
|
||||||
|
|
||||||
import net.sourceforge.pmd.lang.TokenManager;
|
import net.sourceforge.pmd.lang.TokenManager;
|
||||||
import net.sourceforge.pmd.lang.ast.TokenMgrError;
|
import net.sourceforge.pmd.lang.ast.LexException;
|
||||||
import net.sourceforge.pmd.lang.ast.impl.antlr4.AntlrTokenManager;
|
import net.sourceforge.pmd.lang.ast.impl.antlr4.AntlrTokenManager;
|
||||||
import net.sourceforge.pmd.lang.document.TextDocument;
|
import net.sourceforge.pmd.lang.document.TextDocument;
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ public class GroovyTokenManager implements TokenManager<GroovyToken> {
|
|||||||
final int charPositionInLine,
|
final int charPositionInLine,
|
||||||
final String msg,
|
final String msg,
|
||||||
final RecognitionException ex) {
|
final RecognitionException ex) {
|
||||||
throw new TokenMgrError(line, charPositionInLine, textDoc.getFileId(), msg, ex);
|
throw new LexException(line, charPositionInLine, textDoc.getFileId(), msg, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,12 +301,8 @@ import java.util.EnumSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import net.sourceforge.pmd.lang.ast.impl.javacc.CharStream;
|
|
||||||
import net.sourceforge.pmd.lang.ast.GenericToken;
|
|
||||||
import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken;
|
import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken;
|
||||||
import net.sourceforge.pmd.lang.ast.Node;
|
import net.sourceforge.pmd.lang.ast.Node;
|
||||||
import net.sourceforge.pmd.lang.ast.TokenMgrError;
|
|
||||||
import net.sourceforge.pmd.lang.ast.Node;
|
|
||||||
import net.sourceforge.pmd.lang.java.ast.JavaParserImplTokenManager.TokenContext;
|
import net.sourceforge.pmd.lang.java.ast.JavaParserImplTokenManager.TokenContext;
|
||||||
import net.sourceforge.pmd.lang.java.types.JPrimitiveType.PrimitiveTypeKind;
|
import net.sourceforge.pmd.lang.java.types.JPrimitiveType.PrimitiveTypeKind;
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ import net.sourceforge.pmd.cpd.Tokenizer;
|
|||||||
import net.sourceforge.pmd.cpd.Tokens;
|
import net.sourceforge.pmd.cpd.Tokens;
|
||||||
import net.sourceforge.pmd.cpd.test.CpdTextComparisonTest;
|
import net.sourceforge.pmd.cpd.test.CpdTextComparisonTest;
|
||||||
import net.sourceforge.pmd.cpd.test.LanguagePropertyConfig;
|
import net.sourceforge.pmd.cpd.test.LanguagePropertyConfig;
|
||||||
import net.sourceforge.pmd.lang.ast.TokenMgrError;
|
import net.sourceforge.pmd.lang.ast.LexException;
|
||||||
import net.sourceforge.pmd.lang.document.FileId;
|
import net.sourceforge.pmd.lang.document.FileId;
|
||||||
import net.sourceforge.pmd.lang.document.TextDocument;
|
import net.sourceforge.pmd.lang.document.TextDocument;
|
||||||
import net.sourceforge.pmd.lang.java.JavaLanguageModule;
|
import net.sourceforge.pmd.lang.java.JavaLanguageModule;
|
||||||
@ -42,7 +42,7 @@ class JavaTokenizerTest extends CpdTextComparisonTest {
|
|||||||
void testLexExceptionLocation() {
|
void testLexExceptionLocation() {
|
||||||
Tokenizer tokenizer = newTokenizer(defaultProperties());
|
Tokenizer tokenizer = newTokenizer(defaultProperties());
|
||||||
Tokens tokens = new Tokens();
|
Tokens tokens = new Tokens();
|
||||||
TokenMgrError lexException = assertThrows(TokenMgrError.class, () ->
|
LexException lexException = assertThrows(LexException.class, () ->
|
||||||
Tokenizer.tokenize(tokenizer,
|
Tokenizer.tokenize(tokenizer,
|
||||||
// note: the source deliberately contains an unbalanced quote, unterminated string literal
|
// note: the source deliberately contains an unbalanced quote, unterminated string literal
|
||||||
TextDocument.readOnlyString("class F {\n String s=\"abc\";\"\n}\n", FileId.UNKNOWN, getLanguage().getDefaultVersion()),
|
TextDocument.readOnlyString("class F {\n String s=\"abc\";\"\n}\n", FileId.UNKNOWN, getLanguage().getDefaultVersion()),
|
||||||
|
@ -270,7 +270,7 @@ open class ParserTestCtx(testScope: TestScope,
|
|||||||
Pair(true, null)
|
Pair(true, null)
|
||||||
} catch (e: ParseException) {
|
} catch (e: ParseException) {
|
||||||
Pair(false, e)
|
Pair(false, e)
|
||||||
} catch (e: TokenMgrError) {
|
} catch (e: LexException) {
|
||||||
Pair(false, e)
|
Pair(false, e)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,9 +15,6 @@ options {
|
|||||||
PARSER_BEGIN(Ecmascript5ParserImpl)
|
PARSER_BEGIN(Ecmascript5ParserImpl)
|
||||||
package net.sourceforge.pmd.lang.ecmascript5.ast;
|
package net.sourceforge.pmd.lang.ecmascript5.ast;
|
||||||
|
|
||||||
import net.sourceforge.pmd.lang.ast.impl.javacc.CharStream;
|
|
||||||
import net.sourceforge.pmd.lang.ast.TokenMgrError;
|
|
||||||
|
|
||||||
public class Ecmascript5ParserImpl {
|
public class Ecmascript5ParserImpl {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,10 +30,6 @@ options {
|
|||||||
PARSER_BEGIN(JspParserImpl)
|
PARSER_BEGIN(JspParserImpl)
|
||||||
package net.sourceforge.pmd.lang.jsp.ast;
|
package net.sourceforge.pmd.lang.jsp.ast;
|
||||||
|
|
||||||
import net.sourceforge.pmd.lang.ast.impl.javacc.CharStream;
|
|
||||||
import net.sourceforge.pmd.lang.ast.TokenMgrError;
|
|
||||||
import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JSP Parser for PMD.
|
* JSP Parser for PMD.
|
||||||
* @author Pieter, Application Engineers NV/SA, http://www.ae.be
|
* @author Pieter, Application Engineers NV/SA, http://www.ae.be
|
||||||
|
@ -6,16 +6,13 @@ package net.sourceforge.pmd.cpd.test
|
|||||||
|
|
||||||
import io.kotest.assertions.throwables.shouldThrow
|
import io.kotest.assertions.throwables.shouldThrow
|
||||||
import net.sourceforge.pmd.cpd.*
|
import net.sourceforge.pmd.cpd.*
|
||||||
import net.sourceforge.pmd.lang.Language
|
|
||||||
import net.sourceforge.pmd.lang.LanguagePropertyBundle
|
import net.sourceforge.pmd.lang.LanguagePropertyBundle
|
||||||
import net.sourceforge.pmd.lang.LanguageRegistry
|
import net.sourceforge.pmd.lang.LanguageRegistry
|
||||||
import net.sourceforge.pmd.lang.ast.TokenMgrError
|
import net.sourceforge.pmd.lang.ast.LexException
|
||||||
import net.sourceforge.pmd.lang.document.TextDocument
|
import net.sourceforge.pmd.lang.document.TextDocument
|
||||||
import net.sourceforge.pmd.lang.document.TextFile
|
|
||||||
import net.sourceforge.pmd.lang.document.FileId
|
import net.sourceforge.pmd.lang.document.FileId
|
||||||
import net.sourceforge.pmd.test.BaseTextComparisonTest
|
import net.sourceforge.pmd.test.BaseTextComparisonTest
|
||||||
import org.apache.commons.lang3.StringUtils
|
import org.apache.commons.lang3.StringUtils
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CPD test comparing a dump of a file against a saved baseline.
|
* CPD test comparing a dump of a file against a saved baseline.
|
||||||
@ -73,18 +70,18 @@ abstract class CpdTextComparisonTest(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
fun expectTokenMgrError(
|
fun expectLexException(
|
||||||
source: String,
|
source: String,
|
||||||
fileName: FileId = FileId.UNKNOWN,
|
fileName: FileId = FileId.UNKNOWN,
|
||||||
properties: LanguagePropertyConfig = defaultProperties()
|
properties: LanguagePropertyConfig = defaultProperties()
|
||||||
): TokenMgrError =
|
): LexException =
|
||||||
expectTokenMgrError(FileData(fileName, source), properties)
|
expectLexException(FileData(fileName, source), properties)
|
||||||
|
|
||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
fun expectTokenMgrError(
|
fun expectLexException(
|
||||||
fileData: FileData,
|
fileData: FileData,
|
||||||
config: LanguagePropertyConfig = defaultProperties()
|
config: LanguagePropertyConfig = defaultProperties()
|
||||||
): TokenMgrError =
|
): LexException =
|
||||||
shouldThrow {
|
shouldThrow {
|
||||||
tokenize(newTokenizer(config), fileData)
|
tokenize(newTokenizer(config), fileData)
|
||||||
}
|
}
|
||||||
|
@ -21,9 +21,6 @@ options {
|
|||||||
PARSER_BEGIN(MatlabParserImpl)
|
PARSER_BEGIN(MatlabParserImpl)
|
||||||
package net.sourceforge.pmd.lang.matlab.ast;
|
package net.sourceforge.pmd.lang.matlab.ast;
|
||||||
|
|
||||||
import net.sourceforge.pmd.lang.ast.impl.javacc.CharStream;
|
|
||||||
import net.sourceforge.pmd.lang.ast.TokenMgrError;
|
|
||||||
|
|
||||||
public class MatlabParserImpl {
|
public class MatlabParserImpl {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -49,9 +49,6 @@ options {
|
|||||||
PARSER_BEGIN(ModelicaParserImpl)
|
PARSER_BEGIN(ModelicaParserImpl)
|
||||||
package net.sourceforge.pmd.lang.modelica.ast;
|
package net.sourceforge.pmd.lang.modelica.ast;
|
||||||
|
|
||||||
import net.sourceforge.pmd.lang.ast.impl.javacc.CharStream;
|
|
||||||
import net.sourceforge.pmd.lang.ast.TokenMgrError;
|
|
||||||
|
|
||||||
class ModelicaParserImpl {
|
class ModelicaParserImpl {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,12 +18,6 @@ options {
|
|||||||
PARSER_BEGIN(ObjectiveCParserImpl)
|
PARSER_BEGIN(ObjectiveCParserImpl)
|
||||||
package net.sourceforge.pmd.lang.objectivec.ast;
|
package net.sourceforge.pmd.lang.objectivec.ast;
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import net.sourceforge.pmd.lang.ast.impl.javacc.CharStream;
|
|
||||||
import net.sourceforge.pmd.lang.ast.TokenMgrError;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Grammar to parse ObjectiveC 2.0
|
* Grammar to parse ObjectiveC 2.0
|
||||||
* @author Michael Hall - Based on Parnel SableCC ObjectiveC grammar and javacc C grammar
|
* @author Michael Hall - Based on Parnel SableCC ObjectiveC grammar and javacc C grammar
|
||||||
|
@ -157,13 +157,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
|
|
||||||
package net.sourceforge.pmd.lang.plsql.ast;
|
package net.sourceforge.pmd.lang.plsql.ast;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import net.sourceforge.pmd.lang.ast.Node;
|
|
||||||
import net.sourceforge.pmd.lang.document.Chars;
|
import net.sourceforge.pmd.lang.document.Chars;
|
||||||
import net.sourceforge.pmd.lang.ast.impl.javacc.CharStream;
|
|
||||||
import net.sourceforge.pmd.lang.plsql.ast.internal.ParsingExclusion;
|
import net.sourceforge.pmd.lang.plsql.ast.internal.ParsingExclusion;
|
||||||
import net.sourceforge.pmd.lang.ast.TokenMgrError;
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class PLSQLParserImpl {
|
public class PLSQLParserImpl {
|
||||||
|
|
||||||
|
@ -17,9 +17,6 @@ PARSER_BEGIN(PythonParserImpl)
|
|||||||
|
|
||||||
package net.sourceforge.pmd.lang.python.ast;
|
package net.sourceforge.pmd.lang.python.ast;
|
||||||
|
|
||||||
import net.sourceforge.pmd.lang.ast.impl.javacc.CharStream;
|
|
||||||
import net.sourceforge.pmd.lang.ast.TokenMgrError;
|
|
||||||
|
|
||||||
public class PythonParserImpl {
|
public class PythonParserImpl {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
|||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import net.sourceforge.pmd.cpd.test.CpdTextComparisonTest;
|
import net.sourceforge.pmd.cpd.test.CpdTextComparisonTest;
|
||||||
import net.sourceforge.pmd.lang.ast.TokenMgrError;
|
import net.sourceforge.pmd.lang.ast.LexException;
|
||||||
import net.sourceforge.pmd.lang.scala.ScalaLanguageModule;
|
import net.sourceforge.pmd.lang.scala.ScalaLanguageModule;
|
||||||
|
|
||||||
class ScalaTokenizerTest extends CpdTextComparisonTest {
|
class ScalaTokenizerTest extends CpdTextComparisonTest {
|
||||||
@ -35,7 +35,7 @@ class ScalaTokenizerTest extends CpdTextComparisonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void tokenizeFailTest() {
|
void tokenizeFailTest() {
|
||||||
assertThrows(TokenMgrError.class, () -> doTest("unlexable_sample"));
|
assertThrows(LexException.class, () -> doTest("unlexable_sample"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -13,9 +13,6 @@ options {
|
|||||||
PARSER_BEGIN(VfParserImpl)
|
PARSER_BEGIN(VfParserImpl)
|
||||||
package net.sourceforge.pmd.lang.vf.ast;
|
package net.sourceforge.pmd.lang.vf.ast;
|
||||||
|
|
||||||
import net.sourceforge.pmd.lang.ast.impl.javacc.CharStream;
|
|
||||||
import net.sourceforge.pmd.lang.ast.TokenMgrError;
|
|
||||||
|
|
||||||
public class VfParserImpl {
|
public class VfParserImpl {
|
||||||
|
|
||||||
|
|
||||||
|
@ -37,16 +37,11 @@ PARSER_BEGIN(VmParserImpl)
|
|||||||
package net.sourceforge.pmd.lang.vm.ast;
|
package net.sourceforge.pmd.lang.vm.ast;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Reader;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import net.sourceforge.pmd.lang.ast.TokenMgrError;
|
|
||||||
import net.sourceforge.pmd.lang.ast.impl.javacc.CharStream;
|
|
||||||
import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken;
|
import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user