Skip to content

Extension for quick search dialog text viewers. Fixes #2010 #2853

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions bundles/org.eclipse.text.quicksearch/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.text.quicksearch;singleton:=true
Bundle-Version: 1.3.0.qualifier
Bundle-Version: 1.4.0.qualifier
Bundle-Activator: org.eclipse.text.quicksearch.internal.ui.QuickSearchActivator
Require-Bundle: org.eclipse.ui;bundle-version="[3.113.0,4.0.0)",
org.eclipse.core.resources;bundle-version="[3.13.0,4.0.0)",
Expand All @@ -12,12 +12,14 @@ Require-Bundle: org.eclipse.ui;bundle-version="[3.113.0,4.0.0)",
org.eclipse.ui.editors;bundle-version="[3.11.0,4.0.0)",
org.eclipse.jface;bundle-version="[3.17.0,4.0.0)",
org.eclipse.jface.text;bundle-version="[3.15.0,4.0.0)",
org.apache.ant;bundle-version="[1.10.0,2.0.0)"
org.apache.ant;bundle-version="[1.10.0,2.0.0)",
org.eclipse.core.contenttype;bundle-version="[3.9.0,4.0.0)"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-21
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package: org.eclipse.text.quicksearch.internal.core;x-internal:=true,
Export-Package: org.eclipse.text.quicksearch,
org.eclipse.text.quicksearch.internal.core;x-internal:=true,
org.eclipse.text.quicksearch.internal.core.pathmatch;x-internal:=true,
org.eclipse.text.quicksearch.internal.core.preferences;x-internal:=true,
org.eclipse.text.quicksearch.internal.core.priority;x-friends:="org.eclipse.text.quicksearch.tests",
Expand Down
8 changes: 8 additions & 0 deletions bundles/org.eclipse.text.quicksearch/plugin.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#
# Contributors:
# Pivotal Inc - initial API and implementation
# Jozef Tomek - text viewers extension
###############################################################################

pluginName= Quick Search
Expand All @@ -18,3 +19,10 @@ quickSearch.label= Quick Search
quickSearch.ellipsis= &Quick Search...
quickSearch.tooltip=Search for a text pattern in the workspace
quickAccess.category.label=File content
textViewers=Text Viewer
defaultSourceViewer=Text Viewer

QuickSearchActivator.targetIdAttributeMissing=target id attribute ''{0}'' missing
QuickSearchActivator.contentTypeNotFound=content type ''{0}'' not found
QuickSearchActivator.targetNotFound=target ''{0}'' not found
QuickSearchActivator.unexpectedTag=expected tag ''{1}'', got ''{0}''
14 changes: 14 additions & 0 deletions bundles/org.eclipse.text.quicksearch/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@

Contributors:
Pivotal Inc - Initial API and implementation
Jozef Tomek - text viewers extension
-->
<?eclipse version="3.4"?>
<plugin>

<extension-point id="textViewers" name="%textViewers" schema="schema/textViewers.exsd"/>

<extension point="org.eclipse.ui.commands">
<category
name="%quickSearch.label"
Expand Down Expand Up @@ -116,4 +119,15 @@
</computer>
</extension>

<extension point="org.eclipse.text.quicksearch.textViewers">
<viewer
class="org.eclipse.text.quicksearch.internal.ui.DefaultSourceViewerCreator"
id="org.eclipse.text.quicksearch.DefaultSourceViewer"
label="%defaultSourceViewer"/>
<contentTypeBinding
contentTypeId="org.eclipse.core.runtime.text"
viewerId="org.eclipse.text.quicksearch.DefaultSourceViewer">
</contentTypeBinding>
</extension>

</plugin>
226 changes: 226 additions & 0 deletions bundles/org.eclipse.text.quicksearch/schema/textViewers.exsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,226 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="org.eclipse.text.quicksearch" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appinfo>
<meta.schema plugin="org.eclipse.text.quicksearch" id="textViewers" name="Search Results Text Viewers"/>
</appinfo>
<documentation>
This extension point allows a plug-in to register text viewers for specific types of content in which quick search matches were found.
Since viewers don&apos;t have a default constructor, the extension point must implement the factory interface for viewers &lt;samp&gt;org.eclipse.text.quicksearch.ITextViewerCreator&lt;/samp&gt; that then creates viewers wrapped by implementation of &lt;samp&gt;org.eclipse.text.quicksearch.ITextViewerCreator.ITextViewerHandle&lt;/samp&gt; providing methods necessary for presenting quick search results.
</documentation>
</annotation>

