From: crawshaw Date: Tue, 23 Nov 2004 16:27:26 +0000 (+0000) Subject: improved error output X-Git-Url: http://git.megacz.com/?p=org.ibex.tool.git;a=commitdiff_plain;h=2eb9305beb350987c0a0822664aec9f1c72b29eb improved error output darcs-hash:20041123162726-2eb37-dd073edaf8432208bff202f453743e85509ff5c4.gz --- diff --git a/src/java/org/ibex/tool/Compiler.java b/src/java/org/ibex/tool/Compiler.java index 8d10ce3..bba4466 100644 --- a/src/java/org/ibex/tool/Compiler.java +++ b/src/java/org/ibex/tool/Compiler.java @@ -87,7 +87,7 @@ public class Compiler { private Source[] sources; private File builddir = new File("."); - private File sourcedir = new File("."); + private String sourcedir = null; public Compiler() { List defs = Collections.EMPTY_LIST; @@ -104,7 +104,7 @@ public class Compiler { public void setBuildDir(String dir) { builddir = new File(dir == null ? "." : dir); } - public void setSourceDir(String dir) { sourcedir = new File(dir == null ? "." : dir); } + public void setSourceDir(String dir) { sourcedir = dir; } /** Pass CompilerOptions.VERSION_1_*. A String of form "1.1", ".2", etc. */ public void setSource(String v) { settings.put(CompilerOptions.OPTION_Source, v); } @@ -116,7 +116,7 @@ public class Compiler { public void compile() { List s = new ArrayList(); - filterSources(s, sourcedir, new char[0][]); + filterSources(s, new File(sourcedir), new char[0][]); if (DEBUG) System.out.println("working with "+s.size() +" sources"); sources = new Source[s.size()]; s.toArray(sources); ICompilationUnit[] units = new ICompilationUnit[s.size()]; @@ -193,8 +193,10 @@ public class Compiler { private Source(File o, char[] n, char[][] p) { orig = o; this.n = n; this.p = p; - try { fileName = orig.getCanonicalPath().toCharArray(); } // FIXME: dont use full path - catch (IOException e) { fileName = orig.getName().toCharArray(); } + String file = sourcedir; + file += File.separatorChar + str(p, File.separatorChar); + file += File.separatorChar + new String(n) + ".java"; + fileName = file.toCharArray(); } } @@ -317,7 +319,7 @@ public class Compiler { for (int i=0; i < nested.length; i++) nested[i] = new LoadedNestedType(classes[i]); - Constructor[] constructors = c.getConstructors(); + Constructor[] constructors = c.getDeclaredConstructors(); Method[] methods = c.getDeclaredMethods(); if (methods.length + constructors.length > 0) { meth = new IBinaryMethod[methods.length + constructors.length]; @@ -421,11 +423,12 @@ public class Compiler { boolean hasErrors = false; IProblem[] p = result.getProblems(); for (int i=0; i < p.length; i++) { - if (p[i].isError()) hasErrors = true; out.print(p[i].getOriginatingFileName()); out.print(':'); out.print(p[i].getSourceLineNumber()); out.print(':'); + if (p[i].isError()) { out.print(" error: "); hasErrors = true; } + else out.print(" warning: "); out.println(p[i].getMessage()); } out.flush();