Skip to content

Refine error message with package name suggestion #6897

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

Conversation

mininny
Copy link
Contributor

@mininny mininny commented Sep 14, 2023

Update error message when there's a package target with a similar name as the one provided in the dependency.

Motivation:

Partially addresses #4803.

It adds a suggestion for an alternative dependency name when there's a dependency target with similar name as the one provided in the Package.swift.

Modifications:

Use the existing bestMatch(for, from) from TSCBasic to compare the productRef.name and allTargetNames.
However, I'm not sure how and if I can include target from system packages.

Result:

Error messages for package target not found may also suggest an alternative name like:
product 'Barx' required by package 'foo' target 'FooTarget' not found. Did you mean 'Bar'?

@MaxDesiatov MaxDesiatov changed the title Add fix-its with package name suggestion. Add fix-its with package name suggestion Sep 14, 2023
Copy link
Contributor

@MaxDesiatov MaxDesiatov left a comment

Choose a reason for hiding this comment

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

Is this a true fix-it? I.e. is it displayed as an actionable fix-it that users can easily apply when parsed by Xcode or SourceKit-LSP?

@mininny
Copy link
Contributor Author

mininny commented Sep 16, 2023

Is this a true fix-it? I.e. is it displayed as an actionable fix-it that users can easily apply when parsed by Xcode or SourceKit-LSP?

No, this is not a true fix-it that users can interact on(e.g. click to replace text). It's just a text inside warning that gives a clue about detecting typos.

@mininny mininny force-pushed the add-fix-it-for-similar-package-dependency branch from e6d992c to efd8395 Compare September 16, 2023 09:44
@mininny mininny force-pushed the add-fix-it-for-similar-package-dependency branch from efd8395 to ab88fd3 Compare September 16, 2023 10:19
@MaxDesiatov MaxDesiatov changed the title Add fix-its with package name suggestion Refine error message with package name suggestion Sep 18, 2023
@MaxDesiatov
Copy link
Contributor

@swift-ci test

@MaxDesiatov MaxDesiatov enabled auto-merge (squash) September 18, 2023 11:13
@MaxDesiatov MaxDesiatov merged commit 9ae01ed into swiftlang:main Sep 18, 2023
MaxDesiatov pushed a commit that referenced this pull request Sep 28, 2023
… provided in the dependency (#6897)

Update error message when there's a package target with a similar name as the one provided in the dependency.

### Motivation:
Partially addresses #4803.

It adds a suggestion for an alternative dependency name when there's a dependency target with similar name as the one provided in the `Package.swift`.

### Modifications:
Use the existing `bestMatch(for, from)` from TSCBasic to compare the `productRef.name` and `allTargetNames`. 
However, I'm not sure how and if I can include target from system packages. 

### Result:
Error messages for package target not found may also suggest an alternative name like: 
`product 'Barx' required by package 'foo' target 'FooTarget' not found. Did you mean 'Bar'?`
MaxDesiatov pushed a commit that referenced this pull request Sep 28, 2023
… provided in the dependency (#6897)

Update error message when there's a package target with a similar name as the one provided in the dependency.

### Motivation:
Partially addresses #4803.

It adds a suggestion for an alternative dependency name when there's a dependency target with similar name as the one provided in the `Package.swift`.

### Modifications:
Use the existing `bestMatch(for, from)` from TSCBasic to compare the `productRef.name` and `allTargetNames`. 
However, I'm not sure how and if I can include target from system packages. 

### Result:
Error messages for package target not found may also suggest an alternative name like: 
`product 'Barx' required by package 'foo' target 'FooTarget' not found. Did you mean 'Bar'?`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants