Skip to content

Commit 6a15bba

Browse files
committed
Created JSGraphQLRestartLanguageServiceAction to allow keyboard shortcut (#49)
1 parent accd108 commit 6a15bba

File tree

3 files changed

+33
-6
lines changed

3 files changed

+33
-6
lines changed

resources/META-INF/plugin.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,9 @@
238238
<keyboard-shortcut first-keystroke="meta ENTER" keymap="Mac OS X 10.5+"/>
239239
</action>
240240

241+
<action class="com.intellij.lang.jsgraphql.ide.actions.JSGraphQLRestartLanguageServiceAction" id="com.intellij.lang.jsgraphql.ide.actions.JSGraphQLRestartLanguageServiceAction">
242+
</action>
243+
241244
</actions>
242245

243246
</idea-plugin>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Copyright (c) 2015-present, Jim Kynde Meyer
3+
* All rights reserved.
4+
* <p>
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
package com.intellij.lang.jsgraphql.ide.actions;
9+
10+
import com.intellij.icons.AllIcons;
11+
import com.intellij.lang.jsgraphql.ide.project.JSGraphQLLanguageUIProjectService;
12+
import com.intellij.openapi.actionSystem.AnAction;
13+
import com.intellij.openapi.actionSystem.AnActionEvent;
14+
15+
public class JSGraphQLRestartLanguageServiceAction extends AnAction {
16+
17+
public JSGraphQLRestartLanguageServiceAction() {
18+
super("Restart JS GraphQL Language Service", "Restarts the JS GraphQL Language Service Node.js process", AllIcons.Javaee.UpdateRunningApplication);
19+
}
20+
21+
@Override
22+
public void actionPerformed(AnActionEvent e) {
23+
if (e.getProject() != null) {
24+
JSGraphQLLanguageUIProjectService.getService(e.getProject()).restartInstance();
25+
}
26+
}
27+
}

src/main/com/intellij/lang/jsgraphql/ide/project/JSGraphQLLanguageUIProjectService.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import com.intellij.lang.jsgraphql.icons.JSGraphQLIcons;
3131
import com.intellij.lang.jsgraphql.ide.actions.JSGraphQLEditEndpointsAction;
3232
import com.intellij.lang.jsgraphql.ide.actions.JSGraphQLExecuteEditorAction;
33+
import com.intellij.lang.jsgraphql.ide.actions.JSGraphQLRestartLanguageServiceAction;
3334
import com.intellij.lang.jsgraphql.ide.actions.JSGraphQLToggleVariablesAction;
3435
import com.intellij.lang.jsgraphql.ide.configuration.JSGraphQLConfigurationListener;
3536
import com.intellij.lang.jsgraphql.ide.configuration.JSGraphQLConfigurationProvider;
@@ -152,11 +153,7 @@ public JSGraphQLLanguageUIProjectService(@NotNull final Project project) {
152153
final MessageBusConnection messageBusConnection = project.getMessageBus().connect(this);
153154

154155
// the restart action
155-
AnAction restartInstanceAction = new AnAction("Restart JS GraphQL Language Service", "Restarts the JS GraphQL Language Service Node.js process", AllIcons.Javaee.UpdateRunningApplication) {
156-
public void actionPerformed(AnActionEvent e) {
157-
restartInstance();
158-
}
159-
};
156+
final AnAction restartInstanceAction = ActionManager.getInstance().getAction(JSGraphQLRestartLanguageServiceAction.class.getName());
160157

161158
// tool window
162159
myToolWindowManager = new JSGraphQLLanguageToolWindowManager(project, GRAPH_QL_TOOL_WINDOW_NAME, GRAPH_QL_TOOL_WINDOW_NAME, JSGraphQLIcons.UI.GraphQLNode, restartInstanceAction);
@@ -552,7 +549,7 @@ private void logErrorsForFile(VirtualFile file, boolean forceRefresh) {
552549
}
553550
}
554551

555-
private void restartInstance() {
552+
public void restartInstance() {
556553

557554
synchronized(this.myLock) {
558555
final JSGraphQLNodeLanguageServiceInstance instance = JSGraphQLNodeLanguageServiceClient.getLanguageServiceInstance(myProject);

0 commit comments

Comments
 (0)