Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » Configuring characters to match in XML editor
Configuring characters to match in XML editor [message #187962] Tue, 13 February 2007 16:36 Go to next message
Eclipse UserFriend
Originally posted by: yves.monier.temis.com

Hello,

I'm developing a custom XML editor based on StructuredTextEditor.
Typical files to edit often contain elements with a lot of indented ()
and {} pairs.

It seems that, by default, the XML editor only highlights matching '<'
and '>', while the Java editor, for example, highlights {} and ().

Is there a way to configure the characters I want to highlight?

I have looked at many classes and interfaces
(StructuredTextViewerConfiguration and derived classes,
SourceViewerDecorationSupport, ICharacterPairMatcher, ...), but failed
to find en entry point somewhere for that...

Any help greatly appreciated!

Yves
Re: Configuring characters to match in XML editor [message #188031 is a reply to message #187962] Wed, 14 February 2007 19:44 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 2335
Registered: July 2009
Senior Member
Yves Monier wrote:
> I'm developing a custom XML editor based on StructuredTextEditor.
> Typical files to edit often contain elements with a lot of indented ()
> and {} pairs.
>
> It seems that, by default, the XML editor only highlights matching '<'
> and '>', while the Java editor, for example, highlights {} and ().
>
> Is there a way to configure the characters I want to highlight?
>
> I have looked at many classes and interfaces
> (StructuredTextViewerConfiguration and derived classes,
> SourceViewerDecorationSupport, ICharacterPairMatcher, ...), but failed
> to find en entry point somewhere for that...
>
> Any help greatly appreciated!

There isn't a way to configure the matching characters as of yet.
3.3 is the first release of the platform that will have a readily
usable character pair matcher we can call upon (see bug 56836 and
the doc for
org.eclipse.jface.text.source.DefaultCharacterPairMatcher). The
StructuredTextEditor loads the character pair matcher as an editor
configuration in the createCharacterPairMatcher() method. The
following, judiciously edited, should cause your own pair matcher to
be used instead of the default implementation,
org.eclipse.wst.xml.ui.internal.text.XMLDocumentRegionEdgeMa tcher:

<extension point="org.eclipse.wst.sse.ui.editorConfiguration">
<provisionalConfiguration
type="characterpairmatcher"
class="MyCharacterPairMatcher"
target="myCustomContentType" />
</extension>

The only requirement is that MyCharacterPairMatcher implement
org.eclipse.jface.text.source.ICharacterPairMatcher. If you've
extended the XML content type, you could use that as your target
value, otherwise use the editor site ID you've given to your source
page.

--
Nitin Dahyabhai
Structured Source Editor


---
Nitin Dahyabhai
Eclipse WTP, IBM
Re: Configuring characters to match in XML editor [message #188112 is a reply to message #188031] Fri, 16 February 2007 16:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: yves.monier.temis.com

Hi Nitin,

Thanks a lot for your answer.
I had a look at XMLDocumentRegionEdgeMatcher. I naively admit that I was
prepared to see lines of code dealing with '<' and '>' characters, but I
mostly saw things about document regions and edges.
JavaPairMatcher implementation, on the other hand, was closer to the
character-based matching I expected to see.

Ideally I'd like my editor to offer the current XML matcher behavior
(i.e. based on '<' and '>') + more or less the JavaPairMatcher's one.
Do you think a kind or merging XMLDocumentRegionEdgeMatcher and
JavaPairMatcher behaviors has sense? If so, do you think it can be done
by a nearly Eclipse plugins beginner, or is it hopeless without a deep
knowledge of Eclipse internals like XML document regions?

Best regards,

Yves Monier


Nitin Dahyabhai a écrit :
> Yves Monier wrote:
>> I'm developing a custom XML editor based on StructuredTextEditor.
>> Typical files to edit often contain elements with a lot of indented ()
>> and {} pairs.
>>
>> It seems that, by default, the XML editor only highlights matching '<'
>> and '>', while the Java editor, for example, highlights {} and ().
>>
>> Is there a way to configure the characters I want to highlight?
>>
>> I have looked at many classes and interfaces
>> (StructuredTextViewerConfiguration and derived classes,
>> SourceViewerDecorationSupport, ICharacterPairMatcher, ...), but failed
>> to find en entry point somewhere for that...
>>
>> Any help greatly appreciated!
>
> There isn't a way to configure the matching characters as of yet. 3.3 is
> the first release of the platform that will have a readily usable
> character pair matcher we can call upon (see bug 56836 and the doc for
> org.eclipse.jface.text.source.DefaultCharacterPairMatcher). The
> StructuredTextEditor loads the character pair matcher as an editor
> configuration in the createCharacterPairMatcher() method. The
> following, judiciously edited, should cause your own pair matcher to be
> used instead of the default implementation,
> org.eclipse.wst.xml.ui.internal.text.XMLDocumentRegionEdgeMa tcher:
>
> <extension point="org.eclipse.wst.sse.ui.editorConfiguration">
> <provisionalConfiguration
> type="characterpairmatcher"
> class="MyCharacterPairMatcher"
> target="myCustomContentType" />
> </extension>
>
> The only requirement is that MyCharacterPairMatcher implement
> org.eclipse.jface.text.source.ICharacterPairMatcher. If you've extended
> the XML content type, you could use that as your target value, otherwise
> use the editor site ID you've given to your source page.
>
> --
> Nitin Dahyabhai
> Structured Source Editor
Re: Configuring characters to match in XML editor [message #188129 is a reply to message #188112] Fri, 16 February 2007 21:24 Go to previous message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 2335
Registered: July 2009
Senior Member
Yves Monier wrote:
> Thanks a lot for your answer.
> I had a look at XMLDocumentRegionEdgeMatcher. I naively admit that I was
> prepared to see lines of code dealing with '<' and '>' characters, but I
> mostly saw things about document regions and edges.
> JavaPairMatcher implementation, on the other hand, was closer to the
> character-based matching I expected to see.
>
> Ideally I'd like my editor to offer the current XML matcher behavior
> (i.e. based on '<' and '>') + more or less the JavaPairMatcher's one.
> Do you think a kind or merging XMLDocumentRegionEdgeMatcher and
> JavaPairMatcher behaviors has sense? If so, do you think it can be done
> by a nearly Eclipse plugins beginner, or is it hopeless without a deep
> knowledge of Eclipse internals like XML document regions?

It should be possible to merge the two by calling one and then the
other if a match isn't found by the first. The trickiest part I
would expect would be matching quotation marks on attribute values,
as that should use the XML text region information so it knows
whether to search for the matching quotation mark forwards or
backwards. There's room for experimentation in combining a more
traditional matcher's usage with the existing
XMLDocumentRegionEdgeMatcher.

--
Nitin Dahyabhai
Structured Source Editor


---
Nitin Dahyabhai
Eclipse WTP, IBM
Previous Topic:Extending JSP Editor
Next Topic:Headless workspace compilation
Goto Forum:
  


Current Time: Wed Nov 26 13:14:17 GMT 2014

Powered by FUDForum. Page generated in 0.01681 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software