Possible to deduce plugin from object instance [message #88711] |
Sun, 27 May 2007 02:01 |
Eclipse User |
|
|
|
Originally posted by: expires07.logular.com
Is it possible to deduce the Eclipse plugin that is associated with an
object instance? If so, how?
Background: I'd like to enhance my tracing routine (shown below) to avoid
passage of the plugin parameter. A new implementation would determine
the correct plugin ID internally.
Thanks for any tips,
Jason.
/**
* Return true if the passed object (or an ancestor) is currently being
traced.
*/
public static boolean isTracing(Plugin plugin, Object tracer) {
if (plugin == null || plugin.getBundle() == null || !
plugin.isDebugging()) {
return false;
}
String className = getClassName(tracer);
Boolean enabled = (Boolean)classNameFlagMap.get(className);
if (enabled == null) {
String pluginId = plugin.getBundle().getSymbolicName()
+"/";
String name = className;
while (name.length() > 0) {
String option = Platform.getDebugOption(pluginId
+name);
// ascend the outer class and package hierarchy
to see if one of these
// "parents" is enabled.
if (option == null) {
int index = name.lastIndexOf('.');
if (index > 0) {
name = name.substring(0, index);
}
else {
break;
}
}
else {
enabled = Boolean.valueOf(option);
break;
}
}
if (enabled == null) {
System.err.println("Tracing is not configured for
"+className+"\n" +
"The project's .options file needs an entry
like: \n "+
pluginId + className + " = false");
enabled = Boolean.FALSE;
}
classNameFlagMap.put(className, enabled);
}
return enabled.booleanValue();
}
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02933 seconds