Skip to content
This repository has been archived by the owner on Jun 8, 2023. It is now read-only.

Compiles and run on Scala 2.12, latest version of Ensime (2.0.0-M4). Added settings to change server log level from VSCode #54

Merged
merged 20 commits into from
Sep 12, 2017

Conversation

fede0664
Copy link
Contributor

  • Scala 2.12: The challenge was upgrading scala-json-rpc to version 2.0.0, required a few changes on Commands.scala and JsonRpcUtils.scala
  • Ensime (2.0.0-M4): implemented changes suggested at bump the server #50. The ActorInitializationException seems to be gone, but Ensime still has some irrecoverable fails, for example when getting the definition of a Manifest. Trouble showing local val tooltip #37 still not fixed.
  • Settings change: Added a flag in VSCode settings that is sent to Coursier to change the default logging level for org.github.dragos.vscode on loogback.groovy. The goal of this is to limit the verbosity of the log on production, log files grow quickly to a several GBs in DEBUG level.

Copy link
Owner

@dragos dragos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! I would ask you to try to follow the coding style in the project, in particular to have a space after : in type ascription. I'll approve the PR and wait a bit to see if you have time to update it, otherwise I'll do it later.

@dragos
Copy link
Owner

dragos commented Sep 11, 2017

I just noticed that Document Symbols stopped working. I see these errors in the log, perhaps related to the upgrade to scala-json-rpc 2.0?

