javac错误消息不显示整个文件路径 [英] javac error message does not display entire filepath

查看:183
本文介绍了javac错误消息不显示整个文件路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当使用javac(或ant任务)时,错误消息不包括整个文件路径,它只包括文件名。例如,

When using javac (or the ant task ), the error message does not include the entire filepath, it only includes the file name. For example,

$ javac src/path/to/Filename.java
Filename.java:1: package foo.bar does not exist
import foo.bar.Baz;
              ^

我想要的是

$ javac src/path/to/Filename.java
src/path/to/Filename.java:1: package foo.bar does not exist
import foo.bar.Baz;
              ^

我的问题是,如果没有给出整个文件路径,vim quickfix不工作,而不仅仅是文件名。只是文件名,运行后打开一个新的空文件:make。

My problem is that vim quickfix does not work if it's not given the entire filepath, not just the filename. With just the filename, a new empty file is opened up after running :make.

我使用的是:


  • Debian wheezy

  • openjdk-6-jdk v6b23〜pre7-1

  • javac v1.6.0_23

  • Debian wheezy
  • openjdk-6-jdk v6b23~pre7-1
  • javac v1.6.0_23

推荐答案

我不认为有一个简单的方法。

I don't think there is a simple way to do this.

但是,我相信有一个复杂的方法。它基本上涉及编写自己的编译器运行器,它使用JDK安装的能力,在正在运行的程序中加载和运行Java编译器。你需要实现很多东西,但关键是一个诊断处理器,格式化编译器错误消息,你需要他们格式化的方式。

However, I believe that there is a complicated way. It basically involves writing your own compiler runner that makes use of a JDK installation's ability to load and run the Java compiler inside of a running program. You need to implement a lot of stuff, but the key thing is a diagnostic processor that formats the compiler error messages in the way that you need them to be formatted.

在这里是一些相关链接:

Here are some relevant links:


  • javax.tools - 提供了可以从程序,例如编译器。

  • JavaCompiler - 由编译器实现的接口

  • FileObject - 编译器用来表示源文件的接口;例如在诊断。请注意 toUri()方法!

  • Package javax.tools - provides interfaces for tools which can be invoked from a program, for example, compilers.
  • JavaCompiler - the interface implemented by the compiler
  • FileObject - the interface that the compiler uses to represent source files; e.g. in diagnostics. Note the toUri() method!

这篇关于javac错误消息不显示整个文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