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
1 change: 1 addition & 0 deletions vsintegration/src/FSharp.Editor/Common/RoslynHelpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ 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 =
Expand Down
70 changes: 1 addition & 69 deletions vsintegration/src/FSharp.Editor/Common/Vs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,84 +3,16 @@
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 =
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

module internal Com =
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
Expand Down
19 changes: 12 additions & 7 deletions vsintegration/src/FSharp.Editor/FSharp.Editor.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
<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>
Expand All @@ -40,20 +42,18 @@
<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" />
<Compile Include="Options\EditorOptions.fs" />
<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" />
Expand Down Expand Up @@ -107,6 +107,11 @@
<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>
Expand All @@ -127,6 +132,8 @@
<Project>{991dcf75-c2eb-42b6-9a0d-aa1d2409d519}</Project>
<Private>True</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Reference Include="mscorlib" />
<Reference Include="PresentationFramework" />
<Reference Include="System.Windows.Forms" />
Expand All @@ -139,6 +146,8 @@
<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>
Expand All @@ -147,10 +156,6 @@
<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>
Expand Down
61 changes: 0 additions & 61 deletions vsintegration/src/FSharp.Editor/LanguageService/IProjectSite.fs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ open Microsoft.FSharp.Compiler.CompileOps
open Microsoft.FSharp.Compiler.SourceCodeServices
open Microsoft.VisualStudio
open Microsoft.VisualStudio.Editor
open Microsoft.VisualStudio.FSharp.Editor.SiteProvider
open Microsoft.VisualStudio.FSharp.LanguageService
open Microsoft.VisualStudio.FSharp.LanguageService.SiteProvider
open Microsoft.VisualStudio.TextManager.Interop
open Microsoft.VisualStudio.LanguageServices
open Microsoft.VisualStudio.LanguageServices.Implementation.LanguageService
Expand Down
Loading