-
Notifications
You must be signed in to change notification settings - Fork 13
New module template #871
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
base: main
Are you sure you want to change the base?
New module template #871
Conversation
rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/parametric/ParametricWorkspaceService.java
Show resolved
Hide resolved
DavyLandman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is heading in the right direction, it does need some extra love.
rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/rascal/RascalLanguageServices.java
Outdated
Show resolved
Hide resolved
rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/rascal/RascalLanguageServices.java
Outdated
Show resolved
Hide resolved
rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/rascal/RascalLanguageServices.java
Outdated
Show resolved
Hide resolved
rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/rascal/RascalTextDocumentService.java
Outdated
Show resolved
Hide resolved
rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/rascal/RascalTextDocumentService.java
Outdated
Show resolved
Hide resolved
| .thenApply(edits -> DocumentChanges.translateDocumentChanges(this, edits)) | ||
| .thenCompose(wsEdit -> wsEdit.getDocumentChanges().isEmpty() | ||
| ? null | ||
| : availableClient().applyEdit(new ApplyWorkspaceEditParams(wsEdit, "Auto-insert module headers"))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we mark these as needing a review? such that a user can see that this is happening, and accept it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, but then we should do #872 first (or hack it in Java here, which I am not a proponent of)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or finish this one, and add it after #872 is done
| for (f <- newFiles) { | ||
| try { | ||
| // check if file is empty | ||
| if (!(f.extension == "rsc" && exists(f) && isBlank(f))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about we check if there is a module <...> in there? as a user might already be typing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean? Aren't we out of luck when there are any contents anyway? Trying to race with a typing user seems tricky.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I was thinking more about if paste a new rascal file, so the copy already has code in there, but the wrong one?
But agreed, it might be more painful, so better only do it in empty files.
| try { | ||
| // Test if the qualified name is valid | ||
| parse(#QualifiedName, qname); | ||
| return "module <qname>\n\n// TODO Auto-generated module contents.\n"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
\n might not be the right newline for the current open editor tab. Would it not be simpler to either generate 2 text edits, one for line 1 and one for line 2?
Next to this: wat does "// TODO Auto-generated module contents mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good, idea, and I tried this. Unfortunately, we cannot use edits to add to non-existing lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you cannot insert a new line using a text edit? that seems weird?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll, an edit is just a replace. For an insert, the replace range should have start == end. I'll check how newlines are treated. Maybe VS Code maps them to the editor default anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My VS Code converts the newlines to the editor setting when the file is saved. So, is this really a concern in that case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, but that comment line should be removed, or heavily rephrased , as the current version doesn't make sense to a user. (Unless they recognize the pattern from java functions where a return value is generated that the user should change)
|



When the developer creates a Rascal file from within VS Code, automatically fill in the module header.
Closes #869