Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

LsService::handle_message match replaced with macro#256

Merged
nrc merged 1 commit intorust-lang:masterfrom
Xanewok:handle-message-macro
May 1, 2017
Merged

LsService::handle_message match replaced with macro#256
nrc merged 1 commit intorust-lang:masterfrom
Xanewok:handle-message-macro

Conversation

@Xanewok
Copy link
Copy Markdown
Contributor

@Xanewok Xanewok commented Apr 14, 2017

This fixes #45.
For every Method/Notification enum we can either specify an arbitrary expression to evaluate when handling a message or use a default handler following existing convention:
this.handler.<action_name>([id,] params, &*this.output).
Few things to note:

  • I'd love to get rid of trace_params as I think there may be better idea to handle an optional enum payload token in trace! call
  • Possibly lines with trace! call are too long, but I figured it doesn't add to the logic itself, so throwing a one-liner just to inform of a trace is acceptable
  • I defined macros inside impl for LsService, as the macro is closely related only to that particular scope and it seemed somewhat self-contained, but if needed I can move it to top-level so it generates whole LsService::handle_message (along with initial parse_message, shut_down logic etc.)

@nrc
Copy link
Copy Markdown
Member

nrc commented Apr 30, 2017

Thanks for the PR and apologies for the long wait for review - I've been away on parental leave the past few weeks.

@nrc nrc merged commit 0760a79 into rust-lang:master May 1, 2017
@Xanewok Xanewok deleted the handle-message-macro branch July 4, 2017 22:59
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.

refactoring: parse_message and LsService::handle_message should be generated

2 participants