8000 Interactive scaladoc: demand new typer run when done. by vigdorchik · Pull Request #2387 · scala/scala · GitHub
[go: up one dir, main page]

Skip to content

Interactive scaladoc: demand new typer run when done. #2387

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
Apr 22, 2013
Merged

Interactive scaladoc: demand new typer run when done. #2387

merged 1 commit into from
Apr 22, 2013

Conversation

vigdorchik
Copy link
Contributor

As of now, when further backgroundCompile is in the same typer run as
scaladoc-fetching logic, it gets confused with stale symbols.

Please check if there are other inconsistencies in this PC method.
Review by @odersky.

@adriaanm
Copy link
Contributor

We'll also take reviews from @huitseeker

@@ -856,9 +856,9 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
/** Implements CompilerControl.askDocComment */
private[interactive] def getDocComment(sym: Symbol, source: SourceFile, site: Symbol, fragments: List[(Symbol,SourceFile)],
response: Response[(String, String, Position)]) {
informIDE(s"getDocComment $sym at $source site $site")
informIDE(s"getDocComment $sym at $source; site $site; fragments $fragments")
Copy link
Contributor

Choose a reason for hiding this comment

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

Have you consider something like

fragments.groupBy(_._2).map(
  (sfile,symbls) => "%s in %s".format(symbls.map(_._1), sfile)
).join(", ")

to avoid logfile clutter ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree fragments logging would be too much of a clutter. Given that symbol -> source file mapping is almost 1:1 in stdlib, I think I'd better remove this info at all.

@vigdorchik
Copy link
Contributor Author

I don't include the test here,however I see test failures disappear on the IDE side.
A couple of words to explain myself:
Without starting the new typer run, the interrupted backgroundCompile continues and sees the types resulted from reloading given set of SourceFiles (in the IDE library sources as opposed to symbols coming from classfiles). Since both sets of symbols can appear in the given run, the typer gets confused seeing different class symbols with the same full name. One place where symbols are cached (the one that I was able to track down) is baseTypeSeq: https://github.com/scala/scala/blob/2.10.x/src/reflect/scala/reflect/internal/Types.scala#L2553

The caches are dropped on a new run, so this change fixes the problem.

@@ -856,9 +856,9 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
/** Implements CompilerControl.askDocComment */
private[interactive] def getDocComment(sym: Symbol, source: SourceFile, site: Symbol, fragments: List[(Symbol,SourceFile)],
response: Response[(String, String, Position)]) {
informIDE(s"getDocComment $sym at $source site $site")
informIDE(s"getDocComment $sym at $source, site $site")
Copy link
Contributor

Choose a reason for hiding this comment

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

[nitpicking]
Have you considered something like

fragments.groupBy(_._2).map(
  (sfile,symbls) => "%s in %s".format(symbls.map(_._1), sfile)
).join(", ")

to avoid logfile clutter ?
[/nitpicking]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately that would still be too much: as symbols mostly come from different SourceFiles grouping is not benefitial.

@huitseeker
Copy link
Contributor

While it's true I see less spurious chokage in the IDE thanks to this, I'm afraid this has a performance price in interactive situations. For that reason and maintenance purposes, I'd love to see a code comment at the newTyperRun call that states, at least succintly, that this interrupts backgroundCompiles, mutates Symbols, and hence needs to refresh typing.
Otherwise, LVGTM. 👍

As of now, when backgroundCompile is in the same typer run as
scaladoc-fetching logic, typer is confused with stale symbols.
@vigdorchik
Copy link
Contributor Author

@huitseeker done adding the comment.

adriaanm added a commit that referenced this pull request Apr 22, 2013
Interactive scaladoc: demand new typer run when done.
@adriaanm adriaanm merged commit 4dcb33e into scala:2.10.x Apr 22, 2013
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
0