Home Download Buy Blog Forum Support

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

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

Postby xeno.by on Wed May 09, 2012 9:46 am

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:

Code: Select all
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[_]])

2) scalac crashes which show Java stack traces:

Code: Select all
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?
xeno.by
 
Posts: 104
Joined: Mon Jan 30, 2012 10:03 am
Location: Lausanne, Switzerland

Re: how do I customize the "go to error" functionality?

Postby guillermooo on Wed May 09, 2012 10:12 am

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).

http://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
guillermooo
 
Posts: 728
Joined: Thu Jul 23, 2009 9:06 am

Re: how do I customize the "go to error" functionality?

Postby guillermooo on Wed May 09, 2012 10:21 am

Here's an example of a custom build system:

https://github.com/SublimeText/AAAPacka ... dev.py#L60
guillermooo
 
Posts: 728
Joined: Thu Jul 23, 2009 9:06 am

Re: how do I customize the "go to error" functionality?

Postby xeno.by on Wed May 09, 2012 3:46 pm

guillermooo wrote: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).

http://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


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 :)
xeno.by
 
Posts: 104
Joined: Mon Jan 30, 2012 10:03 am
Location: Lausanne, Switzerland

Re: how do I customize the "go to error" functionality?

Postby guillermooo on Wed May 09, 2012 3:58 pm

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.
guillermooo
 
Posts: 728
Joined: Thu Jul 23, 2009 9:06 am


Return to Technical Support

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 8 guests