Multiple grammars and example web editor [message #1798163] |
Tue, 13 November 2018 09:18  |
Eclipse User |
|
|
|
I have an XText project with five distinct grammars, and have everything working through the IDE, including cross referencing between grammars. I'm at the point where I'm looking at integrating a web based editor for the grammars.
If I run the web example as generated it works correctly for the first grammar defined in the mwe2 workflow. However, if I change the extension within the index.html of the generated example to point to the second or third grammar the editor fails with an error that looks like:
"Xtext service 'occurrences' failed: Unable to identify the Xtext language for resource 2103f6f5.ed"
Can someone shed some light on why just swapping the extension used would not work? At this point I'm just exploring the code in an attempt to gain insight in order to figure out the best way to integrate it into our existing console code.
Thanks!
Pierre Padovnai
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: Multiple grammars and example web editor [message #1798288 is a reply to message #1798287] |
Wed, 14 November 2018 18:10   |
Eclipse User |
|
|
|
alternatively you can do it this way(client side)
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Language" content="en-us">
<title>Example Web Editor</title>
<link rel="stylesheet" type="text/css" href="xtext/2.15.0/xtext-ace.css"/>
<link rel="stylesheet" type="text/css" href="style.css"/>
<script src="webjars/requirejs/2.3.2/require.min.js"></script>
<script type="text/javascript">
var baseUrl = window.location.pathname;
var fileIndex = baseUrl.indexOf("index.html");
if (fileIndex > 0)
baseUrl = baseUrl.slice(0, fileIndex);
require.config({
baseUrl: baseUrl,
paths: {
"jquery": "webjars/jquery/2.2.4/jquery.min",
"ace/ext/language_tools": "webjars/ace/1.2.3/src/ext-language_tools",
"xtext/xtext-ace": "xtext/2.15.0/xtext-ace"
}
});
require(["webjars/ace/1.2.3/src/ace"], function() {
require(["xtext/xtext-ace"], function(xtext) {
xtext.createEditor({
baseUrl: baseUrl,
loadFromServer: false,
parentClass: "xtext-editora",
syntaxDefinition: "xtext-resources/generated/mode-mydsla"
});
xtext.createEditor({
baseUrl: baseUrl,
loadFromServer: false,
parentClass: "xtext-editorb",
syntaxDefinition: "xtext-resources/generated/mode-mydslb"
});
});
});
</script>
</head>
<body>
<div class="header">
<h1>Example MyDslA Web Editor</h1>
</div>
<div class="content">
<div class="xtext-editora" data-editor-resource-id="multi-resource/left.mydsla">
<pre>
HelloA A!
<pre>
</div>
</div>
<div class="content">
<div class="xtext-editorb" data-editor-resource-id="multi-resource/right.mydslb">
<pre>
HelloB B!
</pre>
</div>
</div>
</body>
</html>
ps.: here is my css
body {
width: 100%;
height: 100%;
overflow: hidden;
font: 16px Helvetica,sans-serif;
}
a {
color: #22a;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
.content {
display: block;
width: 400px;
height: 300px;
}
.xtext-editor {
display: block;
position: absolute;
width: 400px;
height: 300px;
padding: 4px;
border: 1px solid #aaa;
}
.xtext-editora {
display: block;
position: absolute;
width: 400px;
height: 300px;
padding: 4px;
border: 1px solid #aaa;
}
.xtext-editorb {
display: block;
position: absolute;
width: 400px;
height: 300px;
padding: 4px;
border: 1px solid #aaa;
}
|
|
|
|
Powered by
FUDForum. Page generated in 0.04948 seconds