<element name="extension">
<annotation>
<appinfo>
<meta.element />
</appinfo>
</annotation>
<complexType>
<sequence>
<element ref="viewer" minOccurs="0" maxOccurs="unbounded"/>
<element ref="contentTypeBinding" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<attribute name="point" type="string" use="required">
<annotation>
<documentation>
a fully qualified identifier of the target extension point
</documentation>
</annotation>
</attribute>
<attribute name="id" type="string">
<annotation>
<documentation>
an optional identifier of the extension instance
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>
an optional name of the extension instance
</documentation>
<appinfo>
<meta.attribute translatable="true"/>
</appinfo>
</annotation>
</attribute>
</complexType>
</element>

<element name="viewer">
<annotation>
<appinfo>
<meta.element labelAttribute="label" icon="icon"/>
</appinfo>
</annotation>
<complexType>
<attribute name="id" type="string" use="required">
<annotation>
<documentation>
a unique identifier that can be used to reference the viewer
</documentation>
</annotation>
</attribute>
<attribute name="class" type="string" use="required">
<annotation>
<documentation>
a fully qualified name of a class that implements a factory for the
text viewer handle and implements &lt;samp&gt;org.eclipse.text.quicksearch.ITextViewerCreator&lt;/samp&gt;
</documentation>
<appinfo>
<meta.attribute kind="java" basedOn=":org.eclipse.text.quicksearch.ITextViewerCreator"/>
</appinfo>
</annotation>
</attribute>
<attribute name="extensions" type="string">
<annotation>
<documentation>
an optional comma separated list of file extensions e.g. &quot;java, html&quot;. If not defined, some &lt;code&gt;contentTypeBinding&lt;/code&gt; must be defined
</documentation>
</annotation>
</attribute>
<attribute name="label" type="string" use="required">
<annotation>
<documentation>
a translatable label that will be used in the UI for this viewer.
</documentation>
<appinfo>
<meta.attribute translatable="true"/>
</appinfo>
</annotation>
</attribute>
<attribute name="linkedEditor" type="string">
<annotation>
<documentation>
Editor id to consider while searching for a viewer matching a content type.
If the specified &quot;linked&quot; editor has content type associations, they will be also considered as possible bindings for this viewer. This is useful in cases where viewer supports same content types as &quot;linked&quot; editor (like in generic editor).
</documentation>
<appinfo>
<meta.attribute kind="identifier" basedOn="org.eclipse.ui.editors/editor/@id"/>
</appinfo>
</annotation>
</attribute>
</complexType>
</element>

<element name="contentTypeBinding">
<annotation>
<appinfo>
<meta.element labelAttribute="contentTypeId"/>
</appinfo>
<documentation>
A &lt;code&gt;contentTypeBinding&lt;/code&gt; binds a text viewer to a content type. If no binding is defined, &lt;code&gt;viewer&lt;/code&gt; needs to declare &lt;code&gt;extensions&lt;/code&gt;
</documentation>
</annotation>
<complexType>
<attribute name="contentTypeId" type="string" use="required">
<annotation>
<documentation>
The id of a content type defined using the &lt;code&gt;org.eclipse.core.contenttype.contentTypes&lt;/code&gt; extension point.
</documentation>
<appinfo>
<meta.attribute kind="identifier" basedOn="org.eclipse.core.contenttype.contentTypes/content-type/@id"/>
</appinfo>
</annotation>
</attribute>
<attribute name="viewerId" type="string" use="required">
<annotation>
<documentation>
The id of a text viewer defined using the &lt;code&gt;viewer&lt;/code&gt; element of this extension point (i.e. &lt;code&gt;org.eclipse.text.quicksearch.DefaultSourceViewer&lt;/code&gt;)
</documentation>
<appinfo>
<meta.attribute kind="identifier" basedOn="org.eclipse.text.quicksearch.textViewers/viewer/@id"/>
</appinfo>
</annotation>
</attribute>
</complexType>
</element>

<annotation>
<appinfo>
<meta.section type="since"/>
</appinfo>
<documentation>
1.3
</documentation>
</annotation>

