diff --git a/Units/parser-elm.r/elm-ports.d/args.ctags b/Units/parser-elm.r/elm-ports.d/args.ctags index 41f6dbed62..beb7b61769 100644 --- a/Units/parser-elm.r/elm-ports.d/args.ctags +++ b/Units/parser-elm.r/elm-ports.d/args.ctags @@ -1,3 +1,3 @@ --sort=no --extras=+r ---fields=+r +--fields=+r{access} diff --git a/Units/parser-elm.r/elm-ports.d/expected.tags b/Units/parser-elm.r/elm-ports.d/expected.tags index e101ed4dc0..002e222047 100644 --- a/Units/parser-elm.r/elm-ports.d/expected.tags +++ b/Units/parser-elm.r/elm-ports.d/expected.tags @@ -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 diff --git a/docs/man/ctags-lang-elm.7.rst b/docs/man/ctags-lang-elm.7.rst index 5a9b5845c9..a1c5769e1c 100644 --- a/docs/man/ctags-lang-elm.7.rst +++ b/docs/man/ctags-lang-elm.7.rst @@ -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 diff --git a/man/ctags-lang-elm.7.rst.in b/man/ctags-lang-elm.7.rst.in index d9fbfa786d..0d236aa041 100644 --- a/man/ctags-lang-elm.7.rst.in +++ b/man/ctags-lang-elm.7.rst.in @@ -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 diff --git a/peg/elm.peg b/peg/elm.peg index bff2a618a9..53ef553f15 100644 --- a/peg/elm.peg +++ b/peg/elm.peg @@ -130,8 +130,10 @@ topLevelStatement <- # to tag them. moduleDeclaration <- - ('port' _1_)? 'module' _1_ _1_ 'exposing' _0_ '(' exposedList ')' EOS { - elm_module_scope_index = makeElmTagSettingScope(auxil, $1, $1s, K_MODULE, ROLE_DEFINITION_INDEX); + (<'port'> _1_)? 'module' _1_ _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 )* diff --git a/peg/elm_post.h b/peg/elm_post.h index d425573071..a7bfa75abc 100644 --- a/peg/elm_post.h +++ b/peg/elm_post.h @@ -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. diff --git a/peg/elm_pre.h b/peg/elm_pre.h index eaaeac834f..d6c04b2427 100644 --- a/peg/elm_pre.h +++ b/peg/elm_pre.h @@ -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);