Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Re #1000388, Re #1000607. Set the call to the Eclipse Java compiler a…

…synchronous so it can see the changes.

The way the incremental Eclipse Java compiler works, it doesn't see that because a .class has been changed it needs
to recompile some sources.
This change 'touches' the java files to recompile and call asynchronously the Eclipse Java compiler so it can see
the touched files in the delta.
  • Loading branch information...
commit 0d02de6bbf45ec8067c9606cb76c49801f47362b 1 parent 7d856bf
@skyluc skyluc authored
View
27 org.scala-ide.sdt.core/src/scala/tools/eclipse/buildmanager/sbtintegration/AnalysisCompile.scala
@@ -23,6 +23,13 @@ import java.io.File
import org.eclipse.jdt.launching.JavaRuntime
import org.eclipse.jdt.core.{ JavaCore, IJavaProject }
import scala.tools.eclipse.util.HasLogger
+import org.eclipse.core.resources.ResourcesPlugin
+import org.eclipse.core.resources.IResource
+import org.eclipse.core.runtime.NullProgressMonitor
+import org.eclipse.core.runtime.jobs.Job
+import org.eclipse.core.runtime.IProgressMonitor
+import org.eclipse.core.runtime.IStatus
+import org.eclipse.core.runtime.Status
class AnalysisCompile (conf: BasicConfiguration, bm: EclipseSbtBuildManager, contr: Controller) extends HasLogger {
import AnalysisFormats._
@@ -137,13 +144,29 @@ class AnalysisCompile (conf: BasicConfiguration, bm: EclipseSbtBuildManager, con
javac.build(org.eclipse.core.resources.IncrementalProjectBuilder.INCREMENTAL_BUILD)
log.flush()
}
- }
+ }
if(order == JavaThenScala) {
compileJava(); compileScala()
throwLater()
} else {
- compileScala(); compileJava()
+ compileScala();
+
+ for (javaSource <- javaSrcs) {
+ for (file <- ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(javaSource.toURI())) {
+ file.touch(new NullProgressMonitor)
+ }
+ }
+
+ val markerJob= new Job("Update classpath error marker") {
+ override def run(monitor: IProgressMonitor): IStatus = {
+ compileJava()
+
+ Status.OK_STATUS
+ }
+ }
+ markerJob.setRule(conf.project.underlying)
+ markerJob.schedule()
// if we reached here, then it might be that compiling scala files failed but java succeded
// it might be the case that we just want to proceed with compiling java files when scala succeded
// this is still something that needs to be settled (in the latter case we won't see errors for java files)

3 comments on commit 0d02de6

@froden

This fixes the problem for me: https://groups.google.com/group/scala-ide-user/browse_thread/thread/2fdf8f63edbd93c4
With this patch I cannot reproduce the error and it happened consistently before. I'm really excited about this since I can finally switch to the sbt build manager :)

One thing I noticed, is that a lot more files gets recompiled now. But I guess that is because you touch the source files?

@skyluc
Owner

It does recompile more files... In fact, it recompiles all Java files in the project every time.

I debugged a bit more to see if I was getting the deltas I expected. I wasn't.

So it is kind of working, but it is not a good solution.

@froden

That explains it. Thank you for looking into this issue. I will do some more testing later.

Please sign in to comment.
Something went wrong with that request. Please try again.