From ed27cc5d0dac26bec288a3520f65a1c915e8f038 Mon Sep 17 00:00:00 2001 From: kohsuke Date: Fri, 14 Sep 2007 05:47:57 +0000 Subject: [PATCH] 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 --- .../src/main/java/hudson/maven/MavenModuleSet.java | 7 +++++-- .../java/hudson/search/CollectionSearchIndex.java | 14 +++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/hudson/maven/MavenModuleSet.java b/core/src/main/java/hudson/maven/MavenModuleSet.java index 7e07df08a1..b33948b8d5 100644 --- a/core/src/main/java/hudson/maven/MavenModuleSet.java +++ b/core/src/main/java/hudson/maven/MavenModuleSet.java @@ -211,10 +211,10 @@ public final class MavenModuleSet extends AbstractMavenProject() {// for computers protected MavenModule get(String key) { for (MavenModule m : modules.values()) { - if(m.getName().equals(key)) + if(m.getDisplayName().equals(key)) return m; } return null; @@ -222,6 +222,9 @@ public final class MavenModuleSet extends AbstractMavenProject all() { return modules.values(); } + protected String getName(MavenModule o) { + return o.getName(); + } }); } diff --git a/core/src/main/java/hudson/search/CollectionSearchIndex.java b/core/src/main/java/hudson/search/CollectionSearchIndex.java index 0a48d49783..31e4855434 100644 --- a/core/src/main/java/hudson/search/CollectionSearchIndex.java +++ b/core/src/main/java/hudson/search/CollectionSearchIndex.java @@ -9,7 +9,7 @@ import java.util.Map; * * @author Kohsuke Kawaguchi */ -public abstract class CollectionSearchIndex implements SearchIndex { +public abstract class CollectionSearchIndex implements SearchIndex { /** * Gets a single item that exactly matches the given key. */ @@ -19,7 +19,7 @@ public abstract class CollectionSearchIndex implements SearchIndex { * Returns all items in the map. * The collection can include null items. */ - protected abstract Collection all(); + protected abstract Collection all(); public void find(String token, List result) { SearchItem p = get(token); @@ -28,11 +28,15 @@ public abstract class CollectionSearchIndex implements SearchIndex { } public void suggest(String token, List result) { - Collection items = all(); + Collection items = all(); if(items==null) return; - for (SearchableModelObject o : items) { - if(o!=null && o.getDisplayName().contains(token)) + for (SMT o : items) { + if(o!=null && getName(o).contains(token)) result.add(o); } } + + protected String getName(SMT o) { + return o.getDisplayName(); + } } -- GitLab