<annotation>
<appinfo>
<meta.section type="examples"/>
</appinfo>
<documentation>
The following is an example of a text viewer for text content type:
&lt;p&gt;
&lt;pre&gt;
&lt;extension point=&quot;org.eclipse.text.quicksearch.textViewers&quot;&gt;
&lt;viewer
id=&quot;org.eclipse.text.quicksearch.DefaultSourceViewer&quot;
class=&quot;org.eclipse.text.quicksearch.internal.ui.DefaultSourceViewerCreator&quot;/&gt;
&lt;contentTypeBinding
contentTypeId=&quot;org.eclipse.core.runtime.text&quot;
sourceViewerId=&quot;org.eclipse.text.quicksearch.DefaultSourceViewer&quot;&gt;
&lt;/contentTypeBinding&gt;
&lt;/extension&gt;
&lt;/pre&gt;
&lt;/p&gt;
The following is an example of a text viewer for text content type &amp; content types for which referenced editor is registered:
&lt;p&gt;
&lt;pre&gt;
&lt;extension point=&quot;org.eclipse.text.quicksearch.textViewers&quot;&gt;
&lt;viewer
id=&quot;org.eclipse.ui.genericeditor.quicksearch.GenericEditorViewer&quot;
class=&quot;org.eclipse.ui.internal.genericeditor.quicksearch.GenericEditorViewerCreator&quot;
linkedEditor=&quot;org.eclipse.ui.genericeditor.GenericEditor&quot;/&gt;
&lt;contentTypeBinding
contentTypeId=&quot;org.eclipse.core.runtime.text&quot;
sourceViewerId=&quot;org.eclipse.ui.genericeditor.quicksearch.GenericEditorViewer&quot;&gt;
&lt;/contentTypeBinding&gt;
&lt;/extension&gt;
&lt;/pre&gt;
&lt;/p&gt;
</documentation>
</annotation>

<annotation>
<appinfo>
<meta.section type="apiInfo"/>
</appinfo>
<documentation>
The contributed class must implement &lt;code&gt;org.eclipse.text.quicksearch.ITextViewerCreator&lt;/code&gt;
</documentation>
</annotation>

<annotation>
<appinfo>
<meta.section type="implementation"/>
</appinfo>
<documentation>
The Quick Search plugin provides &lt;code&gt;org.eclipse.text.quicksearch.internal.ui.DefaultSourceViewerCreator&lt;/code&gt; supplying default text viewer with no syntax coloring.
</documentation>
</annotation>

<annotation>
<appinfo>
<meta.section type="copyright"/>
</appinfo>
<documentation>
Copyright (c) 2025 Contributors to the Eclipse Foundation&lt;br&gt;

See the NOTICE file(s) distributed with this work for additional
information regarding copyright ownership.

This program and the accompanying materials are made available under the
terms of the Eclipse Public License 2.0 which is available at
&lt;a href=&quot;https://www.eclipse.org/legal/epl-2.0&quot;&gt;https://www.eclipse.org/legal/epl-2.0.html&lt;/a&gt;

SPDX-License-Identifier: EPL-2.0

Contributors:
Jozef Tomek - initial API and implementation
</documentation>
</annotation>

</schema>
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package org.eclipse.text.quicksearch;

import org.eclipse.jface.text.source.IChangeRulerColumn;
import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.text.quicksearch.SourceViewerConfigurer.ISourceViewerCreator;
import org.eclipse.text.quicksearch.SourceViewerHandle.FixedLineHighlighter;

/**
* Factory used by {@link SourceViewerHandle} responsible for creation and necessary setup of source viewers so that
* they provide common aspects of quicksearch text viewers:
* <ul>
* <li>vertical ruler with line numbers supporting selected match line number highlighting
* <li>selected match line highlighting
* <li>current (caret position) line highlighting
* <li>colors and fonts consistent with text viewers/editors preferences
* </ul>
*
* Actual source viewer instance creation is delegated to provided {@link ISourceViewerCreator}.
* @since 1.3
* @see SourceViewerConfigurer
*/
public interface ISourceViewerConfigurer<T extends SourceViewer> {

/**
* Creates, configures and returns source viewer that provides common aspects of quicksearch text viewers. Delegates
* source viewer creation to {@link ISourceViewerCreator} provided on initialization.
* @param parent the parent SWT control for the viewer
* @return configured source viewer
* @see ISourceViewerCreator
*/
T getSourceViewer(Composite parent);

/**
* Returns change ruler column installed to the viewer.
* @return viewer's change ruler column
*/
IChangeRulerColumn getChangeRulerColumn();

/**
* Returns fixed line highlighter installed to the viewer.
* @return viewer's fixed line highlighter
*/
FixedLineHighlighter getMatchLineHighlighter();
}
Loading