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.
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.
© 2022 - 2024 — McMap. All rights reserved.