Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita1cbffb

Browse files
vasily-kirichenkoKevinRansom
authored andcommitted
Enable previewing (dotnet#2417)
* enable previewing on FileNode* update DocumentManager* fix compilation* add "CommonPhysicalViewAttributes = (int)__VSPHYSICALVIEWATTRIBUTES.PVA_SupportsPreview)"* Go do Definition opens documents in the preview tab* add System.ValueTuple.dll to .gitignore* do not show error dialog on single click on missing filecode cleanup* show "missing file" icon in solution explorer if a file is missing* don't use IVsRunningDocumentTable4 in DocumentManager to make tests happy* revert DocumentManager and FileDocumentManager as it's impossible to fix the tests* fix duplicated tabs* use TextView logical view kind to open documents in DoDefaultAction instead of erasing one passed outside
1 parent17657d2 commita1cbffb

File tree

10 files changed

+85
-74
lines changed

10 files changed

+85
-74
lines changed

‎.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,5 @@ times
107107
source_link.json
108108
.vs/
109109
/VSRelease/net40/bin
110+
System.ValueTuple.dll
111+
tests/fsharpqa/testenv/bin/System.ValueTuple.dll
30 KB
Binary file not shown.

‎vsintegration/src/FSharp.Editor/Navigation/GoToDefinitionService.fs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ type internal FSharpGoToDefinitionService
9797
letworkspace= document.Project.Solution.Workspace
9898
letnavigationService= workspace.Services.GetService<IDocumentNavigationService>()
9999
ignore presenters
100-
navigationService.TryNavigateToSpan(workspace, navigableItem.Document.Id, navigableItem.SourceSpan)
100+
// prefer open documents in the preview tab
101+
letoptions= workspace.Options.WithChangedOption(NavigationOptions.PreferProvisionalTab,true)
102+
navigationService.TryNavigateToSpan(workspace, navigableItem.Document.Id, navigableItem.SourceSpan, options)
101103

102104
// FSROSLYNTODO: potentially display multiple results here
103105
// If GotoDef returns one result then it should try to jump to a discovered location. If it returns multiple results then it should use

‎vsintegration/src/FSharp.ProjectSystem.Base/Project/DocumentManager.cs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
usingSystem.Globalization;
88
usingSystem.Runtime.InteropServices;
99
usingSystem.Security;
10-
usingSystem.Windows;
10+
usingSystem.Windows;
1111
usingMicrosoft.VisualStudio.OLE.Interop;
1212
usingMicrosoft.VisualStudio.Shell;
1313
usingSystem.Drawing;
@@ -36,7 +36,7 @@ public HierarchyNode Node
3636
returnthis.node;
3737
}
3838
}
39-
39+
4040
publicDocumentManager(HierarchyNodenode)
4141
{
4242
this.node=node;
@@ -184,7 +184,7 @@ public string GetOwnerCaption()
184184

185185
return(pvarasstring);
186186
}
187-
187+
188188
publicvoidCloseWindowFrame(refIVsWindowFramewindowFrame)
189189
{
190190
if(windowFrame!=null)
@@ -336,4 +336,4 @@ public static void RenameDocument(IServiceProvider site, string oldName, string
336336
}
337337
}
338338
}
339-
}
339+
}

