Skip to content

Commit 680ed77

Browse files
committed
add abstract create plugin pair method to handle each plugin type
1 parent 07bc2a7 commit 680ed77

File tree

4 files changed

+24
-11
lines changed

4 files changed

+24
-11
lines changed

Flow.Launcher.Core/ExternalPlugins/Environments/AbstractPluginEnvironment.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,20 +112,16 @@ private void EnsureLatestInstalled(string expectedPath, string currentPath, stri
112112

113113
}
114114

115+
internal abstract PluginPair CreatePluginPair(string filePath, PluginMetadata metadata);
116+
115117
private IEnumerable<PluginPair> SetPathForPluginPairs(string filePath, string languageToSet)
116118
{
117119
var pluginPairs = new List<PluginPair>();
118120

119121
foreach (var metadata in PluginMetadataList)
120122
{
121123
if (metadata.Language.Equals(languageToSet, StringComparison.OrdinalIgnoreCase))
122-
{
123-
pluginPairs.Add(new PluginPair
124-
{
125-
Plugin = new PythonPlugin(filePath),
126-
Metadata = metadata
127-
});
128-
}
124+
pluginPairs.Add(CreatePluginPair(filePath, metadata));
129125
}
130126

131127
return pluginPairs;

Flow.Launcher.Core/ExternalPlugins/Environments/PythonEnvironment.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Droplex;
2+
using Flow.Launcher.Core.Plugin;
23
using Flow.Launcher.Infrastructure.UserSettings;
34
using Flow.Launcher.Plugin;
45
using Flow.Launcher.Plugin.SharedCommands;
@@ -34,5 +35,14 @@ internal override void InstallEnvironment()
3435

3536
PluginsSettingsFilePath = ExecutablePath;
3637
}
38+
39+
internal override PluginPair CreatePluginPair(string filePath, PluginMetadata metadata)
40+
{
41+
return new PluginPair
42+
{
43+
Plugin = new PythonPlugin(filePath),
44+
Metadata = metadata
45+
};
46+
}
3747
}
3848
}

Flow.Launcher.Core/ExternalPlugins/Environments/TypeScriptEnvironment.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using Flow.Launcher.Plugin.SharedCommands;
55
using Flow.Launcher.Plugin;
66
using System.IO;
7+
using Flow.Launcher.Core.Plugin;
78

89
namespace Flow.Launcher.Core.ExternalPlugins.Environments
910
{
@@ -30,5 +31,14 @@ internal override void InstallEnvironment()
3031

3132
PluginsSettingsFilePath = ExecutablePath;
3233
}
34+
35+
internal override PluginPair CreatePluginPair(string filePath, PluginMetadata metadata)
36+
{
37+
return new PluginPair
38+
{
39+
Plugin = new NodePlugin(filePath),
40+
Metadata = metadata
41+
};
42+
}
3343
}
3444
}

Flow.Launcher.Core/Plugin/NodePlugin.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ internal class NodePlugin : JsonRPCPlugin
1717
{
1818
private readonly ProcessStartInfo _startInfo;
1919

20-
// TODO: Remove all, not used
2120
public override string SupportedLanguage { get; set; } = AllowedLanguage.Executable;
2221

2322
public NodePlugin(string filename)
@@ -39,9 +38,7 @@ protected override Task<Stream> RequestAsync(JsonRPCRequestModel request, Cancel
3938
}
4039

4140
protected override string Request(JsonRPCRequestModel rpcRequest, CancellationToken token = default)
42-
{
43-
// CONTEXT MENU NOT WORKING ??
44-
41+
{
4542
// since this is not static, request strings will build up in ArgumentList if index is not specified
4643
_startInfo.ArgumentList[1] = rpcRequest.ToString();
4744
return Execute(_startInfo);

0 commit comments

Comments
 (0)