zinc icon indicating copy to clipboard operation
zinc copied to clipboard

Feature request: Build and return `SourceInfos` when incremental compilation fails

Open adpi2 opened this issue 5 years ago • 11 comments

When compilation fails, Zinc throws a xsbti.CompileFailed which contains:

  • arguments: Array[String]
  • problems: Array[Problem]

Based on the previous analysis and the CompileFailed instance I am trying to build an accurate description of the entire codebase but I am lacking information.

I don't know which of the old problems are still valid. Typically, a warning in a file is not reported again if the file is not recompiled, but I don't know if the file has been recompiled or not.

Ideally, the CompileFailed exception could contain an instance of SourceInfos which would give us the list of problems, the old ones that are still valid and the new ones.

At least, as an alternative, I would like to know which files have been recompiled.

adpi2 avatar Oct 08 '20 08:10 adpi2

@Friendseeker Since you closed #1306, should we assume this issue cannot be fixed?

adpi2 avatar Sep 25 '24 08:09 adpi2

@adpi2 Might want to double check with the Scala 2 compiler folks but I do suspect this problem cannot be fixed. The issue is that the compiler early stops and does not necessarily return a complete list of all problems in the recompiled files.

Friendseeker avatar Sep 25 '24 16:09 Friendseeker

Re-reading your comment in #1306 I think it's fine that some errors are not reported. What I need is a complete view of the reported errors so that I don't have to buffer then in the BuildServerReporter in sbt.

It's kind of the consensus already: there are some errors, we fix them, and then some more errors can appear. Everybody seems okay with that.

So I think we should merge #1306

adpi2 avatar Sep 26 '24 07:09 adpi2

@adpi2 Glad to hear your assessment. I shall work on getting #1306 merged. This is also a great opportunity to get #1309 merged as both require AnalysisCallback3. As long as we can get #1306 and #1309 merged in quick succession we can avoid the need to introduce AnalysisCallback4.

Friendseeker avatar Sep 27 '24 04:09 Friendseeker

When we bump the AnalysisCallback, we probably want to send PRs to Scala 2.13 and Scala 3 so the Scala teams don't have to figure out what to change.

eed3si9n avatar Sep 27 '24 14:09 eed3si9n

Just realized there's still work to do. Need to test the below cases. I don't remember my PR covering these cases so probably need to implement these in another PR.

  • For mixed scala / java compilation or during compileAllJava workflow
    • Successful compilation should save java warnings in Analysis
    • Unsuccessful compilation (during java compile) should also throw an exception containing SourceInfos

Friendseeker avatar Oct 06 '24 07:10 Friendseeker

@adpi2

c.c. https://github.com/sbt/zinc/issues/932#issuecomment-2395329422

Just want to confirm with you if these are indeed cases that should be covered.

Friendseeker avatar Oct 06 '24 20:10 Friendseeker

@Friendseeker

Yes indeed, I think we need to cover them both.

About saving the Java warnings in the Analysis, is it not already covered?

adpi2 avatar Oct 07 '24 08:10 adpi2

@Friendseeker

Yes indeed, I think we need to cover them both.

About saving the Java warnings in the Analysis, is it not already covered?

Scala compilation problems are recorded in Analysis via calling AnalysisCallback.problem2. I was inspecting where the method was called and didn't see the Java compiler calling it.

Maybe Java warnings are already tracked in a way that is different than how Scala warnings are tracked. I will do investigation. JavaCompilerSpec is probably a good starting point for me to understand the picture better.

Friendseeker avatar Oct 07 '24 08:10 Friendseeker

Note to myself: Document the list of all exceptions Zinc throws and make sure all of them are handled / wrapped appropriately.

Maybe we should also create some markdown doc to place the documentation as exceptions are part of Zinc public API. This also helps with informing the build tool authors.

This would also help with implementing https://github.com/sbt/zinc/issues/1010#issuecomment-2397381421. Easy to just throw a random error as but can gets difficult to throw the right type of error at the right place.

Friendseeker avatar Oct 07 '24 18:10 Friendseeker

When we bump the AnalysisCallback, we probably want to send PRs to Scala 2.13 and Scala 3 so the Scala teams don't have to figure out what to change.

Hi there! When creating a new AnalysisCallback interface version in the future, please ping me, either here on GitHub or on Discord (same username). I'm the maintainer of the Zinc integration in the Scala Plugin for IntelliJ IDEA. I will take care of the rest, thanks!

vasilmkd avatar Oct 21 '24 15:10 vasilmkd