Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
DedSec256 committed Feb 13, 2025
1 parent 4b4ae9d commit d5d6089
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ type private PatternsHighlightingProcess(fsFile, settingsStore: IContextBoundSet
if isNull symbol then ValueNone else

let fcsType = symbol.FullType
let pattern, fcsType = fixIfOptionalParameter refPat fcsType
let pattern, fcsType = tryGetOuterOptionalParameterAndItsType refPat fcsType
let range = pattern.GetNavigationRange().EndOffsetRange()

createTypeHintHighlighting fcsType defaultDisplayContext range pushToHintMode actionsProvider false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ module SpecifyTypes =
parenPat.SetPattern(pattern) |> ignore
parenPat :> IFSharpPattern

let specifyPattern displayContext (fcsType: FSharpType) (pattern: IFSharpPattern) =
let specifyPatternType displayContext (fcsType: FSharpType) (pattern: IFSharpPattern) =
let pattern, fcsType =
match pattern with
| :? IReferencePat as pattern -> FcsTypeUtil.fixIfOptionalParameter pattern fcsType
| :? IReferencePat as pattern -> FcsTypeUtil.tryGetOuterOptionalParameterAndItsType pattern fcsType
| _ -> pattern, fcsType

let pattern = pattern.IgnoreParentParens()
Expand Down Expand Up @@ -107,7 +107,7 @@ type FunctionAnnotationAction(dataProvider: FSharpContextActionDataProvider) =
| TupleLikePattern pat when isTopLevel ->
specifyParameterTypes fcsType.GenericArguments pat.Patterns false
| pattern ->
SpecifyTypes.specifyPattern displayContext fcsType pattern
SpecifyTypes.specifyPatternType displayContext fcsType pattern

specifyParameterTypes types parameters true

Expand Down Expand Up @@ -186,4 +186,4 @@ type PatternAnnotationAction(dataProvider: FSharpContextActionDataProvider) =
let mfv = symbolUse.Symbol :?> FSharpMemberOrFunctionOrValue
let displayContext = symbolUse.DisplayContext

SpecifyTypes.specifyPattern displayContext mfv.FullType pattern
SpecifyTypes.specifyPatternType displayContext mfv.FullType pattern
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ type SpecifyParameterBaseTypeFix(refExpr: IReferenceExpr, typeUsage: ITypeUsage)
use writeCookie = WriteLockCookie.Create(pat.IsPhysical())

let baseType, displayContext = baseType.Value
SpecifyTypes.specifyPattern displayContext baseType pat
SpecifyTypes.specifyPatternType displayContext baseType pat

override this.Execute(solution, textControl) =
let fcsEntity, displayContext = getFcsEntity typeUsage |> Option.get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ type SpecifyParameterTypeFix(qualifiedExpr: IQualifiedExpr) =

override this.SpecifyType(decl, mfv, d) =
let decl = decl :?> ILocalReferencePat
SpecifyTypes.specifyPattern d mfv.FullType decl
SpecifyTypes.specifyPatternType d mfv.FullType decl


type SpecifyPropertyTypeFix(qualifiedExpr: IQualifiedExpr) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ let getFunctionTypeArgs includeReturnType fcsType =

loop fcsType [] |> List.rev

let fixIfOptionalParameter (pattern: IReferencePat) fcsType =
let tryGetOuterOptionalParameterAndItsType (pattern: IReferencePat) fcsType =
let optionalValPat = OptionalValPatNavigator.GetByPattern(pattern)
if isNotNull optionalValPat && isOption fcsType then (optionalValPat : IFSharpPattern), fcsType.GenericArguments[0]
else pattern, fcsType

0 comments on commit d5d6089

Please sign in to comment.