Support OCaml, Erlang and F# properly - #2138
Merged
Merged
Conversation
Erlang and F# get test-at-point rules, both written against the real grammars rather than guessed at: I installed the Erlang grammar and parsed sample sources for both, which is how the F# rule got right that the attributes are a positional sibling of the definition rather than a field of it. That also turned up a latent trap in the Rust and Java rules I added earlier: they tested for an attribute with the symbol-boundary operators, which consult the syntax table. Under it the angle brackets of F#'s [<Fact>] count as part of the symbol, so the boundary never matches. All three now share one syntax-independent check. OCaml gets no test-at-point rule on purpose. Its tests are ordinary values handed to Alcotest or OUnit, with nothing in the syntax marking one out, so any rule would be guesswork. Its project type gets the attention instead - as do Erlang's, plus a new erlang-mk type.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Test-at-point rules for
erlang-ts-modeandfsharp-ts-mode, plus fullerproject types for all three languages.
Both rules are written against the real grammars, not inferred: the F#
grammar was already installed here, and I installed the Erlang one and parsed
sample sources for both. That's how the F# rule got right that
attributesis apositional sibling of the definition under the enclosing
declaration_expression, rather than a field of it - my first attempt usedtreesit-node-child-by-field-nameand silently matched nothing.It also turned up a latent trap in the Rust and Java rules from #2136. Both
tested for their attribute with
\_</\_>, which consult the buffer's syntaxtable - and under it the
<and>of F#'s[<Fact>]count as part of thesymbol, so the boundary never matches. It happened to work for
#[test]and@Test. All three now share one syntax-independent check, with specs for thebracket forms and for not matching
[<Factory>]when looking forFact.Erlang addresses a test as
module:functionand an Erlang module is named afterits file, so the module comes from the file name. F# unwraps a name written
between double backticks, which is how F# tests usually get readable names, and
filters with
FullyQualifiedName~so the filter works without the namespace.OCaml gets no test-at-point rule, deliberately. Its tests are ordinary values
handed to Alcotest or OUnit - nothing in the syntax marks one out, and
dune runtestruns the lot - so any rule would be guesswork dressed up as support.The effort went into its project type instead:
dune exec,dune install,dune build @installand the source/test directories.rebargained the sametreatment, and
erlang-mkis a new type for the other common Erlang build tool.