本文介绍了IntelliJ的Scala增量编译何时发生?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

何时进行IntelliJ的Scala增量编译?我注意到对文件进行更改不会导致相应的.class文件(在/target中)被更新.什么时候发生?

When does IntelliJ's Scala incremental compilation happen? I notice that making changes to a file does not cause the corresponding .class files (in /target) to be updated. When does this happen?

推荐答案

我认为您误解了Scala增量编译的工作原理.

I think you misunderstand how Scala incremental compilation works.

有2种不同的东西可以称为"IntelliJ的Scala增量编译":

There are 2 different things that might be called "IntelliJ's Scala incremental compilation ":

1)正确的Scala增量编译,或多或少是一套适用于不同编程语言的典型策略,当您按下编译"按钮时,不会从头开始重新编译所有内容.其背后的主要思想是,构建系统可能会注意到某些文件及其所有依赖项自上次编译以来并未更改,因此您不必重新编译它们,而可以使用上次编译的结果.对于Scala来说,这些启发式方法实际上是复杂的,因为它是一种复杂的语言. SBT文档了解增量重新编译" .在某个时候,JetBrains认为它们更聪明并实施了一套启发式算法,并声称它们更好(即增量编译更快),因此现在您可以在Scala编译器设置下基于SBT和基于Idea的增量编译之间进行选择.但是它仍然仅在您按下Compile(或Run或Debug或类似的命令)时才起作用.这不是Idea在后台执行的操作.

1) Proper Scala incremental compilation which is more or less a set of typcial strategies applicable for different programming languages to not (re-)compile everythings from the scratch again when you hit Compile button. The main idea behind that is that the build system might notice that certain files and all their dependency haven't changed since the last compilation and thus you don't have to re-compile them and can use result of the last compilation instead. Those heuristics are actually complicated for Scala as it is a complicated language. Some ideas on what can be done are described at the SBT document "Understanding Incremental Recompilation". At some point JetBrains decided that they are smarter and implemented their set of heuristics and they claim that they are better (i.e. incremental compilation is faster) so now you chose between SBT-based and Idea-based incremental compilation under Scala Compiler settings. But still it only works when you hit Compile (or Run or Debug or something similar). This not something Idea does in background.

2)IntelliJ Idea有另一件事,它也需要某种增量重新编译,并且这种编译几乎是实时的.这是Idea的Scala插件实现的语法突出显示功能,它要求立即以所有与实际编译器相同的方式重新处理您更改的所有文件.实际上,您不应该研究该过程的细节(除非您自己开发Scala插件)​​.这些过程提供的是代码的某些语法结构,而不是实际的.class文件.

2) There is another thing specific for IntelliJ Idea that also requires a kind of incremental recompilation and this one works in almost real time. It is the synxtax highlighting feature that is implemented by Idea's Scala plugin and it requires immediate re-processing of all the files you change in a way similar but now exactly the same as what the real compiler does. And actually you are not supposed to look into the details of that process (unless you are going to develop Scala plug-in itself). What those process provides is some syntax structure of the code but not the actual .class files.

这篇关于IntelliJ的Scala增量编译何时发生?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-12 11:02