Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext web editor -- semantic highlighting
Xtext web editor -- semantic highlighting [message #1724911] Sat, 27 February 2016 01:33 Go to next message
Mary Komor is currently offline Mary KomorFriend
Messages: 61
Registered: July 2009
Member
I'm trying to enable semantic highlighting for my dsl in the web editor, but
I can't seem to be able to get it to work. What's not clear to me is what I
need to put in the CSS file.

I specify an id (say, myDslId) to the given acceptor in my implementation of
the ISemanticHighlightingCalculator, and in the CSS file I have the
following:

myDslId {
color:#1675D2;
font-weight:bold;
}


Is that correct? Am I missing something?

Thanks!

Mary
Re: Xtext web editor -- semantic highlighting [message #1724922 is a reply to message #1724911] Sat, 27 February 2016 07:52 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14068
Registered: July 2009
Senior Member
hi,

are you using orion? or code mirror. it seems ace does not support that
https://www.eclipse.org/Xtext/documentation/330_web_support.html

when i switch to orion this works fine for me

in the workflow (i deleted the old index.html)
			webSupport = {
				generateHtmlExample = true
				framework = "ORION"
			}


in the build.gradle of the web project

def orionDir = file('src/main/webapp/orion')
def orionZip = file("$buildDir/orion/built-codeEdit.zip")
def orionUrl = 'http://download.eclipse.org/orion/drops/S20151203-1425/built-codeEdit.zip'

task downloadOrion {
	onlyIf {!orionZip.exists()}
	doLast {
		orionZip.parentFile.mkdirs()
		println "Download $orionUrl"
		ant.get(src: orionUrl, dest: orionZip)
	}
}

task unpackOrion(type: Copy) {
	onlyIf {!orionDir.exists()}
	dependsOn(downloadOrion)
	from(zipTree(orionZip))
	into(orionDir)
}

task jettyRun(type:JavaExec) {
	dependsOn(sourceSets.main.runtimeClasspath,unpackOrion)
.....


and here is my impl and style.css

class MyDslDefaultSemanticHighlightingCalculator extends DefaultSemanticHighlightingCalculator {
	
	def dispatch protected boolean highlightElement(Greeting object, IHighlightedPositionAcceptor acceptor,
			CancelIndicator cancelIndicator) {
		if (object.name.toLowerCase == object.name) {
			val n = NodeModelUtils.findNodesForFeature(object, MyDslPackage.Literals.GREETING__NAME).head
			acceptor.addPosition(n.offset, n.length,"myid")
			
		}
		return false;
	}
	
	def dispatch protected highlightElement(EObject object, IHighlightedPositionAcceptor acceptor, CancelIndicator cancelIndicator) {
		super.highlightElement(object, acceptor, cancelIndicator)
	}
	
}


class MyDslWebModule extends AbstractMyDslWebModule {
	
	def Class<? extends ISemanticHighlightingCalculator> bindISemanticHighlightingCalculator() {
		MyDslDefaultSemanticHighlightingCalculator
	}
}


.myid {
	background-color: red;
}


see https://github.com/eclipse/xtext/tree/e05d4062aa74eac0c81ad2a246ffcd4db705aaa1/web/org.eclipse.xtext.web.example.jetty as well


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Sat, 27 February 2016 07:54]

Report message to a moderator

Re: Xtext web editor -- semantic highlighting [message #1725007 is a reply to message #1724922] Mon, 29 February 2016 06:28 Go to previous messageGo to next message
Mary Komor is currently offline Mary KomorFriend
Messages: 61
Registered: July 2009
Member
Hi Christian,

Looks like the Xtext project wizard generates an Ace based editor by
default, which is what I currently have. I also overlooked the docs that
indicated that semantic highlighting was not supported in Ace.

I will try to following your example to switch my editor to be Orion based.
Thanks for the example!

I think it will be nice to add an option to the Xtext project wizard to
allow us to choose which editor we want to use (Orion, Ace or CodeMirror),
instead of it defaulting to Ace.

Thanks!

Mary

"Christian Dietrich" wrote in message news:narkkl$vph$1@xxxxxxxxe.org...

hi,

are you using orion? or code mirror. it seems ace does not support that
https://www.eclipse.org/Xtext/documentation/330_web_support.html

when i switch to orion this works fine for me

in the workflow (i deleted the old index.html)

webSupport = {
generateHtmlExample = true
framework = "ORION"
}


in the build.gradle of the web project


def orionDir = file('src/main/webapp/orion')
def orionZip = file("$buildDir/orion/built-codeEdit.zip")
def orionUrl =
'http://download.eclipse.org/orion/drops/S20151203-1425/built-codeEdit.zip'

task downloadOrion {
onlyIf {!orionZip.exists()}
doLast {
orionZip.parentFile.mkdirs()
println "Download $orionUrl"
ant.get(src: orionUrl, dest: orionZip)
}
}

task unpackOrion(type: Copy) {
onlyIf {!orionDir.exists()}
dependsOn(downloadOrion)
from(zipTree(orionZip))
into(orionDir)
}

task jettyRun(type:JavaExec) {
dependsOn(sourceSets.main.runtimeClasspath,unpackOrion)
.....


and here is my impl and style.css


class MyDslDefaultSemanticHighlightingCalculator extends
DefaultSemanticHighlightingCalculator {

def dispatch protected boolean highlightElement(Greeting object,
IHighlightedPositionAcceptor acceptor,
CancelIndicator cancelIndicator) {
if (object.name.toLowerCase == object.name) {
val n = NodeModelUtils.findNodesForFeature(object,
MyDslPackage.Literals.GREETING__NAME).head
acceptor.addPosition(n.offset, n.length,"myid")

}
return false;
}

def dispatch protected highlightElement(EObject object,
IHighlightedPositionAcceptor acceptor, CancelIndicator cancelIndicator) {
super.highlightElement(object, acceptor, cancelIndicator)
}

}



class MyDslWebModule extends AbstractMyDslWebModule {

def Class<? extends ISemanticHighlightingCalculator>
bindISemanticHighlightingCalculator() {
MyDslDefaultSemanticHighlightingCalculator
}
}



myid {
background-color: red;
}

--
Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: Xtext web editor -- semantic highlighting [message #1725011 is a reply to message #1725007] Mon, 29 February 2016 07:13 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14068
Registered: July 2009
Senior Member
Feel free to file a enhancement request for the wizard

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Triggering "re-validation" of non-dirty resource
Next Topic:Regarding Antlr rule matching
Goto Forum:
  


Current Time: Tue Sep 28 19:27:55 GMT 2021

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

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

Back to the top