Skip to content

Commit

Permalink
Add setting to enable/disable JVM checking. "Do not show again" butto…
Browse files Browse the repository at this point in the history
…n for warning msg
  • Loading branch information
BoykoAlex committed Jun 11, 2020
1 parent 1ff8c71 commit 08b1b4d
Show file tree
Hide file tree
Showing 4 changed files with 677 additions and 34 deletions.
13 changes: 10 additions & 3 deletions vscode-extensions/commons-vscode/src/launch-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@ import { Trace, NotificationType } from 'vscode-jsonrpc';
import * as P2C from 'vscode-languageclient/lib/protocolConverter';
import {HighlightService, HighlightParams} from './highlight-service';
import { log } from 'util';
import { tmpdir } from 'os';
import { JVM, findJvm, findJdk } from '@pivotal-tools/jvm-launch-utils';
import { registerClasspathService } from './classpath';
import {HighlightCodeLensProvider} from "./code-lens-service";
import {registerJavaDataService} from "./java-data";
import * as path from "path";

let p2c = P2C.createConverter();

Expand Down Expand Up @@ -67,6 +65,15 @@ function getUserDefinedJvmHeap(wsOpts : VSCode.WorkspaceConfiguration, dflt : s
return (javaOptions && javaOptions.heap) || dflt;
}

function isCheckingJVM(wsOpts : VSCode.WorkspaceConfiguration): boolean {
if (!wsOpts) {
return true;
}
const checkJvm: boolean = wsOpts.get("checkJVM");
console.log(`Check JVM: ${checkJvm}`);
return checkJvm;
}

function getUserDefinedJvmArgs(wsOpts : VSCode.WorkspaceConfiguration) : string[] {
const dflt = [];
if (!wsOpts) {
Expand Down Expand Up @@ -156,7 +163,7 @@ export function activate(options: ActivatorOptions, context: VSCode.ExtensionCon
'-Dsts.log.file=' + logfile,
'-XX:TieredStopAtLevel=1'
];
if (options.checkjvm) {
if (isCheckingJVM(options.workspaceOptions) && options.checkjvm) {
options.checkjvm(context, jvm);
}
if (jvmHeap && !hasHeapArg(jvmArgs)) {
Expand Down
13 changes: 11 additions & 2 deletions vscode-extensions/vscode-spring-boot/lib/Main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

import * as VSCode from 'vscode';
import {workspace} from 'vscode';
import { workspace } from 'vscode';

import * as commons from '@pivotal-tools/commons-vscode';
import * as liveHoverUi from './live-hover-connect-ui';
Expand All @@ -13,6 +13,8 @@ const YAML_LANGUAGE_ID = "spring-boot-properties-yaml";
const JAVA_LANGUAGE_ID = "java";
const XML_LANGUAGE_ID = "xml";

const NEVER_SHOW_AGAIN = "Do not show again";

/** Called when extension is activated */
export function activate(context: VSCode.ExtensionContext): Thenable<LanguageClient> {

Expand All @@ -24,7 +26,14 @@ export function activate(context: VSCode.ExtensionContext): Thenable<LanguageCli
preferJdk: true,
checkjvm: (context: VSCode.ExtensionContext, jvm: commons.JVM) => {
if (!jvm.isJdk()) {
VSCode.window.showWarningMessage('JAVA_HOME or PATH environment variable seems to point to a JRE. A JDK is required, hence Boot Hints are unavailable.');
VSCode.window.showWarningMessage(
'JAVA_HOME or PATH environment variable seems to point to a JRE. A JDK is required, hence Boot Hints are unavailable.',
NEVER_SHOW_AGAIN).then(selection => {
if (selection === NEVER_SHOW_AGAIN) {
options.workspaceOptions.update('checkJVM', false);
}
}
);
}
},
explodedLsJarData: {
Expand Down
Loading

0 comments on commit 08b1b4d

Please sign in to comment.