- This topic has 3 replies, 3 voices, and was last updated 12 years, 7 months ago by support-swapna.
-
AuthorPosts
-
Richard MittlemanMemberI can’t get java templates to work. For example if an “if” statement is wanted I looked in Preferences–>Java–>Editor–>Templates–if and the check box is checked next to “if” and the Preview says
if (${condition:var(boolean)}) { ${line_selection}${cursor} }
I then edit a class and try to use the template.
I have tried typing ‘if’ then pressing command+space and nothing happens.
I have tried selecting the ‘if’ then pressing command+space and nothing happens.
If I type ‘if’ then select it and press control+space the choice of ‘runnable’ is available and when chosen inserts the codenew Runnable() { public void run() { if }
Any suggestions?
support-tonyKeymasterZscipio,
This functionality is base eclipse functionality, so you may get better support by posting in an eclipse user forum. However, I couldn’t replicate the problem with either eclipse or MyEclipse on Mac OS X Lion.
Note that the content assist key combination is Ctrl-Space, which is not one of the combinations you mentioned. Command-Space opens the Mac Spotlight search box. If you select some text and then hit Ctrl-Space, the content assist operates in a different mode, though it’s hard to understand why it would offer Runnable, in your case. If you select a full if statement (or any other statement or block of statements) then a Runnable choice seems reasonable.
Note that Ctrl-Space actually cycles through various sets of proposals. Note the message at the bottom of the pop-up which shows which set of proposals will come up next if you hit Ctrl-Space again.
The key combinations can be changed in the preferences, so you might want to check that.
Richard MittlemanMemberYou reply gave me enough hints so that the Content Assist now works. But I don’t understand why the process works. I went into the templates and changed the “Context” value of the “if” template from “Java statements” to “Java”. What do the values in the “Context” column mean? The values in this column are:
1. Java
2. Java statements
3. SWT statements
4. Javadoc
5. Java type members
I have done a Google search on the meanings of the entries in the “Context” column but to no avail.Thank you for your help.
support-swapnaModeratorZscipio,
Glad that it is working.
For more details on the context values, please take a look at these links:
http://help.eclipse.org/helios/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Freference%2Fpreferences%2Fjava%2Feditor%2Fref-preferences-edit-template-dialog.htm
http://fahdshariff.blogspot.in/2011/08/useful-eclipse-templates-for-faster.htmlHope this helps.
-
AuthorPosts