Snipmatch Code Recommender plugin does not work for custom repository - eclipse

I just created a repository to share our team snippets, and although everyone can see, update, and push new snippets, none of them appear on the Java Editor auto complete.
For testing purposes I created a new snippet (arrayremove) copying the configuration from an existing one (arraymerge).
What am I doing wrong? Am I missing something? Or is this a bug?

Quick Answer
You have to press CTRL+ALT+SPACE to start the Snipmatch snippet search. Snipmatch snippets will not appear in the normal content assist popup.
Background
As one of the developers of the Code Recommenders Snipmatch plugin, let me give you a little bit of background information.
Snipmatch uses a separate shortcut to trigger a search to allow more intelligent snippet searches. For example, the search string may contain spaces and will find keywords defined as an Extra Search Term or as a Tag. Or you can use wildcards * in your search string.
You can change the shortcut on the Preferences > General > Keys preference page. Look for the Snipmatch Snippet Completion binding.
For more information, have a look at the Snipmatch manual.
if you need further support with Snipmatch, you can also contact me directly or go to the Code Recommenders forum.

Related

Is there a way for content assist to allow wildcard characters in Eclipse?

This is not the first time that I would have needed that... In the example bellow I would love to have all set*Listeners listed so I wouldn't have to scroll trough all the houndreds of methods to find the listener setter I need.
Is there a way to do that, or any alternative that lets me search trough the content assist results more effectively? (Allowing a wildcard character would be a really good start)
The Eclipse Code Recommenders project includes subwords completion which seems to be what you are looking for. In your example, it will find setListener when completing on sLis. You don't even have to type in a wildcard.
Keep in mind that subwords completion is not activated by default. Go to Preferences > Code Recommenders > Completions and activate the Subwords-Completion Processor.

Is there a way to create templates for text files in Eclipse?

In Eclipse, I really enjoy being able to create templates for things I commonly write in Java and XML. While there is some room for improvement, templates have proven to be quite the time saver. Today I was documenting some notes in the release notes. We have a specific format that we write said release notes in. I thought it would be handy to write a small template so that I could easily insert most of the boiler plate text when I amend the notes. So I dug around the eclipse settings and didn't see anything for plain text files. I googled around and also didn't see anything.
So is what I'm wanting to do possible in Eclipse? Is there a plugin I would need to enable such a feature?
I assume the closest you can get is using Snippets
Add the view by clicking Window -> Show View -> Snippets. In that view, right-click and select Customizeto create custom snippets. You can now add those snippets in your textfile by double-clicking them.
Maybe there is also some shortcut feature I didn't find yet...

how modify the already installed content-assist?

First of, how can I see what plugin manages the CTRL + SPACE content-assist? And how can I modify it in other to add my own stuff. Any help/idea is gladly welcome.
Thanks.
I think you're looking for "Templates". Assuming you're using Java, this is in the Windows -> Preferences menu, then Java->Editor->Templates. For example, the screenshot below shows the CTRL-SPACE content assist when you type "sysout".
If i would have this task, I would go to preferences. Look for content assist settings. Write down some specific text you see in dialog box. Then go to plugins folder, and start to search inside archives. When match is present, open the plugin.xml of that plugin, and you will see the extension points of the plugin. Based on its name, I am pretty sure you will find the appropiate one. Then you can either google it, or look for plugins extending the extension point. Using JDGui or fetching source code of the extension example plugin will help you in disassembling. Eclipse usually not well documented as for extension points, so i do it this way.

How does Eclipse do code completion specific to third-party frameworks?

