I use Map a lot in Java with eclipse. e.g.
Map<String, String> map = new HashMap<>();
then when I am ready to add something with put:
String key = null;
String value = null;
// somewhere before the put, key and value get populated with Strings
map.put(key, value);
the problem is, every time I type "map.put", Eclipse autocomplete changes it to "map.compute()" so I have to edit and remove the "com" and the "e".
I looked at Window -> preferences -> Java -> Editor -> Content Assist but nothing was apparent. I could, I suppose, turn off all content assist, but that would be like "throwing the baby out with the bath water". There are a lot of useful things in the content assist.
My Eclipse:
Eclipse IDE for Enterprise Java Developers.
Version: 2018-12 (4.10.0)
Build id: 20181214-0600
OS: Windows 10, v.10.0, x86_64 / win32
Java version: 1.8.0_144
How can I fix eclipse so it will make the correct suggestions like it did in previous versions?
None of the proposed solutions worked for me. What fixed it was to disable "Show substring matches" (in Preferences -> Java -> Editor -> Content Assist).
It should be considered that this will break the functionality to just type a random part of the desired reference, e.g. typing "PreparedStatement" no longer leads to OraclePreparedStatement. A feature that I don't care about, but this is obviously a matter of personal preference.
In my opinion, the name of that option is a slight misnomer since the substring aspect only applies to leading and not to trailing content.
Update: In Eclipse 2020-06, there is no longer an option "Show substring matches". In its place there is "Show subword matches", but even when disabled, suggestions for typing map.put still include compute. At least when sorted by relevance rather than alphabetically, put is listed in the suggestions before compute.
Window->Preferences
Java->Editor->Content Assist->Advanced
Unchecking "Java Proposals (Task-Focused)" and instead checking regular "Java Type Proposals" fixed the problem for me. I'm using Eclipse for Enterprise Java Developers 2019-03 on Windows 10.
This appears to be due to the unfortunate decision to remove 'Code Recommenders' going forward from 2018-12
"... Code Recommenders will unfortunately not make it into 2018-12."
https://bugs.eclipse.org/bugs/show_bug.cgi?id=542689
The solution currently is to add it manually from the marketplace.
Help -> Eclipse Marketplace -> Search for 'Code Recommenders'
There are no guarantees it will work for Java 11+.
Once installed, you'll have to:
restart Eclipse
close the 'Autocomplete installed' information page
attempt autocomplete once and select the top option that's something like 'Autocomplete enabled'
Finally attempt autocomplete again, this time it should work as expected
Update: It appears Code Recommenders has been archived due to lack of maintainers. When you try to download it, you will get a 404. Hopefully this is temporary.
Related
I'm currently using Netbeans 8.1 as my default IDE and it has the nice ability of auto-complete the JPQL queries when I CTRL space an object inside the query string, but only whether the query string is a single-lined one. If you break the query in two or more lines to fit in your screen (e.g. 128 columns) it stops auto-completing.
For instance:
-- Here the auto-complete happens properly
"SELECT p FROM Product p JOIN FETCH p.skus skus";
-- Here it doesn't
"SELECT p FROM Product p "
+ "JOIN FETCH p.skus skus";
Any help will be appreciated.
This is still an open item on the NetBeans bug tracker since version 7.2 of the software. The last comments there suggest that it should be fixed in 8.2, but it is still not, so you can take this to the bug tracker page and kindly ask Sergey Petrov to give this issue a higher priority.
Perhaps Eclipse has some tools, like the Hibernate Tools plugin, that can help you with this if you are willing to switch to Eclipse.
Or give IntelliJ IDEA a try with their JPA Console tool.
In Eclipse's watch window ("Expressions"), is there a way to have eclipse interpret the contents of a class/structure, rather than having to open the tree? Currently the "value" for any class/structure is {...}, and opening it consumes multiple lines in the Expressions window.
i.e, suppose I have a class complex with real and imag.
class complex_t {
double real, imag;
}
Is there an XML file somewhere in eclipse to indicate that complex_t should display the values for .real and .imag instead of {...}? I've been searching on Visualizers, but I think that is something else.
Visual Studio, had this functionality say 10 years ago or so and I found it very handy (autoexp.dat). I don't use VS anymore but I think it might now be called Native Visualizer (NatVis). I even found that that Boost provides these XML files to visualizing objects in their library. (https://svn.boost.org/trac/boost/wiki/DebuggerVisualizers). No mention of Eclipse, which is an indication that the answer is no.
Edit: I'm looking for a solution for C/C++ (specifically for Code Composer Studio actually).
Below josivan does have a solution for Java though.
If you want to show details during debug you can do something like
Window > Preferences > Java > Debug > Detail Formatters
Click in Add, Choose your class. In area "Detail formatter code snippet" you define what you want. For example:
return "[r: " + real + ", i: " + imag + "]";
On debug Perpective you can see details of your class.
Take a look in the imagem bellow.
In eclipse help you can get more details. And here are a good article about it.
I am making a Minecraft Mod with Eclipse Mars and I got errors when typing the following:
#SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS)
What did I do wrong? It said "the attribute clientSide/serverSide is undefined for the annotation type SidedProxy" .
I cannot run Minecraft to test my mod without it, so I need to fix this error.
For a definitive answer you need to give us more information.
What version of minecraft forge are you using?
Have you correctly imported SidedProxy?
In eclipse, hold ctrl and click on #SidedProxy to open where it is declared, and check that you are using the correct attribute names (it may have changed between versions, so you may need to put something different)
I am using SpringSource Tool Suite 2.9.2 and Grails 2.0.3. I am trying to use the Expressions and Display windows, but both are giving me errors.
The Expression Window says:
org.eclipse.debug.core.DebugException:
com.sun.jdi.ObjectCollectedException occurred retrieving type
This message is different sometimes and says it could not get the right types as if I didn't include packages.
The Display Window says:
"Evaluation failed. Reason(s): An exception occurred durring
evaluation."
Anyone have any idea what is going on?
EDIT:
Andrew, all of those items in the Preferences were checked with the exception of "Enable extra Groovy debug support on all projects (not just Groovy projects)." which I checked.
I still get the error, and for some reason nothing is showing up in the log, but the Expressions opens a sub window that says:
See error log: startup failed:
__Eval.groovy: 7: unable to resolve class mydomain.User # line 7, column 23. import mydomain.User;
^
1 error
Something that is probably relevant: This import is the 3rd domain import on the page. The other two that look like they are working are in the "domain" folder in my "grails-app" folder, but the one that is not working is in "src/groovy" as the project is using Hibernate.xml files. I would expect the Expressions to work for either, but maybe this is the problem?
There are several things that you need to do before debug evaluations can work in Groovy. Most of the time, these things are configured automatically, but sometimes you need to do one or two things manually.
Go to Preferences -> JDT Weaving, make sure it is enabled
Go to Preferences -> Groovy -> Debugger -> Extended debugging. Make sure that all check boxes are selected.
If you are still getting this exception, then this may be a bug. Please update your question with the full stack trace from the error log (Window -> Show view -> Other -> Error log). Also, include the code snippet that you are evaluating.
I've built an eclipse-based product, and I want to set the default workspace used by the Product. Currently, when the "Workspace Launcher" pops up for the first time, the default workspace location is just in the same directory as the Eclipse Product executable. I'd like to change to something like USER_HOME/myworkspace.
I can't seem to find a setting for this, but I'm guessing / hoping its a setting in my product_configuration.ini.
Cheers!
here is a more easy way
Once you have Eclipse up and running you can open Window-->Preferences-->Editors-->Startup and Shutdown. Click the first box that says Prompt for workspace on startup.
Or In your config.ini file ull've this line (or look in configuration.settings\org.eclipse.ui.ide.prefs)
//The default workspace location
Osgi.instance.area.default=#user.home/workspace
try changing this
Here is what needs to be done.
Wherever eclipse is installed go to the "configuration" directory and open the config.ini file in there.
Windows paths normally look like this:
C:\Users\Wilbert\Documents\Installers\Eclipse\eclipse
You will probably find something like this in the config.ini file:
osgi.instance.area.default=#user.home/workingspace
You need to change that to[Getting rid of the "#" and using forward slashes instead of back slash]:
osgi.instance.area.default=C:/Users/Wilbert/Documents/Programs/CS111B(Java)/Practice Programs/Projects
I just did it and it worked.
In your product (.product), go to the "Configuration" tab. Under the "Properties" section, add the property 'osgi.instance.area.default' with a value of '#user.home/myworkspace'. When you export your product, this property will be automatically added to your product's configuration file (just as ayush and Wilbert Sequeira were manually doing).
Note that only an exported product will use that configuration. When running your product in the Eclipse IDE, the workspace location will be overridden by your IDE's configurations.
The now-defunct Symbian WRT product did this. Looking through the sources, it seems to be done by a p2.inf file in the product package. See the screenshot below:
The first yellow arrow is for Windows and the second for Mac and Linux
In your .product file you can specify this as part of the programArgs element.
<programArgs>-data #user.home/MyWorkspace</programArgs>
Note that you can customize config.ini for individual platforms in the product descriptor (*.product) editor. But it never worked for me - hence that hack using P2. It may be working now as I was working with either 3.5 or early 3.6 when I last tried it.
Have a look at the following tutorial: http://hexapixel.com/2009/01/12/rcp-workspaces.
You said in your comment to the question "I just want to prepopulate the selector window with a certain default location".
You can do just that in PickWorkspaceDialog's (from the tutorial) getWorkspacePathSuggestion() method:
private String getWorkspacePathSuggestion() {
StringBuffer buf = new StringBuffer();
String uHome = System.getProperty("user.home");
if (uHome == null) {
uHome = "c:" + File.separator + "temp";
}
buf.append(uHome);
buf.append(File.separator);
buf.append("My App Name");
buf.append("_Workspace");
return buf.toString();
}
For this to work, you do have to create your own dialog though, and I can't tell if that's an option from your question...
In your .product file within the block add:
<property name="osgi.instance.area.default" value="#user.home/workspace" />
And when you build your product, the default config.ini will have this property set.
Details are in the Eclipse docs regarding the various variables.
To set the workspace location programmatically, use:
Platform.getInstanceLocation().set(new URL(...));