Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Bug fix for not finding Graalvm instance and typo's #14

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2,493 changes: 2,375 additions & 118 deletions graalvm/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion graalvm/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export function activate(context: vscode.ExtensionContext) {
}));
context.subscriptions.push(vscode.commands.registerCommand('extension.graalvm.runVisualVMForPID', () => {
visualvm.selectProcessVisualVM(true).then(selected => {
if (selected) visualvm.startVisualVM();
if (selected) {visualvm.startVisualVM();}
});
}));
context.subscriptions.push(vscode.commands.registerCommand('extension.graalvm.threadDumpVisualVM', () => {
Expand Down
10 changes: 5 additions & 5 deletions graalvm/src/graalVMConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export async function setupProxy() {
}
} catch (e) {
vscode.window.showWarningMessage(e?.message);
};
}
});
}

Expand Down Expand Up @@ -142,8 +142,8 @@ function validateProxySettings(proxy: string) {
}
}

type MavenProxy = { id?:string, active: boolean, protocol: string, host: string, port: number }
type MavenSettings = { settings?: { proxies?: { proxy?: MavenProxy | MavenProxy[] }, [key: string]: any }}
type MavenProxy = { id?:string, active: boolean, protocol: string, host: string, port: number };
type MavenSettings = { settings?: { proxies?: { proxy?: MavenProxy | MavenProxy[] }, [key: string]: any }};
function parseMavenProxies(mavenSettings: MavenSettings | undefined): MavenProxy[] {
const proxies: MavenProxy | MavenProxy[] | undefined = mavenSettings?.settings?.proxies?.proxy;
if (!proxies) {
Expand Down Expand Up @@ -220,7 +220,7 @@ async function updateMavenProxy(proxy: string | undefined) {
if (foundProxy) {
foundProxy.active = true;
} else {
const gvmProxyIndex = mavenProxies.findIndex(p => p.id == ID_GRAALVM_VSCODE);
const gvmProxyIndex = mavenProxies.findIndex(p => p.id === ID_GRAALVM_VSCODE);
if (gvmProxyIndex < 0) {
mavenProxies.push(createMavenProxy(proxy));
} else {
Expand All @@ -238,7 +238,7 @@ function findMavenProxy(proxy: string): (mavenProxy: MavenProxy) => boolean {
return mavenProxy.protocol === parts[0]
&& mavenProxy.host === parts[1]
&& mavenProxy.port === parseInt(parts[2]);
}
};
}

function splitProxy(proxy: string): [string, string, string] {
Expand Down
2 changes: 1 addition & 1 deletion graalvm/src/graalVMDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ export async function attachToPod(kubectl: kubernetes.KubectlV1, podName: string
vscode.window.showErrorMessage(`Error checking pod state`);
return;
}
if (port == -1) {
if (port === -1) {
utils.askYesNo(`Debug port not opened in selected pod. Restart pod with debug port opened?`, async () => {
let info: any = {name: podName, kind: 'Pod'};
while (info && info.kind !== 'Deployment') {
Expand Down
28 changes: 11 additions & 17 deletions graalvm/src/graalVMInstall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,21 +241,15 @@ export async function getGraalVMVersion(homeFolder: string): Promise<string | un
if (stderr) {
let javaVersion: string | undefined;
let graalVMVersion: string | undefined;
stderr.split('\n').forEach((line, idx) => {
switch (idx) {
case 0:
const javaInfo: string[] | null = line.match(/version\s+\"(\S+)\"/);
if (javaInfo && javaInfo.length > 1) {
javaVersion = javaInfo[1];
}
break;
case 2:
const vmInfo = line.match(/(GraalVM.*)\s+\(/);
if (vmInfo && vmInfo.length > 1) {
graalVMVersion = vmInfo[1];
}
break;
}
stderr.split('\n').forEach((line: string) => {
const javaInfo: string[] | null = line.match(/version\s+"(\S+)"/);
const vmInfo = line.match(/(GraalVM.*)\s+\(/);
if (javaInfo && javaInfo.length > 1) {
javaVersion = javaInfo[1];
}
if (vmInfo && vmInfo.length > 1) {
graalVMVersion = vmInfo[1];
}
});
if (javaVersion && graalVMVersion) {
if (javaVersion.startsWith('1.')) {
Expand Down Expand Up @@ -744,7 +738,7 @@ function execCancellable(cmd: string, token: vscode.CancellationToken, options?:
let resolved: boolean = false;
const child = cp.exec(cmd, options, (error, _stdout, _stderr) => {
if (error || _stderr) {
if (!resolved) reject(error ?? new Error(_stderr.toString()));
if (!resolved) {reject(error ?? new Error(_stderr.toString()));}
} else {
resolve(true);
}
Expand Down Expand Up @@ -1124,7 +1118,7 @@ function processsGUOutput(stdout: string): {label: string, detail: string}[] {
}
} else {
const info: string[] | null = line.match(reg);
if(info && info.length == maxLength) {
if(info && info.length === maxLength) {
components.push({ label: info[0], detail: info[2] });
}
}
Expand Down
2 changes: 1 addition & 1 deletion graalvm/src/graalVMLicenseCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class LicenseCheckPanel {
// This happens when the user closes the panel or when the panel is closed programatically
this._panel.onDidDispose(
() => {
this.dispose()
this.dispose();
messageHandler(result);
},
null,
Expand Down
2 changes: 1 addition & 1 deletion graalvm/src/graalVMNativeImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ async function selectOutputDir(): Promise<string | undefined> {
await vscode.window.showQuickPick(choices, {
placeHolder: 'Select native-image configuration output directory',
ignoreFocusOut: true
}).then(async e => { if (e) ret = await e.getTarget(); });
}).then(async e => { if (e) {ret = await e.getTarget();} });
return ret;
}

Expand Down
68 changes: 34 additions & 34 deletions graalvm/src/graalVMVisualVM.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ function configureWhenStarted(context: vscode.ExtensionContext) {
let choices: QuickPickAction[] = getWhenStartedChoices();
vscode.window.showQuickPick(choices, {
placeHolder: 'Select action when process is started (use "Launch VisualVM & Java 8+ Application" configuration)'
}).then(selection => { if (selection) setWhenStarted(context, selection.code); });
}).then(selection => { if (selection) {setWhenStarted(context, selection.code);} });
}

function initializeCpuSamplingFilter(context: vscode.ExtensionContext) {
Expand All @@ -215,7 +215,7 @@ function configureCpuSamplingFilter(context: vscode.ExtensionContext) {
let choices: QuickPickAsyncString[] = getCpuSamplerFilters();
vscode.window.showQuickPick(choices, {
placeHolder: 'Select CPU sampling filter'
}).then(selection => { if (selection) setCpuSamplingFilter(context, selection.code); });
}).then(selection => { if (selection) {setCpuSamplingFilter(context, selection.code);} });
}

function initializeCpuSamplingRate(context: vscode.ExtensionContext) {
Expand All @@ -236,7 +236,7 @@ function configureCpuSamplingRate(context: vscode.ExtensionContext) {
let choices: QuickPickNumber[] = getCpuSamplingFrequencies();
vscode.window.showQuickPick(choices, {
placeHolder: 'Select CPU sampling rate'
}).then(selection => { if (selection) setCpuSamplingRate(context, selection.code); });
}).then(selection => { if (selection) {setCpuSamplingRate(context, selection.code);} });
}

function initializeMemorySamplingRate(context: vscode.ExtensionContext) {
Expand All @@ -257,7 +257,7 @@ function configureMemorySamplingRate(context: vscode.ExtensionContext) {
let choices: QuickPickNumber[] = getMemorySamplingFrequencies();
vscode.window.showQuickPick(choices, {
placeHolder: 'Select memory sampling rate'
}).then(selection => { if (selection) setMemorySamplingRate(context, selection.code); });
}).then(selection => { if (selection) {setMemorySamplingRate(context, selection.code);} });
}

function initializeJfrSettings(context: vscode.ExtensionContext) {
Expand All @@ -278,12 +278,12 @@ function configureJfrSettings(context: vscode.ExtensionContext) {
let choices: QuickPickString[] = getJfrSettingsChoices();
vscode.window.showQuickPick(choices, {
placeHolder: 'Select JFR settings'
}).then(selection => { if (selection) setJfrSettings(context, selection.code); });
}).then(selection => { if (selection) {setJfrSettings(context, selection.code);} });
}


async function getLaunchCommand(openPID: boolean = false): Promise<string | undefined> {
if (!graalVMHome || featureSet == 0) {
if (!graalVMHome || featureSet === 0) {
setupGraalVM(true);
return;
}
Expand Down Expand Up @@ -314,14 +314,14 @@ async function getLaunchCommand(openPID: boolean = false): Promise<string | unde
if (projectName !== undefined && sourcesIntegration) {
let sourceViewer = '';
const vsCodeLauncher = findVSCodeLauncher();
if (vsCodeLauncher) sourceViewer = `${vsCodeLauncher} -g {file}:{line}:{column}`;
if (vsCodeLauncher) {sourceViewer = `${vsCodeLauncher} -g {file}:{line}:{column}`;}

let sourceRoots = '';
const projectSourceRoots = await supportsProjectSourceRoots() ? await findProjectSourceRoots() : undefined;
const javaSourceRoots = findJavaSourceRoots(graalVMHome);
if (projectSourceRoots || javaSourceRoots) {
sourceRoots = `${projectSourceRoots ? projectSourceRoots : javaSourceRoots}`;
if (projectSourceRoots && javaSourceRoots) sourceRoots += path.delimiter + javaSourceRoots;
if (projectSourceRoots && javaSourceRoots) {sourceRoots += path.delimiter + javaSourceRoots;}
}

if (sourceViewer.length + sourceRoots.length < 200) {
Expand All @@ -343,7 +343,7 @@ async function getLaunchCommand(openPID: boolean = false): Promise<string | unde
// Optionally open predefined view for the process
if (openPID && PID) {
command += ` --openpid ${PID?.toString()}`;
if (preselect !== '1') command += `@${preselect}`
if (preselect !== '1') {command += `@${preselect}`;}
}

return command;
Expand Down Expand Up @@ -390,9 +390,9 @@ async function findProjectSourceRoots(): Promise<string | undefined> {
let roots: string[] | undefined = await vscode.commands.executeCommand('java.get.project.source.roots', folder.uri.toString());
if (roots) {
for (const root of roots) {
if (ret === undefined) ret = ''; else ret += path.delimiter;
if (ret === undefined) {ret = '';} else {ret += path.delimiter;}
ret += encode(vscode.Uri.parse(root).fsPath);
};
}
}
}
return ret;
Expand Down Expand Up @@ -440,9 +440,9 @@ async function getProjectPackages(): Promise<string | undefined> {
let packages: string[] | undefined = await vscode.commands.executeCommand('java.get.project.packages', folder.uri.toString(), true);
if (packages) {
for (const packg of packages) {
if (ret === undefined) ret = ''; else ret += ', ';
if (ret === undefined) {ret = '';} else {ret += ', ';}
ret += packg + '.*';
};
}
}
}
return encode(ret);
Expand Down Expand Up @@ -492,21 +492,21 @@ export function attachVisualVM(): string {
}

async function searchForProcess(searchID: string, iterations: number, onFound: (searchID: string, foundPID: number) => void, onTimeout: (searchID: string) => void, onCanceled: (searchID: string) => void) {
if (ID == searchID && iterations > 0) {
if (ID === searchID && iterations > 0) {
const found = await findProcessByID(searchID);
if (found) {
onFound(searchID, found);
} else {
setTimeout(() => {
awaitingProgress = awaitingProgress == 3 ? 0 : ++awaitingProgress;
awaitingProgress = awaitingProgress === 3 ? 0 : ++awaitingProgress;
processNode.updateProcName();
searchForProcess(searchID, --iterations, onFound, onTimeout, onCanceled);
}, 1000);
}
} else if (iterations > 0) {
if (onCanceled) onCanceled(searchID);
if (onCanceled) {onCanceled(searchID);}
} else {
if (onTimeout) onTimeout(searchID);
if (onTimeout) {onTimeout(searchID);}
}
}

Expand Down Expand Up @@ -626,15 +626,15 @@ class QuickPickProcess implements vscode.QuickPickItem{
const suffixIdx = info1.indexOf(DISPLAY_NAME_SUFFIX);
if (prefixIdx === -1 || suffixIdx === -1) {
this.label = info1.split(' ')[0];
if (this.label.length == 0) this.label = 'Java process';
if (this.label.length === 0) {this.label = 'Java process';}
} else {
this.label = info1.substring(prefixIdx + DISPLAY_NAME_PREFIX.length, suffixIdx);
}
} else {
this.label = 'Java process';
}
this.description = `(pid ${pid})`;
if (info2) this.detail = info2;
if (info2) {this.detail = info2;}
}
}

Expand All @@ -653,14 +653,14 @@ export function configureSettingVisualVM(context: vscode.ExtensionContext, ...pa

function computeProcName(): string {
if (PID) {
if (processName) return `${processName} (pid ${PID.toString()})`;
else return `Java process (pid ${PID.toString()})`;
if (processName) {return `${processName} (pid ${PID.toString()})`;}
else {return `Java process (pid ${PID.toString()})`;}
}

if (!ID) return '<not selected, select...>';
if (!ID) {return '<not selected, select...>';}

if (awaitingProgress == 1) return `${processName} (pid pending).`;
if (awaitingProgress == 2) return `${processName} (pid pending)..`;
if (awaitingProgress === 1) {return `${processName} (pid pending).`;}
if (awaitingProgress === 2) {return `${processName} (pid pending)..`;}
return `${processName} (pid pending)...`;
}

Expand Down Expand Up @@ -805,7 +805,7 @@ export async function stopJFRRecordingVisualVM() {
}

function encode(text: string | undefined): string {
if (!text) return 'undefined';
if (!text) {return 'undefined';}
text = text.replace(/\'/g, '%27');
text = text.replace(/\"/g, '%22');
text = text.replace(/\s/g, '%20');
Expand Down Expand Up @@ -1000,7 +1000,7 @@ class WhenStartedNode extends VisualVMNode implements Configurable {
const value = getWhenStartedChoices()[performWhenStarted].label;
this.description = value.charAt(0).toLowerCase() + value.slice(1);
this.tooltip = `${this.label} ${this.description}`;
refreshUI()
refreshUI();
}

}
Expand Down Expand Up @@ -1060,7 +1060,7 @@ class CpuSamplingFilterNode extends VisualVMNode implements Configurable {
const value = getCpuSamplerFilters()[cpuSamplingFilter].label;
this.description = value.charAt(0).toLowerCase() + value.slice(1);
this.tooltip = `${this.label} ${this.description}`;
refreshUI()
refreshUI();
}

}
Expand All @@ -1079,9 +1079,9 @@ class CpuSamplingRateNode extends VisualVMNode implements Configurable {

updateSamplingRate() {
const frequency = getCpuSamplingFrequencies()[cpuSamplingRate];
this.description = `${frequency.label} ${frequency.description}`
this.description = `${frequency.label} ${frequency.description}`;
this.tooltip = `${this.label} ${this.description}`;
refreshUI()
refreshUI();
}

}
Expand Down Expand Up @@ -1109,9 +1109,9 @@ class MemorySamplerRateNode extends VisualVMNode implements Configurable {

updateSamplingRate() {
const frequency = getMemorySamplingFrequencies()[memorySamplingRate];
this.description = `${frequency.label} ${frequency.description}`
this.description = `${frequency.label} ${frequency.description}`;
this.tooltip = `${this.label} ${this.description}`;
refreshUI()
refreshUI();
}

}
Expand Down Expand Up @@ -1140,7 +1140,7 @@ class JfrSettingsNode extends VisualVMNode implements Configurable {
updateSettings() {
this.description = getJfrSettingsChoices()[jfrSettings].label;
this.tooltip = `${this.label} ${this.description}`;
refreshUI()
refreshUI();
}

}
Expand All @@ -1166,7 +1166,7 @@ class ProcessNode extends VisualVMNode {
updateProcName() {
this.description = computeProcName();
this.tooltip = `${this.label} ${this.description}`;
refreshUI()
refreshUI();
}

updateFeatures() {
Expand Down Expand Up @@ -1198,7 +1198,7 @@ export class VisualVMNodeProvider implements vscode.TreeDataProvider<vscode.Tree

getChildren(element?: vscode.TreeItem): vscode.ProviderResult<vscode.TreeItem[]> {
if (!element) {
if (featureSet == 0) {
if (featureSet === 0) {
return [];
} else if (featureSet === 1) {
return [ processNode, emptyNode, latestGralVMNode ];
Expand Down
Loading