Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions src/Compiler/Service/ServiceInterfaceStubGenerator.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ open System
open System.Diagnostics
open Internal.Utilities.Library
open FSharp.Compiler.CodeAnalysis
open FSharp.Compiler.EditorServices.ParsedInput
open FSharp.Compiler.Symbols
open FSharp.Compiler.Syntax
open FSharp.Compiler.SyntaxTreeOps
Expand Down Expand Up @@ -47,13 +48,6 @@ module internal CodeGenerationUtils =
stringWriter.Dispose()
indentWriter.Dispose()

/// An recursive pattern that collect all sequential expressions to avoid StackOverflowException
let rec (|Sequentials|_|) =
function
| SynExpr.Sequential (_, _, e, Sequentials es, _) -> Some(e :: es)
| SynExpr.Sequential (_, _, e1, e2, _) -> Some [ e1; e2 ]
| _ -> None

/// Represent environment where a captured identifier should be renamed
type NamesWithIndices = Map<string, Set<int>>

Expand Down
27 changes: 13 additions & 14 deletions src/Compiler/Service/ServiceParsedInputOps.fs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,19 @@ module Entity =

module ParsedInput =

/// A pattern that collects all sequential expressions to avoid StackOverflowException
let internal (|Sequentials|_|) expr =

let rec collect expr acc =
match expr with
| SynExpr.Sequential (_, _, e1, (SynExpr.Sequential _ as e2), _) -> collect e2 (e1 :: acc)
| SynExpr.Sequential (_, _, e1, e2, _) -> e2 :: e1 :: acc
| _ -> acc

match collect expr [] with
| [] -> None
| exprs -> Some(List.rev exprs)

let emptyStringSet = HashSet<string>()

let GetRangeOfExprLeftOfDot (pos: pos, parsedInput) =
Expand Down Expand Up @@ -558,13 +571,6 @@ module ParsedInput =
| SynArgPats.Pats ps -> ps
| SynArgPats.NamePatPairs (pats = xs) -> List.map (fun (_, _, pat) -> pat) xs

/// A recursive pattern that collect all sequential expressions to avoid StackOverflowException
let rec (|Sequentials|_|) expr =
match expr with
| SynExpr.Sequential (_, _, e, Sequentials es, _) -> Some(e :: es)
| SynExpr.Sequential (_, _, e1, e2, _) -> Some [ e1; e2 ]
| _ -> None

let inline isPosInRange range = rangeContainsPos range pos

let inline ifPosInRange range f =
Expand Down Expand Up @@ -1557,13 +1563,6 @@ module ParsedInput =
SyntaxTraversal.Traverse(pos, parsedInput, visitor) |> ignore
path |> List.map (fun x -> x.idText) |> List.toArray

/// An recursive pattern that collect all sequential expressions to avoid StackOverflowException
let rec (|Sequentials|_|) expr =
match expr with
| SynExpr.Sequential (_, _, e, Sequentials es, _) -> Some(e :: es)
| SynExpr.Sequential (_, _, e1, e2, _) -> Some [ e1; e2 ]
| _ -> None

let (|ConstructorPats|) pats =
match pats with
| SynArgPats.Pats ps -> ps
Expand Down
3 changes: 3 additions & 0 deletions src/Compiler/Service/ServiceParsedInputOps.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ type public InsertionContextEntity =

/// Operations querying the entire syntax tree
module public ParsedInput =
/// A pattern that collects all sequential expressions to avoid StackOverflowException
val internal (|Sequentials|_|): SynExpr -> SynExpr list option

val TryFindExpressionASTLeftOfDotLeftOfCursor: pos: pos * parsedInput: ParsedInput -> (pos * bool) option

val GetRangeOfExprLeftOfDot: pos: pos * parsedInput: ParsedInput -> range option
Expand Down