-
Notifications
You must be signed in to change notification settings - Fork 628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeScript function with ternary (or if-statement) short-circuits parser #4000
Comments
It's actually not the ternary but the |
FWIW this ugly hack works: diff --git a/parsers/typescript.c b/parsers/typescript.c
index 0e04b1b69..063388dfa 100644
--- a/parsers/typescript.c
+++ b/parsers/typescript.c
@@ -1173,7 +1173,7 @@ static void parseVariable (bool constVar, bool localVar, const int scope, tokenI
{
clearPoolToken (token);
parsed = tryInSequence (token, false,
- parseTemplate,
+ nestLevel > 0 ? parseComment : parseTemplate,
parseComment,
parseStringRegex,
parseStringSQuote, |
class A {
constructor() {
if (1 > 2 && 2 < 1) {
}
}
function1() {
[].forEach(v => 0);
}
} It seems to work by removing diff --git a/parsers/typescript.c b/parsers/typescript.c
index 0e04b1b69..19ca1b663 100644
--- a/parsers/typescript.c
+++ b/parsers/typescript.c
@@ -1173,7 +1173,7 @@ static void parseVariable (bool constVar, bool localVar, const int scope, tokenI
{
clearPoolToken (token);
parsed = tryInSequence (token, false,
- parseTemplate,
+ nestLevel > 0 ? parseComment : parseTemplate,
parseComment,
parseStringRegex,
parseStringSQuote,
@@ -1396,7 +1396,6 @@ static void parseFunctionBody (const int scope, tokenInfo *const token)
parseStringDQuote,
parseStringTemplate,
parseStringRegex,
- parseTemplate,
NULL);
} while (parsed && ! isType (token, TOKEN_OPEN_CURLY));
@@ -1414,7 +1413,6 @@ static void parseFunctionBody (const int scope, tokenInfo *const token)
parseStringDQuote,
parseStringTemplate,
parseStringRegex,
- parseTemplate,
parseVarKeyword,
parseLetKeyword,
parseConstKeyword, |
yeah, so parseTemplate is needed in parseFunctionBody to handle other cases. I don't have time now to look into this but as @masatake said, if you'd like to fix this please run tests to see if everything works. |
Another issue: class A {
f() {
const a = b => {
if (!c) {}
}
d.e()
}
}
But not when class A {
f() {
const a = b => {
if (c) {}
}
d.e()
}
}
|
The name of the parser: TypeScript
The command line you used to run ctags:
The content of input file:
The tags output you are not satisfied with:
The tags output you expect:
The version of ctags:
How do you get ctags binary:
The text was updated successfully, but these errors were encountered: