use of org.sonar.plugins.openedge.foundation.IRefactorSessionEnv in project sonar-openedge by Riverside-Software.
the class OpenEdgeCPDSensor method execute.
@Override
public void execute(SensorContext context) {
if ((context.runtime().getProduct() == SonarProduct.SONARLINT) || !settings.useSimpleCPD())
return;
settings.init();
IRefactorSessionEnv sessions = settings.getProparseSessions();
for (InputFile file : context.fileSystem().inputFiles(context.fileSystem().predicates().hasLanguage(Constants.LANGUAGE_KEY))) {
LOG.debug("CPD on {}", file);
IProparseEnvironment session = sessions.getSession(file.relativePath());
try {
processFile(context, session, file);
} catch (UncheckedIOException | ProparseRuntimeException caught) {
if (caught.getCause() instanceof XCodedFileException) {
LOG.error("Unable to process xcode'd file '{}", file);
} else {
LOG.error("Unable to lex file '{}'", file, caught);
}
}
}
}
use of org.sonar.plugins.openedge.foundation.IRefactorSessionEnv in project sonar-openedge by Riverside-Software.
the class OpenEdgeCodeColorizer method execute.
@Override
public void execute(SensorContext context) {
if (context.runtime().getProduct() == SonarProduct.SONARLINT)
return;
settings.init();
IRefactorSessionEnv sessions = settings.getProparseSessions();
for (InputFile file : context.fileSystem().inputFiles(context.fileSystem().predicates().hasLanguage(Constants.LANGUAGE_KEY))) {
LOG.debug("Syntax highlight on {}", file);
IProparseEnvironment session = sessions.getSession(file.relativePath());
try {
highlightFile(context, session, file);
} catch (UncheckedIOException | ProparseRuntimeException caught) {
if (caught.getCause() instanceof XCodedFileException) {
LOG.error("Unable to highlight xcode'd file '{}", file);
} else {
LOG.error("Unable to lex file '{}'", file, caught);
}
}
}
}
use of org.sonar.plugins.openedge.foundation.IRefactorSessionEnv in project sonar-openedge by Riverside-Software.
the class OpenEdgeProparseSensor method execute.
@Override
public void execute(SensorContext context) {
if (settings.skipProparseSensor())
return;
settings.init();
components.init(context);
for (Map.Entry<ActiveRule, OpenEdgeProparseCheck> entry : components.getProparseRules().entrySet()) {
ruleTime.put(entry.getKey().ruleKey().toString(), 0L);
}
IRefactorSessionEnv sessions = settings.getProparseSessions();
FilePredicates predicates = context.fileSystem().predicates();
// Counting total number of files
long totFiles = StreamSupport.stream(context.fileSystem().inputFiles(predicates.and(predicates.hasLanguage(Constants.LANGUAGE_KEY), predicates.hasType(Type.MAIN))).spliterator(), false).count();
long prevMessage = System.currentTimeMillis();
for (InputFile file : context.fileSystem().inputFiles(predicates.and(predicates.hasLanguage(Constants.LANGUAGE_KEY), predicates.hasType(Type.MAIN)))) {
LOG.debug("Parsing {}", file);
numFiles++;
if (System.currentTimeMillis() - prevMessage > 30000L) {
prevMessage = System.currentTimeMillis();
LOG.info("{}/{} - Current file: {}", numFiles, totFiles, file.relativePath());
}
IProparseEnvironment session = sessions.getSession(file.relativePath());
if (settings.isIncludeFile(file.filename())) {
parseIncludeFile(context, file, session);
} else {
parseMainFile(context, file, session);
}
if (context.isCancelled()) {
LOG.info("Analysis cancelled...");
return;
}
}
computeAnalytics(context);
logStatistics();
context.addContextProperty("sonar.oe.ncloc", Integer.toString(ncLocs));
generateProparseDebugIndex();
}
Aggregations