diff --git a/src/CSharpLanguageServer/Documentation.fs b/src/CSharpLanguageServer/Documentation.fs index 0bd9219c..d78db199 100644 --- a/src/CSharpLanguageServer/Documentation.fs +++ b/src/CSharpLanguageServer/Documentation.fs @@ -178,7 +178,7 @@ let markdownDocForSymbol (sym: ISymbol) = |> (fun ss -> String.Join("\n", ss)) let markdownDocForSymbolWithSignature (sym: ISymbol) (semanticModel: SemanticModel) pos = - let symbolInfo = symbolToLspSymbolInformation true sym (Some semanticModel) (Some pos) + let symbolInfo = symbolToLspSymbolInformation sym (Some semanticModel) (Some pos) let symAssemblyName = sym.ContainingAssembly diff --git a/src/CSharpLanguageServer/RoslynHelpers.fs b/src/CSharpLanguageServer/RoslynHelpers.fs index 34bf91ce..9389abca 100644 --- a/src/CSharpLanguageServer/RoslynHelpers.fs +++ b/src/CSharpLanguageServer/RoslynHelpers.fs @@ -237,11 +237,12 @@ let formatSymbol (sym: ISymbol) | false, _, _ -> sym.Name let symbolToLspSymbolInformation - showAttributes (symbol: ISymbol) (semanticModel: SemanticModel option) (pos: int option) : Types.SymbolInformation = + let showAttributes = true + let (symbolName, symbolKind) = match symbol with | :? ILocalSymbol as ls -> @@ -282,7 +283,7 @@ let symbolToLspSymbolInformation ContainerName = None } -type DocumentSymbolCollector (documentUri, semanticModel: SemanticModel, showAttributes) = +type DocumentSymbolCollector (documentUri, semanticModel: SemanticModel) = inherit CSharpSyntaxWalker(SyntaxWalkerDepth.Token) let mutable collectedSymbols: Types.SymbolInformation list = [] @@ -293,7 +294,13 @@ type DocumentSymbolCollector (documentUri, semanticModel: SemanticModel, showAtt Range = identifier.GetLocation().GetLineSpan().Span |> lspRangeForRoslynLinePosSpan } - let rawSymbol = symbolToLspSymbolInformation showAttributes symbol None None + let identifierStartPos = identifier.GetLocation().SourceSpan.Start + + let rawSymbol = symbolToLspSymbolInformation + symbol + (Some semanticModel) + (Some identifierStartPos) + let symbol = { rawSymbol with Location = identifierLocation } collectedSymbols <- symbol :: collectedSymbols @@ -453,8 +460,10 @@ let findSymbolsInSolution (solution: Solution) symbolsFound <- (List.ofSeq symbols) @ symbolsFound - return Seq.map (fun s -> symbolToLspSymbolInformation true s None None) symbolsFound - |> List.ofSeq + let getSymbolInformation s = + symbolToLspSymbolInformation s None None + + return symbolsFound |> Seq.map getSymbolInformation |> List.ofSeq } let instantiateRoslynProviders<'ProviderType> (isValidProvider: Type -> bool) = diff --git a/src/CSharpLanguageServer/Server.fs b/src/CSharpLanguageServer/Server.fs index e28cf7e1..ad4825ea 100644 --- a/src/CSharpLanguageServer/Server.fs +++ b/src/CSharpLanguageServer/Server.fs @@ -671,8 +671,7 @@ let setupServerHandlers options (lspClient: LspClient) = | Some doc -> let! ct = Async.CancellationToken let! semanticModel = doc.GetSemanticModelAsync(ct) |> Async.AwaitTask - let showAttributes = false - let collector = DocumentSymbolCollector(p.TextDocument.Uri, semanticModel, showAttributes) + let collector = DocumentSymbolCollector(p.TextDocument.Uri, semanticModel) let! syntaxTree = doc.GetSyntaxTreeAsync(ct) |> Async.AwaitTask collector.Visit(syntaxTree.GetRoot()) diff --git a/src/Ionide.LanguageServerProtocol/LanguageServerProtocol.fs b/src/Ionide.LanguageServerProtocol/LanguageServerProtocol.fs index 8491f452..7ebc4364 100644 --- a/src/Ionide.LanguageServerProtocol/LanguageServerProtocol.fs +++ b/src/Ionide.LanguageServerProtocol/LanguageServerProtocol.fs @@ -552,4 +552,4 @@ module Client = return () } - |> Async.Start \ No newline at end of file + |> Async.Start