‎vsintegration/src/FSharp.ProjectSystem.Base/Project/FSharpEditorFactory.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
namespaceMicrosoft.VisualStudio.FSharp.ProjectSystem
1818
{
1919
[Guid(Constants.FSharpEditorFactoryIdString)]
20-
[ProvideEditorFactory(typeof(FSharpEditorFactory),101)]
20+
[ProvideEditorFactory(typeof(FSharpEditorFactory),101,CommonPhysicalViewAttributes=(int)__VSPHYSICALVIEWATTRIBUTES.PVA_SupportsPreview)]
2121
[ProvideEditorExtension(typeof(FSharpEditorFactory),".fs",32)]
2222
[ProvideEditorExtension(typeof(FSharpEditorFactory),".fsi",32)]
2323
[ProvideEditorExtension(typeof(FSharpEditorFactory),".fsscript",32)]

‎vsintegration/src/FSharp.ProjectSystem.Base/Project/FileDocumentManager.cs‎

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public int Open(bool newFile, bool openWith, WindowFrameShowAction windowFrameAc
7777
{
7878
GuidlogicalView=Guid.Empty;
7979
IVsWindowFramewindowFrame=null;
80-
returnthis.Open(newFile,openWith,logicalView,logicalView,outwindowFrame,windowFrameAction);
80+
returnthis.Open(newFile,openWith,logicalView,outwindowFrame,windowFrameAction);
8181
}
8282

8383
/// <summary>
@@ -89,7 +89,7 @@ public int Open(bool newFile, bool openWith, WindowFrameShowAction windowFrameAc
8989
/// <param name="frame">A reference to the window frame that is mapped to the file</param>
9090
/// <param name="windowFrameAction">Determine the UI action on the document window</param>
9191
/// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code.</returns>
92-
publicintOpen(boolnewFile,boolopenWith,GuidlogicalView,GuidfallbackLogicalView,outIVsWindowFrameframe,WindowFrameShowActionwindowFrameAction)
92+
publicintOpen(boolnewFile,boolopenWith,GuidlogicalView,outIVsWindowFrameframe,WindowFrameShowActionwindowFrameAction)
9393
{
9494
frame=null;
9595
IVsRunningDocumentTablerdt=this.Node.ProjectMgr.Site.GetService(typeof(SVsRunningDocumentTable))asIVsRunningDocumentTable;
@@ -112,11 +112,7 @@ public int Open(bool newFile, bool openWith, Guid logicalView, Guid fallbackLogi
112112
try
113113
{
114114
ErrorHandler.ThrowOnFailure(rdt.FindAndLockDocument((uint)flags,path,outivsHierarchy,outitemid,outdocData,outdocCookie));
115-
varhr=this.Open(newFile,openWith,reflogicalView,docData,outframe,windowFrameAction);
116-
if(hr!=VSConstants.S_OK&&fallbackLogicalView!=logicalView)
117-
{
118-
ErrorHandler.ThrowOnFailure(this.Open(newFile,openWith,reffallbackLogicalView,docData,outframe,windowFrameAction));
119-
}
115+
ErrorHandler.ThrowOnFailure(this.Open(newFile,openWith,reflogicalView,docData,outframe,windowFrameAction));
120116
}
121117
catch(COMExceptione)
122118
{
@@ -166,15 +162,12 @@ private int Open(bool newFile, bool openWith, uint editorFlags, ref Guid editorT
166162
intreturnValue=VSConstants.S_OK;
167163
stringcaption=this.GetOwnerCaption();
168164
stringfullPath=this.GetFullPathForDocument();
169-
165+
170166
// Make sure that the file is on disk before we open the editor and display message if not found
171167
if(!((FileNode)this.Node).IsFileOnDisk(true))
172168
{
173-
// Inform clients that we have an invalid item (wrong icon)
174-
this.Node.OnInvalidateItems(this.Node.Parent);
175-
176169
// Bail since we are not able to open the item
177-
// Do not return an error code otherwise anpublic error message is shown. The scenario for this operation
170+
// Do not return an error code otherwise aninternal error message is shown. The scenario for this operation
178171
// normally is already a reaction to a dialog box telling that the item has been removed.
179172
returnVSConstants.S_FALSE;
180173
}
@@ -186,7 +179,7 @@ private int Open(bool newFile, bool openWith, uint editorFlags, ref Guid editorT
186179
{
187180
this.Node.ProjectMgr.OnOpenItem(fullPath);
188181
intresult=VSConstants.E_FAIL;
189-
182+
190183
if(openWith)
191184
{
192185
result=uiShellOpenDocument.OpenStandardEditor((uint)__VSOSEFLAGS.OSE_UseOpenWithDialog,fullPath,reflogicalView,caption,Node.ProjectMgr.InteropSafeIVsUIHierarchy,this.Node.ID,docDataExisting,serviceProvider,outwindowFrame);
@@ -197,8 +190,8 @@ private int Open(bool newFile, bool openWith, uint editorFlags, ref Guid editorT
197190
if(newFile)
198191
{
199192
openFlags|=__VSOSEFLAGS.OSE_OpenAsNewFile;
200-
}
201-
193+
}
194+
202195
//NOTE: we MUST pass the IVsProject in pVsUIHierarchy and the itemid
203196
// of the node being opened, otherwise the debugger doesn't work.
204197
if(editorType!=Guid.Empty)
@@ -256,4 +249,4 @@ private int Open(bool newFile, bool openWith, uint editorFlags, ref Guid editorT
256249
returnreturnValue;
257250
}
258251
}
259-
}
252+
}

‎vsintegration/src/FSharp.ProjectSystem.Base/Project/FileNode.cs‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ public override string Caption
9292
returncaption;
9393
}
9494
}
95+
9596
publicoverrideintImageIndex
9697
{
9798
get
@@ -466,16 +467,16 @@ public override int ExecCommandOnNode(Guid cmdGroup, uint cmd, uint nCmdexecopt,
466467
switch((VsCommands)cmd)
467468
{
468469
caseVsCommands.ViewCode:
469-
return((FileDocumentManager)this.GetDocumentManager()).Open(false,false,VSConstants.LOGVIEWID_Code,VSConstants.LOGVIEWID_Code,outwindowFrame,WindowFrameShowAction.Show);
470+
return((FileDocumentManager)this.GetDocumentManager()).Open(false,false,VSConstants.LOGVIEWID_Code,outwindowFrame,WindowFrameShowAction.Show);
470471

471472
caseVsCommands.ViewForm:
472-
return((FileDocumentManager)this.GetDocumentManager()).Open(false,false,VSConstants.LOGVIEWID_Designer,VSConstants.LOGVIEWID_Designer,outwindowFrame,WindowFrameShowAction.Show);
473+
return((FileDocumentManager)this.GetDocumentManager()).Open(false,false,VSConstants.LOGVIEWID_Designer,outwindowFrame,WindowFrameShowAction.Show);
473474

474475
caseVsCommands.Open:
475476
return((FileDocumentManager)this.GetDocumentManager()).Open(false,false,WindowFrameShowAction.Show);
476477

477478
caseVsCommands.OpenWith:
478-
return((FileDocumentManager)this.GetDocumentManager()).Open(false,true,VSConstants.LOGVIEWID_UserChooseView,VSConstants.LOGVIEWID_UserChooseView,outwindowFrame,WindowFrameShowAction.Show);
479+
return((FileDocumentManager)this.GetDocumentManager()).Open(false,true,VSConstants.LOGVIEWID_UserChooseView,outwindowFrame,WindowFrameShowAction.Show);
479480
}
480481
}
481482

@@ -1070,5 +1071,10 @@ private List<HierarchyNode> GetChildNodes()
10701071
}
10711072
returnchildNodes;
10721073
}
1074+
1075+
publicoverride__VSPROVISIONALVIEWINGSTATUSProvisionalViewingStatus=>
1076+
IsFileOnDisk(false)
1077+
?__VSPROVISIONALVIEWINGSTATUS.PVS_Enabled
1078+
:__VSPROVISIONALVIEWINGSTATUS.PVS_Disabled;
10731079
}
1074-
}
1080+
}

‎vsintegration/src/FSharp.ProjectSystem.Base/Project/HierarchyNode.cs‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,12 @@ public virtual object GetProperty(int propId)
797797
result=this.ProjectMgr.GetProjectProperty("TargetPlatformIdentifier");
798798
}
799799

