Dear list members, When I recently turned on reflection warnings, I missed source path information (i.e. filenames) because warnings will include referenced modules. It would be nice to be able to differentiate from the output where each warning belongs to, e.g. instead of
Reflection warning, line: 5 - call to endsWith can't be resolved. Reflection warning, line: 8 - call to configure can't be resolved. Reflection warning, line: 11 - call to configure can't be resolved. Reflection warning, line: 33 - reference to field createChannel can't be resolved. Reflection warning, line: 34 - call to basicConsume can't be resolved. Reflection warning, line: 65 - reference to field interrupt can't be resolved. Reflection warning, line: 66 - reference to field close can't be resolved. Reflection warning, line: 129 - call to newConnection can't be resolved. Reflection warning, line: 130 - reference to field createChannel can't be resolved. Reflection warning, line: 137 - call to setReturnListener can't be resolved. Reflection warning, line: 151 - call to java.lang.Thread ctor can't be resolved. Reflection warning, line: 12 - call to write can't be resolved. Reflection warning, line: 23 - call to channel can't be resolved. Reflection warning, line: 23 - call to close can't be resolved. I would like to see something like: Reflection warning, module1/logging.clj:5 - call to endsWith can't be resolved. Reflection warning, module1/logging.clj:8 - call to configure can't be resolved. Reflection warning, module1/logging.clj:11 - call to configure can't be resolved. Reflection warning, module1/mq.clj:33 - reference to field createChannel can't be resolved. Reflection warning, module1/mq.clj:34 - call to basicConsume can't be resolved. Reflection warning, module1/mq.clj:65 - reference to field interrupt can't be resolved. Reflection warning, module1/mq.clj:66 - reference to field close can't be resolved. Reflection warning, module1/mq.clj:129 - call to newConnection can't be resolved. Reflection warning, module1/mq.clj:130 - reference to field createChannel can't be resolved. Reflection warning, module1/mq.clj:137 - call to setReturnListener can't be resolved. Reflection warning, module1/mq.clj:151 - call to java.lang.Thread ctor can't be resolved. Reflection warning, module2/io.clj:12 - call to write can't be resolved. Reflection warning, module2/io.clj:23 - call to channel can't be resolved. Reflection warning, module2/io.clj:23 - call to close can't be resolved. Maybe something along the lines of the attached patch will do. Cheers, Toralf --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---
diff --git a/src/jvm/clojure/lang/Compiler.java b/src/jvm/clojure/lang/Compiler.java index e683da9..7b94ec0 100644 --- a/src/jvm/clojure/lang/Compiler.java +++ b/src/jvm/clojure/lang/Compiler.java @@ -180,7 +180,7 @@ static final public Var SOURCE = Var.intern(Namespace.findOrCreate(Symbol.create //String static final public Var SOURCE_PATH = Var.intern(Namespace.findOrCreate(Symbol.create("clojure.core")), - Symbol.create("*file*"), null); + Symbol.create("*file*"), "NO_SOURCE_PATH"); //String static final public Var COMPILE_PATH = Var.intern(Namespace.findOrCreate(Symbol.create("clojure.core")), @@ -864,8 +864,8 @@ static class InstanceFieldExpr extends FieldExpr implements AssignableExpr{ if(field == null && RT.booleanCast(RT.WARN_ON_REFLECTION.deref())) { ((PrintWriter) RT.ERR.deref()) - .format("Reflection warning, line: %d - reference to field %s can't be resolved.\n", line, - fieldName); + .format("Reflection warning, %s:%d - reference to field %s can't be resolved.\n", + SOURCE_PATH.deref(), line, fieldName); } } @@ -1127,7 +1127,8 @@ static class InstanceMethodExpr extends MethodExpr{ if(method == null && RT.booleanCast(RT.WARN_ON_REFLECTION.deref())) { ((PrintWriter) RT.ERR.deref()) - .format("Reflection warning, line: %d - call to %s can't be resolved.\n", line, methodName); + .format("Reflection warning, %s:%d - call to %s can't be resolved.\n", + SOURCE_PATH.deref(), line, methodName); } } @@ -1268,7 +1269,8 @@ static class StaticMethodExpr extends MethodExpr{ if(method == null && RT.booleanCast(RT.WARN_ON_REFLECTION.deref())) { ((PrintWriter) RT.ERR.deref()) - .format("Reflection warning, line: %d - call to %s can't be resolved.\n", line, methodName); + .format("Reflection warning, %s:%d - call to %s can't be resolved.\n", + SOURCE_PATH.deref(), line, methodName); } } @@ -2107,7 +2109,8 @@ public static class NewExpr implements Expr{ if(ctor == null && RT.booleanCast(RT.WARN_ON_REFLECTION.deref())) { ((PrintWriter) RT.ERR.deref()) - .format("Reflection warning, line: %d - call to %s ctor can't be resolved.\n", line, c.getName()); + .format("Reflection warning, %s:%d - call to %s ctor can't be resolved.\n", + SOURCE_PATH.deref(), line, c.getName()); } }