Skip to content
This repository was archived by the owner on Jan 3, 2019. It is now read-only.

Commit

Permalink
Protect against failures when computing navigation items
Browse files Browse the repository at this point in the history
  • Loading branch information
dsyme committed Dec 29, 2013
1 parent 96868f8 commit 8f24798
Showing 1 changed file with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,18 @@ type FSharpTextEditorCompletion() =


open Microsoft.FSharp.Compiler.Range

[<AutoOpen>]
module Helper =
type UntypedParseInfo with
// GetNavigationItems is not 100% solid and throws occasional exceptions
member x.GetNavigationItemsDeclarationsSafe() =
try x.GetNavigationItems().Declarations
with _ ->
Debug.Assert(false, "couldn't update navigation items, ignoring")
[| |]


type FSharpPathExtension() =
inherit TextEditorExtension()

Expand Down Expand Up @@ -387,7 +399,10 @@ type FSharpPathExtension() =
let cursor = (docloc.Column, docloc.Line)
posGeq cursor start && posGeq finish cursor

let toplevel = ast.Untyped.GetNavigationItems().Declarations
let toplevel =
// GetNavigationItems is not 100% solid and throws occasional exceptions
try ast.Untyped.GetNavigationItemsDeclarationsSafe()
with _ -> [| |]

#if DEBUG
let allthings = [| for tl in toplevel do yield (tl.Declaration.Name, tl.Nested |> Array.map (fun n -> n.Name)) |]
Expand Down Expand Up @@ -454,13 +469,13 @@ and FSharpDataProvider(ext:FSharpPathExtension, tag) =
memberList.Clear()
match tag with
| :? TypedParseResult as tpr ->
let navitems = tpr.Untyped.GetNavigationItems()
for decl in navitems.Declarations do
let navitems = tpr.Untyped.GetNavigationItemsDeclarationsSafe()
for decl in navitems do
memberList.Add(decl.Declaration)
| :? (TypedParseResult * string) as typeAndFilter ->
let tpr, filter = typeAndFilter
let navitems = tpr.Untyped.GetNavigationItems()
for decl in navitems.Declarations do
let navitems = tpr.Untyped.GetNavigationItemsDeclarationsSafe()
for decl in navitems do
if decl.Declaration.Name.StartsWith(filter) then
memberList.Add(decl.Declaration)
| :? TopLevelDeclaration as tld ->
Expand Down

0 comments on commit 8f24798

Please sign in to comment.