Skip to content

Jump-to-definition doesn't work on not-zipped source archives. #477

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

Open
jcreedcmu opened this issue Jun 25, 2020 · 8 comments
Open

Jump-to-definition doesn't work on not-zipped source archives. #477

jcreedcmu opened this issue Jun 25, 2020 · 8 comments
Labels
enhancement New feature or request VSCode

Comments

@jcreedcmu
Copy link
Contributor

Databases from LGTM are built with odasa rather than codeql, and so don't have zipped source archives, and require an extra codeql database cleanup step to zip the source archive before jump-to-definition works on them.

It would be nice in principle if it just worked out of the box. With the current strategy of making one DefinitionProvider for the zipped archive scheme, it doesn't seem possible. We could perhaps, for each database add and delete, register and unregister a DefinitionProvider with an absolute file path pattern matching files in that database's source archive. Alternatively it might be the case that registering a broadly applicable DefinitionProvider isn't harmful as long as it simply returns zero results when another DefinitionProvider also exists.

@jcreedcmu jcreedcmu added the enhancement New feature or request label Jun 25, 2020
@jcreedcmu
Copy link
Contributor Author

Actually, wait, no, here is one concrete reason why not to make a DefinitionProvider that matches every file everywhere: iiuc, the bare fact of it being registered means "Jump to Definition" will always be in the context menu, even when wildly inappropriate, like in arbitrary text files.

@aeisenberg
Copy link
Contributor

Since we are now actively zipping sources for zipped databases, is this still something worth working on?

@jcreedcmu
Copy link
Contributor Author

Assume you mean 'actively zipping sources for unzipped-source-archive databases, when they are downloaded from within the extension'. I think this issue is still worth keeping open to the extent that it's possible for someone to download a database from lgtm themselves and try to work with it in the extension.

@aeisenberg
Copy link
Contributor

Sure. Let's keep this open, though the priority is lower now.

@adityasharad
Copy link
Contributor

Instead of writing new definition providers, could we approach this by prompting the user when they first attempt jump-to-def, and then zipping up the source archive for the database they chose? That would allow us to reuse the work you've already done to support databases downloaded from LGTM within the extension. I think the two situations are similar enough that we should handle them in similar ways.

@aeisenberg
Copy link
Contributor

The difference is that if we zip sources in an unzipped database, that's a change to the user's files outside of the workspace and the extension's control. In general, it's not good practice for extensions to reach into the file system and make changes unless the user explicitly accepts them. We don't know if the user is relying on this structure in some way.

This case is a little different because:

  1. An unzipped source location is basically deprecated
  2. We are only updating the file system specific to Code QL.
  3. Also, we can choose to zip non-destructively if we avoid deleting the unzipped source folder.

Though, waiting until the user issues a Jump-to-def command to do the zipping will be difficult since we'd need to do a bunch of cleanup and workspace changes on the fly (like close the source files and re-open then from the zipped location) and update workspace folders). It might be easiest to do this on workspace startup or when the workspace is added.

@adityasharad
Copy link
Contributor

All wise points. Your suggestions (ask the user explicitly to make sure they are not relying on the structure, keeping the unzipped folder, and doing this operation at the time of loading the workspace / adding the database) reduce surprises for the user while hopefully still reducing the amount of new work that you would need to do.

@aeisenberg
Copy link
Contributor

Summarizing the points above. Here is the approach we can take:

  1. For existing databases with unzipped sources, prompt on startup to zip.
  2. For new databases, prompt when adding.

Some more things to be aware of:

  1. Should keep the unzipped folder
  2. Existing editors coming from unzipped source locations should be closed (only necessary when prompted at startup)
  3. Remove unzipped source folders from workspace
  4. Add a setting for this so that users are never prompted.
  5. Create a command so that users can forcibly unzip whenever they want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request VSCode
Projects
None yet
Development

No branches or pull requests

3 participants