openHAB VS Code Extension 0.3.0

vscode
Tags: #<Tag:0x00007f6cf3c38b80>

(Mark) #21

I’ve kinda lost track of the status of the issue with URI mapping when using samba shares. Does this work in the most recent build (#1088)?


(Kuba Wolanin) #22

I didn’t update my setup to #1088 yet so can’t really tell from experience.
There’s this bug raised by @Udo_Hartmann - he’s experiencing it on #1088 so I’m assuming it’s still relevant.
BR


(SteveW) #23

I’m using
OH2 build #1088,
VSCode 1.18.1
VSCode OH2 extension 0.3.0
on a Windows10 x64 machine,
with Openhab2 running on Ubuntu1604
and the /conf mapped via samba share,
and accessed in VSCode over //path-to-server/conf

Upon launching VSCode I get the same error as @Dries did in list post of 19/11/17 against #1084.

I’m new to the extension so not confident which bit is not working though -
in VSCode, code snippets works, autocompletion of existing Item names works, sitemap (Basic) preview works, but it doesn’t spot any syntax errors that are otherwise reported in openhab.log when I save e.g. a new Rule.


(Mark) #24

Thanks. I completely missed that issue. Looks like there’s already a PR in the pipeline… :+1:


(Sebastian) #25

What do I have to do to get this? I am a little bit lost.
Do I need Visual Studio?


(Dries) #26

No, Visual Studio Code (https://code.visualstudio.com/)


(marcolino) #27

Hi,
I’m using:
OH2 2.2.1, with misc-lsp
VSCode 1.18.1
VSCode OH2 extension 0.3.0
on a Windows7 x64 machine,
with Openhab2 running on Debian 9
and the /conf mapped via samba share,
and accessed in VSCode over //path-to-server/conf

I have a couple of questions:

  1. Object explorer does not work. If I click to refresh i got this error:
command 'openhab.command.refreshEntry' not found
  1. If I use wrong syntax, in example
if 1=!2 then

}
else {
}

There is no error, so i cannot understand if I misstype something in my code.

Can you help me?

Thanks


(Jens W.) #28

Just wanted to post a quick “me too”.

I’m on a MacBook & Raspberry running VS Code (latest) with VS Code Plugin (0.3.0) and openhab (build #1094). I’m getting those “on hover” (etc.) errors in VS Code as well:

[Error - 17:26:14] Request textDocument/hover failed.
  Message: Internal error, please look at the server's logs.
  Code: -32603 

In openhab I’m getting:

2017-11-24 17:26:08.050 [INFO ] [el.lsp.internal.MappingUriExtensions] - Path mapping could not be done for 'file:///Users/jens/openHAB/openHAB-conf', leaving it untouched

for every start of VS Code and I’m getting:

2017-11-24 17:26:09.552 [WARN ] [eclipse.lsp4j.jsonrpc.RemoteEndpoint] - Notification threw an exception: {
  "jsonrpc": "2.0",
  "method": "textDocument/didOpen",
  "params": {
    "textDocument": {
      "uri": "file:///Users/<MY_MAC_USER_NAME>/openHAB/openHAB-conf/rules/<MY_RULE_FILE>.rules",
      "languageId": "openhab",
      "version": 1,
      "text": <SOME_CODE>
    }
  }
}
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:53) ~[102:org.eclipse.lsp4j.jsonrpc:0.2.1.v20170706-0855]
	...
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	... 11 more
Caused by: java.lang.NullPointerException
	...
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:51) ~[?:?]
	... 11 more

for every file open action. I’m also getting:

2017-11-24 19:44:35.648 [ERROR] [eclipse.lsp4j.jsonrpc.RemoteEndpoint] - Internal error: java.lang.NullPointerException
java.util.concurrent.CompletionException: java.lang.NullPointerException
	at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:273) [?:?]
	at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:280) [?:?]
	at java.util.concurrent.CompletableFuture.uniApply(CompletableFuture.java:604) [?:?]
	at java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:577) [?:?]
	at java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:442) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
	at java.lang.Thread.run(Thread.java:748) [?:?]
Caused by: java.lang.NullPointerException
	at org.eclipse.xtext.ide.server.WorkspaceManager.getProjectManager(WorkspaceManager.java:173) ~[?:?]
	at org.eclipse.xtext.ide.server.WorkspaceManager.doRead(WorkspaceManager.java:229) ~[?:?]
	at org.eclipse.xtext.ide.server.LanguageServerImpl.lambda$hover$23(LanguageServerImpl.java:539) ~[?:?]
	at org.eclipse.xtext.ide.server.concurrent.RequestManager.lambda$runRead$2(RequestManager.java:116) ~[?:?]
	at java.util.concurrent.CompletableFuture.uniApply(CompletableFuture.java:602) ~[?:?]
	... 5 more

