Skip to content

Commit 37d0c1f

Browse files
tree-sitter removed
1 parent 6ee00ec commit 37d0c1f

File tree

7 files changed

+199
-118
lines changed

7 files changed

+199
-118
lines changed

.codebolt/chat.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]

.codebolt/debug.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]

.codebolt/projectState.json

+128
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
{
2+
"0": "{",
3+
"1": "\n",
4+
"2": " ",
5+
"3": " ",
6+
"4": "\"",
7+
"5": "a",
8+
"6": "c",
9+
"7": "t",
10+
"8": "i",
11+
"9": "v",
12+
"10": "e",
13+
"11": "A",
14+
"12": "g",
15+
"13": "e",
16+
"14": "n",
17+
"15": "t",
18+
"16": "\"",
19+
"17": ":",
20+
"18": " ",
21+
"19": "f",
22+
"20": "a",
23+
"21": "l",
24+
"22": "s",
25+
"23": "e",
26+
"24": ",",
27+
"25": "\n",
28+
"26": " ",
29+
"27": " ",
30+
"28": "\"",
31+
"29": "p",
32+
"30": "i",
33+
"31": "n",
34+
"32": "n",
35+
"33": "e",
36+
"34": "d",
37+
"35": "A",
38+
"36": "g",
39+
"37": "e",
40+
"38": "n",
41+
"39": "t",
42+
"40": "\"",
43+
"41": ":",
44+
"42": " ",
45+
"43": "[",
46+
"44": "]",
47+
"45": "\n",
48+
"46": "}",
49+
"currentLayout": {
50+
"grid": {
51+
"root": {
52+
"type": "branch",
53+
"data": [
54+
{
55+
"type": "leaf",
56+
"data": {
57+
"views": [
58+
"Code"
59+
],
60+
"activeView": "Code",
61+
"id": "1"
62+
},
63+
"size": 512
64+
},
65+
{
66+
"type": "branch",
67+
"data": [
68+
{
69+
"type": "leaf",
70+
"data": {
71+
"views": [
72+
"Chat"
73+
],
74+
"activeView": "Chat",
75+
"id": "2"
76+
},
77+
"size": 334
78+
},
79+
{
80+
"type": "leaf",
81+
"data": {
82+
"views": [
83+
"Preview"
84+
],
85+
"activeView": "Preview",
86+
"id": "3"
87+
},
88+
"size": 334
89+
}
90+
],
91+
"size": 512
92+
}
93+
],
94+
"size": 668
95+
},
96+
"width": 1024,
97+
"height": 668,
98+
"orientation": "HORIZONTAL"
99+
},
100+
"panels": {
101+
"Code": {
102+
"id": "Code",
103+
"contentComponent": "Code",
104+
"tabComponent": "props.defaultTabComponent",
105+
"title": "Code",
106+
"renderer": "always"
107+
},
108+
"Chat": {
109+
"id": "Chat",
110+
"contentComponent": "Chat",
111+
"tabComponent": "props.defaultTabComponent",
112+
"title": "Chat",
113+
"renderer": "always"
114+
},
115+
"Preview": {
116+
"id": "Preview",
117+
"contentComponent": "Preview",
118+
"tabComponent": "props.defaultTabComponent",
119+
"title": "Preview",
120+
"renderer": "always"
121+
}
122+
},
123+
"activeGroup": "3"
124+
},
125+
"treeViewState": "{\"tree-2\":{\"focusedItem\":null,\"expandedItems\":[\"root-1\",\"root-2\",\"root-3\",\"root-4\",\"root-5\",\"root-6\",\"root-7\",\"root-8\",\"root-9\",\"root-10\",\"root-11\",\"root-12\",\"root-13\",\"root-14\",\"root-15\"],\"selectedItems\":[]}}",
126+
"pinnedAgent": [],
127+
"activeAgent": false
128+
}

.codebolt/tasks.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]

package-lock.json

-48
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@codebolt/codeboltjs",
3-
"version": "1.1.68",
3+
"version": "1.1.69",
44
"description": "",
55
"keywords": [],
66
"author": "",
@@ -20,8 +20,6 @@
2020
"dependencies": {
2121
"@codebolt/types": "^1.0.10",
2222
"js-yaml": "^4.1.0",
23-
"tree-sitter": "^0.21.1",
24-
"tree-sitter-javascript": "^0.21.2",
2523
"typedoc-plugin-missing-exports": "^2.2.0",
2624
"ws": "^8.17.0"
2725
},

src/modules/codeutils.ts

+67-67
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import cbws from './websocket';
22
import * as fs from 'fs';
33
import path from 'path';
4-
import Parser from 'tree-sitter';
5-
import JavaScript from 'tree-sitter-javascript';
4+
// import Parser from 'tree-sitter';
5+
// import JavaScript from 'tree-sitter-javascript';
66

77
import { GetJsTreeResponse, MatchProblemResponse, GetMatcherListTreeResponse, getMatchDetail } from '@codebolt/types';
88

