Skip to content

Commit

Permalink
Change priority of Compile Solidity File menu item.
Browse files Browse the repository at this point in the history
  • Loading branch information
allisterb committed Dec 28, 2023
1 parent db7e73e commit 7348461
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
namespace Stratis.VS.StratisEVM
{
[ExportFileContextActionProvider((FileContextActionProviderOptions)VsCommandActionProviderOptions.SupportVsCommands, ProviderType, ProviderPriority.Normal, StratisEVMPackageIds.SolidityFileContextType)]
public class WordCountActionProviderFactory : IWorkspaceProviderFactory<IFileContextActionProvider>, IVsCommandActionProvider
public class SolidityFileContextActionProviderFactory : IWorkspaceProviderFactory<IFileContextActionProvider>, IVsCommandActionProvider
{
// Unique Guid for WordCountActionProvider.
private const string ProviderType = "e4c4063b-0682-43b6-aff5-f81dec7029a5";
Expand All @@ -24,25 +24,25 @@ public class WordCountActionProviderFactory : IWorkspaceProviderFactory<IFileCon
private static readonly IReadOnlyList<CommandID> SupportedCommands = new List<CommandID>
{
new CommandID(StratisEVMPackageIds.GuidStratisEVMPackageCmdSet, StratisEVMPackageIds.Cmd1Id),
new CommandID(StratisEVMPackageIds.GuidStratisEVMPackageCmdSet, StratisEVMPackageIds.Cmd2Id),
//new CommandID(StratisEVMPackageIds.GuidStratisEVMPackageCmdSet, StratisEVMPackageIds.Cmd2Id),
};

public IFileContextActionProvider CreateProvider(IWorkspace workspaceContext)
{
return new WordCountActionProvider(workspaceContext);
return new SolidityFileContextActionProvider(workspaceContext);
}

public IReadOnlyCollection<CommandID> GetSupportedVsCommands()
{
return SupportedCommands;
}

internal class WordCountActionProvider : IFileContextActionProvider
internal class SolidityFileContextActionProvider : IFileContextActionProvider
{
private static readonly Guid ActionOutputWindowPane = new Guid("b9319ea3-b873-442f-abaa-3c1c1c00fd08");
private IWorkspace workspaceContext;

internal WordCountActionProvider(IWorkspace workspaceContext)
internal SolidityFileContextActionProvider(IWorkspace workspaceContext)
{
this.workspaceContext = workspaceContext;
}
Expand All @@ -62,6 +62,7 @@ public Task<IReadOnlyList<IFileContextAction>> GetActionsAsync(string filePath,
}),

// Toggle word count type command:
/*
new MyContextAction(
fileContext,
new Tuple<Guid, uint>(ProviderCommandGroup, StratisEVMPackageIds.Cmd2Id),
Expand All @@ -70,6 +71,7 @@ public Task<IReadOnlyList<IFileContextAction>> GetActionsAsync(string filePath,
{
await OutputWindowPaneAsync("command 2");
}),
*/
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ class SolidityFileContextProviderFactory : IWorkspaceProviderFactory<IFileContex
/// <inheritdoc/>
public IFileContextProvider CreateProvider(IWorkspace workspaceContext)
{
return new TxtFileContextProvider(workspaceContext);
return new SolidityFileContextProvider(workspaceContext);
}

private class TxtFileContextProvider : IFileContextProvider
private class SolidityFileContextProvider : IFileContextProvider
{
private IWorkspace workspaceContext;

internal TxtFileContextProvider(IWorkspace workspaceContext)
internal SolidityFileContextProvider(IWorkspace workspaceContext)
{
this.workspaceContext = workspaceContext;
}
Expand All @@ -40,7 +40,7 @@ public async Task<IReadOnlyCollection<FileContext>> GetContextsForFileAsync(stri

if (filePath.EndsWith(".sol"))
{
Runtime.Info("adding file contxt");
Runtime.Debug("Adding file context for file {file}.", filePath);
fileContexts.Add(new FileContext(
new Guid(ProviderType),
new Guid(StratisEVMPackageIds.SolidityFileContextType),
Expand Down
2 changes: 1 addition & 1 deletion src/Stratis.VS.StratisEVM/StratisEVMPackage.vsct
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
group as the part of a menu contained between two lines. The parent of a group
must be a menu. -->
<Groups>
<Group guid="guidStratisEVMPackageCmdSet" id="MyMenuGroup" priority="0x0600">
<Group guid="guidStratisEVMPackageCmdSet" id="MyMenuGroup" priority="0x0200">
<Parent guid="guidWorkspaceExplorerToolWindowCmdSet" id="idmWSE_ContextMenu"/>
</Group>
</Groups>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ pragma solidity ^0.8.23;

contract ReceivesEth {
uint public amount = 1 et;

receive() external payable {
require(msg.value == amount, "Wrong amount");
llll++

}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
solidity: "0.8.23",
solidity: {
version: "0.8.23",
settings: {}
},
};
21 changes: 21 additions & 0 deletions tests/solidity/test2/BasicContract.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

// Uncomment this line to use console.log
// import "hardhat/console.sol";

contract BasicContract {
event BasicEvent(uint eventArg);

receive() external payable {}

function basicFunction(uint funcArg) public {
// Uncomment this line, and the import of "hardhat/console.sol", to print a log in your terminal
// console.log("Unlock time is %o and block timestamp is %o", unlockTime, block.timestamp);
emit BasicEvent(funcArg);
}

function foo(uint s) private pure {
s = 4;
}
}
7 changes: 7 additions & 0 deletions tests/solidity/test2/hardhat.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
solidity: {
version: "0.8.23",
settings: {}
},
};

0 comments on commit 7348461

Please sign in to comment.