How does the Eclipse editor work to enable code completion? For example, within the XML editor for Hibernate property files, if I ctrl-space within a tag, a list of possible value relevant to hibernate will show up.
I understand that the XML editor is pre-configured to understand xml tag, but how about tag specific to a particular framework? How does Eclipse know about that?
I believe that the eclipse XML editor gets the content assist information from any referenced DTDs, or XMLSchema information it associates with the XML file. Try this experiment: Remove the DOCTYPE entry at the beginning of the file and see if content assist still works.
If you're interested in writing your own content assistants, you may want to start by reading the following:
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.platform.doc.isv/guide/editors_contentassist.htm
In a nutshell, like most things in Eclipse, this is a platform hook. When you press the button, it queries all the registered assistants (I'm simplifying here), and they provide suggestions based on the current element or even the current content.
When writing a source editor or viewer for a particular language or document type, it is common to provide at least some rudimentary content assistants.
Removed the DOCTYPE entry at the beginning of the file and im now able to see the commands while typing ctrl+space...
To add to Uri's answer, you can define your own editor for your own language with XText as long as you have a simple EBNF grammar language for your DSL (domain specific language).
You will have:
syntax coloring,
model navigation (F3, etc.),
code completion,
outline view, and
code templates.
Here is a solution you can work. Actually I was facing a same problem with struts.xml file. I was not able to produce tags by cntrl+space
what i did was...
go to Preferences...Java...Editor...Content Assist...Advanced
check all the check-boxes ON and press OK.
sometimes the problem persists due to some false alarming in eclipse. If it happens, just delete your xml file and create a new one in same location.
I hope it will help.
I had the same issue while using the struts.xml file.
I got fix when I tried below...
Go to “Preferences>Java>Editor>Content Assist>Advanced“. Make sure “Java Non Types Proposals” are ticked on both the places as shown in the image below then click Apply and OK button:-

Storing code snippets in eclipse

I'm a recent semi-convert to Eclipse after 20 years of using vi and gvim. One of the things I miss about gvim is that I could cut a bunch of different snippets of code into named buffers, and paste them at will when doing something like repeating a common idiom. For instance I'd have it so "ap would paste
DatabaseHandle handle = null;
try
{
handle = DatabaseConnectionPool.newHandle();
and then "bp would paste
handle.commit();
}
finally
{
handle.rollback();
DatabaseConnectionPool.returnHandle(handle);
}
And I could repeat both of them over and over in the course of a day. In an answer to another question, somebody mentioned that you could "manage code snippets" in Eclipse, but didn't mention how. So now I'm asking: how do you manage code snippets in Eclipse?
You might want to store those two snippets into a code template, as explained in this tutorial.
And do not forget about the possibility to quickly execute any kind of java code snippets in a scrapbook (not exactly what you want, but it can come in handy at times)
Newtopian adds (in the comments)
In fact templates become much more powerful by adding variables and tabstops within, so your example above would become dbHandle ctrl+space. It would copy snippets from both parts and place your cursor right in the middle.
Eclipse also offers something very similar to the templates feature described by VonC called (would you believe) snippets. Window > Show view > Snippets.
To add a new snippet category: Right click in the Snippets window and click Customize...
Click New > New Category. Enter a category name if necessary (e.g. "Java"). Click Apply.
With your chosen category selected, click New > New Item. Enter your snippet.
To use a snippet, put the cursor where you want to insert the snippet, then double click on a snippet in the Snippets window.
I ran into the Snip2Code plugin recently.
It did the job, and I can collect and search snippets in a quick way.
Well a picture worths a thousand words, what about this one?
The question is old but the link of the answere is older ;)
Here is a nice tutorial:
http://www.dansshorts.com/post/creating-snippets-in-eclipse
I have used snippets in some IDEs, like Dreamweaver and Homesite, an old Coldfusion IDE. I also use a lot of snippets in MySQL Workbench - where i type a lot of SQL, very handy there.
I am now using Eclipse Java EE IDE for Web Developers Version Indigo Release and found the snippets panel in Window|Show View|Other...|General|Snippets. I was able to manipulate it and figure out how to add the code I wanted as snippets and how to use it efficiently.
Use Eclipse Snipmatch (Part of Eclipse for Java Developers Package).
Works very well for Java code snippets but also works for any other language like HTML, ABABP, PHP etc.
You can convert any code fragment from your editor directly to a code template. Highlight the code you'd like to convert to a snippet, context menu "create snippet", complete the form and done.
snippets can be shared via Git repositories with your team members
Manual:
https://www.eclipse.org/recommenders/manual/#snipmatch
Installation:
https://marketplace.eclipse.org/content/snipmatch