Skip to content
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

Fix: Trigger watch event on file change #30

Conversation

WilsonZiweiWang
Copy link
Contributor

No description provided.

@WilsonZiweiWang WilsonZiweiWang added the bug Something isn't working label Dec 7, 2023
@WilsonZiweiWang WilsonZiweiWang self-assigned this Dec 7, 2023
client/src/language/languageClient.ts Show resolved Hide resolved
workspace.createFileSystemWatcher('**/*.bb', false, true, false),
workspace.createFileSystemWatcher('**/*.conf', false, true, false)
workspace.createFileSystemWatcher('**/*.bbclass', false, false, false),
workspace.createFileSystemWatcher('**/*.inc', false, false, false),
Copy link
Member

Choose a reason for hiding this comment

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

I think I've seen that the watcher event runs rescan-project instead of just parsing. rescan would be too slow for file changes IMO.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From my observation, I have seen multiple parses on a single file save but I didn't see it triggered scan.

Copy link
Member

Choose a reason for hiding this comment

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

Elinor has had trouble with the watcher events. I think that if it's not properly configured, it will infinetely keep parsing/scanning. On disk changes should not happen in any uncontrolled manner in our workflows. I wonder if we shouldn't just drop any kind of file watch?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is some code for embedded languages in the watch function. If we are worried about the parse/scan, we can remove the function call to parse and figure out something else to trigger it.

workspace.createFileSystemWatcher('**/*.bbclass', false, false, false),
workspace.createFileSystemWatcher('**/*.inc', false, false, false),
workspace.createFileSystemWatcher('**/*.bb', false, false, false),
workspace.createFileSystemWatcher('**/*.conf', false, false, false)
Copy link
Member

Choose a reason for hiding this comment

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

This feature should be configurable and also not run if settings are not sane. Look for the mecanisms for this in server.ts on file save and make sure they are applied to watched changes. Could reuse the same settings?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The onDidSave currently also triggers parseAllRecipes, and usually saving a file will now trigger the change event (because I changed the boolean value to false). Hence the multiple parses as I mentioned in another conversation. I would prefer to remove the code in onDidSave.

As for the settings, do we want to have a general setting for all files or one for each file type? Also, in case you don't know, those 3 boolean values in the createFileSystemWatcher are respectively createEvent, changeEvent and deleteEvent. These may all be configurable.

Copy link
Member

Choose a reason for hiding this comment

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

Bitbake files can only be modified if:

  • the user edits them (so he will save them and we already start parse)
  • the user runs devtool commands (we already rescan just what's necessary)
    So I think we should plainly remove this feature. There's no external bitbake modfications that require any action as I'm aware of.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some possible modifications are coming from git. Which was the main reason I created the ticket in the redmine

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if we don't care about git, then we can remove the feature and close this PR

Copy link
Member

Choose a reason for hiding this comment

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

onDidSave is very usefull to get bitbake diagnostics quickly. Since scanning is so massive, I think we should remove the watchedFiles features. I probed other internal users and they unanimously agreed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Then we might want to remove the parseAllRecipes from connection.onDidChangeWatchedFiles for now. The modification of the rest needs Io's attention

Copy link
Member

Choose a reason for hiding this comment

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

Yes we should remove any kind of Watched Files features 👍

Choose a reason for hiding this comment

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

Some possible modifications are coming from git. Which was the main reason I created the ticket in the redmine

If it matters, non-opened files could also change with "rename" and "Replace All" (I personally use this one all the time). I would not be surprised if there are other ways.

"EmbeddedLanguageDocsManager" use "workspace.onDidRenameFiles" and "workspace.onDidDeleteFiles" in order to avoid keeping data of non-existing files and have a memory leak. That being said, I assume the user would have to create, delete and rename millions of documents before it becomes noticeable. So I guess we can do without it.

Copy link
Member

@deribaucourt deribaucourt left a comment

Choose a reason for hiding this comment

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

I think we should rather remove any kind of file watching features as discussed in this thread. Parsing when saving is already pretty intrusive and scanning is too long to be automated.

@WilsonZiweiWang
Copy link
Contributor Author

Closed as discussed in the conversations.

@WilsonZiweiWang WilsonZiweiWang deleted the Bug-13773-watch-file-on-change branch January 29, 2024 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants