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

Recognize crate plugin dependencies #208

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

integraledelebesgue
Copy link
Member

@integraledelebesgue integraledelebesgue commented Jan 21, 2025

Stack:

⚠️ Part of a stack created by spr. Do not merge manually using the UI - doing so may have unexpected results.

Cargo.toml Show resolved Hide resolved
src/project/builtin_plugins.rs Outdated Show resolved Hide resolved
src/project/builtin_plugins.rs Outdated Show resolved Hide resolved
@integraledelebesgue integraledelebesgue force-pushed the spr/main/fa144cb1 branch 2 times, most recently from 98cc352 to 321bd50 Compare January 22, 2025 17:21
src/project/mod.rs Show resolved Hide resolved
@piotmag769
Copy link
Contributor

Please don't merge until we have the metadata changes on main


let package_name = &plugin_metadata.package.repr;

if package_name.contains("assert_macros") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why .contains() instead of regular ==? We can make true here on package like assert_macros_but_better, don't we?

Copy link
Member Author

Choose a reason for hiding this comment

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

package_name stores a serialized name, containing the version and source. For assert_macros, it is assert_macros 2.9.2 (std). That's why this method checks whether the plugin is built in and then whether its name .contains the important part. Alternatively, we can tokenize those names and use == as you suggested, or use regular expression matching.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's fine, but please comment on this at least.

Copy link
Member Author

@integraledelebesgue integraledelebesgue Jan 23, 2025

Choose a reason for hiding this comment

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

Sure, I added an explanation

Copy link
Contributor

Choose a reason for hiding this comment

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

Now that I think about it maybe regex is indeed better xD

Copy link
Contributor

Choose a reason for hiding this comment

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

// The package discriminator has form: "<name> <version> (<source>)".

So maybe .starts_with("<name> ") (note space after name)?
You will not catch it in the source and it can be arbitrary link.

@integraledelebesgue integraledelebesgue force-pushed the spr/main/fa144cb1 branch 2 times, most recently from c43464a to c161fce Compare January 23, 2025 12:57
let package_discriminator = &plugin_metadata.package.repr;

// Check if the discriminator refers to a known built-in plugin package.
if package_discriminator.contains("assert_macros") {
Copy link
Member

@mkaput mkaput Jan 28, 2025

Choose a reason for hiding this comment

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

do at least this

Suggested change
if package_discriminator.contains("assert_macros") {
if package_discriminator.starts_with("assert_macros ") {

this will be immune to packages having this keyword in their source part

but I think to be entirely sure, you should not inspect the ID, but look for package metadata instead and do == equality over package name + possibly whitelist source

src/project/builtin_plugins.rs Show resolved Hide resolved
@@ -58,7 +58,7 @@ lsp-server = "0.7.8"
lsp-types = "=0.95.0"
memchr = "2.7.4"
salsa = { package = "rust-analyzer-salsa", version = "0.17.0-pre.6" }
scarb-metadata = "1.13"
scarb-metadata = { git = "https://github.com/software-mansion/scarb", branch = "spr/main/ac416d0e" } # TODO: Change back to crates-io as soon as changes from that branch are released there
Copy link
Member

Choose a reason for hiding this comment

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

Blocking until these changes are indeed released. I don't want to fall into trap when Cairo 2.10 is released and we don't have this fixed yet

Base automatically changed from spr/main/a1e078b6 to main February 6, 2025 13:36
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