Skip to content

Commit

Permalink
Remove Obsolete code.
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf committed Jul 11, 2023
1 parent 111236a commit 84121ae
Showing 1 changed file with 2 additions and 61 deletions.
63 changes: 2 additions & 61 deletions src/FsAutoComplete/CodeFixes/AddExplicitTypeAnnotation.fs
Original file line number Diff line number Diff line change
@@ -1,81 +1,22 @@
module FsAutoComplete.CodeFix.AddExplicitTypeAnnotation

open System
open FsToolkit.ErrorHandling
open FsAutoComplete.CodeFix.Types
open Ionide.LanguageServerProtocol.Types
open FsAutoComplete
open FsAutoComplete.LspHelpers
open FSharp.Compiler.CodeAnalysis
open FSharp.Compiler.Symbols
open FSharp.Compiler.Syntax
open FSharp.Compiler.Text.Range
open FsAutoComplete.Core.InlayHints
open FsAutoComplete.Core


let toLspEdit ({ Pos = insertAt; Text = text }: HintInsertion) =
{ Range = fcsPosToProtocolRange insertAt
NewText = text }

let toLspEdits (edits: HintInsertion[]) = edits |> Array.map toLspEdit

[<Obsolete>] //TODO: correct?
let private isPositionContainedInUntypedImplicitCtorParameter input pos =
let result =
SyntaxTraversal.Traverse(
pos,
input,
{ new SyntaxVisitorBase<_>() with
member _.VisitModuleDecl(_, defaultTraverse, decl) =
match decl with
| SynModuleDecl.Types(typeDefns = typeDefns) ->
option {
let! ctorArgs =
typeDefns
|> List.tryPick (function
| SynTypeDefn(implicitConstructor = Some(SynMemberDefn.ImplicitCtor(ctorArgs = args))) when
rangeContainsPos args.Range pos
->
Some args
| _ -> None)

match ctorArgs with
| SynSimplePats.SimplePats(pats = pats) ->
let! pat = pats |> List.tryFind (fun pat -> rangeContainsPos pat.Range pos)

let rec tryGetUntypedIdent =
function
| SynSimplePat.Id(ident = ident) when rangeContainsPos ident.idRange pos -> Some ident
| SynSimplePat.Attrib(pat = pat) when rangeContainsPos pat.Range pos -> tryGetUntypedIdent pat
| SynSimplePat.Typed _
| _ -> None

return! tryGetUntypedIdent pat
| _ -> return! None
}
|> Option.orElseWith (fun _ -> defaultTraverse decl)
| _ -> defaultTraverse decl }
)

result.IsSome

[<Obsolete>] //TODO: correct
let private isSymbolToTriggerTypeAnnotation
(funcOrValue: FSharpMemberOrFunctionOrValue)
(symbolUse: FSharpSymbolUse)
(parseFileResults: FSharpParseFileResults)
=
(funcOrValue.IsValue
|| (funcOrValue.IsFunction
&& parseFileResults.IsBindingALambdaAtPosition symbolUse.Range.Start))
//TODO: check here for curried parameter? necessary? Or handled by `tryGetExplicitTypeInfo`?
&& not funcOrValue.IsMember
&& not funcOrValue.IsMemberThisValue
&& not funcOrValue.IsConstructorThisValue
&& not (PrettyNaming.IsOperatorDisplayName funcOrValue.DisplayName)


let title = "Add explicit type annotation"

let rec nonTypedParameterName p =
Expand Down Expand Up @@ -113,7 +54,7 @@ let (|FunctionBindingWithMissingTypes|_|) =
/// <param name="textDocument"></param>
/// <param name="sourceText"></param>
/// <param name="lineStr"></param>
/// <param name="cursorPos">Expected to be between the start of the binding (from the keyword) and the end of the function name.</param>
/// <param name="cursorPos">Expected to be between the start of the leading keyword and the end of the function name.</param>
let tryFunctionIdentifier (parseAndCheck: ParseAndCheckResults) textDocument sourceText lineStr cursorPos =
let bindingInfo =
SyntaxTraversal.Traverse(
Expand Down Expand Up @@ -209,7 +150,7 @@ let fix (getParseResultsForFile: GetParseResultsForFile) : CodeFix =
let filePath = codeActionParams.TextDocument.GetFilePath() |> Utils.normalizePath

let fcsStartPos = protocolPosToPos codeActionParams.Range.Start
let! (parseAndCheck, lineStr, sourceText) = getParseResultsForFile filePath fcsStartPos
let! parseAndCheck, lineStr, sourceText = getParseResultsForFile filePath fcsStartPos

let res =
InlayHints.tryGetDetailedExplicitTypeInfo
Expand Down

0 comments on commit 84121ae

Please sign in to comment.