-
Notifications
You must be signed in to change notification settings - Fork 60
feat: Add support for custom code templates (fix #987) #988
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?
Conversation
|
@travkin79 to be consistent with other existing class, I suggest that you use |
I didn't find a way to satisfy the compiler with adapting the return type or modifying the returned value. It always complains about incompatible nullability constraints on the Iterator type in the method signature.
|
Please add some screenshots to this PR. Thanks! |
|
@travkin79 I noticed that you have changed the Tm4e with Tm, please use |
I think it should be very cool to update the docs with screenshot. |
Hi @sebthom, New preferences dialog (very similar to the "Templates" preferences in JDT and CDT, due to reusing code from the Eclipse platform): Users can add custom code templates for registered languages by pressing the "New" button in the preferences dialog. Here is how the dialog for new code templates looks like (again very similar to the corresponding dialog in JDT and CDT): The context (context types) list is automatically created by checking registered grammars / languages. In the "New Template" dialog, you'll get a list of all available languages / scopes: Pushing the button "Insert variable" in the "New Template" dialog shows available code template variables (currently only the language-independent ones): The preview source viewer in the preferences dialog uses the syntax highlighting associated with the registered grammar corresponding to the template's context type, here Java: In an editor with syntax highlighting activated through TM4E, users get code proposals based on existing code templates: |
|
@travkin79 it looks super great! Congrats! But IMHO I think you should also support vscode snippet. TM4E already supports:
that you can share between vscode and Eclipse IDE. VSCode snippets is the last part which misses. For instance instead of using cursor or selection, you should use snippet syntax If you can support that, you could copy/paste for instance https://github.com/redhat-developer/vscode-java/blob/main/snippets/server.json and use it directly. And it would be very nice to provide an extension point to contribute to TM4E with snippet like we have for textmate and language configuration. If you can manage that, you could share snippets from all existing vscode extension and it will be very easy for developer to manages snippets for vscode and Eclipse IDE both. Please note that IntelliJ supports also vscode snippets. |
|
Hello @angelozerr, I see the benefits of VSCode syntax support. But I think, it would also demand a lot of work to add VSCode snippet support. For that reason I prefer to begin with a smaller feature set, without VSCode snippet syntax support for now. We can add that feature later with a separate PR (see my issue comment on that). In my implementation, I tried to reuse as many code template support code from the Eclipse platform as possible and though, it was already quite some work to get that far. Now, I'd like to clarify if I'm on the right way with my concept of using
In addition, I'd like to finish my implementation and clarify / improve a few things in code. Most of these things can be found in TODO comments in my changed files.
|
Those screenshot and description should be included in the doc that @sebthom has written |






This PR fixes issue #987 and adds