Skip to content

Commit

Permalink
formatted the filePath string to be sent to the client
Browse files Browse the repository at this point in the history
  • Loading branch information
yaad96 committed Mar 3, 2024
1 parent b2b9914 commit fa107bb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/DoiProcessing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class DoiProcessing{
}
}

this.timedVisitedFiles.push({ timeStamp, filePath: newFilePath });
this.timedVisitedFiles.push({ timeStamp, filePath: newFilePath.replace(/\\/g, '/') });
}


Expand Down
17 changes: 9 additions & 8 deletions src/FileChangeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 => {
Expand Down Expand Up @@ -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, '/')
}));
}

Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -15,7 +15,7 @@ import { DoiProcessing } from './DoiProcessing';

//const readFileAsync = promisify(fs.readFile);

const port = 9000;
const port = 8887;



Expand All @@ -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);


Expand Down
4 changes: 2 additions & 2 deletions src/utilites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fa107bb

Please sign in to comment.