Sublime Forum

How do I customize the "go to error" functionality?

#1

result_file_regex is really cool, but sometimes it’s not enough.

We develop the Scala compiler. Our build process involves compiling ourselves with a stable version of scalac. Hence, compilation errors might fall into two categories:

  1. scalac compilation errors such as:
C:\Projects\KeplerUnderRefactoring\src\compiler\scala\tools\nsc\typechecker\Macros.scala:648: error: type mismatch;
found   : c.Expr[Any]
    (which expands to)  c.mirror.Expr[Any]
  required: c.Expr[scala.reflect.base.Universe]
    (which expands to)  c.mirror.Expr[scala.reflect.base.Universe]
      scala.reflect.makro.internal.materializeArrayTag_impl(c)(args(1).asInstanceOf[c.Expr[Any]])(args(2).asInstanceOf[c.TypeTag[_]])
                                                                                    ^
C:\Projects\KeplerUnderRefactoring\src\compiler\scala\tools\nsc\typechecker\Macros.scala:653: error: type mismatch;
 found   : c.Expr[Any]
    (which expands to)  c.mirror.Expr[Any]
 required: c.Expr[scala.reflect.base.Universe]
    (which expands to)  c.mirror.Expr[scala.reflect.base.Universe]
      scala.reflect.makro.internal.materializeErasureTag_impl(c)(args(1).asInstanceOf[c.Expr[Any]])(args(2).asInstanceOf[c.TypeTag[_]])
  1. scalac crashes which show Java stack traces:
error: scala.reflect.internal.MissingRequirementError: package object scala.reflect.makro.internal not found.
  at scala.reflect.internal.MissingRequirementError$.signal(MissingRequirementError.scala:16)
  at scala.reflect.internal.MissingRequirementError$.notFound(MissingRequirementError.scala:17)
  at scala.reflect.internal.Definitions$Roots.getPackageObject(Definitions.scala:169)
  at scala.reflect.internal.Definitions$DefinitionsClass.MacroInternalPackage(Definitions.scala:672)
  at scala.reflect.internal.Definitions$DefinitionsClass.MacroInternal_materializeArrayTag(Definitions.scala:673)
  at scala.tools.nsc.typechecker.Macros$class.$init$(Macros.scala:648)

“Go to error” for errors of type #1 works flawlessly, since it’s easy to make scalac display absolute paths in errors. Type #2 is tricky, because the JVM only prints class names in its stack traces. Hence I need to somehow inject into Sublime’s logic that navigates from an error to its file. In emacs I was able to write an advice around compilation-find-file, but what do I do in Sublime?

0 Likes

#2

I’d say you need to create your own build system.

Define two sets of regexes to find the file/line info, and inspect the compiler’s output before printing to the output panel. Either print to the output panel immediately (scalac) or gather more info from your files and then set the new regexes to be used (for Java).

docs.sublimetext.info/en/latest/ … stems.html

Read up on the “target” option to build systems to find out how to override the default build system.

Hope that helps

0 Likes

#3

Here’s an example of a custom build system:

github.com/SublimeText/AAAPacka … dev.py#L60

0 Likes

#4

[quote=“guillermooo”]I’d say you need to create your own build system.

Define two sets of regexes to find the file/line info, and inspect the compiler’s output before printing to the output panel. Either print to the output panel immediately (scalac) or gather more info from your files and then set the new regexes to be used (for Java).

docs.sublimetext.info/en/latest/ … stems.html

Read up on the “target” option to build systems to find out how to override the default build system.

Hope that helps[/quote]

Yeah, I’m already using my own build system (in fact, I’m not using any build system at all, just redirecting output of our build tool into a sublime view). So I’m morally prepared to write a filter that would infer full names of files from java stack traces. I just hoped there’s an easier solution :smile:

0 Likes

#5

Ha. When you said “we develop the Scala compiler” I knew you had to have figured out how build systems work. Yep, it looks like there’s no easy solution.

0 Likes