Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Goldthorpe2010-01-08 19:57:17 +0000
committerChris Goldthorpe2010-01-08 19:57:17 +0000
commit3ba79722ab08d1a09d2ff7d688ae232279c9f896 (patch)
treee48849a53f377a4716701f1b9ad09222a87a904b
parentaace23df09c8a3438df18379c815730360d306a7 (diff)
downloadeclipse.platform.ua-3ba79722ab08d1a09d2ff7d688ae232279c9f896.tar.gz
eclipse.platform.ua-3ba79722ab08d1a09d2ff7d688ae232279c9f896.tar.xz
eclipse.platform.ua-3ba79722ab08d1a09d2ff7d688ae232279c9f896.zip
Bug 298510 – [Help][Search] org.eclipse.help.base API uses classes from Lucene
-rw-r--r--org.eclipse.help.base/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.help.base/plugin.xml3
-rw-r--r--org.eclipse.help.base/schema/luceneSearchParticipants.exsd57
-rw-r--r--org.eclipse.help.base/schema/searchParticipant.exsd194
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/internal/search/HTMLSearchParticipant.java32
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/internal/search/IndexingOperation.java4
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/internal/search/LocalSearchManager.java98
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/internal/search/LuceneSearchDocument.java61
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/internal/search/LuceneSearchParticipantAdapter.java71
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java28
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/internal/search/XHTMLSearchParticipant.java6
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/internal/search/federated/LocalHelp.java4
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/search/IHelpSearchIndex.java55
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/search/ISearchDocument.java67
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/search/ISearchIndex.java9
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/search/LuceneSearchParticipant.java7
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/search/SearchParticipant.java190
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/search/SearchParticipantXML.java385
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/search/XMLSearchParticipant.java7
-rw-r--r--org.eclipse.ua.tests/data/help/search/participant_xml_1.xml22
-rw-r--r--org.eclipse.ua.tests/data/help/search/participant_xml_2.xml23
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/AllSearchTests.java2
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/MockSearchParticipant.java48
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/MockSearchParticipantXML.java64
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/SearchParticipantTest.java70
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/SearchParticipantXMLTest.java70
-rw-r--r--org.eclipse.ua.tests/plugin.xml17
-rw-r--r--org.eclipse.ui.cheatsheets/plugin.xml4
-rw-r--r--org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/CheatsheetSearchParticipant.java6
-rw-r--r--org.eclipse.ui.intro/plugin.xml2
-rw-r--r--org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroSearchParticipant.java31
31 files changed, 1525 insertions, 114 deletions
diff --git a/org.eclipse.help.base/META-INF/MANIFEST.MF b/org.eclipse.help.base/META-INF/MANIFEST.MF
index 1c3c6f3c5..e715cd206 100644
--- a/org.eclipse.help.base/META-INF/MANIFEST.MF
+++ b/org.eclipse.help.base/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %help_base_plugin_name
Bundle-SymbolicName: org.eclipse.help.base; singleton:=true
-Bundle-Version: 3.4.100.qualifier
+Bundle-Version: 3.5.0.qualifier
Bundle-Activator: org.eclipse.help.internal.base.HelpBasePlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
diff --git a/org.eclipse.help.base/plugin.xml b/org.eclipse.help.base/plugin.xml
index d1cf74835..de819ad58 100644
--- a/org.eclipse.help.base/plugin.xml
+++ b/org.eclipse.help.base/plugin.xml
@@ -18,6 +18,7 @@
<extension-point id="activitySupport" name="%activity_extension_point_name" schema="schema/activitySupport.exsd"/>
<extension-point id="luceneSearchParticipants" name="%search_participant_extension_point_name" schema="schema/luceneSearchParticipants.exsd"/>
<extension-point id="server" name="%server_extension_point_name" schema="schema/server.exsd"/>
+ <extension-point id="searchParticipant" name="Help Search Participant" schema="schema/searchParticipant.exsd"/>
<!-- Stand-alone infocenter application -->
<extension
@@ -203,7 +204,7 @@
</extraClasspathEntry>
</extension>
<extension
- point="org.eclipse.help.base.luceneSearchParticipants">
+ point="org.eclipse.help.base.searchParticipant">
<searchParticipant
extensions="xhtml"
id="org.eclipse.help.base.xhtml"
diff --git a/org.eclipse.help.base/schema/luceneSearchParticipants.exsd b/org.eclipse.help.base/schema/luceneSearchParticipants.exsd
index e65c67af3..7022320d8 100644
--- a/org.eclipse.help.base/schema/luceneSearchParticipants.exsd
+++ b/org.eclipse.help.base/schema/luceneSearchParticipants.exsd
@@ -2,9 +2,9 @@
<!-- Schema file written by PDE -->
<schema targetNamespace="org.eclipse.help.base" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
- <appinfo>
+ <appInfo>
<meta.schema plugin="org.eclipse.help.base" id="luceneSearchParticipants" name="Lucene Search Participants"/>
- </appinfo>
+ </appInfo>
<documentation>
This extension point should be used to add document content to the Lucene search index. There are two cases were you would want to add a search participant:
&lt;ol&gt;
@@ -23,9 +23,12 @@ Search participants are associated with the plug-in the extension appears in. In
<element name="extension">
<annotation>
- <appinfo>
- <meta.element />
- </appinfo>
+ <appInfo>
+ <meta.element deprecated="true" replacement="org.eclipse.help.base.searchParticipant" />
+ </appInfo>
+ <documentation>
+ This extension point is deprecated because it depends on API classes which expose Lucene classes, which are not binary compatible between major release. The extension point org.eclipse.help.base.searchParticipant should be used instead.
+ </documentation>
</annotation>
<complexType>
<choice minOccurs="1" maxOccurs="unbounded">
@@ -51,9 +54,9 @@ Search participants are associated with the plug-in the extension appears in. In
<documentation>
</documentation>
- <appinfo>
+ <appInfo>
<meta.attribute translatable="true"/>
- </appinfo>
+ </appInfo>
</annotation>
</attribute>
</complexType>
@@ -61,9 +64,9 @@ Search participants are associated with the plug-in the extension appears in. In
<element name="searchParticipant">
<annotation>
- <appinfo>
+ <appInfo>
<meta.element labelAttribute="id" icon="icon"/>
- </appinfo>
+ </appInfo>
</annotation>
<complexType>
<sequence>
@@ -81,9 +84,9 @@ Search participants are associated with the plug-in the extension appears in. In
<documentation>
an optional translatable name that will be used to represent the participant as a category of documents that can be included in the search. The name is not required when the participant is used for documents in the TOC (i.e. when &lt;code&gt;extensions&lt;/code&gt; attribute is set).
</documentation>
- <appinfo>
+ <appInfo>
<meta.attribute translatable="true"/>
- </appinfo>
+ </appInfo>
</annotation>
</attribute>
<attribute name="icon" type="string">
@@ -91,9 +94,9 @@ Search participants are associated with the plug-in the extension appears in. In
<documentation>
an optional icon to be used to render search hits from the documents indexed by this participant. The icon will be used for the documents outside of the help&apos;s TOC to indicate that opening the search hit may result in an action different from showing the regular help document. Consequently, icon is not required when the participant is used for documents in the TOC (i.e. when &lt;code&gt;extensions&lt;/code&gt; attribute is set).
</documentation>
- <appinfo>
+ <appInfo>
<meta.attribute kind="resource"/>
- </appinfo>
+ </appInfo>
</annotation>
</attribute>
<attribute name="participant" type="string">
@@ -101,9 +104,9 @@ Search participants are associated with the plug-in the extension appears in. In
<documentation>
(&lt;strong&gt;new in 3.2&lt;/strong&gt;) the implementation class for the help search participant. This class must implement the &lt;samp&gt;org.eclipse.help.search.ILuceneSearchParticipant&lt;/samp&gt; interface. This attribute may be omitted, and the nested &lt;samp&gt;participant&lt;/samp&gt; element may be provided instead.
</documentation>
- <appinfo>
+ <appInfo>
<meta.attribute kind="java" basedOn="org.eclipse.help.IHelpSerchParticipant"/>
- </appinfo>
+ </appInfo>
</annotation>
</attribute>
<attribute name="extensions" type="string">
@@ -165,27 +168,27 @@ Search participants are associated with the plug-in the extension appears in. In
<documentation>
a reference to the search participant declared elsewhere using &lt;code&gt;searchParticipant&lt;/code&gt; element. Binding can be used to reuse search participants in plug-ins without violating the top-down policy. Binding is only needed for indexing documents that are part of the TOC. Otherwise, participant has global scope.
</documentation>
- <appinfo>
+ <appInfo>
<meta.attribute kind="identifier" basedOn="org.eclipse.help.base.luceneSearchParticipants/searchParticipant/@id"/>
- </appinfo>
+ </appInfo>
</annotation>
</attribute>
</complexType>
</element>
<annotation>
- <appinfo>
+ <appInfo>
<meta.section type="since"/>
- </appinfo>
+ </appInfo>
<documentation>
3.2
</documentation>
</annotation>
<annotation>
- <appinfo>
+ <appInfo>
<meta.section type="examples"/>
- </appinfo>
+ </appInfo>
<documentation>
The following is a sample usage of the extension point:
@@ -207,27 +210,27 @@ Search participants are associated with the plug-in the extension appears in. In
</annotation>
<annotation>
- <appinfo>
+ <appInfo>
<meta.section type="apiInfo"/>
- </appinfo>
+ </appInfo>
<documentation>
The supplied search participant class must extend the &lt;samp&gt;org.eclipse.help.search.LuceneSearchParticipant&lt;/samp&gt; abstract class.
</documentation>
</annotation>
<annotation>
- <appinfo>
+ <appInfo>
<meta.section type="implementation"/>
- </appinfo>
+ </appInfo>
<documentation>
Help system provides search participant for XHTML files (xhtml extension). Plug-ins that have dynamic XHTML documents as part of TOC must bind to this participant using &lt;code&gt;binding&lt;/code&gt; element and &lt;code&gt;org.eclipse.help.base.xhtml&lt;/code&gt; as the target participant id.
</documentation>
</annotation>
<annotation>
- <appinfo>
+ <appInfo>
<meta.section type="copyright"/>
- </appinfo>
+ </appInfo>
<documentation>
Copyright (c) 2005, 2006 IBM Corporation and others.&lt;br&gt;
All rights reserved. This program and the accompanying materials are made
diff --git a/org.eclipse.help.base/schema/searchParticipant.exsd b/org.eclipse.help.base/schema/searchParticipant.exsd
new file mode 100644
index 000000000..28ad9004f
--- /dev/null
+++ b/org.eclipse.help.base/schema/searchParticipant.exsd
@@ -0,0 +1,194 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.help.base" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.help.base" id="searchParticipant" name="Help Search Participant"/>
+ </appInfo>
+ <documentation>
+ This extension point should be used to add document content to the search index. There are two cases were you would want to add a search participant:
+&lt;ol&gt;
+&lt;li&gt;
+To index documents registered with the help system&apos;s TOC that are not of the HTML format (e.g. XML). In this case, the participant must declare file extensions it can handle. It will be called to index each matching document. In this case, the participant has the plug-in scope.
+&lt;/li&gt;
+&lt;li&gt;
+To index documents outside of the help system&apos;s TOC. In this case, the participant will be given a chance to index all the documents it knows about at once. In addition, the participant will be delegated the task of opening the search result because the help system will not know how to open the documents outside the TOC. In this case, the participant has global scope.
+&lt;/li&gt;
+&lt;/ol&gt;
+&lt;p&gt;
+Search participants are associated with the plug-in the extension appears in. In order to reuse the participant in other plug-ins, &lt;code&gt;binding&lt;/code&gt; should be used to reference them. This strategy prevents a plug-in from imposing its participant on the entire product for the file extensions it was registered with. By adding an explicit reference, the plug-in declares that it allows the referenced search participant to handle indexing of documents with those extensions. For documents that are not part of the TOC, there is no such danger. For this reason, they are global and &lt;code&gt;binding&lt;/code&gt; should not be used.
+&lt;/p&gt;
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <choice minOccurs="1" maxOccurs="unbounded">
+ <element ref="searchParticipant"/>
+ <element ref="binding"/>
+ </choice>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="searchParticipant">
+ <annotation>
+ <appInfo>
+ <meta.element labelAttribute="id" icon="icon"/>
+ </appInfo>
+ </annotation>
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ a unique identifier of this search participant
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ an optional translatable name that will be used to represent the participant as a category of documents that can be included in the search. The name is not required when the participant is used for documents in the TOC (i.e. when &lt;code&gt;extensions&lt;/code&gt; attribute is set).
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="icon" type="string">
+ <annotation>
+ <documentation>
+ an optional icon to be used to render search hits from the documents indexed by this participant. The icon will be used for the documents outside of the help&apos;s TOC to indicate that opening the search hit may result in an action different from showing the regular help document. Consequently, icon is not required when the participant is used for documents in the TOC (i.e. when &lt;code&gt;extensions&lt;/code&gt; attribute is set).
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="resource"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="participant" type="string" use="required">
+ <annotation>
+ <documentation>
+ The implementation class for the help search participant. This class must implement the &lt;samp&gt;org.eclipse.help.search.SearchParticipant&lt;/samp&gt; interface. This attribute may be omitted, and the nested &lt;samp&gt;participant&lt;/samp&gt; element may be provided instead.
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn="org.eclipse.help.search.SearchParticipant:"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="extensions" type="string">
+ <annotation>
+ <documentation>
+ an optional field containing the list of file types handled by the search participant. This is a string containing comma separate file extensions (e.g. &quot;abc, xyz&quot;). This attribute should be used when files are made explicitly known to the help system in the &lt;code&gt;org.eclipse.help.toc&lt;/code&gt; extension point. The absence of this attribute is an indication that the participant will index all the documents it is responsible for by itself.
+&lt;p&gt;Note also that participants that are registered for known documents have plug-in scope. If you want a participant to apply to documents in another plug-in, you must use the &lt;code&gt;binding&lt;/code&gt; element to extend the scope. In contrast, participants that do not specify this attribute have global scope.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="headless" type="boolean" use="default" value="false">
+ <annotation>
+ <documentation>
+ specifies whether or not this search participant should be used when running the help system outside an eclipse workbench, i.e. it is running in either standalone or infocenter mode. The default value is &lt;code&gt;false&lt;/code&gt;.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="binding">
+ <complexType>
+ <attribute name="participantId" type="string">
+ <annotation>
+ <documentation>
+ a reference to the search participant declared elsewhere using &lt;code&gt;searchParticipant&lt;/code&gt; element. Binding can be used to reuse search participants in plug-ins without violating the top-down policy. Binding is only needed for indexing documents that are part of the TOC. Otherwise, participant has global scope.
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.help.base.luceneSearchParticipants/searchParticipant/@id"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ 3.5
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ The following is a sample usage of the extension point:
+
+&lt;p&gt;
+&lt;pre&gt;
+ &lt;extension point=&quot;org.eclipse.help.base.luceneSearchParticipant&quot;&gt;
+ &lt;searchParticipant id=&quot;org.eclipse.myGlobalParticipant&quot;
+ name=&quot;Global Participant&quot;
+ icon=&quot;icons/mydoc.gif&quot;
+ participant=&quot;org.eclipse.myPlugin.myPackage.MyGlobalParticipant&quot;
+ headless=&quot;true&quot;/&gt;
+ &lt;searchParticipant id=&quot;org.eclipse.myXYZParticipant&quot;
+ extensions=&quot;xyz&quot;
+ participant=&quot;org.eclipse.myPlugin.myPackage.MyXYZParticipant&quot;/&gt;
+ &lt;/extension&gt;
+&lt;/pre&gt;
+&lt;/p&gt;
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ The supplied search participant class must extend the &lt;samp&gt;org.eclipse.help.search.SearchParticipant&lt;/samp&gt; abstract class.
+ </documentation>
+ </annotation>
+
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ Copyright (c) 2010 IBM Corporation and others.&lt;br&gt;
+All rights reserved. This program and the accompanying materials are made
+available under the terms of the Eclipse Public License v1.0 which accompanies
+this distribution, and is available at &lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/search/HTMLSearchParticipant.java b/org.eclipse.help.base/src/org/eclipse/help/internal/search/HTMLSearchParticipant.java
index 729dc5f6e..def26f9b1 100644
--- a/org.eclipse.help.base/src/org/eclipse/help/internal/search/HTMLSearchParticipant.java
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/search/HTMLSearchParticipant.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2009 IBM Corporation and others.
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -14,19 +14,18 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.content.IContentDescriber;
import org.eclipse.help.internal.base.BaseHelpSystem;
import org.eclipse.help.internal.base.HelpBasePlugin;
import org.eclipse.help.internal.xhtml.XHTMLContentDescriber;
-import org.eclipse.help.search.ISearchIndex;
-import org.eclipse.help.search.LuceneSearchParticipant;
+import org.eclipse.help.search.IHelpSearchIndex;
+import org.eclipse.help.search.ISearchDocument;
+import org.eclipse.help.search.SearchParticipant;
-public class HTMLSearchParticipant extends LuceneSearchParticipant {
+public class HTMLSearchParticipant extends SearchParticipant {
private static final String HELP_BASE_XHTML = "org.eclipse.help.base.xhtml"; //$NON-NLS-1$
private HTMLDocParser parser;
@@ -39,16 +38,17 @@ public class HTMLSearchParticipant extends LuceneSearchParticipant {
this.indexPath = indexPath;
}
- public IStatus addDocument(ISearchIndex index, String pluginId, String name, URL url, String id,
- Document doc) {
+
+ public IStatus addDocument(IHelpSearchIndex index, String pluginId, String name, URL url, String id,
+ ISearchDocument doc) {
// if it's XHTML, forward it on to the proper search participant
if (isXHTML(pluginId, url)) {
LocalSearchManager manager = BaseHelpSystem.getLocalSearchManager();
- LuceneSearchParticipant participant = manager.getParticipant(HELP_BASE_XHTML);
+ SearchParticipant participant = manager.getParticipant(HELP_BASE_XHTML);
if (participant == null) {
participant = getXhtmlParticipant();
}
- return participant.addDocument(index, pluginId, name, url, id, doc);
+ return participant.addDocument((IHelpSearchIndex) index, pluginId, name, url, id, doc);
}
// otherwise, treat it as HTML
else {
@@ -62,13 +62,10 @@ public class HTMLSearchParticipant extends LuceneSearchParticipant {
+ name + " cannot be opened.", //$NON-NLS-1$
null);
}
- doc.add(new Field("contents", parser.getContentReader())); //$NON-NLS-1$
- doc.add(new Field("exact_contents", parser.getContentReader())); //$NON-NLS-1$
+ doc.addContents(parser.getContentReader(), parser.getContentReader());
String title = parser.getTitle();
- doc.add(new Field("title", title, Field.Store.NO, Field.Index.TOKENIZED)); //$NON-NLS-1$
- doc.add(new Field("exact_title", title, Field.Store.NO, Field.Index.TOKENIZED)); //$NON-NLS-1$
- doc.add(new Field("raw_title", title, Field.Store.YES, Field.Index.NO)); //$NON-NLS-1$
- doc.add(new Field("summary", parser.getSummary(title), Field.Store.YES, Field.Index.NO)); //$NON-NLS-1$
+ doc.setTitle(title);
+ doc.setSummary(parser.getSummary(title));
if (parser.getException() != null) {
return new Status(IStatus.ERROR, HelpBasePlugin.PLUGIN_ID, IStatus.ERROR,
"Parse error occurred while adding document " + name //$NON-NLS-1$
@@ -88,7 +85,7 @@ public class HTMLSearchParticipant extends LuceneSearchParticipant {
}
}
- private XHTMLSearchParticipant getXhtmlParticipant() {
+ private SearchParticipant getXhtmlParticipant() {
if (xhtmlParticipant == null) {
xhtmlParticipant = new XHTMLSearchParticipant();
}
@@ -124,4 +121,5 @@ public class HTMLSearchParticipant extends LuceneSearchParticipant {
return false;
}
+
}
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/search/IndexingOperation.java b/org.eclipse.help.base/src/org/eclipse/help/internal/search/IndexingOperation.java
index 55a2765a2..de3dea14a 100644
--- a/org.eclipse.help.base/src/org/eclipse/help/internal/search/IndexingOperation.java
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/search/IndexingOperation.java
@@ -39,7 +39,7 @@ import org.eclipse.help.internal.base.util.HelpProperties;
import org.eclipse.help.internal.protocols.HelpURLConnection;
import org.eclipse.help.internal.toc.Toc;
import org.eclipse.help.internal.toc.TocFileProvider;
-import org.eclipse.help.search.LuceneSearchParticipant;
+import org.eclipse.help.search.SearchParticipant;
/**
* Indexing Operation represents a long operation, which performs indexing of
@@ -372,7 +372,7 @@ class IndexingOperation {
}
}
//Add documents from global search participants
- LuceneSearchParticipant[] participants = BaseHelpSystem.getLocalSearchManager().getGlobalParticipants();
+ SearchParticipant[] participants = BaseHelpSystem.getLocalSearchManager().getGlobalParticipants();
for (int j=0; j<participants.length; j++) {
String participantId;
try {
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/search/LocalSearchManager.java b/org.eclipse.help.base/src/org/eclipse/help/internal/search/LocalSearchManager.java
index 438c9fb47..13edcb6b8 100644
--- a/org.eclipse.help.base/src/org/eclipse/help/internal/search/LocalSearchManager.java
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/search/LocalSearchManager.java
@@ -39,6 +39,7 @@ import org.eclipse.help.internal.base.HelpBasePlugin;
import org.eclipse.help.internal.search.IndexingOperation.IndexingException;
import org.eclipse.help.internal.util.URLCoder;
import org.eclipse.help.search.LuceneSearchParticipant;
+import org.eclipse.help.search.SearchParticipant;
import org.osgi.framework.Bundle;
/*
@@ -46,7 +47,8 @@ import org.osgi.framework.Bundle;
*/
public class LocalSearchManager {
- private static final String SEARCH_PARTICIPANT_XP_FULLNAME = "org.eclipse.help.base.luceneSearchParticipants"; //$NON-NLS-1$
+ private static final String LUCENE_SEARCH_PARTICIPANT_XP_FULLNAME = "org.eclipse.help.base.luceneSearchParticipants"; //$NON-NLS-1$
+ private static final String SEARCH_PARTICIPANT_XP_FULLNAME = "org.eclipse.help.base.searchParticipant"; //$NON-NLS-1$
private static final String SEARCH_PARTICIPANT_XP_NAME = "searchParticipant"; //$NON-NLS-1$
private static final String BINDING_XP_NAME = "binding"; //$NON-NLS-1$
private static final Object PARTICIPANTS_NOT_FOUND = new Object();
@@ -59,7 +61,7 @@ public class LocalSearchManager {
private static class ParticipantDescriptor implements IHelpResource {
private IConfigurationElement element;
- private LuceneSearchParticipant participant;
+ private SearchParticipant participant;
public ParticipantDescriptor(IConfigurationElement element) {
this.element = element;
@@ -86,12 +88,16 @@ public class LocalSearchManager {
return this;
}
- public LuceneSearchParticipant getParticipant() {
+ public SearchParticipant getParticipant() {
if (participant == null) {
try {
Object obj = element.createExecutableExtension("participant"); //$NON-NLS-1$
- if (obj instanceof LuceneSearchParticipant) {
- participant = (LuceneSearchParticipant) obj;
+ if (obj instanceof SearchParticipant) {
+ participant = (SearchParticipant)obj;
+ participant.init(getId());
+ } else if (obj instanceof LuceneSearchParticipant) {
+ LuceneSearchParticipant luceneParticipant = (LuceneSearchParticipant) obj;
+ participant = new LuceneSearchParticipantAdapter(luceneParticipant);
participant.init(getId());
}
} catch (Throwable t) {
@@ -259,7 +265,7 @@ public class LocalSearchManager {
return pluginId;
}
- public LuceneSearchParticipant getGlobalParticipant(String participantId) {
+ public SearchParticipant getGlobalParticipant(String participantId) {
ParticipantDescriptor desc = getGlobalParticipantDescriptor(participantId);
return desc != null ? desc.getParticipant() : null;
}
@@ -294,7 +300,7 @@ public class LocalSearchManager {
* @param participantId the participant's unique id
* @return the participant with the given id
*/
- public LuceneSearchParticipant getParticipant(String participantId) {
+ public SearchParticipant getParticipant(String participantId) {
ParticipantDescriptor desc = (ParticipantDescriptor)searchParticipantsById.get(participantId);
if (desc != null) {
return desc.getParticipant();
@@ -310,7 +316,7 @@ public class LocalSearchManager {
* @return
*/
- public LuceneSearchParticipant getParticipant(String pluginId, String fileName) {
+ public SearchParticipant getParticipant(String pluginId, String fileName) {
ArrayList list = getParticipantDescriptors(pluginId);
if (list == null)
return null;
@@ -354,16 +360,10 @@ public class LocalSearchManager {
public Set getPluginsWithSearchParticipants() {
HashSet set = new HashSet();
- IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(
- SEARCH_PARTICIPANT_XP_FULLNAME);
-
- for (int i = 0; i < elements.length; i++) {
- IConfigurationElement element = elements[i];
- if (element.getName().equals("binding") || element.getName().equals("searchParticipant")) //$NON-NLS-1$//$NON-NLS-2$
- set.add(element.getContributor().getName());
- }
+ addSearchBindings(set);
+ addLuceneSearchBindings(set);
// must ask global search participants directly
- LuceneSearchParticipant[] gps = getGlobalParticipants();
+ SearchParticipant[] gps = getGlobalParticipants();
for (int i = 0; i < gps.length; i++) {
Set ids;
try {
@@ -378,6 +378,28 @@ public class LocalSearchManager {
return set;
}
+ private void addSearchBindings(HashSet set) {
+ IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(
+ SEARCH_PARTICIPANT_XP_FULLNAME);
+
+ for (int i = 0; i < elements.length; i++) {
+ IConfigurationElement element = elements[i];
+ if (element.getName().equals("binding") || element.getName().equals("searchParticipant")) //$NON-NLS-1$//$NON-NLS-2$
+ set.add(element.getContributor().getName());
+ }
+ }
+
+ private void addLuceneSearchBindings(HashSet set) {
+ IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(
+ LUCENE_SEARCH_PARTICIPANT_XP_FULLNAME);
+
+ for (int i = 0; i < elements.length; i++) {
+ IConfigurationElement element = elements[i];
+ if (element.getName().equals("binding") || element.getName().equals("searchParticipant")) //$NON-NLS-1$//$NON-NLS-2$
+ set.add(element.getContributor().getName());
+ }
+ }
+
/**
* Loops through all the loaded search participants and notifies them that they can drop the
* cached data to reduce runtime memory footprint.
@@ -391,12 +413,15 @@ public class LocalSearchManager {
}
private ArrayList createSearchParticipants(String pluginId) {
- IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(
- SEARCH_PARTICIPANT_XP_FULLNAME);
- if (elements.length == 0)
- return null;
ArrayList list = null;
+ list = getBindingsForPlugin(pluginId, list, SEARCH_PARTICIPANT_XP_FULLNAME);
+ list = getBindingsForPlugin(pluginId, list, LUCENE_SEARCH_PARTICIPANT_XP_FULLNAME);
+ return list;
+ }
+ private ArrayList getBindingsForPlugin(String pluginId, ArrayList list, String extensionPointName) {
+ IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(
+ extensionPointName);
ArrayList binding = null;
for (int i = 0; i < elements.length; i++) {
IConfigurationElement element = elements[i];
@@ -410,10 +435,10 @@ public class LocalSearchManager {
IConfigurationElement rel = elements[j];
if (!rel.getName().equals("searchParticipant")) //$NON-NLS-1$
continue;
+ String id = rel.getAttribute("id"); //$NON-NLS-1$
// don't allow binding the global participants
if (rel.getAttribute("extensions") == null) //$NON-NLS-1$
continue;
- String id = rel.getAttribute("id"); //$NON-NLS-1$
if (id != null && id.equals(refId)) {
// match
if (binding == null)
@@ -463,7 +488,7 @@ public class LocalSearchManager {
for (int j = 0; j < participants.size(); j++) {
ParticipantDescriptor desc = (ParticipantDescriptor) participants.get(j);
if (desc.contains(refEl)) {
- // found the matching rescriptor - add it to the list
+ // found the matching descriptor - add it to the list
if (list == null)
list = new ArrayList();
list.add(desc);
@@ -489,22 +514,27 @@ public class LocalSearchManager {
* @return an array of the global search participants.
*/
- public LuceneSearchParticipant[] getGlobalParticipants() {
+ public SearchParticipant[] getGlobalParticipants() {
if (globalSearchParticipants == null) {
createGlobalSearchParticipants();
}
ArrayList result = new ArrayList();
for (int i = 0; i < globalSearchParticipants.size(); i++) {
ParticipantDescriptor desc = (ParticipantDescriptor) globalSearchParticipants.get(i);
- LuceneSearchParticipant p = desc.getParticipant();
+ SearchParticipant p = desc.getParticipant();
if (p != null)
result.add(p);
}
- return (LuceneSearchParticipant[]) result.toArray(new LuceneSearchParticipant[result.size()]);
+ return (SearchParticipant[]) result.toArray(new SearchParticipant[result.size()]);
}
private void createGlobalSearchParticipants() {
globalSearchParticipants = new ArrayList();
+ addSearchParticipants();
+ addLuceneSearchParticipants();
+ }
+
+ private void addSearchParticipants() {
IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(
SEARCH_PARTICIPANT_XP_FULLNAME);
for (int i = 0; i < elements.length; i++) {
@@ -520,6 +550,22 @@ public class LocalSearchManager {
}
}
+ private void addLuceneSearchParticipants() {
+ IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(
+ LUCENE_SEARCH_PARTICIPANT_XP_FULLNAME);
+ for (int i = 0; i < elements.length; i++) {
+ IConfigurationElement element = elements[i];
+ if (!element.getName().equals(SEARCH_PARTICIPANT_XP_NAME))
+ continue;
+ if (element.getAttribute("extensions") != null) //$NON-NLS-1$
+ continue;
+ if (!isParticipantEnabled(String.valueOf(true).equals(element.getAttribute("headless")))) //$NON-NLS-1$
+ continue;
+ ParticipantDescriptor desc = new ParticipantDescriptor(element);
+ globalSearchParticipants.add(desc);
+ }
+ }
+
private ArrayList getParticipantDescriptors(String pluginId) {
Object result = searchParticipantsByPlugin.get(pluginId);
if (result == null) {
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/search/LuceneSearchDocument.java b/org.eclipse.help.base/src/org/eclipse/help/internal/search/LuceneSearchDocument.java
new file mode 100644
index 000000000..beee87072
--- /dev/null
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/search/LuceneSearchDocument.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.help.internal.search;
+
+import java.io.Reader;
+import java.io.StringReader;
+
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+import org.eclipse.help.search.ISearchDocument;
+
+/**
+ * Class which adapts a Lucene Document to ISearchDocument.
+ */
+
+public class LuceneSearchDocument implements ISearchDocument {
+
+ private Document doc;
+
+ public LuceneSearchDocument(Document document) {
+ this.doc = document;
+ }
+
+ public void setTitle(String title) {
+ doc.add(new Field("title", title, Field.Store.NO, Field.Index.TOKENIZED)); //$NON-NLS-1$
+ doc.add(new Field("exact_title", title, Field.Store.NO, Field.Index.TOKENIZED)); //$NON-NLS-1$
+ doc.add(new Field("raw_title", title, Field.Store.YES, Field.Index.NO)); //$NON-NLS-1$
+ }
+
+ public void setSummary(String summary) {
+ doc.add(new Field("summary", summary, Field.Store.YES, Field.Index.NO)); //$NON-NLS-1$
+ }
+
+ public void addContents(String contents) {
+ doc.add(new Field("contents", new StringReader(contents))); //$NON-NLS-1$
+ doc.add(new Field("exact_contents", new StringReader(contents))); //$NON-NLS-1$
+ }
+
+ public void setHasFilters(boolean hasFilters) {
+ doc.add(new Field("filters", Boolean.toString(hasFilters), Field.Store.YES, Field.Index.NO)); //$NON-NLS-1$
+ }
+
+ public Document getDocument() {
+ return doc;
+ }
+
+ public void addContents(Reader contents, Reader exactContents) {
+ doc.add(new Field("contents", contents)); //$NON-NLS-1$
+ doc.add(new Field("exact_contents", exactContents)); //$NON-NLS-1$
+ }
+
+}
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/search/LuceneSearchParticipantAdapter.java b/org.eclipse.help.base/src/org/eclipse/help/internal/search/LuceneSearchParticipantAdapter.java
new file mode 100644
index 000000000..d29e35fcc
--- /dev/null
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/search/LuceneSearchParticipantAdapter.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.help.internal.search;
+
+/**
+ * Adapts a LuceneSearchParticipant to SearchParticipant. This allows
+ * the deprecated extension point org.eclipse.help.base.luceneSearchParticipants
+ * to continue to function even though the rest of the help system has
+ * switched to use the class SearchParticipant instead of LuceneSearchParticipant
+ */
+
+import java.net.URL;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.help.search.IHelpSearchIndex;
+import org.eclipse.help.search.ISearchDocument;
+import org.eclipse.help.search.LuceneSearchParticipant;
+import org.eclipse.help.search.SearchParticipant;
+
+public class LuceneSearchParticipantAdapter extends SearchParticipant {
+
+ private LuceneSearchParticipant searchParticipant;
+
+ public LuceneSearchParticipantAdapter(LuceneSearchParticipant participant) {
+ this.searchParticipant = participant;
+ }
+
+ public IStatus addDocument(IHelpSearchIndex index, String pluginId, String name, URL url, String id,
+ ISearchDocument doc) {
+ // In the help system the only class that implements ISearchDocument is LuceneSearchDocument
+ // and the only class that implements IHelpSearchIndex is SearchIndex
+ LuceneSearchDocument luceneDoc = (LuceneSearchDocument)doc;
+ SearchIndex searchIndex = (SearchIndex) index;
+ return searchParticipant.addDocument(searchIndex, pluginId, name, url, id, luceneDoc.getDocument());
+ }
+
+ public Set getAllDocuments(String locale) {
+ return searchParticipant.getAllDocuments(locale);
+ }
+
+ public void clear() {
+ searchParticipant.clear();
+ }
+
+ public boolean equals(Object obj) {
+ return searchParticipant.equals(obj);
+ }
+
+ public Set getContributingPlugins() {
+ return searchParticipant.getContributingPlugins();
+ }
+
+ public int hashCode() {
+ return searchParticipant.hashCode();
+ }
+
+ public boolean open(String id) {
+ return searchParticipant.open(id);
+ }
+
+}
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java b/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java
index 85a6137ae..56170c95c 100644
--- a/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -60,8 +60,10 @@ import org.eclipse.help.internal.protocols.HelpURLStreamHandler;
import org.eclipse.help.internal.toc.TocFileProvider;
import org.eclipse.help.internal.toc.TocManager;
import org.eclipse.help.internal.util.ResourceLocator;
+import org.eclipse.help.search.IHelpSearchIndex;
+import org.eclipse.help.search.ISearchDocument;
import org.eclipse.help.search.ISearchIndex;
-import org.eclipse.help.search.LuceneSearchParticipant;
+import org.eclipse.help.search.SearchParticipant;
import org.osgi.framework.Bundle;
import org.osgi.framework.Constants;
import org.osgi.framework.Version;
@@ -69,7 +71,7 @@ import org.osgi.framework.Version;
/**
* Text search index. Documents added to this index can than be searched against a search query.
*/
-public class SearchIndex implements ISearchIndex {
+public class SearchIndex implements ISearchIndex, IHelpSearchIndex {
private IndexReader ir;
@@ -192,8 +194,8 @@ public class SearchIndex implements ISearchIndex {
if (relativePath != null) {
doc.add(new Field(FIELD_INDEX_ID, relativePath, Field.Store.YES, Field.Index.UN_TOKENIZED));
}
- // NEW: check for the explicit search participant.
- LuceneSearchParticipant participant = null;
+ // check for the explicit search participant.
+ SearchParticipant participant = null;
HelpURLConnection urlc = new HelpURLConnection(url);
String id = urlc.getValue("id"); //$NON-NLS-1$
String pid = urlc.getValue("participantId"); //$NON-NLS-1$
@@ -203,7 +205,7 @@ public class SearchIndex implements ISearchIndex {
if (participant == null)
participant = BaseHelpSystem.getLocalSearchManager().getParticipant(pluginId, name);
if (participant != null) {
- IStatus status = participant.addDocument(this, pluginId, name, url, id, doc);
+ IStatus status = participant.addDocument(this, pluginId, name, url, id, new LuceneSearchDocument(doc));
if (status.getSeverity() == IStatus.OK) {
String filters = doc.get("filters"); //$NON-NLS-1$
indexedDocs.put(name, filters != null ? filters : "0"); //$NON-NLS-1$
@@ -216,7 +218,7 @@ public class SearchIndex implements ISearchIndex {
return status;
}
// default to html
- IStatus status = htmlSearchParticipant.addDocument(this, pluginId, name, url, id, doc);
+ IStatus status = htmlSearchParticipant.addDocument(this, pluginId, name, url, id, new LuceneSearchDocument(doc));
if (status.getSeverity() == IStatus.OK) {
String filters = doc.get("filters"); //$NON-NLS-1$
indexedDocs.put(name, filters != null ? filters : "0"); //$NON-NLS-1$
@@ -1045,11 +1047,11 @@ public class SearchIndex implements ISearchIndex {
public IStatus addDocument(String pluginId, String name, URL url, String id, Document doc) {
// try a registered participant for the file format
- LuceneSearchParticipant participant = BaseHelpSystem.getLocalSearchManager()
+ SearchParticipant participant = BaseHelpSystem.getLocalSearchManager()
.getParticipant(pluginId, name);
if (participant != null) {
try {
- return participant.addDocument(this, pluginId, name, url, id, doc);
+ return participant.addDocument(this, pluginId, name, url, id, new LuceneSearchDocument(doc));
}
catch (Throwable t) {
return new Status(IStatus.ERROR, HelpBasePlugin.PLUGIN_ID, IStatus.ERROR,
@@ -1058,6 +1060,12 @@ public class SearchIndex implements ISearchIndex {
}
}
// default to html
- return htmlSearchParticipant.addDocument(this, pluginId, name, url, id, doc);
+ return htmlSearchParticipant.addDocument(this, pluginId, name, url, id, new LuceneSearchDocument(doc));
+ }
+
+ public IStatus addSearchableDocument(String pluginId, String name, URL url, String id, ISearchDocument doc) {
+ // In the help system the only class that implements ISearchDocument is LuceneSearchDocument
+ LuceneSearchDocument luceneDoc = (LuceneSearchDocument)doc;
+ return addDocument(pluginId, name, url, id, luceneDoc.getDocument());
}
}
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/search/XHTMLSearchParticipant.java b/org.eclipse.help.base/src/org/eclipse/help/internal/search/XHTMLSearchParticipant.java
index 761f58455..b14f639fc 100644
--- a/org.eclipse.help.base/src/org/eclipse/help/internal/search/XHTMLSearchParticipant.java
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/search/XHTMLSearchParticipant.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2009 IBM Corporation and others.
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -16,13 +16,13 @@ import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.help.internal.base.HelpBasePlugin;
import org.eclipse.help.internal.xhtml.DynamicXHTMLProcessor;
-import org.eclipse.help.search.XMLSearchParticipant;
+import org.eclipse.help.search.SearchParticipantXML;
import org.xml.sax.Attributes;
/**
* The search participant responsible for indexing XHTML documents.
*/
-public class XHTMLSearchParticipant extends XMLSearchParticipant {
+public class XHTMLSearchParticipant extends SearchParticipantXML {
private static final String KEYWORDS = "keywords"; //$NON-NLS-1$
private static final String META_TAG = "meta"; //$NON-NLS-1$
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/search/federated/LocalHelp.java b/org.eclipse.help.base/src/org/eclipse/help/internal/search/federated/LocalHelp.java
index 9bf6a4290..79dbd0225 100644
--- a/org.eclipse.help.base/src/org/eclipse/help/internal/search/federated/LocalHelp.java
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/search/federated/LocalHelp.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -92,7 +92,7 @@ public class LocalHelp implements ISearchEngine2 {
return false;
String participantId = id.substring(0, sep);
id = id.substring(sep+1);
- LuceneSearchParticipant participant = BaseHelpSystem.getLocalSearchManager().getGlobalParticipant(participantId);
+ SearchParticipant participant = BaseHelpSystem.getLocalSearchManager().getGlobalParticipant(participantId);
if (participant==null)
return false;
try {
diff --git a/org.eclipse.help.base/src/org/eclipse/help/search/IHelpSearchIndex.java b/org.eclipse.help.base/src/org/eclipse/help/search/IHelpSearchIndex.java
new file mode 100644
index 000000000..03b73058a
--- /dev/null
+++ b/org.eclipse.help.base/src/org/eclipse/help/search/IHelpSearchIndex.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.help.search;
+
+import java.net.URL;
+
+
+import org.eclipse.core.runtime.IStatus;
+
+/**
+ * Represents a Lucene index for one locale. The interface is used
+ * to allow participants to delegate indexing of documents outside
+ * of the TOC using the same algorithms as those in TOC.
+ *
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @since 3.5
+ */
+
+public interface IHelpSearchIndex {
+
+ /**
+ * Adds a document to the search index database by parsing it using one of the file-based search
+ * participants, or the default HTML search participant. Use this method when encountering
+ * documents outside of TOC that are nevertheless of the known format and help system knows how
+ * to handle.
+ *
+ * @param pluginId
+ * the id of the contributing plug-in
+ * @param name
+ * the name of the document
+ * @param url
+ * the URL of the document using format '/pluginId/href'
+ * @param id
+ * the unique id of this document as defined in the participant
+ * @param doc
+ * the document to be added
+ * @return the status of the operation
+ */
+ IStatus addSearchableDocument(String pluginId, String name, URL url, String id, ISearchDocument doc);
+
+ /**
+ * A search index is created for each locale.
+ * @return the locale associated with this index.
+ */
+ String getLocale();
+}
diff --git a/org.eclipse.help.base/src/org/eclipse/help/search/ISearchDocument.java b/org.eclipse.help.base/src/org/eclipse/help/search/ISearchDocument.java
new file mode 100644
index 000000000..30799a225
--- /dev/null
+++ b/org.eclipse.help.base/src/org/eclipse/help/search/ISearchDocument.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.help.search;
+
+import java.io.Reader;
+
+/**
+ * Represents a document in the search index. This interface is used by
+ * clients which implement the search participant extension point. While the
+ * help system uses the Lucene classes internally this interface does not
+ * import anything from Lucene and enables the API for adding search participants
+ * to remain binary compatible whatever changes are made in Lucene.
+ *
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @since 3.5
+ */
+
+public interface ISearchDocument {
+
+ /**
+ * @param title the title which will be shown in the search results summary.
+ * This function should be called exactly once per document
+ */
+ public void setTitle(String title);
+
+ /**
+ * @param summary the summary which will be used when displaying search results.
+ * This function should be called exactly once per document
+ */
+ public void setSummary(String summary);
+
+ /**
+ * @param contents the text which will be used when performing a search. The search index
+ * will parse the contents and store the results in a database for rapid retrieval.
+ */
+ public void addContents(String contents);
+
+ /**
+ * Alternate way of adding contents which is closer to the API for the
+ * deprecated extension point org.eclipse.help.base.luceneSearchParticipants.
+ * This is provided for backward compatibility, most users will find it simpler
+ * to use <code>addContents(String)</code>
+ * @param contents a Reader object which provides the contents
+ * @param exactContents a second Reader object which contains the same same contents
+ */
+ public void addContents(Reader contents, Reader exactContents);
+
+ /**
+ * Allows search participant to indicate that a document will be processed
+ * at runtime and that parts of the contents may not be displayed to the
+ * user, causing a match in the search to be shown as a potential match.
+ * By default documents are considered to be unfiltered so this function
+ * need only be called to indicate that a document is filtered
+ */
+ public void setHasFilters(boolean hasFilters);
+
+}
diff --git a/org.eclipse.help.base/src/org/eclipse/help/search/ISearchIndex.java b/org.eclipse.help.base/src/org/eclipse/help/search/ISearchIndex.java
index 05a71040c..c45b58a97 100644
--- a/org.eclipse.help.base/src/org/eclipse/help/search/ISearchIndex.java
+++ b/org.eclipse.help.base/src/org/eclipse/help/search/ISearchIndex.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -19,6 +19,13 @@ import org.eclipse.core.runtime.IStatus;
* Represents a Lucene index for one locale. The interface is used
* to allow participants to delegate indexing of documents outside
* of the TOC using the same algorithms as those in TOC.
+ * @deprecated
+ * This interface is deprecated because it exposes Lucene classes,
+ * which are not binary compatible between major release. This
+ * interface was used by clients which implemented the extension
+ * point org.eclipse.help.bace.luceneSearchParticipants. The
+ * extension point org.eclipse.help.base.searchParticipant
+ * and the interface IHelpSearchIndex should be used instead.
*/
public interface ISearchIndex {
diff --git a/org.eclipse.help.base/src/org/eclipse/help/search/LuceneSearchParticipant.java b/org.eclipse.help.base/src/org/eclipse/help/search/LuceneSearchParticipant.java
index a65e4fc48..6a19f1b25 100644
--- a/org.eclipse.help.base/src/org/eclipse/help/search/LuceneSearchParticipant.java
+++ b/org.eclipse.help.base/src/org/eclipse/help/search/LuceneSearchParticipant.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2007 IBM Corporation and others.
+ * Copyright (c) 2006, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -51,6 +51,11 @@ import org.osgi.framework.Bundle;
* </ol>
*
* @since 3.2
+ * @deprecated
+ * This class is deprecated because it exposes Lucene classes,
+ * which are not binary compatible between major release. The
+ * extension point org.eclipse.help.base.searchParticipant
+ * and the class SearchParticipant should be used instead.
*/
public abstract class LuceneSearchParticipant {
diff --git a/org.eclipse.help.base/src/org/eclipse/help/search/SearchParticipant.java b/org.eclipse.help.base/src/org/eclipse/help/search/SearchParticipant.java
new file mode 100644
index 000000000..708954c9a
--- /dev/null
+++ b/org.eclipse.help.base/src/org/eclipse/help/search/SearchParticipant.java
@@ -0,0 +1,190 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.help.search;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.help.internal.util.ResourceLocator;
+import org.osgi.framework.Bundle;
+
+/**
+ * Participant in the help search. A plug-in can contribute instance of SearchParticipant to
+ * <code>"org.eclipse.help.search.searchParticipant"</code> extension point. Search
+ * participant is responsible for adding the content of documents it is responsible for into the
+ * help system's search index. Once in the index, the document becomes searchable and can produce
+ * search hits. There are two ways of using the participant:
+ * <ol>
+ * <li> For adding documents that are part of the help's TOC that have content formats not known to
+ * the default indexer (which are essentially all documents that are not of HTML format). In this
+ * case, the help system knows about the documents because they are in TOC but does not know how to
+ * index them. Because of the non-HTML format, help search participants are normally accompanied by
+ * the help content producers that are responsible for transforming the unknown format into HTML on
+ * the fly. <br>
+ * <br>
+ * When used in this mode, search participants must be registered with file extensions they handle.
+ * Based on the file extension mapping, they will be the first to get a chance at indexing the
+ * document with the matching extension.<br>
+ * <br>
+ * </li>
+ * <li> For adding documents that are outside of the help's TOC. In this case, the documents are
+ * completely unknown to the help system. Search participants are responsible for providing a set of
+ * documents they know about and are not supposed to declare file extensions they can handle. They
+ * are also responsible for opening these documents when asked because the help system will not be
+ * able to open them in any meaningful way. </li>
+ * </ol>
+ *
+ * @since 3.5
+ */
+public abstract class SearchParticipant {
+
+ private static final HashSet EMPTY_SET = new HashSet();
+
+ private String id;
+
+ /**
+ * Initializes the participant with the unique identifier from the registry. The method is
+ * called by the help system - subclasses are not supposed to call it.
+ *
+ * @param id
+ * the unique identifier of this participant
+ */
+
+ public final void init(String id) {
+ this.id = id;
+ }
+
+ /**
+ * Returns the unique identifier of this participant.
+ *
+ * @return the unique id
+ */
+ public final String getId() {
+ return id;
+ }
+
+ /**
+ * Adds the document to the search index.
+ *
+ * @param index
+ * the abstract representation of the help index that is currently running. Indexing
+ * known file types in participants that manage documents outside the TOC can be
+ * delegated to the index.
+ * @param pluginId
+ * the plug-in that owns the document
+ * @param name
+ * the name of the document to index
+ * @param url
+ * the url of the document to index
+ * @param id
+ * the unique id associated with this document
+ * @param doc
+ * the document to add searchable content to
+ * @return the status of the indexing operation. A successful operation should return
+ * <code>Status.OK</code>.
+ */
+ public abstract IStatus addDocument(IHelpSearchIndex index, String pluginId, String name, URL url, String id,
+ ISearchDocument doc);
+
+ /**
+ * Returns all the documents that this participant knows about. This method is only used for
+ * participants that handle documents outside of the help system's TOC.
+ *
+ * @param locale
+ * the index locale
+ *
+ * @return a set of hrefs for documents managed by this participant.
+ */
+ public Set getAllDocuments(String locale) {
+ return EMPTY_SET;
+ }
+
+ /**
+ * Returns a set of identifiers of plug-ins that contribute indexable documents. This method is
+ * only used for participants that handle documents outside of the help system's TOC.
+ *
+ * @return a set of contributing plug-in ids
+ */
+
+ public Set getContributingPlugins() {
+ return EMPTY_SET;
+ }
+
+ /**
+ * A utility method that resolves a file name that contains '$'-based substitution variables.
+ *
+ * @param pluginId
+ * the identifier of the originating plug-in
+ * @param fileName
+ * the source file name
+ * @param locale
+ * the locale to use when resolving nl variable
+ * @return the plug-in relative file name with resolved variables
+ */
+
+ protected static String resolveVariables(String pluginId, String fileName, String locale) {
+ if (fileName.indexOf('$') == -1)
+ return fileName;
+ ArrayList prefix = ResourceLocator.getPathPrefix(locale);
+ Bundle bundle = Platform.getBundle(pluginId);
+ if (bundle == null)
+ return fileName;
+ URL url = ResourceLocator.find(bundle, new Path(fileName), prefix);
+ URL root = FileLocator.find(bundle, new Path(""), null); //$NON-NLS-1$
+ return url.toString().substring(root.toString().length());
+ }
+
+ /**
+ * A utility method that adds a title to the document.
+ *
+ * @param title
+ * the title string
+ * @param doc
+ * the document
+ */
+
+ protected void addTitle(String title, ISearchDocument doc) {
+ doc.setTitle(title);
+ }
+
+ /**
+ * Help system does not know how to open documents outside of the system's TOC. Global search
+ * participants that bring additional documents into the index when
+ * <code>getAllDocuments(String)</code> have a chance to open the document when it is part of
+ * the search results. The default implementation returns <code>false</code> indicating that
+ * the help system should open the document. In most cases this is wrong for most of XML files
+ * that are in some interesting way.
+ *
+ * @param id
+ * a participant-specific identifier that completely represents a search result
+ *
+ * @return <code>true</code> if the file has been opened correctly or <code>false</code> to
+ * allow the help system to try to open the document.
+ */
+
+ public boolean open(String id) {
+ return false;
+ }
+
+ /**
+ * Signals to the participant that the indexing operation has finished and that cached resources
+ * can be disposed to free up memory. The participant itself is still kept around (hence this is
+ * semantically different from <code>dispose</code>).
+ */
+ public void clear() {
+ }
+}
diff --git a/org.eclipse.help.base/src/org/eclipse/help/search/SearchParticipantXML.java b/org.eclipse.help.base/src/org/eclipse/help/search/SearchParticipantXML.java
new file mode 100644
index 000000000..e3b9073cc
--- /dev/null
+++ b/org.eclipse.help.base/src/org/eclipse/help/search/SearchParticipantXML.java
@@ -0,0 +1,385 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.help.search;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.net.URL;
+import java.util.Stack;
+
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.help.internal.base.HelpBasePlugin;
+import org.eclipse.help.internal.dynamic.DocumentReader;
+import org.eclipse.help.internal.dynamic.ExtensionHandler;
+import org.eclipse.help.internal.dynamic.IncludeHandler;
+import org.eclipse.help.internal.dynamic.ProcessorHandler;
+import org.eclipse.help.internal.dynamic.XMLProcessor;
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * An abstract search participants for adding XML documents to the search index. Subclass it
+ * and implement or override protected methods to handle parsing of the document.
+ *
+ * @since 3.5
+ */
+public abstract class SearchParticipantXML extends SearchParticipant {
+ private Stack stack = new Stack();
+ private SAXParser parser;
+ private XMLProcessor processor;
+ private boolean hasFilters;
+
+ /**
+ * Class that implements this interface is used to store data obtained during the parsing phase.
+ */
+ protected interface IParsedXMLContent {
+
+ /**
+ * Returns the locale of the index.
+ *
+ * @return the locale string
+ */
+ String getLocale();
+
+ /**
+ * Sets the title of the parsed document for indexing.
+ *
+ * @param title
+ * the document title
+ */
+ void setTitle(String title);
+
+ /**
+ * Sets the optional summary of the parsed document that can be later rendered for the
+ * search hits.
+ *
+ * @param summary
+ * the short document summary
+ */
+ void addToSummary(String summary);
+
+ /**
+ * Adds the text to the content buffer for indexing.
+ *
+ * @param text
+ * the text to add to the document content buffer
+ */
+ void addText(String text);
+ }
+
+ private static class ParsedXMLContent implements IParsedXMLContent {
+ private StringBuffer buffer = new StringBuffer();
+ private StringBuffer summary = new StringBuffer();
+ private String title;
+ private String locale;
+ private static int SUMMARY_LENGTH = 200;
+
+ public ParsedXMLContent(String locale) {
+ this.locale = locale;
+ }
+
+ public String getLocale() {
+ return locale;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public void addToSummary(String text) {
+ if (summary.length() >= SUMMARY_LENGTH)
+ return;
+ if (summary.length() > 0)
+ summary.append(" "); //$NON-NLS-1$
+ summary.append(text);
+ if (summary.length() > SUMMARY_LENGTH)
+ summary.delete(SUMMARY_LENGTH, summary.length());
+ }
+
+ public void addText(String text) {
+ if (buffer.length() > 0)
+ buffer.append(" "); //$NON-NLS-1$
+ buffer.append(text);
+ }
+
+ public String getContent() {
+ return buffer.toString();
+ }
+
+ public String getSummary() {
+ // if the summary starts with the title, trim that part off.
+ String summaryStr = summary.toString();
+ if (title != null && summaryStr.length() >= title.length()) {
+ String header = summaryStr.substring(0, title.length());
+ if (header.equalsIgnoreCase(title)) {
+ return summaryStr.substring(title.length()).trim();
+ }
+ }
+ return summaryStr;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+ }
+
+ private class XMLHandler extends DefaultHandler {
+
+ public ParsedXMLContent data;
+
+ public XMLHandler(ParsedXMLContent data) {
+ this.data = data;
+ }
+
+ public void startElement(String uri, String localName, String qName, Attributes attributes)
+ throws SAXException {
+ stack.push(qName);
+ handleStartElement(qName, attributes, data);
+ if (attributes.getValue("filter") != null || qName.equalsIgnoreCase("filter")) { //$NON-NLS-1$ //$NON-NLS-2$
+ hasFilters = true;
+ }
+ }
+
+ public void endElement(String uri, String localName, String qName) throws SAXException {
+ handleEndElement(qName, data);
+ String top = (String) stack.peek();
+ if (top != null && top.equals(qName))
+ stack.pop();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.xml.sax.helpers.DefaultHandler#startDocument()
+ */
+ public void startDocument() throws SAXException {
+ SearchParticipantXML.this.handleStartDocument(data);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.xml.sax.helpers.DefaultHandler#endDocument()
+ */
+ public void endDocument() throws SAXException {
+ SearchParticipantXML.this.handleEndDocument(data);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.xml.sax.helpers.DefaultHandler#processingInstruction(java.lang.String,
+ * java.lang.String)
+ */
+ public void processingInstruction(String target, String pidata) throws SAXException {
+ handleProcessingInstruction(target, data);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.xml.sax.helpers.DefaultHandler#characters(char[], int, int)
+ */
+ public void characters(char[] characters, int start, int length) throws SAXException {
+ if (length == 0)
+ return;
+ StringBuffer buff = new StringBuffer();
+ for (int i = 0; i < length; i++) {
+ buff.append(characters[start + i]);
+ }
+ String text = buff.toString();
+ if (text.trim().length() > 0)
+ handleText(text, data);
+ }
+
+ /*
+ * Note: throws clause does not declare IOException due to a bug in
+ * sun jdk: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6327149
+ *
+ * @see org.xml.sax.helpers.DefaultHandler#resolveEntity(java.lang.String, java.lang.String)
+ */
+ public InputSource resolveEntity(String publicId, String systemId) throws SAXException {
+ return new InputSource(new StringReader("")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Called when the element has been started.
+ *
+ * @param name
+ * the element name
+ * @param attributes
+ * the element attributes
+ * @param data
+ * data the parser content data to update
+ */
+ protected abstract void handleStartElement(String name, Attributes attributes, IParsedXMLContent data);
+
+ /**
+ * Called when the element has been ended.
+ *
+ * @param name
+ * the name of the XML element
+ * @param data
+ * data the parser content data to update
+ */
+ protected abstract void handleEndElement(String name, IParsedXMLContent data);
+
+ /**
+ * Called when the XML document has been started.
+ *
+ * @param data
+ * data the parser content data to update
+ */
+ protected void handleStartDocument(IParsedXMLContent data) {
+ }
+
+ /**
+ * Called when the XML document has been ended.
+ *
+ * @param data
+ * data the parser content data to update
+ */
+ protected void handleEndDocument(IParsedXMLContent data) {
+ }
+
+ /**
+ * Called when a processing instruction has been encountered.
+ *
+ * @param type
+ * the instruction data
+ * @param data
+ * the parser content data to update
+ */
+ protected void handleProcessingInstruction(String type, IParsedXMLContent data) {
+ }
+
+ /**
+ * Called when element body text has been encountered. Use 'getElementStackPath()' to determine
+ * the element in question.
+ *
+ * @param text
+ * the body text
+ * @param data
+ * the parser content data to update
+ */
+ protected abstract void handleText(String text, IParsedXMLContent data);
+
+
+ public IStatus addDocument(IHelpSearchIndex index, String pluginId,
+ String name, URL url, String id, ISearchDocument doc) {
+ InputStream stream = null;
+ try {
+ if (parser == null) {
+ parser = SAXParserFactory.newInstance().newSAXParser();
+ }
+ stack.clear();
+ hasFilters = false;
+ ParsedXMLContent parsed = new ParsedXMLContent(index.getLocale());
+ XMLHandler handler = new XMLHandler(parsed);
+ stream = url.openStream();
+ stream = preprocess(stream, name, index.getLocale());
+ parser.parse(stream, handler);
+ doc.addContents(parsed.getContent());
+ String title = parsed.getTitle();
+ if (title != null)
+ addTitle(title, doc);
+ String summary = parsed.getSummary();
+ if (summary != null)
+ doc.setSummary(summary);
+ if (hasFilters) {
+ doc.setHasFilters(true);
+ }
+ return Status.OK_STATUS;
+ } catch (Exception e) {
+ return new Status(IStatus.ERROR, HelpBasePlugin.PLUGIN_ID, IStatus.ERROR,
+ "Exception occurred while adding document " + name //$NON-NLS-1$
+ + " to index.", //$NON-NLS-1$
+ e);
+ } finally {
+ if (stream != null) {
+ try {
+ stream.close();
+ } catch (IOException e) {
+ }
+ stream = null;
+ }
+ }
+ }
+
+ /**
+ * Returns the name of the element that is currently at the top of the element stack.
+ *
+ * @return the name of the element that is currently at the top of the element stack
+ */
+
+ protected String getTopElement() {
+ return (String) stack.peek();
+ }
+
+ /**
+ * Returns the full path of the current element in the stack separated by the '/' character.
+ *
+ * @return the path to the current element in the stack.
+ */
+ protected String getElementStackPath() {
+ StringBuffer buf = new StringBuffer();
+ for (int i = 0; i < stack.size(); i++) {
+ if (i > 0)
+ buf.append("/"); //$NON-NLS-1$
+ buf.append((String) stack.get(i));
+ }
+ return buf.toString();
+ }
+
+ /**
+ * <p>
+ * Pre-processes the given document input stream for the given document name and locale.
+ * This implementation will resolve dynamic content that is applicable to searching,
+ * e.g. includes and extensions, but not filters. Subclasses may override to do their
+ * own pre-processing.
+ * </p>
+ * <p>
+ * For performance, implementations that handle documents that do not support dynamic
+ * content should subclass and return the original stream.
+ * </p>
+ *
+ * @param in the input stream for the document content
+ * @param name the name of the document as it appears in the index
+ * @param locale the locale code, e.g. "en_US"
+ * @return the processed content
+ * @since 3.3
+ */
+ protected InputStream preprocess(InputStream in, String name, String locale) {
+ if (processor == null) {
+ DocumentReader reader = new DocumentReader();
+ processor = new XMLProcessor(new ProcessorHandler[] {
+ new IncludeHandler(reader, locale),
+ new ExtensionHandler(reader, locale)
+ });
+ }
+ try {
+ return processor.process(in, name, null);
+ }
+ catch (Throwable t) {
+ String msg = "An error occured while pre-processing user assistance document \"" + name + "\" for search indexing"; //$NON-NLS-1$ //$NON-NLS-2$
+ HelpBasePlugin.logError(msg, t);
+ return in;
+ }
+ }
+}
diff --git a/org.eclipse.help.base/src/org/eclipse/help/search/XMLSearchParticipant.java b/org.eclipse.help.base/src/org/eclipse/help/search/XMLSearchParticipant.java
index 626f72f33..abe7927a7 100644
--- a/org.eclipse.help.base/src/org/eclipse/help/search/XMLSearchParticipant.java
+++ b/org.eclipse.help.base/src/org/eclipse/help/search/XMLSearchParticipant.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -40,6 +40,11 @@ import org.xml.sax.helpers.DefaultHandler;
* and implement or override protected methods to handle parsing of the document.
*
* @since 3.2
+ * * @deprecated
+ * This class is deprecated because it exposes Lucene classes,
+ * which are not binary compatible between major release. The
+ * extension point org.eclipse.help.base.searchParticipant
+ * and the class SearchParticipantXML should be used instead.
*/
public abstract class XMLSearchParticipant extends LuceneSearchParticipant {
private Stack stack = new Stack();
diff --git a/org.eclipse.ua.tests/data/help/search/participant_xml_1.xml b/org.eclipse.ua.tests/data/help/search/participant_xml_1.xml
new file mode 100644
index 000000000..74d095c4a
--- /dev/null
+++ b/org.eclipse.ua.tests/data/help/search/participant_xml_1.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Copyright (c) 2010 IBM Corporation and others.
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html
+
+ Contributors:
+ IBM Corporation - initial API and implementation
+ -->
+
+<participant title = "Participant XML 1">
+ <text title="ignored title" summary = "Summary for">
+ search word jfplepdl
+ </text>
+ <text summary = "file Participant XML1">
+ search word memdjkemd
+ </text>
+</participant>
+
diff --git a/org.eclipse.ua.tests/data/help/search/participant_xml_2.xml b/org.eclipse.ua.tests/data/help/search/participant_xml_2.xml
new file mode 100644
index 000000000..fea9fc6ae
--- /dev/null
+++ b/org.eclipse.ua.tests/data/help/search/participant_xml_2.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Copyright (c) 2010 IBM Corporation and others.
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html
+
+ Contributors:
+ IBM Corporation - initial API and implementation
+ -->
+
+<outer>
+<participant title = "Participant XML 2 - tests nesting">
+ <text title="ignored title" summary = "Summary for">
+ search word odoeofoedo
+ <text summary = "file Participant XML2">
+ search word odkeofkeks
+ </text>
+ </text>
+</participant>
+</outer>
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/AllSearchTests.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/AllSearchTests.java
index 3d0198b60..18c06fa12 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/AllSearchTests.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/AllSearchTests.java
@@ -38,6 +38,8 @@ public class AllSearchTests extends TestSuite {
addTest(SearchIntro.suite());
addTest(EncodedCharacterSearch.suite());
addTest(MetaKeywords.suite());
+ addTest(SearchParticipantTest.suite());
+ addTest(SearchParticipantXMLTest.suite());
addTest(LuceneParticipantTest.suite());
addTest(LuceneXMLParticipantTest.suite());
}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/MockSearchParticipant.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/MockSearchParticipant.java
new file mode 100644
index 000000000..fc0189472
--- /dev/null
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/MockSearchParticipant.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.ua.tests.help.search;
+
+import java.net.URL;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.help.search.IHelpSearchIndex;
+import org.eclipse.help.search.ISearchDocument;
+import org.eclipse.help.search.SearchParticipant;
+
+public class MockSearchParticipant extends SearchParticipant {
+
+ private static final String DOC_1 = "/org.eclipse.ua.tests/participant1.xml";
+ private static final String DOC_2 = "/org.eclipse.ua.tests/participant2.xml";
+
+ public Set getAllDocuments(String locale) {
+ HashSet set = new HashSet();
+ set.add(DOC_1);
+ set.add(DOC_2);
+ return set;
+ }
+
+ public IStatus addDocument(IHelpSearchIndex index, String pluginId,
+ String name, URL url, String id, ISearchDocument doc) {
+ boolean isDoc1 = url.getPath().equals(DOC_1) ;
+ String title = isDoc1 ? "Title1" : "Title2";
+ String summary = isDoc1? "Summary1" : "Summary2";
+ String contents = isDoc1? "jkijkijkk frgeded" : "olhoykk lgktihku";
+ doc.setTitle(title);
+ doc.setSummary(summary);
+ doc.addContents(contents);
+ return Status.OK_STATUS;
+ }
+
+}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/MockSearchParticipantXML.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/MockSearchParticipantXML.java
new file mode 100644
index 000000000..1f45b4797
--- /dev/null
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/MockSearchParticipantXML.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.ua.tests.help.search;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.help.search.SearchParticipantXML;
+import org.xml.sax.Attributes;
+
+public class MockSearchParticipantXML extends SearchParticipantXML {
+
+ public static final String DOC_1 = "/org.eclipse.ua.tests/data/help/search/participant_xml_1.xml";
+ public static final String DOC_2 = "/org.eclipse.ua.tests/data/help/search/participant_xml_2.xml";
+
+ public Set getAllDocuments(String locale) {
+ HashSet set = new HashSet();
+ set.add(DOC_1 + "?id=xml1" + "?id=xml2");
+ set.add(DOC_2);
+ return set;
+ }
+
+ public Set getContributingPlugins() {
+ Set result = new HashSet();
+ result.add("org.eclipse.ua.tests");
+ return result;
+ }
+
+ protected void handleStartElement(String name, Attributes attributes,
+ IParsedXMLContent data) {
+ if ("participant".equalsIgnoreCase(name)) {
+ data.setTitle(attributes.getValue("title"));
+ }
+ String summary = attributes.getValue("summary");
+ if (summary != null) {
+ data.addToSummary(summary);
+ }
+ }
+
+ protected void handleEndElement(String name, IParsedXMLContent data) {
+ }
+
+ protected void handleText(String text, IParsedXMLContent data) {
+ String top = getTopElement();
+ if ("text".equalsIgnoreCase(top)) {
+ data.addText(text);
+ }
+ }
+
+ public boolean open(String id) {
+ System.out.println("Open " + id);
+ return true;
+ }
+
+}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/SearchParticipantTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/SearchParticipantTest.java
new file mode 100644
index 000000000..223e42a99
--- /dev/null
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/SearchParticipantTest.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ua.tests.help.search;
+
+
+import org.eclipse.help.internal.search.SearchHit;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+
+public class SearchParticipantTest extends TestCase {
+
+ /*
+ * Returns an instance of this Test.
+ */
+ public static Test suite() {
+ return new TestSuite(SearchParticipantTest.class);
+ }
+
+ public void testSearchFirstWordInFirstDoc() {
+ SearchTestUtils.searchAllLocales("jkijkijkk", new String[] { "/org.eclipse.ua.tests/participant1.xml" });
+ }
+
+ public void testSearchLastWordInFirstDoc() {
+ SearchTestUtils.searchAllLocales("frgeded", new String[] { "/org.eclipse.ua.tests/participant1.xml" });
+ }
+
+ public void testSearchUsingAndInFirstDoc() {
+ SearchTestUtils.searchAllLocales("jkijkijkk AND frgeded", new String[] { "/org.eclipse.ua.tests/participant1.xml" });
+ }
+
+ public void testSearchUsingAndInSeparateDocs() {
+ SearchTestUtils.searchAllLocales("jduehdye and olhoykk", new String[0]);
+ }
+
+ public void testSearchExactMatch() {
+ SearchTestUtils.searchAllLocales("\"jkijkijkk frgeded\"", new String[] { "/org.eclipse.ua.tests/participant1.xml" });
+ }
+
+ public void testSearchExactMatchNotFound() {
+ SearchTestUtils.searchAllLocales("\"frgeded jkijkijkk\"", new String[0]);
+ }
+
+ public void testSearchWordInSecondDoc() {
+ SearchTestUtils.searchAllLocales("olhoykk", new String[] { "/org.eclipse.ua.tests/participant2.xml" });
+ }
+
+ public void testReturnedTitle() {
+ SearchHit[] hits = SearchTestUtils.getSearchHits("jkijkijkk", "en");
+ assertEquals(hits.length,1);
+ assertEquals("Title1", hits[0].getLabel());
+ }
+
+ public void testReturnedSummary() {
+ SearchHit[] hits = SearchTestUtils.getSearchHits("jkijkijkk", "en");
+ assertEquals(hits.length,1);
+ assertEquals("Summary1", hits[0].getSummary());
+ }
+
+}
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/SearchParticipantXMLTest.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/SearchParticipantXMLTest.java
new file mode 100644
index 000000000..181c3644e
--- /dev/null
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/SearchParticipantXMLTest.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ua.tests.help.search;
+
+
+import org.eclipse.help.internal.search.SearchHit;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+
+public class SearchParticipantXMLTest extends TestCase {
+
+ /*
+ * Returns an instance of this Test.
+ */
+ public static Test suite() {
+ return new TestSuite(SearchParticipantXMLTest.class);
+ }
+
+ public void testSearchFirstWordInFirstDoc() {
+ SearchTestUtils.searchAllLocales("jfplepdl", new String[] { MockSearchParticipantXML.DOC_1 });
+ }
+
+ public void testSearchLastWordInFirstDoc() {
+ SearchTestUtils.searchAllLocales("memdjkemd", new String[] { MockSearchParticipantXML.DOC_1 });
+ }
+
+ public void testSearchWordFromOuterElement() {
+ SearchTestUtils.searchAllLocales("odoeofoedo", new String[] { MockSearchParticipantXML.DOC_2 });
+ }
+
+ public void testSearchWordFromNestedElement() {
+ SearchTestUtils.searchAllLocales("odkeofkeks", new String[] { MockSearchParticipantXML.DOC_2 });
+ }
+
+ public void testReturnedTitle() {
+ SearchHit[] hits = SearchTestUtils.getSearchHits("jfplepdl", "en");
+ assertEquals(hits.length,1);
+ assertEquals("Participant XML 1", hits[0].getLabel());
+ }
+
+ public void testReturnedSummary() {
+ SearchHit[] hits = SearchTestUtils.getSearchHits("jfplepdl", "en");
+ assertEquals(hits.length,1);
+ assertEquals("Summary for file Participant XML1", hits[0].getSummary());
+ }
+
+ public void testReturnedTitleNestedCase() {
+ SearchHit[] hits = SearchTestUtils.getSearchHits("odoeofoedo", "en");
+ assertEquals(hits.length,1);
+ assertEquals("Participant XML 2 - tests nesting", hits[0].getLabel());
+ }
+
+ public void testReturnedSummaryNestedCase() {
+ SearchHit[] hits = SearchTestUtils.getSearchHits("odoeofoedo", "en");
+ assertEquals(hits.length,1);
+ assertEquals("Summary for file Participant XML2", hits[0].getSummary());
+ }
+
+}
diff --git a/org.eclipse.ua.tests/plugin.xml b/org.eclipse.ua.tests/plugin.xml
index 4aa87542d..936209c2d 100644
--- a/org.eclipse.ua.tests/plugin.xml
+++ b/org.eclipse.ua.tests/plugin.xml
@@ -621,5 +621,22 @@
participant="org.eclipse.ua.tests.help.search.MockLuceneXMLParticipant">
</searchParticipant>
</extension>
+ <extension
+ point="org.eclipse.help.base.searchParticipant">
+ <searchParticipant
+ headless="false"
+ icon="icons/sample4.gif"
+ id="org.eclipse.ua.tests.searchParticipant"
+ name="Mock Search Participant"
+ participant="org.eclipse.ua.tests.help.search.MockSearchParticipant">
+ </searchParticipant>
+ <searchParticipant
+ headless="false"
+ icon="icons/sample4.gif"
+ id="org.eclipse.ua.tests.searchParticipantXml"
+ name="Mock Search Participant for XML"
+ participant="org.eclipse.ua.tests.help.search.MockSearchParticipantXML">
+ </searchParticipant>
+ </extension>
</plugin>
diff --git a/org.eclipse.ui.cheatsheets/plugin.xml b/org.eclipse.ui.cheatsheets/plugin.xml
index e463e25f4..af3896fb0 100644
--- a/org.eclipse.ui.cheatsheets/plugin.xml
+++ b/org.eclipse.ui.cheatsheets/plugin.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?> <!--
- Copyright (c) 2005, 2008 IBM Corporation and others.
+ Copyright (c) 2005, 2010 IBM Corporation and others.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
@@ -206,7 +206,7 @@
</triggerPoint>
</extension>
<extension
- point="org.eclipse.help.base.luceneSearchParticipants">
+ point="org.eclipse.help.base.searchParticipant">
<searchParticipant
icon="$nl$/icons/view16/cheatsheet_view.gif"
id="org.eclipse.ui.cheatsheets"
diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/CheatsheetSearchParticipant.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/CheatsheetSearchParticipant.java
index 8ab1ae976..a1903ca21 100644
--- a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/CheatsheetSearchParticipant.java
+++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/CheatsheetSearchParticipant.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -15,7 +15,7 @@ import java.util.Set;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.Platform;
-import org.eclipse.help.search.XMLSearchParticipant;
+import org.eclipse.help.search.SearchParticipantXML;
import org.eclipse.jface.action.Action;
import org.eclipse.ui.cheatsheets.OpenCheatSheetAction;
import org.eclipse.ui.internal.cheatsheets.composite.parser.ICompositeCheatsheetTags;
@@ -23,7 +23,7 @@ import org.eclipse.ui.internal.cheatsheets.data.IParserTags;
import org.eclipse.ui.internal.cheatsheets.registry.CheatSheetRegistryReader;
import org.xml.sax.Attributes;
-public class CheatsheetSearchParticipant extends XMLSearchParticipant {
+public class CheatsheetSearchParticipant extends SearchParticipantXML {
private static final String INTRO_DESC = "cheatsheet/intro/description"; //$NON-NLS-1$
private static final String ITEM_DESC = "cheatsheet/item/description"; //$NON-NLS-1$
diff --git a/org.eclipse.ui.intro/plugin.xml b/org.eclipse.ui.intro/plugin.xml
index 9c2d6ef4f..d260659f2 100644
--- a/org.eclipse.ui.intro/plugin.xml
+++ b/org.eclipse.ui.intro/plugin.xml
@@ -36,7 +36,7 @@
</standbyContentPart>
</extension>
<extension
- point="org.eclipse.help.base.luceneSearchParticipants">
+ point="org.eclipse.help.base.searchParticipant">
<searchParticipant
icon="$nl$/icons/welcome16.gif"
id="org.eclipse.ui.intro"
diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroSearchParticipant.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroSearchParticipant.java
index f851e4e4d..656714c7c 100644
--- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroSearchParticipant.java
+++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroSearchParticipant.java
@@ -10,20 +10,18 @@
*******************************************************************************/
package org.eclipse.ui.internal.intro.impl.model;
-import java.io.StringReader;
import java.net.URL;
import java.util.HashSet;
import java.util.Set;
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IProduct;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
-import org.eclipse.help.search.ISearchIndex;
-import org.eclipse.help.search.LuceneSearchParticipant;
+import org.eclipse.help.search.IHelpSearchIndex;
+import org.eclipse.help.search.ISearchDocument;
+import org.eclipse.help.search.SearchParticipant;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.internal.intro.impl.IntroPlugin;
import org.eclipse.ui.internal.intro.impl.model.loader.ExtensionPointManager;
@@ -34,12 +32,12 @@ import org.eclipse.ui.intro.config.IntroURLFactory;
import org.osgi.framework.Bundle;
/**
- * An implementation of the Lucene search participant that adds Welcome content into the local help
+ * An implementation of SearchParticipant that adds Welcome content into the local help
* index so that it can be searched.
*
*/
-public class IntroSearchParticipant extends LuceneSearchParticipant {
+public class IntroSearchParticipant extends SearchParticipant {
private IntroModelRoot model;
@@ -148,8 +146,9 @@ public class IntroSearchParticipant extends LuceneSearchParticipant {
* java.lang.String, java.net.URL, java.lang.String, java.lang.String,
* org.apache.lucene.document.Document)
*/
- public IStatus addDocument(ISearchIndex index, String pluginId, String name, URL url, String id,
- Document doc) {
+
+ public IStatus addDocument(IHelpSearchIndex index, String pluginId, String name, URL url, String id,
+ ISearchDocument doc) {
if (model == null)
return Status.CANCEL_STATUS;
IntroPage page = getPage(id);
@@ -167,8 +166,8 @@ public class IntroSearchParticipant extends LuceneSearchParticipant {
return null;
}
- private IStatus addPage(ISearchIndex index, String pluginId, String name, URL url, IntroPage page,
- Document doc) {
+ private IStatus addPage(IHelpSearchIndex index, String pluginId, String name, URL url, IntroPage page,
+ ISearchDocument doc) {
AbstractIntroElement[] children = page.getChildren();
if (children.length > 0) {
StringBuffer buf = new StringBuffer();
@@ -179,17 +178,16 @@ public class IntroSearchParticipant extends LuceneSearchParticipant {
addTitle(titleSummary.title, doc);
}
if (titleSummary.summary != null) {
- doc.add(new Field("summary", titleSummary.summary, Field.Store.YES, Field.Index.NO)); //$NON-NLS-1$
+ doc.setSummary(titleSummary.summary);
}
- doc.add(new Field("contents", new StringReader(contents))); //$NON-NLS-1$
- doc.add(new Field("exact_contents", new StringReader(contents))); //$NON-NLS-1$
+ doc.addContents(contents);
return Status.OK_STATUS;
}
// delegate to the help system
- return index.addDocument(pluginId, name, url, page.getId(), doc);
+ return index.addSearchableDocument(pluginId, name, url, page.getId(), doc);
}
- private void addChildren(AbstractIntroElement[] children, StringBuffer buf, Document doc, TitleAndSummary titleSummary) {
+ private void addChildren(AbstractIntroElement[] children, StringBuffer buf, ISearchDocument doc, TitleAndSummary titleSummary) {
for (int i = 0; i < children.length; i++) {
AbstractIntroElement child = children[i];
if (child instanceof IntroLink) {
@@ -255,4 +253,5 @@ public class IntroSearchParticipant extends LuceneSearchParticipant {
IIntroURL url = IntroURLFactory.createIntroURL("http://org.eclipse.ui.intro/showPage?id=" + id); //$NON-NLS-1$
return url.execute();
}
+
}

Back to the top