Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve reliability: CxxCpdVisitor & CxxVCppBuildLogParser #1126

Merged
merged 1 commit into from
May 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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