800+
if(propId==(int)__VSHPROPID5.VSHPROPID_ProvisionalViewingStatus)
801+
{
802+
// Indicates that the node support previewing
803+
result=ProvisionalViewingStatus;
804+
}
805+
800806
#ifDEBUG
801807
if(propId!=LastTracedProperty)
802808
{
@@ -3287,5 +3293,7 @@ public int GetResourceItem(uint itemidDocument, string pszCulture, uint grfPRF,
32873293
{
32883294
thrownewNotImplementedException();
32893295
}
3296+
3297+
publicvirtual__VSPROVISIONALVIEWINGSTATUSProvisionalViewingStatus=>__VSPROVISIONALVIEWINGSTATUS.PVS_Disabled;
32903298
}
32913299
}

‎vsintegration/src/FSharp.ProjectSystem.FSharp/Project.fs‎

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2151,26 +2151,28 @@ namespace rec Microsoft.VisualStudio.FSharp.ProjectSystem
21512151
base.Dispose(disposing)
21522152

21532153
overridex.ImageIndex=
2154-
if(x.IsFormSubType)then
2155-
int32 ProjectNode.ImageName.WindowsForm
2156-
elif(FSharpProjectNode.IsFSharpCodeFileIconwise(x.FileName))then
2157-
FSharpProjectNode.ImageOffset+ int32 FSharpImageName.FsFile
2158-
elif(FSharpProjectNode.IsFSharpSignatureFileIconwise(x.FileName))then
2159-
FSharpProjectNode.ImageOffset+ int32 FSharpImageName.FsiFile
2160-
elif(FSharpProjectNode.IsFSharpScriptFileIconwise(x.FileName))then
2161-
FSharpProjectNode.ImageOffset+ int32 FSharpImageName.FsxFile
2162-
else
2163-
base.ImageIndex
2154+
// Check if the file is there.
2155+
ifnot(x.CanShowDefaultIcon())then
2156+
int ProjectNode.ImageName.MissingFile
2157+
elif x.IsFormSubTypethen
2158+
int ProjectNode.ImageName.WindowsForm
2159+
elif(FSharpProjectNode.IsFSharpCodeFileIconwise(x.FileName))then
2160+
FSharpProjectNode.ImageOffset+ int FSharpImageName.FsFile
2161+
elif(FSharpProjectNode.IsFSharpSignatureFileIconwise(x.FileName))then
2162+
FSharpProjectNode.ImageOffset+ int FSharpImageName.FsiFile
2163+
elif(FSharpProjectNode.IsFSharpScriptFileIconwise(x.FileName))then
2164+
FSharpProjectNode.ImageOffset+ int FSharpImageName.FsxFile
2165+
else
2166+
base.ImageIndex
21642167

