Search in sources :

Example 1 with ReferenceIndex

use of com.github._1c_syntax.bsl.languageserver.references.ReferenceIndex in project bsl-language-server by 1c-syntax.

the class CallHierarchyProvider method incomingCalls.

public List<CallHierarchyIncomingCall> incomingCalls(DocumentContext documentContext, CallHierarchyIncomingCallsParams params) {
    URI uri = documentContext.getUri();
    CallHierarchyItem item = params.getItem();
    Position position = item.getSelectionRange().getStart();
    return referenceResolver.findReference(uri, position).flatMap(Reference::getSourceDefinedSymbol).stream().map(referenceIndex::getReferencesTo).flatMap(Collection::stream).collect(groupingBy(Reference::getFrom, mapping(Reference::getSelectionRange, toCollection(ArrayList::new)))).entrySet().stream().map(entry -> new CallHierarchyIncomingCall(getCallHierarchyItem(entry.getKey()), entry.getValue())).collect(Collectors.toList());
}
Also used : ReferenceResolver(com.github._1c_syntax.bsl.languageserver.references.ReferenceResolver) Collection(java.util.Collection) RequiredArgsConstructor(lombok.RequiredArgsConstructor) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) MdoRefBuilder(com.github._1c_syntax.bsl.languageserver.utils.MdoRefBuilder) DocumentContext(com.github._1c_syntax.bsl.languageserver.context.DocumentContext) SourceDefinedSymbol(com.github._1c_syntax.bsl.languageserver.context.symbol.SourceDefinedSymbol) Collectors(java.util.stream.Collectors) CallHierarchyItem(org.eclipse.lsp4j.CallHierarchyItem) ArrayList(java.util.ArrayList) Reference(com.github._1c_syntax.bsl.languageserver.references.Reference) CallHierarchyIncomingCall(org.eclipse.lsp4j.CallHierarchyIncomingCall) ReferenceIndex(com.github._1c_syntax.bsl.languageserver.references.ReferenceIndex) Collectors.toCollection(java.util.stream.Collectors.toCollection) Component(org.springframework.stereotype.Component) List(java.util.List) CallHierarchyOutgoingCallsParams(org.eclipse.lsp4j.CallHierarchyOutgoingCallsParams) CallHierarchyOutgoingCall(org.eclipse.lsp4j.CallHierarchyOutgoingCall) Collectors.mapping(java.util.stream.Collectors.mapping) Position(org.eclipse.lsp4j.Position) URI(java.net.URI) CallHierarchyIncomingCallsParams(org.eclipse.lsp4j.CallHierarchyIncomingCallsParams) CallHierarchyPrepareParams(org.eclipse.lsp4j.CallHierarchyPrepareParams) Collections(java.util.Collections) CallHierarchyIncomingCall(org.eclipse.lsp4j.CallHierarchyIncomingCall) Position(org.eclipse.lsp4j.Position) Reference(com.github._1c_syntax.bsl.languageserver.references.Reference) CallHierarchyItem(org.eclipse.lsp4j.CallHierarchyItem) URI(java.net.URI)

Example 2 with ReferenceIndex

use of com.github._1c_syntax.bsl.languageserver.references.ReferenceIndex in project bsl-language-server by 1c-syntax.

the class CallHierarchyProvider method outgoingCalls.

public List<CallHierarchyOutgoingCall> outgoingCalls(DocumentContext documentContext, CallHierarchyOutgoingCallsParams params) {
    URI uri = documentContext.getUri();
    Position position = params.getItem().getSelectionRange().getStart();
    return referenceResolver.findReference(uri, position).flatMap(Reference::getSourceDefinedSymbol).stream().map(referenceIndex::getReferencesFrom).flatMap(Collection::stream).filter(Reference::isSourceDefinedSymbolReference).collect(groupingBy(reference -> reference.getSourceDefinedSymbol().orElseThrow(), mapping(Reference::getSelectionRange, toCollection(ArrayList::new)))).entrySet().stream().map(entry -> new CallHierarchyOutgoingCall(getCallHierarchyItem(entry.getKey()), entry.getValue())).collect(Collectors.toList());
}
Also used : ReferenceResolver(com.github._1c_syntax.bsl.languageserver.references.ReferenceResolver) Collection(java.util.Collection) RequiredArgsConstructor(lombok.RequiredArgsConstructor) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) MdoRefBuilder(com.github._1c_syntax.bsl.languageserver.utils.MdoRefBuilder) DocumentContext(com.github._1c_syntax.bsl.languageserver.context.DocumentContext) SourceDefinedSymbol(com.github._1c_syntax.bsl.languageserver.context.symbol.SourceDefinedSymbol) Collectors(java.util.stream.Collectors) CallHierarchyItem(org.eclipse.lsp4j.CallHierarchyItem) ArrayList(java.util.ArrayList) Reference(com.github._1c_syntax.bsl.languageserver.references.Reference) CallHierarchyIncomingCall(org.eclipse.lsp4j.CallHierarchyIncomingCall) ReferenceIndex(com.github._1c_syntax.bsl.languageserver.references.ReferenceIndex) Collectors.toCollection(java.util.stream.Collectors.toCollection) Component(org.springframework.stereotype.Component) List(java.util.List) CallHierarchyOutgoingCallsParams(org.eclipse.lsp4j.CallHierarchyOutgoingCallsParams) CallHierarchyOutgoingCall(org.eclipse.lsp4j.CallHierarchyOutgoingCall) Collectors.mapping(java.util.stream.Collectors.mapping) Position(org.eclipse.lsp4j.Position) URI(java.net.URI) CallHierarchyIncomingCallsParams(org.eclipse.lsp4j.CallHierarchyIncomingCallsParams) CallHierarchyPrepareParams(org.eclipse.lsp4j.CallHierarchyPrepareParams) Collections(java.util.Collections) Position(org.eclipse.lsp4j.Position) CallHierarchyOutgoingCall(org.eclipse.lsp4j.CallHierarchyOutgoingCall) Reference(com.github._1c_syntax.bsl.languageserver.references.Reference) Collection(java.util.Collection) Collectors.toCollection(java.util.stream.Collectors.toCollection) URI(java.net.URI)

Aggregations

DocumentContext (com.github._1c_syntax.bsl.languageserver.context.DocumentContext)2 SourceDefinedSymbol (com.github._1c_syntax.bsl.languageserver.context.symbol.SourceDefinedSymbol)2 Reference (com.github._1c_syntax.bsl.languageserver.references.Reference)2 ReferenceIndex (com.github._1c_syntax.bsl.languageserver.references.ReferenceIndex)2 ReferenceResolver (com.github._1c_syntax.bsl.languageserver.references.ReferenceResolver)2 MdoRefBuilder (com.github._1c_syntax.bsl.languageserver.utils.MdoRefBuilder)2 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 Collections (java.util.Collections)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 Collectors.groupingBy (java.util.stream.Collectors.groupingBy)2 Collectors.mapping (java.util.stream.Collectors.mapping)2 Collectors.toCollection (java.util.stream.Collectors.toCollection)2 RequiredArgsConstructor (lombok.RequiredArgsConstructor)2 CallHierarchyIncomingCall (org.eclipse.lsp4j.CallHierarchyIncomingCall)2 CallHierarchyIncomingCallsParams (org.eclipse.lsp4j.CallHierarchyIncomingCallsParams)2 CallHierarchyItem (org.eclipse.lsp4j.CallHierarchyItem)2 CallHierarchyOutgoingCall (org.eclipse.lsp4j.CallHierarchyOutgoingCall)2