Re: Code Completion
Emilian Bold <[email protected]> Thu, 30 Mar 2017 09:05:11 +0300
| Newsgroups | gmane.comp.java.netbeans.devel |
|---|---|
| Message-ID | <CAL6R17DiLN6uAagyhxm8dAHSH6K9kDtn_iXVPTi6_H6fOQ-nmg@mail.gmail.com> |
--001a1142e0c032170f054bec7c2a Content-Type: text/plain; charset=UTF-8 A CompletionItem is literally a line in the completion popup. Did you inject your completion item in the completion via some CompletionProvider? I guess you want a listener actually, but I'm not certain we have an official API for that. https://platform.netbeans.org/tutorials/nbm-code-completion.html --emi On Tue, Mar 28, 2017 at 11:47 PM, melG <[email protected]> wrote: > Hello, > I want to perform some action when a code completed. > > For instance, when "toString" method completed, I will perform my action. > > I've found that in "CompletionItem" class has a > "defaultAction(JTextComponent component)" method which is invoked, after > pressing VK_ENTER or double-clicking on that item. > > http://bits.netbeans.org/dev/javadoc/org-netbeans-modules- > editor-completion/org/netbeans/spi/editor/completion/CompletionItem.html > > Simply, I tried to print something to output as follows: > > > Code: > > public class SomeCompletionItem implements CompletionItem { > ... > @Override > public void defaultAction(JTextComponent component) { > System.out.println("Code Completed."); > } > ... > } > > > > But I did not anything printed. Is there something I'm missing or is there > any way that I can do that? > > > > > --001a1142e0c032170f054bec7c2a Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">A CompletionItem is literally a line in the completion pop= up. Did you inject your completion item in the completion via some Completi= onProvider?<div><br></div><div>I guess you want a listener actually, but I&= #39;m not certain we have an official API for that.</div><div><br></div><di= v><a href=3D"https://platform.netbeans.org/tutorials/nbm-code-completion.ht= ml">https://platform.netbeans.org/tutorials/nbm-code-completion.html</a>=C2= =A0</div></div><div class=3D"gmail_extra"><br clear=3D"all"><div><div class= =3D"gmail_signature" data-smartmail=3D"gmail_signature"><div dir=3D"ltr"><d= iv><br></div><div>--emi<br></div></div></div></div> <br><div class=3D"gmail_quote">On Tue, Mar 28, 2017 at 11:47 PM, melG <span= dir=3D"ltr"><<a href=3D"mailto:[email protected]" target=3D"_blan= k">[email protected]</a>></span> wrote:<br><blockquote class=3D"gm= ail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-le= ft:1ex">Hello,<br> I want to perform some action when a code completed.<br> <br> For instance, when "toString" method completed, I will perform my= action.<br> <br> I've found that in "CompletionItem" class has a "default= Action(JTextComponent component)" method which is invoked, after press= ing VK_ENTER or double-clicking on that item.<br> <br> <a href=3D"http://bits.netbeans.org/dev/javadoc/org-netbeans-modules-editor= -completion/org/netbeans/spi/editor/completion/CompletionItem.html" rel=3D"= noreferrer" target=3D"_blank">http://bits.netbeans.org/dev/<wbr>javadoc/org= -netbeans-modules-<wbr>editor-completion/org/<wbr>netbeans/spi/editor/<wbr>= completion/CompletionItem.html</a><br> <br> Simply, I tried to print something to output as follows:<br> <br> <br> Code:<br> <br> public class SomeCompletionItem implements CompletionItem {<br> =C2=A0 =C2=A0...<br> =C2=A0 =C2=A0@Override<br> =C2=A0 =C2=A0public void defaultAction(JTextComponent component) {<br> =C2=A0 =C2=A0 =C2=A0 System.out.println("Code Completed.");<br> =C2=A0 =C2=A0}<br> =C2=A0 =C2=A0...<br> }<br> <br> <br> <br> But I did not anything printed. Is there something I'm missing or is th= ere any way that I can do that?<br> <br> <br> <br> <br> </blockquote></div><br></div> --001a1142e0c032170f054bec7c2a--