Xtext Language Server - xtext

I wrapped an Ace Editor in a React Front-End Application and served a separat Java-Backend using the LanguageServerImpl class to have my own grammar using Xtext.
I want to use xtexts validation and autocomplete methods passing data between the Ace Editor and the Xtext Languageserver. The way it works is in sending JSON-RPC between the Editor and the Langserver. But there is no documentation how to call the valdiation or autocompletion from Editor to Server an back to Editor with the response.
How does the JSON-RPC looks like to achieve this behaviour?
This is the Code how I init the Lang- Server. Currently the Input is a simple System.in Stream.
server = injector.getInstance(LanguageServerImpl.class);
org.eclipse.lsp4j.jsonrpc.Launcher<LanguageClient> launcher = LSPLauncher.createServerLauncher(server, in, out);
LanguageClient client = launcher.getRemoteProxy();
server.connect(client);
launcher.startListening();
The second question I have is: Why do I need the LanguageClient? The Editor is the Client which is hosted by a different Server...

Related

Update variable information in the openwrt web interface luci

From the picture we see the value of RSSI, there is a code on lua and sh that displays this value, the script sh writes a value to the file, in lua we write it to a variable from the file and assign it to the label element
os.execute('/bin/rssi')
file = io.open("/tmp/rssi", "r");
d:option(DummyValue, "label", "rssi: "..(file:read("*line")));
file:close();
Everything works, but I want to see information in the web interface every N second. I will be grateful for your help.
It's something that has to be implemented at the frontend (HTML, JS, PHP), not in the Lua backend. I don't know how the kids do it these days, but from what I know, you'd need to use JavaScript to refresh that part of the HTML document every few seconds, as you want.
The way it works is as such:
Request a web page from Chrome/Firefox/Opera/Edge;
Web server opens requested file, if file is a script, script runs;
Script retrieves data from systems, databases, etc.;
3.1 Lua script runs, returns value (of RSSI, for you);
3.2 Script replaces variable by value returned by Lua script;
3.3 Script returns HTML code where variables have been replaced by values from databases, systems, etc.;
Web server sends data over the network;
Client web browser displays the data, usually as a HTML document formatted by CSS, with JavaScript interactivity, and automatic activities.
In your case, you'd want this:
JavaScript in client browser refreshes part of the document, essentially going through steps 1-5, but only replacing a portion of what's being displayed (an HTML element).

Strict validation in Mirth Connect

Within a Mirth Connect installation (version 3.5.1), I have setup a channel TCP (LLP) that receive a message HL7 and send an XML with the data of the PID segment (plus some of other useful informations about the HL7 message) to an external site.
I want to validate the message (if contains an error) and filtering the message according to some rules for the data of the segment PID (no name, no surname, etc).
To accompish this requirement, I have write a simple javascript filter and set in the channel (from Summary tab) the strict validation.
But I have this behavior.
If I don't use the strict validation option for the messages, I get all the data of the segment PID within tags like PID.1, PID.2 etc (e.g. for the name I have the following XML structure <PID.5><PID.5.1>XXX</PID.5.1>....</PID.5>).
Instead, if I use the strict validation option the message (in the filter) became different and other tags are present (e.g. for the name I have the following XML structure <PID.5><XPN.1><FN.1>XXX</FN.1></XPN.1>....</PID.5>).
Someone know the why I have this behavior? It is caused by some misconfiguration? Or it is the normal behavior?
Thanks at all for the support.
UPDATE
I realized only now that the structures were not visible.
Now, yes.
Thanks again at all for the support.
This is normal behavior. The default parser is implemented in the mirth hl7v2 datatype itself. When you use the strict parser, it uses the HAPI parser which produces the alternate xml you are seeing that actually conforms to the hl7 specification.

In Asp.net using C#, how can I convert ==head== __italic__ and others to html equivalents?

I was able to save the following in database
==heading===
Some __useful contents__ and **bold texts** here
I want to output ==heading== to <h1>heading</h1>
__useful contents__ to <i>useful contents</i>
**bold texts** to <b>bold texts</b>
Thanks
I'd recommend using Markdown for this purpose (same is used here, in SO).
You can get package that will convert markdown to HTML here in for C#. Or if you want client browser to render it (to save CPU on the server) you can use this JS plugin.

