Everlaw / nbts

NetBeans TypeScript editor plugin
282 stars 46 forks source link

Code templates missing in code completion #67

Closed Chris2011 closed 7 years ago

Chris2011 commented 8 years ago

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

jeffrey-easyesi commented 8 years ago

How do code templates appear in JS code completion? I'm not seeing them.

junichi11 commented 8 years ago

Would you like me to do it? nbts-issue67

Thanks.

Chris2011 commented 8 years ago

@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)

Chris2011 commented 8 years ago

It's coming in NB 8.2

junichi11 commented 8 years ago

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 ;)

Chris2011 commented 7 years ago

@jeffrey-easyesi can you accept that @junichi11 can make a PR please or is there smth wrong with it?

jeffrey-easyesi commented 7 years ago

Fixed in 2.1.4.1

Chris2011 commented 7 years ago

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.

Chris2011 commented 7 years ago

Please let me reopen the ticket, because it is not working or reopen by your own.

jeffrey-easyesi commented 7 years ago

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.

Chris2011 commented 7 years ago

As a test, I created a code template for JavaScript: ddd: js-custom-code-tpl

it is not showing inside the code completion.

Then I created a code template for TypeScript, because it is already there: dam: ts-custom-code-tpl

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: ng2-custom-code-tpl

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.

Chris2011 commented 7 years ago

So you can install my plugin and test it on your own.

jeffrey-easyesi commented 7 years ago

Try adding the contexts="JavaScript-Code" attribute to your <codetemplate> elements

Chris2011 commented 7 years ago

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.

Chris2011 commented 7 years ago

It should work out of the box, when I create a new code template for JS or TypeScript.

jeffrey-easyesi commented 7 years ago

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)

Chris2011 commented 7 years ago

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.

jeffrey-easyesi commented 7 years ago

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.

Chris2011 commented 7 years ago

Ok but doesn't that mean, that the TS code templates will appear in JS files too? Or is there an other check?

jeffrey-easyesi commented 7 years ago

Code templates are tied to a particular MIME type (text/javascript vs. text/typescript)

Chris2011 commented 7 years ago

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.