Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #1000613. Modified code to handle this special case.

To be able to handle files which are not part of the workspace (like a
previous version from source control), Eclipse uses a non-existing
project. This one has to be handle correctly.
  • Loading branch information...
commit b59088e80f9c876701c8e9103243ed7a312a8f88 1 parent 93537d2
@skyluc skyluc authored
View
15 org.scala-ide.sdt.core/src/scala/tools/eclipse/ScalaProject.scala
@@ -142,8 +142,6 @@ class ScalaProject(val underlying: IProject) extends HasLogger {
def externalDepends = underlying.getReferencedProjects
lazy val javaProject = {
- if (!underlying.exists())
- underlying.create(null)
JavaCore.create(underlying)
}
@@ -364,10 +362,15 @@ class ScalaProject(val underlying: IProject) extends HasLogger {
}
def initialize(settings: Settings, filter: Settings#Setting => Boolean) = {
- val env = new NameEnvironment(javaProject)
-
- for ((src, dst) <- sourceOutputFolders(env))
- settings.outputDirs.add(EclipseResource(src), EclipseResource(dst))
+
+ // if the workspace project doesn't exist, it is a virtual project used by Eclipse.
+ // As such the source folders don't exist.
+ if (underlying.exists()) {
+ val env = new NameEnvironment(javaProject)
+
+ for ((src, dst) <- sourceOutputFolders(env))
+ settings.outputDirs.add(EclipseResource(src), EclipseResource(dst))
+ }
// TODO Per-file encodings
val sfs = sourceFolders
View
5 org.scala-ide.sdt.core/src/scala/tools/eclipse/javaelements/ScalaCompilationUnit.scala
@@ -34,6 +34,7 @@ import org.eclipse.jdt.core.IParent
import org.eclipse.jdt.internal.core.JavaElement
import org.eclipse.jdt.internal.core.SourceRefElement
import scala.tools.eclipse.util.HasLogger
+import org.eclipse.jdt.core.compiler.CharOperation
trait ScalaCompilationUnit extends Openable with env.ICompilationUnit with ScalaElement with IScalaCompilationUnit with IBufferChangedListener with HasLogger {
val project = ScalaPlugin.plugin.getScalaProject(getJavaProject.getProject)
@@ -58,7 +59,9 @@ trait ScalaCompilationUnit extends Openable with env.ICompilationUnit with Scala
}
def createSourceFile : BatchSourceFile = {
- new BatchSourceFile(file, getContents)
+ // call getContent() only when the underlying resource exists, otherwise
+ // it logs an exception
+ new BatchSourceFile(file, if (getResource.exists) getContents else CharOperation.NO_CHAR)
}
def getProblemRequestor : IProblemRequestor = null
Please sign in to comment.
Something went wrong with that request. Please try again.