Skip to content

Fix naming and availability in command palette of various commands#377

Merged
jcreedcmu merged 4 commits intogithub:masterfrom
jcreedcmu:jcreed/prefix
May 19, 2020
Merged

Fix naming and availability in command palette of various commands#377
jcreedcmu merged 4 commits intogithub:masterfrom
jcreedcmu:jcreed/prefix

Conversation

@jcreedcmu
Copy link
Copy Markdown
Contributor

No description provided.

@jcreedcmu jcreedcmu requested a review from aeisenberg May 19, 2020 13:11
@shati-patel
Copy link
Copy Markdown
Contributor

(Sorry, a few drive-by questions!)

  • Is there a reason for there to be two "CodeQL: Download database" commands? (codeQL.downloadDatabase and codeQL.chooseDatabaseInternet) They both show up in the Command Palette 🤔
  • Would it be okay to change that command to "CodeQL: Download Database", to keep the capitalization consistent with other commands?

This corrects what is an unfortunately common accidental antipattern,
where creating a command meant just to be the handler of a user
interface button ends up in the command palette unless you explicitly
set `"when": "false"` in the command palette section of the
configuration.

Also enforce the naming convention that commands prefixed with
`codeQLDatabases.` are those meant for the databases panel only, while
prefixing `codeQL.` means that it's meant to be directly accessible
through the command palette.
@jcreedcmu
Copy link
Copy Markdown
Contributor Author

Oh, good catch! I had misunderstood the problem. These unprefixed commands were not supposed to be in the command palette at all, but just hooked up to those database view buttons. The command codeQL.downloadDatabase is the palette command, and (what is now named, for consistency) codeQLDatabases.chooseDatabaseInternet is the command behind the corresponding button, and will no longer show up in the command palette as of the above commit.

"onCommand:codeQL.chooseDatabaseFolder",
"onCommand:codeQL.chooseDatabaseArchive",
"onCommand:codeQL.chooseDatabaseInternet",
"onCommand:codeQLDatabases.chooseDatabaseFolder",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I had thought the difference between the codeQL namespace and the codeQLDatabases namespace was that the latter accepted an existing database as an argument (and so was only applicable in the databases view). Whereas the former could be invoked in any context.

I see you're disabling them as global commands, so maybe that's what we want.

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.

Happy to be persuaded about choice of convention, but my intent so far about the codeQL$FOO.$BAR name structure (where $FOO is nonempty) was just about scoping to portions of the interface. Consider for example codeQLDatabases.sortByName which does not take a database as an argument, and things like codeQLQueryHistory.openQuery which are relevant to user events taking place in the query history view, but don't imply any particular constraints about the types of those handlers.

"when": "false"
},
{
"command": "codeQLDatabases.chooseDatabaseFolder",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we want to disable these as global commands?

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.

We definitely do want to disable these commands if we want to consistently maintain the pattern that the hover text over the buttons is not be prefixed, and the command palette command names is prefixed with CodeQL: . And I think both of those patterns are desirable.

However, we totally could also have command-palette-visible commands (which would be named, like, codeQL.chooseDatabaseFolder) which do the same thing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That makes sense. Maybe we don't want to pollute the global scope here with commands that are so tightly related to the databases view (I'm contradicting what I said earlier). So, what you have right now is fine.

@aeisenberg
Copy link
Copy Markdown
Contributor

Yes, this is inconsistent. Maybe the best solution is to simply remove codeQL.downloadDatabase. Is there any reason not to make the other commands globally available?

@jcreedcmu
Copy link
Copy Markdown
Contributor Author

Yes, this is inconsistent. Maybe the best solution is to simply remove codeQL.downloadDatabase. Is there any reason not to make the other commands globally available?

As commented above, I don't think we need to remove it, but I could make the naming of the internal command more consistent, and add command palette versions of the other two, just in case people are exploring around the command palette and/or prefer to do things with the keyboard instead of clicking on icons with the mouse. Commit incoming shortly...

@aeisenberg
Copy link
Copy Markdown
Contributor

Either way is fine: removing the palette command, or adding the 2 extra palette commands available consistently.

aeisenberg
aeisenberg previously approved these changes May 19, 2020
Copy link
Copy Markdown
Contributor

@aeisenberg aeisenberg left a comment

Choose a reason for hiding this comment

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

Nice. Thanks for fixing.

@jcreedcmu jcreedcmu changed the title Prefix command titles with "CodeQL:" Fix naming and availability in command palette of various commands May 19, 2020
Attempt to enforce some regularity in how we name commands, and fix
one command that was showing up improperly in the command palette.
@jcreedcmu jcreedcmu merged commit 0e4c3be into github:master May 19, 2020
@jcreedcmu jcreedcmu deleted the jcreed/prefix branch May 19, 2020 17:54
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.

3 participants