Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Solves problem with not compiled java files when they depend on scala files. Additionally there was a problem of disappearing error markers. Fix #1002486
- Loading branch information
1 parent
32e220e
commit fbef29a
Showing
13 changed files
with
221 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...ide.sdt.core.tests/src/org/scalaide/core/sbtbuilder/JavaDependsOnScalaBothAreOkTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package org.scalaide.core | ||
package sbtbuilder | ||
|
||
import org.junit.BeforeClass | ||
import org.scalaide.core.testsetup.SDTTestUtils | ||
import org.junit.Assert._ | ||
import org.junit.Test | ||
import org.eclipse.core.resources.IFile | ||
import org.eclipse.core.runtime.NullProgressMonitor | ||
import org.eclipse.core.resources.IncrementalProjectBuilder | ||
import org.eclipse.core.resources.IMarker | ||
|
||
object JavaDependsOnScalaBothAreOkTest extends testsetup.TestProjectSetup("javaDependsOnScalaBothAreOk") { | ||
@BeforeClass def setup(): Unit = { | ||
SDTTestUtils.enableAutoBuild(false) | ||
} | ||
} | ||
|
||
class JavaDependsOnScalaBothAreOkTest { | ||
import JavaDependsOnScalaBothAreOkTest._ | ||
|
||
@Test def shouldCreateProjectFromOkJavaAndSpoilAndFixIt(): Unit = { | ||
val TypeBMustImplementFoo = 1 | ||
cleanProject() | ||
import SDTTestUtils._ | ||
|
||
val aClass = compilationUnit("main/A.scala") | ||
val bClass = compilationUnit("main/B.java") | ||
def rebuildAndCollectProblems(): List[IMarker] = { | ||
project.underlying.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, new NullProgressMonitor) | ||
getProblemMarkers(aClass, bClass) | ||
} | ||
|
||
step("first compile scala and dependent java classes") { | ||
val problems = rebuildAndCollectProblems() | ||
assertTrue("No build error expected, got: " + markersMessages(problems), problems.isEmpty) | ||
} | ||
|
||
step("then extends java B with abstract A") { | ||
changeContentOfFile(bClass.getResource().getAdapter(classOf[IFile]).asInstanceOf[IFile], changed_main_B) | ||
val problems = rebuildAndCollectProblems() | ||
assertTrue("One build error expected, got: " + markersMessages(problems), problems.length == TypeBMustImplementFoo) | ||
} | ||
|
||
step("and then give body to 'foo' in abstract A") { | ||
changeContentOfFile(aClass.getResource().getAdapter(classOf[IFile]).asInstanceOf[IFile], changed_main_A) | ||
val problems = rebuildAndCollectProblems() | ||
assertTrue("No build error expected, got: " + markersMessages(problems), problems.isEmpty) | ||
} | ||
} | ||
|
||
private def step(description: String)(runInStep: => Unit): Unit = runInStep | ||
|
||
lazy val changed_main_A = """ | ||
package main | ||
abstract class A { | ||
def foo(s: String): Unit = {} | ||
} | ||
""" | ||
lazy val changed_main_B = """ | ||
package main; | ||
public class B extends A { | ||
} | ||
""" | ||
} |
68 changes: 68 additions & 0 deletions
68
org.scala-ide.sdt.core.tests/src/org/scalaide/core/sbtbuilder/JavaDependsOnScalaTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package org.scalaide.core | ||
package sbtbuilder | ||
|
||
import org.junit.BeforeClass | ||
import org.scalaide.core.testsetup.SDTTestUtils | ||
import org.junit.Assert._ | ||
import org.junit.Test | ||
import org.eclipse.core.resources.IFile | ||
import org.eclipse.core.runtime.NullProgressMonitor | ||
import org.eclipse.core.resources.IncrementalProjectBuilder | ||
import org.eclipse.core.resources.IMarker | ||
|
||
object JavaDependsOnScalaTest extends testsetup.TestProjectSetup("javaDependsOnScala") { | ||
@BeforeClass def setup(): Unit = { | ||
SDTTestUtils.enableAutoBuild(false) | ||
} | ||
} | ||
|
||
class JavaDependsOnScalaTest { | ||
import JavaDependsOnScalaTest._ | ||
|
||
@Test def shouldCreateProjectFromWrongJavaAndSpoilAndFixScalaClass(): Unit = { | ||
val TypeBMustImplementFoo = 1 | ||
cleanProject() | ||
import SDTTestUtils._ | ||
|
||
val aClass = compilationUnit("main/A.scala") | ||
val initiallyWrongAclass = slurpAndClose(project.underlying.getFile("src/main/A.scala").getContents) | ||
val bClass = compilationUnit("main/B.java") | ||
def rebuildAndCollectProblems(): List[IMarker] = { | ||
project.underlying.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, new NullProgressMonitor) | ||
getProblemMarkers(aClass, bClass) | ||
} | ||
|
||
step("first compile scala and dependent java classes") { | ||
val problems = rebuildAndCollectProblems() | ||
assertTrue("One build error expected, got: " + markersMessages(problems), problems.length == TypeBMustImplementFoo) | ||
} | ||
|
||
step("then fix scala class") { | ||
changeContentOfFile(aClass.getResource().getAdapter(classOf[IFile]).asInstanceOf[IFile], changed_main_A) | ||
val problems = rebuildAndCollectProblems() | ||
assertTrue("No build error expected, got: " + markersMessages(problems), problems.isEmpty) | ||
} | ||
|
||
step("and then flaw scala class again") { | ||
changeContentOfFile(aClass.getResource().getAdapter(classOf[IFile]).asInstanceOf[IFile], initiallyWrongAclass) | ||
val problems = rebuildAndCollectProblems() | ||
assertTrue("One build error expected, got: " + markersMessages(problems), problems.length == TypeBMustImplementFoo) | ||
} | ||
|
||
step("finally fix scala class") { | ||
changeContentOfFile(aClass.getResource().getAdapter(classOf[IFile]).asInstanceOf[IFile], changed_main_A) | ||
val problems = rebuildAndCollectProblems() | ||
assertTrue("No build error expected, got: " + markersMessages(problems), problems.isEmpty) | ||
} | ||
} | ||
|
||
private def step(description: String)(runInStep: => Unit): Unit = runInStep | ||
|
||
lazy val changed_main_A = """ | ||
package main | ||
abstract class A { | ||
def foo(s: String): Unit = {} | ||
} | ||
""" | ||
} |
7 changes: 7 additions & 0 deletions
7
org.scala-ide.sdt.core.tests/test-workspace/javaDependsOnScala/.classpath
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="con" path="org.scala-ide.sdt.launching.SCALA_CONTAINER"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
18 changes: 18 additions & 0 deletions
18
org.scala-ide.sdt.core.tests/test-workspace/javaDependsOnScala/.project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>javaDependsOnScala</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.scala-ide.sdt.core.scalabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.scala-ide.sdt.core.scalanature</nature> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
5 changes: 5 additions & 0 deletions
5
org.scala-ide.sdt.core.tests/test-workspace/javaDependsOnScala/src/main/A.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package main | ||
|
||
abstract class A { | ||
def foo(s: String): Unit //= {} | ||
} |
5 changes: 5 additions & 0 deletions
5
org.scala-ide.sdt.core.tests/test-workspace/javaDependsOnScala/src/main/B.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package main; | ||
|
||
public class B extends A { | ||
} | ||
|
7 changes: 7 additions & 0 deletions
7
org.scala-ide.sdt.core.tests/test-workspace/javaDependsOnScalaBothAreOk/.classpath
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="con" path="org.scala-ide.sdt.launching.SCALA_CONTAINER"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
18 changes: 18 additions & 0 deletions
18
org.scala-ide.sdt.core.tests/test-workspace/javaDependsOnScalaBothAreOk/.project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>javaDependsOnScalaBothAreOk</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.scala-ide.sdt.core.scalabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.scala-ide.sdt.core.scalanature</nature> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
5 changes: 5 additions & 0 deletions
5
org.scala-ide.sdt.core.tests/test-workspace/javaDependsOnScalaBothAreOk/src/main/A.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package main | ||
|
||
abstract class A { | ||
def foo(s: String): Unit | ||
} |
5 changes: 5 additions & 0 deletions
5
org.scala-ide.sdt.core.tests/test-workspace/javaDependsOnScalaBothAreOk/src/main/B.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package main; | ||
|
||
public class B { | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters