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

Parser: implement import #3627

Merged
merged 10 commits into from
Aug 2, 2022
Merged

Parser: implement import #3627

merged 10 commits into from
Aug 2, 2022

Conversation

kazcw
Copy link
Contributor

@kazcw kazcw commented Jul 29, 2022

Pull Request Description

Based on usage; I believe this handles every case in current .enso files.

Important Notes

  • import is a built-in macro, so an import statement parses as a MultiSegmentApp.
  • Every import syntax will have a segment whose leading keyword is import; however import macros can be identified more efficiently by looking at only the first keyword. A MultiSegmentApp is an import if and only if its first keyword is in the set { "polyglot", "from", "import" }.

Checklist

Please include the following checklist in your PR:

  • The documentation has been updated if necessary.
  • All code conforms to the
    Scala,
    Java,
    and
    Rust
    style guides.
  • All code has been tested:
    • Unit tests have been written where possible.
    • If GUI codebase was changed: Enso GUI was tested when built using BOTH
      ./run ide dist and ./run ide watch.

[ci no changelog needed]

@kazcw kazcw marked this pull request as ready for review July 29, 2022 13:18
@kazcw kazcw self-assigned this Jul 29, 2022
Copy link
Member

@JaroslavTulach JaroslavTulach left a comment

Choose a reason for hiding this comment

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

Please create Tree.Import and capture the import info in there.

@kazcw
Copy link
Contributor Author

kazcw commented Jul 29, 2022

We are implementing this sort of thing with "macros" (MultiSegmentApp)

@JaroslavTulach
Copy link
Member

If I properly remember our yesterday conversation, then MultiSegmentApp is suitable representation for if/then/else, but import would benefit from its own Tree structure. The less logic I can do in TreeToIr the better.

@kazcw kazcw marked this pull request as draft August 2, 2022 10:06
@kazcw kazcw marked this pull request as ready for review August 2, 2022 10:06
" type Baz",
];
#[rustfmt::skip]
let expected = block![
Copy link
Member

Choose a reason for hiding this comment

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

+1, thanks for this test.

Copy link
Member

@JaroslavTulach JaroslavTulach left a comment

Choose a reason for hiding this comment

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

Looks fine. Chatting with Kaz over the table revealed that import is a Java keyword and we need to prefix the field with something. Otherwise OK.

@kazcw kazcw added the CI: Ready to merge This PR is eligible for automatic merge label Aug 2, 2022
@mergify mergify bot merged commit 796b1b5 into develop Aug 2, 2022
@mergify mergify bot deleted the wip/kw/parser/import branch August 2, 2022 15:09
@@ -106,7 +106,9 @@ impl FromMeta {
let mut fields = Vec::with_capacity(fields_.size_hint().0);
for field in fields_ {
let meta::Field { name, type_, hide, .. } = field;
let name = name.to_camel_case().expect("Unimplemented: Tuples.");
let mut name_ = meta::FieldName::from_snake_case("field");
Copy link
Member

@JaroslavTulach JaroslavTulach Aug 9, 2022

Choose a reason for hiding this comment

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

This change renamed even the public getters. Now I see Line.getFieldExpression() methods & co. Workarounded by aa2b63a#r940901973

mergify bot pushed a commit that referenced this pull request Sep 3, 2022
…tions and signatures; fix field names (#3653)

Implements:
- UUIDs: https://www.pivotaltracker.com/story/show/182931137
- Comments: https://www.pivotaltracker.com/story/show/182981779
- Type annotations and signatures: https://www.pivotaltracker.com/story/show/182497454
- Fix getter names (#3627 (comment)).

# Important Notes
- I can't fully test UUIDs; I have tested that the data obtained in Rust matches my understanding of how the format is supposed to work. What remains to be tested is that the data in Java matches the way the old parser handles the format. So @JaroslavTulach, let me know if you see any cases where I'm not returning the same values.
- This implementation of type annotations and signatures accepts any expression in type context. It would probably be nice to narrow this down at some point, but for now I have no design info on what specifically should be allowed in type expressions; this implementation should be at least an incremental improvement.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: Ready to merge This PR is eligible for automatic merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants