Skip to content

feat: hover over operators and override operators#536

Open
anakin4747 wants to merge 1 commit into
yoctoproject:stagingfrom
anakin4747:staging
Open

feat: hover over operators and override operators#536
anakin4747 wants to merge 1 commit into
yoctoproject:stagingfrom
anakin4747:staging

Conversation

@anakin4747

Copy link
Copy Markdown

Add hover documentation verbatim for all operators and override style operators '=', '?=', '??=', ':=', '+=', '=+', '.=', '=.', ':append', ':prepend', and ':remove'.

I didn't see an AI policy for this repo so I just used the AI policy of the Linux kernel

Assisted-by: OpenCode:big-pickle

weak-default-operator

@deribaucourt deribaucourt 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 useful for newcomers!
I love to see some vim screenshots as well 😄
Small comments on the tests.

const ASSIGNMENT_OPERATORS = new Set(['=', '?=', '??=', ':=', '+=', '=+', '.=', '=.'])
const OVERRIDE_OPERATORS = new Set(['append', 'prepend', 'remove'])
if (bitbakeNode !== null) {
const isAssignmentOperator = ASSIGNMENT_OPERATORS.has(bitbakeNode.type) && bitbakeNode.parent?.type === 'variable_assignment'

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.

You could do the type checks before the ASSIGNMENT_OPERATORS lookup, which will resolve mush faster in the general case.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Sounds good, I switched the order, let me know if thats what you meant

)
})

it('should show hover documentation for assignment operators', async () => {

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.

It is very thorough to have all the operators tested, but will also be harder to maintain. For instance, if the paragraphs in the Yocto doc change.
Could you keep just essential examples for each hover case? No need to exhaust all operators.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I left only the first of each plus the test for append when its not used as an operator

MYVAR =+ "prepended"
MYVAR .= "appendednospace"
MYVAR =. "prependednospace"
MYVAR:append = " append"

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 think it would be interesting to add a test case here checking that the " append" string part does not display the :append tooltip.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Sounds great! I added a test for append when it is not an operator

Add hover documentation verbatim for all operators and override style
operators '=', '?=', '??=', ':=', '+=', '=+', '.=', '=.', ':append',
':prepend', and ':remove'.

Assisted-by: OpenCode:big-pickle
@anakin4747

Copy link
Copy Markdown
Author

Thanks for taking the time to review it! Hopefully, it all looks good now!

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.

2 participants