Skip to content

Commit d454282

Browse files
authored
Merge branch 'main' into launch-config-update
2 parents 9ef1d82 + 62ede83 commit d454282

File tree

9 files changed

+186
-33
lines changed

9 files changed

+186
-33
lines changed

build.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
patches/8442-draft.diff
6363
patches/8460-draft.diff
6464
patches/8470.diff
65+
patches/8484.diff
6566
patches/disable-error-notification.diff
6667
patches/mvn-sh.diff
6768
patches/project-marker-jdk.diff

patches/8484.diff

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
diff --git a/ide/editor.document/src/org/netbeans/api/editor/document/LineDocumentUtils.java b/ide/editor.document/src/org/netbeans/api/editor/document/LineDocumentUtils.java
2+
index 5fb34c754a..247dda8b82 100644
3+
--- a/ide/editor.document/src/org/netbeans/api/editor/document/LineDocumentUtils.java
4+
+++ b/ide/editor.document/src/org/netbeans/api/editor/document/LineDocumentUtils.java
5+
@@ -30,7 +30,6 @@ import org.netbeans.lib.editor.util.swing.DocumentUtilities;
6+
import org.netbeans.modules.editor.document.DocumentServices;
7+
import org.netbeans.modules.editor.document.TextSearchUtils;
8+
import org.netbeans.modules.editor.document.implspi.CharClassifier;
9+
-import org.netbeans.modules.editor.lib2.AcceptorFactory;
10+
import org.netbeans.spi.editor.document.DocumentFactory;
11+
import org.openide.util.Lookup;
12+
13+
diff --git a/java/java.source.base/src/org/netbeans/modules/java/source/save/Reformatter.java b/java/java.source.base/src/org/netbeans/modules/java/source/save/Reformatter.java
14+
index 0e44783168..3202b2ac97 100644
15+
--- a/java/java.source.base/src/org/netbeans/modules/java/source/save/Reformatter.java
16+
+++ b/java/java.source.base/src/org/netbeans/modules/java/source/save/Reformatter.java
17+
@@ -2565,7 +2565,36 @@ public class Reformatter implements ReformatTask {
18+
StatementTree elseStat = node.getElseStatement();
19+
CodeStyle.BracesGenerationStyle redundantIfBraces = cs.redundantIfBraces();
20+
int eoln = findNewlineAfterStatement(node);
21+
- if ((elseStat != null && redundantIfBraces == CodeStyle.BracesGenerationStyle.ELIMINATE && danglingElseChecker.hasDanglingElse(node.getThenStatement())) ||
22+
+ Boolean hasErrThenStatement = node.getThenStatement() instanceof ExpressionStatementTree thenStatement
23+
+ && thenStatement.getExpression() instanceof ErroneousTree;
24+
+ if (hasErrThenStatement) {
25+
+ if (getCurrentPath().getParentPath().getLeaf() instanceof BlockTree parentStTree) {
26+
+ boolean isPreviousIfTree = false;
27+
+ int endPositionOfErrThenStatement = endPos;
28+
+ for (StatementTree statement : parentStTree.getStatements()) {
29+
+ if (isPreviousIfTree) {
30+
+ int startPositionOfNextErrorStatement = (int) sp.getStartPosition(getCurrentPath().getCompilationUnit(), statement);
31+
+ endPositionOfErrThenStatement = startPositionOfNextErrorStatement;
32+
+ break;
33+
+ } else if (statement == node) {
34+
+ isPreviousIfTree = true;
35+
+ endPositionOfErrThenStatement = (int) sp.getEndPosition(getCurrentPath().getCompilationUnit(), parentStTree) - 1;
36+
+ }
37+
+
38+
+ }
39+
+ if (isPreviousIfTree) {
40+
+ while (tokens.offset() <= endPositionOfErrThenStatement && endPositionOfErrThenStatement != -1) {
41+
+ tokens.moveNext();
42+
+ }
43+
+ tokens.movePrevious();
44+
+ if (endPositionOfErrThenStatement != -1) {
45+
+ endPos = endPositionOfErrThenStatement;
46+
+ }
47+
+ }
48+
+ }
49+
+ }
50+
+
51+
+ if (hasErrThenStatement || (elseStat != null && redundantIfBraces == CodeStyle.BracesGenerationStyle.ELIMINATE && danglingElseChecker.hasDanglingElse(node.getThenStatement())) ||
52+
(redundantIfBraces == CodeStyle.BracesGenerationStyle.GENERATE && (startOffset > sp.getStartPosition(root, node) || endOffset < eoln || node.getCondition().getKind() == Tree.Kind.ERRONEOUS))) {
53+
redundantIfBraces = CodeStyle.BracesGenerationStyle.LEAVE_ALONE;
54+
}
55+
diff --git a/java/java.source.base/test/unit/src/org/netbeans/modules/java/source/save/FormatingTest.java b/java/java.source.base/test/unit/src/org/netbeans/modules/java/source/save/FormatingTest.java
56+
index 8797b9111b..d5962a9ba3 100644
57+
--- a/java/java.source.base/test/unit/src/org/netbeans/modules/java/source/save/FormatingTest.java
58+
+++ b/java/java.source.base/test/unit/src/org/netbeans/modules/java/source/save/FormatingTest.java
59+
@@ -1556,6 +1556,76 @@ public class FormatingTest extends NbTestCase {
60+
preferences.putBoolean("specialElseIf", false);
61+
reformat(doc, content, golden);
62+
preferences.putBoolean("specialElseIf", true);
63+
+
64+
+ content = """
65+
+ package hierbas.del.litoral;
66+
+ class Test extends Integer implements Runnable, Serializable{
67+
+ public void run(){
68+
+ if ("foo".contains("bar"))))) ))) {
69+
+ System.out.println("bar");
70+
+ }
71+
+ }
72+
+ }
73+
+ """;
74+
+ golden = """
75+
+ package hierbas.del.litoral;
76+
+
77+
+ class Test extends Integer implements Runnable, Serializable {
78+
+
79+
+ public void run() {
80+
+ if ("foo".contains("bar"))))) ))) {
81+
+ System.out.println("bar");
82+
+ }
83+
+ }
84+
+ }
85+
+ """;
86+
+ reformat(doc, content, golden);
87+
+
88+
+ content = """
89+
+ package hierbas.del.litoral;
90+
+ class Test extends Integer implements Runnable, Serializable{
91+
+ public void run(){
92+
+ if ("foo".contains("bar"))))) )))
93+
+ }
94+
+ }
95+
+ """;
96+
+ golden = """
97+
+ package hierbas.del.litoral;
98+
+
99+
+ class Test extends Integer implements Runnable, Serializable {
100+
+
101+
+ public void run() {
102+
+ if ("foo".contains("bar"))))) )))
103+
+ }
104+
+ }
105+
+ """;
106+
+ reformat(doc, content, golden);
107+
+
108+
+ content = """
109+
+ package hierbas.del.litoral;
110+
+ class Test extends Integer implements Runnable, Serializable{
111+
+ public void run(){
112+
+ if ("foo".contains("bar"))))) )))
113+
+ else {
114+
+ System.out.println("bar2")
115+
+ }
116+
+ }
117+
+ }
118+
+ """;
119+
+ golden = """
120+
+ package hierbas.del.litoral;
121+
+
122+
+ class Test extends Integer implements Runnable, Serializable {
123+
+
124+
+ public void run() {
125+
+ if ("foo".contains("bar"))))) )))
126+
+ else {
127+
+ System.out.println("bar2")
128+
+ }
129+
+ }
130+
+ }
131+
+ """;
132+
+ reformat(doc, content, golden);
133+
}
134+
135+
public void testWhile() throws Exception {

vscode/l10n/bundle.l10n.en.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,7 @@
9696
"jdk.workspace.new.prompt": "Input the directory path where the new file will be generated",
9797
"jdk.extension.utils.error_message.failedHttpsRequest": "Failed to get {url} ({statusCode})",
9898
"jdk.extension.error_msg.notEnabled": "{SERVER_NAME} not enabled",
99-
"jdk.telemetry.consent": "Allow anonymous telemetry data to be reported to Oracle? You may opt-out or in at any time from the Settings for jdk.telemetry.enabled."
99+
"jdk.telemetry.consent": "Allow anonymous telemetry data to be reported to Oracle? You may opt-out or in at any time from the Settings for jdk.telemetry.enabled.",
100+
"jdk.configChanged": "Configurations updated for oracle java extenion , please reload the window to restart the extension.",
101+
"jdk.configChangedFailed": "Error while updating extension configurations , please reload the window to restart the extension."
100102
}

vscode/l10n/bundle.l10n.ja.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,7 @@
9696
"jdk.workspace.new.prompt": "新しいファイルを生成するディレクトリのパスを入力してください",
9797
"jdk.extension.utils.error_message.failedHttpsRequest": "{url}の取得に失敗しました({statusCode})",
9898
"jdk.extension.error_msg.notEnabled": "{SERVER_NAME}が有効化されていません",
99-
"jdk.telemetry.consent": "匿名テレメトリ・データをOracleにレポートすることを許可しますか。jdk.telemetry.enabledの設定からいつでもオプトアウトまたはオプトインできます。"
99+
"jdk.telemetry.consent": "匿名テレメトリ・データをOracleにレポートすることを許可しますか。jdk.telemetry.enabledの設定からいつでもオプトアウトまたはオプトインできます。",
100+
"jdk.configChanged": "Configurations updated for oracle java extenion , please reload the window to restart the extension.",
101+
"jdk.configChangedFailed": "Error while updating extension configurations , please reload the window to restart the extension."
100102
}

vscode/l10n/bundle.l10n.zh-cn.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,7 @@
9696
"jdk.workspace.new.prompt": "输入生成新文件的目录路径",
9797
"jdk.extension.utils.error_message.failedHttpsRequest": "无法获取 {url} ({statusCode})",
9898
"jdk.extension.error_msg.notEnabled": "{SERVER_NAME} 未启用",
99-
"jdk.telemetry.consent": "是否允许向 Oracle 报告匿名遥测数据?您随时可以通过 jdk.telemetry.enabled 对应的设置选择退出或加入。"
99+
"jdk.telemetry.consent": "是否允许向 Oracle 报告匿名遥测数据?您随时可以通过 jdk.telemetry.enabled 对应的设置选择退出或加入。",
100+
"jdk.configChanged": "Configurations updated for oracle java extenion , please reload the window to restart the extension.",
101+
"jdk.configChangedFailed": "Error while updating extension configurations , please reload the window to restart the extension."
100102
}

