Skip to content

Commit 5a5dee3

Browse files
adding fmtall/clippyall commands + fixing buildall
1 parent 41f2a8e commit 5a5dee3

File tree

6 files changed

+59
-13
lines changed

6 files changed

+59
-13
lines changed

.github/workflows/cdp.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,14 @@ jobs:
8787
fail-on-error: true
8888

8989
- name: Upload VSIX
90-
uses: actions/upload-artifact@v3
90+
uses: actions/upload-artifact@v4
9191
with:
9292
name: ${{ github.event.repository.name }}.zip
9393
path: ${{ env.OutDir }}${{ env.VsixFileName }}
9494
if-no-files-found: error
9595

9696
- name: Upload TestAdapter
97-
uses: actions/upload-artifact@v3
97+
uses: actions/upload-artifact@v4
9898
with:
9999
name: ${{ env.TestAdapterNameNoExt }}.zip
100100
path: ${{ env.OutDir }}${{ env.TestAdapterNameNoExt }}.zip

src/RustAnalyzer/Shell/CmdServices.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ public sealed class CmdServices
2121
{
2222
private IComponentModel2 _mef;
2323
private ILogger _l;
24-
private ITelemetryService _t;
2524
private ShellInterop.IVsSolution _solution;
2625
private ShellInterop.IVsDebugger _debugger;
2726
private ShellInterop.IVsUIShell _vsUIShell;
2827
private IToolchainService _toolchainService;
28+
private ISettingsService _settingsService;
2929
private IBuildOutputSink _buildOutputSink;
3030
private IVsFolderWorkspaceService _folderWorkspaceService;
3131

@@ -40,19 +40,19 @@ public CmdServices(Func<AsyncPackage> getPackage)
4040

4141
public IBuildOutputSink BuildOutputSink => _buildOutputSink ??= Mef?.GetService<IBuildOutputSink>();
4242

43-
private IComponentModel2 Mef => _mef ??= GetPackage().GetService<SComponentModel, IComponentModel2>(false);
43+
public IComponentModel2 Mef => _mef ??= GetPackage().GetService<SComponentModel, IComponentModel2>(false);
4444

45-
private ITelemetryService T => _t ??= Mef?.GetService<ITelemetryService>();
45+
public ILogger L => _l ??= Mef?.GetService<ILogger>();
4646

47-
private ILogger L => _l ??= Mef?.GetService<ILogger>();
47+
public ShellInterop.IVsSolution Solution => _solution ??= GetPackage().GetService<ShellInterop.SVsSolution, ShellInterop.IVsSolution>(false);
4848

49-
private ShellInterop.IVsSolution Solution => _solution ??= GetPackage().GetService<ShellInterop.SVsSolution, ShellInterop.IVsSolution>(false);
49+
public ShellInterop.IVsDebugger Debugger => _debugger ??= GetPackage().GetService<ShellInterop.SVsShellDebugger, ShellInterop.IVsDebugger>(false);
5050

51-
private ShellInterop.IVsDebugger Debugger => _debugger ??= GetPackage().GetService<ShellInterop.SVsShellDebugger, ShellInterop.IVsDebugger>(false);
51+
public IToolchainService ToolchainService => _toolchainService ??= Mef?.GetService<IToolchainService>();
5252

53-
private IToolchainService ToolchainService => _toolchainService ??= Mef?.GetService<IToolchainService>();
53+
public ISettingsService SettingsService => _settingsService ??= FolderWorkspaceService?.CurrentWorkspace?.GetService<ISettingsService>();
5454

55-
private IVsFolderWorkspaceService FolderWorkspaceService => _folderWorkspaceService ??= Mef?.GetService<IVsFolderWorkspaceService>();
55+
public IVsFolderWorkspaceService FolderWorkspaceService => _folderWorkspaceService ??= Mef?.GetService<IVsFolderWorkspaceService>();
5656

5757
private readonly IMapper _buildMessageMapper = new MapperConfiguration(cfg => cfg.CreateMap<DetailedBuildMessage, WorkspaceBuildMessage>()).CreateMapper();
5858

src/RustAnalyzer/Shell/RustToolsCommands.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
using KS.RustAnalyzer.TestAdapter.Common;
1212
using Microsoft.VisualStudio;
1313
using Microsoft.VisualStudio.Shell;
14-
using CommunityVS = Community.VisualStudio.Toolkit.VS;
1514

1615
namespace KS.RustAnalyzer.Shell;
1716

src/RustAnalyzer/Shell/ToolChainCommands.cs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,16 @@ protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
9595
await CmdServices.ExecuteToolchainOperationAsync(Operation, selectedPath, GetOptions);
9696
}
9797

98-
private PathEx GetManifestPath()
98+
protected PathEx GetManifestPath()
9999
{
100100
ThreadHelper.ThrowIfNotOnUIThread();
101101

102102
return CmdServices.GetWorkspaceRoot() + Constants.ManifestFileName2;
103103
}
104104