21652168
/// Open a file depending on the SubType property associated with the file item in the project file
21662169
overridex.DoDefaultAction()=
21672170
letmanager=(x.GetDocumentManager():?> FileDocumentManager)
21682171
Debug.Assert(manager<>null,"Could not get the FileDocumentManager")
21692172

2170-
letviewGuid=(if x.IsFormSubTypethen VSConstants.LOGVIEWID_Designerelse VSConstants.LOGVIEWID_Primary)
2171-
letfallbackViewGuid=(if x.IsFormSubTypethen VSConstants.LOGVIEWID_Primaryelse VSConstants.LOGVIEWID_Designer)
2173+
letviewGuid=(if x.IsFormSubTypethen VSConstants.LOGVIEWID_Designerelse VSConstants.LOGVIEWID_TextView)
21722174
let mutableframe:IVsWindowFrame=null
2173-
manager.Open(false,false, viewGuid,fallbackViewGuid,&frame, WindowFrameShowAction.Show)|> ignore
2175+
manager.Open(false,false, viewGuid,&frame, WindowFrameShowAction.Show)|> ignore
21742176

21752177
/// In solution explorer, move the last of my siblings to just above me, return the moved FSharpFileNode
21762178
static memberMoveLastToAbove(target:HierarchyNode,root:FSharpProjectNode):FSharpFileNode=

