Initial Release
English | Português
A web tool for InterSystems IRIS/Caché that searches for text in the source code (classes and routines) of all namespaces at once, without having to enter each one.
| Class | Purpose |
|---|---|
CodeSearch.Page |
Zen page with the search form and the results display. |
CodeSearch.SearchAPI |
JSON HTTP endpoint (%CSP.Page) called by the page. Actions: start, status, result and cancel. |
CodeSearch.Engine |
Search logic: lists namespaces, enumerates items, reads the code and builds the snippets found. |
CodeSearch.Messages |
Message dictionary (i18n) for the interface, in English, Spanish and Portuguese. |
The search runs in the background, in a server Job process. This avoids the Web Gateway HTTP 504 error, which cuts off any request open for more than ~60 s. The flow is:
start, and the server starts the job and immediately returns a jobId.status every ~0.7 s and shows the progress (current namespace, namespaces completed, items checked and matches).result and displays the results.The job state is kept in the ^CodeSearchJob global, in the namespace where the classes are installed. Old jobs (older than 1 hour) are deleted automatically. Each job can only be queried or cancelled by the user who started it.
%SQL.Statement SQL).Import and compile the classes in the %SYS namespace, so that %SYS.Namespace is accessible. The namespace used by VS Code is in .vscode/settings.json.
From the IRIS terminal:
zn "%SYS"
do $system.OBJ.LoadDir("C:\path\to\SearchAll-app\CodeSearch", "ck", .errors, 1)
Or from VS Code, with the InterSystems ObjectScript extension: open the folder and use Import and Compile.
Create a CSP Web Application in System Administration > Security > Applications > Web Applications:
| Field | Suggested value |
|---|---|
| Name | /csp/codesearch |
| Namespace | %SYS |
| Enable | Application, plus the desired authentication method (e.g.: Password) |
| Allowed Authentication Methods | at least one authenticated method, do not allow unauthenticated access |
CodeSearch.Page and CodeSearch.SearchAPI live in the same application, and the page calls the API by relative path.
Open the page:
http://<server>:<port>/csp/codesearch/CodeSearch.Page.cls
Security: by default, the page is protected only by the Web Application authentication. It reads the source code of every namespace the logged-in user is allowed to access. Restrict access to those who need it. To require a dedicated role, create a Resource (e.g.:
%CodeSearch_Search), a Role withUSEon it, and uncomment/add inCodeSearch.Page:Parameter SECURITYRESOURCE = "%CodeSearch_Search:USE";
_)..cls, .mac, .int, .inc, .bas.* as a wildcard, always case-insensitive. Examples: app*.cls, *.mac,my.test.*.mac. When filled in, it replaces the checked extensions.| Key | Action |
|---|---|
| Enter | Search |
| Esc | Cancel the search in progress |
| Ctrl+K | Go back to the search field |
The preferences (term, options, extensions and selected namespaces) are saved in the browser (localStorage) and restored on the next visit. The Clear button erases the term, the mask and the results.
The interface is available in English (en), Spanish (es) and Portuguese (pt). The language is chosen with the selector in the header; on the first visit the browser language applies (e.g.: es-MX uses es) and, if there is no translation, English. The choice is saved in the browser (codesearch.lang).
The texts live in CodeSearch.Messages, one XML XData block per language (<m k="key">text</m>, with %placeholders%). English is the fallback language: a key missing from another language uses the English text. To add a language:
XData en block, rename it to the new language code (e.g.: fr) and translate the values, keeping the keys and the %placeholders%.LANGUAGES and its native name to LANGUAGENAMES (same order) and recompile.The API error responses (SearchAPI) carry error (English text), errorCode and errorParams; the page translates them using the key err.<errorCode>.
Defined as parameters in CodeSearch.Engine:
| Parameter | Default | Description |
|---|---|---|
MAXRESULTS |
500 | Maximum number of matches per search. |
MAXSECONDS |
600 | Maximum search time, in seconds. Since the search runs in the background, this value is not limited by the Web Gateway timeout. |
MINTERMLEN |
3 | Minimum length of the term. |
SNIPPETCONTEXTCHARS |
80 | Characters of context before/after the term in the displayed snippet. |
When MAXRESULTS or MAXSECONDS is reached, the search stops and the screen shows a truncated-results warning. In that case, use a more specific term or select fewer namespaces and extensions.
CodeSearch.SearchAPI was not compiled, or the session expired and the server returned a login page. Recompile and reload the page.Job (process/license limit reached). Try again or ask an administrator to check.%SYS, and the user needs access to the namespace listing..cls is checked under Extensions and that the mask is empty or compatible with the item name.