Skip to content

Commit 199360e

Browse files
committed
Merge branch 'duplicate-details'
2 parents 66ed844 + fc37cb2 commit 199360e

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

src/main/java/org/scijava/menu/ShadowMenu.java

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -548,12 +548,14 @@ else if (existingChild != null) {
548548
final ModuleInfo childInfo = existingChild.getModuleInfo();
549549
if (childInfo != null && info.getPriority() == childInfo.getPriority())
550550
{
551-
log.warn("ShadowMenu: menu item already exists:\n\texisting: " +
552-
childInfo + "\n\t ignored: " + info);
551+
log.warn("ShadowMenu: menu item already exists:\n" + //
552+
"\texisting: " + details(childInfo) + "\n" + //
553+
"\t ignored: " + details(info));
553554
}
554555
else {
555556
log.debug("ShadowMenu: higher-priority menu item already exists:\n" +
556-
"\texisting: " + childInfo + "\n\t ignored: " + info);
557+
"\texisting: " + details(childInfo) + "\n" + //
558+
"\t ignored: " + details(info));
557559
}
558560
}
559561
}
@@ -564,6 +566,21 @@ private boolean isLeaf(final int depth, final MenuPath path) {
564566
return depth == path.size() - 1;
565567
}
566568

569+
private String details(final ModuleInfo info) {
570+
if (info == null) return "<null>";
571+
String className, classLocation;
572+
try {
573+
final Class<?> c = info.loadDelegateClass();
574+
className = c.getName();
575+
classLocation = ClassUtils.getLocation(c).toString();
576+
}
577+
catch (final ClassNotFoundException exc) {
578+
className = info.getDelegateClassName();
579+
classLocation = "<invalid>";
580+
}
581+
return info.getMenuPath() + " : " + className + " [" + classLocation + "]";
582+
}
583+
567584
private ShadowMenu getMenu(final MenuPath menuPath, final int index) {
568585
final MenuEntry entry = menuPath.get(index);
569586

src/main/java/org/scijava/script/ScriptLanguageIndex.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import javax.script.ScriptEngineFactory;
4141

4242
import org.scijava.log.LogService;
43+
import org.scijava.util.ClassUtils;
4344
import org.scijava.util.FileUtils;
4445

4546
/**
@@ -173,9 +174,15 @@ private String overwriteMessage(final boolean overwrite, final String type,
173174
final String key, final ScriptLanguage proposed,
174175
final ScriptLanguage existing)
175176
{
176-
return (overwrite ? "Overwriting " : "Not overwriting ") + type + //
177-
" '" + key + "':\n\tproposed = " + proposed.getClass().getName() +
178-
"\n\texisting = " + existing.getClass().getName();
177+
return (overwrite ? "Overwriting " : "Not overwriting ") + //
178+
type + " '" + key + "':\n" + //
179+
"\tproposed = " + details(proposed) + "\n" +
180+
"\texisting = " + details(existing);
179181
}
180182

183+
/** Helper method of {@link #overwriteMessage}. */
184+
private String details(final ScriptLanguage language) {
185+
final Class<?> c = language.getClass();
186+
return c.getName() + " [" + ClassUtils.getLocation(c);
187+
}
181188
}

0 commit comments

Comments
 (0)