‎vsintegration/src/FSharp.ProjectSystem.FSharp/ProjectSystem.fsproj‎

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,39 @@
2929
<GeneratePkgDefFile>true</GeneratePkgDefFile>
3030
<IncludePkgdefInVSIXContainer>true</IncludePkgdefInVSIXContainer>
3131
</PropertyGroup>
32+
<ImportProject="$(FSharpSourcesRoot)\FSharpSource.targets" />
33+
<ImportProject="$(FSharpSourcesRoot)\..\vsintegration\vsintegration.targets" />
34+
<ImportProject="$(VsSDKInstall)\Microsoft.VsSDK.targets" />
35+
<PropertyGroup>
36+
<BuildingProject>true</BuildingProject>
37+
<BuildDependsOn>VSCTCompile;CopyCtoFile;$(BuildDependsOn)</BuildDependsOn>
38+
</PropertyGroup>
39+
<TargetName="CopyCtoFile">
40+
<CopySourceFiles="@(VSCTCompile->'$(IntermediateOutputPath)%(FileName).cto')"DestinationFiles="@(VSCTCompile->'ctofiles\%(FileName).cto')" />
41+
</Target>
42+
<PropertyGroup>
43+
<Win32Resource>$(IntermediateOutputPath)\ProjectResources.rc.res</Win32Resource>
44+
</PropertyGroup>
45+
<TargetName="BeforeBuild">
46+
<ExecCommand="&quot;$(ProgramFiles)\Windows Kits\8.1\bin\x86\rc.exe&quot; /fo $(IntermediateOutputPath)$(RCResourceFile).res $(RCResourceFile)"Condition="Exists('$(ProgramFiles)\Windows Kits\8.1\bin\x86\rc.exe')" />
47+
<ExecCommand="&quot;$(ProgramFiles)\Windows Kits\10\bin\x86\rc.exe&quot; /fo $(IntermediateOutputPath)$(RCResourceFile).res $(RCResourceFile)"Condition="Exists('$(ProgramFiles)\Windows Kits\10\bin\x86\rc.exe')" />
48+
</Target>
49+
<TargetName="GatherBinariesToBeSigned"AfterTargets="Localize"Condition="'$(UseGatherBinaries)' == 'true'">
50+
<ItemGroup>
51+
<BinariesToBeSignedInclude="$(OutDir)$(AssemblyName).dll" />
52+
<BinariesToBeSignedInclude="$(OutDir)localize\**\$(AssemblyName).resources.dll" />
53+
<FilesToSignInclude="@(BinariesToBeSigned)">
54+
<Authenticode>Microsoft</Authenticode>
55+
<StrongName>StrongName</StrongName>
56+
</FilesToSign>
57+
</ItemGroup>
58+
</Target>
59+
<TargetName="CopyLocalizationResources"BeforeTargets="Localize">
60+
<ItemGroup>
61+
<LocalizationResourcesInclude="MenusAndCommands.vsct" />
62+
</ItemGroup>
63+
<CopySourceFiles="@(LocalizationResources)"DestinationFiles="@(LocalizationResources->'$(OutDir)%(Filename)%(Extension)')" />
64+
</Target>
3265
<ItemGroup>
3366
<FilesToLocalizeInclude="$(OutDir)$(AssemblyName).dll">
3467
<TranslationFile>$(FSharpSourcesRoot)\..\loc\lcl\{Lang}\$(AssemblyName).dll.lcl</TranslationFile>
@@ -44,8 +77,6 @@
4477
<Link>FSharp.ProjectSystem.FSharp.dll</Link>
4578
<Parser>210</Parser>
4679
</FilesToLocalize>
47-
</ItemGroup>
48-
<ItemGroup>
4980
<VSCTCompileInclude="MenusAndCommands.vsct" />
5081
<EmbeddedResourceInclude="VSPackage.resx">
5182
<MergeWithCTO>true</MergeWithCTO>
@@ -161,37 +192,4 @@
161192
<Name>FSharp.Core</Name>
162193
</ProjectReference>
163194
</ItemGroup>
164-
<ImportProject="$(FSharpSourcesRoot)\FSharpSource.targets" />
165-
<ImportProject="$(FSharpSourcesRoot)\..\vsintegration\vsintegration.targets" />
166-
<ImportProject="$(VsSDKInstall)\Microsoft.VsSDK.targets" />
167-
<PropertyGroup>
168-
<BuildingProject>true</BuildingProject>
169-
<BuildDependsOn>VSCTCompile;CopyCtoFile;$(BuildDependsOn)</BuildDependsOn>
170-
</PropertyGroup>
171-
<TargetName="CopyCtoFile">
172-
<CopySourceFiles="@(VSCTCompile->'$(IntermediateOutputPath)%(FileName).cto')"DestinationFiles="@(VSCTCompile->'ctofiles\%(FileName).cto')" />
173-
</Target>
174-
<PropertyGroup>
175-
<Win32Resource>$(IntermediateOutputPath)\ProjectResources.rc.res</Win32Resource>
176-
</PropertyGroup>
177-
<TargetName="BeforeBuild">
178-
<ExecCommand="&quot;$(ProgramFiles)\Windows Kits\8.1\bin\x86\rc.exe&quot; /fo $(IntermediateOutputPath)$(RCResourceFile).res $(RCResourceFile)"Condition="Exists('$(ProgramFiles)\Windows Kits\8.1\bin\x86\rc.exe')" />
179-
<ExecCommand="&quot;$(ProgramFiles)\Windows Kits\10\bin\x86\rc.exe&quot; /fo $(IntermediateOutputPath)$(RCResourceFile).res $(RCResourceFile)"Condition="Exists('$(ProgramFiles)\Windows Kits\10\bin\x86\rc.exe')" />
180-
</Target>
181-
<TargetName="GatherBinariesToBeSigned"AfterTargets="Localize"Condition="'$(UseGatherBinaries)' == 'true'">
182-
<ItemGroup>
183-
<BinariesToBeSignedInclude="$(OutDir)$(AssemblyName).dll" />
184-
<BinariesToBeSignedInclude="$(OutDir)localize\**\$(AssemblyName).resources.dll" />
185-
<FilesToSignInclude="@(BinariesToBeSigned)">
186-
<Authenticode>Microsoft</Authenticode>
187-
<StrongName>StrongName</StrongName>
188-
</FilesToSign>
189-
</ItemGroup>
190-
</Target>
191-
<TargetName="CopyLocalizationResources"BeforeTargets="Localize">
192-
<ItemGroup>
193-
<LocalizationResourcesInclude="MenusAndCommands.vsct" />
194-
</ItemGroup>
195-
<CopySourceFiles="@(LocalizationResources)"DestinationFiles="@(LocalizationResources->'$(OutDir)%(Filename)%(Extension)')" />
196-
</Target>
197195
</Project>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp