Skip to content

Commit

Permalink
fix: sslr-cxx-toolkit fails after SonarOpenCommunity#1645
Browse files Browse the repository at this point in the history
* org.sonar.sslr.toolkit.ConfigurationModel doesn't receive
  the file path of the processed file
* file path plays important role for the preprocessor
* pass a dummy path

fixes SonarOpenCommunity#1662
  • Loading branch information
ivangalkin committed Jan 10, 2019
1 parent dc83764 commit ae66798
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

import com.sonar.sslr.api.Grammar;
import com.sonar.sslr.impl.Parser;

import java.io.File;
import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.List;
Expand All @@ -37,8 +39,8 @@
import org.sonar.cxx.CxxConfiguration;
import org.sonar.cxx.CxxLanguage;
import org.sonar.cxx.api.CxxKeyword;
import org.sonar.cxx.api.CxxMetric;
import org.sonar.cxx.parser.CxxParser;
import org.sonar.squidbridge.SquidAstVisitorContext;
import org.sonar.squidbridge.SquidAstVisitorContextImpl;
import org.sonar.squidbridge.api.SourceProject;
import org.sonar.sslr.toolkit.AbstractConfigurationModel;
Expand Down Expand Up @@ -120,8 +122,9 @@ public Charset getCharset() {

@Override
public Parser<? extends Grammar> doGetParser() {
SquidAstVisitorContext<Grammar> context
SquidAstVisitorContextImpl<Grammar> context
= new SquidAstVisitorContextImpl<>(new SourceProject(""));
context.setFile(new File("file.cpp").getAbsoluteFile(), CxxMetric.FILES);
CppLanguage language = new CppLanguage(settings.asConfig());
return CxxParser.create(context, getConfiguration(language), language);
}
Expand Down

0 comments on commit ae66798

Please sign in to comment.