nsmcp::CodeSearchTool method execute (public)

 <instance of nsmcp::CodeSearchTool[i]> execute context arguments

Defined in /usr/local/ns/tcl/nsmcp/code-tools.tcl

Parameters:
context (required)
arguments (required)

Testcases:
No testcase defined.
Source code:
set opts [:options $arguments]; set catalog [::nsmcp::codeCatalog]
set matches {}; set needle [string tolower [dict get $opts query]]
foreach name [lsort [dict keys [dict get $catalog entries]]] {
    set doc [::nsmcp::codeMetadata $name]
    set text $name
    if {[dict exists $doc main]} {append text \n [string range [dict get $doc main] 0 8191]}
    if {[string first $needle [string tolower $text]]>=0} {lappend matches $name}
}
set rows {}; set i 0; set offset [dict get $opts offset]; set limit [dict get $opts limit]
foreach name [lrange $matches $offset [expr {$offset+$limit-1}]] {
    set doc [::nsmcp::codeMetadata $name]; set path {}
    if {[dict exists $doc script]} {set path [dict get $doc script]}
    lappend rows $i object [list name string $name kind string [dict get $catalog entries $name kind] sourceFile string $path]
    incr i
}
set more [expr {$offset+$i<[llength $matches]}]; set next {}
if {$more} {set next [list query string [dict get $opts query] limit number $limit offset number [expr {$offset+$i}]]}
return [list {} object [list server string [$context server] observedAt number [clock seconds] matches array $rows matchCount number [llength $matches] more boolean $more nextArguments object $next catalogLimited boolean [dict get $catalog limited] documentationSearchCharacters number 8192 source string loaded-interpreter filesRead boolean false]]
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: