Skip to content

Instantly share code, notes, and snippets.

@masatake
Created May 30, 2017 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masatake/b09f530f5b1376b909a62bb54e74e533 to your computer and use it in GitHub Desktop.
Save masatake/b09f530f5b1376b909a62bb54e74e533 to your computer and use it in GitHub Desktop.
commit 129295aa67b290c87e04a67d3bf49b9a2da960c8
Author: Masatake YAMATO <yamato@redhat.com>
Date: Tue May 9 10:34:40 2017 +0900
temp
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
diff --git a/parsers/jscript.c b/parsers/jscript.c
index 884c141..0b0f70f 100644
--- a/parsers/jscript.c
+++ b/parsers/jscript.c
@@ -292,9 +292,11 @@ static void copyToken (tokenInfo *const dest, const tokenInfo *const src,
* Tag generation functions
*/
-static void makeJsTag (const tokenInfo *const token, const jsKind kind,
+static int makeJsTag (const tokenInfo *const token, const jsKind kind,
vString *const signature, vString *const inheritance)
{
+ int corkIndex = CORK_NIL;
+
if (JsKinds [kind].enabled && ! token->ignoreTag )
{
const char *name = vStringValue (token->string);
@@ -353,15 +355,17 @@ static void makeJsTag (const tokenInfo *const token, const jsKind kind,
if (inheritance)
e.extensionFields.inheritance = vStringValue(inheritance);
- makeTagEntry (&e);
+ corkIndex = makeTagEntry (&e);
vStringDelete (fullscope);
}
+ return corkIndex;
}
-static void makeClassTag (tokenInfo *const token, vString *const signature,
+static int makeClassTag (tokenInfo *const token, vString *const signature,
vString *const inheritance)
{
vString * fulltag;
+ int corkIndex = CORK_NIL;
if ( ! token->ignoreTag )
{
@@ -379,15 +383,17 @@ static void makeClassTag (tokenInfo *const token, vString *const signature,
if ( ! stringListHas(ClassNames, vStringValue (fulltag)) )
{
stringListAdd (ClassNames, vStringNewCopy (fulltag));
- makeJsTag (token, JSTAG_CLASS, signature, inheritance);
+ corkIndex = makeJsTag (token, JSTAG_CLASS, signature, inheritance);
}
vStringDelete (fulltag);
}
+ return corkIndex;
}
-static void makeFunctionTag (tokenInfo *const token, vString *const signature, bool generator)
+static int makeFunctionTag (tokenInfo *const token, vString *const signature, bool generator)
{
vString * fulltag;
+ int corkIndex = CORK_NIL;
if ( ! token->ignoreTag )
{
@@ -405,10 +411,11 @@ static void makeFunctionTag (tokenInfo *const token, vString *const signature, b
if ( ! stringListHas(FunctionNames, vStringValue (fulltag)) )
{
stringListAdd (FunctionNames, vStringNewCopy (fulltag));
- makeJsTag (token, generator ? JSTAG_GENERATOR : JSTAG_FUNCTION, signature, NULL);
+ corkIndex = makeJsTag (token, generator ? JSTAG_GENERATOR : JSTAG_FUNCTION, signature, NULL);
}
vStringDelete (fulltag);
}
+ return corkIndex;
}
/*
@@ -1102,6 +1109,7 @@ static void parseFunction (tokenInfo *const token)
vString *const signature = vStringNew ();
bool is_class = false;
bool is_generator = false;
+ int corkIndex = CORK_NIL;
/*
* This deals with these formats
@@ -1146,12 +1154,19 @@ static void parseFunction (tokenInfo *const token)
{
is_class = parseBlock (token, name);
if ( is_class )
- makeClassTag (name, signature, NULL);
+ corkIndex = makeClassTag (name, signature, NULL);
else
- makeFunctionTag (name, signature, is_generator);
+ corkIndex = makeFunctionTag (name, signature, is_generator);
}
findCmdTerm (token, false, false);
+ if (corkIndex != CORK_NIL)
+ {
+ tagEntryInfo *e = getEntryInCorkQueue(corkIndex);
+ if (e)
+ e->extensionFields.endLine = token->lineNumber;
+ }
+
cleanUp:
vStringDelete (signature);
@@ -2253,6 +2268,7 @@ extern parserDefinition* JavaScriptParser (void)
def->finalize = finalize;
def->keywordTable = JsKeywordTable;
def->keywordCount = ARRAY_SIZE (JsKeywordTable);
+ def->useCork = true;
return def;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment