-
Notifications
You must be signed in to change notification settings - Fork 414
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
Fill in package for newly created file #1222
Comments
@testforstephen will adopt this. |
From the API documentation, the file events could be from file explorer, or If the new file is created from file explorer, it makes sense to pre-populate some contents based on the context. But if the new file is from For example, the Java extension provides a quick fix to create the missing type, where the workspace edit will contain an operation to new a file and a text edit to populate the class contents. The client doesn't need do anything for this file create event. There are similar issues on the rename event. When an user is renaming a class name from the symbol, the Java extension will return a workspace edit to rename its Java file too. It's unnecessary for the client to watch such events to do something. // @jrieken |
No, you cannot know what triggered the event. Still, when using |
this is the ideal situation, but the actual sequence won't support that. See the sequence i observed: So at the onDidCreateFiles event, actually the language server didn't receive the previous edit change yet, so cannot tell the file is empty. |
You can "change" the sequence by opening the document while handling the event. The onDid-event doesn't wait for you and it can use these files just as hint as way of "this file has been created, keep this in mind and fill in default when I know more and when it makes sense" |
ok, thanks. I managed to exclude non-empty new files via Now regarding to the rename events, it's a little complicated.
|
For us, rename and move are the same. So, I don't know how you would differentiate between them?
Not sure what you mean? Are you concerned that you could have caused the move and that there is nothing that needs to be done? Is there a "move to new folder" refactoring or how does this happen? |
I understand rename in VS Code is generic, it's just because our Java implementation uses different logic to handle them. Currently i will check whether the oldUri and newUri is in the same directory to tell it's a rename or move. yes, the Java extension provides a "move" refactoring in the editor context. And when the menu is clicked, it will prompt a quick pick to tell user to select the destination, after that the language server calculates a workspace edit and apply the move operation. What i want is to exclude such kind of rename event in the client rename listener, because the move refactoring already contains both file rename and import update. |
Understood - we could add a |
I have created microsoft/vscode#93470 for this |
Cool. that's exactly what i want. |
When creating a new file, e.g
Foo.java
inside thecom.mycomp.app
-folder then the extension should use the newvscode.workspace.on[Will|Did]CreateFile
-api to fill in some default content, esp thepackage
-declarationpackage com.mycomp.app
etc.Environment
Steps To Reproduce
Current Result
File is empty
Expected Result
File should be pre-populated
The text was updated successfully, but these errors were encountered: