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
10 changes: 8 additions & 2 deletions vsintegration/src/FSharp.Editor/CommonRoslynHelpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ module internal CommonRoslynHelpers =
let endPosition = sourceText.Lines.[range.EndLine - 1].Start + range.EndColumn
TextSpan(startPosition, endPosition - startPosition)


let GetCompletedTaskResult(task: Task<'TResult>) =
if task.Status = TaskStatus.RanToCompletion then
task.Result
Expand All @@ -29,8 +28,15 @@ module internal CommonRoslynHelpers =
raise(task.Exception.GetBaseException())

let StartAsyncAsTask cancellationToken computation =
let computation =
async {
try
return! computation
with e ->
Assert.Exception(e)
return Unchecked.defaultof<_>
}
Async.StartAsTask(computation, TaskCreationOptions.None, cancellationToken)
.ContinueWith(GetCompletedTaskResult, cancellationToken)

let StartAsyncUnitAsTask cancellationToken (computation:Async<unit>) =
StartAsyncAsTask cancellationToken computation :> Task
Expand Down
30 changes: 10 additions & 20 deletions vsintegration/src/FSharp.Editor/LanguageDebugInfoService.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,17 @@ namespace Microsoft.VisualStudio.FSharp.Editor

open System
open System.Composition
open System.Collections.Concurrent
open System.Collections.Generic
open System.Threading
open System.Threading.Tasks
open System.Linq

open Microsoft.CodeAnalysis
open Microsoft.CodeAnalysis.Classification
open Microsoft.CodeAnalysis.Editor
open Microsoft.CodeAnalysis.Editor.Implementation.Debugging
open Microsoft.CodeAnalysis.Editor.Implementation
open Microsoft.CodeAnalysis.Editor.Shared.Utilities
open Microsoft.CodeAnalysis.Formatting
open Microsoft.CodeAnalysis.Host.Mef
open Microsoft.CodeAnalysis.Text

open Microsoft.VisualStudio.FSharp.LanguageService
open Microsoft.VisualStudio.Text
open Microsoft.VisualStudio.Text.Tagging

open Microsoft.FSharp.Compiler.Parser
open Microsoft.FSharp.Compiler.SourceCodeServices
open Microsoft.FSharp.Compiler.Range

[<Shared>]
[<ExportLanguageService(typeof<ILanguageDebugInfoService>, FSharpCommonConstants.FSharpLanguageName)>]
Expand All @@ -45,10 +33,10 @@ type internal FSharpLanguageDebugInfoService
let token = tokens.[tokenIndex.Value]

match token.ClassificationType with

| ClassificationTypeNames.StringLiteral ->
Some(token.TextSpan)

| ClassificationTypeNames.Identifier ->
let textLine = sourceText.Lines.GetLineFromPosition(position)
let textLinePos = sourceText.Lines.GetLinePosition(position)
Expand All @@ -58,10 +46,9 @@ type internal FSharpLanguageDebugInfoService
| Some(island, islandEnd, _) ->
let islandDocumentStart = textLine.Start + islandEnd - island.Length
Some(TextSpan.FromBounds(islandDocumentStart, islandDocumentStart + island.Length))

| _ -> None


interface ILanguageDebugInfoService with

// FSROSLYNTODO: This is used to get function names in breakpoint window. It should return fully qualified function name and line offset from the start of the function.
Expand All @@ -75,10 +62,13 @@ type internal FSharpLanguageDebugInfoService
let textSpan = TextSpan.FromBounds(0, sourceText.Length)
let tokens = CommonHelpers.getColorizationData(document.Id, sourceText, textSpan, Some(document.Name), defines, cancellationToken)
let result =
match FSharpLanguageDebugInfoService.GetDataTipInformation(sourceText, position, tokens) with
| None -> DebugDataTipInfo()
| Some(textSpan) -> DebugDataTipInfo(textSpan, sourceText.GetSubText(textSpan).ToString())
match FSharpLanguageDebugInfoService.GetDataTipInformation(sourceText, position, tokens) with
| None ->
DebugDataTipInfo()
| Some textSpan ->
DebugDataTipInfo(textSpan, sourceText.GetSubText(textSpan).ToString())
return result
} |> CommonRoslynHelpers.StartAsyncAsTask cancellationToken
}
|> CommonRoslynHelpers.StartAsyncAsTask(cancellationToken)