Skip to content

Commit efbd6c1

Browse files
committed
GH-598 Additional fixes, also improves multi-module project support with JDT only
1 parent ba7103a commit efbd6c1

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

integrations/vscode/src/projectUtils.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export async function getSourceRoots(workspaceFolder?: vscode.WorkspaceFolder):
7575
const unrecognizedProjectFolders: vscode.Uri[] = [];
7676
try {
7777
const foundSourceRoots = await getUriSourceRoots(sourceRoots, folder, folder.uri.toString(), hasNblsProjectInfoCommand, hasMicronautToolsSubprojectCommand, jdtApi);
78-
if (!foundSourceRoots && !isSupportedProjectUri(folder.uri)) {
78+
if (!foundSourceRoots && (!hasNblsProjectSourceRootsCommand || !isSupportedProjectUri(folder.uri))) { // Workaround to allow deep search when using JDT, fixes GDK & JDT without Micronaut Tools
7979
unrecognizedProjectFolders.push(folder.uri);
8080
}
8181
} catch (err) {
@@ -91,7 +91,7 @@ export async function getSourceRoots(workspaceFolder?: vscode.WorkspaceFolder):
9191
const subfolderUri = vscode.Uri.joinPath(unrecognizedProjectFolder, subfolder);
9292
if (fs.lstatSync(subfolderUri.fsPath)?.isDirectory()) {
9393
const foundSourceRoots = await getUriSourceRoots(sourceRoots, folder, subfolderUri.toString(), hasNblsProjectInfoCommand, hasMicronautToolsSubprojectCommand, jdtApi);
94-
if (!foundSourceRoots && !isSupportedProjectUri(folder.uri)) {
94+
if (!foundSourceRoots && (!hasNblsProjectSourceRootsCommand || !isSupportedProjectUri(subfolderUri))) { // Workaround to allow deep search when using JDT, fixes GDK & JDT without Micronaut Tools
9595
unrecognizedProjectFolders.push(subfolderUri);
9696
}
9797
}
@@ -135,7 +135,7 @@ async function getUriSourceRootsNbls(sourceRoots: string[], folder: vscode.Works
135135
}
136136
}
137137
for (const subproject of subprojects) {
138-
foundSourceRoots = foundSourceRoots || await getUriSourceRootsNbls(sourceRoots, folder, subproject, false, false); // false prevents deep search (OK for GCN, may need to be enabled for other projects)
138+
foundSourceRoots = await getUriSourceRootsNbls(sourceRoots, folder, subproject, false, false) || foundSourceRoots; // false prevents deep search (OK for GCN, may need to be enabled for other projects)
139139
}
140140
}
141141
}
@@ -144,7 +144,7 @@ async function getUriSourceRootsNbls(sourceRoots: string[], folder: vscode.Works
144144
return foundSourceRoots;
145145
}
146146

147-
// TODO: add support for modules/subprojects?
147+
// TODO: add support for modules/subprojects (for example GDK project and Micronaut Tools ext. not installed)
148148
// NOTE: modules/subprojects are defined by the Micronaut Tools ext., which has NBLS as a required dependency -> getUriSourceRootsNbls will be executed instead of getUriSourceRootsJdt
149149
async function getUriSourceRootsJdt(sourceRoots: string[], _folder: vscode.WorkspaceFolder, uri: string, _hasNblsProjectInfoCommand: boolean, _hasMicronautToolsSubprojectCommand: boolean, api: any): Promise<boolean> {
150150
let foundSourceRoots = false;
@@ -195,7 +195,7 @@ export async function getPackages(workspaceFolder?: vscode.WorkspaceFolder): Pro
195195
const unrecognizedProjectFolders: vscode.Uri[] = [];
196196
try {
197197
const foundPackages = await getUriPackages(packages, folder, folder.uri.toString(), hasNblsProjectInfoCommand, hasMicronautToolsSubprojectCommand);
198-
if (!foundPackages && !isSupportedProjectUri(folder.uri)) {
198+
if (!foundPackages && (!hasNblsProjectPackagesCommand || !isSupportedProjectUri(folder.uri))) { // Workaround to allow deep search when using JDT, fixes GDK & JDT without Micronaut Tools
199199
unrecognizedProjectFolders.push(folder.uri);
200200
}
201201
} catch (err) {
@@ -211,7 +211,7 @@ export async function getPackages(workspaceFolder?: vscode.WorkspaceFolder): Pro
211211
const subfolderUri = vscode.Uri.joinPath(unrecognizedProjectFolder, subfolder);
212212
if (fs.lstatSync(subfolderUri.fsPath)?.isDirectory()) {
213213
const foundPackages = await getUriPackages(packages, folder, subfolderUri.toString(), hasNblsProjectInfoCommand, hasMicronautToolsSubprojectCommand);
214-
if (!foundPackages && !isSupportedProjectUri(folder.uri)) {
214+
if (!foundPackages && (!hasNblsProjectPackagesCommand || !isSupportedProjectUri(subfolderUri))) { // Workaround to allow deep search when using JDT, fixes GDK & JDT without Micronaut Tools
215215
unrecognizedProjectFolders.push(subfolderUri);
216216
}
217217
}
@@ -247,7 +247,7 @@ async function getUriPackagesNbls(packages: string[], folder: vscode.WorkspaceFo
247247
const infos: any[] = await vscode.commands.executeCommand(NBLS_PROJECT_INFO_COMMAND, uri, { projectStructure: true });
248248
if (infos?.length && infos[0]) {
249249
for (const subproject of infos[0].subprojects) { // multimodule - most likely GCN
250-
foundPackages = foundPackages || await getUriPackagesNbls(packages, folder, subproject, false, false); // false prevents deep search (OK for GCN, may need to be enabled for other projects)
250+
foundPackages = await getUriPackagesNbls(packages, folder, subproject, false, false) || foundPackages; // false prevents deep search (OK for GCN, may need to be enabled for other projects)
251251
}
252252
}
253253
}
@@ -256,7 +256,7 @@ async function getUriPackagesNbls(packages: string[], folder: vscode.WorkspaceFo
256256
return foundPackages;
257257
}
258258

259-
// TODO: add support for modules/subprojects?
259+
// TODO: add support for modules/subprojects (for example GDK project and Micronaut Tools ext. not installed)
260260
// NOTE: modules/subprojects are defined by the Micronaut Tools ext., which has NBLS as a required dependency -> getUriPackagesNbls will be executed instead of getUriPackagesJdt
261261
async function getUriPackagesJdt(packages: string[], _folder: vscode.WorkspaceFolder, uri: string): Promise<boolean> {
262262
let foundPackages = false;

0 commit comments

Comments
 (0)