ASP.NET WEB API 406 error:for POST request using Media format

I am very new to web api stuff:
I am getting an error
406: Not Acceptable
error message in asp.net web api rest service.
In my rest service I’m using media format for my customized XML output, to get customized output.
I’m registering my formatted media in Global.asax page.
GlobalConfiguration.Configuration.Formatters.Clear();
GlobalConfiguration.Configuration.Formatters.Add(new mynewformat());
all my methods are post methods with typed object as parameter and parameters are accepts from body.
Whenever I try to test the service… Getting 406: Not acceptable error message.
can anyone please help me ... what could be the reason for this....???
I did notice couple of interesting points here...
If I’m commenting below line then I’m getting 200 (OK) status code (which is fine.)... but format is not applying to output.
GlobalConfiguration.Configuration.Formatters.Clear();
If i'm removing parameters in my service method.. Then its working
fine..
I request everyone.. Please guide me what could be the reason/work around/solution/fix..for this issue.
Note:I don't want accept parameters from URI so i made it to accept from frombody only.
Thanks.
There is a lot more to implementing a custom format than just adding it to the configuration formatters. It starts with having to change the media-type header to a new custom type of your choosing (like "application/myNewFormat") for all requests, for the client. On the back end, you have to implement a new MediaTypeFormatter that can handle the serialization. This involves a bit more of code.
A good example of this resides here, it can easily be stripped to boiler-plate code:
http://www.codeproject.com/Articles/559378/Implementing-Custom-Media-Formatters-in-ASP-NET-We

setting innerHTML in xul

I have in my browser.xul code,what I am tyring to is to fetch data from an html file and to insert it into my div element.
I am trying to use div.innerHTML but I am getting an exception:
Component returned failure code: 0x804e03f7
[nsIDOMNSHTMLElement.innerHTML]
I tried to parse the HTML using Components.interfaces.nsIScriptableUnescapeHTML and to append the parsed html into my div but my problem is that style(attribute and tag) and script isn`t parsed.
First a warning: if your HTML data comes from the web then you are trying to build a security hole into your extension. HTML code from the web should never be trusted (even when coming from your own web server and via HTTPS) and you should really use nsIScriptableUnescapeHTML. Styles should be part of your extension, using styles from the web isn't safe. For more information: https://developer.mozilla.org/En/Displaying_web_content_in_an_extension_without_security_issues
As to your problem, this error code is NS_ERROR_HTMLPARSER_STOPPARSING which seems to mean a parsing error. I guess that you are trying to feed it regular HTML code rather than XHTML (which would be XML-compliant). Either way, a better way to parse XHTML code would be DOMParser, this gives you a document that you can then insert into the right place.
If the point is really to parse HTML code (not XHTML) then you have two options. One is using an <iframe> element and displaying your data there. You can generate a data: URL from your HTML data:
frame.src = "data:text/html;charset=utf-8," + encodeURIComponent(htmlData);
If you don't want to display the data in a frame you will still need a frame (can be hidden) that has an HTML document loaded (can be about:blank). You then use Range.createContextualFragment() to parse your HTML string:
var range = frame.contentDocument.createRange();
range.selectNode(frame.contentDocument.documentElement);
var fragment = range.createContextualFragment(htmlData);
XML documents don't have innerHTML, and nsIScriptableUnescapeHTML is one way to get the html parsed but it's designed for uses where the HTML might not be safe; as you've found out it throws away the script nodes (and a few other things).
There are a couple of alternatives, however. You can use the responseXML property, although this may be suboptimal unless you're receiving XHTML content.
You could also use an iframe. It may seem old-fashioned, but an iframe's job is to take a url (the src property) and render the content it receives, which necessarily means parsing it and building a DOM. In general, when an extension running as chrome does this, it will have to take care not to give the remote content the same chrome privilages. Luckily that's easily managed; just put type="content" on the iframe. However, since you're looking to import the DOM into your XUL document wholesale, you must have already ensured that this remote content will always be safe. You're evidently using an HTTPS connection, and you've taken extra care to verify the identity of the server by making sure it sends the right certificate. You've also verified that the server hasn't been hacked and isn't delivering malicious content.

Resources