未验证 提交 3b9f82ba 编写于 作者: K Kevin Ransom (msft) 提交者: GitHub

Enable language preview option for fsi in the ide (#8443)

上级 7f14ea0d
......@@ -742,7 +742,7 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC
member bc.ParseAndCheckProject(options, userOpName) =
reactor.EnqueueAndAwaitOpAsync(userOpName, "ParseAndCheckProject", options.ProjectFileName, fun ctok -> bc.ParseAndCheckProjectImpl(options, ctok, userOpName))
member __.GetProjectOptionsFromScript(filename, sourceText, loadedTimeStamp, otherFlags, useFsiAuxLib: bool option, useSdkRefs: bool option, assumeDotNetFramework: bool option, extraProjectInfo: obj option, optionsStamp: int64 option, userOpName) =
member __.GetProjectOptionsFromScript(filename, sourceText, previewEnabled, loadedTimeStamp, otherFlags, useFsiAuxLib: bool option, useSdkRefs: bool option, assumeDotNetFramework: bool option, extraProjectInfo: obj option, optionsStamp: int64 option, userOpName) =
reactor.EnqueueAndAwaitOpAsync (userOpName, "GetProjectOptionsFromScript", filename, fun ctok ->
cancellable {
use errors = new ErrorScope()
......@@ -751,10 +751,16 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC
let useFsiAuxLib = defaultArg useFsiAuxLib true
let useSdkRefs = defaultArg useSdkRefs true
let reduceMemoryUsage = ReduceMemoryFlag.Yes
let previewEnabled = defaultArg previewEnabled false
// Do we assume .NET Framework references for scripts?
let assumeDotNetFramework = defaultArg assumeDotNetFramework true
let otherFlags = defaultArg otherFlags [| |]
let extraFlags =
if previewEnabled then
[| "--langversion:preview" |]
else
[||]
let otherFlags = defaultArg otherFlags extraFlags
let useSimpleResolution =
#if ENABLE_MONO_SUPPORT
runningOnMono || otherFlags |> Array.exists (fun x -> x = "--simpleresolution")
......@@ -1142,9 +1148,9 @@ type FSharpChecker(legacyReferenceResolver,
backgroundCompiler.ParseAndCheckProject(options, userOpName)
/// For a given script file, get the ProjectOptions implied by the #load closure
member __.GetProjectOptionsFromScript(filename, source, ?loadedTimeStamp, ?otherFlags, ?useFsiAuxLib, ?useSdkRefs, ?assumeDotNetFramework, ?extraProjectInfo: obj, ?optionsStamp: int64, ?userOpName: string) =
member __.GetProjectOptionsFromScript(filename, source, ?previewEnabled, ?loadedTimeStamp, ?otherFlags, ?useFsiAuxLib, ?useSdkRefs, ?assumeDotNetFramework, ?extraProjectInfo: obj, ?optionsStamp: int64, ?userOpName: string) =
let userOpName = defaultArg userOpName "Unknown"
backgroundCompiler.GetProjectOptionsFromScript(filename, source, loadedTimeStamp, otherFlags, useFsiAuxLib, useSdkRefs, assumeDotNetFramework, extraProjectInfo, optionsStamp, userOpName)
backgroundCompiler.GetProjectOptionsFromScript(filename, source, previewEnabled, loadedTimeStamp, otherFlags, useFsiAuxLib, useSdkRefs, assumeDotNetFramework, extraProjectInfo, optionsStamp, userOpName)
member __.GetProjectOptionsFromCommandLineArgs(projectFileName, argv, ?loadedTimeStamp, ?extraProjectInfo: obj) =
let loadedTimeStamp = defaultArg loadedTimeStamp DateTime.MaxValue // Not 'now', we don't want to force reloading
......
......@@ -228,7 +228,7 @@ type public FSharpChecker =
/// so that an 'unload' and 'reload' action will cause the script to be considered as a new project,
/// so that references are re-resolved.</param>
/// <param name="userOpName">An optional string used for tracing compiler operations associated with this request.</param>
member GetProjectOptionsFromScript : filename: string * sourceText: ISourceText * ?loadedTimeStamp: DateTime * ?otherFlags: string[] * ?useFsiAuxLib: bool * ?useSdkRefs: bool * ?assumeDotNetFramework: bool * ?extraProjectInfo: obj * ?optionsStamp: int64 * ?userOpName: string -> Async<FSharpProjectOptions * FSharpErrorInfo list>
member GetProjectOptionsFromScript : filename: string * sourceText: ISourceText * ?previewEnabled:bool * ?loadedTimeStamp: DateTime * ?otherFlags: string[] * ?useFsiAuxLib: bool * ?useSdkRefs: bool * ?assumeDotNetFramework: bool * ?extraProjectInfo: obj * ?optionsStamp: int64 * ?userOpName: string -> Async<FSharpProjectOptions * FSharpErrorInfo list>
/// <summary>
/// <para>Get the FSharpProjectOptions implied by a set of command line arguments.</para>
......
......@@ -20,6 +20,7 @@ open System.Threading
open Microsoft.VisualStudio.Shell.Interop
open Microsoft.VisualStudio.LanguageServices.Implementation.TaskList
open Microsoft.CodeAnalysis.ExternalAccess.FSharp.LanguageServices
open Microsoft.VisualStudio.FSharp.Interactive.Session
[<AutoOpen>]
module private FSharpProjectOptionsHelpers =
......@@ -97,7 +98,7 @@ type private FSharpProjectOptionsReactor (_workspace: VisualStudioWorkspace, set
match singleFileCache.TryGetValue(document.Id) with
| false, _ ->
let! sourceText = document.GetTextAsync(ct) |> Async.AwaitTask
let! scriptProjectOptions, _ = checkerProvider.Checker.GetProjectOptionsFromScript(document.FilePath, sourceText.ToFSharpSourceText())
let! scriptProjectOptions, _ = checkerProvider.Checker.GetProjectOptionsFromScript(document.FilePath, sourceText.ToFSharpSourceText(), SessionsProperties.fsiPreview)
let projectOptions =
if isScriptFile document.FilePath then
scriptProjectOptions
......
......@@ -11,6 +11,7 @@ open Microsoft.VisualStudio.TextManager.Interop
open Microsoft.VisualStudio.Text
open FSharp.Compiler.SourceCodeServices
open Microsoft.VisualStudio.FSharp.LanguageService.SiteProvider
open Microsoft.VisualStudio.FSharp.Interactive.Session
#nowarn "44" // use of obsolete CheckFileInProjectAllowingStaleCachedResults
......@@ -94,7 +95,7 @@ type internal FSharpLanguageServiceBackgroundRequests_DEPRECATED
lazy // This portion is executed on the language service thread
let timestamp = if source=null then System.DateTime(2000,1,1) else source.OpenedTime // source is null in unit tests
let checker = getInteractiveChecker()
let checkOptions, _diagnostics = checker.GetProjectOptionsFromScript(fileName, FSharp.Compiler.Text.SourceText.ofString sourceText, timestamp, [| |]) |> Async.RunSynchronously
let checkOptions, _diagnostics = checker.GetProjectOptionsFromScript(fileName, FSharp.Compiler.Text.SourceText.ofString sourceText, SessionsProperties.fsiPreview, timestamp, [| |]) |> Async.RunSynchronously
let referencedProjectFileNames = [| |]
let projectSite = ProjectSitesAndFiles.CreateProjectSiteForScript(fileName, referencedProjectFileNames, checkOptions)
{ ProjectSite = projectSite
......
......@@ -148,4 +148,14 @@
<data name="FSharpInteractiveDebugging" xml:space="preserve">
<value>Debugging</value>
</data>
<data name="FSharpInteractivePreview" xml:space="preserve">
<value>FSI Preview</value>
</data>
<data name="FSharpInteractivePreviewModeDescr" xml:space="preserve">
<value>Enable preview of in-development language features in F# Interactive</value>
</data>
<data name="FSharpInteractivePreviewMode" xml:space="preserve">
<value>Enable preview language features</value>
</data>
</root>
\ No newline at end of file
......@@ -36,30 +36,35 @@ module internal ContentType =
[<ClassInterface(ClassInterfaceType.AutoDual)>]
[<Guid("4489e9de-6ac1-3cd6-bff8-a904fd0e82d4")>]
type FsiPropertyPage() =
inherit DialogPage()
inherit DialogPage()
[<ResourceCategory(SRProperties.FSharpInteractiveMisc)>]
[<ResourceDisplayName(SRProperties.FSharpInteractive64Bit)>]
[<ResourceDescription(SRProperties.FSharpInteractive64BitDescr)>]
[<ResourceDisplayName(SRProperties.FSharpInteractive64Bit)>]
[<ResourceDescription(SRProperties.FSharpInteractive64BitDescr)>]
member this.FsiPreferAnyCPUVersion with get() = SessionsProperties.useAnyCpuVersion and set (x:bool) = SessionsProperties.useAnyCpuVersion <- x
[<ResourceCategory(SRProperties.FSharpInteractiveMisc)>]
[<ResourceDisplayName(SRProperties.FSharpInteractiveOptions)>]
[<ResourceDescription(SRProperties.FSharpInteractiveOptionsDescr)>]
[<ResourceDescription(SRProperties.FSharpInteractiveOptionsDescr)>]
member this.FsiCommandLineArgs with get() = SessionsProperties.fsiArgs and set (x:string) = SessionsProperties.fsiArgs <- x
[<ResourceCategory(SRProperties.FSharpInteractiveMisc)>]
[<ResourceDisplayName(SRProperties.FSharpInteractiveShadowCopy)>]
[<ResourceDescription(SRProperties.FSharpInteractiveShadowCopyDescr)>]
[<ResourceDescription(SRProperties.FSharpInteractiveShadowCopyDescr)>]
member this.FsiShadowCopy with get() = SessionsProperties.fsiShadowCopy and set (x:bool) = SessionsProperties.fsiShadowCopy <- x
[<ResourceCategory(SRProperties.FSharpInteractiveDebugging)>]
[<ResourceDisplayName(SRProperties.FSharpInteractiveDebugMode)>]
[<ResourceDescription(SRProperties.FSharpInteractiveDebugModeDescr)>]
[<ResourceDescription(SRProperties.FSharpInteractiveDebugModeDescr)>]
member this.FsiDebugMode with get() = SessionsProperties.fsiDebugMode and set (x:bool) = SessionsProperties.fsiDebugMode <- x
[<ResourceCategory(SRProperties.FSharpInteractivePreview)>]
[<ResourceDisplayName(SRProperties.FSharpInteractivePreviewMode)>]
[<ResourceDescription(SRProperties.FSharpInteractivePreviewModeDescr)>]
member this.FsiPreview with get() = SessionsProperties.fsiPreview and set (x:bool) = SessionsProperties.fsiPreview <- x
// CompletionSet
type internal FsiCompletionSet(imageList,source:Source) =
type internal FsiCompletionSet(imageList,source:Source) =
inherit CompletionSet(imageList, source)
// Declarations
......
......@@ -70,6 +70,7 @@ module SessionsProperties =
let mutable fsiArgs = "--optimize"
let mutable fsiShadowCopy = true
let mutable fsiDebugMode = false
let mutable fsiPreview = false
// This code pre-dates the events/object system.
// Later: Tidy up.
......@@ -218,7 +219,7 @@ let fsiStartInfo channelName =
let addBoolOption name value args = sprintf "%s --%s%s" args name (if value then "+" else "-")
let addStringOption name value args = sprintf "%s --%s:%O" args name value
let procArgs =
""
|> addStringOption "fsi-server-output-codepage" outCP
......@@ -227,11 +228,18 @@ let fsiStartInfo channelName =
|> addStringOption "fsi-server" channelName
|> (fun s -> s + sprintf " %s" SessionsProperties.fsiArgs)
|> addBoolOption "shadowcopyreferences" SessionsProperties.fsiShadowCopy
|> (fun args -> if SessionsProperties.fsiDebugMode then
// for best debug experience, need optimizations OFF and debug info ON
// tack these on the the end, they will override whatever comes earlier
args |> addBoolOption "optimize" false |> addBoolOption "debug" true
else args)
|> (fun args ->
// for best debug experience, need optimizations OFF and debug info ON
// tack these on the the end, they will override whatever comes earlier
if SessionsProperties.fsiDebugMode then
args |> addBoolOption "optimize" false |> addBoolOption "debug" true
else
args)
|> (fun args ->
if SessionsProperties.fsiPreview then
args |> addStringOption "langversion" "preview"
else
args)
procInfo.Arguments <- procArgs
procInfo.CreateNoWindow <- true
......
......@@ -27,6 +27,21 @@
<target state="translated">Různé</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractivePreview">
<source>FSI Preview</source>
<target state="new">FSI Preview</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractivePreviewMode">
<source>Enable preview language features</source>
<target state="new">Enable preview language features</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractivePreviewModeDescr">
<source>Enable preview of in-development language features in F# Interactive</source>
<target state="new">Enable preview of in-development language features in F# Interactive</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractiveShadowCopy">
<source>Shadow copy assemblies</source>
<target state="translated">Sestavení stínových kopií</target>
......
......@@ -27,6 +27,21 @@
<target state="translated">Verschiedene</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractivePreview">
<source>FSI Preview</source>
<target state="new">FSI Preview</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractivePreviewMode">
<source>Enable preview language features</source>
<target state="new">Enable preview language features</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractivePreviewModeDescr">
<source>Enable preview of in-development language features in F# Interactive</source>
<target state="new">Enable preview of in-development language features in F# Interactive</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractiveShadowCopy">
<source>Shadow copy assemblies</source>
<target state="translated">Schattenkopie-Assemblys</target>
......
......@@ -27,6 +27,21 @@
<target state="translated">Varios</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractivePreview">
<source>FSI Preview</source>
<target state="new">FSI Preview</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractivePreviewMode">
<source>Enable preview language features</source>
<target state="new">Enable preview language features</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractivePreviewModeDescr">
<source>Enable preview of in-development language features in F# Interactive</source>
<target state="new">Enable preview of in-development language features in F# Interactive</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractiveShadowCopy">
<source>Shadow copy assemblies</source>
<target state="translated">Ensamblados de instantánea</target>
......
......@@ -27,6 +27,21 @@
<target state="translated">Divers</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractivePreview">
<source>FSI Preview</source>
<target state="new">FSI Preview</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractivePreviewMode">
<source>Enable preview language features</source>
<target state="new">Enable preview language features</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractivePreviewModeDescr">
<source>Enable preview of in-development language features in F# Interactive</source>
<target state="new">Enable preview of in-development language features in F# Interactive</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractiveShadowCopy">
<source>Shadow copy assemblies</source>
<target state="translated">Assemblys de cliché instantané</target>
......
......@@ -27,6 +27,21 @@
<target state="translated">Varie</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractivePreview">
<source>FSI Preview</source>
<target state="new">FSI Preview</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractivePreviewMode">
<source>Enable preview language features</source>
<target state="new">Enable preview language features</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractivePreviewModeDescr">
<source>Enable preview of in-development language features in F# Interactive</source>
<target state="new">Enable preview of in-development language features in F# Interactive</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractiveShadowCopy">
<source>Shadow copy assemblies</source>
<target state="translated">Assembly copie shadow</target>
......
......@@ -27,6 +27,21 @@
<target state="translated">その他</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractivePreview">
<source>FSI Preview</source>
<target state="new">FSI Preview</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractivePreviewMode">
<source>Enable preview language features</source>
<target state="new">Enable preview language features</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractivePreviewModeDescr">
<source>Enable preview of in-development language features in F# Interactive</source>
<target state="new">Enable preview of in-development language features in F# Interactive</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractiveShadowCopy">
<source>Shadow copy assemblies</source>
<target state="translated">シャドウ コピーのアセンブリ</target>
......
......@@ -27,6 +27,21 @@
<target state="translated">기타</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractivePreview">
<source>FSI Preview</source>
<target state="new">FSI Preview</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractivePreviewMode">
<source>Enable preview language features</source>
<target state="new">Enable preview language features</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractivePreviewModeDescr">
<source>Enable preview of in-development language features in F# Interactive</source>
<target state="new">Enable preview of in-development language features in F# Interactive</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractiveShadowCopy">
<source>Shadow copy assemblies</source>
<target state="translated">섀도 복사본 어셈블리</target>
......
......@@ -27,6 +27,21 @@
<target state="translated">Różne</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractivePreview">
<source>FSI Preview</source>
<target state="new">FSI Preview</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractivePreviewMode">
<source>Enable preview language features</source>
<target state="new">Enable preview language features</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractivePreviewModeDescr">
<source>Enable preview of in-development language features in F# Interactive</source>
<target state="new">Enable preview of in-development language features in F# Interactive</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractiveShadowCopy">
<source>Shadow copy assemblies</source>
<target state="translated">Zestawy kopii w tle</target>
......
......@@ -27,6 +27,21 @@
<target state="translated">Diversos</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractivePreview">
<source>FSI Preview</source>
<target state="new">FSI Preview</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractivePreviewMode">
<source>Enable preview language features</source>
<target state="new">Enable preview language features</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractivePreviewModeDescr">
<source>Enable preview of in-development language features in F# Interactive</source>
<target state="new">Enable preview of in-development language features in F# Interactive</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractiveShadowCopy">
<source>Shadow copy assemblies</source>
<target state="translated">Assemblies de cópia de sombra</target>
......
......@@ -27,6 +27,21 @@
<target state="translated">Прочее</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractivePreview">
<source>FSI Preview</source>
<target state="new">FSI Preview</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractivePreviewMode">
<source>Enable preview language features</source>
<target state="new">Enable preview language features</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractivePreviewModeDescr">
<source>Enable preview of in-development language features in F# Interactive</source>
<target state="new">Enable preview of in-development language features in F# Interactive</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractiveShadowCopy">
<source>Shadow copy assemblies</source>
<target state="translated">Теневое копирование сборок</target>
......
......@@ -27,6 +27,21 @@
<target state="translated">Çeşitli</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractivePreview">
<source>FSI Preview</source>
<target state="new">FSI Preview</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractivePreviewMode">
<source>Enable preview language features</source>
<target state="new">Enable preview language features</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractivePreviewModeDescr">
<source>Enable preview of in-development language features in F# Interactive</source>
<target state="new">Enable preview of in-development language features in F# Interactive</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractiveShadowCopy">
<source>Shadow copy assemblies</source>
<target state="translated">Gölge kopya bütünleştirilmiş kodları</target>
......
......@@ -27,6 +27,21 @@
<target state="translated">杂项</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractivePreview">
<source>FSI Preview</source>
<target state="new">FSI Preview</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractivePreviewMode">
<source>Enable preview language features</source>
<target state="new">Enable preview language features</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractivePreviewModeDescr">
<source>Enable preview of in-development language features in F# Interactive</source>
<target state="new">Enable preview of in-development language features in F# Interactive</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractiveShadowCopy">
<source>Shadow copy assemblies</source>
<target state="translated">卷影副本程序集</target>
......
......@@ -27,6 +27,21 @@
<target state="translated">其他</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractivePreview">
<source>FSI Preview</source>
<target state="new">FSI Preview</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractivePreviewMode">
<source>Enable preview language features</source>
<target state="new">Enable preview language features</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractivePreviewModeDescr">
<source>Enable preview of in-development language features in F# Interactive</source>
<target state="new">Enable preview of in-development language features in F# Interactive</target>
<note />
</trans-unit>
<trans-unit id="FSharpInteractiveShadowCopy">
<source>Shadow copy assemblies</source>
<target state="translated">陰影複製組件</target>
......
......@@ -1101,7 +1101,7 @@ module internal Salsa =
member file.GetFileName() = filename
member file.GetProjectOptionsOfScript() =
project.Solution.Vs.LanguageService.FSharpChecker.GetProjectOptionsFromScript(filename, FSharp.Compiler.Text.SourceText.ofString file.CombinedLines, System.DateTime(2000,1,1), [| |])
project.Solution.Vs.LanguageService.FSharpChecker.GetProjectOptionsFromScript(filename, FSharp.Compiler.Text.SourceText.ofString file.CombinedLines, false, System.DateTime(2000,1,1), [| |])
|> Async.RunSynchronously
|> fst // drop diagnostics
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册