fix(editor): match real F∆I YAML type shape + warn on bad types
The 0.15.0 type-token coloring regex hunted for `type: <name>`,
but the F∆I YAML actually shapes types as `<fieldname>: <name>`
under `inputs:` / `outputs:` blocks. Real-world flows
(`hello.yaml`, `extract.yaml`) and module manifests (echo,
text-summarize, …) never produce the `type:` keyword unless
the operator hand-authors the long form.
Fix the regex to match an indented `KEY: VALUE` line where the
value is one of `text|json|bytes|file|number|integer`. Leading
whitespace is required so top-level keys (`name: foo`,
`version: 0.1.0`) can't false-match. This handles both
shapes — the implicit `pdf: bytes` and the explicit
`type: bytes` (used by module schema v2 inputs lists) —
because either way the pattern boils down to "key colon known
type token".
Analyzer also grows a type-token check: any inputs/outputs
field whose value isn't a known type lights up as a warning
("Unknown input type 'byes' …"), modulo `$ref` expressions
(flow outputs) and empty values (operator is mid-keystroke).
Adds `test/flow_analyzer_test.dart` with seven cases covering
empty, valid hello, unknown capability, unknown type, parse
error, version-bare matching, and the empty-installed-list
silence path.
Bumps the package to 0.15.1.
Signed-off-by: flemming-it <sf@flemming.it>
This commit is contained in:
parent
885d2db4e1
commit
911f368362
4 changed files with 162 additions and 7 deletions
|
|
@ -39,13 +39,25 @@ class FlowYamlCodeController extends CodeController {
|
|||
analyzer = FlowAnalyzer(availableCapabilities: provider);
|
||||
}
|
||||
|
||||
// Matches `type:` followed by (optional) quote + one of our
|
||||
// known type names + (optional) closing quote. The captured
|
||||
// group is the type name only — we use the parent match span
|
||||
// to locate it inside the document so we can recolour just
|
||||
// the name (not the `type:` key itself).
|
||||
// Matches an indented `key: value` line where the value is
|
||||
// one of our known type tokens. This covers both shapes the
|
||||
// F∆I YAML uses:
|
||||
//
|
||||
// inputs:
|
||||
// pdf: bytes # field-name → type
|
||||
// count: number
|
||||
//
|
||||
// inputs:
|
||||
// - name: pdf
|
||||
// type: bytes # explicit `type:` row
|
||||
//
|
||||
// We require at least one leading whitespace so top-level
|
||||
// keys (`name: foo`, `version: 0.1.0`) can't false-match.
|
||||
// The captured group is the value — we resolve its offset
|
||||
// inside the document and recolour only that token.
|
||||
static final RegExp _typeAssignment = RegExp(
|
||||
r'''\btype\s*:\s*(?:['"])?([A-Za-z_][\w-]*)(?:['"])?''',
|
||||
r'''^[ \t]+[A-Za-z_][\w-]*\s*:\s*(?:['"])?([A-Za-z_][\w-]*)(?:['"])?\s*(?:#.*)?$''',
|
||||
multiLine: true,
|
||||
);
|
||||
|
||||
@override
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue