Skip to content

Auto complete fails with an exception in getTokenPosOfNode #1306

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

Closed
jsotrifork opened this issue Nov 29, 2014 · 13 comments
Closed

Auto complete fails with an exception in getTokenPosOfNode #1306

jsotrifork opened this issue Nov 29, 2014 · 13 comments
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@jsotrifork
Copy link

The Palantir eclipse-typescript Eclipse plugin fails consistently on a fresh Eclipse/plugin installation with an exception in getTokenPosOfNode(). The Palantir developers believes that this is your table.

Steps to reproduce: Hit ctrl-space in any .ts file.

Here is a link to the eclipse-typescript issue, including full stacktrace for ts 1.3 and further comments: palantir/eclipse-typescript#214

Here is the top of the stacktrace with the ts 1.4 version of the plugin:

java.lang.RuntimeException: The following request caused an error to be thrown:
{"endpoint":"language","method":"getCompletionsAtPosition","arguments":["0d703036-865e-46b2-857e-40bdde7f0065","0d703036-865e-46b2-857e-40bdde7f0065",42]}
TypeError: Cannot read property 'text' of undefined
at Object.getTokenPosOfNode (X:\products\eclipse-standard-32bit\plugins\com.palantir.typescript_1.4.0.v20141129-1925\bin\bridge.js:2584:71)
at NodeObject.getStart (X:\products\eclipse-standard-32bit\plugins\com.palantir.typescript_1.4.0.v20141129-1925\bin\bridge.js:20597:23)
at NodeObject.getWidth (X:\products\eclipse-standard-32bit\plugins\com.palantir.typescript_1.4.0.v20141129-1925\bin\bridge.js:20606:41)
at nodeHasTokens (X:\products\eclipse-standard-32bit\plugins\com.palantir.typescript_1.4.0.v20141129-1925\bin\bridge.js:18422:18)
at findRightmostChildNodeWithTokens (X:\products\eclipse-standard-32bit\plugins\com.palantir.typescript_1.4.0.v20141129-1925\bin\bridge.js:18411:21)
at findRightmostToken (X:\products\eclipse-standard-32bit\plugins\com.palantir.typescript_1.4.0.v20141129-1925\bin\bridge.js:18381:29)
at find (X:\products\eclipse-standard-32bit\plugins\com.palantir.typescript_1.4.0.v20141129-1925\bin\bridge.js:18406:37)
at Object.findPrecedingToken (X:\products\eclipse-standard-32bit\plugins\com.palantir.typescript_1.4.0.v20141129-1925\bin\bridge.js:18375:16)
at Object.getCompletionsAtPosition (X:\products\eclipse-standard-32bit\plugins\com.palantir.typescript_1.4.0.v20141129-1925\bin\bridge.js:22043:36)
at LanguageEndpoint.getCompletionsAtPosition (X:\products\eclipse-standard-32bit\plugins\com.palantir.typescript_1.4.0.v20141129-1925\bin\bridge.js:25746:65)
at com.palantir.typescript.services.Bridge.processRequest(Bridge.java:142)
at com.palantir.typescript.services.Bridge.call(Bridge.java:95)
at com.palantir.typescript.services.Bridge.call(Bridge.java:83)
at com.palantir.typescript.services.language.LanguageEndpoint.getCompletionsAtPosition(LanguageEndpoint.java:171)

@DanielRosenwasser
Copy link
Member

Hi there @jsommer, would you be able to provide us with some code that reproduces this issue?

@jsotrifork
Copy link
Author

Hi Daniel,
There is none of my own code in play here. I get the error on any error with a fresh Eclipse and eclipse-typescript installation. The exception happens on all auto complete actions in any open .ts file.

I don't have good tools for debugging the bridge.js file, but I got this far with the exception in getTokenPosOfNode (typescript version 1.4):
sourceFile: undefined
node: (object)
node.kind: 191 (~ModuleDeclaration, but depends on context)
getSourceFileOfNode(node): Returns undefined
node.parent: undefined

node.parent being undefined looks suspicious to me. Shouldn't there be a parent at some level of type 'SourceFile'? getSourceFileOfNode seems to assume this.

@vladima
Copy link
Contributor

vladima commented Nov 29, 2014

That is strange indeed. Can you please try typescriptServices.js from LKG? Post 1.3 there was a lot of code changes in getCompletionsAtPositions to keep just one syntax tree so original stack trace is no longer relevant. If you will still see the error - please post an updated stacktrace so we can address this problem.

@derekcicerone-zz
Copy link

Unfortunately I can't use the LKG typescriptServices.js since there is no accompanying definition file for it (that would be a great addition to start keeping the definition file as well - then I wouldn't have to build typescriptServices.* from source each time). I suspect other tools built on the language services would also benefit from having the definition file in the LKG.

I just tried updating to the latest TypeScript code in master but I hit #1305 so I can't push a new release until that is fixed.

@derekcicerone-zz
Copy link

Btw, since bridge.js is just typescriptServices.js with some glue code concatenated to the end, all the line numbers from stack traces via bridge.js should line up with the corresponding typescriptServices.js file checked into the eclipse-typescript repo. For example, the currently incubating develop version of the plugin uses this snapshot of typescriptServices.js:
https://github.com/palantir/eclipse-typescript/blob/develop/Bridge/lib/typescriptServices.js

@mhegazy mhegazy added the Bug A bug in TypeScript label Nov 30, 2014
@derekcicerone-zz
Copy link

After investigating this further we figured out that this is #1015. I added a workaround which appends ".ts" to affected files and that seems to be working.

@mhegazy mhegazy self-assigned this Nov 30, 2014
@mhegazy
Copy link
Contributor

mhegazy commented Dec 3, 2014

@derekcicerone #1015 should be fixed now. can you give this another try.

@mhegazy mhegazy added this to the TypeScript 1.4 milestone Dec 3, 2014
@derekcicerone-zz
Copy link

Works great - thanks!

@derekcicerone-zz
Copy link

Oh wait, do you want me to test with the new compiler option? I was just going to leave in the workaround of appending ".ts" to the file names.

@mhegazy
Copy link
Contributor

mhegazy commented Dec 3, 2014

up to you :) The new option just bypasses the error. you need to think about what implications this has about emitted file names as well. but again this is totally up to you.

@derekcicerone-zz
Copy link

Cool, I'll keep it in mind in case the workaround becomes a problem. For now I think its fine as-is since its relatively isolated and all other files are guaranteed to have the proper extensions.

@derekcicerone-zz
Copy link

I think this can be closed now.

@mhegazy
Copy link
Contributor

mhegazy commented Dec 12, 2014

thanks @derekcicerone

@mhegazy mhegazy closed this as completed Dec 12, 2014
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Dec 12, 2014
@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

5 participants