Skip to content

Revert changes to codeQLModelEditor.jumpToMethod to allow jumping to usages other than the first usage#2977

Merged
robertbrignull merged 3 commits intomainfrom
robertbrignull/fix_jump_to_usage
Oct 16, 2023
Merged

Revert changes to codeQLModelEditor.jumpToMethod to allow jumping to usages other than the first usage#2977
robertbrignull merged 3 commits intomainfrom
robertbrignull/fix_jump_to_usage

Conversation

@robertbrignull
Copy link
Copy Markdown
Contributor

In #2926 I was trying to simplify the code as much as possible, but I accidentally changed the codeQLModelEditor.jumpToMethod command which does need to be able to jump to usages other than the first usage.

This PR reverts the changes to that command and makes it work again. This does require adding a new getMethod method to the modeling store.

I did consider another way of implementing this which was to add a usageIndex: number field to the command. That also worked, but I decided it was safer to just revert the changes from the earlier PR and stick more closely to the original state of the code.

Checklist

  • CHANGELOG.md has been updated to incorporate all user visible changes made by this pull request.
  • Issues have been created for any UI or other user-facing changes made by this pull request.
  • [Maintainers only] If this pull request makes user-facing changes that require documentation changes, open a corresponding docs pull request in the github/codeql repo and add the ready-for-doc-review label there.

@robertbrignull robertbrignull requested review from a team as code owners October 16, 2023 09:42
@robertbrignull robertbrignull changed the title Revert changes to codeQLModelEditor.jumpToMethod Revert changes to codeQLModelEditor.jumpToMethod to allow jumping to usages other than the first usage Oct 16, 2023
Comment thread extensions/ql-vscode/src/common/commands.ts Outdated
}

public setSelectedMethod(dbItem: DatabaseItem, methodSignature: string) {
public setSelectedMethod(dbItem: DatabaseItem, method: Method, usage: Usage) {
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.

Should we add a comment to this method to specify that the method and usage need to have been retrieved from the modeling store? Theoretically you could pass in a usage received from the webview which might cause other code relying on object referential identity to break.

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.

That's a good point. I'll add a comment about that.

It might be nice if we could avoid pitfalls like this, but I'm not fully convinced yet if other approaches are better.

@robertbrignull robertbrignull merged commit b1a4586 into main Oct 16, 2023
@robertbrignull robertbrignull deleted the robertbrignull/fix_jump_to_usage branch October 16, 2023 10:21
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