Open hovsater opened 1 month ago
It's actually not the ternary but the <
which is incorrectly recognized as the start of a template and "eats" the rest of the file (or until a ;
if you add one at the end of the line).
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,
parseFunctionBody
also need to be modified to handle case like this
class A {
constructor() {
if (1 > 2 && 2 < 1) {
}
}
function1() {
[].forEach(v => 0);
}
}
It seems to work by removing parseTemplate
function parseFunctionBody
, although I'm not sure of the consequence of removing it.
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,
If a parser maintainer is absent, what we can believe are our valuable test cases. For Typescript, we have enough!
Fell free to make a pull request though I can say merge it in soon.
If none try, I will add this to the end of my queue.
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: d
is recognized as method
class A {
f() {
const a = b => {
if (!c) {}
}
d.e()
}
}
A test2.ts /^class A {$/;" c
a test2.ts /^ const a = b => {$/;" C method:A.f
d test2.ts /^ d.e()$/;" m class:A
f test2.ts /^ f() {$/;" m class:A
But not when !
is removed from !c
class A {
f() {
const a = b => {
if (c) {}
}
d.e()
}
}
A test2.ts /^class A {$/;" c
a test2.ts /^ const a = b => {$/;" C method:A.f
f test2.ts /^ f() {$/;" m class:A
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: