@@ -589,7 +589,7 @@ type TypeCheckInfo
589589let getItem ( x : ItemWithInst ) = x.Item
590590let GetDeclaredItems ( parseResultsOpt : FSharpParseFileResults option , lineStr : string , origLongIdentOpt , colAtEndOfNamesAndResidue , residueOpt , line , loc ,
591591filterCtors , resolveOverloads , hasTextChangedSinceLastTypecheck , isInRangeOperator , allSymbols : unit -> AssemblySymbol list ) =
592-
592+
593593// Are the last two chars (except whitespaces) = ".."
594594let isLikeRangeOp =
595595match FindFirstNonWhitespacePosition lineStr( colAtEndOfNamesAndResidue- 1 ) with
@@ -893,7 +893,9 @@ type TypeCheckInfo
893893/// Find items in the best naming environment.
894894let ( nenv , ad ), m = GetBestEnvForPos cursorPos
895895 NameResolution.IsItemResolvable ncenv nenv m ad plid item)
896- ( fun _ -> false )
896+ ( fun msg ->
897+ Trace.TraceInformation( sprintf" FCS: recovering from error in IsRelativeNameResolvable: '%s '" msg)
898+ false )
897899
898900/// Get the auto-complete items at a location
899901member __.GetDeclarations ( ctok , parseResultsOpt , line , lineStr , colAtEndOfNamesAndResidue , qualifyingNames , partialName , getAllSymbols , hasTextChangedSinceLastTypecheck ) =
@@ -911,7 +913,9 @@ type TypeCheckInfo
911913|> Option.map( fun parsedInput -> UntypedParseImpl.GetFullNameOfSmallestModuleOrNamespaceAtPoint( parsedInput, mkPos line0 ))
912914let isAttributeApplication = ctx= Some CompletionContext.AttributeApplication
913915 FSharpDeclarationListInfo.Create( infoReader, m, denv, getAccessibility, items, reactorOps, currentNamespaceOrModule, isAttributeApplication, checkAlive))
914- ( fun msg -> FSharpDeclarationListInfo.Error msg)
916+ ( fun msg ->
917+ Trace.TraceInformation( sprintf" FCS: recovering from error in GetDeclarations: '%s '" msg)
918+ FSharpDeclarationListInfo.Error msg)
915919
916920/// Get the symbols for auto-complete items at a location
917921member __.GetDeclarationListSymbols ( ctok , parseResultsOpt , line , lineStr , colAtEndOfNamesAndResidue , qualifyingNames , partialName , hasTextChangedSinceLastTypecheck ) =
@@ -975,7 +979,9 @@ type TypeCheckInfo
975979
976980//end filtering
977981 items)
978- ( fun _msg -> [])
982+ ( fun msg ->
983+ Trace.TraceInformation( sprintf" FCS: recovering from error in GetDeclarationListSymbols: '%s '" msg)
984+ [])
979985
980986/// Get the "reference resolution" tooltip for at a location
981987member __.GetReferenceResolutionStructuredToolTipText ( ctok , line , col ) =
@@ -1009,7 +1015,9 @@ type TypeCheckInfo
10091015
10101016 ErrorScope.Protect Range.range0
10111017 dataTipOfReferences
1012- ( fun err -> FSharpToolTipText[ FSharpStructuredToolTipElement.CompositionError err])
1018+ ( fun err ->
1019+ Trace.TraceInformation( sprintf" FCS: recovering from error in GetReferenceResolutionStructuredToolTipText: '%s '" err)
1020+ FSharpToolTipText[ FSharpStructuredToolTipElement.CompositionError err])
10131021
10141022// GetToolTipText: return the "pop up" (or "Quick Info") text given a certain context.
10151023member __.GetStructuredToolTipText ( ctok , line , lineStr , colAtEndOfNames , names ) =
@@ -1020,7 +1028,9 @@ type TypeCheckInfo
10201028| None-> FSharpToolTipText[]
10211029| Some( items, denv, _, m) ->
10221030 FSharpToolTipText( items|> List.map( fun x -> FormatStructuredDescriptionOfItemfalse infoReader m denv x.ItemWithInst)))
1023- ( fun err -> FSharpToolTipText[ FSharpStructuredToolTipElement.CompositionError err])
1031+ ( fun err ->
1032+ Trace.TraceInformation( sprintf" FCS: recovering from error in GetStructuredToolTipText: '%s '" err)
1033+ FSharpToolTipText[ FSharpStructuredToolTipElement.CompositionError err])
10241034
10251035// See devdiv bug 646520 for rationale behind truncating and caching these quick infos (they can be big!)
10261036let key = line, colAtEndOfNames, lineStr
@@ -1059,7 +1069,9 @@ type TypeCheckInfo
10591069-> GetF1Keyword g typ
10601070| _ -> None
10611071)
1062- ( fun _ -> None)
1072+ ( fun msg ->
1073+ Trace.TraceInformation( sprintf" FCS: recovering from error in GetF1Keyword: '%s '" msg)
1074+ None)
10631075
10641076member __.GetMethods ( ctok , line , lineStr , colAtEndOfNames , namesOpt ) =
10651077 ErrorScope.Protect Range.range0
@@ -1068,17 +1080,26 @@ type TypeCheckInfo
10681080| None-> FSharpMethodGroup( " " ,[| |])
10691081| Some( items, denv, _, m) -> FSharpMethodGroup.Create( infoReader, m, denv, items|> List.map( fun x -> x.ItemWithInst)))
10701082( fun msg ->
1083+ Trace.TraceInformation( sprintf" FCS: recovering from error in GetMethods: '%s '" msg)
10711084 FSharpMethodGroup( msg,[| |]))
10721085
10731086member __.GetMethodsAsSymbols ( ctok , line , lineStr , colAtEndOfNames , names ) =
1087+ ErrorScope.Protect Range.range0
1088+ ( fun () ->
10741089match GetDeclItemsForNamesAtPosition( ctok, None, Some( names), None, line, lineStr, colAtEndOfNames, ResolveTypeNamesToCtors, ResolveOverloads.No,( fun () -> []), fun _ -> false ) with
10751090| None| Some([],_,_,_) -> None
10761091| Some( items, denv, _, m) ->
10771092let allItems = items|> List.collect( fun item -> SymbolHelpers.FlattenItems g m item.Item)
10781093let symbols = allItems|> List.map( fun item -> FSharpSymbol.Create( g, thisCcu, tcImports, item))
10791094 Some( symbols, denv, m)
1095+ )
1096+ ( fun msg ->
1097+ Trace.TraceInformation( sprintf" FCS: recovering from error in GetMethodsAsSymbols: '%s '" msg)
1098+ None)
10801099
10811100member scope.GetDeclarationLocation ( ctok , line , lineStr , colAtEndOfNames , names , preferFlag ) =
1101+ ErrorScope.Protect Range.range0
1102+ ( fun () ->
10821103match GetDeclItemsForNamesAtPosition( ctok, None, Some( names), None, line, lineStr, colAtEndOfNames, ResolveTypeNamesToCtors, ResolveOverloads.Yes,( fun () -> []), fun _ -> false ) with
10831104| None
10841105| Some([], _, _, _) -> FSharpFindDeclResult.DeclNotFound FSharpFindDeclFailureReason.Unknown
@@ -1119,13 +1140,23 @@ type TypeCheckInfo
11191140 FSharpFindDeclResult.DeclFound( mkRange filename itemRange.Start itemRange.End)
11201141else
11211142 fail FSharpFindDeclFailureReason.NoSourceCode// provided items may have TypeProviderDefinitionLocationAttribute that binds them to some location
1143+ )
1144+ ( fun msg ->
1145+ Trace.TraceInformation( sprintf" FCS: recovering from error in GetDeclarationLocation: '%s '" msg)
1146+ FSharpFindDeclResult.DeclNotFound FSharpFindDeclFailureReason.Unknown)
11221147
11231148member scope.GetSymbolUseAtLocation ( ctok , line , lineStr , colAtEndOfNames , names ) =
1149+ ErrorScope.Protect Range.range0
1150+ ( fun () ->
11241151match GetDeclItemsForNamesAtPosition( ctok, None, Some( names), None, line, lineStr, colAtEndOfNames, ResolveTypeNamesToCtors, ResolveOverloads.Yes,( fun () -> []), fun _ -> false ) with
11251152| None| Some([], _, _, _) -> None
11261153| Some( item:: _, denv, _, m) ->
11271154let symbol = FSharpSymbol.Create( g, thisCcu, tcImports, item.Item)
11281155 Some( symbol, denv, m)
1156+ )
1157+ ( fun msg ->
1158+ Trace.TraceInformation( sprintf" FCS: recovering from error in GetSymbolUseAtLocation: '%s '" msg)
1159+ None)
11291160
11301161member scope.PartialAssemblySignature () = FSharpAssemblySignature( g, thisCcu, tcImports, None, ccuSig)
11311162
@@ -1139,6 +1170,8 @@ type TypeCheckInfo
11391170 sSymbolUses.GetFormatSpecifierLocationsAndArity()
11401171
11411172member __.GetSemanticClassification ( range : range option ) : ( range * SemanticClassificationType ) [] =
1173+ ErrorScope.Protect Range.range0
1174+ ( fun () ->
11421175let (| LegitTypeOccurence | _ |) = function
11431176| ItemOccurence.UseInType
11441177| ItemOccurence.UseInAttribute
@@ -1243,6 +1276,10 @@ type TypeCheckInfo
12431276| _ -> None)
12441277|> Seq.toArray
12451278|> Array.append( sSymbolUses.GetFormatSpecifierLocationsAndArity() |> Array.map( fun m -> fst m, SemanticClassificationType.Printf))
1279+ )
1280+ ( fun msg ->
1281+ Trace.TraceInformation( sprintf" FCS: recovering from error in GetSemanticClassification: '%s '" msg)
1282+ Array.empty)
12461283
12471284/// The resolutions in the file
12481285member __.ScopeResolutions = sResolutions
@@ -1291,7 +1328,7 @@ module internal Parser =
12911328if not ( exn.IsPhaseInCompile()) then
12921329// Reaching this point means that the error would be sticky if we let it prop up to the language service.
12931330// Assert and recover by replacing phase with one known to the language service.
1294- System.Diagnostics.Debug.Assert ( false , sprintf" The subcategory '%s ' seen in an error should not be seen by the language service" ( exn.Subcategory()))
1331+ Trace.TraceInformation ( sprintf" The subcategory '%s ' seen in an error should not be seen by the language service" ( exn.Subcategory()))
12951332{ exnwith Phase= BuildPhase.TypeCheck}
12961333else exn
12971334if reportErrorsthen