Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Custom coloring for block of code(Custom coloring for block of code)
Custom coloring for block of code [message #1819468] Thu, 16 January 2020 05:20 Go to next message
Virag Purnam is currently offline Virag PurnamFriend
Messages: 142
Registered: June 2014
Senior Member
Hi,

Requirement is to custom color the block of code.
How can I achieve this?

Consider the below example.
<CodeBlock> which are under if(false) will not be executed. Requirement is to mark those as grayed out or any custom color. User will know that block will not be executed.


  if(true){
  
    <Code Block>

   }

   if(false){

    <Code Block>
   }



Please guide me how to proceed. Some pointers will be helpful.

Thanks and regards,
Virag Purnam
Re: Custom coloring for block of code [message #1819469 is a reply to message #1819468] Thu, 16 January 2020 05:23 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
please have a look at semantic highlighting

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Custom coloring for block of code [message #1819471 is a reply to message #1819469] Thu, 16 January 2020 06:15 Go to previous messageGo to next message
Tamas Miklossy is currently offline Tamas MiklossyFriend
Messages: 157
Registered: February 2016
Senior Member
See also https://www.eclipse.org/Xtext/documentation/310_eclipse_support.html#highlighting
Re: Custom coloring for block of code [message #1819472 is a reply to message #1819469] Thu, 16 January 2020 06:20 Go to previous messageGo to next message
Virag Purnam is currently offline Virag PurnamFriend
Messages: 142
Registered: June 2014
Senior Member
Thanks Mr. Christian Dietrich and Mr. Tamas Miklossy for the pointer.
I will look at semantic highlighting.
Re: Custom coloring for block of code [message #1819534 is a reply to message #1819472] Fri, 17 January 2020 04:52 Go to previous messageGo to next message
Virag Purnam is currently offline Virag PurnamFriend
Messages: 142
Registered: June 2014
Senior Member
Hi,

Semantic highlighting gets called during the start of application.
I want to achieve this dynamically.
When ever any 'if statement' is false, I want to gray out the code block present inside that.
Is there any class which I can refer?

Thanks and regards,
Virag
Re: Custom coloring for block of code [message #1819535 is a reply to message #1819534] Fri, 17 January 2020 05:26 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
I cannot follow you. Semantic highlighting is called when you type in the editor.
Please explain what you do


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Custom coloring for block of code [message #1819536 is a reply to message #1819535] Fri, 17 January 2020 06:05 Go to previous messageGo to next message
Virag Purnam is currently offline Virag PurnamFriend
Messages: 142
Registered: June 2014
Senior Member
Hi Mr. Christian Dietrich,

I have implemented TokenSource interface.
In the method nextToken(), I am checking IF condition.
If condition is false, I am making all the token present in IF block as SL comment, by changing token type.

But in editor, it does not appear as SL comment color. It retains its original color.


Thanks and regards,
Virag
Re: Custom coloring for block of code [message #1819537 is a reply to message #1819536] Fri, 17 January 2020 06:06 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
this makes no sense. this is not semantic highlighting

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Custom coloring for block of code [message #1819540 is a reply to message #1819537] Fri, 17 January 2020 06:40 Go to previous messageGo to next message
Tamas Miklossy is currently offline Tamas MiklossyFriend
Messages: 157
Registered: February 2016
Senior Member
You can find an example for semantic highlighting in the GEF DOT project:
https://github.com/eclipse/gef/blob/master/org.eclipse.gef.dot.ui/src/org/eclipse/gef/dot/internal/ui/language/highlighting/DotSemanticHighlightingCalculator.java
Re: Custom coloring for block of code [message #1819559 is a reply to message #1819540] Fri, 17 January 2020 10:38 Go to previous message
Virag Purnam is currently offline Virag PurnamFriend
Messages: 142
Registered: June 2014
Senior Member
Thanks Mr. Tamas Miklossy for the example. I will check, if I get something out of this.
Thanks Mr. Christian Dietrich. Yes requirement does not look nice. Just wanted to give try and check the feasibility.
Previous Topic:Xtext editor backed by XMI resource
Next Topic:Facing problem in cross references
Goto Forum:
  


Current Time: Tue Apr 23 11:53:07 GMT 2024

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

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

Back to the top