Permalink
Browse files

Fixed #1000350, fixed #1000326. Catch exceptions thrown during override

indicators building (errors in the source file may trick the compiler into crashing while looking at overridden methods.
  • Loading branch information...
1 parent e9e4497 commit 3e397d44dd6e7b30edbf791413961ba95f76a2c5 @dragos dragos committed Apr 5, 2011
@@ -17,7 +17,7 @@ import scala.tools.eclipse.contribution.weaving.jdt.IScalaOverrideIndicator
import org.eclipse.ui.texteditor.ITextEditor
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility
-import scala.tools.eclipse.ScalaPresentationCompiler
+import scala.tools.eclipse.{ ScalaPresentationCompiler, ScalaPlugin }
trait ScalaOverrideIndicatorBuilder { self : ScalaPresentationCompiler =>
class OverrideIndicatorBuilderTraverser(scu : ScalaCompilationUnit, annotationMap : JMap[AnyRef, AnyRef]) extends Traverser {
@@ -58,19 +58,23 @@ trait ScalaOverrideIndicatorBuilder { self : ScalaPresentationCompiler =>
override def traverse(tree: Tree): Unit = {
tree match {
case defn: DefTree if (defn.symbol ne NoSymbol) && defn.symbol.pos.isOpaqueRange =>
- for(base <- defn.symbol.allOverriddenSymbols) {
- val isOverwrite = base.isDeferred && !defn.symbol.isDeferred
- val text = (if (isOverwrite) "implements " else "overrides ") + base.fullName
- val position = new JFacePosition(defn.pos.startOrPoint, 0)
-
- if (base.isJavaDefined) {
- val packageName = base.enclosingPackage.fullName
- val typeNames = enclosingTypeNames(base).mkString(".")
- val methodName = base.name.toString
- val paramTypes = base.tpe.paramss.flatMap(_.map(_.tpe))
- val methodTypeSignatures = paramTypes.map(mapParamTypeSignature(_))
- annotationMap.put(JavaIndicator(packageName, typeNames, methodName, methodTypeSignatures, text, isOverwrite), position)
- } else annotationMap.put(ScalaIndicator(text, base, isOverwrite), position)
+ try {
+ for(base <- defn.symbol.allOverriddenSymbols) {
+ val isOverwrite = base.isDeferred && !defn.symbol.isDeferred
+ val text = (if (isOverwrite) "implements " else "overrides ") + base.fullName
+ val position = new JFacePosition(defn.pos.startOrPoint, 0)
+
+ if (base.isJavaDefined) {
+ val packageName = base.enclosingPackage.fullName
+ val typeNames = enclosingTypeNames(base).mkString(".")
+ val methodName = base.name.toString
+ val paramTypes = base.tpe.paramss.flatMap(_.map(_.tpe))
+ val methodTypeSignatures = paramTypes.map(mapParamTypeSignature(_))
+ annotationMap.put(JavaIndicator(packageName, typeNames, methodName, methodTypeSignatures, text, isOverwrite), position)
+ } else annotationMap.put(ScalaIndicator(text, base, isOverwrite), position)
+ }
+ } catch {
+ case ex => ScalaPlugin.plugin.logError("Error creating override indicators for %s".format(scu.file.path), ex)
}
case _ =>
}

0 comments on commit 3e397d4

Please sign in to comment.