From 84121aed8db55cff9725b6ac00e5f5add2832cb0 Mon Sep 17 00:00:00 2001 From: nojaf Date: Tue, 11 Jul 2023 21:31:20 +0200 Subject: [PATCH] Remove Obsolete code. --- .../CodeFixes/AddExplicitTypeAnnotation.fs | 63 +------------------ 1 file changed, 2 insertions(+), 61 deletions(-) diff --git a/src/FsAutoComplete/CodeFixes/AddExplicitTypeAnnotation.fs b/src/FsAutoComplete/CodeFixes/AddExplicitTypeAnnotation.fs index d84e20e69..ff6cb423a 100644 --- a/src/FsAutoComplete/CodeFixes/AddExplicitTypeAnnotation.fs +++ b/src/FsAutoComplete/CodeFixes/AddExplicitTypeAnnotation.fs @@ -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 -[] //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 - -[] //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 = @@ -113,7 +54,7 @@ let (|FunctionBindingWithMissingTypes|_|) = /// /// /// -/// Expected to be between the start of the binding (from the keyword) and the end of the function name. +/// Expected to be between the start of the leading keyword and the end of the function name. let tryFunctionIdentifier (parseAndCheck: ParseAndCheckResults) textDocument sourceText lineStr cursorPos = let bindingInfo = SyntaxTraversal.Traverse( @@ -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