You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 3, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Mar 3, 2023. It is now read-only.
Uncaught TypeError: Cannot read property '0' of undefined #6982
Atom Version: 0.202.0 System: Mac OS X 10.10.3 Thrown From: Atom Core
Stack Trace
Uncaught TypeError: Cannot read property '0' of undefined
At /Applications/Atom.app/Contents/Resources/app.asar/src/tokenized-line.js:89
TypeError: Cannot read property '0' of undefined
at TokenizedLine.module.exports.TokenizedLine.transformContent (/Applications/Atom.app/Contents/Resources/app.asar/src/tokenized-line.js:89:38)
at new TokenizedLine (/Applications/Atom.app/Contents/Resources/app.asar/src/tokenized-line.js:71:12)
at TokenizedBuffer.module.exports.TokenizedBuffer.buildTokenizedLineForRowWithText (/Applications/Atom.app/Contents/Resources/app.asar/src/tokenized-buffer.js:521:14)
at TokenizedBuffer.module.exports.TokenizedBuffer.buildTokenizedLineForRow (/Applications/Atom.app/Contents/Resources/app.asar/src/tokenized-buffer.js:506:19)
at TokenizedBuffer.module.exports.TokenizedBuffer.tokenizeNextChunk (/Applications/Atom.app/Contents/Resources/app.asar/src/tokenized-buffer.js:286:43)
at /Applications/Atom.app/Contents/Resources/app.asar/src/tokenized-buffer.js:263:26
at /Applications/Atom.app/Contents/Resources/app.asar/node_modules/underscore-plus/node_modules/underscore/underscore.js:666:47
Worth mentioning: its not atom-typescript that's changed. Its atom that's changed that broken this < not blaming ... just pointing the path of investigation for those interested 🌹
Ah yes, I see now. I describe the new encoding here: #6757
It's for memory savings purposes. Basically I'm interleaving scope starts/stops (represented by negative integers) with positive integers representing tokens (by their length). You'll need to interact with methods on the grammar registry to translate scopes to numeric ids, but it should be doable.
@nathansobo cool. That helps a lot. I'll make a hotfix to move back to cson driven grammar so people can still use and investigate the rest later tonight 🌹
@basarat you shouldn't be overriding the grammar in this new version right? Hard to explain how this error could happen otherwise. @JonathanMEdwards are you sure you're upgraded? You may need to reload your editor as we don't yet reload code properly after upgrades due to module caching issues.
Going to close this out as it's a package erroring on a private API. I definitely wouldn't discourage this kind of hacking but also can't guarantee things won't break. @basarat I'd love to see you keep experimenting with this approach. It might inform how we could give you a better official interface to hook into your own parser someday.
You're on the right track. Read lower in that explanation and you'll find the true format that more efficiently represent the same concept, with integers. It's pretty cryptic but the other representations ate too much memory.
May I ask why you're +1-ing this issue? The author has fixed the problem in a subsequent release. If you upgrade and reload Atom, the issue should disappear.
This issue has been automatically locked since there has not been any recent activity after it was closed. If you can still reproduce this issue in Safe Mode then please open a new issue and fill out the entire issue template to ensure that we have enough information to address your issue. Thanks!
Activity
basarat commentedon May 27, 2015
I believe my custom grammar stuff for
atom-typescriptis the issue. Investigating.Note: Broken with atom
v0.202@dxue2012 did you have a
.tsfile open by chance?dxue2012 commentedon May 27, 2015
@basarat Yes I did.
In fact I don't recall this issue being present before I updated
atom-typescripttov4.5.2. Thank you for investigating!basarat commentedon May 27, 2015
Worth mentioning: its not atom-typescript that's changed. Its atom that's changed that broken this < not blaming ... just pointing the path of investigation for those interested 🌹
kevinsawicki commentedon May 27, 2015
/cc @nathansobo
basarat commentedon May 28, 2015
Its because of addition of
tags. Still going through the code. For anybody interested this is my code : https://github.com/TypeStrong/atom-typescript/blob/master/lib/main/atom/typescriptGrammar.ts#L181-L227Tags where added to firstmate : https://github.com/atom/first-mate/blob/94604652a81cfebb5eae57e7d7c666905912f19f/src/grammar.coffee#L93-L96
Investigating what I should be returning (and functions I should be calling) from my custom
tokenizeLine.nathansobo commentedon May 28, 2015
@basarat So you're constructing
TokenizedLines on your own?basarat commentedon May 28, 2015
@nathansobo yes
basarat commentedon May 28, 2015
@nathansobo by overriding
tokenizeLine: https://github.com/TypeStrong/atom-typescript/blob/master/lib/main/atom/typescriptGrammar.ts#L38-L85nathansobo commentedon May 28, 2015
Ah yes, I see now. I describe the new encoding here: #6757
It's for memory savings purposes. Basically I'm interleaving scope starts/stops (represented by negative integers) with positive integers representing tokens (by their length). You'll need to interact with methods on the grammar registry to translate scopes to numeric ids, but it should be doable.
basarat commentedon May 28, 2015
@nathansobo cool. That helps a lot. I'll make a hotfix to move back to
csondriven grammar so people can still use and investigate the rest later tonight 🌹hotfix grammar
basarat commentedon May 28, 2015
Thanks for the guidance. Published
atom-typescript:v4.5.3with hotfix 🌹FWIW the other package I know that uses similar custom grammar code is by @p-e-w https://github.com/p-e-w/language-javascript-semantic
JonathanMEdwards commentedon May 28, 2015
I'm getting same trap on .ts files with with atom 0.204.0 and atom-typescript 4.5.5
nathansobo commentedon May 28, 2015
@basarat you shouldn't be overriding the grammar in this new version right? Hard to explain how this error could happen otherwise. @JonathanMEdwards are you sure you're upgraded? You may need to reload your editor as we don't yet reload code properly after upgrades due to module caching issues.
JonathanMEdwards commentedon May 28, 2015
Duh - yeah restart fixes.
nathansobo commentedon May 28, 2015
It's not obvious a restart should be required and we need to fix it, but yeah, glad it worked.
nathansobo commentedon May 28, 2015
Going to close this out as it's a package erroring on a private API. I definitely wouldn't discourage this kind of hacking but also can't guarantee things won't break. @basarat I'd love to see you keep experimenting with this approach. It might inform how we could give you a better official interface to hook into your own parser someday.
wcandillon commentedon Jun 1, 2015
@nathansobo I appear to have the same issue in my plugin. What is the private API that causes this issue? Here's my plugin: https://github.com/wcandillon/language-jsoniq/blob/master/lib/jsoniq-grammar.js
wcandillon commentedon Jun 1, 2015
@nathansobo my
tokenizeLineimplementation used to return the following format:[ { "start": "source.jq" }, { "value": "import module namespace", "scopes": [ "source.jq.keyword" ], "bufferDelta": 23, "firstNonWhitespaceIndex": null, "firstTrailingWhitespaceIndex": null, "screenDelta": 23 }, { "value": " ", "scopes": [ "source.jq.text" ], "bufferDelta": 1, "firstNonWhitespaceIndex": null, "firstTrailingWhitespaceIndex": null, "screenDelta": 1 }, { "value": "xmldb", "scopes": [ "source.jq.text" ], "bufferDelta": 5, "firstNonWhitespaceIndex": null, "firstTrailingWhitespaceIndex": null, "screenDelta": 5 }, { "value": "=", "scopes": [ "source.jq.keyword.operator" ], "bufferDelta": 1, "firstNonWhitespaceIndex": null, "firstTrailingWhitespaceIndex": null, "screenDelta": 1 }, { "value": "\"", "scopes": [ "source.jq.string" ], "bufferDelta": 1, "firstNonWhitespaceIndex": null, "firstTrailingWhitespaceIndex": null, "screenDelta": 1 }, { "value": "http://28.io/modules/exist-db", "scopes": [ "source.jq.string" ], "bufferDelta": 29, "firstNonWhitespaceIndex": null, "firstTrailingWhitespaceIndex": null, "screenDelta": 29 }, { "value": "\"", "scopes": [ "source.jq.string" ], "bufferDelta": 1, "firstNonWhitespaceIndex": null, "firstTrailingWhitespaceIndex": null, "screenDelta": 1 }, { "value": ";", "scopes": [ "source.jq.text" ], "bufferDelta": 1, "firstNonWhitespaceIndex": null, "firstTrailingWhitespaceIndex": null, "screenDelta": 1 }, { "value": "", "scopes": [ "source.jq" ], "bufferDelta": 0, "firstNonWhitespaceIndex": null, "firstTrailingWhitespaceIndex": null, "screenDelta": 0 } ]I modified the implementation to return the following:
[ { "start": "source.jq" }, { "start": "keyword" }, "import module namespace", { "end": "keyword" }, { "start": "text" }, " ", { "end": "text" }, { "start": "text" }, "xmldb", { "end": "text" }, { "start": "keyword.operator" }, "=", { "end": "keyword.operator" }, { "start": "string" }, "\"", { "end": "string" }, { "start": "string" }, "http://28.io/modules/exist-db", { "end": "string" }, { "start": "string" }, "\"", { "end": "string" }, { "start": "text" }, ";", { "end": "text" } ]Does this new output format look good? It doesn't appear to work.
nathansobo commentedon Jun 1, 2015
You're on the right track. Read lower in that explanation and you'll find the true format that more efficiently represent the same concept, with integers. It's pretty cryptic but the other representations ate too much memory.
basarat commentedon Jun 1, 2015
@wcandillon tip (not related to the issue though) ... no need to override
tokenizeLine**s**as the default implementation is similar to what you came up with : https://github.com/atom/first-mate/blob/1c2b006ed2bf119f2662e87f64a3b21beca481e9/src/grammar.coffee#L73-L80 (as far as I can see).michaelkrog commentedon Jun 2, 2015
+1
nathansobo commentedon Jun 2, 2015
May I ask why you're +1-ing this issue? The author has fixed the problem in a subsequent release. If you upgrade and reload Atom, the issue should disappear.
p-e-w commentedon Jun 5, 2015
@basarat, @wcandillon: With some key hints from @nathansobo in #7124, I managed to port my package language-javascript-semantic to the new format and it now features a working CoffeeScript-provided grammar again. The relevant code is here.
basarat commentedon Jun 6, 2015
@p-e-w thanks a lot. Stable link for when I get the time : https://github.com/p-e-w/language-javascript-semantic/blob/b7b61524b0c9cf27fb978a5021da723b4c3a0ea3/lib/javascript-semantic-grammar.coffee#L92
lock commentedon Jan 22, 2019
This issue has been automatically locked since there has not been any recent activity after it was closed. If you can still reproduce this issue in Safe Mode then please open a new issue and fill out the entire issue template to ensure that we have enough information to address your issue. Thanks!