Skip to content

Commit

Permalink
Merge pull request #61 from joutvhu/v242
Browse files Browse the repository at this point in the history
Reformat code
  • Loading branch information
joutvhu authored Aug 10, 2024
2 parents 3081e6b + 4ec52e7 commit 56e742c
Show file tree
Hide file tree
Showing 14 changed files with 128 additions and 118 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static Map<String, String> getActionParams(YAMLKeyValue element) {
} else if (element.getValue() instanceof YAMLBlockMappingImpl yamlBlockMapping) {
for (PsiElement child = yamlBlockMapping.getFirstChild(); child != null; child = child.getNextSibling()) {
if (child instanceof YAMLKeyValue yamlKeyValue && yamlKeyValue.getValue() instanceof YAMLScalar) {
params.put(yamlKeyValue.getKeyText(),yamlKeyValue.getValueText());
params.put(yamlKeyValue.getKeyText(), yamlKeyValue.getValueText());
}
}
return params;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public class PubspecRunScriptAction extends AnAction {
public static final String TERMINAL_KEY = "terminal";

public PubspecRunScriptAction(
@Nullable @NlsActions.ActionText String text,
@Nullable @NlsActions.ActionDescription String description,
@Nullable Icon icon
@Nullable @NlsActions.ActionText String text,
@Nullable @NlsActions.ActionDescription String description,
@Nullable Icon icon
) {
super(text, description, icon);
}
Expand All @@ -50,10 +50,10 @@ public void actionPerformed(@NotNull AnActionEvent e) {
String workingDirectory = file.getVirtualFile().getParent().getPath();
if (params.containsKey(DIRECTORY_KEY)) {
workingDirectory = Paths.get(workingDirectory)
.resolve(params.get(DIRECTORY_KEY))
.normalize()
.toAbsolutePath()
.toString();
.resolve(params.get(DIRECTORY_KEY))
.normalize()
.toAbsolutePath()
.toString();
}
Boolean executeInTerminal = null;
if (params.containsKey(TERMINAL_KEY)) {
Expand All @@ -65,12 +65,12 @@ public void actionPerformed(@NotNull AnActionEvent e) {
}

PubspecTerminalHelper.runScript(
this.getExecutor(),
e.getData(CommonDataKeys.PROJECT),
element.getKeyText(),
scriptText,
workingDirectory,
executeInTerminal);
this.getExecutor(),
e.getData(CommonDataKeys.PROJECT),
element.getKeyText(),
scriptText,
workingDirectory,
executeInTerminal);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ public class DartScriptConfigurationType extends SimpleConfigurationType {

DartScriptConfigurationType() {
super(
ID, CONFIGURATION_NAME,
DartBundle.message("ds.run.configuration.description.0.configuration", CONFIGURATION_NAME),
NotNullLazyValue.createConstantValue(DartIcons.ScriptIcon)
ID, CONFIGURATION_NAME,
DartBundle.message("ds.run.configuration.description.0.configuration", CONFIGURATION_NAME),
NotNullLazyValue.createConstantValue(DartIcons.ScriptIcon)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ private static void writePathWithMetadata(@NotNull Element element, @NotNull Str

private static String readPathWithMetadata(@NotNull Element element, @NotNull String pathTag) {
return Boolean.parseBoolean(JDOMExternalizerUtil.readField(element, TAG_PREFIX + pathTag))
? readStringTagValue(element, pathTag)
: FileUtil.toSystemDependentName(readStringTagValue(element, pathTag));
? readStringTagValue(element, pathTag)
: FileUtil.toSystemDependentName(readStringTagValue(element, pathTag));
}

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public class DartScriptRunConfigurationEditor extends SettingsEditor<DartScriptR

DartScriptRunConfigurationEditor(Project project) {
myScriptWorkingDirectory.addBrowseFolderListener(
DartBundle.message("ds.label.choose.script.working.directory"),
"", project,
FileChooserDescriptorFactory.createSingleFolderDescriptor()
DartBundle.message("ds.label.choose.script.working.directory"),
"", project,
FileChooserDescriptorFactory.createSingleFolderDescriptor()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,7 @@ private static void addIfPresent(@NotNull List<String> commandLine, @Nullable St
ContainerUtil.addIfNotNull(commandLine, StringUtil.nullize(options));
}

private static void addIfPresent(
@NotNull List<String> commandLine,
@NotNull Map<String, String> envs
) {
private static void addIfPresent(@NotNull List<String> commandLine, @NotNull Map<String, String> envs) {
int index = 0;
for (Map.Entry<String, String> entry : envs.entrySet()) {
String key = entry.getKey();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

public interface DartScriptRunner {
void run(
@NotNull Project project,
@NotNull String command,
@NotNull String workingDirectory,
@NotNull @NlsContexts.TabTitle String title,
boolean activateToolWindow
@NotNull Project project,
@NotNull String command,
@NotNull String workingDirectory,
@NotNull @NlsContexts.TabTitle String title,
boolean activateToolWindow
);

boolean isAvailable(@NotNull Project project);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ public class DartScriptTerminalRunner implements DartScriptRunner {
private static final Logger logger = Logger.getInstance(DartScriptTerminalRunner.class);

public void run(
@NotNull Project project,
@NotNull String command,
@NotNull String workingDirectory,
@NotNull @NlsContexts.TabTitle String title,
boolean activateToolWindow
@NotNull Project project,
@NotNull String command,
@NotNull String workingDirectory,
@NotNull @NlsContexts.TabTitle String title,
boolean activateToolWindow
) {
TerminalToolWindowManager terminalView = TerminalToolWindowManager.getInstance(project);
ToolWindow window = ToolWindowManager.getInstance(project)
.getToolWindow(TerminalToolWindowFactory.TOOL_WINDOW_ID);
.getToolWindow(TerminalToolWindowFactory.TOOL_WINDOW_ID);
if (window == null) {
return;
}
Expand All @@ -42,9 +42,9 @@ public void run(
try {
if (pair == null) {
terminalView.createShellWidget(
workingDirectory,
title,
activateToolWindow,
workingDirectory,
title,
activateToolWindow,
true
).sendCommandToExecute(command);
return;
Expand All @@ -62,13 +62,13 @@ public void run(

public boolean isAvailable(@NotNull Project project) {
ToolWindow window = ToolWindowManager.getInstance(project)
.getToolWindow(TerminalToolWindowFactory.TOOL_WINDOW_ID);
.getToolWindow(TerminalToolWindowFactory.TOOL_WINDOW_ID);
return window != null && window.isAvailable();
}

private static @Nullable Pair<Content, ShellTerminalWidget> getSuitableProcess(
@NotNull ContentManager contentManager,
@NotNull String workingDirectory
@NotNull ContentManager contentManager,
@NotNull String workingDirectory
) {
Content selectedContent = contentManager.getSelectedContent();
if (selectedContent != null) {
Expand All @@ -78,15 +78,15 @@ public boolean isAvailable(@NotNull Project project) {
}

return Arrays.stream(contentManager.getContents())
.map(content -> getSuitableProcess(content, workingDirectory))
.filter(Objects::nonNull)
.findFirst()
.orElse(null);
.map(content -> getSuitableProcess(content, workingDirectory))
.filter(Objects::nonNull)
.findFirst()
.orElse(null);
}

private static @Nullable Pair<Content, ShellTerminalWidget> getSuitableProcess(
@NotNull Content content,
@NotNull String workingDirectory
@NotNull Content content,
@NotNull String workingDirectory
) {
JBTerminalWidget widget = TerminalToolWindowManager.getWidgetByContent(content);
if (!(widget instanceof ShellTerminalWidget shellTerminalWidget))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@
@UtilityClass
public class PubspecTerminalHelper {
public RunConfiguration runScript(
Executor executor,
Project project,
String name,
String script,
String workingDirectory,
Boolean executeInTerminal
Executor executor,
Project project,
String name,
String script,
String workingDirectory,
Boolean executeInTerminal
) {
RunManager runManager = RunManager.getInstance(project);
DartScriptConfigurationType configurationType = ConfigurationTypeUtil
.findConfigurationType(DartScriptConfigurationType.class);
.findConfigurationType(DartScriptConfigurationType.class);

RunnerAndConfigurationSettings configurationSettings = runManager
.findConfigurationByTypeAndName(configurationType, name);
.findConfigurationByTypeAndName(configurationType, name);
if (configurationSettings == null) {
configurationSettings = runManager.createConfiguration(name, configurationType);
runManager.addConfiguration(configurationSettings);
Expand All @@ -38,7 +38,7 @@ public RunConfiguration runScript(
runConfiguration.setScriptWorkingDirectory(workingDirectory);

ExecutionEnvironmentBuilder builder = ExecutionEnvironmentBuilder
.createOrNull(executor, runConfiguration);
.createOrNull(executor, runConfiguration);
if (builder != null)
ExecutionManager.getInstance(project).restartRunProfile(builder.build());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ private DartBundle() {
@NotNull
@Nls
public static String message(
@NotNull @PropertyKey(resourceBundle = BUNDLE) String key,
@NotNull Object... params
@NotNull @PropertyKey(resourceBundle = BUNDLE) String key,
@NotNull Object... params
) {
return INSTANCE.getMessage(key, params);
}

@NotNull
public static Supplier<String> messagePointer(
@NotNull @PropertyKey(resourceBundle = BUNDLE) String key,
@NotNull Object... params
@NotNull @PropertyKey(resourceBundle = BUNDLE) String key,
@NotNull Object... params
) {
return INSTANCE.getLazyMessage(key, params);
}
Expand Down
64 changes: 32 additions & 32 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
<idea-plugin>
<id>com.joutvhu.intellij.dart-scripts</id>
<name>Dart Scripts Runner</name>
<category>Other Tools</category>
<vendor email="[email protected]" url="https://github.com/joutvhu">Giao Ho</vendor>
<id>com.joutvhu.intellij.dart-scripts</id>
<name>Dart Scripts Runner</name>
<category>Other Tools</category>
<vendor email="[email protected]" url="https://github.com/joutvhu">Giao Ho</vendor>

<description>
<![CDATA[
<p>Support to run scripts in <b>pubspec.yaml</b> file with just one click.</p>
<br>
<img src="https://github.com/joutvhu/dart-scripts/raw/main/docs/images/pubspec-scripts-running.png" alt="Run script on pubspec.yaml" style="max-width: 100%;">
]]>
</description>
<description>
<![CDATA[
<p>Support to run scripts in <b>pubspec.yaml</b> file with just one click.</p>
<br>
<img src="https://github.com/joutvhu/dart-scripts/raw/main/docs/images/pubspec-scripts-running.png" alt="Run script on pubspec.yaml" style="max-width: 100%;">
]]>
</description>

<change-notes>
<![CDATA[
<a href="https://github.com/joutvhu/dart-scripts/blob/master/CHANGELOG.md">Changelog</a><br/>
<a href="https://github.com/joutvhu/dart-scripts/blob/master/README.md">Readme</a><br/>
<a href="https://github.com/joutvhu/dart-scripts/blob/master/LICENSE">License</a><br/>
]]>
</change-notes>
<change-notes>
<![CDATA[
<a href="https://github.com/joutvhu/dart-scripts/blob/master/CHANGELOG.md">Changelog</a><br/>
<a href="https://github.com/joutvhu/dart-scripts/blob/master/README.md">Readme</a><br/>
<a href="https://github.com/joutvhu/dart-scripts/blob/master/LICENSE">License</a><br/>
]]>
</change-notes>

<!-- please see https://plugins.jetbrains.com/docs/intellij/plugin-compatibility.html
on how to target different products -->
<depends>com.intellij.modules.platform</depends>
<depends>org.jetbrains.plugins.terminal</depends>
<depends>org.jetbrains.plugins.yaml</depends>
<!-- please see https://plugins.jetbrains.com/docs/intellij/plugin-compatibility.html
on how to target different products -->
<depends>com.intellij.modules.platform</depends>
<depends>org.jetbrains.plugins.terminal</depends>
<depends>org.jetbrains.plugins.yaml</depends>

<extensions defaultExtensionNs="com.intellij">
<configurationType implementation="com.joutvhu.intellij.dartscripts.run.DartScriptConfigurationType"/>
<applicationService serviceInterface="com.joutvhu.intellij.dartscripts.run.DartScriptRunner"
serviceImplementation="com.joutvhu.intellij.dartscripts.run.DartScriptTerminalRunner"/>
<codeInsight.lineMarkerProvider language="yaml"
implementationClass="com.joutvhu.intellij.dartscripts.PubspecLineMarkerProvider">
</codeInsight.lineMarkerProvider>
</extensions>
<extensions defaultExtensionNs="com.intellij">
<configurationType implementation="com.joutvhu.intellij.dartscripts.run.DartScriptConfigurationType"/>
<applicationService serviceInterface="com.joutvhu.intellij.dartscripts.run.DartScriptRunner"
serviceImplementation="com.joutvhu.intellij.dartscripts.run.DartScriptTerminalRunner"/>
<codeInsight.lineMarkerProvider language="yaml"
implementationClass="com.joutvhu.intellij.dartscripts.PubspecLineMarkerProvider">
</codeInsight.lineMarkerProvider>
</extensions>

<actions/>
<actions/>
</idea-plugin>
36 changes: 26 additions & 10 deletions src/main/resources/META-INF/pluginIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 56e742c

Please sign in to comment.