Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse linq expr variable type #214

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/CSharpLanguageServer/DocumentationUtil.fs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
namespace CSharpLanguageServer

open System
open System.Linq
open System.Xml.Linq
open System.Reflection

open Microsoft.CodeAnalysis
open Microsoft.CodeAnalysis.CSharp.Syntax

open CSharpLanguageServer.Conversions

Expand Down Expand Up @@ -179,6 +182,24 @@ module DocumentationUtil =
|> Option.map (fun a -> a.Name)
|> Option.defaultValue ""

match sym with
| :? IRangeVariableSymbol as rangeVarSym ->
let underlyingSymList = rangeVarSym.GetType().GetMember("_underlying", BindingFlags.Instance|||BindingFlags.NonPublic)
let underlyingSymType = underlyingSymList.Single() :?> FieldInfo |> _.FieldType

(sprintf "rangeVarSym.Type=%s; underlyingSym=%s" (rangeVarSym.GetType() |> string)
(underlyingSymType |> string))

//(sprintf "syntax=%s; type=%s" (syntax |> string) (syntax.GetType() |> string))
(*
let typeInfo = semanticModel.GetTypeInfo(syntax)
(sprintf "typeInfo=%s; typeInfo.Type=\"%s\"" (typeInfo |> string) (typeInfo.Type |> string))
let typeName = typeInfo.Type.ToDisplayString()
"o"
(sprintf "kind=%s, symbolName=%s, symAssemblyName=%s; typeName=%s" (string sym.Kind) symbolName symAssemblyName typeName)
*)
| _ -> "x"
(*
let symbolInfoLines =
match symbolName, symAssemblyName with
| "", "" -> []
Expand All @@ -202,3 +223,4 @@ module DocumentationUtil =
)
|> Seq.append symbolInfoLines
|> (fun ss -> String.Join("\n", ss))
*)
8 changes: 7 additions & 1 deletion src/CSharpLanguageServer/Handlers/Hover.fs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,15 @@ module Hover =
RegisterOptions = registerOptions |> serialize |> Some }

let handle (context: ServerRequestContext) (p: TextDocumentPositionParams) : AsyncLspResult<Hover option> = async {
let logMessage = context.WindowShowMessage

match! context.FindSymbol' p.TextDocument.Uri p.Position with
| None -> return None |> success
| None ->
do! logMessage "no symbol here!"
return None |> success

| Some (symbol, doc) ->
do! logMessage (sprintf "have symbol %s in doc %s" (string symbol) (string doc))
let! ct = Async.CancellationToken
let! semanticModel = doc.GetSemanticModelAsync(ct) |> Async.AwaitTask
let content = DocumentationUtil.markdownDocForSymbolWithSignature symbol semanticModel
Expand Down
Loading