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

feat(compiler): bring directories #4210

Merged
merged 36 commits into from
Sep 27, 2023
Merged

feat(compiler): bring directories #4210

merged 36 commits into from
Sep 27, 2023

Conversation

Chriscbr
Copy link
Contributor

@Chriscbr Chriscbr commented Sep 18, 2023

This pull request adds support for bringing directories. Bringing a directory will make all types defined in the files in a directory accessible through the alias defined by the user:

bring "./aws" as aws;

If a symbol like "Bucket" is defined multiple times inside files at the same hierarchical level of "aws", an error will be raised saying that there are multiple definitions of "Bucket" inside the directory. If the directory contains subdirectories, it will be available through a child namespace inside aws. For example, aws.storage will contain types from all aws/storage/*.w files.

To achieve this, I had to figure out some way to model symbol lookups in a directory, where there might be multiple symbol environments that have to be looked up before finding a symbol. To that end, I changed Namespace so instead of storing a single single environment, it stores a vector of symbol environments, as this seemed like the least invasive change.

Future items:

Checklist

  • Title matches Winglang's style guide
  • Description explains motivation and solution
  • Tests added (always)
  • Docs updated (only required for features)
  • Added pr/e2e-full label if this feature requires end-to-end testing

By submitting this pull request, I confirm that my contribution is made under the terms of the Wing Cloud Contribution License.

libs/wingc/src/parser.rs Outdated Show resolved Hide resolved
@monadabot
Copy link
Contributor

monadabot commented Sep 18, 2023

Console preview environment is available at https://wing-console-pr-4210.fly.dev 🚀

Updated (UTC): 2023-09-27 17:56

@monadabot monadabot added the ⚠️ pr/review-mutation PR has been mutated and will not auto-merge. Clear this label if the changes look good! label Sep 20, 2023
@Chriscbr Chriscbr changed the title [WIP] feat(compiler): bring directories feat(compiler): bring directories Sep 25, 2023
@Chriscbr Chriscbr marked this pull request as ready for review September 25, 2023 18:01
@Chriscbr Chriscbr requested a review from a team as a code owner September 25, 2023 18:01
@Chriscbr Chriscbr removed the ⚠️ pr/review-mutation PR has been mutated and will not auto-merge. Clear this label if the changes look good! label Sep 25, 2023
docs/docs/03-language-reference.md Show resolved Hide resolved
docs/docs/03-language-reference.md Outdated Show resolved Hide resolved
libs/wingc/src/file_graph.rs Show resolved Hide resolved
libs/wingc/src/jsify.rs Show resolved Hide resolved
libs/wingc/src/jsify.rs Show resolved Hide resolved
libs/wingc/src/lsp/completions.rs Outdated Show resolved Hide resolved
libs/wingc/src/parser.rs Show resolved Hide resolved
libs/wingc/src/parser.rs Outdated Show resolved Hide resolved
libs/wingc/src/type_check.rs Show resolved Hide resolved
examples/tests/valid/subdir2/file1.w Show resolved Hide resolved
@monadabot monadabot added the ⚠️ pr/review-mutation PR has been mutated and will not auto-merge. Clear this label if the changes look good! label Sep 26, 2023
@Chriscbr Chriscbr removed the ⚠️ pr/review-mutation PR has been mutated and will not auto-merge. Clear this label if the changes look good! label Sep 26, 2023
@Chriscbr Chriscbr requested a review from eladb September 26, 2023 20:06
examples/tests/invalid/subdir/other.w Show resolved Hide resolved
docs/docs/03-language-reference.md Show resolved Hide resolved
docs/docs/03-language-reference.md Show resolved Hide resolved
examples/tests/valid/bring_local_dir.test.w Show resolved Hide resolved
examples/tests/valid/struct_from_json.test.w Outdated Show resolved Hide resolved
examples/tests/valid/subdir2/inner/widget.w Show resolved Hide resolved
libs/wingc/src/ast.rs Outdated Show resolved Hide resolved
libs/wingc/src/parser.rs Show resolved Hide resolved
libs/wingc/src/parser.rs Outdated Show resolved Hide resolved
libs/wingc/src/parser.rs Show resolved Hide resolved
libs/wingc/src/type_check.rs Show resolved Hide resolved
@mergify
Copy link
Contributor

mergify bot commented Sep 27, 2023

Thanks for contributing, @Chriscbr! This PR will now be added to the merge queue, or immediately merged if rybickic/bring-dir is up-to-date with main and the queue is empty.

mergify bot added a commit that referenced this pull request Sep 27, 2023
@mergify mergify bot merged commit a1ed608 into main Sep 27, 2023
15 checks passed
@mergify mergify bot deleted the rybickic/bring-dir branch September 27, 2023 18:47
@monadabot
Copy link
Contributor

Congrats! 🚀 This was released in Wing 0.33.17.

@eladb
Copy link
Contributor

eladb commented Sep 28, 2023

Horray!

@Chriscbr Chriscbr mentioned this pull request Sep 29, 2023
5 tasks
mergify bot pushed a commit that referenced this pull request Oct 5, 2023
Introduces the `wing pack` command - a standard way to package libraries in Wing.

`wing pack` can be run in any Wing project directory that has a `package.json` in it. `wing pack` will validate your `package.json` produce a tarball that contains the libraries source files. For more documentation, see https://winglang.io/docs/libraries.

## Implementation

When you `bring "foo"`, the parser now performs some Node module resolution to look up the `foo` package and see if it's a JSII library or a Wing library based on its `package.json`. If `bring "foo"` refers to a Wing library, then it's equivalent to bringing that library's root directory, per #4210.

## Future related work
- #4415
- #4294
- #2171

## Checklist

- [x] Title matches [Winglang's style guide](https://www.winglang.io/contributing/start-here/pull_requests#how-are-pull-request-titles-formatted)
- [x] Description explains motivation and solution
- [x] Tests added (always)
- [x] Docs updated (only required for features)
- [ ] Added `pr/e2e-full` label if this feature requires end-to-end testing

*By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*.
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.

5 participants