Skip to content

Commit

Permalink
Merge pull request #1126 from Bertk/fixes2
Browse files Browse the repository at this point in the history
improve reliability: CxxCpdVisitor & CxxVCppBuildLogParser
  • Loading branch information
guwirth authored May 6, 2017
2 parents 9933dbb + 391bc59 commit 00caf05
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,14 @@ public void visitToken(Token token) {
}

try {
TextRange range = inputFile.newRange(token.getLine(), token.getColumn(), token.getLine(), token.getColumn() + token.getValue().length());
TextRange range = inputFile.newRange(token.getLine(), token.getColumn(),
token.getLine(), token.getColumn() + token.getValue().length());
cpdTokens.addToken(range, text);
} catch (IllegalArgumentException e) { //NOSONAR
} catch (IllegalArgumentException|IllegalStateException e) {
// ignore range errors: parsing errors could lead to wrong location data
LOG.debug("CPD error in file '{}' at line:{}, column:{}", getContext().getFile().getAbsoluteFile(), token.getLine(), token.getColumn());
LOG.warn("CPD error in file '{}' at line:{}, column:{}", getContext().getFile().getAbsoluteFile(),
token.getLine(), token.getColumn());
LOG.debug("CPD error in file {} {}", getContext().getFile().getAbsoluteFile(), e);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,15 @@ public void parseVCppLog(File buildLog, String baseDir, String charsetName) {
* @param data
*/
private void parseCLParameters(String line, Path currentProjectPath, String data) {
String path = data.replaceAll("\"", "");
String fileElement;
try {
String fileElement = Paths.get(currentProjectPath.toAbsolutePath().toString(), data).toAbsolutePath().toString();
if (!path.isEmpty() && path.matches("^[a-zA-Z]:.*$")) {
// do not add project path if data is not a relative path
fileElement = Paths.get(path).toAbsolutePath().toString();
} else {
fileElement = Paths.get(currentProjectPath.toAbsolutePath().toString(), path).toAbsolutePath().toString();
}

if (!uniqueDefines.containsKey(fileElement)) {
uniqueDefines.put(fileElement, new HashSet<String>());
Expand Down

0 comments on commit 00caf05

Please sign in to comment.