From fa107bbbda177606d0cba42cd3196ed780f18fae Mon Sep 17 00:00:00 2001 From: mainulyaad Date: Sat, 2 Mar 2024 21:39:10 -0500 Subject: [PATCH] formatted the filePath string to be sent to the client --- src/DoiProcessing.ts | 2 +- src/FileChangeManager.ts | 17 +++++++++-------- src/extension.ts | 7 ++++--- src/utilites.ts | 4 ++-- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/DoiProcessing.ts b/src/DoiProcessing.ts index 8e64303..24814f2 100644 --- a/src/DoiProcessing.ts +++ b/src/DoiProcessing.ts @@ -70,7 +70,7 @@ export class DoiProcessing{ } } - this.timedVisitedFiles.push({ timeStamp, filePath: newFilePath }); + this.timedVisitedFiles.push({ timeStamp, filePath: newFilePath.replace(/\\/g, '/') }); } diff --git a/src/FileChangeManager.ts b/src/FileChangeManager.ts index 11e5311..c57e683 100644 --- a/src/FileChangeManager.ts +++ b/src/FileChangeManager.ts @@ -126,7 +126,7 @@ export class FileChangeManager { if (this.ws) { const message = JSON.stringify({ command: command, - data: { filePath: javaFilePath, xml: xmlContent } + data: { filePath: javaFilePath.replace(/\\/g, '/'), xml: xmlContent } }); this.ws.send(message, error => { if (error) { @@ -137,7 +137,7 @@ export class FileChangeManager { const check_rule_messaage = JSON.stringify({ command:WebSocketConstants.SEND_CHECK_RULES_FOR_FILE_MSG, - data:javaFilePath + data:javaFilePath.replace(/\\/g, '/') }); this.ws.send(check_rule_messaage, error => { @@ -174,7 +174,7 @@ export class FileChangeManager { if(this.ws){ this.ws.send(JSON.stringify({ command:WebSocketConstants.SEND_FILE_CHANGE_IN_IDE_MSG, - data: javaFilePath + data: javaFilePath.replace(/\\/g, '/') })); } @@ -194,7 +194,7 @@ export class FileChangeManager { const xmlContent = await this.convertToXML(javaFilePath); // Adjusted call this.xmlFiles.push({ filePath: javaFilePath, xmlContent }); - this.sendUpdatedXMLFile(javaFilePath, xmlContent, WebSocketConstants.SEND_UPDATE_XML_FILE_MSG); + this.sendUpdatedXMLFile(javaFilePath.replace(/\\/g, '/'), xmlContent, WebSocketConstants.SEND_UPDATE_XML_FILE_MSG); // Generate and send new project hierarchy this.updateProjectHierarchy(); @@ -215,7 +215,7 @@ export class FileChangeManager { if (index !== -1) { this.xmlFiles.splice(index, 1); - this.sendUpdatedXMLFile(javaFilePath, "", WebSocketConstants.SEND_UPDATE_XML_FILE_MSG); + this.sendUpdatedXMLFile(javaFilePath.replace(/\\/g, '/'), "", WebSocketConstants.SEND_UPDATE_XML_FILE_MSG); // Generate and send new project hierarchy this.updateProjectHierarchy(); @@ -241,7 +241,7 @@ export class FileChangeManager { } this.xmlFiles.push({ filePath: newFilePath, xmlContent }); - this.sendUpdatedXMLFile(newFilePath, xmlContent, WebSocketConstants.SEND_UPDATE_XML_FILE_MSG); + this.sendUpdatedXMLFile(newFilePath.replace(/\\/g, '/'), xmlContent, WebSocketConstants.SEND_UPDATE_XML_FILE_MSG); // Generate and send new project hierarchy this.updateProjectHierarchy(); @@ -270,7 +270,7 @@ export class FileChangeManager { this.xmlFiles.push({ filePath: javaFilePath, xmlContent }); } - this.sendUpdatedXMLFile(javaFilePath, xmlContent, WebSocketConstants.SEND_UPDATE_XML_FILE_MSG); + this.sendUpdatedXMLFile(javaFilePath.replace(/\\/g, '/'), xmlContent, WebSocketConstants.SEND_UPDATE_XML_FILE_MSG); } catch (error) { console.error(`Error processing ${javaFilePath}:`, error); @@ -324,9 +324,10 @@ export class FileChangeManager { console.log("number of xmlfiles: ", this.xmlFiles.length); for (const { filePath, xmlContent } of this.xmlFiles) { + const formattedFilePath = filePath.replace(/\\/g, '/'); const message = JSON.stringify({ command: WebSocketConstants.SEND_XML_FILES_MSG, - data: { filePath, xml: xmlContent } + data: { filePath:formattedFilePath, xml: xmlContent } }); // Wait for the send operation to complete before proceeding to the next file diff --git a/src/extension.ts b/src/extension.ts index 30acf1f..d50683d 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -6,7 +6,7 @@ import { FileChangeManager } from './FileChangeManager'; // Ensure correct path import { buildFolderHierarchy } from './utilites'; // Removed extra semicolon and corrected typo //import { MessageProcessor } from './MessageProcessor'; import { WebSocketConstants } from './WebSocketConstants'; -import * as path from 'path'; + import { FollowAndAuthorRulesProcessor } from './FollowAndAuthorRulesProcessor'; import { MiningRulesProcessor } from './MiningRulesProcessor'; import { DoiProcessing } from './DoiProcessing'; @@ -15,7 +15,7 @@ import { DoiProcessing } from './DoiProcessing'; //const readFileAsync = promisify(fs.readFile); -const port = 9000; +const port = 8887; @@ -36,7 +36,8 @@ export function activate(context: vscode.ExtensionContext) { (async () => { // Immediately Invoked Function Expression (IIFE) for async if (vscode.workspace.workspaceFolders) { - const projectPath = vscode.workspace.workspaceFolders[0].uri.fsPath; + var projectPath = vscode.workspace.workspaceFolders[0].uri.fsPath; + projectPath = projectPath.replace(/\\/g, '/'); const fileChangeManager = FileChangeManager.getInstance(projectPath, ws); diff --git a/src/utilites.ts b/src/utilites.ts index 21f2a2e..0924a5d 100644 --- a/src/utilites.ts +++ b/src/utilites.ts @@ -117,8 +117,8 @@ function traverseDirectory(currentPath: string, parentNode: DirectoryJson) { const childNode: DirectoryJson = { children: [], properties: { - canonicalPath: fullPath, - parent: currentPath, + canonicalPath: fullPath.replace(/\\/g, '/'), + parent: currentPath.replace(/\\/g, '/'), name: isDirectory ? dirent.name : path.basename(dirent.name, path.extname(dirent.name)), isDirectory: isDirectory, // Include fileName for files