use of com.github._1c_syntax.bsl.languageserver.context.DocumentContext in project bsl-language-server by 1c-syntax.
the class UsingModalWindowsDiagnosticTest method testUse.
@Test
void testUse() {
DocumentContext documentContext = getDocumentContextWithUseFlag(UseMode.USE);
List<Diagnostic> diagnostics = getDiagnostics(documentContext);
assertThat(diagnostics).isEmpty();
}
use of com.github._1c_syntax.bsl.languageserver.context.DocumentContext in project bsl-language-server by 1c-syntax.
the class DisableDiagnosticTriggeringSupplierTest method testGetCodeActions.
@Test
void testGetCodeActions() {
DocumentContext documentContext = TestUtils.getDocumentContextFromFile("./src/test/resources/suppliers/disableDiagnosticTriggering.bsl");
TextDocumentIdentifier textDocumentIdentifier = new TextDocumentIdentifier(documentContext.getUri().toString());
CodeActionContext codeActionContext = new CodeActionContext();
codeActionContext.setDiagnostics(documentContext.getDiagnostics());
CodeActionParams params = new CodeActionParams();
params.setRange(new Range());
params.setTextDocument(textDocumentIdentifier);
params.setContext(codeActionContext);
List<CodeAction> codeActions = codeActionSupplier.getCodeActions(params, documentContext);
assertThat(codeActions).hasSize(10).anyMatch(codeAction -> codeAction.getTitle().equals("Disable all diagnostic in file")).anyMatch(codeAction -> codeAction.getTitle().equals("Disable NumberOfValuesInStructureConstructor in file")).anyMatch(codeAction -> codeAction.getTitle().equals("Disable ExportVariables in file")).anyMatch(codeAction -> codeAction.getTitle().equals("Disable IfElseDuplicatedCondition in file")).anyMatch(codeAction -> codeAction.getTitle().equals("Disable CanonicalSpellingKeywords in file")).anyMatch(codeAction -> codeAction.getTitle().equals("Disable FunctionShouldHaveReturn in file")).anyMatch(codeAction -> codeAction.getTitle().equals("Disable IfElseIfEndsWithElse in file")).anyMatch(codeAction -> codeAction.getTitle().equals("Disable MagicNumber in file")).anyMatch(codeAction -> codeAction.getTitle().equals("Disable MissingSpace in file")).anyMatch(codeAction -> codeAction.getTitle().equals("Disable MissingVariablesDescription in file")).anyMatch(codeAction -> codeAction.getTitle().equals("Disable all diagnostic in file"));
}
use of com.github._1c_syntax.bsl.languageserver.context.DocumentContext in project bsl-language-server by 1c-syntax.
the class DisableDiagnosticTriggeringSupplierTest method testGetCodeActionsRegion.
@Test
void testGetCodeActionsRegion() {
DocumentContext documentContext = TestUtils.getDocumentContextFromFile("./src/test/resources/suppliers/disableDiagnosticTriggering.bsl");
TextDocumentIdentifier textDocumentIdentifier = new TextDocumentIdentifier(documentContext.getUri().toString());
Range range = Ranges.create(53, 0, 56, 38);
CodeActionContext codeActionContext = new CodeActionContext();
codeActionContext.setDiagnostics(documentContext.getDiagnostics().stream().filter(diagnostic -> Ranges.containsRange(range, diagnostic.getRange())).collect(Collectors.toList()));
CodeActionParams params = new CodeActionParams();
params.setRange(range);
params.setTextDocument(textDocumentIdentifier);
params.setContext(codeActionContext);
List<CodeAction> codeActions = codeActionSupplier.getCodeActions(params, documentContext);
assertThat(codeActions).hasSize(8).anyMatch(codeAction -> codeAction.getTitle().equals("Disable MagicNumber in range")).anyMatch(codeAction -> codeAction.getTitle().equals("Disable MissingSpace in range")).anyMatch(codeAction -> codeAction.getTitle().equals("Disable MagicNumber in file")).anyMatch(codeAction -> codeAction.getTitle().equals("Disable MissingSpace in file")).anyMatch(codeAction -> codeAction.getTitle().equals("Disable all diagnostic in range")).anyMatch(codeAction -> codeAction.getTitle().equals("Disable all diagnostic in file")).anyMatch(codeAction -> codeAction.getTitle().equals("Disable CanonicalSpellingKeywords in range")).anyMatch(codeAction -> codeAction.getTitle().equals("Disable CanonicalSpellingKeywords in file"));
}
use of com.github._1c_syntax.bsl.languageserver.context.DocumentContext in project bsl-language-server by 1c-syntax.
the class DisableDiagnosticTriggeringSupplierTest method testGetCodeActionsOneLine.
@Test
void testGetCodeActionsOneLine() {
DocumentContext documentContext = TestUtils.getDocumentContextFromFile("./src/test/resources/suppliers/disableDiagnosticTriggering.bsl");
TextDocumentIdentifier textDocumentIdentifier = new TextDocumentIdentifier(documentContext.getUri().toString());
Range range = Ranges.create(53, 0, 53, 30);
CodeActionContext codeActionContext = new CodeActionContext();
codeActionContext.setDiagnostics(documentContext.getDiagnostics().stream().filter(diagnostic -> Ranges.containsRange(range, diagnostic.getRange())).collect(Collectors.toList()));
CodeActionParams params = new CodeActionParams();
params.setRange(range);
params.setTextDocument(textDocumentIdentifier);
params.setContext(codeActionContext);
List<CodeAction> codeActions = codeActionSupplier.getCodeActions(params, documentContext);
assertThat(codeActions).hasSize(6).anyMatch(codeAction -> codeAction.getTitle().equals("Disable MagicNumber in line")).anyMatch(codeAction -> codeAction.getTitle().equals("Disable MissingSpace in line")).anyMatch(codeAction -> codeAction.getTitle().equals("Disable MagicNumber in file")).anyMatch(codeAction -> codeAction.getTitle().equals("Disable MissingSpace in file")).anyMatch(codeAction -> codeAction.getTitle().equals("Disable all diagnostic in line")).anyMatch(codeAction -> codeAction.getTitle().equals("Disable all diagnostic in file"));
}
use of com.github._1c_syntax.bsl.languageserver.context.DocumentContext in project bsl-language-server by 1c-syntax.
the class GenerateStandardRegionsSupplierTest method testGetCodeActions.
@Test
void testGetCodeActions() {
// given
String filePath = "./src/test/resources/suppliers/generateRegion.bsl";
DocumentContext documentContext = TestUtils.getDocumentContextFromFile(filePath);
List<Diagnostic> diagnostics = new ArrayList<>();
TextDocumentIdentifier textDocumentIdentifier = new TextDocumentIdentifier(documentContext.getUri().toString());
CodeActionContext codeActionContext = new CodeActionContext();
codeActionContext.setDiagnostics(diagnostics);
CodeActionParams params = new CodeActionParams();
params.setRange(new Range());
params.setTextDocument(textDocumentIdentifier);
params.setContext(codeActionContext);
// when
List<CodeAction> codeActions = codeActionSupplier.getCodeActions(params, documentContext);
assertThat(codeActions).hasSize(1).anyMatch(codeAction -> codeAction.getTitle().equals("Generate missing regions"));
}
Aggregations