for every “hover” action.

My VS Code config:

{
    ...,
    "openhab.host": "openhabianpi",
    "openhab.port": 8080,
    "openhab.useRestApi": true,
    "openhab.lspEnabled": true,
    "openhab.restCompletions": false
}

Item stats and things are shown in VS Code, so the connection works in principle.

Interestingly, the openHab addon “openhab-misc-lsp” has disappeared from Paper UI after updating to one of the most recent #1080/1090-ish builds. The other misc packages seem to be all still there. But I’m guessing this was done on purpose. The logs say that the language server is indeed started.

I’m also getting the

2017-11-24 17:27:20.514 [WARN ] [org.apache.karaf.services.eventadmin] - EventAdmin: Blacklisting ServiceReference [{org.osgi.service.event.EventHandler, org.eclipse.smarthome.core.events.EventPublisher}={event.topics=smarthome, component.name=org.eclipse.smarthome.core.internal.events.OSGiEventManager, component.id=50, service.id=138, service.bundleid=109, service.scope=bundle} | Bundle(org.eclipse.smarthome.core_0.9.0.201711202142 [109])] due to timeout!

warning upon start of openhab as well, btw.

Just to be sure I tried again with an SD card image of a freshly installed openhabian installation that I did in September 2017 (then latest unstable, some bindings installed via Paper UI, but otherwise not tampered with) and updated to #1094 right away. And that timeout-error appeared.


(Kuba Wolanin) #29

@jewesta and others experiencing the issues with REST connection and whatnot.
I would appreciate if you shared your exact steps to reproduce this bug + described the environment you’re running VSCode (and openHAB) in.

Here’s the GitHub issue. My comment contains packaged VSIX extension with a potential fix. If the fix works for you, please also comment it in the issue.

That’s because LSP has become already a core, built-in feature of openHAB distro. There’s no need to install it as an extension since distro #1083. Here’s the PR introducing that change.

Thank you all for testing!
I hope we’ll find a good, working solution soon :slight_smile:

Meanwhile, @sjka is working on solving this defect.

Cheers


(Mark) #30

@kubawolanin
FYI I logged a couple issues related to vscode and LSP. Using build 1098 and the most recent 0.3.0 code you posted towards the bottom of this issue

First issue is here

And another one here


(The Squid) #31

Just curious if the "Internal error: java.lang.reflect.InvocationTargetException has been addressed.

I also have this appear in the Karaf console

Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Keep-Alive
-Timer"
Exception in thread "TCP Refresh Service" Exception in thread "upnp-async-6277" java.lang.OutOfMemor
yError: Java heap space
Exception in thread "upnp-async-6280" java.lang.OutOfMemoryError: Java heap space
        at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:932)
Exception in thread "upnp-main-1" Exception in thread "SocketListener(JmDNS-IP-1)" Exception in thre
ad "upnp-async-6264" Exception in thread "upnp-main-2"  at java.util.concurrent.ThreadPoolExecutor.p
rocessWorkerExit(ThreadPoolExecutor.java:1025)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: Java heap space
        at java.util.Arrays.copyOf(Arrays.java:3332)
        at java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:124)
        at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:448)
        at java.lang.StringBuilder.append(StringBuilder.java:136)
        at java.lang.StringBuilder.append(StringBuilder.java:131)
        at org.jupnp.model.message.UpnpHeaders.addParsedValue(UpnpHeaders.java:83)
        at org.jupnp.model.message.UpnpHeaders.parseHeaders(UpnpHeaders.java:76)
        at org.jupnp.model.message.UpnpHeaders.getAsArray(UpnpHeaders.java:139)
        at org.jupnp.model.message.UpnpHeaders.getFirstHeader(UpnpHeaders.java:152)
        at org.jupnp.model.message.discovery.IncomingSearchRequest.getMX(IncomingSearchRequest.java:
38)
        at org.jupnp.protocol.async.ReceivingSearch.waitBeforeExecution(ReceivingSearch.java:111)
        at org.jupnp.protocol.ReceivingAsync.run(ReceivingAsync.java:61)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)

I’m running OH 2.3 and the latest version of the VS plugin.

When I encounter that error it kills all of my TCP binding calls that I use to control my lighting.

Squid


(The Squid) #32

Anyone have a suggestion?

@kubawolanin

@Confectrician


(Jerome) #33

No sorry.
I have already seen your post and would have already answered if I had an idea.


(Kuba Wolanin) #34

I don’t think this error is caused by VSCode extension whatsoever.
All the work for syntax validation is done by Eclipse SmartHome, and specifically by Language Server. You can search Language Server Protocol to learn more about the subject.

Here’s a list of currently open issues with LSP.

The extension is just a client for the LSP.