Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* go to C# symbols * fix tests * cleanup * fix tests * support field, events and constructors * fix tests * implement IVsSymbolicNavigationNotify * cleanup * fix * cleanup * Improve package definition specs fro F# VS Package * Fixed some bugs with nested types with fields/events * fix compilation * use AppTy AP * Add support for overloaded methods, generic methods, generic (nested) classes, constructors * Jump to property definition instead of getter/setter * Add ExternalSymbol to FSharp.Compiler.Service.fsproj * Fix FSharp.Compiler.Private.BuildFromSource.fsproj * address code review
- Loading branch information
1 parent
cd23839
commit 9606209
Showing
14 changed files
with
417 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
namespace Microsoft.FSharp.Compiler.SourceCodeServices | ||
|
||
open FSharp.Reflection | ||
open Microsoft.FSharp.Compiler.AbstractIL.IL | ||
open System.Diagnostics | ||
|
||
module private Option = | ||
|
||
let ofOptionList (xs : 'a option list) : 'a list option = | ||
|
||
if xs |> List.forall Option.isSome then | ||
xs |> List.map Option.get |> Some | ||
else | ||
None | ||
|
||
/// Represents a type in an external (non F#) assembly. | ||
[<RequireQualifiedAccess>] | ||
type ExternalType = | ||
/// Type defined in non-F# assembly. | ||
| Type of fullName: string * genericArgs: ExternalType list | ||
/// Array of type that is defined in non-F# assembly. | ||
| Array of inner: ExternalType | ||
/// Pointer defined in non-F# assembly. | ||
| Pointer of inner: ExternalType | ||
/// Type variable defined in non-F# assembly. | ||
| TypeVar of typeName: string | ||
override this.ToString() = | ||
match this with | ||
| Type (name, genericArgs) -> | ||
match genericArgs with | ||
| [] -> "" | ||
| args -> | ||
args | ||
|> List.map (sprintf "%O") | ||
|> String.concat ", " | ||
|> sprintf "<%s>" | ||
|> sprintf "%s%s" name | ||
| Array inner -> sprintf "%O[]" inner | ||
| Pointer inner -> sprintf "&%O" inner | ||
| TypeVar name -> sprintf "'%s" name | ||
|
||
module ExternalType = | ||
let rec internal tryOfILType (typeVarNames: string array) (ilType: ILType) = | ||
|
||
match ilType with | ||
| ILType.Array (_, inner) -> | ||
tryOfILType typeVarNames inner |> Option.map ExternalType.Array | ||
| ILType.Boxed tyspec | ||
| ILType.Value tyspec -> | ||
tyspec.GenericArgs | ||
|> List.map (tryOfILType typeVarNames) | ||
|> Option.ofOptionList | ||
|> Option.map (fun genericArgs -> ExternalType.Type (tyspec.FullName, genericArgs)) | ||
| ILType.Ptr inner -> | ||
tryOfILType typeVarNames inner |> Option.map ExternalType.Pointer | ||
| ILType.TypeVar ordinal -> | ||
typeVarNames | ||
|> Array.tryItem (int ordinal) | ||
|> Option.map (fun typeVarName -> ExternalType.TypeVar typeVarName) | ||
| _ -> | ||
None | ||
|
||
[<RequireQualifiedAccess>] | ||
type ParamTypeSymbol = | ||
| Param of ExternalType | ||
| Byref of ExternalType | ||
override this.ToString () = | ||
match this with | ||
| Param t -> t.ToString() | ||
| Byref t -> sprintf "ref %O" t | ||
|
||
module ParamTypeSymbol = | ||
let rec internal tryOfILType (typeVarNames : string array) = | ||
function | ||
| ILType.Byref inner -> ExternalType.tryOfILType typeVarNames inner |> Option.map ParamTypeSymbol.Byref | ||
| ilType -> ExternalType.tryOfILType typeVarNames ilType |> Option.map ParamTypeSymbol.Param | ||
|
||
let internal tryOfILTypes typeVarNames ilTypes = | ||
ilTypes |> List.map (tryOfILType typeVarNames) |> Option.ofOptionList | ||
|
||
[<RequireQualifiedAccess>] | ||
[<DebuggerDisplay "{ToDebuggerDisplay(),nq}">] | ||
type ExternalSymbol = | ||
| Type of fullName: string | ||
| Constructor of typeName: string * args: ParamTypeSymbol list | ||
| Method of typeName: string * name: string * paramSyms: ParamTypeSymbol list * genericArity: int | ||
| Field of typeName: string * name: string | ||
| Event of typeName: string * name: string | ||
| Property of typeName: string * name: string | ||
override this.ToString () = | ||
match this with | ||
| Type fullName -> fullName | ||
| Constructor (typeName, args) -> | ||
args | ||
|> List.map (sprintf "%O") | ||
|> String.concat ", " | ||
|> sprintf "%s..ctor(%s)" typeName | ||
| Method (typeName, name, args, genericArity) -> | ||
let genericAritySuffix = | ||
if genericArity > 0 then sprintf "`%d" genericArity | ||
else "" | ||
|
||
args | ||
|> List.map (sprintf "%O") | ||
|> String.concat ", " | ||
|> sprintf "%s.%s%s(%s)" typeName name genericAritySuffix | ||
| Field (typeName, name) | ||
| Event (typeName, name) | ||
| Property (typeName, name) -> | ||
sprintf "%s.%s" typeName name | ||
|
||
member internal this.ToDebuggerDisplay () = | ||
let caseInfo, _ = FSharpValue.GetUnionFields(this, typeof<ExternalSymbol>) | ||
sprintf "%s %O" caseInfo.Name this |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
namespace Microsoft.FSharp.Compiler.SourceCodeServices | ||
|
||
open FSharp.Reflection | ||
open Microsoft.FSharp.Compiler.AbstractIL.IL | ||
|
||
/// Represents a type in an external (non F#) assembly. | ||
[<RequireQualifiedAccess>] | ||
type ExternalType = | ||
/// Type defined in non-F# assembly. | ||
| Type of fullName: string * genericArgs: ExternalType list | ||
/// Array of type that is defined in non-F# assembly. | ||
| Array of inner: ExternalType | ||
/// Pointer defined in non-F# assembly. | ||
| Pointer of inner: ExternalType | ||
/// Type variable defined in non-F# assembly. | ||
| TypeVar of typeName: string | ||
override ToString : unit -> string | ||
|
||
module ExternalType = | ||
val internal tryOfILType : string array -> ILType -> ExternalType option | ||
|
||
|
||
/// Represents the type of a single method parameter | ||
[<RequireQualifiedAccess>] | ||
type ParamTypeSymbol = | ||
| Param of ExternalType | ||
| Byref of ExternalType | ||
override ToString : unit -> string | ||
|
||
module ParamTypeSymbol = | ||
val internal tryOfILType : string array -> ILType -> ParamTypeSymbol option | ||
val internal tryOfILTypes : string array -> ILType list -> ParamTypeSymbol list option | ||
|
||
|
||
/// Represents a symbol in an external (non F#) assembly | ||
[<RequireQualifiedAccess>] | ||
type ExternalSymbol = | ||
| Type of fullName: string | ||
| Constructor of typeName: string * args: ParamTypeSymbol list | ||
| Method of typeName: string * name: string * paramSyms: ParamTypeSymbol list * genericArity: int | ||
| Field of typeName: string * name: string | ||
| Event of typeName: string * name: string | ||
| Property of typeName: string * name: string | ||
override ToString : unit -> string | ||
member internal ToDebuggerDisplay : unit -> string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.