mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-10-10 03:28:03 +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)
|
const insideCodeBlock = this.isInsideCodeBlock(context, activeHandler)
|
||||||
|
|
||||||
// Check if we're inside a tool parameter (but not at the parameter level itself)
|
// Check if we're inside a tool parameter (but not at the parameter level itself)
|
||||||
const insideToolParameter =
|
const insideToolParameter = this.isInsideToolParameter(activeHandler)
|
||||||
activeHandler &&
|
|
||||||
activeHandler.constructor.name === "ToolDirectiveHandler" &&
|
|
||||||
(activeHandler as any).currentContext === "param"
|
|
||||||
|
|
||||||
// Only process XML tags if NOT inside code block AND NOT inside tool parameter
|
// Only process XML tags if NOT inside code block AND NOT inside tool parameter
|
||||||
if (!insideCodeBlock && !insideToolParameter) {
|
if (!insideCodeBlock && !insideToolParameter) {
|
||||||
|
|
@ -64,11 +61,7 @@ export class DirectiveStreamingParser {
|
||||||
const insideCodeBlock = this.isInsideCodeBlock(context, activeHandler)
|
const insideCodeBlock = this.isInsideCodeBlock(context, activeHandler)
|
||||||
|
|
||||||
// Check if we're inside a tool parameter (but not at the parameter level itself)
|
// Check if we're inside a tool parameter (but not at the parameter level itself)
|
||||||
const insideToolParameter =
|
const insideToolParameter = this.isInsideToolParameter(activeHandler, tagName)
|
||||||
activeHandler &&
|
|
||||||
activeHandler.constructor.name === "ToolDirectiveHandler" &&
|
|
||||||
(activeHandler as any).currentContext === "param" &&
|
|
||||||
tagName !== (activeHandler as any).currentParamName
|
|
||||||
|
|
||||||
if (!insideCodeBlock && !insideToolParameter) {
|
if (!insideCodeBlock && !insideToolParameter) {
|
||||||
// Normal XML processing
|
// 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
|
* Convert SAX node attributes to string representation
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue