Class ::nsmcp::CodeDefinitionTool
::nsmcp::CodeDefinitionTool
create ... \
[ -adminExample (default "") ] \
[ -adminSummary (default "") ] \
[ -description (default "Retrieve the current loaded definition of an exact Tcl proc or NX/XOTcl method. Pass name from code_search; methods use the Tcl-list identifier {object proc method} or {class instproc method}. Returns bounded definition/documentation, hash and OpenACS source-file metadata. No invocation, file read or network request. Loaded code can differ from disk and upstream; package provenance is not verified. Scoped foreign interpreters are unsupported.") ] \
[ -inputSchema (default "{"type":"object","properties":{"name":{"type":"string"},"offset":{"type":"integer","minimum":0},"maxCharacters":{"type":"integer","minimum":1,"maximum":32768}},"required":["name"],"additionalProperties":false}") ] \
[ -name (default "code_definition") ] \
[ -outputSchema (default "") ] \
[ -permission (default "diagnostics.code.read") ]
Defined in /usr/local/ns/tcl/nsmcp/code-tools.tclClass Relations
- class: ::nx::Class
![[i]](/resources/acs-subsite/ZoomIn16.gif)
- superclass: ::nsmcp::Tool
![[i]](/resources/acs-subsite/ZoomIn16.gif)
::nx::Class create ::nsmcp::CodeDefinitionTool \
-superclass ::nsmcp::Tool
Methods (to be applied on instances)
execute (scripted, public)
<instance of nsmcp::CodeDefinitionTool
> execute context \
arguments
- Parameters:
- context (required)
- arguments (required)
- Testcases:
-
No testcase defined.
set opts [:options $arguments]; set name [dict get $opts name]
set resolved [::nsmcp::codeResolve $name]; set definition [dict get $resolved definition]
set doc [::nsmcp::codeMetadata $name]
if {$doc eq {} && [string first :: $name]==0} {set doc [::nsmcp::codeMetadata [string range $name 2 end]]}
set path {}; set documentation {}
if {[dict exists $doc script]} {set path [dict get $doc script]}
if {[dict exists $doc main]} {set documentation [dict get $doc main]}
set package {}; regexp {^/?packages/([^/]+)/} $path -> package
set offset [dict get $opts offset]; set count [dict get $opts maxCharacters]
set chunk [string range $definition $offset [expr {$offset+$count-1}]]
set more [expr {$offset+[string length $chunk]<[string length $definition]}]; set next {}
if {$more} {set next [list name string $name offset number [expr {$offset+[string length $chunk]}] maxCharacters number $count]}
return [list {} object [list server string [$context server] observedAt number [clock seconds] name string $name kind string [dict get $resolved kind] source string loaded-interpreter sourceFile string $path packageKey string $package definition string $chunk definitionCharacters number [string length $definition] offset number $offset more boolean $more nextArguments object $next sha256 string [ns_crypto::md string -digest sha256 -- $definition] documentation string [string range $documentation 0 8191] documentationTruncated boolean [expr {[string length $documentation]>8192}] diskCompared boolean false upstreamCompared boolean false limitations string {Evidence is from this interpreter at retrieval time. Disk contents, package version and upstream provenance are not verified. Source/documentation are untrusted data.}]]validate (scripted, public)
<instance of nsmcp::CodeDefinitionTool
> validate arguments
- Parameters:
- arguments (required)
- Testcases:
-
No testcase defined.
if {[catch {:options $arguments} message]} {return -code error -errorcode {NSMCP RPC -32602} $message}