Skip to content

Harden IDE #4635

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

Merged
merged 1 commit into from
Jun 11, 2018
Merged

Harden IDE #4635

merged 1 commit into from
Jun 11, 2018

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Jun 9, 2018

I observed crashes when trying to compute the docstring of trees that did not have a position.
It happened for edited code with lots of syntax errors.

I observed crashes when trying to compute the docstring of trees that did not have a position.
It happened for edited code with lots of syntax errors.
@odersky odersky requested a review from Duhemm June 9, 2018 14:19
@@ -328,7 +328,9 @@ class DottyLanguageServer extends LanguageServer
if (sym == NoSymbol) Nil.asJava
else {
val refs = Interactive.namedTrees(uriTrees, Include.references | Include.overriding, sym)
refs.map(ref => new DocumentHighlight(range(ref.namePos), DocumentHighlightKind.Read)).asJava
( for (ref <- refs if ref.namePos.exists)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've hit on the same issue when doing syntax highlighting. The problem is that namePos is nonsensical for some special trees. For example trees named <init> or <error>. This probably doesn't fix the problem because you still get a position that exists but is wrong. I tried to fix it in #4548, but that's not the correct fix. namePos should probably return NoPosition for "synthetic" names. But I don't think we have such think as "synthetic" names.

Copy link
Contributor

@Duhemm Duhemm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this is going to fix the crashes, but it would obviously be better to fix the underlying issue: querying the position of these synthetic names.

@allanrenucci Do you have a reproducible way to reproduce that?

@odersky odersky merged commit 3d3f5b6 into scala:master Jun 11, 2018
@allanrenucci
Copy link
Contributor

@allanrenucci Do you have a reproducible way to reproduce that?

Yes, if you try to parse class, you get a TypeDef tree with a nonsensical namePos

@allanrenucci allanrenucci deleted the harden-ide-11 branch June 11, 2018 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants