Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to enable Java when no other Java support extension is currently installed #5889

Merged
merged 1 commit into from
Apr 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 29 additions & 16 deletions java/java.lsp.server/vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,23 +344,36 @@ export function activate(context: ExtensionContext): VSNetBeansAPI {

function checkConflict(): void {
let conf = workspace.getConfiguration();
if (conf.get("netbeans.conflict.check") && conf.get("netbeans.javaSupport.enabled")) {
const e : boolean | undefined = shouldEnableConflictingJavaSupport();
if (!e && vscode.extensions.getExtension('redhat.java')) {
if (e === false) {
// do not ask, an extension wants us to disable on conflict
conf.update("netbeans.javaSupport.enabled", false, true);
} else {
const DISABLE_EXTENSION = `Manually disable extension`;
const DISABLE_JAVA = `Disable Java in Apache NetBeans Language Server`;
vscode.window.showInformationMessage(`Another Java support extension is already installed. It is recommended to use only one Java support per workspace.`, DISABLE_EXTENSION, DISABLE_JAVA).then((selected) => {
if (DISABLE_EXTENSION === selected) {
vscode.commands.executeCommand('workbench.extensions.action.showInstalledExtensions');
} else if (DISABLE_JAVA === selected) {
conf.update("netbeans.javaSupport.enabled", false, true);
}
});
if (conf.get("netbeans.conflict.check")) {
if (conf.get("netbeans.javaSupport.enabled")) {
const e : boolean | undefined = shouldEnableConflictingJavaSupport();
if (!e && vscode.extensions.getExtension('redhat.java')) {
if (e === false) {
// do not ask, an extension wants us to disable on conflict
conf.update("netbeans.javaSupport.enabled", false, true);
} else {
const DISABLE_EXTENSION = `Manually disable extension`;
const DISABLE_JAVA = `Disable Java in Apache NetBeans Language Server`;
vscode.window.showInformationMessage(`Another Java support extension is already installed. It is recommended to use only one Java support per workspace.`, DISABLE_EXTENSION, DISABLE_JAVA).then((selected) => {
if (DISABLE_EXTENSION === selected) {
vscode.commands.executeCommand('workbench.extensions.action.showInstalledExtensions');
} else if (DISABLE_JAVA === selected) {
conf.update("netbeans.javaSupport.enabled", false, true);
}
});
}
}
} else if (!vscode.extensions.getExtension('redhat.java')) {
workspace.findFiles(`**/*.java`, undefined, 1).then(files => {
if (files.length) {
const ENABLE_JAVA = `Enable Java in Apache NetBeans Language Server`;
vscode.window.showInformationMessage(`Java in Apache NetBeans Language Server is disabled and no other Java support extension is currently installed.`, ENABLE_JAVA).then((selected) => {
if (ENABLE_JAVA === selected) {
conf.update("netbeans.javaSupport.enabled", true, true);
}
});
}
});
}
}
}
Expand Down