Skip to content

Commit df26017

Browse files
JoshwinThomasIBMJoshwinThomasIBM
authored andcommitted
addressed review comments
1 parent e92d752 commit df26017

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

src/extension.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,10 @@ export function registerFileWatcher(projectProvider: ProjectProvider): void {
188188
const watcher: vscode.FileSystemWatcher = vscode.workspace.createFileSystemWatcher("{**/pom.xml,**/build.gradle,**/settings.gradle,**/src/main/liberty/config/server.xml}");
189189
// Async handler for the file system events (create, change, delete)
190190
const handleUri = async (uri: vscode.Uri) => {
191+
if (uri.fsPath.endsWith("server.xml")) {
192+
await projectProvider.refresh();
193+
return;
194+
}
191195
const workspaceFolders = vscode.workspace.workspaceFolders;
192196

193197
if (!workspaceFolders) {
@@ -210,16 +214,12 @@ export function registerFileWatcher(projectProvider: ProjectProvider): void {
210214
* Determines the parent directory of the project root.
211215
* If a valid parent exists, use its path for searching. Otherwise, use the project root path itself.
212216
*/
213-
try {
214-
let projectRootParent = path.dirname(projectRoot);
215-
if (fs.existsSync(projectRootParent) && fs.statSync(projectRootParent).isDirectory())
216-
projectRoot = projectRootParent;
217-
else
218-
console.debug("project root parent is not found ")
219-
} catch (error) {
220-
console.error("project root parent is not found ");
217+
let projectRootParent = path.dirname(projectRoot);
218+
if (!(fs.existsSync(projectRootParent) && fs.statSync(projectRootParent).isDirectory())) {
219+
projectRootParent = projectRoot;// If the parent directory of the project root doesn't exist, set projectRootParent to projectRoot.
220+
console.debug("project root parent is not found ")
221221
}
222-
const siblingFileExists = await helperUtil.checkSiblingFilesInTargetOrBuildParent(uri.fsPath, projectRoot);
222+
const siblingFileExists = await helperUtil.checkSiblingFilesInTargetOrBuildParent(uri.fsPath, projectRootParent);
223223
if (!siblingFileExists) {
224224
console.debug(`No sibling build file found, refreshing project... for ` + uri.fsPath);
225225
// Refresh the project if no sibling file is found

src/util/helperUtil.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (c) 2020, 2024 IBM Corporation.
2+
* Copyright (c) 2020, 2025 IBM Corporation.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -102,7 +102,7 @@ export async function checkSiblingFilesInTargetOrBuildParent(filePath: string, p
102102
outputDir = 'build'; // For Gradle projects, look for build directory
103103
siblingFileType = 'build.gradle';
104104
} else {
105-
console.debug("Invalid file type. Only 'pom.xml' or 'build.gradle' are supported.");
105+
console.debug("Invalid file type. Only 'pom.xml' or 'build.gradle' or 'settings.gradle' are supported.");
106106
return false;
107107
}
108108

@@ -154,8 +154,9 @@ async function checkOutputDirAndSiblingBuildFile(currentDir: string, filePath: s
154154
} else {
155155
console.debug(" sibling not found " + siblingFilePath + " for " + filePath);
156156
}
157-
} else
157+
} else{
158158
console.debug(currentOutputDir + " is not found");
159+
}
159160
return false; // No sibling file found
160161
} catch (err) {
161162
console.error('Error during directory traversal in checkSiblingFileInDir:', err);

0 commit comments

Comments
 (0)