[2017-09-11 14:34:55,435] DEBUG org.github.dragos.vscode.EnsimeLanguageServer - got back: List(StructureViewMember(class,Hello,OffsetSourcePosition(RawFile(/Users/dragos/workspace/oss/test-code/src/main/scala/Hello.scala),8),List(StructureViewMember(def,foo,OffsetSourcePosition(RawFile(/Users/dragos/workspace/oss/test-code/src/main/scala/Hello.scala),22),List()), StructureViewMember(type,X,OffsetSourcePosition(RawFile(/Users/dragos/workspace/oss/test-code/src/main/scala/Hello.scala),135),List()))))
[2017-09-11 14:34:55,435] DEBUG org.github.dragos.vscode.EnsimeLanguageServer - got back: List(StructureViewMember(class,Hello,OffsetSourcePosition(RawFile(/Users/dragos/workspace/oss/test-code/src/main/scala/Hello.scala),8),List(StructureViewMember(def,foo,OffsetSourcePosition(RawFile(/Users/dragos/workspace/oss/test-code/src/main/scala/Hello.scala),22),List()), StructureViewMember(type,X,OffsetSourcePosition(RawFile(/Users/dragos/workspace/oss/test-code/src/main/scala/Hello.scala),135),List()))))
[2017-09-11 14:34:55,437] INFO langserver.core.Connection - Result:DocumentSymbolResult(List(SymbolInformation(Hello,5,Location(file:///Users/dragos/workspace/oss/test-code/src/main/scala/Hello.scala,Range(Position(2,6),Position(2,11))),None), SymbolInformation(foo,6,Location(file:///Users/dragos/workspace/oss/test-code/src/main/scala/Hello.scala,Range(Position(3,6),Position(3,9))),Some(Hello)), SymbolInformation(X,11,Location(file:///Users/dragos/workspace/oss/test-code/src/main/scala/Hello.scala,Range(Position(11,7),Position(11,8))),Some(Hello))))
[2017-09-11 14:34:55,437] INFO langserver.core.Connection - Result:DocumentSymbolResult(List(SymbolInformation(Hello,5,Location(file:///Users/dragos/workspace/oss/test-code/src/main/scala/Hello.scala,Range(Position(2,6),Position(2,11))),None), SymbolInformation(foo,6,Location(file:///Users/dragos/workspace/oss/test-code/src/main/scala/Hello.scala,Range(Position(3,6),Position(3,9))),Some(Hello)), SymbolInformation(X,11,Location(file:///Users/dragos/workspace/oss/test-code/src/main/scala/Hello.scala,Range(Position(11,7),Position(11,8))),Some(Hello))))
[2017-09-11 14:34:55,441] ERROR langserver.core.Connection - ResultResponse.write:DocumentSymbolResult(List(SymbolInformation(Hello,5,Location(file:///Users/dragos/workspace/oss/test-code/src/main/scala/Hello.scala,Range(Position(2,6),Position(2,11))),None), SymbolInformation(foo,6,Location(file:///Users/dragos/workspace/oss/test-code/src/main/scala/Hello.scala,Range(Position(3,6),Position(3,9))),Some(Hello)), SymbolInformation(X,11,Location(file:///Users/dragos/workspace/oss/test-code/src/main/scala/Hello.scala,Range(Position(11,7),Position(11,8))),Some(Hello))))
[2017-09-11 14:34:55,441] ERROR langserver.core.Connection - ResultResponse.write:DocumentSymbolResult(List(SymbolInformation(Hello,5,Location(file:///Users/dragos/workspace/oss/test-code/src/main/scala/Hello.scala,Range(Position(2,6),Position(2,11))),None), SymbolInformation(foo,6,Location(file:///Users/dragos/workspace/oss/test-code/src/main/scala/Hello.scala,Range(Position(3,6),Position(3,9))),Some(Hello)), SymbolInformation(X,11,Location(file:///Users/dragos/workspace/oss/test-code/src/main/scala/Hello.scala,Range(Position(11,7),Position(11,8))),Some(Hello))))

it looks like the error is a Json validation error, I wonder why...

play.api.libs.json.JsResultException: JsResultException(errors:List((,List(JsonValidationError(List(error.expected.jsobject),WrappedArray())))))
	at play.api.libs.json.JsReadable.$anonfun$as$2(JsReadable.scala:24)
	at play.api.libs.json.JsError.fold(JsResult.scala:55)
	at play.api.libs.json.JsReadable.as(JsReadable.scala:23)
	at play.api.libs.json.JsReadable.as$(JsReadable.scala:22)
	at play.api.libs.json.JsArray.as(JsValue.scala:93)
	at langserver.utils.JsonRpcUtils$$anon$1.writes(JsonRpcUtils.scala:39)
	at com.dhpcs.jsonrpc.ResponseCompanion.write(MessageCompanions.scala:56)
	at com.dhpcs.jsonrpc.ResponseCompanion.write$(MessageCompanions.scala:52)
	at langserver.messages.ResultResponse$.write(Commands.scala:253)
	at langserver.core.Connection.$anonfun$handleCommand$3(Connection.scala:168)
	at scala.util.Try$.apply(Try.scala:209)
	at langserver.core.Connection.$anonfun$handleCommand$2(Connection.scala:166)
	at langserver.core.Connection.$anonfun$handleCommand$2$adapted(Connection.scala:163)
	at scala.util.Success.$anonfun$map$1(Try.scala:251)
	at scala.util.Success.map(Try.scala:209)
	at scala.concurrent.Future.$anonfun$map$1(Future.scala:287)
	at scala.concurrent.impl.Promise.liftedTree1$1(Promise.scala:29)
	at scala.concurrent.impl.Promise.$anonfun$transform$1(Promise.scala:29)
	at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:60)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)

override def reads(json: JsValue) = Reads.of[B].reads(json).map(apply(_))
override def writes(o: A) = Writes.of[B].writes(unapply(o))
override def writes(o: A) = Writes.of[B].writes(unapply(o)).as[JsObject]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be the cause of the exception I reported earlier. In the case of DocumentSymbolResult the underlying type is a sequence, not a Json object.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that's the case we'll need a similar workaround like the one I implemented for the Locations for "textDocument/definition". It seems that the latest play-json-rcp Message.MessageFormats only accepts JsObject, can't deal with JsValue. I'll take a look later today.
Can you add a test case to include this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed the changes to fix the issue with "textDocument/definition". I had to use the same workaround used for the Seq[Location]. Changed JsonRpcUtils.valueFormat to work only with JsObject.

@dragos
Copy link
Owner

dragos commented Sep 12, 2017

Fantastic, thanks a lot! Merging this.

@dragos dragos merged commit 811f9c4 into dragos:master Sep 12, 2017
@jvican
Copy link

jvican commented Sep 12, 2017

Yay!! You cannot imagine the atrocities I've done to my 2.12 build to support the vscode integration for scalac-performance here: https://github.com/scalacenter/scalac-profiling.

@dragos dragos mentioned this pull request Sep 13, 2017
@dhpiggott
Copy link

Hey. scala-json-rpc author here. I see now from looking over this (found it via https://twitter.com/jaguarul/status/907514621728260096) that this was a regression in scala-json-rpc 2.0.0.

I've just fixed it via dhpiggott/scala-json-rpc#48 and released the fixed version as 2.0.1, so it should be possible now to update dragos-vscode-scala and remove these workarounds.

@dragos
Copy link
Owner

dragos commented Sep 14, 2017

Thank you @dhpiggott! Open-source at its finest!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants