Skip to content

Commit

Permalink
Update some BI checkpoint for project setting page (#1342)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdneo authored May 29, 2024
1 parent 88a1845 commit 1acb978
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const Hint = (): JSX.Element | null => {

useEffect(() => {
updateMaxHeight();
}, [projectType, libraries, effectiveLibraries]);
}, [projectType, classpathModified]);

useEffect(() => {
window.addEventListener('resize', updateMaxHeight);
Expand Down
28 changes: 14 additions & 14 deletions src/project-settings/handlers/ClasspathRequestHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export class ClasspathRequestHandler implements vscode.Disposable {
return true;
};

private listProjects = instrumentOperation("classpath.listProjects", async (operationId: string) => {
private listProjects = instrumentOperation("projectSettings.classpath.listProjects", async (operationId: string) => {
// listProjects() will be called when the component is mounted,
// we first check the requirement here in case user triggers 'reload webview'
if (!(await this.checkRequirement())) {
Expand Down Expand Up @@ -149,7 +149,7 @@ export class ClasspathRequestHandler implements vscode.Disposable {
});
});

private listVmInstalls = instrumentOperation("classpath.listVmInstalls", async (operationId: string) => {
private listVmInstalls = instrumentOperation("projectSettings.classpath.listVmInstalls", async (operationId: string) => {
let vmInstalls: VmInstall[] = await this.getVmInstallsFromLS();
vmInstalls = vmInstalls.sort((vmA: VmInstall, vmB: VmInstall) => {
return vmA.name.localeCompare(vmB.name);
Expand All @@ -169,7 +169,7 @@ export class ClasspathRequestHandler implements vscode.Disposable {

private debounceListVmInstalls = _.debounce(this.listVmInstalls, 3000 /*ms*/);

private loadProjectClasspath = instrumentOperation("classpath.loadClasspath", async (operationId: string, currentProjectRoot: vscode.Uri) => {
private loadProjectClasspath = instrumentOperation("projectSettings.classpath.loadClasspath", async (operationId: string, currentProjectRoot: vscode.Uri) => {
const classpath = await this.getProjectClasspathFromLS(currentProjectRoot);
if (classpath) {
this.webview.postMessage({
Expand Down Expand Up @@ -215,7 +215,7 @@ export class ClasspathRequestHandler implements vscode.Disposable {
return undefined;
}

private addSourcePathForUnmanagedFolder = instrumentOperation("classpath.addSourcePathForUnmanagedFolder", async (_operationId: string, currentProjectRoot: vscode.Uri) => {
private addSourcePathForUnmanagedFolder = instrumentOperation("projectSettings.classpath.addSourcePathForUnmanagedFolder", async (_operationId: string, currentProjectRoot: vscode.Uri) => {
const relativePath: string | undefined = await this.selectSourceFolderPath(currentProjectRoot);
if (!relativePath) {
return;
Expand All @@ -232,15 +232,15 @@ export class ClasspathRequestHandler implements vscode.Disposable {
});
});

private updateSourcePathsForUnmanagedFolder = instrumentOperation("classpath.updateSourcePathsForUnmanagedFolder", async (_operationId: string, currentProjectRoot: vscode.Uri, sourcePaths: string[]) => {
private updateSourcePathsForUnmanagedFolder = instrumentOperation("projectSettings.classpath.updateSourcePathsForUnmanagedFolder", async (_operationId: string, currentProjectRoot: vscode.Uri, sourcePaths: string[]) => {
vscode.workspace.getConfiguration("java", currentProjectRoot).update(
"project.sourcePaths",
sourcePaths,
vscode.ConfigurationTarget.Workspace,
);
});

private selectFolder = instrumentOperation("classpath.selectFolder", async (_operationId: string, currentProjectRoot: vscode.Uri, type: string) => {
private selectFolder = instrumentOperation("projectSettings.classpath.selectFolder", async (_operationId: string, currentProjectRoot: vscode.Uri, type: string) => {
const relativePath: string | undefined = await this.selectSourceFolderPath(currentProjectRoot);
if (!relativePath) {
return;
Expand All @@ -252,7 +252,7 @@ export class ClasspathRequestHandler implements vscode.Disposable {
});
});

private updateClassPaths = instrumentOperation("classpath.updateClassPaths", async (_operationId: string, rootPath: string, projectType: ProjectType, sourcePaths: ClasspathEntry[], defaultOutputPath: string, vmInstallPath: string, libraries: ClasspathEntry[]) => {
private updateClassPaths = instrumentOperation("projectSettings.classpath.updateClassPaths", async (_operationId: string, rootPath: string, projectType: ProjectType, sourcePaths: ClasspathEntry[], defaultOutputPath: string, vmInstallPath: string, libraries: ClasspathEntry[]) => {
this.webview.postMessage({
command: "classpath.onDidChangeLoadingState",
loading: true,
Expand Down Expand Up @@ -301,7 +301,7 @@ export class ClasspathRequestHandler implements vscode.Disposable {
});
});

private selectOutputPath = instrumentOperation("classpath.selectOutputPath", async (_operationId: string, currentProjectRoot: vscode.Uri) => {
private selectOutputPath = instrumentOperation("projectSettings.classpath.selectOutputPath", async (_operationId: string, currentProjectRoot: vscode.Uri) => {
const outputFolder: vscode.Uri[] | undefined = await vscode.window.showOpenDialog({
defaultUri: vscode.workspace.workspaceFolders?.[0].uri,
openLabel: "Select Output Folder",
Expand Down Expand Up @@ -332,7 +332,7 @@ export class ClasspathRequestHandler implements vscode.Disposable {
}
});

private setOutputPath = instrumentOperation("classpath.setOutputPath", async (operationId: string, currentProjectRoot: vscode.Uri, outputRelativePath: string) => {
private setOutputPath = instrumentOperation("projectSettings.classpath.setOutputPath", async (operationId: string, currentProjectRoot: vscode.Uri, outputRelativePath: string) => {
if (vscode.workspace.getConfiguration("java", currentProjectRoot).get<string>("project.outputPath") === outputRelativePath) {
return;
}
Expand All @@ -357,7 +357,7 @@ export class ClasspathRequestHandler implements vscode.Disposable {
);
});

private addNewJdk = instrumentOperation("classpath.addNewJdk", async (operationId: string, currentProjectRoot: vscode.Uri) => {
private addNewJdk = instrumentOperation("projectSettings.classpath.addNewJdk", async (operationId: string, currentProjectRoot: vscode.Uri) => {
const actionResult: Record<string, string> = {
name: "classpath.configuration",
kind: "add-new-jdk"
Expand Down Expand Up @@ -404,7 +404,7 @@ export class ClasspathRequestHandler implements vscode.Disposable {
}
});

private changeJdk = instrumentOperation("classpath.changeJdk", async (operationId: string, currentProjectRoot: vscode.Uri, jdkPath: string) => {
private changeJdk = instrumentOperation("projectSettings.classpath.changeJdk", async (operationId: string, currentProjectRoot: vscode.Uri, jdkPath: string) => {
const actionResult: Record<string, string> = {
name: "classpath.configuration",
kind: "use-existing-jdk"
Expand Down Expand Up @@ -439,7 +439,7 @@ export class ClasspathRequestHandler implements vscode.Disposable {
}
});

private selectLibraries = instrumentOperation("classpath.selectLibraries", async (_operationId: string, currentProjectRoot: vscode.Uri) => {
private selectLibraries = instrumentOperation("projectSettings.classpath.selectLibraries", async (_operationId: string, currentProjectRoot: vscode.Uri) => {
const jarFiles: vscode.Uri[] | undefined = await vscode.window.showOpenDialog({
defaultUri: vscode.workspace.workspaceFolders?.[0].uri,
openLabel: "Select Jar File",
Expand Down Expand Up @@ -469,13 +469,13 @@ export class ClasspathRequestHandler implements vscode.Disposable {
}
});

private updateUnmanagedFolderLibraries = instrumentOperation("classpath.updateUnmanagedFolderLibraries", async (_operationId: string, jarFilePaths: string[]) => {
private updateUnmanagedFolderLibraries = instrumentOperation("projectSettings.classpath.updateUnmanagedFolderLibraries", async (_operationId: string, jarFilePaths: string[]) => {
const setting = this.getReferencedLibrariesSetting();
setting.include = jarFilePaths;
this.updateReferencedLibraries(setting);
});

private gotoProjectConfigurationFile = instrumentOperation("classpath.gotoProjectConfigurationFile", (operationId: string, rootUri: string, projectType: ProjectType) => {
private gotoProjectConfigurationFile = instrumentOperation("projectSettings.classpath.gotoProjectConfigurationFile", (operationId: string, rootUri: string, projectType: ProjectType) => {
const rootPath: string = vscode.Uri.parse(rootUri).fsPath;
let configurationPath: string = "";
if (projectType === ProjectType.Gradle) {
Expand Down
12 changes: 9 additions & 3 deletions src/project-settings/handlers/CompilerRequestHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT license.

import * as vscode from "vscode";
import { instrumentOperation, sendError, setUserError } from "vscode-extension-telemetry-wrapper";
import { instrumentOperation, sendError, sendInfo, setUserError } from "vscode-extension-telemetry-wrapper";

const ADD_VARIABlLE_ATTRIBUTE = "org.eclipse.jdt.core.compiler.debug.localVariable";
const ADD_LINE_NUMBER_ATTRIBUTE = "org.eclipse.jdt.core.compiler.debug.lineNumber";
Expand Down Expand Up @@ -75,7 +75,7 @@ export class CompilerRequestHandler implements vscode.Disposable {
});
});

private onWillUpdateCompilerSettings = instrumentOperation("projectSettings.compiler.onWillUpdateCompilerSettings", async (_operationId: string,
private onWillUpdateCompilerSettings = instrumentOperation("projectSettings.compiler.onWillUpdateCompilerSettings", async (operationId: string,
uri: string, useRelease: boolean, enablePreview: boolean, complianceLevel: string, sourceLevel: string, targetLevel: string,
generateDebugInfo: boolean, storeMethodParamNames: boolean): Promise<void> => {
const compilerSettings: Map<string, string> = new Map<string, string>();
Expand Down Expand Up @@ -107,6 +107,12 @@ export class CompilerRequestHandler implements vscode.Disposable {
sourceLevel: compilerSettings.get(SOURCE_COMPATIBILITY),
targetLevel: compilerSettings.get(TARGET_COMPATIBILITY),
});

sendInfo(operationId, {
operationName: "projectSettings.updateCompilerSettings",
// remove the common prefix to reduce the payload.
arg: JSON.stringify([...compilerSettings]).replace(/org\.eclipse\.jdt\.core\.compiler\./g, ""),
});
});

public dispose() {
Expand Down Expand Up @@ -141,4 +147,4 @@ export class CompilerRequestHandler implements vscode.Disposable {
return categories?.properties?.["java.configuration.runtimes"];
}
}
}
}
6 changes: 3 additions & 3 deletions src/project-settings/handlers/MavenRequestHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class MavenRequestHandler implements vscode.Disposable {
}));
}

private onWillGetSelectedProfiles = instrumentOperation("maven.onWillGetSelectedProfiles", async (_operationId: string, uri: any): Promise<void> => {
private onWillGetSelectedProfiles = instrumentOperation("projectSettings.maven.onWillGetSelectedProfiles", async (_operationId: string, uri: any): Promise<void> => {
const response: any = await vscode.commands.executeCommand<Object>("java.execute.workspaceCommand",
"java.project.getSettings", uri, [M2E_SELECTED_PROFILES]);
const selectedProfiles: string = response?.[M2E_SELECTED_PROFILES];
Expand All @@ -39,12 +39,12 @@ export class MavenRequestHandler implements vscode.Disposable {
}
});

private onWillUpdateSelectProfiles = instrumentOperation("maven.onWillUpdateSelectProfiles", async (_operationId: string, uri: any, selectedProfiles: string[]): Promise<void> => {
private onWillUpdateSelectProfiles = instrumentOperation("projectSettings.maven.onWillUpdateSelectProfiles", async (_operationId: string, uri: any, selectedProfiles: string[]): Promise<void> => {
await vscode.commands.executeCommand("java.execute.workspaceCommand",
"java.project.updateSettings", uri, { [M2E_SELECTED_PROFILES]: selectedProfiles });
});

public dispose() {
this.disposables.forEach(d => d.dispose());
}
}
}

0 comments on commit 1acb978

Please sign in to comment.