use of com.github._1c_syntax.bsl.languageserver.context.symbol.SymbolTree 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.symbol.SymbolTree 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.symbol.SymbolTree in project bsl-language-server by 1c-syntax.
the class ReferenceIndex method getSourceDefinedSymbol.
private Optional<SourceDefinedSymbol> getSourceDefinedSymbol(MultiKey<String> multikey) {
String mdoRef = multikey.getKey(0);
ModuleType moduleType = ModuleType.valueOf(multikey.getKey(1));
String symbolName = multikey.getKey(2);
return serverContext.getDocument(mdoRef, moduleType).map(DocumentContext::getSymbolTree).flatMap(symbolTree -> symbolTree.getMethodSymbol(symbolName));
}
use of com.github._1c_syntax.bsl.languageserver.context.symbol.SymbolTree in project bsl-language-server by 1c-syntax.
the class SourceDefinedSymbolDeclarationReferenceFinder method findReference.
@Override
public Optional<Reference> findReference(URI uri, Position position) {
DocumentContext document = serverContext.getDocument(uri);
if (document == null) {
return Optional.empty();
}
SymbolTree symbolTree = document.getSymbolTree();
return symbolTree.getChildrenFlat().stream().filter(sourceDefinedSymbol -> Ranges.containsPosition(sourceDefinedSymbol.getSelectionRange(), position)).map(sourceDefinedSymbol -> new Reference(symbolTree.getModule(), sourceDefinedSymbol, uri, sourceDefinedSymbol.getSelectionRange())).findFirst();
}
Aggregations