Skip to content
This repository was archived by the owner on Jan 16, 2024. It is now read-only.

Support import aliases - #82

Merged
grouville merged 1 commit into
dagger:mainfrom
eonpatapon:pkg-alias
Aug 1, 2022
Merged

grouville merged 1 commit into
dagger:mainfrom
eonpatapon:pkg-alias

Conversation

@eonpatapon

Copy link
Copy Markdown
Contributor

It doesn't seem possible to get package aliases from cue's build
instances. They only seem to be used internally in the adt and not
exported in the public API.

Therefore the patch relies on the ast to record package aliases by
loaded file. When the selector of a definition isn't found we make some
extra calls to see if it's a package alias in the current file and find
the associated instance.

Closes #79

@grouville grouville left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Very elegant solution. Thanks for your contribution ! 🔥 Interested in @TomChv's opinion, but LGTM

@TomChv TomChv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for your PR, that's a really good improvement that should solve #79 🚀

However, I left a little question 👀
I'll play with your PR to make sure everything is ok but that looks great.

Comment thread plan/plan.go Outdated
Comment on lines +216 to +218
if i, found := p.imports[pkgName]; found {
return i, nil
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i is already set to the current instance no? Are Those 3 lines useful?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Absolutely not :)

Updated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice, thanks you 🚀

It doesn't seem possible to get package aliases from cue's build
instances. They only seem to be used internally in the adt and not
exported in the public API.

Therefore the patch relies on the ast to record package aliases by
loaded file. When the selector of a definition isn't found we make some
extra calls to see if it's a package alias in the current file and find
the associated instance.

Closes dagger#79
@TomChv

TomChv commented Aug 1, 2022

Copy link
Copy Markdown
Member

I tried it locally, it works well! 🚀
You can merge it when you want @grouville

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.

🐞 Jump to def do not support alias import

3 participants