未验证 提交 351d06b6 编写于 作者: P Phillip Carter 提交者: GitHub

Remove dependency on FSharp.LanguageService (#4108)

* Move ProjectSitesAndFiles to FSharp.Editor

* Remove commented out code

* Fix build that wasn't reported when running build.cmd

* Remove weird stuff and add the VSLang proj reference like it is in FSharp.LanguageService

* Remove dependency on FSharp.LanguageService

* remove commented out reference
上级 9333b068
......@@ -14,7 +14,6 @@ open Microsoft.FSharp.Compiler
open Microsoft.FSharp.Compiler.Layout
open Microsoft.FSharp.Compiler.SourceCodeServices
open Microsoft.FSharp.Compiler.Range
open Microsoft.VisualStudio.FSharp.LanguageService
[<RequireQualifiedAccess>]
module internal RoslynHelpers =
......
......@@ -3,16 +3,84 @@
namespace Microsoft.VisualStudio.FSharp.Editor
open System
open System.Runtime.InteropServices
open Microsoft.VisualStudio
open Microsoft.VisualStudio.Editor
open Microsoft.VisualStudio.Shell.Interop
open Microsoft.VisualStudio.TextManager.Interop
/// Helper methods for interoperating with COM
module internal Com =
module internal Com =
let ThrowOnFailure0(hr) =
ErrorHandler.ThrowOnFailure(hr) |> ignore
let ThrowOnFailure1(hr,res) =
ErrorHandler.ThrowOnFailure(hr) |> ignore;
res
let ThrowOnFailure2(hr,res1,res2) =
ErrorHandler.ThrowOnFailure(hr) |> ignore;
res1,res2
let ThrowOnFailure3(hr,res1,res2,res3) =
ErrorHandler.ThrowOnFailure(hr) |> ignore;
res1,res2,res3
let ThrowOnFailure4(hr,res1,res2,res3,res4) =
ErrorHandler.ThrowOnFailure(hr) |> ignore;
res1,res2,res3,res4
let Succeeded hr =
// REVIEW: Not the correct check for succeeded
hr = VSConstants.S_OK
module internal VsUserData =
let vsBufferMoniker = Guid("978A8E17-4DF8-432A-9623-D530A26452BC")
// This is the file name of the buffer.
let GetBufferMonker(ud:IVsUserData) : string =
downcast Com.ThrowOnFailure1(ud.GetData(ref vsBufferMoniker))
module internal VsTextLines =
/// Get the length of the given line.
let LengthOfLine (buffer:IVsTextBuffer) (line:int) : int =
Com.ThrowOnFailure1(buffer.GetLengthOfLine(line))
/// Get the text for a particular line.
let LineText (buffer:IVsTextLines) line =
Com.ThrowOnFailure1(buffer.GetLineText(line, 0, line, LengthOfLine buffer line))
/// Get the color state
let TextColorState (buffer:IVsTextLines) : IVsTextColorState= unbox(box(buffer))
/// Get the filename of the given buffer (via IVsUserData). Not all buffers have a file. This will be an exception.
let GetFilename(buffer : IVsTextLines) =
let ud = (box buffer) :?> IVsUserData
VsUserData.GetBufferMonker(ud)
/// Get the string contents of a given buffer (the current snapshot).
let GetFileContents(buffer: IVsTextBuffer, editorAdaptersFactoryService: IVsEditorAdaptersFactoryService) =
let dataBuffer = editorAdaptersFactoryService.GetDataBuffer(buffer)
dataBuffer.CurrentSnapshot.GetText()
module internal VsRunningDocumentTable =
let FindDocumentWithoutLocking(rdt:IVsRunningDocumentTable, url:string) : (IVsHierarchy * IVsTextLines) option =
let (hr:int, hier:IVsHierarchy, _itemid:uint32, unkData:IntPtr, _cookie:uint32) = rdt.FindAndLockDocument(uint32 _VSRDTFLAGS.RDT_NoLock, url)
try
if Com.Succeeded(hr) then
let bufferObject =
if unkData=IntPtr.Zero then null
else Marshal.GetObjectForIUnknown(unkData)
let buffer =
match bufferObject with
| :? IVsTextLines as tl -> tl
| _ -> null
Some(hier, buffer)
else None
finally
if IntPtr.Zero <> unkData then Marshal.Release(unkData)|>ignore
[<AutoOpen>]
module internal ServiceProviderExtensions =
type internal System.IServiceProvider with
......
......@@ -32,8 +32,6 @@
<InternalsVisibleTo Include="FSharp.ProjectSystem.FSharp" />
<InternalsVisibleTo Include="VisualFSharp.UnitTests" />
<InternalsVisibleTo Include="VisualFSharp.Salsa" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="FSharp.Editor.resx">
<GenerateSource>true</GenerateSource>
<GeneratedModuleName>Microsoft.VisualStudio.FSharp.Editor.SR</GeneratedModuleName>
......@@ -42,11 +40,11 @@
<Compile Include="Common\Pervasive.fs" />
<Compile Include="Common\Extensions.fs" />
<Compile Include="Common\Constants.fs" />
<Compile Include="Common\Error.fs" />
<Compile Include="Common\Logging.fs" />
<Compile Include="Common\RoslynHelpers.fs" />
<Compile Include="Common\CodeAnalysisExtensions.fs" />
<Compile Include="Common\ContentType.fs" />
<Compile Include="Common\Error.fs" />
<Compile Include="Common\Vs.fs" />
<Compile Include="Options\SettingsPersistence.fs" />
<Compile Include="Options\UIHelpers.fs" />
......@@ -54,6 +52,8 @@
<Compile Include="LanguageService\Tokenizer.fs" />
<Compile Include="LanguageService\Symbols.fs" />
<Compile Include="LanguageService\FSharpCheckerExtensions.fs" />
<Compile Include="LanguageService\IProjectSite.fs" />
<Compile Include="LanguageService\ProjectSitesAndFiles.fs" />
<Compile Include="LanguageService\LanguageService.fs" />
<Compile Include="LanguageService\AssemblyContentProvider.fs" />
<Compile Include="LanguageService\SymbolHelpers.fs" />
......@@ -107,11 +107,6 @@
<Project>{DED3BBD7-53F4-428A-8C9F-27968E768605}</Project>
<Name>FSharp.Core</Name>
</ProjectReference>
<ProjectReference Include="$(FSharpSourcesRoot)\..\vsintegration\src\FSharp.LanguageService\FSharp.LanguageService.fsproj">
<Name>FSharp.LanguageService</Name>
<Project>{ee85aab7-cda0-4c4e-bda0-a64ccc413e3f}</Project>
<Private>True</Private>
</ProjectReference>
<ProjectReference Include="$(FSharpSourcesRoot)\..\vsintegration\src\FSharp.LanguageService.Base\FSharp.LanguageService.Base.csproj">
<Name>FSharp.LanguageService.Base</Name>
<Project>{1c5c163c-37ea-4a3c-8ccc-0d34b74bf8ef}</Project>
......@@ -132,8 +127,6 @@
<Project>{991dcf75-c2eb-42b6-9a0d-aa1d2409d519}</Project>
<Private>True</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Reference Include="mscorlib" />
<Reference Include="PresentationFramework" />
<Reference Include="System.Windows.Forms" />
......@@ -146,8 +139,6 @@
<Reference Include="System" />
<Reference Include="PresentationCore" />
<Reference Include="System.ComponentModel.Composition" />
</ItemGroup>
<ItemGroup>
<Reference Include="EnvDTE">
<HintPath>$(FSharpSourcesRoot)\..\packages\EnvDTE.8.0.1\lib\net10\EnvDTE.dll</HintPath>
<Private>True</Private>
......@@ -156,6 +147,10 @@
<HintPath>$(FSharpSourcesRoot)\..\packages\EnvDTE80.8.0.1\lib\net10\EnvDTE80.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="VSLangProj">
<HintPath>$(FSharpSourcesRoot)\..\packages\VSSDK.VSLangProj.7.0.4\lib\net20\VSLangProj.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.Threading">
<HintPath>$(FSharpSourcesRoot)\..\packages\Microsoft.VisualStudio.Threading.$(MicrosoftVisualStudioThreadingVersion)\lib\net45\Microsoft.VisualStudio.Threading.dll</HintPath>
</Reference>
......
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
namespace Microsoft.VisualStudio.FSharp.Editor
open System.Runtime.InteropServices
/// Narrow abstraction over the project system.
type internal AdviseProjectSiteChanges = delegate of unit -> unit
[<ComImport; InterfaceType(ComInterfaceType.InterfaceIsIUnknown); Guid("ad98f020-bad0-0000-0000-abc037459871")>]
type internal IProvideProjectSite =
abstract GetProjectSite : unit -> IProjectSite
/// Represents known F#-specific information about a project.
and internal IProjectSite =
/// List of files in the project. In the correct order.
abstract CompilationSourceFiles : string[]
/// Flags that the compiler would need to understand how to compile. Includes '-r'
/// options but not source files
abstract CompilationOptions : string[]
/// The normalized '-r:' assembly references, without the '-r:'
abstract CompilationReferences : string []
/// The '-o:' output bin path, without the '-o:'
abstract CompilationBinOutputPath : string option
/// The name of the project file.
abstract ProjectFileName : string
/// Register for notifications for when the above change
abstract AdviseProjectSiteChanges : callbackOwnerKey: string * AdviseProjectSiteChanges -> unit
/// Register for notifications when project is cleaned/rebuilt (and thus any live TypeProviders should be refreshed)
abstract AdviseProjectSiteCleaned : callbackOwnerKey: string * AdviseProjectSiteChanges -> unit
// Register for notifications when project is closed.
abstract AdviseProjectSiteClosed : callbackOwnerKey: string * AdviseProjectSiteChanges -> unit
/// A user-friendly description of the project. Used only for developer/DEBUG tooltips and such.
abstract Description : string
/// The error list task reporter
abstract BuildErrorReporter : Microsoft.VisualStudio.Shell.Interop.IVsLanguageServiceBuildErrorReporter2 option with get, set
/// False type resolution errors are invalid. This occurs with orphaned source files. The prior
/// type checking state is unknown. In this case we don't want to squiggle the type checking files.
abstract IsIncompleteTypeCheckEnvironment : bool
/// target framework moniker
abstract TargetFrameworkMoniker : string
/// Project Guid
abstract ProjectGuid : string
/// timestamp the site was last loaded
abstract LoadTime : System.DateTime
abstract ProjectProvider : IProvideProjectSite option
\ No newline at end of file
......@@ -23,8 +23,7 @@ open Microsoft.FSharp.Compiler.CompileOps
open Microsoft.FSharp.Compiler.SourceCodeServices
open Microsoft.VisualStudio
open Microsoft.VisualStudio.Editor
open Microsoft.VisualStudio.FSharp.LanguageService
open Microsoft.VisualStudio.FSharp.LanguageService.SiteProvider
open Microsoft.VisualStudio.FSharp.Editor.SiteProvider
open Microsoft.VisualStudio.TextManager.Interop
open Microsoft.VisualStudio.LanguageServices
open Microsoft.VisualStudio.LanguageServices.Implementation.LanguageService
......
......@@ -1471,7 +1471,7 @@ namespace rec Microsoft.VisualStudio.FSharp.ProjectSystem
member __.TargetFrameworkMoniker = x.GetTargetFrameworkMoniker()
member __.ProjectGuid = x.GetProjectGuid()
member __.LoadTime = creationTime
member __.ProjectProvider = Some (x :> IProvideProjectSite)
member __.ProjectProvider = Some (x :> Microsoft.VisualStudio.FSharp.LanguageService.IProvideProjectSite)
}
......@@ -1507,7 +1507,7 @@ namespace rec Microsoft.VisualStudio.FSharp.ProjectSystem
member __.TargetFrameworkMoniker = targetFrameworkMoniker
member __.ProjectGuid = x.GetProjectGuid()
member __.LoadTime = creationTime
member __.ProjectProvider = Some (x :> IProvideProjectSite)
member __.ProjectProvider = Some (x :> Microsoft.VisualStudio.FSharp.LanguageService.IProvideProjectSite)
}
// let the language service ask us questions
......
......@@ -113,7 +113,7 @@ type internal FSharpLanguageServiceTestable() as this =
serviceProvider <- None
/// Respond to project settings changes
member this.OnProjectSettingsChanged(site:IProjectSite) =
member this.OnProjectSettingsChanged(site: Microsoft.VisualStudio.FSharp.LanguageService.IProjectSite) =
// The project may have changed its references. These would be represented as 'dependency files' of each source file. Each source file will eventually start listening
// for changes to those dependencies, at which point we'll get OnDependencyFileCreateOrDelete notifications. Until then, though, we just 'make a note' that this project is out of date.
bgRequests.AddOutOfDateProjectFileName(site.ProjectFileName)
......@@ -126,7 +126,7 @@ type internal FSharpLanguageServiceTestable() as this =
| None -> ()
/// Respond to project being cleaned/rebuilt (any live type providers in the project should be refreshed)
member this.OnProjectCleaned(projectSite:IProjectSite) =
member this.OnProjectCleaned(projectSite:Microsoft.VisualStudio.FSharp.LanguageService.IProjectSite) =
let enableInMemoryCrossProjectReferences = true
let _, checkOptions = ProjectSitesAndFiles.GetProjectOptionsForProjectSite(enableInMemoryCrossProjectReferences, (fun _ -> None), projectSite, serviceProvider.Value, None(*projectId*), "" ,None, None, false)
this.FSharpChecker.NotifyProjectCleaned(checkOptions) |> Async.RunSynchronously
......@@ -147,12 +147,12 @@ type internal FSharpLanguageServiceTestable() as this =
match result with
| Some(hier,_) ->
match hier with
| :? IProvideProjectSite as siteProvider ->
| :? Microsoft.VisualStudio.FSharp.LanguageService.IProvideProjectSite as siteProvider ->
let site = siteProvider.GetProjectSite()
site.AdviseProjectSiteChanges(FSharpConstants.FSharpLanguageServiceCallbackName,
new AdviseProjectSiteChanges(fun () -> this.OnProjectSettingsChanged(site)))
new Microsoft.VisualStudio.FSharp.LanguageService.AdviseProjectSiteChanges(fun () -> this.OnProjectSettingsChanged(site)))
site.AdviseProjectSiteCleaned(FSharpConstants.FSharpLanguageServiceCallbackName,
new AdviseProjectSiteChanges(fun () -> this.OnProjectCleaned(site)))
new Microsoft.VisualStudio.FSharp.LanguageService.AdviseProjectSiteChanges(fun () -> this.OnProjectCleaned(site)))
| _ ->
// This can happen when the file is in a solution folder or in, say, a C# project.
()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册