package org.jetbrains.plugins.scala
package debugger

import com.intellij.debugger.NameMapper
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.util.Computable
import com.intellij.psi.PsiClass
import org.jetbrains.annotations.NotNull
import org.jetbrains.plugins.scala.lang.psi.api.toplevel.typedef.{ScObject, ScTemplateDefinition, ScTrait}

/**
*@author ilyas
*/
class ScalaJVMNameMapper extends NameMapper {
  def getQualifiedName(@NotNull clazz: PsiClass): String = {
    ApplicationManager.getApplication.runReadAction(new Computable[String] {
      def compute: String = {
        clazz match {
          case obj: ScObject => obj.qualifiedName + "$"
          case tr: ScTrait => tr.qualifiedName
          case templDef: ScTemplateDefinition => templDef.qualifiedName
          case psiClass => psiClass.getQualifiedName
        }
      }
    })
  }
}

package org.jetbrains.plugins.scala
package debugger

import com.intellij.debugger.NameMapper
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.util.Computable
import com.intellij.psi.PsiClass
import org.jetbrains.annotations.NotNull
import org.jetbrains.plugins.scala.lang.psi.api.toplevel.typedef.{ScObject, ScTemplateDefinition, ScTrait}

/**
*@author ilyas
*/
class ScalaJVMNameMapper extends NameMapper {
  def getQualifiedName(@NotNull clazz: PsiClass): String = {
    ApplicationManager.getApplication.runReadAction(new Computable[String] {
      def compute: String = {
        clazz match {
          case obj: ScObject => obj.qualifiedName + "$"
          case tr: ScTrait => tr.qualifiedName
          case templDef: ScTemplateDefinition => templDef.qualifiedName
          case psiClass => null
        }
      }
    })
  }
}

Fix compatible problem with other NameMapper
Fix compatible problem with other NameMapper

IDEA's com.intellij.debugger.impl.DebuggerManagerImpl#getVMClassQualifiedName will iterate all registered NameMapper and return the first not null result from NameMapper.

When install Scala plugin with another plugin which also register a NameMapper to DebugManager, Scala's ScalaJVMNameMapper will return a not null value when the class is not a Scala object. This cause the follow NameMappers dit not got any chance to execute.

Return a null when it is not a Scala object will fix this bug.
