use of com.github._1c_syntax.bsl.languageserver.context.DocumentContext in project sonar-bsl-plugin-community by 1c-syntax.
the class BSLCoreSensor method saveMeasures.
private void saveMeasures(InputFile inputFile, DocumentContext documentContext) {
MetricStorage metrics = documentContext.getMetrics();
context.<Integer>newMeasure().on(inputFile).forMetric(CoreMetrics.NCLOC).withValue(metrics.getNcloc()).save();
context.<Integer>newMeasure().on(inputFile).forMetric(CoreMetrics.STATEMENTS).withValue(metrics.getStatements()).save();
context.<Integer>newMeasure().on(inputFile).forMetric(CoreMetrics.FUNCTIONS).withValue(metrics.getProcedures() + metrics.getFunctions()).save();
context.<Integer>newMeasure().on(inputFile).forMetric(CoreMetrics.COGNITIVE_COMPLEXITY).withValue(metrics.getCognitiveComplexity()).save();
context.<Integer>newMeasure().on(inputFile).forMetric(CoreMetrics.COMPLEXITY).withValue(metrics.getCyclomaticComplexity()).save();
context.<Integer>newMeasure().on(inputFile).forMetric(CoreMetrics.COMMENT_LINES).withValue(metrics.getComments()).save();
FileLinesContext fileLinesContext = fileLinesContextFactory.createFor(inputFile);
for (int line : metrics.getNclocData()) {
fileLinesContext.setIntValue(CoreMetrics.NCLOC_DATA_KEY, line, 1);
}
fileLinesContext.save();
}
use of com.github._1c_syntax.bsl.languageserver.context.DocumentContext in project bsl-language-server by 1c-syntax.
the class BSLTextDocumentService method rangeFormatting.
@Override
public CompletableFuture<List<? extends TextEdit>> rangeFormatting(DocumentRangeFormattingParams params) {
DocumentContext documentContext = context.getDocument(params.getTextDocument().getUri());
if (documentContext == null) {
return CompletableFuture.completedFuture(null);
}
List<TextEdit> edits = formatProvider.getRangeFormatting(params, documentContext);
return CompletableFuture.completedFuture(edits);
}
use of com.github._1c_syntax.bsl.languageserver.context.DocumentContext in project bsl-language-server by 1c-syntax.
the class BSLTextDocumentService method didClose.
@Override
public void didClose(DidCloseTextDocumentParams params) {
DocumentContext documentContext = context.getDocument(params.getTextDocument().getUri());
if (documentContext == null) {
return;
}
documentContext.clearSecondaryData();
diagnosticProvider.publishEmptyDiagnosticList(documentContext);
}
use of com.github._1c_syntax.bsl.languageserver.context.DocumentContext in project bsl-language-server by 1c-syntax.
the class BSLTextDocumentService method diagnostics.
@Override
public CompletableFuture<Diagnostics> diagnostics(DiagnosticParams params) {
DocumentContext documentContext = context.getDocument(params.getTextDocument().getUri());
if (documentContext == null) {
return CompletableFuture.completedFuture(Diagnostics.EMPTY);
}
return CompletableFuture.supplyAsync(() -> {
var diagnostics = documentContext.getDiagnostics();
var range = params.getRange();
if (range != null) {
diagnostics = diagnostics.stream().filter(diagnostic -> Ranges.containsRange(range, diagnostic.getRange())).collect(Collectors.toList());
}
return new Diagnostics(diagnostics, documentContext.getVersion());
});
}
use of com.github._1c_syntax.bsl.languageserver.context.DocumentContext in project bsl-language-server by 1c-syntax.
the class BSLTextDocumentService method formatting.
@Override
public CompletableFuture<List<? extends TextEdit>> formatting(DocumentFormattingParams params) {
DocumentContext documentContext = context.getDocument(params.getTextDocument().getUri());
if (documentContext == null) {
return CompletableFuture.completedFuture(null);
}
List<TextEdit> edits = formatProvider.getFormatting(params, documentContext);
return CompletableFuture.completedFuture(edits);
}
Aggregations