提交 ed27cc5d 编写于 作者: K kohsuke

search index should include m2 modules.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@4751 71c3de6d-444a-0410-be80-ed276b4c234a
上级 6e6179c3
...@@ -211,10 +211,10 @@ public final class MavenModuleSet extends AbstractMavenProject<MavenModuleSet,Ma ...@@ -211,10 +211,10 @@ public final class MavenModuleSet extends AbstractMavenProject<MavenModuleSet,Ma
@Override @Override
protected SearchIndexBuilder makeSearchIndex() { protected SearchIndexBuilder makeSearchIndex() {
return super.makeSearchIndex() return super.makeSearchIndex()
.add(new CollectionSearchIndex() {// for computers .add(new CollectionSearchIndex<MavenModule>() {// for computers
protected MavenModule get(String key) { protected MavenModule get(String key) {
for (MavenModule m : modules.values()) { for (MavenModule m : modules.values()) {
if(m.getName().equals(key)) if(m.getDisplayName().equals(key))
return m; return m;
} }
return null; return null;
...@@ -222,6 +222,9 @@ public final class MavenModuleSet extends AbstractMavenProject<MavenModuleSet,Ma ...@@ -222,6 +222,9 @@ public final class MavenModuleSet extends AbstractMavenProject<MavenModuleSet,Ma
protected Collection<MavenModule> all() { protected Collection<MavenModule> all() {
return modules.values(); return modules.values();
} }
protected String getName(MavenModule o) {
return o.getName();
}
}); });
} }
......
...@@ -9,7 +9,7 @@ import java.util.Map; ...@@ -9,7 +9,7 @@ import java.util.Map;
* *
* @author Kohsuke Kawaguchi * @author Kohsuke Kawaguchi
*/ */
public abstract class CollectionSearchIndex implements SearchIndex { public abstract class CollectionSearchIndex<SMT extends SearchableModelObject> implements SearchIndex {
/** /**
* Gets a single item that exactly matches the given key. * Gets a single item that exactly matches the given key.
*/ */
...@@ -19,7 +19,7 @@ public abstract class CollectionSearchIndex implements SearchIndex { ...@@ -19,7 +19,7 @@ public abstract class CollectionSearchIndex implements SearchIndex {
* Returns all items in the map. * Returns all items in the map.
* The collection can include null items. * The collection can include null items.
*/ */
protected abstract Collection<? extends SearchableModelObject> all(); protected abstract Collection<SMT> all();
public void find(String token, List<SearchItem> result) { public void find(String token, List<SearchItem> result) {
SearchItem p = get(token); SearchItem p = get(token);
...@@ -28,11 +28,15 @@ public abstract class CollectionSearchIndex implements SearchIndex { ...@@ -28,11 +28,15 @@ public abstract class CollectionSearchIndex implements SearchIndex {
} }
public void suggest(String token, List<SearchItem> result) { public void suggest(String token, List<SearchItem> result) {
Collection<? extends SearchableModelObject> items = all(); Collection<SMT> items = all();
if(items==null) return; if(items==null) return;
for (SearchableModelObject o : items) { for (SMT o : items) {
if(o!=null && o.getDisplayName().contains(token)) if(o!=null && getName(o).contains(token))
result.add(o); result.add(o);
} }
} }
protected String getName(SMT o) {
return o.getDisplayName();
}
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册