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

[Merged by Bors] - Fix start position on class declarations with decorators #628

Closed
wants to merge 1 commit into from

Conversation

dsherret
Copy link
Contributor

@dsherret dsherret commented Feb 5, 2020

Fixes: #626 (comment)

See #581

@@ -92,7 +92,6 @@ impl<'a, I: Tokens> Parser<'a, I> {
top_level: bool,
decorators: Vec<Decorator>,
) -> PResult<'a, Stmt> {
let start = cur_pos!();
Copy link
Contributor Author

@dsherret dsherret Feb 5, 2020

Choose a reason for hiding this comment

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

This is being passed in on line 90.

@dsherret dsherret changed the title Fixes start position on class declarations with decorators Fix start position on class declarations with decorators Feb 5, 2020
@kdy1
Copy link
Member

kdy1 commented Feb 6, 2020

bors r+

bors bot pushed a commit that referenced this pull request Feb 6, 2020
@kdy1
Copy link
Member

kdy1 commented Feb 6, 2020

Thanks!

@bors
Copy link
Contributor

bors bot commented Feb 6, 2020

Build succeeded

  • continuous-integration/travis-ci/push

@bors
Copy link
Contributor

bors bot commented Feb 6, 2020

Pull request successfully merged into master.

@bors bors bot changed the title Fix start position on class declarations with decorators [Merged by Bors] - Fix start position on class declarations with decorators Feb 6, 2020
@bors bors bot closed this Feb 6, 2020
@dsherret dsherret deleted the fixStatementWidth branch February 6, 2020 02:30
@dsherret
Copy link
Contributor Author

dsherret commented Feb 6, 2020

Thanks @kdy1 and that's awesome you implemented top level await so fast!

Would it be possible to get a release for swc_ecma_parser sometime you find the chance?

@kdy1
Copy link
Member

kdy1 commented Feb 6, 2020

@dsherret I publised it. Note that you need to update swc_common too.

@dsherret
Copy link
Contributor Author

dsherret commented Feb 6, 2020

Thanks a lot @kdy1 !

I'm wondering how to get the byte position and comment vector pairs out of the RefMulti in the DashMap though. Any ideas? If not, I will sadly clone for now (edit: or determine whether cloning or just reading from this map is faster).

let (leading_comments, trailing_comments) = comments.take_all();
// previously did something like this:
let leading_comments: HashMap<BytePos, Vec<Comment>>
    = leading_comments.into_iter().collect();

@kdy1
Copy link
Member

kdy1 commented Feb 6, 2020

@dsherret
DashMap does not support taking all value, but you can use iter_mut with std::mem::replace.
Iterate over a dashmap with iter_mut(), and replace the value with

replace( item..value_mut(), Default::default())

@dsherret
Copy link
Contributor Author

dsherret commented Feb 6, 2020

@kdy1 awesome idea. Thanks! 🙂

@dsherret
Copy link
Contributor Author

dsherret commented Feb 6, 2020

Hmmm... couldn't figure it out then tried to just use CommentMap in my code to see how it performs, but ran into some issues. I just went back to cloning for now :(

Only slightly slower so no big deal! I'll look into this later.

@swc-project swc-project locked as resolved and limited conversation to collaborators Nov 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Support top level await
2 participants