105+
protected string GetToolArgsFromSettings(string argName)
106+
=> RustAnalyzerPackage.JTF.Run(async () => await CmdServices.SettingsService.GetAsync(argName, GetManifestPath()));
107+
105108
private bool IsCommandActive()
106109
{
107110
ThreadHelper.ThrowIfNotOnUIThread();
@@ -116,7 +119,7 @@ public class BuildAllCommand : BaseBuildToolChainCommand<BuildAllCommand>
116119
{
117120
protected override ToolchainOperation Operation => its => its.BuildAsync;
118121

119-
protected override string GetOptions(Options opts) => opts.AdditionalBuildArguments;
122+
protected override string GetOptions(Options opts) => GetToolArgsFromSettings(SettingsInfo.TypeAdditionalBuildArguments);
120123
}
121124

122125
[Command(PackageGuids.guidRustAnalyzerPackageString, PackageIds.IdCleanAll)]
@@ -126,3 +129,19 @@ public class CleanAllCommand : BaseBuildToolChainCommand<CleanAllCommand>
126129

127130
protected override string GetOptions(Options opts) => string.Empty;
128131
}
132+
133+
[Command(PackageGuids.guidRustAnalyzerPackageString, PackageIds.IdClippyAll)]
134+
public class ClippyAll : BaseBuildToolChainCommand<ClippyAll>
135+
{
136+
protected override ToolchainOperation Operation => its => its.RunClippyAsync;
137+
138+
protected override string GetOptions(Options opts) => opts.DefaultCargoClippyArgs;
139+
}
140+
141+
[Command(PackageGuids.guidRustAnalyzerPackageString, PackageIds.IdFmtAll)]
142+
public class FmtAllCommand : BaseBuildToolChainCommand<FmtAllCommand>
143+
{
144+
protected override ToolchainOperation Operation => its => its.RunFmtAsync;
145+
146+
protected override string GetOptions(Options opts) => opts.DefaultCargoFmtArgs;
147+
}

src/RustAnalyzer/VSCommandTable.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ internal sealed partial class PackageIds
5151
public const int IdCargoFmt = 0x0101;
5252
public const int IdBuildAll = 0x0102;
5353
public const int IdCleanAll = 0x0103;
54+
public const int IdClippyAll = 0x0104;
55+
public const int IdFmtAll = 0x0105;
5456
public const int IdGTargetSystem = 0x0010;
5557
public const int IdTargetSystemCombo = 0x0100;
5658
public const int IdTargetSystemComboGetList = 0x0101;

src/RustAnalyzer/VSCommandTable.vsct

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,28 @@
172172
<ButtonText>&amp;Clean Workspace</ButtonText>
173173
</Strings>
174174
</Button>
175+
176+
<Button guid="guidRustAnalyzerPackage" id="IdClippyAll" priority="0x0102" type="Button">
177+
<Parent guid="guidSHLMainMenu" id="IDG_VS_BUILD_SOLUTION" />
178+
<CommandFlag>IconIsMoniker</CommandFlag>
179+
<CommandFlag>DynamicVisibility</CommandFlag>
180+
<CommandFlag>DefaultDisabled</CommandFlag>
181+
<CommandFlag>DefaultInvisible</CommandFlag>
182+
<Strings>
183+
<ButtonText>C&amp;lippy Workspace</ButtonText>
184+
</Strings>
185+
</Button>
186+
187+
<Button guid="guidRustAnalyzerPackage" id="IdFmtAll" priority="0x0103" type="Button">
188+
<Parent guid="guidSHLMainMenu" id="IDG_VS_BUILD_SOLUTION" />
189+
<CommandFlag>IconIsMoniker</CommandFlag>
190+
<CommandFlag>DynamicVisibility</CommandFlag>
191+
<CommandFlag>DefaultDisabled</CommandFlag>
192+
<CommandFlag>DefaultInvisible</CommandFlag>
193+
<Strings>
194+
<ButtonText>&amp;Fmt Workspace</ButtonText>
195+
</Strings>
196+
</Button>
175197
</Buttons>
176198

177199
<Combos>
@@ -203,6 +225,8 @@
203225

204226
<KeyBindings>
205227
<KeyBinding guid="guidRustAnalyzerPackage" id="IdBuildAll" editor="guidVSStd97" key1="B" mod1="Control Alt Shift" />
228+
<KeyBinding guid="guidRustAnalyzerPackage" id="IdClippyAll" editor="guidVSStd97" key1="L" mod1="Control Alt Shift" />
229+
<KeyBinding guid="guidRustAnalyzerPackage" id="IdFmtAll" editor="guidVSStd97" key1="F" mod1="Control Alt Shift" />
206230
</KeyBindings>
207231

208232
<CommandPlacements>
@@ -252,6 +276,8 @@
252276
<IDSymbol name="IdCargoFmt" value="0x0101" />
253277
<IDSymbol name="IdBuildAll" value="0x0102" />
254278
<IDSymbol name="IdCleanAll" value="0x0103" />
279+
<IDSymbol name="IdClippyAll" value="0x0104" />
280+
<IDSymbol name="IdFmtAll" value="0x0105" />
255281
</GuidSymbol>
256282

257283
<GuidSymbol name="guidRustAnalyzerTargetSystemCmdSet" value="{76879a43-4f48-45d1-922c-54f713889a1f}">

0 commit comments

Comments
 (0)