KEMBAR78
Improve the completion for attribute arguments by MartinGC94 · Pull Request #25129 · PowerShell/PowerShell · GitHub
Skip to content

Conversation

@MartinGC94
Copy link
Contributor

@MartinGC94 MartinGC94 commented Mar 5, 2025

PR Summary

Improves the argument completion for attributes so it can work in all scenarios I can think of.
Today the attribute completion only works reliably when you have a variable to bind the attribute to, as the parser throws away the AttributeAst if it can't find a variable. I have fixed this by adding the parsed AttributeAsts to the ErrorExpression that would be created in this case.
Inside a param block the parser already keeps the parsed attributes like this so I have updated the completion code to also handle how the attributes are stored for incomplete parameters inside the param block.

PR Context

Fixes #25111

Regression comes from #17902

PR Checklist

@iSazonov
Copy link
Collaborator

iSazonov commented Mar 5, 2025

@MartinGC94 If it is a regression could you please point in the PR description where it comes from (PR/commit)? If possible of course.

@MartinGC94
Copy link
Contributor Author

It seems to have been this one: #17902 but this new PR is not just a fix for this regression. It's (hopefully) a fix for all the oddities regarding attribute argument completion.

@MartinGC94 MartinGC94 changed the title Improve the completion for arguments Improve the completion for attribute arguments Mar 5, 2025
@iSazonov iSazonov self-assigned this Mar 5, 2025
@iSazonov iSazonov added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Mar 5, 2025
@MartinGC94
Copy link
Contributor Author

Hmm, looks like I was a bit too ambitious with what it could do. I removed the test as I don't see a way to fix it. There are no related asts around the cursor on a new line so I can't really find my way back to the attribute ast and be sure that this is what should be completed. It's not terribly important though, I've never seen anyone place attribute arguments on separate lines.

@iSazonov

This comment was marked as outdated.

@azure-pipelines

This comment was marked as outdated.

@iSazonov iSazonov enabled auto-merge (squash) March 6, 2025 12:57
@iSazonov iSazonov merged commit d820692 into PowerShell:master Mar 6, 2025
39 of 41 checks passed
@microsoft-github-policy-service
Copy link
Contributor

microsoft-github-policy-service bot commented Mar 6, 2025

📣 Hey @MartinGC94, how did we do? We would love to hear your feedback with the link below! 🗣️

🔗 https://aka.ms/PSRepoFeedback

@MartinGC94 MartinGC94 deleted the ImproveAttributeCompletion branch March 6, 2025 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7.4+ Regression: Attribute Value Completion if variable isn't defined.

2 participants