未验证 提交 8ba5a403 编写于 作者: E Eugene Auduchinok 提交者: GitHub

Symbols: add more APIs (#13824)

* Symbols: add BasicQualifiedName, FSharpType.ErasedType
Co-authored-by: NTomas Grosup <tomasgrosup@microsoft.com>
上级 bc88b51b
......@@ -433,18 +433,27 @@ type FSharpEntity(cenv: SymbolEnv, entity: EntityRef) =
Some (buildAccessPath (Some cp))
| Some _ -> None
member x.QualifiedName =
member x.CompiledRepresentation =
checkIsResolved()
let fail() = invalidOp (sprintf "the type '%s' does not have a qualified name" x.LogicalName)
let fail () =
invalidOp $"the type '{x.LogicalName}' does not have a qualified name"
#if !NO_TYPEPROVIDERS
if entity.IsTypeAbbrev || entity.IsProvidedErasedTycon || entity.IsNamespace then fail()
#else
if entity.IsTypeAbbrev || entity.IsNamespace then fail()
if entity.IsTypeAbbrev || entity.IsProvidedErasedTycon || entity.IsNamespace then fail ()
#else
if entity.IsTypeAbbrev || entity.IsNamespace then fail ()
#endif
match entity.CompiledRepresentation with
| CompiledTypeRepr.ILAsmNamed(tref, _, _) -> tref.QualifiedName
| CompiledTypeRepr.ILAsmOpen _ -> fail()
match entity.CompiledRepresentation with
| CompiledTypeRepr.ILAsmNamed(tref, _, _) -> tref
| CompiledTypeRepr.ILAsmOpen _ -> fail ()
member x.QualifiedName =
x.CompiledRepresentation.QualifiedName
member x.BasicQualifiedName =
x.CompiledRepresentation.BasicQualifiedName
member x.FullName =
checkIsResolved()
match x.TryFullName with
......@@ -746,6 +755,10 @@ type FSharpEntity(cenv: SymbolEnv, entity: EntityRef) =
| None -> invalidOp "not a type abbreviation"
| Some ty -> FSharpType(cenv, ty)
member _.AsType() =
let ty = generalizedTyconRef cenv.g entity
FSharpType(cenv, ty)
override _.Attributes =
if isUnresolved() then makeReadOnlyCollection [] else
GetAttribInfosOfEntity cenv.g cenv.amap range0 entity
......@@ -2250,6 +2263,11 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
| V vref -> isForallFunctionTy cenv.g vref.Type
| _ -> false
member x.IsRefCell =
match d with
| V vref -> not vref.IsCtorThisVal && isRefCellTy cenv.g vref.Type
| _ -> false
override x.Equals(other: obj) =
box x === other ||
match other with
......@@ -2483,6 +2501,21 @@ type FSharpType(cenv, ty:TType) =
GetSuperTypeOfType cenv.g cenv.amap range0 ty
|> Option.map (fun ty -> FSharpType(cenv, ty))
member x.ErasedType=
FSharpType(cenv, stripTyEqnsWrtErasure EraseAll cenv.g ty)
member x.BasicQualifiedName =
let fail () =
invalidOp $"the type '{x}' does not have a qualified name"
protect <| fun () ->
match stripTyparEqns ty with
| TType_app(tcref, _, _) ->
match tcref.CompiledRepresentation with
| CompiledTypeRepr.ILAsmNamed(tref, _, _) -> tref.BasicQualifiedName
| CompiledTypeRepr.ILAsmOpen _ -> fail ()
| _ -> fail ()
member _.Instantiate(instantiation:(FSharpGenericParameter * FSharpType) list) =
let resTy = instType (instantiation |> List.map (fun (tyv, ty) -> tyv.TypeParameter, ty.Type)) ty
FSharpType(cenv, resTy)
......
......@@ -217,6 +217,9 @@ type FSharpEntity =
/// Get the fully qualified name of the type or module
member QualifiedName: string
/// The fully qualified name of the type or module without strong assembly name.
member BasicQualifiedName: string
/// Get the full name of the type or module
member FullName: string
......@@ -346,6 +349,9 @@ type FSharpEntity =
/// Get the type abbreviated by an F# type abbreviation
member AbbreviatedType: FSharpType
/// Instantiates FSharpType
member AsType: unit -> FSharpType
/// Get the cases of a union type
member UnionCases: IList<FSharpUnionCase>
......@@ -933,8 +939,8 @@ type FSharpMemberOrFunctionOrValue =
/// Indicated if this is a value compiled to a method
member IsValCompiledAsMethod: bool
/// Indicates if this is a function
member IsFunction: bool
/// Indicates if this is a ref cell
member IsRefCell: bool
/// Indicated if this is a value
member IsValue: bool
......@@ -1108,6 +1114,12 @@ type FSharpType =
/// if it is an instantiation of a generic type.
member BaseType: FSharpType option
/// Canonical form of the type with abbreviations, measures, and F# tuples and functions erased.
member ErasedType: FSharpType
/// The fully qualified name of the type or module without strong assembly name.
member BasicQualifiedName: string
/// Adjust the type by removing any occurrences of type inference variables, replacing them
/// systematically with lower-case type inference variables such as <c>'a</c>.
static member Prettify: ty: FSharpType -> FSharpType
......
......@@ -4514,6 +4514,7 @@ FSharp.Compiler.Symbols.FSharpEntity: FSharp.Compiler.Symbols.FSharpAccessibilit
FSharp.Compiler.Symbols.FSharpEntity: FSharp.Compiler.Symbols.FSharpDelegateSignature FSharpDelegateSignature
FSharp.Compiler.Symbols.FSharpEntity: FSharp.Compiler.Symbols.FSharpDelegateSignature get_FSharpDelegateSignature()
FSharp.Compiler.Symbols.FSharpEntity: FSharp.Compiler.Symbols.FSharpType AbbreviatedType
FSharp.Compiler.Symbols.FSharpEntity: FSharp.Compiler.Symbols.FSharpType AsType()
FSharp.Compiler.Symbols.FSharpEntity: FSharp.Compiler.Symbols.FSharpType get_AbbreviatedType()
FSharp.Compiler.Symbols.FSharpEntity: FSharp.Compiler.Symbols.FSharpXmlDoc XmlDoc
FSharp.Compiler.Symbols.FSharpEntity: FSharp.Compiler.Symbols.FSharpXmlDoc get_XmlDoc()
......@@ -4559,6 +4560,7 @@ FSharp.Compiler.Symbols.FSharpEntity: System.Collections.Generic.IList`1[FSharp.
FSharp.Compiler.Symbols.FSharpEntity: System.Collections.Generic.IList`1[FSharp.Compiler.Symbols.FSharpUnionCase] UnionCases
FSharp.Compiler.Symbols.FSharpEntity: System.Collections.Generic.IList`1[FSharp.Compiler.Symbols.FSharpUnionCase] get_UnionCases()
FSharp.Compiler.Symbols.FSharpEntity: System.String AccessPath
FSharp.Compiler.Symbols.FSharpEntity: System.String BasicQualifiedName
FSharp.Compiler.Symbols.FSharpEntity: System.String CompiledName
FSharp.Compiler.Symbols.FSharpEntity: System.String DisplayName
FSharp.Compiler.Symbols.FSharpEntity: System.String FullName
......@@ -4567,6 +4569,7 @@ FSharp.Compiler.Symbols.FSharpEntity: System.String QualifiedName
FSharp.Compiler.Symbols.FSharpEntity: System.String ToString()
FSharp.Compiler.Symbols.FSharpEntity: System.String XmlDocSig
FSharp.Compiler.Symbols.FSharpEntity: System.String get_AccessPath()
FSharp.Compiler.Symbols.FSharpEntity: System.String get_BasicQualifiedName()
FSharp.Compiler.Symbols.FSharpEntity: System.String get_CompiledName()
FSharp.Compiler.Symbols.FSharpEntity: System.String get_DisplayName()
FSharp.Compiler.Symbols.FSharpEntity: System.String get_FullName()
......@@ -4872,6 +4875,7 @@ FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean IsOverrideOrExpli
FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean IsProperty
FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean IsPropertyGetterMethod
FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean IsPropertySetterMethod
FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean IsRefCell
FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean IsTypeFunction
FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean IsUnresolved
FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean IsValCompiledAsMethod
......@@ -4903,6 +4907,7 @@ FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean get_IsOverrideOrE
FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean get_IsProperty()
FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean get_IsPropertyGetterMethod()
FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean get_IsPropertySetterMethod()
FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean get_IsRefCell()
FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean get_IsTypeFunction()
FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean get_IsUnresolved()
FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue: Boolean get_IsValCompiledAsMethod()
......@@ -5119,7 +5124,9 @@ FSharp.Compiler.Symbols.FSharpType: FSharp.Compiler.Symbols.FSharpType Abbreviat
FSharp.Compiler.Symbols.FSharpType: FSharp.Compiler.Symbols.FSharpType Instantiate(Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[FSharp.Compiler.Symbols.FSharpGenericParameter,FSharp.Compiler.Symbols.FSharpType]])
FSharp.Compiler.Symbols.FSharpType: FSharp.Compiler.Symbols.FSharpType Prettify(FSharp.Compiler.Symbols.FSharpType)
FSharp.Compiler.Symbols.FSharpType: FSharp.Compiler.Symbols.FSharpType StripAbbreviations()
FSharp.Compiler.Symbols.FSharpType: FSharp.Compiler.Symbols.FSharpType ErasedType
FSharp.Compiler.Symbols.FSharpType: FSharp.Compiler.Symbols.FSharpType get_AbbreviatedType()
FSharp.Compiler.Symbols.FSharpType: FSharp.Compiler.Symbols.FSharpType get_ErasedType()
FSharp.Compiler.Symbols.FSharpType: FSharp.Compiler.Text.TaggedText[] FormatLayout(FSharp.Compiler.Symbols.FSharpDisplayContext)
FSharp.Compiler.Symbols.FSharpType: FSharp.Compiler.Text.TaggedText[] FormatLayoutWithConstraints(FSharp.Compiler.Symbols.FSharpDisplayContext)
FSharp.Compiler.Symbols.FSharpType: Int32 GetHashCode()
......@@ -5132,9 +5139,11 @@ FSharp.Compiler.Symbols.FSharpType: System.Collections.Generic.IList`1[FSharp.Co
FSharp.Compiler.Symbols.FSharpType: System.Collections.Generic.IList`1[FSharp.Compiler.Symbols.FSharpType] get_AllInterfaces()
FSharp.Compiler.Symbols.FSharpType: System.Collections.Generic.IList`1[FSharp.Compiler.Symbols.FSharpType] get_GenericArguments()
FSharp.Compiler.Symbols.FSharpType: System.Collections.Generic.IList`1[System.Collections.Generic.IList`1[FSharp.Compiler.Symbols.FSharpParameter]] Prettify(System.Collections.Generic.IList`1[System.Collections.Generic.IList`1[FSharp.Compiler.Symbols.FSharpParameter]])
FSharp.Compiler.Symbols.FSharpType: System.String BasicQualifiedName
FSharp.Compiler.Symbols.FSharpType: System.String Format(FSharp.Compiler.Symbols.FSharpDisplayContext)
FSharp.Compiler.Symbols.FSharpType: System.String FormatWithConstraints(FSharp.Compiler.Symbols.FSharpDisplayContext)
FSharp.Compiler.Symbols.FSharpType: System.String ToString()
FSharp.Compiler.Symbols.FSharpType: System.String get_BasicQualifiedName()
FSharp.Compiler.Symbols.FSharpType: System.Tuple`2[System.Collections.Generic.IList`1[System.Collections.Generic.IList`1[FSharp.Compiler.Symbols.FSharpParameter]],FSharp.Compiler.Symbols.FSharpParameter] Prettify(System.Collections.Generic.IList`1[System.Collections.Generic.IList`1[FSharp.Compiler.Symbols.FSharpParameter]], FSharp.Compiler.Symbols.FSharpParameter)
FSharp.Compiler.Symbols.FSharpUnionCase
FSharp.Compiler.Symbols.FSharpUnionCase: Boolean Equals(System.Object)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册