mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-10-09 03:17:58 +00:00
refactor: extract duplicated insideToolParameter logic into helper method
- Created isInsideToolParameter() helper method to eliminate code duplication - Method handles both open and close tag scenarios with optional tagName parameter - Maintains existing functionality while improving code maintainability - All tests continue to pass
This commit is contained in:
parent
e7289bdc33
commit
d18e110668
1 changed files with 21 additions and 9 deletions
|
|
@ -30,10 +30,7 @@ export class DirectiveStreamingParser {
|
|||
const insideCodeBlock = this.isInsideCodeBlock(context, activeHandler)
|
||||
|
||||
// Check if we're inside a tool parameter (but not at the parameter level itself)
|
||||
const insideToolParameter =
|
||||
activeHandler &&
|
||||
activeHandler.constructor.name === "ToolDirectiveHandler" &&
|
||||
(activeHandler as any).currentContext === "param"
|
||||
const insideToolParameter = this.isInsideToolParameter(activeHandler)
|
||||
|
||||
// Only process XML tags if NOT inside code block AND NOT inside tool parameter
|
||||
if (!insideCodeBlock && !insideToolParameter) {
|
||||
|
|
@ -64,11 +61,7 @@ export class DirectiveStreamingParser {
|
|||
const insideCodeBlock = this.isInsideCodeBlock(context, activeHandler)
|
||||
|
||||
// Check if we're inside a tool parameter (but not at the parameter level itself)
|
||||
const insideToolParameter =
|
||||
activeHandler &&
|
||||
activeHandler.constructor.name === "ToolDirectiveHandler" &&
|
||||
(activeHandler as any).currentContext === "param" &&
|
||||
tagName !== (activeHandler as any).currentParamName
|
||||
const insideToolParameter = this.isInsideToolParameter(activeHandler, tagName)
|
||||
|
||||
if (!insideCodeBlock && !insideToolParameter) {
|
||||
// Normal XML processing
|
||||
|
|
@ -134,6 +127,25 @@ export class DirectiveStreamingParser {
|
|||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we're inside a tool parameter (but not at the parameter level itself)
|
||||
*/
|
||||
private static isInsideToolParameter(activeHandler: any, tagName?: string): boolean {
|
||||
if (!activeHandler || activeHandler.constructor.name !== "ToolDirectiveHandler") {
|
||||
return false
|
||||
}
|
||||
|
||||
const isInParamContext = (activeHandler as any).currentContext === "param"
|
||||
|
||||
// For close tags, also check if this is not the parameter tag itself
|
||||
if (tagName !== undefined) {
|
||||
return isInParamContext && tagName !== (activeHandler as any).currentParamName
|
||||
}
|
||||
|
||||
// For open tags, just check if we're in param context
|
||||
return isInParamContext
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert SAX node attributes to string representation
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue