Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elm: minor changes #3320

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Units/parser-elm.r/elm-ports.d/args.ctags
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
--sort=no
--extras=+r
--fields=+r
--fields=+r{access}
2 changes: 1 addition & 1 deletion Units/parser-elm.r/elm-ports.d/expected.tags
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Main input.elm /^port module Main exposing (..)$/;" m roles:def
Main input.elm /^port module Main exposing (..)$/;" m access:port roles:def
outgoing input.elm /^port outgoing : Enc.Value -> Cmd msg$/;" p module:Main typeref:typename:Enc.Value -> Cmd msg roles:def
incoming input.elm /^port incoming : (Enc.Value -> msg) -> Sub msg$/;" p module:Main typeref:typename:(Enc.Value -> msg) -> Sub msg roles:def
23 changes: 22 additions & 1 deletion docs/man/ctags-lang-elm.7.rst
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,39 @@ signature field. They are not really function signatures, but
it's the closest concept available in ctags.
Use "--fields=+S".

"input.elm"

.. code-block:: Elm

funcA a1 a2 =
a1 + a2

"output.tags"
with "--sort=no --extras=+r --fields=+rS"
with "--options=NONE -o - --sort=no --extras=+r --fields=+rS input.elm"

.. code-block:: tags

funcA input.elm /^funcA a1 a2 =$/;" f signature:a1 a2 roles:def

Module where ports are defined
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If a module is modified with "port", the parser fills the ``access``
field of the tag for the module with "port".

"input.elm"

.. code-block:: Elm

port module Main exposing (..)

"output.tags"
with "--options=NONE -o - --sort=no --fields=+a input.elm"

.. code-block:: tags

Main input.elm /^port module Main exposing (..)$/;" m access:port

KNOWN LIMITATIONS
-----------------
The ctags signature field is used for function parameter lists, even
Expand Down
23 changes: 22 additions & 1 deletion man/ctags-lang-elm.7.rst.in
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,39 @@ signature field. They are not really function signatures, but
it's the closest concept available in ctags.
Use "--fields=+S".

"input.elm"

.. code-block:: Elm

funcA a1 a2 =
a1 + a2

"output.tags"
with "--sort=no --extras=+r --fields=+rS"
with "--options=NONE -o - --sort=no --extras=+r --fields=+rS input.elm"

.. code-block:: tags

funcA input.elm /^funcA a1 a2 =$/;" f signature:a1 a2 roles:def

Module where ports are defined
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If a module is modified with "port", the parser fills the ``access``
field of the tag for the module with "port".

"input.elm"

.. code-block:: Elm

port module Main exposing (..)

"output.tags"
with "--options=NONE -o - --sort=no --fields=+a input.elm"

.. code-block:: tags

Main input.elm /^port module Main exposing (..)$/;" m access:port

KNOWN LIMITATIONS
-----------------
The ctags signature field is used for function parameter lists, even
Expand Down
6 changes: 4 additions & 2 deletions peg/elm.peg
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,10 @@ topLevelStatement <-
# to tag them.

moduleDeclaration <-
('port' _1_)? 'module' _1_ <dottedIdentifier> _1_ 'exposing' _0_ '(' exposedList ')' EOS {
elm_module_scope_index = makeElmTagSettingScope(auxil, $1, $1s, K_MODULE, ROLE_DEFINITION_INDEX);
(<'port'> _1_)? 'module' _1_ <dottedIdentifier> _1_ 'exposing' _0_ '(' exposedList ')' EOS {
elm_module_scope_index = makeElmTagSettingScope(auxil, $2, $2s, K_MODULE, ROLE_DEFINITION_INDEX);
if (*$1 != '\0')
addElmAccess(elm_module_scope_index, "port");
}

exposedList <- _0_ exposedItem _0_ (',' _0_ exposedList )*
Expand Down
8 changes: 8 additions & 0 deletions peg/elm_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ static void addElmTypeRef(int scope_index, const char *sig)
}
}

static void addElmAccess(int scope_index, const char *access_)
{
tagEntryInfo *e = getEntryInCorkQueue (scope_index);

if (e)
e->extensionFields.access = eStrdup (access_);
}

/* There are several steps to making the type of constructors within
* a custom type:
* 1. Initialise the fields when we encounter the custom type declaration.
Expand Down
1 change: 1 addition & 0 deletions peg/elm_pre.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ static int makeElmTag (struct parserCtx *auxil, const char *name, long offset, i
static int makeElmTagSettingScope (struct parserCtx *auxil, const char *name, long offset, int kind, int role);
static void addElmSignature(int scope_index, const char *sig);
static void addElmTypeRef(int scope_index, const char *str);
static void addElmAccess(int scope_index, const char *access);
static void initElmConstructorFields (struct parserCtx *auxil, const char *name);
static void initElmConstructorSubtypeFields (struct parserCtx *auxil);
static void addElmConstructorSubtype (struct parserCtx *auxil, const char *name);
Expand Down