Skip to content

Commit 9e0254f

Browse files
committed
Minor updates for deprecations and general code changes
1 parent 452f829 commit 9e0254f

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

src/main/java/org/mediawiki/MediaWikiPhpPredefinedCodeStyle.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,14 @@ public void apply(CodeStyleSettings settings) {
2121
CommonCodeStyleSettings commonSettings = settings.getCommonSettings(getLanguage());
2222
commonSettings.KEEP_BLANK_LINES_IN_CODE = 1;
2323
commonSettings.KEEP_BLANK_LINES_BEFORE_RBRACE = 0;
24+
25+
// Don't keep line breaks when reformatting
2426
commonSettings.KEEP_LINE_BREAKS = false;
27+
2528
commonSettings.KEEP_CONTROL_STATEMENT_IN_ONE_LINE = false;
2629

27-
commonSettings.CLASS_BRACE_STYLE = 1;
28-
commonSettings.METHOD_BRACE_STYLE = 1;
30+
commonSettings.CLASS_BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
31+
commonSettings.METHOD_BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
2932

3033
commonSettings.CATCH_ON_NEW_LINE = false;
3134
commonSettings.FINALLY_ON_NEW_LINE = false;
@@ -43,12 +46,13 @@ public void apply(CodeStyleSettings settings) {
4346
commonSettings.SPACE_WITHIN_SWITCH_PARENTHESES = true;
4447
commonSettings.SPACE_WITHIN_ARRAY_INITIALIZER_BRACES = true;
4548
commonSettings.SPACE_AFTER_TYPE_CAST = false;
49+
// Doesn't seem to exist?
4650
// commonSettings.SPACES_AROUND_VAR_WITHIN_BRACKETS = false;
4751

48-
commonSettings.IF_BRACE_FORCE = 3;
49-
commonSettings.FOR_BRACE_FORCE = 3;
50-
commonSettings.DOWHILE_BRACE_FORCE = 3;
51-
commonSettings.WHILE_BRACE_FORCE = 3;
52+
commonSettings.IF_BRACE_FORCE = CommonCodeStyleSettings.FORCE_BRACES_ALWAYS;
53+
commonSettings.FOR_BRACE_FORCE = CommonCodeStyleSettings.FORCE_BRACES_ALWAYS;
54+
commonSettings.DOWHILE_BRACE_FORCE = CommonCodeStyleSettings.FORCE_BRACES_ALWAYS;
55+
commonSettings.WHILE_BRACE_FORCE = CommonCodeStyleSettings.FORCE_BRACES_ALWAYS;
5256

5357
commonSettings.ARRAY_INITIALIZER_WRAP = 2;
5458
commonSettings.ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE = true;
@@ -81,9 +85,6 @@ public void apply(CodeStyleSettings settings) {
8185
// Doesn't seem to exist?
8286
// commonSettings.SOFT_MARGINS = 100;
8387

84-
// Don't keep line breaks when reformatting
85-
commonSettings.KEEP_LINE_BREAKS = false;
86-
8788
PhpCodeStyleSettings phpSettings = settings.getCustomSettings(PhpCodeStyleSettings.class);
8889
phpSettings.LOWER_CASE_BOOLEAN_CONST = true;
8990
phpSettings.LOWER_CASE_NULL_CONST = true;

src/main/java/org/mediawiki/MediaWikiSearchDocsAction.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.mediawiki;
1818

1919
import com.intellij.ide.BrowserUtil;
20+
import com.intellij.openapi.actionSystem.ActionUpdateThread;
2021
import com.intellij.openapi.actionSystem.AnAction;
2122
import com.intellij.openapi.actionSystem.AnActionEvent;
2223
import com.intellij.openapi.actionSystem.CommonDataKeys;
@@ -26,14 +27,14 @@
2627
import org.jetbrains.annotations.NotNull;
2728
import org.jetbrains.annotations.Nullable;
2829

29-
import java.io.UnsupportedEncodingException;
3030
import java.net.URLEncoder;
31+
import java.nio.charset.StandardCharsets;
3132

3233
/**
3334
* @author Reedy
3435
*/
3536
public class MediaWikiSearchDocsAction extends AnAction {
36-
public void update(AnActionEvent event) {
37+
public void update(@NotNull AnActionEvent event) {
3738
boolean enabled = getSelectedText(event) != null;
3839
event.getPresentation().setEnabled(enabled);
3940
event.getPresentation().setVisible(enabled);
@@ -49,7 +50,7 @@ private static String getSelectedText(AnActionEvent e) {
4950
return StringUtil.nullize(selectedText, true);
5051
}
5152

52-
public void actionPerformed(AnActionEvent event) {
53+
public void actionPerformed(@NotNull AnActionEvent event) {
5354
String selectedText = getSelectedText(event);
5455
if (selectedText == null) {
5556
return;
@@ -59,10 +60,10 @@ public void actionPerformed(AnActionEvent event) {
5960

6061
@NonNls
6162
private static String getSearchUrl(@NotNull String textToSearch) {
62-
try {
63-
return "https://www.mediawiki.org/w/index.php?title=Special%3ASearch&profile=default&fulltext=Search&search=" + URLEncoder.encode(textToSearch, "UTF-8");
64-
} catch (UnsupportedEncodingException e) {
65-
}
66-
return "";
63+
return "https://www.mediawiki.org/w/index.php?title=Special%3ASearch&profile=default&fulltext=Search&search=" + URLEncoder.encode(textToSearch, StandardCharsets.UTF_8);
64+
}
65+
66+
public @NotNull ActionUpdateThread getActionUpdateThread() {
67+
return ActionUpdateThread.BGT;
6768
}
6869
}

0 commit comments

Comments
 (0)