Commit Graph
34 Commits
Author SHA1 Message Date
Will Herrmann 377baf7caf Replacing IOUtils.closeQuietly(foo) with try-with-resources statements 2018-10-19 14:23:51 -05:00
Will Herrmann cba4e87acd Replacing deprecated IO methods with ones that specify a charset
Standardizing with StandardCharsets.UTF_8, given that it was used in
several places of code already, and it provides compile-time checking
(as opposed to "UTF-8")
2018-10-12 17:25:08 -05:00
Rafael Cortês 888824d24a Fix NullPointerException in CPPTokenizer:99
Due to `skipBlocks = true` and `skipBlocksStart` being uninitialized in `CPPTokenizer`, `maybeSkipBlocks` would always throw a NullPointerException as it is assuming that `setProperties` is always called after the constructor.
Changed `CPPLanguage` to always invoke `setProperties`, similarly to `CsLanguage`.
This only happens in programmatic invocations.
2018-07-29 09:11:15 +01:00
Andreas Dangel 5a7bbe19a2 dogfood: fix missing override
Note: the rule is disabled for pmd-xml, refs #1074
2018-06-16 17:48:36 +02:00
Juan Martín Sotuyo Dodero 47e345945e [cpp] Allow CPD suppressions with comments 2018-04-14 22:33:37 -03:00
gonzalo 91b8a22b42 Update GenericToken specialToken method to obtain only comment tokens 2017-10-28 14:42:44 -03:00
gonzalo e8fdbdbca4 Update GenericToken interface to expose directly region methods 2017-10-28 14:42:44 -03:00
gonzalo f29e3f0408 Change ant tasks over (CPP) Token class 2017-10-28 14:42:44 -03:00
Andreas Dangel 3d9511a0e5 [doc] Remove old maven site 2017-08-15 14:31:03 +02:00
Matias Comercio e5ddad3c3b Remove pushed .gitignored files
These files were already at the repository
but they should have been ignored
2017-07-27 18:31:20 -03:00
Andreas Dangel ead8d964c5 [cpp] Undo changes to String literals in grammar, it's not needed anymore
Such slightly illegal char escape sequences can still be parsed now.
2017-07-08 11:48:06 +02:00
Andreas Dangel 5bcf30a2a4 [cpp] Add unit test to assert begin/end of Tokens with continuation 2017-07-08 11:32:54 +02:00
Andreas Dangel ec631f3993 [cpp] Don't skip the continuation character in the grammar anymore
Since we now have a CppCharStream, we can remove the changes
introduced for #431
2017-07-07 23:11:27 +02:00
Andreas Dangel dbc2d02895 [cpp] Add custom CppCharStream for line continuation support
Fixes #448
2017-07-07 22:46:21 +02:00
Andreas Dangel 0f9a4a97c0 cpp: skip line continuation character in grammar
Fixes #431

Note: the tokens separate by such continuation characters are not
merged and appear as two separate tokens, which could lead to false
negatives in duplication detection.

ContinuationReader is deleted, since skipping characters in the stream
makes it difficult to provide accurate line numbers/positions.
2017-06-17 12:42:13 +02:00
Andreas Dangel d92688a07d Introduce end-of-line normalization
References pmd/build-tools#2
2017-02-02 20:52:08 +01:00
Andreas Dangel e280151987 pmd-cpp/pmd-java: checkstyle fixes 2016-12-16 15:48:53 +01:00
Andreas Dangel edcd4e5ccb pmd-cpp: checkstyle, formatting 2016-12-02 09:18:02 +01:00
Jan van Nunen c099d50397 Added support for Raw String Literals (C++11). 2015-12-10 16:15:40 +01:00
Jan van Nunen c92dc9706c Relaxed C++ tokenizer so a '\'(backslash) can be use to escape any character inside a string or character.
The following 2 code snippets could not be tokenized:

