Skip to content

Commit

Permalink
Merge pull request #1660 from ivangalkin/CxxPreprocessor_init
Browse files Browse the repository at this point in the history
CxxPreprocessor: unitilize com.sonar.sslr.api.Preprocessor::init()
  • Loading branch information
guwirth authored Jan 10, 2019
2 parents 92ae26a + 8dfd12f commit dc83764
Showing 1 changed file with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -442,14 +442,10 @@ public Collection<Include> getMissingIncludeFiles(File file) {
}

@Override
public PreprocessorAction process(List<Token> tokens) { //TODO: deprecated PreprocessorAction
Token token = tokens.get(0);
TokenType ttype = token.getType();

final String rootFilePath = getFileUnderAnalysis().getAbsolutePath();

// CxxPreprocessor::process() can be called a) while construction,
// b) for a new "physical" file or c) for #include directive.
public void init() {
// CxxPreprocessor::init() can be called a) while construction,
// b) for a new "physical" file or c) while processing of
// #include directive.
// Make sure, that the following code is executed for a new "physical" file
// only.
final boolean processingNewSourceFile = !ctorInProgress && (context.getFile() != currentContextFile);
Expand All @@ -462,12 +458,12 @@ public PreprocessorAction process(List<Token> tokens) { //TODO: deprecated Prepr
compilationUnitSettings = conf.getCompilationUnitSettings(currentContextFile.getAbsolutePath());

if (compilationUnitSettings != null) {
LOG.debug("compilation unit settings for: '{}'", rootFilePath);
LOG.debug("compilation unit settings for: '{}'", currentContextFile);
} else {
compilationUnitSettings = conf.getGlobalCompilationUnitSettings();

if (compilationUnitSettings != null) {
LOG.debug("global compilation unit settings for: '{}'", rootFilePath);
LOG.debug("global compilation unit settings for: '{}'", currentContextFile);
}
}

Expand Down Expand Up @@ -523,7 +519,7 @@ public PreprocessorAction process(List<Token> tokens) { //TODO: deprecated Prepr
}
} else {
// Use global settings
LOG.debug("global settings for: '{}'", rootFilePath);
LOG.debug("global settings for: '{}'", currentContextFile);
if (isCFile(currentContextFile.getAbsolutePath())) {
//Create macros to replace C++ keywords when parsing C files
getMacros().putAll(Macro.COMPATIBILITY_MACROS);
Expand All @@ -533,6 +529,13 @@ public PreprocessorAction process(List<Token> tokens) { //TODO: deprecated Prepr
}
}
}
}

@Override
public PreprocessorAction process(List<Token> tokens) { //TODO: deprecated PreprocessorAction
final Token token = tokens.get(0);
final TokenType ttype = token.getType();
final String rootFilePath = getFileUnderAnalysis().getAbsolutePath();

if (ttype.equals(PREPROCESSOR)) {

Expand Down

0 comments on commit dc83764

Please sign in to comment.