Matching start/end tags [message #546157] |
Sun, 11 July 2010 21:28 |
Timotei Mising name Messages: 89 Registered: March 2010 |
Member |
|
|
Hi!
I have the following parts of my grammar:
WMLTag:
start = WMLStartTag
( (Ttags += WMLTag)
| (Tkeys += WMLKey)
| (Tmacros += WMLMacro)
)*
end = WMLEndTag
;
WMLStartTag:
'[' tagname = ID ']'
;
WMLEndTag:
'[/' tagname = ID ']'
;
Now, I want to "highlight" the start/end tags. So when with the cursor is on startTag/EndTag, both of the tags to be highlighted. By highlighting I mean, get the: "" and "[/mytag]", be shaded/backgrounded/have their caracteristics modified. Maybe if I can "surround" them with a box like it's currently with bracket matching?
The highlighting will be easy done, with a HighlightingConfiguration (that is already in place).
The only question is, how can I get the current XtextEditor - so I can get current cursor's location/offset ?
Can this be done, "globally"? Or I need an instance of something before?
Currently I have this method that does the highlighting, can I use that resource to get the XTextEditor? :
public void provideHighlightingFor(XtextResource resource, IHighlightedPositionAcceptor acceptor)
Or, is there anyother method of highlighting the start/end tags, without this method of highlighting?
Thanks,
Timotei
|
|
|
|
|
|
|
|
|
|
|
Re: Matching start/end tags [message #697418 is a reply to message #546845] |
Sat, 16 July 2011 17:38 |
Timotei Mising name Messages: 89 Registered: March 2010 |
Member |
|
|
Hi!
I've reworked a bit my current way of highlighting the end/start. However, there is a weird problem happening.
If I click on a tag, it colors it. If I click on another tag, it might color that too (note, there should be just *1* colored at a time). This is not happening all the time.
What I use: I implement the DefaultCharacterPairMatcher, and I've implemented a separate method along with the default, that does the logic. When a tag is found in the tree, it adds a new adapter to it. This is taken in account in the ISemanticHighlightinCalculator.
I've checked manually to see what's happening, and it seems the it remains colored some of the file. Is there any way of getting the editor to refresh the *entire* (maybe just the visible) section ? I can have access just to the XtextResource, as it is seen in the following code:
http://pastebin.com/kWH4JAvz
LE: looking deeper in it, it seems that the semantic highlighter is called non-stop (making the processor 100%). If I remove the modify thingy, then it isn't called all the time. What could be the problem?
Thanks,
Timo
[Updated on: Sat, 16 July 2011 17:50] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.04211 seconds