`tokenizeLine` is not a function
See original GitHub issueHello, I’m Denis, an Italian developer ! I’m trying to craft an advanced postfix completion helper for vscode : https://github.com/Denis-net/vscode-definitive-postfix
I wanted to activate my suggestions only when not inside comment blocks (tokens), I tried regexs but I didn’t manage to distinguish strings from comment or line comment to block comment etc.
( for example:
var x=5; // /*
x++;
// */
var aString = "//"; x++;
)
I discovered that I need a syntax analyzer/tokenizer and after a long search i came across this intresting project.
But I missed something important, because I can’t make it working.
I read about tmLanguage and plist, I found them on vscode.env.appRoot/extensions/*/syntaxes
and on
textmate repo.
In extension.ts
.loadParser
(:110) method I call the parseRawGrammar
, then I store the result in my global singleton(SnippetCollector.Current
) field.
In completionProvider.ts
.isInsideComment
(:46) method I tried to use the parser, but It raises an exception :
“
parser.tokenizeLine
is not a function”
so it didn’t create the expected object.
Furthermore, in the loadGrammar.then()
(extension.ts:137) the grammar
arg is null, while inside the promise I can load a rawGrammar
object.
Could you help me ? Maybe you know what I’m doing wrong, or if there is another way of doing it.
Thanks
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (2 by maintainers)
I tried to compile it but I had issues with node/electron environment (not understood well)… anyway.
I found a compiled version in
C:\Users\User\AppData\Local\Programs\Microsoft VS Code\resources\app\node_modules.asar.unpacked\oniguruma\build\Release
So I copied it into my folder and… the good news is : It works ✨ the bad news is : don’t work as I expected 😔Using plist:
Using tmLanguage I can get more information:
But what I would really like to have are the built-in scope inspector’s data : With It i could understand exactly where I am (more specifically if user cursor is in a comment)
I think I had misunderstood the
vscode-textmate
plugin. Or I didn’t make it working …Anyway Thank you @msftrncs for the great help !
For patching the doc (Readme.md) what can we do ? Because isn’t specified that developers need the Registry and that the addGrammar().then() will return the real Grammar object. Not speaking about this oniguruma build dependency.
Or can i just close this issue for posterity ?
Ok, The best I can do is this: I opened this pull request. Hope this could help in fixing the Readme so other developers could save time. Thanks again !