Skip to content

Add extension support and first extension, unwrap_newtypes#72

Merged
bors[bot] merged 5 commits into
ron-rs:masterfrom
torkleyy:ext
Jan 17, 2018
Merged

Add extension support and first extension, unwrap_newtypes#72
bors[bot] merged 5 commits into
ron-rs:masterfrom
torkleyy:ext

Conversation

@torkleyy

@torkleyy torkleyy commented Jan 16, 2018

Copy link
Copy Markdown
Member

TODO

  • More tests, especially regarding error handling
  • discuss TODOs / design
  • docs for extensions (postponed)
  • add syntax to Sublime plugin

Fixes

Fixes #69

Comment thread src/de/error.rs Outdated
ParseError::ExpectedArray => "Expected array",
ParseError::ExpectedArrayEnd => "Expected end of array",
ParseError::ExpectedAttribute => "Expected an enable attribute",
ParseError::ExpectedAttributeEnd => "Expected a closing `]` after the attribute",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ah, this could also fail if ) is missing. The error message should reflect that.

Comment thread src/de/mod.rs Outdated
) -> Result<V::Value>
where V: Visitor<'de>
{
if Extension::unwrap_newtypes(self.bytes.exts) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

if the set of extensions is known at compile time, any reason we don't do something like if self.extensions.contains(Extension::UNWRAP_NEWTYPES) {..}?

@torkleyy

torkleyy commented Jan 17, 2018 via email

Copy link
Copy Markdown
Member Author

@torkleyy

Copy link
Copy Markdown
Member Author

bors try

bors Bot added a commit that referenced this pull request Jan 17, 2018
@bors

bors Bot commented Jan 17, 2018

Copy link
Copy Markdown
Contributor

try

Build succeeded

scope: source.ron
contexts:
main:
# extensions

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This could be done better, but I think it's sufficient. Could you try it out with your editor?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I tested it. Seems to work fine.

@torkleyy

Copy link
Copy Markdown
Member Author

r? @kvark

Please also check the syntax file, I didn't check it!

@torkleyy torkleyy removed the working label Jan 17, 2018

@kvark kvark left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Almost there!

Comment thread src/de/tests.rs
fn multiple_attributes() {
#[derive(Debug, Deserialize, PartialEq)]
struct New(String);
let de: Result<New> = from_str("#![enable(unwrap_newtypes)] #![enable(unwrap_newtypes)] \"Hello\"");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this is not supported by the syntax highlighter, I think
Can we require the features to always come as a list in a single pragma? e.g. #![enable(feature1, feature2)]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think it is supported? It should match against the same pattern twice.

Comment thread src/parse.rs
.map(|elem| {
if self.consume(elem) {
self.skip_ws();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

weird newline

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Personal style, I always make a newline before the return value.

@kvark

kvark commented Jan 17, 2018

Copy link
Copy Markdown
Collaborator

:shipit:
bors r+

bors Bot added a commit that referenced this pull request Jan 17, 2018
72: Add extension support and first extension, unwrap_newtypes r=kvark a=torkleyy

## TODO

* [x] More tests, especially regarding error handling
* [x] discuss TODOs / design
* [x] ~~docs for extensions~~ (postponed)
* [x] add syntax to Sublime plugin

## Fixes

Fixes #69
@bors

bors Bot commented Jan 17, 2018

Copy link
Copy Markdown
Contributor

Canceled

@torkleyy

Copy link
Copy Markdown
Member Author

Just noticed two nits and fixed them.

bors r=kvark

bors Bot added a commit that referenced this pull request Jan 17, 2018
72: Add extension support and first extension, unwrap_newtypes r=kvark a=torkleyy

## TODO

* [x] More tests, especially regarding error handling
* [x] discuss TODOs / design
* [x] ~~docs for extensions~~ (postponed)
* [x] add syntax to Sublime plugin

## Fixes

Fixes #69
@bors

bors Bot commented Jan 17, 2018

Copy link
Copy Markdown
Contributor

Build succeeded

@Boscop

Boscop commented Jul 1, 2020

Copy link
Copy Markdown

@torkleyy The syntax highlighting in Sublime is messed up as soon as I add attributes:

image

@kvark

kvark commented Jul 2, 2020

Copy link
Copy Markdown
Collaborator

Could you file that on https://github.com/ron-rs/sublime-ron please?

@Boscop

Boscop commented Jul 3, 2020

Copy link
Copy Markdown

Done: ron-rs/sublime-ron#6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider adding top-level attributes

3 participants