question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`tokenizeLine` is not a function

See original GitHub issue

Hello, 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:closed
  • Created 4 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ghostcommented, May 3, 2019

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: parsed

Using tmLanguage I can get more information: tmJsonParser

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 ?

0reactions
ghostcommented, May 11, 2019

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 !

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is causing the error `string.split is not a function`?
This is because document.location is a Location object. The default .toString() returns the location in string form, so the concatenation will trigger that....
Read more >
How To Fix Split is Not a Function Error in JavaScript - Isotropic
split is not a function error. The Problem. First and foremost it is important to understand the usage of the split() method. It...
Read more >
"TypeError: value.split is not a function" when one parameter ...
I'm getting the following error when with diff 2.2.3, Node.js v6.2.0 (and npm 3.8.9): [...]/node_modules/diff/lib/diff/line.js:22 ...
Read more >
tokenize — Tokenizer for Python source — Python 3.11.1 ...
Raised when either a docstring or expression that may be split over several lines is not completed anywhere in the file, for example:....
Read more >
String.prototype.split() - JavaScript - MDN Web Docs
The following example defines a function that splits a string into an array of strings using separator . After splitting the string, the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found