Skip to content

Commit 619b301

Browse files
Merge branch 'main' into fix/utf8-docstring-truncation-1017
2 parents e85fe83 + feadbe1 commit 619b301

25 files changed

Lines changed: 2892 additions & 36 deletions

Makefile.cbm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ EXTRACTION_SRCS = \
135135
$(CBM_DIR)/extract_k8s.c \
136136
$(CBM_DIR)/helpers.c \
137137
$(CBM_DIR)/lang_specs.c \
138+
$(CBM_DIR)/macro_table.c \
139+
$(CBM_DIR)/iris_export_xml.c \
138140
$(CBM_DIR)/service_patterns.c
139141

140142
# LSP resolvers (compiled as one unit via lsp_all.c)

THIRD_PARTY.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@ License summary:
4848
original upstream authors' licenses — see the manifest for per-grammar
4949
provenance.
5050

51+
### tree-sitter-objectscript (UDL + routine)
52+
53+
- **Project:** [intersystems/tree-sitter-objectscript](https://github.com/intersystems/tree-sitter-objectscript)
54+
- **License:** MIT
55+
- **Copyright:** (c) 2025 InterSystems Corporation
56+
- **Vendored at:** `internal/cbm/vendored/grammars/objectscript_udl/`, `internal/cbm/vendored/grammars/objectscript_routine/`
57+
- **Pinned commit:** `a7ffcdf`
58+
- **Notes:** InterSystems-maintained grammar for the ObjectScript language (InterSystems IRIS / Caché). Vendor-maintained; not in nvim-treesitter or Helix registries. Each `scanner.c`'s upstream `#include "../../common/scanner.h"` is repointed to a per-directory `objectscript_common.h` (verbatim copy of upstream `common/scanner.h`).
59+
5160
## Vendored C/C++ Libraries
5261

5362
| Library | Path | License | Project |

internal/cbm/cbm.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -721,11 +721,6 @@ static bool cbm_source_nesting_exceeds(const char *source, int source_len, int c
721721
return false;
722722
}
723723

724-
static CBMFileResult *cbm_extract_file_impl(const char *source, int source_len,
725-
CBMLanguage language, const char *project,
726-
const char *rel_path, int64_t timeout_micros,
727-
const char **extra_defines, const char **include_paths);
728-
729724
/* Best-effort parse-coverage collection (#963). Walks only the has_error paths
730725
* of the tree and records the 1-based line ranges of the TOP-MOST ERROR/MISSING
731726
* nodes (does not descend into an error subtree — one range per failed region).
@@ -886,17 +881,17 @@ static const char *cbm_error_ranges_str(CBMArena *a, const cbm_error_regions_t *
886881
CBMFileResult *cbm_extract_file(const char *source, int source_len, CBMLanguage language,
887882
const char *project, const char *rel_path, int64_t timeout_micros,
888883
const char **extra_defines, const char **include_paths) {
889-
CBMFileResult *r = cbm_extract_file_impl(source, source_len, language, project, rel_path,
890-
timeout_micros, extra_defines, include_paths);
891-
cbm_index_mark_done(rel_path);
884+
CBMFileResult *r =
885+
cbm_extract_file_ex(source, source_len, language, project, rel_path, timeout_micros,
886+
extra_defines, include_paths, NULL, NULL);
892887
return r;
893888
}
894889

895-
static CBMFileResult *cbm_extract_file_impl(const char *source, int source_len,
896-
CBMLanguage language, const char *project,
897-
const char *rel_path, int64_t timeout_micros,
898-
const char **extra_defines,
899-
const char **include_paths) {
890+
CBMFileResult *cbm_extract_file_ex(const char *source, int source_len, CBMLanguage language,
891+
const char *project, const char *rel_path,
892+
int64_t timeout_micros, const char **extra_defines,
893+
const char **include_paths, const CBMMacroTable *macro_table,
894+
const CBMReturnTypeTable *return_type_table) {
900895
// Allocate result on heap (arena inside for all string data)
901896
enum { SINGLE = 1 };
902897
CBMFileResult *result = (CBMFileResult *)calloc(SINGLE, sizeof(CBMFileResult));
@@ -926,6 +921,7 @@ static CBMFileResult *cbm_extract_file_impl(const char *source, int source_len,
926921
if (!spec) {
927922
result->has_error = true;
928923
result->error_msg = cbm_arena_strdup(a, "unsupported language");
924+
cbm_index_mark_done(rel_path);
929925
return result;
930926
}
931927

@@ -934,6 +930,7 @@ static CBMFileResult *cbm_extract_file_impl(const char *source, int source_len,
934930
if (!ts_lang) {
935931
result->has_error = true;
936932
result->error_msg = cbm_arena_strdup(a, "no tree-sitter grammar");
933+
cbm_index_mark_done(rel_path);
937934
return result;
938935
}
939936

@@ -953,6 +950,7 @@ static CBMFileResult *cbm_extract_file_impl(const char *source, int source_len,
953950
if (!parser) {
954951
result->has_error = true;
955952
result->error_msg = cbm_arena_strdup(a, "parser alloc failed");
953+
cbm_index_mark_done(rel_path);
956954
return result;
957955
}
958956

@@ -985,6 +983,7 @@ static CBMFileResult *cbm_extract_file_impl(const char *source, int source_len,
985983
result->has_error = true;
986984
result->error_msg =
987985
cbm_arena_strdup(a, timeout_micros > 0 ? "parse timeout" : "parse failed");
986+
cbm_index_mark_done(rel_path);
988987
return result;
989988
}
990989

@@ -1009,6 +1008,8 @@ static CBMFileResult *cbm_extract_file_impl(const char *source, int source_len,
10091008
.rel_path = rel_path,
10101009
.module_qn = result->module_qn,
10111010
.root = root,
1011+
.macro_table = macro_table,
1012+
.return_type_table = return_type_table,
10121013
};
10131014

10141015
// Run extractors: defs + imports use separate walks (unique recursion patterns),
@@ -1318,6 +1319,7 @@ static CBMFileResult *cbm_extract_file_impl(const char *source, int source_len,
13181319
// Retain tree for cross-file LSP reuse (caller frees via cbm_free_tree)
13191320
result->cached_tree = tree;
13201321
result->cached_lang = language;
1322+
cbm_index_mark_done(rel_path);
13211323
return result;
13221324
}
13231325

internal/cbm/cbm.h

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,16 @@ typedef enum {
164164
CBM_LANG_APEX,
165165
CBM_LANG_SOQL,
166166
CBM_LANG_SOSL,
167-
CBM_LANG_KUSTOMIZE, // kustomization.yaml — Kubernetes overlay tool
168-
CBM_LANG_K8S, // Generic Kubernetes manifest (apiVersion: detected)
169-
CBM_LANG_PINE, // Pine Script (TradingView indicator / strategy language)
170-
CBM_LANG_QML, // Qt QML (Qt Modeling Language — declarative UI + embedded JS)
171-
CBM_LANG_CFSCRIPT, // CFML script dialect (.cfc components — Lucee/ColdFusion)
172-
CBM_LANG_CFML, // CFML tag dialect (.cfm templates — Lucee/ColdFusion)
173-
CBM_LANG_MOJO, // Mojo
167+
CBM_LANG_KUSTOMIZE, // kustomization.yaml — Kubernetes overlay tool
168+
CBM_LANG_K8S, // Generic Kubernetes manifest (apiVersion: detected)
169+
CBM_LANG_PINE, // Pine Script (TradingView indicator / strategy language)
170+
CBM_LANG_QML, // Qt QML (Qt Modeling Language — declarative UI + embedded JS)
171+
CBM_LANG_CFSCRIPT, // CFML script dialect (.cfc components — Lucee/ColdFusion)
172+
CBM_LANG_CFML, // CFML tag dialect (.cfm templates — Lucee/ColdFusion)
173+
CBM_LANG_MOJO, // Mojo
174+
CBM_LANG_OBJECTSCRIPT_UDL, // InterSystems ObjectScript UDL (.cls class files)
175+
CBM_LANG_OBJECTSCRIPT_ROUTINE, // InterSystems ObjectScript routine (.mac/.int/.rtn/.inc)
176+
CBM_LANG_OBJECTSCRIPT_EXPORT, // InterSystems Studio Export XML (<Export generator="Cache">)
174177
CBM_LANG_COUNT
175178
} CBMLanguage;
176179

@@ -499,6 +502,24 @@ typedef struct {
499502
int count;
500503
} CBMStringConstantMap;
501504

505+
// Forward declaration: ObjectScript macro table (defined in macro_table.h).
506+
typedef struct CBMMacroTable CBMMacroTable;
507+
508+
// Method-return-type table for ObjectScript variable type inference. Populated
509+
// from definition nodes (method QN -> declared return type) so a later
510+
// `Set x = obj.Method()` can resolve x's class.
511+
#define CBM_RETURN_TYPE_TABLE_CAP 2048
512+
513+
typedef struct {
514+
const char *method_qn;
515+
const char *return_type;
516+
} CBMReturnTypeEntry;
517+
518+
typedef struct {
519+
CBMReturnTypeEntry entries[CBM_RETURN_TYPE_TABLE_CAP];
520+
int count;
521+
} CBMReturnTypeTable;
522+
502523
typedef struct {
503524
CBMArena *arena;
504525
CBMFileResult *result;
@@ -509,9 +530,11 @@ typedef struct {
509530
const char *rel_path;
510531
const char *module_qn;
511532
TSNode root;
512-
EFCache ef_cache; // enclosing function cache
513-
const char *enclosing_class_qn; // for nested class QN computation
514-
CBMStringConstantMap string_constants; // module-level NAME = "value" pairs
533+
EFCache ef_cache; // enclosing function cache
534+
const char *enclosing_class_qn; // for nested class QN computation
535+
CBMStringConstantMap string_constants; // module-level NAME = "value" pairs
536+
const CBMMacroTable *macro_table; // ObjectScript $$$macro table (NULL if none)
537+
const CBMReturnTypeTable *return_type_table; // ObjectScript method return types (NULL if none)
515538
} CBMExtractCtx;
516539

517540
// --- Public API ---
@@ -561,6 +584,18 @@ CBMFileResult *cbm_extract_file(const char *source, int source_len, CBMLanguage
561584
const char **include_paths // NULL-terminated, or NULL
562585
);
563586

587+
// Pipeline-internal variant of cbm_extract_file() carrying ObjectScript
588+
// per-project tables (macro table + method-return-type table). The public
589+
// cbm_extract_file() is a thin wrapper that passes NULL, NULL for both.
590+
CBMFileResult *cbm_extract_file_ex(
591+
const char *source, int source_len, CBMLanguage language, const char *project,
592+
const char *rel_path, int64_t timeout_micros,
593+
const char **extra_defines, // NULL-terminated, or NULL
594+
const char **include_paths, // NULL-terminated, or NULL
595+
const CBMMacroTable *macro_table, // ObjectScript macros, or NULL
596+
const CBMReturnTypeTable *return_type_table // OS return types, or NULL
597+
);
598+
564599
// Free all memory associated with a result.
565600
void cbm_free_result(CBMFileResult *result);
566601

0 commit comments

Comments
 (0)