Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace play-json with circe #165

Closed
wants to merge 18 commits into from
Closed

Replace play-json with circe #165

wants to merge 18 commits into from

Conversation

gabro
Copy link
Member

@gabro gabro commented Jan 4, 2018

This is based on #164.

There's some bits I'm not particularly happy with, but not too bad!

The only relevant commit is d9b38bc

import langserver.messages.WorkspaceExecuteCommandRequest
import langserver.messages.WorkspaceSymbolRequest
import langserver.messages.WorkspaceSymbolResult
import langserver.messages._
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

// case Right(conf) =>
// logger.info(s"Configuration updated $conf")
// configurationSubscriber.onNext(conf)
// }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Commented out code

Copy link
Member Author

@gabro gabro Jan 4, 2018

Choose a reason for hiding this comment

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

ah, thanks, fixed.


case event =>
logger.warn(s"Unhandled file event: $event")
()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Doesn’t logger.warn already return unit?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think so, but you better add this comment to @olafurpg's PR. This is just based on it.

| "signatures" : [
| {
| "label" : "<init>(name: String)User",
| "documentation" : null,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Any concern that the previous json library did not serialization null values and circe appears presently configured to serialization them as JsNull?

Copy link
Member Author

Choose a reason for hiding this comment

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

From a protocol POV it should be irrelevant.
As mentioned in #165 (comment) I treated this as an implementation detail. Changing the default pretty-printer would've been much more bothersome.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Printer is easy to change, IIRC it’s just printer.copy(dropNullValues = true)
I don’t think changing json libraries should require test changes. Are we comparing raw strings where we should be comparing parsed json in tests?

Copy link
Member Author

@gabro gabro Jan 4, 2018

Choose a reason for hiding this comment

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

Printer is easy to change, IIRC it’s just printer.copy(dropNullValues = true)

It is, but then you have to pass around the printer instance and do json.pretty(printer) instead of json.spaces2.

Are we comparing raw strings where we should be comparing parsed json in test

Using directly the json strings was a choice we took a while ago and it served us well so far.

I would be ok in comparing with parsed json instead. Something like:

import io.circe.Json.{obj, arr, fromInt => int, fromString => str, False}

// ...

check(
  "foo",
  obj(
    "isIncomplete" -> False,
    "items" -> arr(
      obj(
        "label" -> str(label),
        "kind" -> int(kind.value),
        "detail" -> str(detail),
        "sortText" -> str("00000")
      )
    )
  )
)

wdyt @olafurpg?

Copy link
Member

Choose a reason for hiding this comment

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

What do we gain by moving to comparing parsed json instead of strings? I personally think strings are nice because

  1. test errors are reported as unified diff which are easy to read
  2. false negatives are easy to fix by copy-pasting the failed test output and pasting it into the field

Copy link
Member

Choose a reason for hiding this comment

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

For the tests I would recommend using dropNullValues = true to minimize the string output, I have no preference for the messages sent from MessageWriter

Copy link
Member

Choose a reason for hiding this comment

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

I don’t think changing json libraries should require test changes.

I think it's totally fine if the pretty-printers are incompatible. It would be nice if there was a compatible printer so we can keep the tests unchanged, I personally liked the play-json pretty-printer output since it was quite compact compared to the output in these tests.

Copy link
Member

@olafurpg olafurpg left a comment

Choose a reason for hiding this comment

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

LGTM 👍 Very gratifying diff ❤️

screen shot 2018-01-04 at 17 08 26

I will try to address the comments in #164 asap we can get both in!

@olafurpg
Copy link
Member

olafurpg commented Jan 4, 2018

Merged commits from this PR into #164 so we can close this here. Very nice to get play-json out! It was a big annoyance while writing #164

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

Successfully merging this pull request may close these issues.

3 participants