Skip to content

Commit 57689f6

Browse files
ver28 added
1 parent 9666c43 commit 57689f6

File tree

2 files changed

+39
-8
lines changed

2 files changed

+39
-8
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@codebolt/codeboltjs",
3-
"version": "1.1.27",
3+
"version": "1.1.28",
44
"description": "",
55
"keywords": [],
66
"author": "",

src/modules/codeutils.ts

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,8 @@ import cbws from './websocket';
44
* A utility module for working with code.
55
*/
66
const cbcodeutils = {
7-
/**
8-
* Asynchronously generates a code tree from the provided source code.
9-
* @param {any} fileName - The name of the file.
10-
* @param {any} source - The source code to generate the tree from.
11-
* @param {any} filePath - The file path where the source code is located.
12-
* @returns {Promise<any>} A promise that resolves with the code tree.
13-
*/
7+
8+
149
getCodeTree: (): Promise<any> => {
1510
return new Promise((resolve, reject) => {
1611
cbws.getWebsocket.send(JSON.stringify({
@@ -25,6 +20,23 @@ const cbcodeutils = {
2520
});
2621
});
2722
},
23+
getJsTree: (filePath:string): Promise<any> => {
24+
return new Promise((resolve, reject) => {
25+
cbws.getWebsocket.send(JSON.stringify({
26+
"type": "codeEvent",
27+
"action":"getJsTree",
28+
payload:{
29+
filePath
30+
}
31+
}));
32+
cbws.getWebsocket.on('message', (data: string) => {
33+
const response = JSON.parse(data);
34+
if (response.type === "getgetJsTreeResponse") {
35+
resolve(response.payload); // Resolve the Promise with the response data
36+
}
37+
});
38+
});
39+
},
2840
getAllFilesAsMarkDown:()=>{
2941
return new Promise((resolve, reject) => {
3042
cbws.getWebsocket.send(JSON.stringify({
@@ -38,6 +50,25 @@ const cbcodeutils = {
3850
}
3951
});
4052
});
53+
},
54+
matchProblem:(matcherDefinition:object, problemPatterns:[], problems:[])=>{
55+
return new Promise((resolve, reject) => {
56+
cbws.getWebsocket.send(JSON.stringify({
57+
"type": "codeEvent",
58+
"action":"getJsTree",
59+
payload:{
60+
matcherDefinition,
61+
problemPatterns,
62+
problems
63+
}
64+
}));
65+
cbws.getWebsocket.on('message', (data: string) => {
66+
const response = JSON.parse(data);
67+
if (response.type === "getgetJsTreeResponse") {
68+
resolve(response.payload); // Resolve the Promise with the response data
69+
}
70+
});
71+
});
4172
}
4273
};
4374

0 commit comments

Comments
 (0)