use of com.github._1c_syntax.bsl.languageserver.context.DocumentContext in project bsl-language-server by 1c-syntax.
the class DiagnosticsConfiguration method diagnostics.
@Bean
@Scope("prototype")
public List<BSLDiagnostic> diagnostics(DocumentContext documentContext) {
Collection<DiagnosticInfo> diagnosticInfos = diagnosticInfos();
DiagnosticsOptions diagnosticsOptions = configuration.getDiagnosticsOptions();
if (needToComputeDiagnostics(documentContext, diagnosticsOptions)) {
FileType fileType = documentContext.getFileType();
CompatibilityMode compatibilityMode = documentContext.getServerContext().getConfiguration().getCompatibilityMode();
ModuleType moduleType = documentContext.getModuleType();
return diagnosticInfos.stream().filter(diagnosticInfo -> isEnabled(diagnosticInfo, diagnosticsOptions)).filter(info -> inScope(info, fileType)).filter(info -> correctModuleType(info, moduleType, fileType)).filter(info -> passedCompatibilityMode(info, compatibilityMode)).map(DiagnosticInfo::getDiagnosticClass).map(diagnosticObjectProvider::get).collect(Collectors.toList());
} else {
return Collections.emptyList();
}
}
use of com.github._1c_syntax.bsl.languageserver.context.DocumentContext in project bsl-language-server by 1c-syntax.
the class VariableSymbolMarkupContentBuilderTest method testFileVarContentFromDirectFile_NoComments.
@Test
void testFileVarContentFromDirectFile_NoComments() {
// given
DocumentContext documentContext = TestUtils.getDocumentContextFromFile(PATH_TO_FILE);
final var symbolTree = documentContext.getSymbolTree();
var varSymbol = symbolTree.getVariableSymbol("ИмяБезОписания", symbolTree.getModule()).orElseThrow();
// when
var content = markupContentBuilder.getContent(varSymbol).getValue();
assertThat(content).isNotEmpty();
var blocks = Arrays.asList(content.split("---\n?"));
assertThat(blocks).hasSize(2);
assertThat(blocks.get(0)).isEqualTo("```bsl\n" + "Перем ИмяБезОписания\n" + "```\n" + "\n");
assertThat(blocks.get(1)).matches("Переменная из file://.*/src/test/resources/hover/variableSymbolMarkupContentBuilder.bsl\n" + "\n");
}
use of com.github._1c_syntax.bsl.languageserver.context.DocumentContext in project bsl-language-server by 1c-syntax.
the class VariableSymbolMarkupContentBuilderTest method testMethodVarContentFromDirectFile_3_comments_strings.
@Test
void testMethodVarContentFromDirectFile_3_comments_strings() {
// given
DocumentContext documentContext = TestUtils.getDocumentContextFromFile(PATH_TO_FILE);
final var symbolTree = documentContext.getSymbolTree();
var methodSymbol = symbolTree.getMethodSymbol("ИмяФункции").orElseThrow();
var varSymbol = symbolTree.getVariableSymbol("Имя_ОписаниеСверхуТриСтрокиПоследняяПустая_Функция", methodSymbol).orElseThrow();
// when
var content = markupContentBuilder.getContent(varSymbol).getValue();
assertThat(content).isNotEmpty();
var blocks = Arrays.asList(content.split("---\n?"));
assertThat(blocks).hasSize(3);
assertThat(blocks.get(0)).isEqualTo("```bsl\n" + "Перем Имя_ОписаниеСверхуТриСтрокиПоследняяПустая_Функция\n" + "```\n" + "\n");
assertThat(blocks.get(1)).matches("Переменная из file://.*/src/test/resources/hover/variableSymbolMarkupContentBuilder.bsl.ИмяФункции\n" + "\n");
assertThat(blocks.get(2)).matches("описание 1 строка\n2 строка\n" + "\n");
}
use of com.github._1c_syntax.bsl.languageserver.context.DocumentContext in project bsl-language-server by 1c-syntax.
the class CallHierarchyProviderTest method testPrepareHierarchyOnDeclaration.
@Test
void testPrepareHierarchyOnDeclaration() {
// given
var textDocument = new TextDocumentIdentifier(documentContext.getUri().toString());
CallHierarchyPrepareParams params = new CallHierarchyPrepareParams();
params.setTextDocument(textDocument);
params.setPosition(firstProcedureDeclarationPosition);
// when
List<CallHierarchyItem> items = provider.prepareCallHierarchy(documentContext, params);
// then
assertThat(items).hasSize(1).allMatch(callHierarchyItem -> callHierarchyItem.getName().equals("ПерваяПроцедура")).allMatch(callHierarchyItem -> callHierarchyItem.getKind().equals(SymbolKind.Method)).allMatch(callHierarchyItem -> callHierarchyItem.getTags().isEmpty());
}
use of com.github._1c_syntax.bsl.languageserver.context.DocumentContext in project bsl-language-server by 1c-syntax.
the class CallHierarchyProviderTest method testPrepareHierarchyLocalDeprecatedMethodCall.
@Test
void testPrepareHierarchyLocalDeprecatedMethodCall() {
// given
var textDocument = new TextDocumentIdentifier(documentContext.getUri().toString());
CallHierarchyPrepareParams params = new CallHierarchyPrepareParams();
params.setTextDocument(textDocument);
params.setPosition(secondFunctionCallPosition);
// when
List<CallHierarchyItem> items = provider.prepareCallHierarchy(documentContext, params);
// then
assertThat(items).hasSize(1).allMatch(callHierarchyItem -> callHierarchyItem.getName().equals("ВтораяФункция")).allMatch(callHierarchyItem -> callHierarchyItem.getKind().equals(SymbolKind.Method)).allMatch(callHierarchyItem -> callHierarchyItem.getTags().contains(SymbolTag.Deprecated));
}
Aggregations