Skip to content

Commit 0d32e66

Browse files
committed
SCSS: add module parser-specific field
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
1 parent fa6c6b3 commit 0d32e66

File tree

7 files changed

+29
-10
lines changed

7 files changed

+29
-10
lines changed

Tmain/list-fields-with-prefix.d/stdout-expected.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ x UCTAGSxpath no NONE s-- no -- xpath for
4848
- UCTAGSoverline no ReStructuredText --b no -- whether using overline & underline for declaring section
4949
- UCTAGSsectionMarker no ReStructuredText s-- no -- character used for declaring section
5050
- UCTAGSmixin yes Ruby s-- no -- how the class or module is mixed in (mixin:HOW:MODULE)
51+
- UCTAGSmodule yes SCSS s-- no rw the name of module behind the namespace
5152
- UCTAGSdefiner yes Scheme s-- no -- the name of the function or macro that defines the unknown/Y-kind object
5253
- UCTAGSparameter no SystemVerilog --b no -- parameter whose value can be overridden.
5354
- UCTAGStarget yes Thrift s-- no -- the target language specified at "namespace"

Tmain/list-fields.d/stdout-expected.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ z kind no NONE s-- no r- [tags output] prepend "kind:" to k/ (or K/) field outpu
6666
- overline no ReStructuredText --b no -- whether using overline & underline for declaring section
6767
- sectionMarker no ReStructuredText s-- no -- character used for declaring section
6868
- mixin yes Ruby s-- no -- how the class or module is mixed in (mixin:HOW:MODULE)
69+
- module yes SCSS s-- no rw the name of module behind the namespace
6970
- definer yes Scheme s-- no -- the name of the function or macro that defines the unknown/Y-kind object
7071
- parameter no SystemVerilog --b no -- parameter whose value can be overridden.
7172
- target yes Thrift s-- no -- the target language specified at "namespace"
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
X/y input.scss /^@use "X\/y";$/;" M roles:used
2-
y input.scss /^@use "X\/y";$/;" n roles:def
2+
y input.scss /^@use "X\/y";$/;" n roles:def module:X/y
33
Z input.scss /^@use "Z";$/;" M roles:used
4-
Z input.scss /^@use "Z";$/;" n roles:def
4+
Z input.scss /^@use "Z";$/;" n roles:def module:Z
55
A input.scss /^@use "A" as NS;$/;" M roles:used
6-
NS input.scss /^@use "A" as NS;$/;" n roles:def
6+
NS input.scss /^@use "A" as NS;$/;" n roles:def module:A
77
B/ input.scss /^@use "B\/";$/;" M roles:used
88
C/d/e input.scss /^@use 'C\/d\/e';$/;" M roles:used
9-
e input.scss /^@use 'C\/d\/e';$/;" n roles:def
9+
e input.scss /^@use 'C\/d\/e';$/;" n roles:def module:C/d/e
1010
P/q input.scss /^@use 'P\/q' as *;$/;" M roles:used

docs/man/ctags-lang-scss.7.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Change since "0.0"
2828

2929
* New kind ``module`` and new role ``used`` of the ``module`` kind
3030
* New kind ``namespace``
31+
* New field ``module``
3132

3233
SEE ALSO
3334
--------

man/ctags-lang-scss.7.rst.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Change since "0.0"
2828

2929
* New kind ``module`` and new role ``used`` of the ``module`` kind
3030
* New kind ``namespace``
31+
* New field ``module``
3132

3233
SEE ALSO
3334
--------

optlib/scss.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,18 @@ static void initializeSCSSParser (const langType language)
6363
" % module-name offset' count namespace-string\n"
6464
" _copyinterval\n"
6565
" dup length 0 gt {\n"
66-
" /namespace @1 _tag _commit pop\n"
66+
" /namespace @1 _tag _commit \\1 SCSS.module:\n"
6767
" } {\n"
6868
" clear\n"
6969
" } ifelse\n"
7070
" } {\n"
7171
" % Extract the module name as a namespace.\n"
72-
" \\1 /namespace @1 _tag _commit pop\n"
72+
" \\1 /namespace @1 _tag _commit \\1 SCSS.module:\n"
7373
" } ifelse\n"
7474
" } {\n"
7575
" % \"as *\" doesn't make a namespace.\n"
7676
" \\3 (*) ne {\n"
77-
" \\3 /namespace @3 _tag _commit pop\n"
77+
" \\3 /namespace @3 _tag _commit \\1 SCSS.module:\n"
7878
" } if\n"
7979
" } ifelse\n"
8080
"}}", NULL);
@@ -233,6 +233,16 @@ extern parserDefinition* SCSSParser (void)
233233
ATTACH_ROLES(SCSSModuleRoleTable),
234234
},
235235
};
236+
static fieldDefinition SCSSFieldTable [] = {
237+
{
238+
.enabled = true,
239+
.name = "module",
240+
.description = "the name of module behind the namespace",
241+
.dataType = FIELDTYPE_SCRIPTABLE|FIELDTYPE_STRING,
242+
.getValueObject = getFieldValueGeneric,
243+
.setValueObject = setFieldValueGeneric,
244+
},
245+
};
236246

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

@@ -246,6 +256,8 @@ extern parserDefinition* SCSSParser (void)
246256
def->useCork = CORK_QUEUE;
247257
def->kindTable = SCSSKindTable;
248258
def->kindCount = ARRAY_SIZE(SCSSKindTable);
259+
def->fieldTable = SCSSFieldTable;
260+
def->fieldCount = ARRAY_SIZE(SCSSFieldTable);
249261
def->initialize = initializeSCSSParser;
250262

251263
return def;

optlib/scss.ctags

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@
4040
--kinddef-SCSS=M,module,modules
4141
--_roledef-SCSS.{module}=used,used
4242

43+
--_fielddef-SCSS=module,the name of module behind the namespace{datatype=str}
44+
--fields-SCSS=+{module}
45+
4346
--_tabledef-SCSS=toplevel
4447
--_tabledef-SCSS=comment
4548
--_tabledef-SCSS=interp
@@ -69,18 +72,18 @@
6972
% module-name offset' count namespace-string
7073
_copyinterval
7174
dup length 0 gt {
72-
/namespace @1 _tag _commit pop
75+
/namespace @1 _tag _commit \1 SCSS.module:
7376
} {
7477
clear
7578
} ifelse
7679
} {
7780
% Extract the module name as a namespace.
78-
\1 /namespace @1 _tag _commit pop
81+
\1 /namespace @1 _tag _commit \1 SCSS.module:
7982
} ifelse
8083
} {
8184
% "as *" doesn't make a namespace.
8285
\3 (*) ne {
83-
\3 /namespace @3 _tag _commit pop
86+
\3 /namespace @3 _tag _commit \1 SCSS.module:
8487
} if
8588
} ifelse
8689
}}

0 commit comments

Comments
 (0)