Skip to content
This repository was archived by the owner on Dec 23, 2024. It is now read-only.

Commit 351d06b

Browse files
authored
Remove dependency on FSharp.LanguageService (dotnet#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
1 parent 9333b06 commit 351d06b

File tree

8 files changed

+468
-23
lines changed

8 files changed

+468
-23
lines changed

vsintegration/src/FSharp.Editor/Common/RoslynHelpers.fs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ open Microsoft.FSharp.Compiler
1414
open Microsoft.FSharp.Compiler.Layout
1515
open Microsoft.FSharp.Compiler.SourceCodeServices
1616
open Microsoft.FSharp.Compiler.Range
17-
open Microsoft.VisualStudio.FSharp.LanguageService
1817

1918
[<RequireQualifiedAccess>]
2019
module internal RoslynHelpers =

vsintegration/src/FSharp.Editor/Common/Vs.fs

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,84 @@
33
namespace Microsoft.VisualStudio.FSharp.Editor
44

55
open System
6+
open System.Runtime.InteropServices
67
open Microsoft.VisualStudio
8+
open Microsoft.VisualStudio.Editor
79
open Microsoft.VisualStudio.Shell.Interop
810
open Microsoft.VisualStudio.TextManager.Interop
911

1012
/// Helper methods for interoperating with COM
11-
module internal Com =
13+
module internal Com =
14+
let ThrowOnFailure0(hr) =
15+
ErrorHandler.ThrowOnFailure(hr) |> ignore
16+
17+
let ThrowOnFailure1(hr,res) =
18+
ErrorHandler.ThrowOnFailure(hr) |> ignore;
19+
res
20+
21+
let ThrowOnFailure2(hr,res1,res2) =
22+
ErrorHandler.ThrowOnFailure(hr) |> ignore;
23+
res1,res2
24+
25+
let ThrowOnFailure3(hr,res1,res2,res3) =
26+
ErrorHandler.ThrowOnFailure(hr) |> ignore;
27+
res1,res2,res3
28+
29+
let ThrowOnFailure4(hr,res1,res2,res3,res4) =
30+
ErrorHandler.ThrowOnFailure(hr) |> ignore;
31+
res1,res2,res3,res4
32+
1233
let Succeeded hr =
1334
// REVIEW: Not the correct check for succeeded
1435
hr = VSConstants.S_OK
1536

37+
module internal VsUserData =
38+
39+
let vsBufferMoniker = Guid("978A8E17-4DF8-432A-9623-D530A26452BC")
40+
41+
// This is the file name of the buffer.
42+
let GetBufferMonker(ud:IVsUserData) : string =
43+
downcast Com.ThrowOnFailure1(ud.GetData(ref vsBufferMoniker))
44+
45+
module internal VsTextLines =
46+
/// Get the length of the given line.
47+
let LengthOfLine (buffer:IVsTextBuffer) (line:int) : int =
48+
Com.ThrowOnFailure1(buffer.GetLengthOfLine(line))
49+
50+
/// Get the text for a particular line.
51+
let LineText (buffer:IVsTextLines) line =
52+
Com.ThrowOnFailure1(buffer.GetLineText(line, 0, line, LengthOfLine buffer line))
53+
54+
/// Get the color state
55+
let TextColorState (buffer:IVsTextLines) : IVsTextColorState= unbox(box(buffer))
56+
57+
/// Get the filename of the given buffer (via IVsUserData). Not all buffers have a file. This will be an exception.
58+
let GetFilename(buffer : IVsTextLines) =
59+
let ud = (box buffer) :?> IVsUserData
60+
VsUserData.GetBufferMonker(ud)
61+
62+
/// Get the string contents of a given buffer (the current snapshot).
63+
let GetFileContents(buffer: IVsTextBuffer, editorAdaptersFactoryService: IVsEditorAdaptersFactoryService) =
64+
let dataBuffer = editorAdaptersFactoryService.GetDataBuffer(buffer)
65+
dataBuffer.CurrentSnapshot.GetText()
66+
67+
module internal VsRunningDocumentTable =
68+
let FindDocumentWithoutLocking(rdt:IVsRunningDocumentTable, url:string) : (IVsHierarchy * IVsTextLines) option =
69+
let (hr:int, hier:IVsHierarchy, _itemid:uint32, unkData:IntPtr, _cookie:uint32) = rdt.FindAndLockDocument(uint32 _VSRDTFLAGS.RDT_NoLock, url)
70+
try
71+
if Com.Succeeded(hr) then
72+
let bufferObject =
73+
if unkData=IntPtr.Zero then null
74+
else Marshal.GetObjectForIUnknown(unkData)
75+
let buffer =
76+
match bufferObject with
77+
| :? IVsTextLines as tl -> tl
78+
| _ -> null
79+
Some(hier, buffer)
80+
else None
81+
finally
82+
if IntPtr.Zero <> unkData then Marshal.Release(unkData)|>ignore
83+
1684
[<AutoOpen>]
1785
module internal ServiceProviderExtensions =
1886
type internal System.IServiceProvider with

vsintegration/src/FSharp.Editor/FSharp.Editor.fsproj

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
<InternalsVisibleTo Include="FSharp.ProjectSystem.FSharp" />
3333
<InternalsVisibleTo Include="VisualFSharp.UnitTests" />
3434
<InternalsVisibleTo Include="VisualFSharp.Salsa" />
35-
</ItemGroup>
36-
<ItemGroup>
3735
<EmbeddedResource Include="FSharp.Editor.resx">
3836
<GenerateSource>true</GenerateSource>
3937
<GeneratedModuleName>Microsoft.VisualStudio.FSharp.Editor.SR</GeneratedModuleName>
@@ -42,18 +40,20 @@
4240
<Compile Include="Common\Pervasive.fs" />
4341
<Compile Include="Common\Extensions.fs" />
4442
<Compile Include="Common\Constants.fs" />
43+
<Compile Include="Common\Error.fs" />
4544
<Compile Include="Common\Logging.fs" />
4645
<Compile Include="Common\RoslynHelpers.fs" />
4746
<Compile Include="Common\CodeAnalysisExtensions.fs" />
4847
<Compile Include="Common\ContentType.fs" />
49-
<Compile Include="Common\Error.fs" />
5048
<Compile Include="Common\Vs.fs" />
5149
<Compile Include="Options\SettingsPersistence.fs" />
5250
<Compile Include="Options\UIHelpers.fs" />
5351
<Compile Include="Options\EditorOptions.fs" />
5452
<Compile Include="LanguageService\Tokenizer.fs" />
5553
<Compile Include="LanguageService\Symbols.fs" />
5654
<Compile Include="LanguageService\FSharpCheckerExtensions.fs" />
55+
<Compile Include="LanguageService\IProjectSite.fs" />
56+
<Compile Include="LanguageService\ProjectSitesAndFiles.fs" />
5757
<Compile Include="LanguageService\LanguageService.fs" />
5858
<Compile Include="LanguageService\AssemblyContentProvider.fs" />
5959
<Compile Include="LanguageService\SymbolHelpers.fs" />
@@ -107,11 +107,6 @@
107107
<Project>{DED3BBD7-53F4-428A-8C9F-27968E768605}</Project>
108108
<Name>FSharp.Core</Name>
109109
</ProjectReference>
110-
<ProjectReference Include="$(FSharpSourcesRoot)\..\vsintegration\src\FSharp.LanguageService\FSharp.LanguageService.fsproj">
111-
<Name>FSharp.LanguageService</Name>
112-
<Project>{ee85aab7-cda0-4c4e-bda0-a64ccc413e3f}</Project>
113-
<Private>True</Private>
114-
</ProjectReference>
115110
<ProjectReference Include="$(FSharpSourcesRoot)\..\vsintegration\src\FSharp.LanguageService.Base\FSharp.LanguageService.Base.csproj">
116111
<Name>FSharp.LanguageService.Base</Name>
117112
<Project>{1c5c163c-37ea-4a3c-8ccc-0d34b74bf8ef}</Project>
@@ -132,8 +127,6 @@
132127
<Project>{991dcf75-c2eb-42b6-9a0d-aa1d2409d519}</Project>
133128
<Private>True</Private>
134129
</ProjectReference>
135-
</ItemGroup>
136-
<ItemGroup>
137130
<Reference Include="mscorlib" />
138131
<Reference Include="PresentationFramework" />
139132
<Reference Include="System.Windows.Forms" />
@@ -146,8 +139,6 @@
146139
<Reference Include="System" />
147140
<Reference Include="PresentationCore" />
148141
<Reference Include="System.ComponentModel.Composition" />
149-
</ItemGroup>
150-
<ItemGroup>
151142
<Reference Include="EnvDTE">
152143
<HintPath>$(FSharpSourcesRoot)\..\packages\EnvDTE.8.0.1\lib\net10\EnvDTE.dll</HintPath>
153144
<Private>True</Private>
@@ -156,6 +147,10 @@
156147
<HintPath>$(FSharpSourcesRoot)\..\packages\EnvDTE80.8.0.1\lib\net10\EnvDTE80.dll</HintPath>
157148
<Private>True</Private>
158149
</Reference>
150+
<Reference Include="VSLangProj">
151+
<HintPath>$(FSharpSourcesRoot)\..\packages\VSSDK.VSLangProj.7.0.4\lib\net20\VSLangProj.dll</HintPath>
152+
<Private>True</Private>
153+
</Reference>
159154
<Reference Include="Microsoft.VisualStudio.Threading">
160155
<HintPath>$(FSharpSourcesRoot)\..\packages\Microsoft.VisualStudio.Threading.$(MicrosoftVisualStudioThreadingVersion)\lib\net45\Microsoft.VisualStudio.Threading.dll</HintPath>
161156
</Reference>
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
2+
3+
namespace Microsoft.VisualStudio.FSharp.Editor
4+
5+
open System.Runtime.InteropServices
6+
7+
/// Narrow abstraction over the project system.
8+
type internal AdviseProjectSiteChanges = delegate of unit -> unit
9+
10+
[<ComImport; InterfaceType(ComInterfaceType.InterfaceIsIUnknown); Guid("ad98f020-bad0-0000-0000-abc037459871")>]
11+
type internal IProvideProjectSite =
12+
abstract GetProjectSite : unit -> IProjectSite
13+
14+
/// Represents known F#-specific information about a project.
15+
and internal IProjectSite =
16+
17+
/// List of files in the project. In the correct order.
18+
abstract CompilationSourceFiles : string[]
19+
20+
/// Flags that the compiler would need to understand how to compile. Includes '-r'
21+
/// options but not source files
22+
abstract CompilationOptions : string[]
23+
24+
/// The normalized '-r:' assembly references, without the '-r:'
25+
abstract CompilationReferences : string []
26+
27+
/// The '-o:' output bin path, without the '-o:'
28+
abstract CompilationBinOutputPath : string option
29+
30+
/// The name of the project file.
31+
abstract ProjectFileName : string
32+
33+
/// Register for notifications for when the above change
34+
abstract AdviseProjectSiteChanges : callbackOwnerKey: string * AdviseProjectSiteChanges -> unit
35+
36+
/// Register for notifications when project is cleaned/rebuilt (and thus any live TypeProviders should be refreshed)
37+
abstract AdviseProjectSiteCleaned : callbackOwnerKey: string * AdviseProjectSiteChanges -> unit
38+
39+
// Register for notifications when project is closed.
40+
abstract AdviseProjectSiteClosed : callbackOwnerKey: string * AdviseProjectSiteChanges -> unit
41+
42+
/// A user-friendly description of the project. Used only for developer/DEBUG tooltips and such.
43+
abstract Description : string
44+
45+
/// The error list task reporter
46+
abstract BuildErrorReporter : Microsoft.VisualStudio.Shell.Interop.IVsLanguageServiceBuildErrorReporter2 option with get, set
47+
48+
/// False type resolution errors are invalid. This occurs with orphaned source files. The prior
49+
/// type checking state is unknown. In this case we don't want to squiggle the type checking files.
50+
abstract IsIncompleteTypeCheckEnvironment : bool
51+
52+
/// target framework moniker
53+
abstract TargetFrameworkMoniker : string
54+
55+
/// Project Guid
56+
abstract ProjectGuid : string
57+
58+
/// timestamp the site was last loaded
59+
abstract LoadTime : System.DateTime
60+
61+
abstract ProjectProvider : IProvideProjectSite option

vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ open Microsoft.FSharp.Compiler.CompileOps
2323
open Microsoft.FSharp.Compiler.SourceCodeServices
2424
open Microsoft.VisualStudio
2525
open Microsoft.VisualStudio.Editor
26-
open Microsoft.VisualStudio.FSharp.LanguageService
27-
open Microsoft.VisualStudio.FSharp.LanguageService.SiteProvider
26+
open Microsoft.VisualStudio.FSharp.Editor.SiteProvider
2827
open Microsoft.VisualStudio.TextManager.Interop
2928
open Microsoft.VisualStudio.LanguageServices
3029
open Microsoft.VisualStudio.LanguageServices.Implementation.LanguageService

0 commit comments

Comments
 (0)