Xtext web editor -- semantic highlighting [message #1724911] |
Fri, 26 February 2016 20:33  |
Eclipse User |
|
|
|
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 02:52   |
Eclipse User |
|
|
|
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
[Updated on: Sat, 27 February 2016 02:54] by Moderator
|
|
|
Re: Xtext web editor -- semantic highlighting [message #1725007 is a reply to message #1724922] |
Mon, 29 February 2016 01:28   |
Eclipse User |
|
|
|
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
|
|
|
|
Powered by
FUDForum. Page generated in 0.08027 seconds