use of org.sonar.php.compat.PhpFileImpl in project sonar-php by SonarSource.
the class SymbolScanner method scanFile.
@Override
void scanFile(InputFile file) {
PhpFileImpl phpFile = new PhpFileImpl(file);
try {
Tree ast = statistics.time("ProjectSymbolParsing", () -> parser.parse(phpFile.contents()));
SymbolTableImpl symbolTable = statistics.time("ProjectSymbolTable", () -> SymbolTableImpl.create((CompilationUnitTree) ast, new ProjectSymbolData(), phpFile));
symbolTable.classSymbolDatas().forEach(projectSymbolData::add);
symbolTable.functionSymbolDatas().forEach(projectSymbolData::add);
} catch (RecognitionException e) {
LOG.debug("Parsing error in " + file);
}
}
use of org.sonar.php.compat.PhpFileImpl in project sonar-php by SonarSource.
the class PhpIniSensor method execute.
@VisibleForTesting
protected void execute(SensorContext context, Checks<PhpIniCheck> checks) {
PhpIniParser parser = new PhpIniParser();
FileSystem fs = context.fileSystem();
Iterable<InputFile> inputFiles = fs.inputFiles(fs.predicates().matchesPathPattern("**/php.ini"));
for (InputFile inputFile : inputFiles) {
PhpIniFile phpIni;
try {
phpIni = parser.parse(new PhpFileImpl(inputFile));
} catch (RecognitionException e) {
LOG.error("Unable to parse file: " + inputFile.toString());
LOG.error(e.getMessage());
continue;
}
for (PhpIniCheck check : checks.all()) {
List<PhpIniIssue> issues = check.analyze(phpIni);
saveIssues(context, inputFile, checks.ruleKey(check), issues);
}
}
}
Aggregations