Skip to content

Commit

Permalink
Reduce delegate command calls when classpath changes
Browse files Browse the repository at this point in the history
Signed-off-by: Sheng Chen <[email protected]>
  • Loading branch information
jdneo authored and rgrunber committed Dec 22, 2023
1 parent eaeedf7 commit b8fd158
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/lombokSupport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as fse from "fs-extra";
import * as path from "path";
import * as semver from 'semver';
import * as vscode from "vscode";
import { ExtensionContext, window, commands } from "vscode";
import { ExtensionContext, window, commands, Uri } from "vscode";
import { Commands } from "./commands";
import { apiManager } from "./apiManager";
import { languageStatusBarProvider } from './runtimeStatusBarProvider';
Expand Down Expand Up @@ -117,7 +117,7 @@ export function addLombokParam(context: ExtensionContext, params: string[]) {
updateActiveLombokPath(lombokJarPath);
}

export async function checkLombokDependency(context: ExtensionContext) {
export async function checkLombokDependency(context: ExtensionContext, projectUri?: Uri) {
if (!isLombokSupportEnabled()) {
return;
}
Expand All @@ -126,7 +126,7 @@ export async function checkLombokDependency(context: ExtensionContext) {
let currentLombokVersion: string = undefined;
let previousLombokVersion: string = undefined;
let currentLombokClasspath: string = undefined;
const projectUris: string[] = await getAllJavaProjects();
const projectUris: string[] = projectUri ? [projectUri.toString()] : await getAllJavaProjects();
for (const projectUri of projectUris) {
const classpathResult = await apiManager.getApiInstance().getClasspaths(projectUri, {scope: 'test'});
for (const classpath of classpathResult.classpaths) {
Expand Down
4 changes: 2 additions & 2 deletions src/standardLanguageClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ export class StandardLanguageClient {
showImportFinishNotification(context);
}
checkLombokDependency(context);
apiManager.getApiInstance().onDidClasspathUpdate((e: Uri) => {
checkLombokDependency(context);
apiManager.getApiInstance().onDidClasspathUpdate((projectUri: Uri) => {
checkLombokDependency(context, projectUri);
});
// Disable the client-side snippet provider since LS is ready.
snippetCompletionProvider.dispose();
Expand Down

0 comments on commit b8fd158

Please sign in to comment.