Closed Chris2011 closed 7 years ago
How do code templates appear in JS code completion? I'm not seeing them.
Would you like me to do it?
Thanks.
@junichi11 it would be very nice, if you can do this. Thx.
@jeffrey-easyesi here is the implementation from Petr Pisl: https://netbeans.org/bugzilla/show_bug.cgi?id=259167 (http://hg.netbeans.org/web-main/rev/12efdfd69406)
It's coming in NB 8.2
I can do it (and can send a PR) :) But I follow the author because this is not my repo. I don't do anything if the author will fix it ;)
@jeffrey-easyesi can you accept that @junichi11 can make a PR please or is there smth wrong with it?
Fixed in 2.1.4.1
Unfortunately it is not working. No code templates are inside the code completion. When I type 'ng2' I expect the code completion comes up with the codetemplates for ng2... I have the latest version of the plugin.
Please let me reopen the ticket, because it is not working or reopen by your own.
There are no code templates starting with ng2
in JavaScript in a stock NetBeans installation - did you add them yourself? If you go to Tools > Options > Editor > Code Templates you can customize code templates for any language.
As a test, I created a code template for JavaScript: ddd:
it is not showing inside the code completion.
Then I created a code template for TypeScript, because it is already there: dam:
it is not showing inside the code completion.
Why I ask for this is, I created a plugin which creates code templates for ng2 for TypeScript: https://github.com/Chris2011/netbeans-angular2-code-templates
it add those code templates:
All code templates are working:
ddd -> TAB -> expands dam -> TAB -> expands ng2-pipe -> TAB -> expands
BUT they will be not showing inside the code completion.
So you can install my plugin and test it on your own.
Try adding the contexts="JavaScript-Code"
attribute to your <codetemplate>
elements
Sure I can but ddd and dam were added via the options Menu and there I can't add such option. So this is an error or missing function in your plugin. Please add it.
It should work out of the box, when I create a new code template for JS or TypeScript.
When you add a new code template in the options dialog, it won't appear in code completion in any contexts by default, you have to go to the Contexts tab. (right now the Contexts tab isn't appearing for TypeScript - this will be fixed with https://github.com/Everlaw/nbts/issues/86)
Ok I see, can you give me the correct context for TypeScript? Is it TypeScript-Code? So I can added those to it. Because it is TypeScript and not a JS code template.
No, I'm using the same name "JavaScript-Code" for easier merging of future changes from NetBeans javascript2.editor/src/org/netbeans/modules/javascript2/editor/resources/codetemplates.xml.
Ok but doesn't that mean, that the TS code templates will appear in JS files too? Or is there an other check?
Code templates are tied to a particular MIME type (text/javascript vs. text/typescript)
I will update my plugin with adding contexts="JavaScript-Code" what you mentioned. It works good. I have one problem. My code templates look like ng2-subscribe. After hitting "-" the code completion disappears. But atm, I don't know whether it is a problem with your plugin or a general problem with NetBeans.
I created a ticket for missing code templates in JS in netbeans, so the same happens here too. I can create new code templates like ctor but first, the code templates which are still there will not be shown inside the code completion and the custom code templates too. So please add the code templates to the code completion.
Cheers
Chris