Skip to content

Commit e655295

Browse files
changes
1 parent b0341b8 commit e655295

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

src/modules/codeutils.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const cbcodeutils = {
6060
// Get parser for this file type
6161
const { parser, query } = languageParsers[ext] || {};
6262
if (!parser || !query) {
63-
throw new Error(`Unsupported file type: ${ext}`);
63+
throw new Error(`Unsupported language: ${ext}`);
6464
}
6565

6666
// Read file content
@@ -125,19 +125,20 @@ const cbcodeutils = {
125125

126126
/**
127127
* Performs a matching operation based on the provided matcher definition and problem patterns.
128-
* @param {object} matcherDefinition - The definition of the matcher.
129-
* @param {Array} problemPatterns - The patterns to match against.
130-
* @param {Array} problems - The list of problems.
128+
* @param {object} matcherDefinition - The definition of the matcher (name, pattern, language, etc.).
129+
* @param {Array} problemPatterns - The patterns to match against (regex patterns with severity levels).
130+
* @param {Array} problems - Optional list of pre-existing problems to include.
131131
* @returns {Promise<MatchProblemResponse>} A promise that resolves with the matching problem response.
132132
*/
133-
performMatch: (matcherDefinition: object, problemPatterns: any[], problems: any[]): Promise<MatchProblemResponse> => {
133+
performMatch: (matcherDefinition: object, problemPatterns: any[], problems: any[] = []): Promise<MatchProblemResponse> => {
134134
return cbws.messageManager.sendAndWaitForResponse(
135135
{
136136
"type": "codeEvent",
137137
"action": "performMatch",
138138
payload: {
139139
matcherDefinition,
140140
problemPatterns,
141+
problems
141142
}
142143
},
143144
"matchProblemResponse"
@@ -160,7 +161,7 @@ const cbcodeutils = {
160161

161162
/**
162163
* Retrieves details of a match.
163-
* @param {string} matcher - The matcher to retrieve details for.
164+
* @param {string} matcher - The matcher to retrieve details for (by name or identifier).
164165
* @returns {Promise<getMatchDetail>} A promise that resolves with the match detail response.
165166
*/
166167
matchDetail: (matcher: string): Promise<getMatchDetail> => {
@@ -169,7 +170,7 @@ const cbcodeutils = {
169170
"type": "codeEvent",
170171
"action": "getMatchDetail",
171172
payload: {
172-
match: matcher
173+
matcher: matcher
173174
}
174175
},
175176
"getMatchDetailResponse"

testcases/tests/codeutils-test.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,17 @@ async function testCodeUtils() {
1010

1111
console.log('\n1. Testing JavaScript tree generation for current directory...');
1212
try {
13-
eerr
14-
// const jsTreeResult = await codebolt.codeutils.getJsTree();
15-
// console.log('✅ JS tree result:', jsTreeResult);
16-
// console.log(' - Event type:', jsTreeResult?.event);
17-
// console.log(' - Payload available:', !!jsTreeResult?.payload);
13+
const jsTreeResult = await codebolt.codeutils.getJsTree();
14+
console.log('✅ JS tree result:', jsTreeResult);
15+
console.log(' - Event type:', jsTreeResult?.event);
16+
console.log(' - Payload available:', !!jsTreeResult?.payload);
1817
} catch (error) {
1918
console.log('⚠️ JS tree generation failed:', error.message);
2019
}
2120

2221
console.log('\n2. Testing JavaScript tree generation for specific file...');
2322
try {
24-
fdf
25-
// const specificFileResult = await codebolt.codeutils.getJsTree('./tests/terminal-test.js');
23+
const specificFileResult = await codebolt.codeutils.getJsTree('./tests/terminal-test.js');
2624
console.log('✅ Specific file JS tree result:', specificFileResult);
2725
console.log(' - Event type:', specificFileResult?.event);
2826
} catch (error) {
@@ -67,7 +65,7 @@ async function testCodeUtils() {
6765
language: 'javascript'
6866
};
6967
const problemPatterns = [
70-
{ pattern: 'console\\.log', severity: 'warning' },
68+
{ pattern: 'logger\\.info', severity: 'warning' },
7169
{ pattern: 'var\\s+', severity: 'error' }
7270
];
7371
const problems = [

0 commit comments

Comments
 (0)