@@ -16,77 +16,77 @@ const cbcodeutils = {
1616
* @param {string} filePath - The path of the file to retrieve the JS tree for.
1717
* @returns {Promise<GetJsTreeResponse>} A promise that resolves with the JS tree response.
1818
*/
19-
getJsTree: (filePath?: string): Promise<any> => {
20-
return new Promise( async (resolve, reject) => {
21-
cbws.getWebsocket.send(JSON.stringify({
22-
"type": "settingEvent",
23-
"action": "getProjectPath"
24-
}));
25-
cbws.getWebsocket.on('message', (data: string) => {
26-
const response = JSON.parse(data);
27-
if (response.type === "getProjectPathResponse") {
28-
// resolve(response);
29-
try {
30-
let pathInput= response.projectPath;
31-
let parser= new Parser();
32-
// Initialize the parser with the JavaScript language
33-
parser.setLanguage(JavaScript);
34-
const trees = [];
35-
const functionNodes = [];
19+
getJsTree: (filePath?: string) => {
20+
// return new Promise( async (resolve, reject) => {
21+
// cbws.getWebsocket.send(JSON.stringify({
22+
// "type": "settingEvent",
23+
// "action": "getProjectPath"
24+
// }));
25+
// cbws.getWebsocket.on('message', (data: string) => {
26+
// const response = JSON.parse(data);
27+
// if (response.type === "getProjectPathResponse") {
28+
// // resolve(response);
29+
// try {
30+
// let pathInput= response.projectPath;
31+
// let parser= new Parser();
32+
// // Initialize the parser with the JavaScript language
33+
// parser.setLanguage(JavaScript);
34+
// const trees = [];
35+
// const functionNodes = [];
3636

37-
const processDirectory = (directory:any) => {
38-
console.log("isdir")
39-
// Read all files in the directory
40-
const files = fs.readdirSync(directory, { withFileTypes: true });
37+
// const processDirectory = (directory:any) => {
38+
// console.log("isdir")
39+
// // Read all files in the directory
40+
// const files = fs.readdirSync(directory, { withFileTypes: true });
4141

42-
files.forEach(file => {
43-
if (file.isDirectory()) {
44-
if (file.name !== 'node_modules') { // Ignore node_modules directory
45-
processDirectory(path.join(directory, file.name)); // Recursive call for subdirectories
46-
}
47-
} else if (path.extname(file.name) === '.js') {
48-
const code = fs.readFileSync(path.join(directory, file.name), 'utf-8');
49-
console.log(code);
50-
let tree:any = parser.parse(code);
51-
tree.rootNode.path = path.join(directory, file.name); // Set file path for t
52-
trees.push(tree);
53-
}
54-
});
55-
};
42+
// files.forEach(file => {
43+
// if (file.isDirectory()) {
44+
// if (file.name !== 'node_modules') { // Ignore node_modules directory
45+
// processDirectory(path.join(directory, file.name)); // Recursive call for subdirectories
46+
// }
47+
// } else if (path.extname(file.name) === '.js') {
48+
// const code = fs.readFileSync(path.join(directory, file.name), 'utf-8');
49+
// console.log(code);
50+
// let tree:any = parser.parse(code);
51+
// tree.rootNode.path = path.join(directory, file.name); // Set file path for t
52+
// trees.push(tree);
53+
// }
54+
// });
55+
// };
5656

57-
if (fs.lstatSync(pathInput).isDirectory()) {
58-
processDirectory(pathInput);
59-
} else if (path.extname(pathInput) === '.js') {
60-
// Read a single JavaScript file
61-
const code = fs.readFileSync(pathInput, 'utf-8');
62-
let tree:any = parser.parse(code);
63-
tree.rootNode.path = pathInput; // Set file path for t
57+
// if (fs.lstatSync(pathInput).isDirectory()) {
58+
// processDirectory(pathInput);
59+
// } else if (path.extname(pathInput) === '.js') {
60+
// // Read a single JavaScript file
61+
// const code = fs.readFileSync(pathInput, 'utf-8');
62+
// let tree:any = parser.parse(code);
63+
// tree.rootNode.path = pathInput; // Set file path for t
6464

65-
trees.push(tree);
66-
}
65+
// trees.push(tree);
66+
// }
6767

68-
resolve({ event: 'GetJsTreeResponse',payload:trees}); // Return an array of abstract syntax trees (ASTs)
69-
} catch (error) {
70-
console.error('An error occurred:', error);
71-
return { event: 'GetJsTreeResponse',payload:null}; // Return null in case of error
72-
}
73-
}
74-
});
68+
// resolve({ event: 'GetJsTreeResponse',payload:trees}); // Return an array of abstract syntax trees (ASTs)
69+
// } catch (error) {
70+
// console.error('An error occurred:', error);
71+
// return { event: 'GetJsTreeResponse',payload:null}; // Return null in case of error
72+
// }
73+
// }
74+
// });
7575

76-
// cbws.getWebsocket.send(JSON.stringify({
77-
// "type": "codeEvent",
78-
// "action":"getJsTree",
79-
// payload:{
80-
// filePath
81-
// }
82-
// }));
83-
// cbws.getWebsocket.on('message', (data: string) => {
84-
// const response = JSON.parse(data);
85-
// if (response.type === "getJsTreeResponse") {
86-
// resolve(response); // Resolve the Promise with the response data
87-
// }
88-
// });
89-
});
76+
// // cbws.getWebsocket.send(JSON.stringify({
77+
// // "type": "codeEvent",
78+
// // "action":"getJsTree",
79+
// // payload:{
80+
// // filePath
81+
// // }
82+
// // }));
83+
// // cbws.getWebsocket.on('message', (data: string) => {
84+
// // const response = JSON.parse(data);
85+
// // if (response.type === "getJsTreeResponse") {
86+
// // resolve(response); // Resolve the Promise with the response data
87+
// // }
88+
// // });
89+
// });
9090
},
9191

9292
/**

0 commit comments

Comments
 (0)