<p>Still hijacking this PR for the moment:</p>
<p>Oops. Normally all we'd have to do is properly fill <code>extensionFields.scopeIndex</code>, like that:</p>
<pre><code>diff --git a/ctags/parsers/rest.c b/ctags/parsers/rest.c
index 1a9dd2e22..a192babf3 100644
--- a/ctags/parsers/rest.c
+++ b/ctags/parsers/rest.c
@@ -34,11 +34,19 @@ typedef enum {
SECTION_COUNT
} restKind;
+static scopeSeparator RestScopeSeparators [] = {
+ { KIND_WILDCARD, ":::" }
+};
+
static kindOption RestKinds[] = {
- { true, 'n', "namespace", "chapters"},
- { true, 'm', "member", "sections" },
- { true, 'd', "macro", "subsections" },
- { true, 'v', "variable", "subsubsections" }
+ { true, 'n', "namespace", "chapters",
+ ATTACH_SEPARATORS(RestScopeSeparators) },
+ { true, 'm', "member", "sections",
+ ATTACH_SEPARATORS(RestScopeSeparators) },
+ { true, 'd', "macro", "subsections",
+ ATTACH_SEPARATORS(RestScopeSeparators) },
+ { true, 'v', "variable", "subsubsections",
+ ATTACH_SEPARATORS(RestScopeSeparators) }
};
static char kindchars[SECTION_COUNT];
@@ -49,7 +57,7 @@ static NestingLevels *nestingLevels = NULL;
* FUNCTION DEFINITIONS
*/
-static void popNestingLevelToKind(const int kind)
+static NestingLevel *getNestingLevel(const int kind)
{
NestingLevel *nl;
tagEntryInfo *e;
@@ -63,14 +71,14 @@ static void popNestingLevelToKind(const int kind)
else
break;
}
+ return nl;
}
static void makeRestTag (const vString* const name, const int kind)
{
+ const NestingLevel *nl = getNestingLevel (kind);
int r = CORK_NIL;
- popNestingLevelToKind(kind);
-
if (vStringLength (name) > 0)
{
tagEntryInfo e;
@@ -79,6 +87,9 @@ static void makeRestTag (const vString* const name, const int kind)
e.lineNumber--; /* we want the line before the '---' underline chars */
+ if (nl)
+ e.extensionFields.scopeIndex = nl->corkIndex;
+
r = makeTagEntry (&e);
}
nestingLevelsPush(nestingLevels, r);
</code></pre>
<p>Unfortunately, although this results in correct scope being emitted, somehow the symbols tree fails to handle nesting when a separator occurs. I didn't dig yet, but it seems like a bug in Geany.<br>
To whether it makes sense to emit more than one scope level for parsers like reST… well, IMO it does; the challenge here is that scope separation is recorded with specific characters in the scope string, and "languages" like reST allow any character in a tag, making this a little fragile. We're using ":::" right now, and ETX (ASCII 03) for Asciidoc and Txt2Tags. The latter two seem less fragile, but still not fully error proof.<br>
So in the end, even though I don't like it too much, it might indeed male sense to only keep one level in the scope here.</p>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/geany/geany/pull/2018#issuecomment-448128093">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABDrJ7BCfiIdsRt3Pxtsdd0U7E5jCQ4_ks5u6J6HgaJpZM4ZXOnd">mute the thread</a>.<img src="https://github.com/notifications/beacon/ABDrJykDluyWMHn7P_QOgA-Yoe_Q3FyUks5u6J6HgaJpZM4ZXOnd.gif" height="1" width="1" alt="" /></p>
<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/geany/geany","title":"geany/geany","subtitle":"GitHub repository","main_image_url":"https://github.githubassets.com/images/email/message_cards/header.png","avatar_image_url":"https://github.githubassets.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/geany/geany"}},"updates":{"snippets":[{"icon":"PERSON","message":"@b4n in #2018: Still hijacking this PR for the moment:\r\n\r\nOops. Normally all we'd have to do is properly fill `extensionFields.scopeIndex`, like that:\r\n```\r\ndiff --git a/ctags/parsers/rest.c b/ctags/parsers/rest.c\r\nindex 1a9dd2e22..a192babf3 100644\r\n--- a/ctags/parsers/rest.c\r\n+++ b/ctags/parsers/rest.c\r\n@@ -34,11 +34,19 @@ typedef enum {\r\n \tSECTION_COUNT\r\n } restKind;\r\n \r\n+static scopeSeparator RestScopeSeparators [] = {\r\n+\t{ KIND_WILDCARD, \":::\" }\r\n+};\r\n+\r\n static kindOption RestKinds[] = {\r\n-\t{ true, 'n', \"namespace\", \"chapters\"},\r\n-\t{ true, 'm', \"member\", \"sections\" },\r\n-\t{ true, 'd', \"macro\", \"subsections\" },\r\n-\t{ true, 'v', \"variable\", \"subsubsections\" }\r\n+\t{ true, 'n', \"namespace\", \"chapters\",\r\n+\t ATTACH_SEPARATORS(RestScopeSeparators) },\r\n+\t{ true, 'm', \"member\", \"sections\",\r\n+\t ATTACH_SEPARATORS(RestScopeSeparators) },\r\n+\t{ true, 'd', \"macro\", \"subsections\",\r\n+\t ATTACH_SEPARATORS(RestScopeSeparators) },\r\n+\t{ true, 'v', \"variable\", \"subsubsections\",\r\n+\t ATTACH_SEPARATORS(RestScopeSeparators) }\r\n };\r\n \r\n static char kindchars[SECTION_COUNT];\r\n@@ -49,7 +57,7 @@ static NestingLevels *nestingLevels = NULL;\r\n * FUNCTION DEFINITIONS\r\n */\r\n \r\n-static void popNestingLevelToKind(const int kind)\r\n+static NestingLevel *getNestingLevel(const int kind)\r\n {\r\n \tNestingLevel *nl;\r\n \ttagEntryInfo *e;\r\n@@ -63,14 +71,14 @@ static void popNestingLevelToKind(const int kind)\r\n \t\telse\r\n \t\t\tbreak;\r\n \t}\r\n+\treturn nl;\r\n }\r\n \r\n static void makeRestTag (const vString* const name, const int kind)\r\n {\r\n+\tconst NestingLevel *nl = getNestingLevel (kind);\r\n \tint r = CORK_NIL;\r\n \r\n-\tpopNestingLevelToKind(kind);\r\n-\r\n \tif (vStringLength (name) \u003e 0)\r\n \t{\r\n \t\ttagEntryInfo e;\r\n@@ -79,6 +87,9 @@ static void makeRestTag (const vString* const name, const int kind)\r\n \r\n \t\te.lineNumber--;\t/* we want the line before the '---' underline chars */\r\n \r\n+\t\tif (nl)\r\n+\t\t\te.extensionFields.scopeIndex = nl-\u003ecorkIndex;\r\n+\r\n \t\tr = makeTagEntry (\u0026e);\r\n \t}\r\n \tnestingLevelsPush(nestingLevels, r);\r\n```\r\n\r\nUnfortunately, although this results in correct scope being emitted, somehow the symbols tree fails to handle nesting when a separator occurs. I didn't dig yet, but it seems like a bug in Geany.\r\nTo whether it makes sense to emit more than one scope level for parsers like reST… well, IMO it does; the challenge here is that scope separation is recorded with specific characters in the scope string, and \"languages\" like reST allow any character in a tag, making this a little fragile. We're using \":::\" right now, and ETX (ASCII 03) for Asciidoc and Txt2Tags. The latter two seem less fragile, but still not fully error proof.\r\nSo in the end, even though I don't like it too much, it might indeed male sense to only keep one level in the scope here."}],"action":{"name":"View Pull Request","url":"https://github.com/geany/geany/pull/2018#issuecomment-448128093"}}}</script>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/geany/geany/pull/2018#issuecomment-448128093",
"url": "https://github.com/geany/geany/pull/2018#issuecomment-448128093",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>