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

Fixed language server crashing because of wrong Lombok jar #2542

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
12 changes: 6 additions & 6 deletions src/lombokSupport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const languageServerDocumentSelector = [
{ pattern: '**/{build,settings}.gradle.kts'}
];

const lombokJarRegex = /lombok-\d+.*\.jar/;

let activeLombokPath: string = undefined;
let isLombokCommandInitialized: boolean = false;

Expand All @@ -46,8 +48,7 @@ export function cleanupLombokCache(context: ExtensionContext): boolean {
}

export function getLombokVersion(context: ExtensionContext): string {
const reg = /lombok-.*\.jar/;
const lombokVersion = reg.exec(activeLombokPath)[0].split('.jar')[0];
const lombokVersion = lombokJarRegex.exec(activeLombokPath)[0].split('.jar')[0];
return lombokVersion;
}

Expand Down Expand Up @@ -75,7 +76,6 @@ export async function checkLombokDependency(context: ExtensionContext) {
if (!isLombokSupportEnabled()) {
return;
}
const reg = /lombok-.*\.jar/;
let needReload = false;
let versionChange = false;
let currentLombokVersion = "";
Expand All @@ -85,11 +85,11 @@ export async function checkLombokDependency(context: ExtensionContext) {
for (const projectUri of projectUris) {
const classpathResult = await apiManager.getApiInstance().getClasspaths(projectUri, {scope: 'runtime'});
for (const classpath of classpathResult.classpaths) {
if (reg.test(classpath)) {
if (lombokJarRegex.test(classpath)) {
currentLombokClasspath = classpath;
if (isLombokImported(context)) {
currentLombokVersion = reg.exec(classpath)[0];
previousLombokVersion = reg.exec(context.workspaceState.get(JAVA_LOMBOK_PATH))[0];
currentLombokVersion = lombokJarRegex.exec(classpath)[0];
previousLombokVersion = lombokJarRegex.exec(context.workspaceState.get(JAVA_LOMBOK_PATH))[0];
if (currentLombokVersion!==previousLombokVersion) {
needReload = true;
versionChange = true;
Expand Down