How often is "incremental compilation" performed on Java in Eclipse/ Intellij?
Asked Answered
R

1

8

I understand that Eclipse uses it's own compiler for Java (ECJ) which has the ability to perform incremental compilation. From most of the readings I have found, this compilation is generally triggered by a save action, but that doesn't seem to match up with the fact that you get error feedback on compilation errors almost immediately after typing a single unit/word of code. I haven't found any documentation or literature that states at what granularity this is triggered (i.e every word, letter, line)? Is there additional background code analysis of some sort going on? Although aside from error detection in syntax , I don't see how this would be able to detect semantic errors that can only be revealed through a compilation process.

Raycher answered 30/3, 2016 at 1:45 Comment(7)
Have you looked at the excellent Architecture of Open Source Applications? Specifically aosabook.org/en/eclipse.htmlArvind
You didn't mention NetBeans!Astri
@JasonSperske I just looked at it, and didn't really see how that page answered the question I am posing. If there is a specific part that does, please point that out to me.Raycher
I don't think IntelliJ does incremental compilation at all.Siret
@chrylis - what makes you say that? blog.jetbrains.com/idea/2012/06/…Raycher
@Raycher I interpret "incremental compilation" to mean the Eclipse style where the syntax tree is exposed to the IDE. As I understand it, IDEA still routes single-file compilation through the usual external compiler; the updates you linked just obviate the need to Ctrl-B all the time. As the OP noted, Eclipse is capable of detecting even syntax errors and recommending fixes during typing before save.Siret
Possible duplicate of Disable or speed up DLTK indexing in Eclipse PDT?Luxuriance
U
1

The tight integration of the compiler allows Eclipse to invoke the compiler in all kinds of situations, two of which are relevant for this question:

The term "incremental compilation" typically refers to compilation on save, which may then trigger compiling more files that depend on a changed file. In technical jargon, this is called "building" which reads .java files and produces .class files.

Even more immediate feedback is given by compilation-as-you-type. Such compilation is based on in-memory working copies rather than files. You may even edit several dependent files without saving, and compilation can already see the changes that have been made on other working copies. In technical jargon this is called "reconciling". Although this feature is implemented by an invocation of the full compiler, reconciling does not produce any class files.

As for the original question of trigger granularity: Reconciling works on a per-editor queue of dirty regions. Recording dirty regions is triggered by keystrokes in the editor. The queue is then polled with a default delay of 500 ms.

In addition to the more immediate feedback, users will experience that reconciling creates error markers only in the editor, while building additionally makes those markers visible in the Problems or Markers views.

Unravel answered 6/12, 2018 at 19:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.