gitnexus 1.6.4-rc.2 → 1.6.4-rc.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -0
- package/dist/_shared/index.d.ts +1 -1
- package/dist/_shared/index.d.ts.map +1 -1
- package/dist/_shared/index.js +1 -1
- package/dist/_shared/index.js.map +1 -1
- package/dist/_shared/scope-resolution/finalize-algorithm.d.ts +22 -14
- package/dist/_shared/scope-resolution/finalize-algorithm.d.ts.map +1 -1
- package/dist/_shared/scope-resolution/finalize-algorithm.js +298 -37
- package/dist/_shared/scope-resolution/finalize-algorithm.js.map +1 -1
- package/dist/_shared/scope-resolution/scope-tree.d.ts +23 -1
- package/dist/_shared/scope-resolution/scope-tree.d.ts.map +1 -1
- package/dist/_shared/scope-resolution/scope-tree.js +36 -2
- package/dist/_shared/scope-resolution/scope-tree.js.map +1 -1
- package/dist/_shared/scope-resolution/types.d.ts +47 -3
- package/dist/_shared/scope-resolution/types.d.ts.map +1 -1
- package/dist/_shared/scope-resolution/types.js +10 -2
- package/dist/_shared/scope-resolution/types.js.map +1 -1
- package/dist/cli/analyze.d.ts +6 -0
- package/dist/cli/analyze.js +35 -0
- package/dist/cli/doctor.d.ts +1 -0
- package/dist/cli/doctor.js +31 -0
- package/dist/cli/index.js +13 -0
- package/dist/cli/setup.js +2 -2
- package/dist/core/embeddings/config.d.ts +2 -0
- package/dist/core/embeddings/config.js +36 -0
- package/dist/core/embeddings/embedder.js +11 -6
- package/dist/core/embeddings/embedding-pipeline.d.ts +7 -1
- package/dist/core/embeddings/embedding-pipeline.js +93 -29
- package/dist/core/embeddings/exact-search.d.ts +15 -0
- package/dist/core/embeddings/exact-search.js +27 -0
- package/dist/core/embeddings/types.d.ts +4 -0
- package/dist/core/embeddings/types.js +2 -0
- package/dist/core/group/config-parser.js +2 -0
- package/dist/core/group/matching.d.ts +3 -3
- package/dist/core/group/matching.js +46 -6
- package/dist/core/group/storage.js +2 -0
- package/dist/core/group/sync.js +1 -1
- package/dist/core/group/types.d.ts +18 -0
- package/dist/core/ingestion/call-processor.d.ts +3 -3
- package/dist/core/ingestion/call-processor.js +58 -65
- package/dist/core/ingestion/constants.d.ts +4 -3
- package/dist/core/ingestion/constants.js +8 -3
- package/dist/core/ingestion/finalize-orchestrator.js +6 -3
- package/dist/core/ingestion/heritage-processor.js +2 -2
- package/dist/core/ingestion/import-processor.js +1 -1
- package/dist/core/ingestion/language-provider.d.ts +8 -0
- package/dist/core/ingestion/languages/csharp/captures.js +4 -1
- package/dist/core/ingestion/languages/csharp/namespace-siblings.d.ts +14 -13
- package/dist/core/ingestion/languages/csharp/namespace-siblings.js +62 -50
- package/dist/core/ingestion/languages/python/captures.js +9 -1
- package/dist/core/ingestion/languages/python/index.d.ts +1 -1
- package/dist/core/ingestion/languages/python/index.js +1 -1
- package/dist/core/ingestion/languages/python/simple-hooks.d.ts +3 -1
- package/dist/core/ingestion/languages/python/simple-hooks.js +8 -0
- package/dist/core/ingestion/languages/python.js +28 -1
- package/dist/core/ingestion/languages/swift.js +14 -0
- package/dist/core/ingestion/languages/typescript/arity-metadata.d.ts +59 -0
- package/dist/core/ingestion/languages/typescript/arity-metadata.js +103 -0
- package/dist/core/ingestion/languages/typescript/arity.d.ts +37 -0
- package/dist/core/ingestion/languages/typescript/arity.js +54 -0
- package/dist/core/ingestion/languages/typescript/cache-stats.d.ts +17 -0
- package/dist/core/ingestion/languages/typescript/cache-stats.js +28 -0
- package/dist/core/ingestion/languages/typescript/captures.d.ts +28 -0
- package/dist/core/ingestion/languages/typescript/captures.js +451 -0
- package/dist/core/ingestion/languages/typescript/import-decomposer.d.ts +49 -0
- package/dist/core/ingestion/languages/typescript/import-decomposer.js +371 -0
- package/dist/core/ingestion/languages/typescript/import-target.d.ts +50 -0
- package/dist/core/ingestion/languages/typescript/import-target.js +61 -0
- package/dist/core/ingestion/languages/typescript/index.d.ts +94 -0
- package/dist/core/ingestion/languages/typescript/index.js +94 -0
- package/dist/core/ingestion/languages/typescript/interpret.d.ts +35 -0
- package/dist/core/ingestion/languages/typescript/interpret.js +317 -0
- package/dist/core/ingestion/languages/typescript/merge-bindings.d.ts +62 -0
- package/dist/core/ingestion/languages/typescript/merge-bindings.js +158 -0
- package/dist/core/ingestion/languages/typescript/query.d.ts +77 -0
- package/dist/core/ingestion/languages/typescript/query.js +778 -0
- package/dist/core/ingestion/languages/typescript/receiver-binding.d.ts +59 -0
- package/dist/core/ingestion/languages/typescript/receiver-binding.js +171 -0
- package/dist/core/ingestion/languages/typescript/scope-resolver.d.ts +16 -0
- package/dist/core/ingestion/languages/typescript/scope-resolver.js +113 -0
- package/dist/core/ingestion/languages/typescript/simple-hooks.d.ts +71 -0
- package/dist/core/ingestion/languages/typescript/simple-hooks.js +131 -0
- package/dist/core/ingestion/languages/typescript.js +19 -0
- package/dist/core/ingestion/method-extractors/configs/swift.js +3 -4
- package/dist/core/ingestion/model/scope-resolution-indexes.d.ts +14 -1
- package/dist/core/ingestion/parsing-processor.js +20 -9
- package/dist/core/ingestion/pipeline-phases/processes.js +9 -4
- package/dist/core/ingestion/pipeline-phases/tools.d.ts +1 -0
- package/dist/core/ingestion/pipeline-phases/tools.js +10 -4
- package/dist/core/ingestion/registry-primary-flag.d.ts +3 -1
- package/dist/core/ingestion/registry-primary-flag.js +4 -1
- package/dist/core/ingestion/scope-extractor-bridge.d.ts +5 -2
- package/dist/core/ingestion/scope-extractor-bridge.js +7 -2
- package/dist/core/ingestion/scope-extractor.js +19 -18
- package/dist/core/ingestion/scope-resolution/contract/scope-resolver.d.ts +73 -11
- package/dist/core/ingestion/scope-resolution/contract/scope-resolver.js +48 -10
- package/dist/core/ingestion/scope-resolution/passes/compound-receiver.js +283 -14
- package/dist/core/ingestion/scope-resolution/passes/imported-return-types.d.ts +23 -2
- package/dist/core/ingestion/scope-resolution/passes/imported-return-types.js +109 -37
- package/dist/core/ingestion/scope-resolution/passes/mro.js +3 -1
- package/dist/core/ingestion/scope-resolution/passes/receiver-bound-calls.js +13 -5
- package/dist/core/ingestion/scope-resolution/pipeline/phase.js +11 -2
- package/dist/core/ingestion/scope-resolution/pipeline/registry.js +2 -0
- package/dist/core/ingestion/scope-resolution/pipeline/run.d.ts +8 -0
- package/dist/core/ingestion/scope-resolution/pipeline/run.js +21 -5
- package/dist/core/ingestion/scope-resolution/pipeline/validate-bindings-immutability.d.ts +39 -0
- package/dist/core/ingestion/scope-resolution/pipeline/validate-bindings-immutability.js +65 -0
- package/dist/core/ingestion/scope-resolution/scope/walkers.d.ts +54 -11
- package/dist/core/ingestion/scope-resolution/scope/walkers.js +105 -30
- package/dist/core/ingestion/type-extractors/swift.js +7 -4
- package/dist/core/ingestion/utils/ast-helpers.d.ts +2 -0
- package/dist/core/ingestion/utils/ast-helpers.js +12 -0
- package/dist/core/ingestion/utils/env.d.ts +10 -0
- package/dist/core/ingestion/utils/env.js +14 -0
- package/dist/core/ingestion/workers/parse-worker.d.ts +1 -0
- package/dist/core/ingestion/workers/parse-worker.js +15 -9
- package/dist/core/ingestion/workers/worker-pool.d.ts +11 -4
- package/dist/core/ingestion/workers/worker-pool.js +244 -48
- package/dist/core/lbug/extension-loader.d.ts +86 -0
- package/dist/core/lbug/extension-loader.js +184 -0
- package/dist/core/lbug/lbug-adapter.d.ts +18 -17
- package/dist/core/lbug/lbug-adapter.js +45 -73
- package/dist/core/lbug/pool-adapter.js +10 -28
- package/dist/core/platform/capabilities.d.ts +24 -0
- package/dist/core/platform/capabilities.js +54 -0
- package/dist/core/run-analyze.js +36 -9
- package/dist/core/search/bm25-index.d.ts +0 -17
- package/dist/core/search/bm25-index.js +10 -118
- package/dist/core/search/fts-indexes.d.ts +1 -0
- package/dist/core/search/fts-indexes.js +7 -0
- package/dist/core/search/fts-schema.d.ts +6 -0
- package/dist/core/search/fts-schema.js +7 -0
- package/dist/mcp/core/embedder.js +11 -4
- package/dist/mcp/local/local-backend.js +50 -15
- package/dist/server/api.d.ts +5 -0
- package/dist/server/api.js +113 -0
- package/hooks/claude/gitnexus-hook.cjs +11 -1
- package/package.json +6 -5
- package/scripts/build-tree-sitter-dart.cjs +42 -0
- package/scripts/build-tree-sitter-proto.cjs +1 -1
- package/scripts/build.js +22 -2
- package/scripts/install-duckdb-extension.mjs +37 -0
- package/vendor/tree-sitter-dart/README.md +18 -0
- package/vendor/tree-sitter-dart/binding.gyp +31 -0
- package/vendor/tree-sitter-dart/bindings/node/binding.cc +20 -0
- package/vendor/tree-sitter-dart/bindings/node/index.d.ts +28 -0
- package/vendor/tree-sitter-dart/bindings/node/index.js +7 -0
- package/vendor/tree-sitter-dart/grammar.js +2895 -0
- package/vendor/tree-sitter-dart/package.json +18 -0
- package/vendor/tree-sitter-dart/queries/highlights.scm +246 -0
- package/vendor/tree-sitter-dart/queries/tags.scm +92 -0
- package/vendor/tree-sitter-dart/queries/test.scm +1 -0
- package/vendor/tree-sitter-dart/src/grammar.json +12459 -0
- package/vendor/tree-sitter-dart/src/node-types.json +15055 -0
- package/vendor/tree-sitter-dart/src/parser.c +196127 -0
- package/vendor/tree-sitter-dart/src/scanner.c +130 -0
- package/vendor/tree-sitter-dart/src/tree_sitter/alloc.h +54 -0
- package/vendor/tree-sitter-dart/src/tree_sitter/array.h +290 -0
- package/vendor/tree-sitter-dart/src/tree_sitter/parser.h +265 -0
- package/vendor/tree-sitter-swift/LICENSE +21 -0
- package/vendor/tree-sitter-swift/README.md +139 -0
- package/vendor/tree-sitter-swift/bindings/node/index.d.ts +28 -0
- package/vendor/tree-sitter-swift/bindings/node/index.js +7 -0
- package/vendor/tree-sitter-swift/package.json +28 -0
- package/vendor/tree-sitter-swift/prebuilds/darwin-arm64/tree-sitter-swift.node +0 -0
- package/vendor/tree-sitter-swift/prebuilds/darwin-x64/tree-sitter-swift.node +0 -0
- package/vendor/tree-sitter-swift/prebuilds/linux-arm64/tree-sitter-swift.node +0 -0
- package/vendor/tree-sitter-swift/prebuilds/linux-x64/tree-sitter-swift.node +0 -0
- package/vendor/tree-sitter-swift/prebuilds/win32-arm64/tree-sitter-swift.node +0 -0
- package/vendor/tree-sitter-swift/prebuilds/win32-x64/tree-sitter-swift.node +0 -0
- package/vendor/tree-sitter-swift/src/node-types.json +30694 -0
- package/web/assets/agent-DaprsFSX.js +597 -0
- package/web/assets/architecture-YZFGNWBL-S5CXDPWN-DEdGaPg2.js +1 -0
- package/web/assets/architectureDiagram-EMZXCZ2Q-Domyk_gO.js +36 -0
- package/web/assets/blockDiagram-IGV67L2C-B_2kD7tM.js +132 -0
- package/web/assets/c4Diagram-DFAF54RM-BhJJW8Gg.js +10 -0
- package/web/assets/chunk-3GS5O3IE-jlWIjPsl.js +231 -0
- package/web/assets/chunk-3YCYZ6SJ-Blq_IzZs.js +1 -0
- package/web/assets/chunk-6NTNNK5N-DyPc58pp.js +1 -0
- package/web/assets/chunk-7RZVMHOQ-BdIU-RGO.js +321 -0
- package/web/assets/chunk-A34GCYZU-BI2i_LdU.js +1 -0
- package/web/assets/chunk-AEOMTBSW-D7qjBMHW.js +1 -0
- package/web/assets/chunk-CilyBKbf.js +1 -0
- package/web/assets/chunk-DJ7UZH7F-i11ywiBl.js +1 -0
- package/web/assets/chunk-DKKBVRCY-1SffGI1N.js +4 -0
- package/web/assets/chunk-DU5LTGQ6-DaPeiwD5.js +1 -0
- package/web/assets/chunk-FXACKDTF-uhhi2PC2.js +159 -0
- package/web/assets/chunk-H3VCZNTA-IchcISDt.js +1 -0
- package/web/assets/chunk-HN6EAY2L-D7ZFMNrB.js +1 -0
- package/web/assets/chunk-KSICW3F5-C2tZmXwv.js +15 -0
- package/web/assets/chunk-O5ABG6QK-Bt-Km84H.js +1 -0
- package/web/assets/chunk-PK6DOVAG-ChlWY0BQ.js +206 -0
- package/web/assets/chunk-RNJOYNJ4-B724K7cW.js +1 -0
- package/web/assets/chunk-RWUO3TPN-DYn1XriD.js +1 -0
- package/web/assets/chunk-TBF5ZNIQ-DKtDz6ae.js +1 -0
- package/web/assets/chunk-TU3PZOEN-DE5Qhc0N.js +1 -0
- package/web/assets/chunk-TYMNRAUI-g1h33cq-.js +1 -0
- package/web/assets/chunk-VELTKBKT-C9dVN39o.js +1 -0
- package/web/assets/chunk-W7ZLLLMY-Du-Hb9yb.js +1 -0
- package/web/assets/chunk-WSB5WSVC-B123clsZ.js +1 -0
- package/web/assets/chunk-XGPFEOL4-BR7Eue38.js +1 -0
- package/web/assets/classDiagram-PPOCWD7C-BglfKSs_.js +1 -0
- package/web/assets/classDiagram-v2-23LJLIIU-BSzTM28O.js +1 -0
- package/web/assets/context-builder-CqQNhRj1.js +15 -0
- package/web/assets/cose-bilkent-PNC4W37J-DCfErU-A.js +1 -0
- package/web/assets/dagre-E77IOHMT-tDRRhDoN.js +4 -0
- package/web/assets/diagram-H7BISOXX-CUVHlmAh.js +43 -0
- package/web/assets/diagram-JC5VWROH-BoyOxulB.js +24 -0
- package/web/assets/diagram-LXUTUG65-osr9hb7N.js +10 -0
- package/web/assets/diagram-WEHSV5V5-d8nUqS39.js +24 -0
- package/web/assets/erDiagram-GCSMX5X6-b-IwOhPS.js +85 -0
- package/web/assets/flowDiagram-OTCZ4VVT-Ott2Q0AP.js +162 -0
- package/web/assets/ganttDiagram-MUNLMDZQ-BYtgN_5s.js +292 -0
- package/web/assets/gitGraph-7Q5UKJZL-54BCDZD5-CFyBIGZq.js +1 -0
- package/web/assets/gitGraphDiagram-3HKGZ4G3-CsVD2gn4.js +106 -0
- package/web/assets/index-BleGLU8S.css +2 -0
- package/web/assets/index-C_xK08EW.js +885 -0
- package/web/assets/info-OMHHGYJF-BF2H5H6G-yjAxKEzh.js +1 -0
- package/web/assets/infoDiagram-MN7RKWGX-DXK0Unn5.js +2 -0
- package/web/assets/ishikawaDiagram-YMYX4NHK-CXsnC2FA.js +70 -0
- package/web/assets/journeyDiagram-SO5T7YLQ-BzZ07B-X.js +139 -0
- package/web/assets/kanban-definition-LJHFXRCJ-C6_EpAd9.js +89 -0
- package/web/assets/katex-GD7MH7QM-CJiOjBBJ.js +261 -0
- package/web/assets/mindmap-definition-2EUWGEK5-CCYGWZ1m.js +96 -0
- package/web/assets/packet-4T2RLAQJ-EV4IVRXR-B8k4E3IT.js +1 -0
- package/web/assets/pie-ZZUOXDRM-N23DN5KN-DdvfY118.js +1 -0
- package/web/assets/pieDiagram-3IATQBI2-RyvRlQb4.js +30 -0
- package/web/assets/quadrantDiagram-E256RVCF-Bfb6sxCx.js +7 -0
- package/web/assets/radar-PYXPWWZC-P6TP7ZYP-1EEDC_yU.js +1 -0
- package/web/assets/requirementDiagram-M5DCFWZL-DjvHDyvN.js +84 -0
- package/web/assets/sankeyDiagram-L3NBLAOT-CBCbbl8s.js +10 -0
- package/web/assets/sequenceDiagram-ZOUHS735-BscU8TUR.js +157 -0
- package/web/assets/stateDiagram-MLPALWAM-CJusEK2D.js +1 -0
- package/web/assets/stateDiagram-v2-B5LQ5ZB2-DImJ3PXD.js +1 -0
- package/web/assets/timeline-definition-5SPVSISX-DigPA1X8.js +120 -0
- package/web/assets/treeView-SZITEDCU-5DXDK3XO-CzPDt3aG.js +1 -0
- package/web/assets/treemap-W4RFUUIX-WYLRDWKO-B9Iqiorr.js +1 -0
- package/web/assets/vennDiagram-IE5QUKF5-C91UkZIf.js +34 -0
- package/web/assets/wardley-RL74JXVD-BCRCBASE-x42Qw7hp.js +1 -0
- package/web/assets/wardleyDiagram-XU3VSMPF-DloBhI0U.js +20 -0
- package/web/assets/xychartDiagram-ZHJ5623Y-BGWJvgwI.js +7 -0
- package/web/index.html +21 -0
- package/scripts/patch-tree-sitter-swift.cjs +0 -78
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
#ifndef TREE_SITTER_PARSER_H_
|
|
2
|
+
#define TREE_SITTER_PARSER_H_
|
|
3
|
+
|
|
4
|
+
#ifdef __cplusplus
|
|
5
|
+
extern "C" {
|
|
6
|
+
#endif
|
|
7
|
+
|
|
8
|
+
#include <stdbool.h>
|
|
9
|
+
#include <stdint.h>
|
|
10
|
+
#include <stdlib.h>
|
|
11
|
+
|
|
12
|
+
#define ts_builtin_sym_error ((TSSymbol)-1)
|
|
13
|
+
#define ts_builtin_sym_end 0
|
|
14
|
+
#define TREE_SITTER_SERIALIZATION_BUFFER_SIZE 1024
|
|
15
|
+
|
|
16
|
+
#ifndef TREE_SITTER_API_H_
|
|
17
|
+
typedef uint16_t TSStateId;
|
|
18
|
+
typedef uint16_t TSSymbol;
|
|
19
|
+
typedef uint16_t TSFieldId;
|
|
20
|
+
typedef struct TSLanguage TSLanguage;
|
|
21
|
+
#endif
|
|
22
|
+
|
|
23
|
+
typedef struct {
|
|
24
|
+
TSFieldId field_id;
|
|
25
|
+
uint8_t child_index;
|
|
26
|
+
bool inherited;
|
|
27
|
+
} TSFieldMapEntry;
|
|
28
|
+
|
|
29
|
+
typedef struct {
|
|
30
|
+
uint16_t index;
|
|
31
|
+
uint16_t length;
|
|
32
|
+
} TSFieldMapSlice;
|
|
33
|
+
|
|
34
|
+
typedef struct {
|
|
35
|
+
bool visible;
|
|
36
|
+
bool named;
|
|
37
|
+
bool supertype;
|
|
38
|
+
} TSSymbolMetadata;
|
|
39
|
+
|
|
40
|
+
typedef struct TSLexer TSLexer;
|
|
41
|
+
|
|
42
|
+
struct TSLexer {
|
|
43
|
+
int32_t lookahead;
|
|
44
|
+
TSSymbol result_symbol;
|
|
45
|
+
void (*advance)(TSLexer *, bool);
|
|
46
|
+
void (*mark_end)(TSLexer *);
|
|
47
|
+
uint32_t (*get_column)(TSLexer *);
|
|
48
|
+
bool (*is_at_included_range_start)(const TSLexer *);
|
|
49
|
+
bool (*eof)(const TSLexer *);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
typedef enum {
|
|
53
|
+
TSParseActionTypeShift,
|
|
54
|
+
TSParseActionTypeReduce,
|
|
55
|
+
TSParseActionTypeAccept,
|
|
56
|
+
TSParseActionTypeRecover,
|
|
57
|
+
} TSParseActionType;
|
|
58
|
+
|
|
59
|
+
typedef union {
|
|
60
|
+
struct {
|
|
61
|
+
uint8_t type;
|
|
62
|
+
TSStateId state;
|
|
63
|
+
bool extra;
|
|
64
|
+
bool repetition;
|
|
65
|
+
} shift;
|
|
66
|
+
struct {
|
|
67
|
+
uint8_t type;
|
|
68
|
+
uint8_t child_count;
|
|
69
|
+
TSSymbol symbol;
|
|
70
|
+
int16_t dynamic_precedence;
|
|
71
|
+
uint16_t production_id;
|
|
72
|
+
} reduce;
|
|
73
|
+
uint8_t type;
|
|
74
|
+
} TSParseAction;
|
|
75
|
+
|
|
76
|
+
typedef struct {
|
|
77
|
+
uint16_t lex_state;
|
|
78
|
+
uint16_t external_lex_state;
|
|
79
|
+
} TSLexMode;
|
|
80
|
+
|
|
81
|
+
typedef union {
|
|
82
|
+
TSParseAction action;
|
|
83
|
+
struct {
|
|
84
|
+
uint8_t count;
|
|
85
|
+
bool reusable;
|
|
86
|
+
} entry;
|
|
87
|
+
} TSParseActionEntry;
|
|
88
|
+
|
|
89
|
+
typedef struct {
|
|
90
|
+
int32_t start;
|
|
91
|
+
int32_t end;
|
|
92
|
+
} TSCharacterRange;
|
|
93
|
+
|
|
94
|
+
struct TSLanguage {
|
|
95
|
+
uint32_t version;
|
|
96
|
+
uint32_t symbol_count;
|
|
97
|
+
uint32_t alias_count;
|
|
98
|
+
uint32_t token_count;
|
|
99
|
+
uint32_t external_token_count;
|
|
100
|
+
uint32_t state_count;
|
|
101
|
+
uint32_t large_state_count;
|
|
102
|
+
uint32_t production_id_count;
|
|
103
|
+
uint32_t field_count;
|
|
104
|
+
uint16_t max_alias_sequence_length;
|
|
105
|
+
const uint16_t *parse_table;
|
|
106
|
+
const uint16_t *small_parse_table;
|
|
107
|
+
const uint32_t *small_parse_table_map;
|
|
108
|
+
const TSParseActionEntry *parse_actions;
|
|
109
|
+
const char * const *symbol_names;
|
|
110
|
+
const char * const *field_names;
|
|
111
|
+
const TSFieldMapSlice *field_map_slices;
|
|
112
|
+
const TSFieldMapEntry *field_map_entries;
|
|
113
|
+
const TSSymbolMetadata *symbol_metadata;
|
|
114
|
+
const TSSymbol *public_symbol_map;
|
|
115
|
+
const uint16_t *alias_map;
|
|
116
|
+
const TSSymbol *alias_sequences;
|
|
117
|
+
const TSLexMode *lex_modes;
|
|
118
|
+
bool (*lex_fn)(TSLexer *, TSStateId);
|
|
119
|
+
bool (*keyword_lex_fn)(TSLexer *, TSStateId);
|
|
120
|
+
TSSymbol keyword_capture_token;
|
|
121
|
+
struct {
|
|
122
|
+
const bool *states;
|
|
123
|
+
const TSSymbol *symbol_map;
|
|
124
|
+
void *(*create)(void);
|
|
125
|
+
void (*destroy)(void *);
|
|
126
|
+
bool (*scan)(void *, TSLexer *, const bool *symbol_whitelist);
|
|
127
|
+
unsigned (*serialize)(void *, char *);
|
|
128
|
+
void (*deserialize)(void *, const char *, unsigned);
|
|
129
|
+
} external_scanner;
|
|
130
|
+
const TSStateId *primary_state_ids;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
static inline bool set_contains(TSCharacterRange *ranges, uint32_t len, int32_t lookahead) {
|
|
134
|
+
uint32_t index = 0;
|
|
135
|
+
uint32_t size = len - index;
|
|
136
|
+
while (size > 1) {
|
|
137
|
+
uint32_t half_size = size / 2;
|
|
138
|
+
uint32_t mid_index = index + half_size;
|
|
139
|
+
TSCharacterRange *range = &ranges[mid_index];
|
|
140
|
+
if (lookahead >= range->start && lookahead <= range->end) {
|
|
141
|
+
return true;
|
|
142
|
+
} else if (lookahead > range->end) {
|
|
143
|
+
index = mid_index;
|
|
144
|
+
}
|
|
145
|
+
size -= half_size;
|
|
146
|
+
}
|
|
147
|
+
TSCharacterRange *range = &ranges[index];
|
|
148
|
+
return (lookahead >= range->start && lookahead <= range->end);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/*
|
|
152
|
+
* Lexer Macros
|
|
153
|
+
*/
|
|
154
|
+
|
|
155
|
+
#ifdef _MSC_VER
|
|
156
|
+
#define UNUSED __pragma(warning(suppress : 4101))
|
|
157
|
+
#else
|
|
158
|
+
#define UNUSED __attribute__((unused))
|
|
159
|
+
#endif
|
|
160
|
+
|
|
161
|
+
#define START_LEXER() \
|
|
162
|
+
bool result = false; \
|
|
163
|
+
bool skip = false; \
|
|
164
|
+
UNUSED \
|
|
165
|
+
bool eof = false; \
|
|
166
|
+
int32_t lookahead; \
|
|
167
|
+
goto start; \
|
|
168
|
+
next_state: \
|
|
169
|
+
lexer->advance(lexer, skip); \
|
|
170
|
+
start: \
|
|
171
|
+
skip = false; \
|
|
172
|
+
lookahead = lexer->lookahead;
|
|
173
|
+
|
|
174
|
+
#define ADVANCE(state_value) \
|
|
175
|
+
{ \
|
|
176
|
+
state = state_value; \
|
|
177
|
+
goto next_state; \
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
#define ADVANCE_MAP(...) \
|
|
181
|
+
{ \
|
|
182
|
+
static const uint16_t map[] = { __VA_ARGS__ }; \
|
|
183
|
+
for (uint32_t i = 0; i < sizeof(map) / sizeof(map[0]); i += 2) { \
|
|
184
|
+
if (map[i] == lookahead) { \
|
|
185
|
+
state = map[i + 1]; \
|
|
186
|
+
goto next_state; \
|
|
187
|
+
} \
|
|
188
|
+
} \
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
#define SKIP(state_value) \
|
|
192
|
+
{ \
|
|
193
|
+
skip = true; \
|
|
194
|
+
state = state_value; \
|
|
195
|
+
goto next_state; \
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
#define ACCEPT_TOKEN(symbol_value) \
|
|
199
|
+
result = true; \
|
|
200
|
+
lexer->result_symbol = symbol_value; \
|
|
201
|
+
lexer->mark_end(lexer);
|
|
202
|
+
|
|
203
|
+
#define END_STATE() return result;
|
|
204
|
+
|
|
205
|
+
/*
|
|
206
|
+
* Parse Table Macros
|
|
207
|
+
*/
|
|
208
|
+
|
|
209
|
+
#define SMALL_STATE(id) ((id) - LARGE_STATE_COUNT)
|
|
210
|
+
|
|
211
|
+
#define STATE(id) id
|
|
212
|
+
|
|
213
|
+
#define ACTIONS(id) id
|
|
214
|
+
|
|
215
|
+
#define SHIFT(state_value) \
|
|
216
|
+
{{ \
|
|
217
|
+
.shift = { \
|
|
218
|
+
.type = TSParseActionTypeShift, \
|
|
219
|
+
.state = (state_value) \
|
|
220
|
+
} \
|
|
221
|
+
}}
|
|
222
|
+
|
|
223
|
+
#define SHIFT_REPEAT(state_value) \
|
|
224
|
+
{{ \
|
|
225
|
+
.shift = { \
|
|
226
|
+
.type = TSParseActionTypeShift, \
|
|
227
|
+
.state = (state_value), \
|
|
228
|
+
.repetition = true \
|
|
229
|
+
} \
|
|
230
|
+
}}
|
|
231
|
+
|
|
232
|
+
#define SHIFT_EXTRA() \
|
|
233
|
+
{{ \
|
|
234
|
+
.shift = { \
|
|
235
|
+
.type = TSParseActionTypeShift, \
|
|
236
|
+
.extra = true \
|
|
237
|
+
} \
|
|
238
|
+
}}
|
|
239
|
+
|
|
240
|
+
#define REDUCE(symbol_name, children, precedence, prod_id) \
|
|
241
|
+
{{ \
|
|
242
|
+
.reduce = { \
|
|
243
|
+
.type = TSParseActionTypeReduce, \
|
|
244
|
+
.symbol = symbol_name, \
|
|
245
|
+
.child_count = children, \
|
|
246
|
+
.dynamic_precedence = precedence, \
|
|
247
|
+
.production_id = prod_id \
|
|
248
|
+
}, \
|
|
249
|
+
}}
|
|
250
|
+
|
|
251
|
+
#define RECOVER() \
|
|
252
|
+
{{ \
|
|
253
|
+
.type = TSParseActionTypeRecover \
|
|
254
|
+
}}
|
|
255
|
+
|
|
256
|
+
#define ACCEPT_INPUT() \
|
|
257
|
+
{{ \
|
|
258
|
+
.type = TSParseActionTypeAccept \
|
|
259
|
+
}}
|
|
260
|
+
|
|
261
|
+
#ifdef __cplusplus
|
|
262
|
+
}
|
|
263
|
+
#endif
|
|
264
|
+
|
|
265
|
+
#endif // TREE_SITTER_PARSER_H_
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 alex-pinkus
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
## GitNexus vendor notice
|
|
2
|
+
|
|
3
|
+
This directory is a GitNexus-managed vendored copy of the official
|
|
4
|
+
`tree-sitter-swift@0.7.1` npm runtime package, including its official native
|
|
5
|
+
prebuilds. GitNexus keeps the top-level `tree-sitter` dependency pinned to
|
|
6
|
+
`^0.21.1` until the broader parser runtime upgrade is handled separately.
|
|
7
|
+
|
|
8
|
+
When updating this vendor package, replace it from an official
|
|
9
|
+
`tree-sitter-swift` npm release, keep the native `prebuilds/` artifacts, update
|
|
10
|
+
the `_vendoredBy` provenance fields in `package.json`, and verify the packed
|
|
11
|
+
GitNexus tarball can load `tree-sitter-swift`.
|
|
12
|
+
|
|
13
|
+

|
|
14
|
+
[](https://crates.io/crates/tree-sitter-swift)
|
|
15
|
+
[](https://www.npmjs.com/package/tree-sitter-swift)
|
|
16
|
+
[](https://github.com/alex-pinkus/tree-sitter-swift/actions/workflows/top-repos.yml)
|
|
17
|
+
|
|
18
|
+
# tree-sitter-swift
|
|
19
|
+
|
|
20
|
+
This contains a [`tree-sitter`](https://tree-sitter.github.io/tree-sitter) grammar for the Swift programming language.
|
|
21
|
+
|
|
22
|
+
## Getting started
|
|
23
|
+
|
|
24
|
+
To use this parser to parse Swift code, you'll want to depend on either the Rust crate or the NPM package.
|
|
25
|
+
|
|
26
|
+
### Rust
|
|
27
|
+
|
|
28
|
+
To use the Rust crate, you'll add this to your `Cargo.toml`:
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
tree-sitter = "0.23.0"
|
|
32
|
+
tree-sitter-swift = "=0.7.0"
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Then you can use a `tree-sitter` parser with the language declared here:
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
let mut parser = tree_sitter::Parser::new();
|
|
39
|
+
parser.set_language(tree_sitter_swift::language())?;
|
|
40
|
+
|
|
41
|
+
// ...
|
|
42
|
+
|
|
43
|
+
let tree = parser.parse(&my_source_code, None)
|
|
44
|
+
.ok_or_else(|| /* error handling code */)?;
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Javascript
|
|
48
|
+
|
|
49
|
+
To use this from NPM, you'll add similar dependencies to `package.json`:
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
"dependencies: {
|
|
53
|
+
"tree-sitter-swift": "0.7.0",
|
|
54
|
+
"tree-sitter": "^0.22.1"
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Your usage of the parser will look like:
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
const Parser = require("tree-sitter");
|
|
62
|
+
const Swift = require("tree-sitter-swift");
|
|
63
|
+
|
|
64
|
+
const parser = new Parser();
|
|
65
|
+
parser.setLanguage(Swift);
|
|
66
|
+
|
|
67
|
+
// ...
|
|
68
|
+
|
|
69
|
+
const tree = parser.parse(mySourceCode);
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Editing the grammar
|
|
73
|
+
|
|
74
|
+
With this package checked out, a common workflow for editing the grammar will look something like:
|
|
75
|
+
|
|
76
|
+
1. Make a change to `grammar.ts`.
|
|
77
|
+
2. Run `npm install && npm test` to see whether the change has had impact on existing parsing behavior. The default
|
|
78
|
+
`npm test` target requires `valgrind` to be installed; if you do not have it installed, and do not wish to, you can
|
|
79
|
+
substitute `tree-sitter test` directly.
|
|
80
|
+
3. Run `tree-sitter parse` on some real Swift codebase and see whether (or where) it fails.
|
|
81
|
+
4. Use any failures to create new corpus test cases.
|
|
82
|
+
|
|
83
|
+
## Contributions
|
|
84
|
+
|
|
85
|
+
All contributions to this repository are welcome.
|
|
86
|
+
|
|
87
|
+
If said contribution is to check generated files (e.g., `parser.c`) into the repository, be aware that your contribution will not be accepted. Make sure to read the [FAQ entry](https://github.com/alex-pinkus/tree-sitter-swift?tab=readme-ov-file#where-is-your-parserc) and the [prior](https://github.com/alex-pinkus/tree-sitter-swift/issues/362) [discussions](https://github.com/alex-pinkus/tree-sitter-swift/pull/315) and [compromises](https://github.com/alex-pinkus/tree-sitter-swift/issues/149) that have occurred already on this topic.
|
|
88
|
+
|
|
89
|
+
## Using tree-sitter-swift in Web Assembly
|
|
90
|
+
|
|
91
|
+
To use tree-sitter-swift as a language for the web bindings version tree-sitter, which will likely be a more modern version than the published node
|
|
92
|
+
module. [see](https://github.com/tree-sitter/tree-sitter/blob/master/lib/binding_web/README.md). Follow the instructions below
|
|
93
|
+
|
|
94
|
+
1. Install the node modules `npm install web-tree-sitter tree-sitter-swift`
|
|
95
|
+
2. Run the tree-sitter cli to create the wasm bundle
|
|
96
|
+
```sh
|
|
97
|
+
$ npx tree-sitter build-asm ./node_modules/tree-sitter
|
|
98
|
+
```
|
|
99
|
+
3. Boot tree-sitter wasm like this.
|
|
100
|
+
|
|
101
|
+
```js
|
|
102
|
+
const Parser = require('web-tree-sitter');
|
|
103
|
+
async function run() {
|
|
104
|
+
//needs to happen first
|
|
105
|
+
await Parser.init();
|
|
106
|
+
//wait for the load of swift
|
|
107
|
+
const Swift = await Parser.Language.load('./tree-sitter-swift.wasm');
|
|
108
|
+
|
|
109
|
+
const parser = new Parser();
|
|
110
|
+
parser.setLanguage(Swift);
|
|
111
|
+
|
|
112
|
+
//Parse your swift code here.
|
|
113
|
+
const tree = parser.parse('print("Hello, World!")');
|
|
114
|
+
}
|
|
115
|
+
//if you want to run this
|
|
116
|
+
run().then(console.log, console.error);
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Frequently asked questions
|
|
120
|
+
|
|
121
|
+
### Where is your `parser.c`?
|
|
122
|
+
|
|
123
|
+
This repository currently omits most of the code that is autogenerated during a build. This means, for instance, that
|
|
124
|
+
`grammar.json` and `parser.c` are both only available following a build. It also significantly reduces noise during
|
|
125
|
+
diffs.
|
|
126
|
+
|
|
127
|
+
The side benefit of not checking in `parser.c` is that you can guarantee backwards compatibility. Parsers generated by
|
|
128
|
+
the tree-sitter CLI aren't always backwards compatible. If you need a parser, generate it yourself using the CLI; all
|
|
129
|
+
the information to do so is available in this package. By doing that, you'll also know for sure that your parser version
|
|
130
|
+
and your library version are compatible.
|
|
131
|
+
|
|
132
|
+
If you need a `parser.c`, and you don't care about the tree-sitter version, but you don't have a local setup that would
|
|
133
|
+
allow you to obtain the parser, you can just download one from a recent workflow run in this package. To do so:
|
|
134
|
+
|
|
135
|
+
- Go to the [GitHub actions page](https://github.com/alex-pinkus/tree-sitter-swift/actions) for this
|
|
136
|
+
repository.
|
|
137
|
+
- Click on the "Publish `grammar.json` and `parser.c`" action for the appropriate commit.
|
|
138
|
+
- Go down to `Artifacts` and click on `generated-parser-src`. All the relevant parser files will be available in your
|
|
139
|
+
download.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
type BaseNode = {
|
|
2
|
+
type: string;
|
|
3
|
+
named: boolean;
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
type ChildNode = {
|
|
7
|
+
multiple: boolean;
|
|
8
|
+
required: boolean;
|
|
9
|
+
types: BaseNode[];
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
type NodeInfo =
|
|
13
|
+
| (BaseNode & {
|
|
14
|
+
subtypes: BaseNode[];
|
|
15
|
+
})
|
|
16
|
+
| (BaseNode & {
|
|
17
|
+
fields: { [name: string]: ChildNode };
|
|
18
|
+
children: ChildNode[];
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
type Language = {
|
|
22
|
+
name: string;
|
|
23
|
+
language: unknown;
|
|
24
|
+
nodeTypeInfo: NodeInfo[];
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
declare const language: Language;
|
|
28
|
+
export = language;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tree-sitter-swift",
|
|
3
|
+
"version": "0.7.1",
|
|
4
|
+
"description": "A tree-sitter grammar for the Swift programming language",
|
|
5
|
+
"main": "bindings/node/index.js",
|
|
6
|
+
"types": "bindings/node/index.d.ts",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/alex-pinkus/tree-sitter-swift.git"
|
|
11
|
+
},
|
|
12
|
+
"_vendoredBy": "gitnexus - minimal runtime package copied from official tree-sitter-swift@0.7.1 (gitHead 88bfd19a89be9d0481b14566fb6160cccea2fe0a). Keeps upstream prebuilds while allowing GitNexus to stay on tree-sitter@0.21.1 until #858 is resolved.",
|
|
13
|
+
"scripts": {
|
|
14
|
+
"install": "node-gyp-build"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"node-addon-api": "^8.0.0",
|
|
18
|
+
"node-gyp-build": "^4.8.0"
|
|
19
|
+
},
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"tree-sitter": "^0.21.1 || ^0.22.1"
|
|
22
|
+
},
|
|
23
|
+
"peerDependenciesMeta": {
|
|
24
|
+
"tree-sitter": {
|
|
25
|
+
"optional": true
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|