Skip to content

Commit

Permalink
SCSS: add module parser-specific field
Browse files Browse the repository at this point in the history
Signed-off-by: Masatake YAMATO <[email protected]>
  • Loading branch information
masatake committed Jan 2, 2025
1 parent f7a7c87 commit b8b157f
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 10 deletions.
1 change: 1 addition & 0 deletions Tmain/list-fields-with-prefix.d/stdout-expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ x UCTAGSxpath no NONE s-- no -- xpath for
- UCTAGSoverline no ReStructuredText --b no -- whether using overline & underline for declaring section
- UCTAGSsectionMarker no ReStructuredText s-- no -- character used for declaring section
- UCTAGSmixin yes Ruby s-- no -- how the class or module is mixed in (mixin:HOW:MODULE)
- UCTAGSmodule yes SCSS s-- no rw the name of module behind the namespace
- UCTAGSparameter no SystemVerilog --b no -- parameter whose value can be overridden.
- UCTAGStarget yes Thrift s-- no -- the target language specified at "namespace"
- UCTAGSthrows yes Thrift s-- no -- throws list of function
Expand Down
1 change: 1 addition & 0 deletions Tmain/list-fields.d/stdout-expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ z kind no NONE s-- no r- [tags output] prepend "kind:" to k/ (or K/) field outpu
- overline no ReStructuredText --b no -- whether using overline & underline for declaring section
- sectionMarker no ReStructuredText s-- no -- character used for declaring section
- mixin yes Ruby s-- no -- how the class or module is mixed in (mixin:HOW:MODULE)
- module yes SCSS s-- no rw the name of module behind the namespace
- parameter no SystemVerilog --b no -- parameter whose value can be overridden.
- target yes Thrift s-- no -- the target language specified at "namespace"
- throws yes Thrift s-- no -- throws list of function
Expand Down
8 changes: 4 additions & 4 deletions Units/parser-scss.r/use.d/expected.tags
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
X/y input.scss /^@use "X\/y";$/;" M roles:used
y input.scss /^@use "X\/y";$/;" n roles:def
y input.scss /^@use "X\/y";$/;" n roles:def module:X/y
Z input.scss /^@use "Z";$/;" M roles:used
Z input.scss /^@use "Z";$/;" n roles:def
Z input.scss /^@use "Z";$/;" n roles:def module:Z
A input.scss /^@use "A" as NS;$/;" M roles:used
NS input.scss /^@use "A" as NS;$/;" n roles:def
NS input.scss /^@use "A" as NS;$/;" n roles:def module:A
B/ input.scss /^@use "B\/";$/;" M roles:used
C/d/e input.scss /^@use 'C\/d\/e';$/;" M roles:used
e input.scss /^@use 'C\/d\/e';$/;" n roles:def
e input.scss /^@use 'C\/d\/e';$/;" n roles:def module:C/d/e
P/q input.scss /^@use 'P\/q' as *;$/;" M roles:used
1 change: 1 addition & 0 deletions docs/man/ctags-lang-scss.7.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Change since "0.0"

* New kind ``module`` and new role ``used`` of the ``module`` kind
* New kind ``namespace``
* New field ``module``

SEE ALSO
--------
Expand Down
1 change: 1 addition & 0 deletions man/ctags-lang-scss.7.rst.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Change since "0.0"

* New kind ``module`` and new role ``used`` of the ``module`` kind
* New kind ``namespace``
* New field ``module``

SEE ALSO
--------
Expand Down
18 changes: 15 additions & 3 deletions optlib/scss.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,18 @@ static void initializeSCSSParser (const langType language)
" % module-name offset' count namespace-string\n"
" _copyinterval\n"
" dup length 0 gt {\n"
" /namespace @1 _tag _commit pop\n"
" /namespace @1 _tag _commit \\1 SCSS.module:\n"
" } {\n"
" clear\n"
" } ifelse\n"
" } {\n"
" % Extract the module name as a namespace.\n"
" \\1 /namespace @1 _tag _commit pop\n"
" \\1 /namespace @1 _tag _commit \\1 SCSS.module:\n"
" } ifelse\n"
" } {\n"
" % \"as *\" doesn't make a namespace.\n"
" \\3 (*) ne {\n"
" \\3 /namespace @3 _tag _commit pop\n"
" \\3 /namespace @3 _tag _commit \\1 SCSS.module:\n"
" } if\n"
" } ifelse\n"
"}}", NULL);
Expand Down Expand Up @@ -233,6 +233,16 @@ extern parserDefinition* SCSSParser (void)
ATTACH_ROLES(SCSSModuleRoleTable),
},
};
static fieldDefinition SCSSFieldTable [] = {

Check warning on line 236 in optlib/scss.c

View check run for this annotation

Codecov / codecov/patch

optlib/scss.c#L236

Added line #L236 was not covered by tests
{
.enabled = true,
.name = "module",
.description = "the name of module behind the namespace",
.dataType = FIELDTYPE_SCRIPTABLE|FIELDTYPE_STRING,
.getValueObject = getFieldValueGeneric,
.setValueObject = setFieldValueGeneric,
},
};

parserDefinition* const def = parserNew ("SCSS");

Expand All @@ -246,6 +256,8 @@ extern parserDefinition* SCSSParser (void)
def->useCork = CORK_QUEUE;
def->kindTable = SCSSKindTable;
def->kindCount = ARRAY_SIZE(SCSSKindTable);
def->fieldTable = SCSSFieldTable;
def->fieldCount = ARRAY_SIZE(SCSSFieldTable);

Check warning on line 260 in optlib/scss.c

View check run for this annotation

Codecov / codecov/patch

optlib/scss.c#L259-L260

Added lines #L259 - L260 were not covered by tests
def->initialize = initializeSCSSParser;

return def;
Expand Down
9 changes: 6 additions & 3 deletions optlib/scss.ctags
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
--kinddef-SCSS=M,module,modules
--_roledef-SCSS.{module}=used,used

--_fielddef-SCSS=module,the name of module behind the namespace{datatype=str}
--fields-SCSS=+{module}

--_tabledef-SCSS=toplevel
--_tabledef-SCSS=comment
--_tabledef-SCSS=interp
Expand Down Expand Up @@ -69,18 +72,18 @@
% module-name offset' count namespace-string
_copyinterval
dup length 0 gt {
/namespace @1 _tag _commit pop
/namespace @1 _tag _commit \1 SCSS.module:
} {
clear
} ifelse
} {
% Extract the module name as a namespace.
\1 /namespace @1 _tag _commit pop
\1 /namespace @1 _tag _commit \1 SCSS.module:
} ifelse
} {
% "as *" doesn't make a namespace.
\3 (*) ne {
\3 /namespace @3 _tag _commit pop
\3 /namespace @3 _tag _commit \1 SCSS.module:
} if
} ifelse
}}
Expand Down

0 comments on commit b8b157f

Please sign in to comment.