4646public class ModuleSearchResult implements SearchResult {
4747
4848 private final ModuleInfo info ;
49- private final String baseDir ;
5049 private final Map <String , String > props ;
5150
5251 public ModuleSearchResult (final ModuleInfo info , final String baseDir ) {
5352 this .info = info ;
54- this .baseDir = baseDir ;
5553
5654 props = new LinkedHashMap <>();
5755 final MenuPath menuPath = info .getMenuPath ();
@@ -66,7 +64,7 @@ public ModuleSearchResult(final ModuleInfo info, final String baseDir) {
6664 }
6765 }
6866 props .put ("Identifier" , info .getIdentifier ());
69- props .put ("Location" , getLocation ( ));
67+ props .put ("Location" , ModuleSearcher . location ( info , baseDir ));
7068 }
7169
7270 public ModuleInfo info () {
@@ -86,12 +84,7 @@ public String identifier() {
8684
8785 @ Override
8886 public String iconPath () {
89- final String iconPath = info .getIconPath ();
90- if (iconPath != null ) return iconPath ;
91- if (info .getMenuPath () != null && info .getMenuPath ().getLeaf () != null ) {
92- return info .getMenuPath ().getLeaf ().getIconPath ();
93- }
94- return null ;
87+ return ModuleSearcher .iconPath (info );
9588 }
9689
9790 @ Override
@@ -101,17 +94,6 @@ public Map<String, String> properties() {
10194
10295 // -- Helper methods --
10396
104- private String getLocation () {
105- String path = info .getLocation ();
106- if (path == null ) return null ;
107- if (path .startsWith ("file:/" )) path = path .replaceFirst ("file:/+" , "/" );
108- if (baseDir != null && path .startsWith (baseDir )) {
109- if (path .length () == baseDir .length ()) return "" ;
110- path = path .substring (baseDir .length () + 1 );
111- }
112- return path ;
113- }
114-
11597 private String getMenuPath (boolean includeLeaf ) {
11698 final MenuPath menuPath = info .getMenuPath ();
11799 if (menuPath == null ) return "" ;
0 commit comments