vscode/src/commands/buildOperations.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { l10n } from "../localiser";
1919
import { extCommands, nbCommands } from "./commands";
2020
import { ICommand } from "./types";
2121
import { wrapCommandWithProgress, wrapProjectActionWithProgress } from "./utils";
22-
import { workspace } from "vscode";
22+
import { window, workspace } from "vscode";
2323
import * as fs from 'fs';
2424

2525
const saveFilesInWorkspaceBeforeBuild = async (callbackFn: Function) => {
@@ -52,22 +52,31 @@ const cleanWorkspaceHandler = () => {
5252
}
5353

5454
const compileProjectHandler = (args: any) => {
55+
let commandArgs = args;
56+
if (!commandArgs) {
57+
commandArgs = window.activeTextEditor?.document.uri.toString();
58+
}
59+
5560
const compileProjectFunction = () =>
5661
wrapProjectActionWithProgress('build',
5762
undefined, l10n.value('jdk.extension.command.progress.compilingProject'),
5863
LOGGER.getOutputChannel(),
59-
args
64+
commandArgs
6065
);
6166

6267
saveFilesInWorkspaceBeforeBuild(compileProjectFunction);
6368
}
6469

6570
const cleanProjectHandler = (args: any) => {
71+
let commandArgs = args;
72+
if (!commandArgs) {
73+
commandArgs = window.activeTextEditor?.document.uri.toString();
74+
}
6675
const cleanProjectHandler = () => wrapProjectActionWithProgress('clean',
6776
undefined,
6877
l10n.value('jdk.extension.command.progress.cleaningProject'),
6978
LOGGER.getOutputChannel(),
70-
args
79+
commandArgs
7180
);
7281

7382
saveFilesInWorkspaceBeforeBuild(cleanProjectHandler);

vscode/src/constants.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ export namespace jdkDownloaderConstants {
3434
export const ORACLE_JDK_FALLBACK_VESIONS = ['24', '21'];
3535

3636
export const OPEN_JDK_VERSION_DOWNLOAD_LINKS: { [key: string]: string } = {
37-
"24": "https://download.java.net/java/GA/jdk24.0.1/24a58e0e276943138bf3e963e6291ac2/9/GPL/openjdk-24.0.1"
37+
"24": "https://download.java.net/java/GA/jdk24.0.2/fdc5d0102fe0414db21410ad5834341f/12/GPL/openjdk-24.0.2"
3838
};
3939
}
40-
4140
export const NODE_WINDOWS_LABEL = "Windows_NT";

vscode/src/lsp/clientPromise.ts

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
16-
import { commands } from "vscode";
16+
import { commands, window } from "vscode";
1717
import { LOGGER } from "../logger";
1818
import { NbProcessManager } from "./nbProcessManager";
1919
import { clientInit } from "./initializer";
2020
import { NbLanguageClient } from "./nbLanguageClient";
2121
import { globalState } from "../globalState";
22+
import { l10n } from "../localiser";
2223

2324
export class ClientPromise {
2425
setClient!: [(c: NbLanguageClient) => void, (err: any) => void];
@@ -60,24 +61,32 @@ export class ClientPromise {
6061
}
6162

6263
public restartExtension = async (nbProcessManager: NbProcessManager | null, notifyKill: boolean) => {
63-
if (this.activationPending) {
64-
LOGGER.warn("Server activation requested repeatedly, ignoring...");
65-
return;
66-
}
67-
if (!nbProcessManager) {
64+
if (nbProcessManager) {
65+
try {
66+
globalState.setDeactivated(true);
67+
await this.stopClient();
68+
await nbProcessManager.killProcess(notifyKill);
69+
this.initialize();
70+
clientInit();
71+
} catch (error) {
72+
LOGGER.error(`Error during activation: ${error}`);
73+
const reloadNow: string = l10n.value("jdk.downloader.message.reload");
74+
const dialogBoxMessage = l10n.value("jdk.configChangedFailed");
75+
const selected = await window.showInformationMessage(dialogBoxMessage, reloadNow);
76+
if (selected === reloadNow) {
77+
await commands.executeCommand('workbench.action.reloadWindow');
78+
}
79+
} finally {
80+
this.activationPending = false;
81+
}
82+
}else{
6883
LOGGER.error("Nbcode Process is null");
69-
return;
70-
}
71-
try {
72-
await this.stopClient();
73-
await nbProcessManager.killProcess(notifyKill);
74-
this.initialize();
75-
clientInit();
76-
} catch (error) {
77-
LOGGER.error(`Error during activation: ${error}`);
78-
throw error;
79-
} finally {
80-
this.activationPending = false;
84+
const reloadNow: string = l10n.value("jdk.downloader.message.reload");
85+
const dialogBoxMessage = l10n.value("jdk.configChanged");
86+
const selected = await window.showInformationMessage(dialogBoxMessage, reloadNow);
87+
if (selected === reloadNow) {
88+
await commands.executeCommand('workbench.action.reloadWindow');
89+
}
8190
}
8291
}
8392

vscode/src/webviews/jdkDownloader/action.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,7 @@ export class JdkDownloaderAction {
121121
dialogBoxMessage = l10n.value("jdk.downloader.message.completedInstallingJdk");
122122
}
123123
LOGGER.log(`JDK installation completed successfully`);
124-
125-
const reloadNow: string = l10n.value("jdk.downloader.message.reload");
126-
const selected = await window.showInformationMessage(dialogBoxMessage, reloadNow);
127-
if (selected === reloadNow) {
128-
await this.downloaderView.disposeView();
129-
await commands.executeCommand('workbench.action.reloadWindow');
130-
}
124+
await window.showInformationMessage(dialogBoxMessage);
131125
}
132126

133127
private jdkInstallationManager = async () => {

0 commit comments

Comments
 (0)