1:  if (*pbuf == '\0x05'), the problem is the '\0' in the character
literal '\0x05'.
2:  szPath = m_sdcacheDir + _T("\    oMedia");, the problem is the '\ '
in the string literal "\    oMedia".

I relaxed the lexical grammar so a '\' (backslash) can escape any
character inside a string or character literal. We can relax the grammar
because CPD only needs the tokens, so it is no problem to accept
'invalid' string / character literals. (according to the ANSI C
standard).  Failing too fast because the tokenizer is too strict is
annoying because then we can't check the files for duplicated code.

Both snippets were taken from existing projects and be successfully
compiled, so for some C / C++ compilers it is valid code.
2015-01-13 11:36:54 +01:00
Jan van Nunen d830974842 Fixed lexical error when a C++ file contains an empty character literal L''.
This commit fixes a lexical error when a C++ file contains an empty
character literal L''. The following code could not be tokenized:

std::wstring wsMessage( sMessage.length(), L'');

It triggers the following error:

net.sourceforge.pmd.lang.ast.TokenMgrError: Lexical error in file
'foo.cpp' at line 1, column 46.  Encountered: "\'" (39), after : "\'"
2015-01-13 11:36:54 +01:00
Jan van Nunen ceef6cd236 Fixed lexical eror when a preprocessor directive is followed by a single line comment that starts with "//*".
This commit fixes a lexical eror when a preprocessor directive is
followed by a single line comment that starts with "//*".

The following code could not be tokenized:

#define LSTFVLES_CPP  //*

It triggers the following error:

net.sourceforge.pmd.lang.ast.TokenMgrError: Lexical error in file
'foo.cpp' at line 2, column 0.  Encountered: <EOF> after : ""
2015-01-13 11:36:53 +01:00
Jan van Nunen 5c2df4c877 Fixed lexical error when a C++ file contains ASM with the '@' character.
This commit fixes a lexical error when a C++ file contains ASM with the
'@' character. The following code cannot be tokenized and triggers a
lexical error:

asm void eSPI_boot()
{
// setup stack pointer
lis r1, _stack_addr@h
ori r1, r1, _stack_addr@l
}

The error that occurs:

net.sourceforge.pmd.lang.ast.TokenMgrError: Lexical error in file
CODE_LOADED_FROM_STRING at line 4, column 22.  Encountered: "@" (64),
after : ""
2015-01-13 11:36:53 +01:00
Andreas Dangel 26b4f850b1 #1252 net.sourceforge.pmd.lang.ast.TokenMgrError: Lexical error in file xxx.cpp 2014-12-12 18:58:51 +01:00
Andreas Dangel 6b3b9d0ccc #1252 implement BOM detection differently for cpp 2014-12-12 17:45:38 +01:00
Andreas Dangel c8887de5ff #1090 cpp parser exception with inline asm 2014-11-28 21:32:32 +01:00
Andreas Dangel 53048546ba Checkstyle/whitespace fixes 2014-10-18 13:31:14 +02:00
Andreas Dangel 5f9bd17ee6 #1252 net.sourceforge.pmd.lang.ast.TokenMgrError: Lexical error in file xxx.cpp 2014-10-18 12:33:40 +02:00
Andreas Dangel 9ade75a621 Refactor CPDGui to detect available languages dynamically 2014-10-12 10:43:53 +02:00
Andreas Dangel 464b0bcef8 Rework CPD's LanguageFactory to use ServiceLoader, too 2014-10-11 12:16:28 +02:00
Andreas Dangel 475745e98e Configure the site for every module 2014-10-08 21:49:23 +02:00
Andreas Dangel 8165bc2bf5 Fix test compilation errors - LanguageVersion*Tests in each sub-module now 2014-10-04 20:40:05 +02:00
Andreas Dangel c352217131 Move cpd tokenizer tests to the various sub-modules 2014-10-04 19:16:01 +02:00
Andreas Dangel cdf293f9fc Move cpp into own sub-module 2014-10-04 18:48:35 +02:00