@nokout/big-dill-core 0.0.1
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/LICENSE +21 -0
- package/README.md +202 -0
- package/dist/completion/complete.d.ts +40 -0
- package/dist/completion/complete.d.ts.map +1 -0
- package/dist/completion/complete.js +134 -0
- package/dist/completion/complete.js.map +1 -0
- package/dist/format/tables.d.ts +7 -0
- package/dist/format/tables.d.ts.map +1 -0
- package/dist/format/tables.js +87 -0
- package/dist/format/tables.js.map +1 -0
- package/dist/gherkin/parser.d.ts +28 -0
- package/dist/gherkin/parser.d.ts.map +1 -0
- package/dist/gherkin/parser.js +44 -0
- package/dist/gherkin/parser.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +92 -0
- package/dist/index.js.map +1 -0
- package/dist/ipc/server.d.ts +13 -0
- package/dist/ipc/server.d.ts.map +1 -0
- package/dist/ipc/server.js +106 -0
- package/dist/ipc/server.js.map +1 -0
- package/dist/lint/rules.d.ts +46 -0
- package/dist/lint/rules.d.ts.map +1 -0
- package/dist/lint/rules.js +387 -0
- package/dist/lint/rules.js.map +1 -0
- package/dist/protocol/types.d.ts +97 -0
- package/dist/protocol/types.d.ts.map +1 -0
- package/dist/protocol/types.js +5 -0
- package/dist/protocol/types.js.map +1 -0
- package/dist/pytest/runner.d.ts +29 -0
- package/dist/pytest/runner.d.ts.map +1 -0
- package/dist/pytest/runner.js +225 -0
- package/dist/pytest/runner.js.map +1 -0
- package/dist/results/outcomes.d.ts +36 -0
- package/dist/results/outcomes.d.ts.map +1 -0
- package/dist/results/outcomes.js +69 -0
- package/dist/results/outcomes.js.map +1 -0
- package/dist/steps/browser.d.ts +42 -0
- package/dist/steps/browser.d.ts.map +1 -0
- package/dist/steps/browser.js +110 -0
- package/dist/steps/browser.js.map +1 -0
- package/dist/steps/documentation.d.ts +10 -0
- package/dist/steps/documentation.d.ts.map +1 -0
- package/dist/steps/documentation.js +39 -0
- package/dist/steps/documentation.js.map +1 -0
- package/dist/steps/references.d.ts +10 -0
- package/dist/steps/references.d.ts.map +1 -0
- package/dist/steps/references.js +34 -0
- package/dist/steps/references.js.map +1 -0
- package/dist/steps/stepCache.d.ts +50 -0
- package/dist/steps/stepCache.d.ts.map +1 -0
- package/dist/steps/stepCache.js +149 -0
- package/dist/steps/stepCache.js.map +1 -0
- package/dist/steps/stubs.d.ts +10 -0
- package/dist/steps/stubs.d.ts.map +1 -0
- package/dist/steps/stubs.js +46 -0
- package/dist/steps/stubs.js.map +1 -0
- package/dist/steps/unimplemented.d.ts +10 -0
- package/dist/steps/unimplemented.d.ts.map +1 -0
- package/dist/steps/unimplemented.js +26 -0
- package/dist/steps/unimplemented.js.map +1 -0
- package/dist/symbols/outline.d.ts +13 -0
- package/dist/symbols/outline.d.ts.map +1 -0
- package/dist/symbols/outline.js +38 -0
- package/dist/symbols/outline.js.map +1 -0
- package/dist/tokens/semanticTokens.d.ts +13 -0
- package/dist/tokens/semanticTokens.d.ts.map +1 -0
- package/dist/tokens/semanticTokens.js +77 -0
- package/dist/tokens/semanticTokens.js.map +1 -0
- package/dist/tree/builder.d.ts +40 -0
- package/dist/tree/builder.d.ts.map +1 -0
- package/dist/tree/builder.js +178 -0
- package/dist/tree/builder.js.map +1 -0
- package/package.json +58 -0
- package/src/completion/complete.ts +165 -0
- package/src/format/tables.ts +108 -0
- package/src/gherkin/parser.ts +69 -0
- package/src/index.ts +136 -0
- package/src/ipc/server.ts +84 -0
- package/src/lint/rules.ts +425 -0
- package/src/protocol/types.ts +114 -0
- package/src/pytest/runner.ts +249 -0
- package/src/results/outcomes.ts +102 -0
- package/src/steps/browser.ts +105 -0
- package/src/steps/documentation.ts +43 -0
- package/src/steps/references.ts +33 -0
- package/src/steps/stepCache.ts +168 -0
- package/src/steps/stubs.ts +48 -0
- package/src/steps/unimplemented.ts +31 -0
- package/src/symbols/outline.ts +52 -0
- package/src/tokens/semanticTokens.ts +98 -0
- package/src/tree/builder.ts +187 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nigel O'Keefe
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
# @nokout/big-dill-core
|
|
2
|
+
|
|
3
|
+
The headless engine behind [Big Dill](https://github.com/nokout/big-dill) —
|
|
4
|
+
tooling for [pytest-bdd](https://pytest-bdd.readthedocs.io/).
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
npm install @nokout/big-dill-core
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
**No editor dependency** — CI asserts it. This package parses Gherkin, runs
|
|
11
|
+
structural lint rules, formats tables, indexes step definitions, computes
|
|
12
|
+
completions and test-tree shape, and orchestrates pytest over a local pipe.
|
|
13
|
+
Everything it returns is plain data, so it runs anywhere Node does — a CI lint
|
|
14
|
+
gate, another editor, a script.
|
|
15
|
+
|
|
16
|
+
```js
|
|
17
|
+
const { parseSource, lintDocument } = require('@nokout/big-dill-core');
|
|
18
|
+
|
|
19
|
+
const text = require('fs').readFileSync('login.feature', 'utf-8');
|
|
20
|
+
const { doc } = parseSource(text);
|
|
21
|
+
|
|
22
|
+
for (const d of lintDocument(doc, text.split('\n'))) {
|
|
23
|
+
console.log(`${d.severity} line ${d.line + 1}: ${d.message}`);
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Where this fits
|
|
28
|
+
|
|
29
|
+
Three packages work together:
|
|
30
|
+
|
|
31
|
+
| | |
|
|
32
|
+
|---|---|
|
|
33
|
+
| **`@nokout/big-dill-core`** | this package — the engine |
|
|
34
|
+
| [`pytest-big-dill`](https://pypi.org/project/pytest-big-dill/) | the pytest plugin, installed into the environment your tests run in |
|
|
35
|
+
| [`big-dill`](https://marketplace.visualstudio.com/items?itemName=nokout.big-dill) | the VS Code extension, a thin adapter over this package |
|
|
36
|
+
|
|
37
|
+
Running tests needs `pytest-big-dill` present in the Python environment; parsing,
|
|
38
|
+
linting and formatting need nothing but this package.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
# Building a host
|
|
43
|
+
|
|
44
|
+
Everything below is the adapter contract: what to call, what comes back, and what
|
|
45
|
+
a host is responsible for. It is meant to be enough on its own, without reading
|
|
46
|
+
the VS Code extension.
|
|
47
|
+
|
|
48
|
+
A host is a thin mapping layer — plain results in, editor types out. Nothing in
|
|
49
|
+
core knows a host exists. The VS Code extension is one host; this describes what
|
|
50
|
+
any other would do.
|
|
51
|
+
|
|
52
|
+
## Four substitutions
|
|
53
|
+
|
|
54
|
+
Everything a VS Code extension would reach for has a plain equivalent. If you are
|
|
55
|
+
porting the existing adapter, these are the only translations you need.
|
|
56
|
+
|
|
57
|
+
| Editor construct | Core equivalent | Bridge with |
|
|
58
|
+
|---|---|---|
|
|
59
|
+
| `CancellationToken` | `AbortSignal` | `token.onCancellationRequested(() => controller.abort())` |
|
|
60
|
+
| `workspace.getConfiguration(…)` | a plain options object | read config at the edge, pass it down |
|
|
61
|
+
| `Uri` | a path string, or `{ path, absolute? }` | `Uri.file(p)` / `Uri.joinPath(cwd, p)` |
|
|
62
|
+
| `Position` / `Range` | `{ line, character }` / `{ start, end }` | construct at the edge |
|
|
63
|
+
|
|
64
|
+
Two conventions worth stating outright, because getting them wrong is silent:
|
|
65
|
+
|
|
66
|
+
- **Lines are 0-based** everywhere core returns them, matching most editor APIs.
|
|
67
|
+
The pytest wire protocol is 1-based; core has already converted.
|
|
68
|
+
- **Uri descriptors** are relative to the run's working directory unless
|
|
69
|
+
`absolute` is set. Feature paths are relative; Python file paths are absolute.
|
|
70
|
+
|
|
71
|
+
## Language features
|
|
72
|
+
|
|
73
|
+
Each takes a parsed document and returns plain results. `GherkinParseCache.parse()`
|
|
74
|
+
accepts anything structurally matching `CacheableDocument` — `{ uri: { fsPath },
|
|
75
|
+
version, getText() }` — which VS Code's `TextDocument` satisfies without adaptation.
|
|
76
|
+
|
|
77
|
+
| You want | Call | You get |
|
|
78
|
+
|---|---|---|
|
|
79
|
+
| Parse | `parseSource(text)` or `GherkinParseCache.parse(doc)` | `{ doc, errors }` |
|
|
80
|
+
| Lint | `lintDocument(doc, lines, config)` | `DiagnosticEntry[]` — `{ line, message, severity }` |
|
|
81
|
+
| Complete | `completeAt(line, column, cache)` | `CompletionEntry[]` |
|
|
82
|
+
| Outline | `buildSymbolTree(doc)` | `SymbolNode[]` — nested, with `kind` and `line` |
|
|
83
|
+
| Highlight tables | `buildTableTokens(doc, lines)` | `TokenEntry[]` — plus `TOKEN_TYPES` and `TYPE_INDEX` for the legend |
|
|
84
|
+
| Format tables | `formatTables(doc, lines)` | `TextEditEntry[]` — `{ startLine, newText }` |
|
|
85
|
+
| Hover text | `renderStepMarkdown(step)` | Markdown `string` |
|
|
86
|
+
| Find references | `findReferencesInLines(lines, step)` | 0-based line numbers |
|
|
87
|
+
| Unimplemented steps | `findUnimplementedSteps(lines, cache)` | `{ lineIndex, stepText }[]` |
|
|
88
|
+
| Generate a stub | `buildStepStub(stepText, keyword)` | Python source `string` |
|
|
89
|
+
| Browse steps | `browseSteps(steps, { mode, filter, group })` | `StepBrowserNode[]` — `group`, `step` or `message` |
|
|
90
|
+
|
|
91
|
+
`lintDocument` takes `LintConfig` — `{ allowedTags?, phrasingRules? }` — as plain
|
|
92
|
+
data. Individual rules are exported too, if a host wants to run a subset.
|
|
93
|
+
|
|
94
|
+
**Completion carries snippet syntax.** `CompletionEntry.insertText` may contain
|
|
95
|
+
LSP snippet syntax (`${1:name}`, `${1|a,b|}`) when `snippet` is true. A host that
|
|
96
|
+
cannot render snippets should insert the text literally; it remains valid.
|
|
97
|
+
|
|
98
|
+
## Step index
|
|
99
|
+
|
|
100
|
+
`StepCache` holds the step definitions discovered from the Python side.
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
const cache = new StepCache();
|
|
104
|
+
cache.update(stepDefinitions); // from a discovery run
|
|
105
|
+
cache.updateDistributed(fromPackages); // from third-party step libraries
|
|
106
|
+
cache.updateUsageCounts(featureLines); // ranks completions by use
|
|
107
|
+
|
|
108
|
+
cache.matchPattern(stepText); // → StepDefinition | null
|
|
109
|
+
cache.paramPositionAt(line, column); // → the parameter under a cursor
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Populate it before offering completion, hover, definition or references — all of
|
|
113
|
+
them read from it.
|
|
114
|
+
|
|
115
|
+
## Running pytest
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
const { discovery, stepDefinitions } = await discoverTests({
|
|
119
|
+
cwd, interpreterPath, pytestArgs, log, signal,
|
|
120
|
+
});
|
|
121
|
+
const payloads = await runTests({ …same, testIds });
|
|
122
|
+
const diagnostics = await runBddLint({ …same, featureFilePath });
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
`PytestOptions` is entirely plain: a resolved `cwd`, an interpreter path, extra
|
|
126
|
+
arguments, an optional `log` callback for subprocess stderr, and an optional
|
|
127
|
+
`AbortSignal`. Core creates the pipe, spawns the interpreter, and parses frames.
|
|
128
|
+
The host resolves the interpreter and the working directory — those are policy
|
|
129
|
+
decisions only a host can make.
|
|
130
|
+
|
|
131
|
+
`interpreterPath` is a plain string. It does **not** require the VS Code Python
|
|
132
|
+
extension; anything that can run `-m pytest` will do.
|
|
133
|
+
|
|
134
|
+
## Displaying results
|
|
135
|
+
|
|
136
|
+
Two steps, deliberately separate so neither needs an editor.
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
const { roots, idToRunId } = buildTestTree(discovery.tests);
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
`roots` is a plain tree of `TreeNode` — `{ id, label, uri, canResolveChildren,
|
|
143
|
+
tags, description?, range?, children }`. Materialise each node as whatever your
|
|
144
|
+
editor displays, resolving `uri` per the descriptor rules above. Keep your own
|
|
145
|
+
map from node id to your item; `idToRunId` maps node ids to pytest run ids.
|
|
146
|
+
|
|
147
|
+
```ts
|
|
148
|
+
for (const decision of resolveExecutionOutcomes(payload, outcomeMapping)) {
|
|
149
|
+
const item = yourIndex.get(decision.runId); // may be absent — skip it
|
|
150
|
+
…
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Each `OutcomeDecision` is `{ runId, state, message?, label }` where `state` is
|
|
155
|
+
one of `passed | failed | errored | skipped | enqueued`.
|
|
156
|
+
|
|
157
|
+
Two things that are easy to get wrong:
|
|
158
|
+
|
|
159
|
+
- **Decisions are produced for every run id in the payload**, including tests
|
|
160
|
+
outside your tree. Skip ids you do not recognise rather than treating them as
|
|
161
|
+
errors.
|
|
162
|
+
- **`label` tells you what to do with the waiting marker** — `'strip'`,
|
|
163
|
+
`'prefix'` or `'none'` — using the exported `WAITING_PREFIX`. Do not derive it
|
|
164
|
+
from `state`: a plain `success` deliberately leaves the label untouched, so an
|
|
165
|
+
item previously marked waiting keeps its marker. That is existing behaviour,
|
|
166
|
+
preserved on purpose.
|
|
167
|
+
|
|
168
|
+
## What a host must provide
|
|
169
|
+
|
|
170
|
+
Core supplies no policy. A complete host is responsible for:
|
|
171
|
+
|
|
172
|
+
1. **An interpreter path** — however it likes: a setting, a discovered virtualenv, `python` on `PATH`.
|
|
173
|
+
2. **A working directory** for pytest, resolved from whatever settings it exposes.
|
|
174
|
+
3. **Configuration** — `allowedTags` and `phrasingRules` for linting, an outcome mapping for custom statuses, extra pytest arguments.
|
|
175
|
+
4. **Registration** — wiring core's results into its own editor: completion, hover, definition, references, code actions, formatting, symbols, semantic tokens, diagnostics, a test tree, and a step browser, as far as it supports them. All are optional and independent.
|
|
176
|
+
5. **Re-discovery triggers** — watching `.feature` files and step definition files, and re-running discovery when they change.
|
|
177
|
+
6. **Cancellation**, if it has a notion of it, bridged to `AbortSignal`.
|
|
178
|
+
|
|
179
|
+
None of this is required all at once. A host that only lints `.feature` files
|
|
180
|
+
needs `parseSource` and `lintDocument` and nothing else — that is the example at
|
|
181
|
+
the top of this file, and it is the quickest way to confirm an installation works.
|
|
182
|
+
|
|
183
|
+
## Versioning
|
|
184
|
+
|
|
185
|
+
Core and `pytest-big-dill` share the wire protocol in `protocol/types.ts`. Pin
|
|
186
|
+
both to compatible versions: a mismatch fails **silently** — an empty test tree,
|
|
187
|
+
or results attaching to no node — rather than erroring.
|
|
188
|
+
|
|
189
|
+
The exported protocol types are the contract. Treat additions as compatible and
|
|
190
|
+
any change to an existing field as breaking.
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
## Status
|
|
195
|
+
|
|
196
|
+
Extracted from the extension incrementally. The API is still settling and may
|
|
197
|
+
change before 1.0; the protocol types shared with `pytest-big-dill` are the part
|
|
198
|
+
most worth pinning.
|
|
199
|
+
|
|
200
|
+
## License
|
|
201
|
+
|
|
202
|
+
MIT — see [`LICENSE`](./LICENSE).
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { StepCache } from '../steps/stepCache';
|
|
2
|
+
export type CompletionKind = 'step' | 'value';
|
|
3
|
+
export interface CompletionEntry {
|
|
4
|
+
label: string;
|
|
5
|
+
kind: CompletionKind;
|
|
6
|
+
/** LSP snippet syntax when `snippet` is true, literal text otherwise. */
|
|
7
|
+
insertText: string;
|
|
8
|
+
snippet: boolean;
|
|
9
|
+
detail?: string;
|
|
10
|
+
sortText?: string;
|
|
11
|
+
}
|
|
12
|
+
export type KeywordAndText = {
|
|
13
|
+
keyword: string;
|
|
14
|
+
text: string;
|
|
15
|
+
};
|
|
16
|
+
/** Extract the Gherkin keyword and the step text from a raw line, or null. */
|
|
17
|
+
export declare function extractStepText(line: string): KeywordAndText | null;
|
|
18
|
+
/**
|
|
19
|
+
* Step patterns matching *partialText*, most-used first.
|
|
20
|
+
*
|
|
21
|
+
* Matches when the normalised pattern starts with the partial text, or when the
|
|
22
|
+
* partial text matches the pattern with placeholders treated as wildcards — the
|
|
23
|
+
* latter covers a user who has already typed values into parameter positions.
|
|
24
|
+
*/
|
|
25
|
+
export declare function completeStepPatterns(partialText: string, keyword: string, cache: StepCache): CompletionEntry[];
|
|
26
|
+
/**
|
|
27
|
+
* Suggested values for the parameter the cursor sits in, if any.
|
|
28
|
+
*
|
|
29
|
+
* Three attempts, because the cursor is often mid-value where the line does not
|
|
30
|
+
* yet match a pattern: the text as-is, then trimmed, then with a dummy character
|
|
31
|
+
* appended so the pattern can match around the cursor.
|
|
32
|
+
*/
|
|
33
|
+
export declare function completeParameterValues(lineText: string, column: number, cache: StepCache): CompletionEntry[];
|
|
34
|
+
/**
|
|
35
|
+
* Complete at a cursor position on a raw line.
|
|
36
|
+
*
|
|
37
|
+
* Parameter values win when available; step patterns are the fallback.
|
|
38
|
+
*/
|
|
39
|
+
export declare function completeAt(line: string, column: number, cache: StepCache): CompletionEntry[];
|
|
40
|
+
//# sourceMappingURL=complete.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"complete.d.ts","sourceRoot":"","sources":["../../src/completion/complete.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAMpD,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,OAAO,CAAC;AAE9C,MAAM,WAAW,eAAe;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,cAAc,CAAC;IACrB,yEAAyE;IACzE,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,cAAc,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/D,8EAA8E;AAC9E,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAInE;AA0CD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAChC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,SAAS,GACjB,eAAe,EAAE,CAuBnB;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACnC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,SAAS,GACjB,eAAe,EAAE,CAkBnB;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,eAAe,EAAE,CAY5F"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) 2026 Nigel O'Keefe. All rights reserved.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
//
|
|
5
|
+
// Completion for step lines in a .feature file.
|
|
6
|
+
//
|
|
7
|
+
// Two levels, tried in order:
|
|
8
|
+
// 1. parameter values — the cursor sits inside a value position of a known step
|
|
9
|
+
// 2. step patterns — the text so far is a prefix of one or more known steps
|
|
10
|
+
//
|
|
11
|
+
// Results are plain entries. `insertText` may carry LSP snippet syntax when
|
|
12
|
+
// `snippet` is set; that format is a protocol convention rather than a
|
|
13
|
+
// particular editor's, so hosts can pass it straight through.
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.extractStepText = extractStepText;
|
|
16
|
+
exports.completeStepPatterns = completeStepPatterns;
|
|
17
|
+
exports.completeParameterValues = completeParameterValues;
|
|
18
|
+
exports.completeAt = completeAt;
|
|
19
|
+
const KEYWORD_RE = /^\s*(Given|When|Then|And|But|\*)\s+/i;
|
|
20
|
+
const PARAM_RE = /\{(\w+)(?::[^}]{1,200})?\}/g;
|
|
21
|
+
/** Extract the Gherkin keyword and the step text from a raw line, or null. */
|
|
22
|
+
function extractStepText(line) {
|
|
23
|
+
const m = KEYWORD_RE.exec(line);
|
|
24
|
+
if (!m)
|
|
25
|
+
return null;
|
|
26
|
+
return { keyword: m[1].toLowerCase(), text: line.slice(m[0].length) };
|
|
27
|
+
}
|
|
28
|
+
/** Strip type annotations from parameter placeholders: {name:Type} → {name}. */
|
|
29
|
+
function normalizePattern(pattern) {
|
|
30
|
+
return pattern.replace(PARAM_RE, (_match, name) => `{${name}}`);
|
|
31
|
+
}
|
|
32
|
+
/** Escape for a snippet choice list, where , | \ $ } are special. */
|
|
33
|
+
function escapeChoice(v) {
|
|
34
|
+
return v.replace(/[\\|,$}]/g, '\\$&');
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Convert a step pattern to snippet syntax.
|
|
38
|
+
*
|
|
39
|
+
* Parameters with suggested values become choice tab stops (${1|NSW,VIC|}) so a
|
|
40
|
+
* host can offer the values inline; the rest become plain placeholders
|
|
41
|
+
* (${1:name}).
|
|
42
|
+
*/
|
|
43
|
+
function patternToSnippet(pattern, parameters) {
|
|
44
|
+
let i = 0;
|
|
45
|
+
let paramIdx = 0;
|
|
46
|
+
return pattern.replace(PARAM_RE, (_match, name) => {
|
|
47
|
+
const param = parameters[paramIdx++];
|
|
48
|
+
const values = param?.suggested_values ?? [];
|
|
49
|
+
if (values.length > 0) {
|
|
50
|
+
return `\${${++i}|${values.map(escapeChoice).join(',')}|}`;
|
|
51
|
+
}
|
|
52
|
+
return `\${${++i}:${name}}`;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Prefix-match regex for a step pattern: literals escaped, {param} placeholders
|
|
57
|
+
* widened to `.*`, and no end anchor, so partially-typed steps still match.
|
|
58
|
+
*/
|
|
59
|
+
function buildPrefixRegex(pattern) {
|
|
60
|
+
const escaped = pattern.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
61
|
+
const withWildcards = escaped.replace(/\\\{[^}]{0,200}\\\}/g, '.*');
|
|
62
|
+
return new RegExp(`^${withWildcards}`, 'i');
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Step patterns matching *partialText*, most-used first.
|
|
66
|
+
*
|
|
67
|
+
* Matches when the normalised pattern starts with the partial text, or when the
|
|
68
|
+
* partial text matches the pattern with placeholders treated as wildcards — the
|
|
69
|
+
* latter covers a user who has already typed values into parameter positions.
|
|
70
|
+
*/
|
|
71
|
+
function completeStepPatterns(partialText, keyword, cache) {
|
|
72
|
+
const lower = partialText.toLowerCase();
|
|
73
|
+
const matched = cache
|
|
74
|
+
.getForKeyword(keyword)
|
|
75
|
+
.filter((s) => normalizePattern(s.pattern).toLowerCase().startsWith(lower) ||
|
|
76
|
+
buildPrefixRegex(s.pattern).test(partialText));
|
|
77
|
+
matched.sort((a, b) => (b.usage_count ?? 0) - (a.usage_count ?? 0));
|
|
78
|
+
return matched.map((s, index) => {
|
|
79
|
+
const snippet = patternToSnippet(s.pattern, s.parameters ?? []);
|
|
80
|
+
const isSnippet = snippet !== s.pattern;
|
|
81
|
+
return {
|
|
82
|
+
label: normalizePattern(s.pattern),
|
|
83
|
+
kind: 'step',
|
|
84
|
+
insertText: isSnippet ? snippet : s.pattern,
|
|
85
|
+
snippet: isSnippet,
|
|
86
|
+
detail: `${s.keyword} step`,
|
|
87
|
+
// Pre-ranked, so hosts that sort alphabetically preserve usage order.
|
|
88
|
+
sortText: String(index).padStart(6, '0'),
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Suggested values for the parameter the cursor sits in, if any.
|
|
94
|
+
*
|
|
95
|
+
* Three attempts, because the cursor is often mid-value where the line does not
|
|
96
|
+
* yet match a pattern: the text as-is, then trimmed, then with a dummy character
|
|
97
|
+
* appended so the pattern can match around the cursor.
|
|
98
|
+
*/
|
|
99
|
+
function completeParameterValues(lineText, column, cache) {
|
|
100
|
+
let pos = cache.paramPositionAt(lineText, column);
|
|
101
|
+
if (!pos) {
|
|
102
|
+
const textUpToCursor = lineText.slice(0, column);
|
|
103
|
+
pos = cache.paramPositionAt(textUpToCursor.trimEnd(), column);
|
|
104
|
+
if (!pos) {
|
|
105
|
+
pos = cache.paramPositionAt(`${textUpToCursor}X`, column);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (!pos)
|
|
109
|
+
return [];
|
|
110
|
+
return pos.parameter.suggested_values.map((v) => ({
|
|
111
|
+
label: v,
|
|
112
|
+
kind: 'value',
|
|
113
|
+
insertText: v,
|
|
114
|
+
snippet: false,
|
|
115
|
+
}));
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Complete at a cursor position on a raw line.
|
|
119
|
+
*
|
|
120
|
+
* Parameter values win when available; step patterns are the fallback.
|
|
121
|
+
*/
|
|
122
|
+
function completeAt(line, column, cache) {
|
|
123
|
+
const stepText = extractStepText(line);
|
|
124
|
+
if (!stepText)
|
|
125
|
+
return [];
|
|
126
|
+
// indexOf('') is 0 for any string, so an empty step text would wrongly anchor
|
|
127
|
+
// at the start of the line. Nothing typed yet means the step starts here.
|
|
128
|
+
const stepTextStart = stepText.text ? line.indexOf(stepText.text) : column;
|
|
129
|
+
const values = completeParameterValues(stepText.text, column - stepTextStart, cache);
|
|
130
|
+
if (values.length > 0)
|
|
131
|
+
return values;
|
|
132
|
+
return completeStepPatterns(line.slice(stepTextStart, column), stepText.keyword, cache);
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=complete.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"complete.js","sourceRoot":"","sources":["../../src/completion/complete.ts"],"names":[],"mappings":";AAAA,yDAAyD;AACzD,kCAAkC;AAClC,EAAE;AACF,gDAAgD;AAChD,EAAE;AACF,8BAA8B;AAC9B,kFAAkF;AAClF,iFAAiF;AACjF,EAAE;AACF,4EAA4E;AAC5E,uEAAuE;AACvE,8DAA8D;;AAuB9D,0CAIC;AAiDD,oDA2BC;AASD,0DAsBC;AAOD,gCAYC;AApJD,MAAM,UAAU,GAAG,sCAAsC,CAAC;AAC1D,MAAM,QAAQ,GAAG,6BAA6B,CAAC;AAgB/C,8EAA8E;AAC9E,SAAgB,eAAe,CAAC,IAAY;IACxC,MAAM,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChC,IAAI,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IACpB,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;AAC1E,CAAC;AAED,gFAAgF;AAChF,SAAS,gBAAgB,CAAC,OAAe;IACrC,OAAO,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,IAA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AE,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AAC5F,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { GherkinDocument } from '@cucumber/messages';
|
|
2
|
+
export interface TextEditEntry {
|
|
3
|
+
startLine: number;
|
|
4
|
+
newText: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function formatTables(doc: GherkinDocument, lines: string[]): TextEditEntry[];
|
|
7
|
+
//# sourceMappingURL=tables.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tables.d.ts","sourceRoot":"","sources":["../../src/format/tables.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,eAAe,EAAY,MAAM,oBAAoB,CAAC;AAEpE,MAAM,WAAW,aAAa;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACnB;AAyED,wBAAgB,YAAY,CAAC,GAAG,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,aAAa,EAAE,CAoBnF"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) 2026 Nigel O'Keefe. All rights reserved.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
//
|
|
5
|
+
// Computes table-alignment edits for a Gherkin document.
|
|
6
|
+
//
|
|
7
|
+
// Returns plain line replacements; turning them into editor edits is the host's
|
|
8
|
+
// job. Datatables are left-aligned throughout; Examples tables right-align
|
|
9
|
+
// columns whose body cells are all numeric, with headers always left-aligned.
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.formatTables = formatTables;
|
|
12
|
+
function isNumeric(v) {
|
|
13
|
+
return /^-?\d+(\.\d+)?$/.test(v.trim());
|
|
14
|
+
}
|
|
15
|
+
function indent(lineText) {
|
|
16
|
+
return lineText.match(/^(\s*)/)?.[1] ?? '';
|
|
17
|
+
}
|
|
18
|
+
function formatRows(rows, lines, rightAlignNumericCols, headerRows = []) {
|
|
19
|
+
if (rows.length === 0)
|
|
20
|
+
return [];
|
|
21
|
+
const colCount = rows[0].cells.length;
|
|
22
|
+
const widths = Array(colCount).fill(0);
|
|
23
|
+
const allNumeric = Array(colCount).fill(true);
|
|
24
|
+
const allRows = [...headerRows, ...rows];
|
|
25
|
+
for (const row of allRows) {
|
|
26
|
+
row.cells.forEach((cell, i) => {
|
|
27
|
+
widths[i] = Math.max(widths[i], cell.value.length);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
// Determine which columns are purely numeric (checking body rows only; headers are text labels)
|
|
31
|
+
// A column is numeric only if all body values are numeric (empty cells are skipped)
|
|
32
|
+
// We do NOT count header rows in allNumeric — the header is always left-aligned regardless
|
|
33
|
+
// But we DO disqualify a column from right-alignment if the header value is numeric too
|
|
34
|
+
// (since column names like "n" are non-numeric text, only pure-numeric body cols are right-aligned)
|
|
35
|
+
for (const row of rows) {
|
|
36
|
+
row.cells.forEach((cell, i) => {
|
|
37
|
+
if (cell.value !== '' && !isNumeric(cell.value))
|
|
38
|
+
allNumeric[i] = false;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
// Also check header cells — if the header is non-empty, it's always non-numeric text
|
|
42
|
+
// so columns with text headers can still be right-aligned if body is all numeric
|
|
43
|
+
// (the header itself is left-aligned via the isHeader flag below)
|
|
44
|
+
const edits = [];
|
|
45
|
+
const formatRow = (row, isHeader) => {
|
|
46
|
+
const lineIndex = row.location.line - 1;
|
|
47
|
+
const original = lines[lineIndex] ?? '';
|
|
48
|
+
const pad = indent(original);
|
|
49
|
+
const cells = row.cells.map((cell, i) => {
|
|
50
|
+
// Header cells of numeric columns are left-aligned
|
|
51
|
+
if (rightAlignNumericCols && allNumeric[i] && !isHeader) {
|
|
52
|
+
return cell.value.padStart(widths[i]);
|
|
53
|
+
}
|
|
54
|
+
return cell.value.padEnd(widths[i]);
|
|
55
|
+
});
|
|
56
|
+
const newText = `${pad}| ${cells.join(' | ')} |`;
|
|
57
|
+
if (newText !== original) {
|
|
58
|
+
edits.push({ startLine: lineIndex, newText });
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
for (const row of headerRows) {
|
|
62
|
+
formatRow(row, true);
|
|
63
|
+
}
|
|
64
|
+
for (const row of rows) {
|
|
65
|
+
formatRow(row, false);
|
|
66
|
+
}
|
|
67
|
+
return edits;
|
|
68
|
+
}
|
|
69
|
+
function formatTables(doc, lines) {
|
|
70
|
+
const edits = [];
|
|
71
|
+
for (const child of doc.feature?.children ?? []) {
|
|
72
|
+
const scenario = child.scenario;
|
|
73
|
+
if (!scenario)
|
|
74
|
+
continue;
|
|
75
|
+
for (const step of scenario.steps) {
|
|
76
|
+
if (step.dataTable) {
|
|
77
|
+
edits.push(...formatRows(step.dataTable.rows, lines, false));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
for (const examples of scenario.examples) {
|
|
81
|
+
const headerRows = examples.tableHeader ? [examples.tableHeader] : [];
|
|
82
|
+
edits.push(...formatRows(examples.tableBody, lines, true, headerRows));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return edits;
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=tables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tables.js","sourceRoot":"","sources":["../../src/format/tables.ts"],"names":[],"mappings":";AAAA,yDAAyD;AACzD,kCAAkC;AAClC,EAAE;AACF,yDAAyD;AACzD,EAAE;AACF,gFAAgF;AAChF,2EAA2E;AAC3E,8EAA8E;;AAgF9E,oCAoBC;AA3FD,SAAS,SAAS,CAAC,CAAS;IACxB,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;AAC5C,CAAC;AAED,SAAS,MAAM,CAAC,QAAgB;IAC5B,OAAO,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;A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CAAC;IAElC,KAAK,MAAM,KAAK,IAAI,GAAG,CAAC,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,CAAC;QAC9C,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAChC,IAAI,CAAC,QAAQ;YAAE,SAAS;QAExB,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;YAChC,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;gBACjB,KAAK,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;YACjE,CAAC;QACL,CAAC;QAED,KAAK,MAAM,QAAQ,IAAI,QAAQ,CAAC,QAAQ,EAAE,CAAC;YACvC,MAAM,UAAU,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACtE,KAAK,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,QAAQ,CAAC,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC;QAC3E,CAAC;IACL,CAAC;IAED,OAAO,KAAK,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { GherkinDocument } from '@cucumber/messages';
|
|
2
|
+
export interface ParseResult {
|
|
3
|
+
doc: GherkinDocument | null;
|
|
4
|
+
errors: string[];
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* The minimum a host must supply to be cacheable: a stable identity, a version
|
|
8
|
+
* that changes when the text changes, and the text itself.
|
|
9
|
+
*
|
|
10
|
+
* VS Code's TextDocument satisfies this structurally, which is why the cache
|
|
11
|
+
* previously took `Pick<vscode.TextDocument, …>` — the coupling was never real.
|
|
12
|
+
*/
|
|
13
|
+
export interface CacheableDocument {
|
|
14
|
+
readonly uri: {
|
|
15
|
+
readonly fsPath: string;
|
|
16
|
+
};
|
|
17
|
+
readonly version: number;
|
|
18
|
+
getText(): string;
|
|
19
|
+
}
|
|
20
|
+
export declare function parseSource(source: string): ParseResult;
|
|
21
|
+
export declare class GherkinParseCache {
|
|
22
|
+
private cache;
|
|
23
|
+
parse(document: CacheableDocument): ParseResult;
|
|
24
|
+
invalidate(uri: {
|
|
25
|
+
fsPath: string;
|
|
26
|
+
}): void;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/gherkin/parser.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D,MAAM,WAAW,WAAW;IACxB,GAAG,EAAE,eAAe,GAAG,IAAI,CAAC;IAC5B,MAAM,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAC9B,QAAQ,CAAC,GAAG,EAAE;QAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,OAAO,IAAI,MAAM,CAAC;CACrB;AAKD,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,CAqBvD;AAED,qBAAa,iBAAiB;IAC1B,OAAO,CAAC,KAAK,CAA+D;IAE5E,KAAK,CAAC,QAAQ,EAAE,iBAAiB,GAAG,WAAW;IAW/C,UAAU,CAAC,GAAG,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;CAG5C"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) 2026 Nigel O'Keefe. All rights reserved.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.GherkinParseCache = void 0;
|
|
6
|
+
exports.parseSource = parseSource;
|
|
7
|
+
const gherkin_1 = require("@cucumber/gherkin");
|
|
8
|
+
const messages_1 = require("@cucumber/messages");
|
|
9
|
+
let _counter = 0;
|
|
10
|
+
const newId = () => String(_counter++);
|
|
11
|
+
function parseSource(source) {
|
|
12
|
+
const errors = [];
|
|
13
|
+
let doc = null;
|
|
14
|
+
const envelopes = (0, gherkin_1.generateMessages)(source, 'anonymous.feature', messages_1.SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN, { newId, includeSource: false, includeGherkinDocument: true, includePickles: false });
|
|
15
|
+
for (const envelope of envelopes) {
|
|
16
|
+
if (envelope.gherkinDocument) {
|
|
17
|
+
doc = envelope.gherkinDocument;
|
|
18
|
+
}
|
|
19
|
+
if (envelope.parseError) {
|
|
20
|
+
errors.push(envelope.parseError.message ?? 'Parse error');
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return { doc, errors };
|
|
24
|
+
}
|
|
25
|
+
class GherkinParseCache {
|
|
26
|
+
constructor() {
|
|
27
|
+
this.cache = new Map();
|
|
28
|
+
}
|
|
29
|
+
parse(document) {
|
|
30
|
+
const key = document.uri.fsPath;
|
|
31
|
+
const cached = this.cache.get(key);
|
|
32
|
+
if (cached?.version === document.version) {
|
|
33
|
+
return cached.result;
|
|
34
|
+
}
|
|
35
|
+
const result = parseSource(document.getText());
|
|
36
|
+
this.cache.set(key, { version: document.version, result });
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
invalidate(uri) {
|
|
40
|
+
this.cache.delete(uri.fsPath);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.GherkinParseCache = GherkinParseCache;
|
|
44
|
+
//# sourceMappingURL=parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../src/gherkin/parser.ts"],"names":[],"mappings":";AAAA,yDAAyD;AACzD,kCAAkC;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AAW,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;QAC/C,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;QAC3D,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,UAAU,CAAC,GAAuB;QAC9B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;CACJ;AAjBD,8CAiBC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @nokout/big-dill-core — the headless engine behind Big Dill.
|
|
3
|
+
*
|
|
4
|
+
* Nothing exported here depends on an editor. Results are plain data; mapping
|
|
5
|
+
* them onto editor types is the host's responsibility. See the "Building a
|
|
6
|
+
* host" section of README.md for what a host must provide.
|
|
7
|
+
*/
|
|
8
|
+
export { parseSource, GherkinParseCache, type ParseResult, type CacheableDocument, } from './gherkin/parser';
|
|
9
|
+
export { lintDocument, graduatePhrasingSeverity, RULES, checkEmptyComments, checkDuplicateExampleRows, checkOversizedExampleTable, checkOutlineMissingExamples, checkEmptyExamplesBody, checkTagAllowlist, checkScenarioShouldBeOutline, checkScenarioHasExamplesNotOutline, checkUndefinedExampleColumn, checkUnusedExampleColumn, checkDuplicateScenarioName, checkDuplicateExamplesColumn, checkEmptyScenario, checkOutlineSingleRow, checkPhrasingRules, type DiagnosticEntry, type PhrasingRule, type LintConfig, } from './lint/rules';
|
|
10
|
+
export { completeAt, completeStepPatterns, completeParameterValues, extractStepText, type CompletionEntry, type CompletionKind, type KeywordAndText, } from './completion/complete';
|
|
11
|
+
export { buildSymbolTree, type SymbolNode, type SymbolNodeKind } from './symbols/outline';
|
|
12
|
+
export { buildTableTokens, TOKEN_TYPES, TYPE_INDEX, type TokenType, type TokenEntry, } from './tokens/semanticTokens';
|
|
13
|
+
export { formatTables, type TextEditEntry } from './format/tables';
|
|
14
|
+
export { renderStepMarkdown } from './steps/documentation';
|
|
15
|
+
export { buildStepStub, patternToFunctionName } from './steps/stubs';
|
|
16
|
+
export { findReferencesInLines } from './steps/references';
|
|
17
|
+
export { findUnimplementedSteps, type UnimplementedStep } from './steps/unimplemented';
|
|
18
|
+
export { browseSteps, filterSteps, groupLabels, stepsInGroup, UNKNOWN_FILE, NO_TYPE, UNTAGGED, type GroupingMode, type StepBrowserNode, type BrowseOptions, } from './steps/browser';
|
|
19
|
+
export { StepCache, patternToRegex, type LineMatch, type ParamAtPosition } from './steps/stepCache';
|
|
20
|
+
export { createIpcServer, type IIpcServer, type IpcMessageHandler } from './ipc/server';
|
|
21
|
+
export { buildTestTree, type TreeNode, type TreeNodeUri, type TreeNodeRange, type BuiltTree, } from './tree/builder';
|
|
22
|
+
export { resolveExecutionOutcomes, WAITING_PREFIX, type RunState, type OutcomeDecision, } from './results/outcomes';
|
|
23
|
+
export { discoverTests, runTests, runBddLint, type PytestOptions, type DiscoveryResult, } from './pytest/runner';
|
|
24
|
+
export type { DiscoveredTestType, DiscoveredTestCommon, DiscoveredTestItem, DiscoveredTestNode, DiscoveredTestPayload, ExecutionTestPayload, StepParameter, StepDefinition, StepDefinitionPayload, LintDiagnosticEntry, LintDiagnosticPayload, } from './protocol/types';
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AAGH,OAAO,EACH,WAAW,EACX,iBAAiB,EACjB,KAAK,WAAW,EAChB,KAAK,iBAAiB,GACzB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACH,YAAY,EACZ,wBAAwB,EACxB,KAAK,EACL,kBAAkB,EAClB,yBAAyB,EACzB,0BAA0B,EAC1B,2BAA2B,EAC3B,sBAAsB,EACtB,iBAAiB,EACjB,4BAA4B,EAC5B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