Skip to main content



      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 00:20 Go to next message
Eclipse UserFriend
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 00:23 Go to previous messageGo to next message
Eclipse UserFriend
please have a look at semantic highlighting
Re: Custom coloring for block of code [message #1819471 is a reply to message #1819469] Thu, 16 January 2020 01:15 Go to previous messageGo to next message
Eclipse UserFriend
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 01:20 Go to previous messageGo to next message
Eclipse UserFriend
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] Thu, 16 January 2020 23:52 Go to previous messageGo to next message
Eclipse UserFriend
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 00:26 Go to previous messageGo to next message
Eclipse UserFriend
I cannot follow you. Semantic highlighting is called when you type in the editor.
Please explain what you do
Re: Custom coloring for block of code [message #1819536 is a reply to message #1819535] Fri, 17 January 2020 01:05 Go to previous messageGo to next message
Eclipse UserFriend
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 01:06 Go to previous messageGo to next message
Eclipse UserFriend
this makes no sense. this is not semantic highlighting
Re: Custom coloring for block of code [message #1819540 is a reply to message #1819537] Fri, 17 January 2020 01:40 Go to previous messageGo to next message
Eclipse UserFriend
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 05:38 Go to previous message
Eclipse UserFriend
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: Sun Jul 06 01:55:28 EDT 2025

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

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

Back to the top