@@ -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
0 commit comments