I'm wondering if its possible to configure Intellij's smart insert to suggest hamcrest and mockito dsl idioms when in test classes. Really I'm looking for something like eclipse's 'static favorites', so that when I hit ctrl + space or ctrl +shift +space the idioms are present.
In general is it possible to configure autocomplete/smart insert or the suggestions balloon for that matter. I've looked through the settings without much luck but could easily have overlooked something.
I don't think it's possible to tweak the Smart Insert feature, but I was able to create my own Live Templates for Mockito. As IntelliJ was a bit limited about export, I just posted a guide to create them manually.
The page is in french but the most important parts should be understandable for an english speaking reader.
http://blog.arkey.fr/2011/10/21/quelques-live-template-intellij-pour-mockito/
There might be some typo error in the page, also these Live Templates were created on a older version of IntelliJ. Let me know if you encounter issues about them.
And you should be able create your own live templates for Hamcrest. Also did you tried FEST-Assert, I found the API of this library pretty nice to use.
Cheers
In terms Eclipse's favourite imports feature: when using Intellij, have you tried using Alt+Return?
When I use Mockito I just write mock(MyService.class) and then pressing Alt+Return gives me the option to statically import the method Mockito.mock.
Related
While working on my code I was reminded of just how much IDEA does for me. This gave me the idea, what if I could add some custom compile time processing. In which, if my code is invalid it will prompt me with an error. Say for example I left a return type as a null when it should never be null. Basically framework and API checks to reduce production errors.
The problem is I have no clue where to start on doing this. I assume I need to develop a plugin but am having issues finding documentation. If someone would be so kind as to help me get started. As well maybe even provide links to example projects or existing projects (github if possible).
As well I plan to release this plugin as part of a few APIs I develop. So helping me will help others in the long run :)
You can create an intellij plugin that implements custom inspections.
Example here:
https://confluence.jetbrains.com/display/IDEADEV/Inspection+of+Code+Source
The inspections that you create can highlight code red, allow the user to disable them, and also prompt for fixes. Please see intellij plugin development API's for more details.
You can use standard java assertions for this:
https://docs.oracle.com/javase/8/docs/technotes/guides/language/assert.html
I have difficulties coding in JavaScript with Netbeans. I can't see beforehand:
my mistypes,
relations between classes, functions and variables (dependency, parents-children etc.),
javadocs references (both original and imported for libraries).
THE PROBLEM is in:
heavy debugging because of primitive mistype and the use of irrelative substances;
time consuming browsing to find help for the context.
I TRIED:
Netbeans 7.4 (some basic Ctrl+Space lookup is supported, but very limited and usually useless);
Eclipse 3.8 (no context support);
These IDEs provide adjustable autoformatting and text mark-up (braces, clever tabs, text colors etc.) This is all very helpful, but insufficient. After having to migrate from Java to JavaScript for job routines, I now understand how much work had I automized and saved coding Java. I just feel I'm missing Ctrl+Space after a dot for Javadoc and Ctrl+LeftClick to navigate to declaration. It results in more time creating similar things in code.
THE QUESTION IS:
How to get JavaScript language docs for Netbeans?
How to make Netbeans show relations between classes, variables and functions so that I don't see what can't be done from this context? For JavaScipt like it does for Java?
Here are Netbeans JavaScript snapshots with everything that's needed. Where is that all? I don't see it in my IDE:
I can't add comments because i haven't reputation enough...
I am a Java developer since Java version 1.1, and Netbeans's truly fan since version 5.5 (Eclipse? What's that thing?).
I am currently developing Javascript code in Netbeans 7.4. It offers code completion exactly as it does with Java (plus javadoc-style documentation popup, Ctrl-Space behavior, colouring code...), almost the same pros and cons as developing java, php or another language...
And yes, it saves a lot of time of searching for object's methods and properties, misspelling...
---- Text added since your last editing some minutes ago....
OK, i know i'm not impartial, forgive me... Take a look to this, it may be helpful:
Netbeans 7 HTML5 webapp javascript debugging
Maybe I don't know really what are you looking for, but in my opinion it is a good stuff. If you can debug an HTML5 webapp to such deep level...enough for me.
About the inline documentation in a javadoc-style, my NB shows a pretty nice one (bundled, i didn't plugged anything...). Of course, it could be more complete or functional... Take a look to this image:
Next I'll try webstorm... Good luck!
---- More Text added .... jQuery documented API integration...
Ok, let's see how NB manages itself to show you a wonderful javadoc-style documentation popup of jQuery API...
It looks so good to me... I love it :)
I only added the developer version of jQuery (the one commented and uncompressed) to the src folder of my opened Java project... nothing more... I think this is some kind of magic... Maybe you can add your own commented .js libraries in the same way. Just explore the jQuery .js to learn how to comment your code.
Just one more resource for you:
Adding jQuery to your NB project
I think, that you cannot expect the same level of tool support for Java (strongly typed, object oriented) and JavaScript (weakly typed, functional).
Compiler for strongly typed languages knows, what is allowed in given context, but in JavaScript is the situation drastically different. Everything is dynamic and you cannot tell what is mistype.
Anyway I think, that latest NetBeans 7.4 has really great support for JavaScript including code completion.
You can see here for such IDE. Also you can take PhpStorm, Idea, WebStorm.
I think the best IDE for JavaScript would be the JetBrains WebStorm.
The company has also made IntelliJ Idea IDE for Java, which is in my humble opinion the best one available.
You can download free version here: http://www.jetbrains.com/webstorm/
I'm using it a lot myself and I can really recommend it.
Steps below helped me to partly resolve the problem:
Changed project type from HTML5 to PHP to exclude libraries folders from code analysis as described here;
Configured at Tools - Options - Editor - Hints - Javascript to "Suggest for current line" instead of "Warning".
tune up and use correct tags for javadocs as described here;
Resolved proxy connection problems to make IDE see the Internet: Tools - Options - General;
updated Netbeans to 7.4 from 7.4RC1;
Now you have:
- fast code completion popup window load,
- docs texts, including pop-up code completion docs for your own comments,
- can navigate to declarations from other files Ctrl+LeftClick,
- have suggestions on errors,
- type recognition failing if you mistype function or variable name to smth impossible.
To me, reading long camel cased words can sometimes be a bit frustrating. For example:
aReallyLongCamelCasedMethodNameWhichIsTooSelfDescribing
Now, look at this version:
a_Really_Long_Camel_Cased_Method_Name_Which_Is_Too_Self_Describing
Which version is easier on your eyes? The second one is for mine.
While using Emacs, I stumbled upon a nice minor mode called glasses mode.
Since I'm working primarily with Java, I'm an Eclipse user and I wonder if there is some way to display camel cased words with underscores?
Note that I'm not asking for a way to actually convert camel cased words as described, I'm just looking for a mechanism that works like Emacs' glasses mode in Eclipse.
A regexp to actually do the conversion can be found by googling "Convert camelCase to underscores".
Have you considered using Emacs as your Java IDE? I really like Eclipse and the move sounds painful to me too. However, I bump into more and more people that are actually doing it. Just type "emacs ide java" into google.
It's definitely not a move for everyone, but if you know Emacs fairly well it might be a better option than trying to convert emacs features into Eclipse.
If you can't find any existing Eclipse plugins, then I would consider writing your own editor extension.
If you haven't laid down your mouse and gone into retirement yet, there are now 2 solutions to this:
use emacs within Eclipse with the emacs+ plugin although I haven't established that you can use a .emacs init file to pre-program much of the cool emacs stuff emacs can do like your requirement
convert camel-case to underscored separated using the AnyEdit plug-in and then hit CTRL+z to go back
try to keep your method names descriptive "and" short. If you have really such method names, i would think about it twice before i code it and maybe it is better to use refactoring "extract method" to tile the functionallity, which you can not describe shortly, into more than one method for a better design ;-) "increasing cohesion"
I love vim, but not having things like IntelliSense/Code completion from Eclipse makes it pretty difficult. I know, I know, I should be able to look at method signatures and java docs for the API I am interested in using. I'd love to, but I'd like it to be accessible from my fingertips instead of having to browse the source tree manually or have a JDK reference handy.
What plugins would make this easier?
I tried eclim for a while. It was pretty good, basically it uses eclipse in the background as a kind of engine and provides a plugin to let you use all of eclipses goodness through vim.
http://eclim.org/
Don't write Java in Vim — put Vim inside a Java IDE:
IdeaVIM for IntelliJ
viPlugin or Eclim for Eclipse
jVi or ViEx for NetBeans
I love Vim, but using an IDE for Java is the only way to stay sane. A decent Java IDE will:
Show invalid syntax or type errors
Show missing JavaDoc
Manage import statements for you
Highlight unused methods and variables
Safely perform powerful refactorings such as moving methods or renaming classes -- (no, search and replace doesn't cut it, I promise)
Reformat your code automatically or on-demand
Vim can't do the above, but you can use all the Vim keybindings in a program which does.
I use Eclipse + Vrapper. Enables the vi dual mode editing we all know and love. <ESC>
Completely free and lightweight. The goal is to have the comfort and ease which comes with the different modes, complex commands and count/operator/motion combinations which are the key features behind editing with Vim, while preserving the powerful features of the different Eclipse text editors, like code generation and refactoring.
While eclim is another alternative, I feel eclim takes over Eclipse and vrapper doesn't.
Check out the JDE plugin for Vim. It provides Java omni-completion and a documentation viewer (among other things).
I use the javacomplete.vim plugin for omni-completion for java. It's a very nice script: it also shows the method signatures on top of the omni-completion. The downside is that it is a bit slow, but it has worked fine for me otherwise. Eclim might be better ut I haven't tried it yet so I can't comment on it.
I've also used the jcommenter.vim plugin for generating javadoc comments. It can parse method signatures and automatically add the relevant #param foo fields and such.
For the API searching I would suggest on overriding the K key on normal mode. It searches man pages for the keyword under the cursor, but the behavior can be overriden by setting the keywordprg variable. See this thread for an example.
Other scripts which I've found very useful (not specific to Java development): NERDCommenter, AutoClose, snipMate, Align.
There's an IntelliJ VIM plugin as well. Plus, IntelliJ is released an open-source, free version.
Vim is not an IDE replacement. But very specific additional tool. With Vim you should only do small-fast tweaks while the main development is going under Netbeans/Eclipse/IDEA.
One more time. It is a Bad Bad Bad idea to turn Vim into Full IDE. Why? It won't be so fast. And thus won't be so pretty.
Here is scenario. You have opened Eclipse or whatever to edit your current task. And in 10 minutes you have to switch to another Task which is kind of urgent. The task is to tweak a little a maven or an ant built script and/or some deployment perl/python/groovy scripts.
How much time will it take to reload Eclipse to work on a new 5 minutes task and switch back?
But if you are Vim guru you can handle this in seconds. You can change one file and run Ant/Mvn within Vim.
And this is the power of Vim. You can change and check one file in no time no matter which extension it has: java, groovy, c++, makefile, bash, c#, etc.
This will be an uphill battle. There is so much knowledge about your program built into Eclipse, that I expect you will eventually have to reimplement it all to be happy.
Any particular reason you cannot just decide you like the built-in editor in Eclipse?
Hey all, my Computational Science course this semester is entirely in Java. I was wondering if there was a good/preferred set of tools to use in ubuntu. Currently I use gedit with a terminal running in the bottom, but I'd like an API browser.
I've considered Eclipse, but it seems to bloated and unfriendly for quick programs.
Java editing tends to go one of two ways; people either stick with a simple editor and use a terminal to compile/run their programs, or they use a big IDE with a zillion features.
I usually go the simple route and just use a plain text editor and terminal, but there's still a lot to be said for IDEs. This is especially true when learning the language, since hitting "spam." brings up a dropdown with all of the fields and methods of the spam object. And this is not just useful to a beginner; it remains useful later on when using unfamiliar libraries and third party modules.
IDEs also have useful tools such as GUI builders which become invaluable when doing professional Java work. So although I typically prefer a simple editor/terminal combo, I highly recommend trying out an IDE such as Eclipse or Netbeans to see how you like it and so that you'll know how to use one later on.
Eclipse may be bloated for learning needs, but will probably give you the best overall Java experience. Try working through some of the built-in tutorials if you find the interface confusing.
I too vouch for eclipse (or IDEA if you have the money, actually IDEA is better than eclipse by a small margin).
But, make sure that you know how to compile and debug without an IDE first, and also learn to read the compiler's warning/error messages - they are essential skills for developers that using an IDE can prevent you from learning.
Eclipse and NetBeans are both good options. If you don't mind paying a little, so is IntelliJ IDEA (an academic license costs $99).
As far as IDEs go, I've found Eclipse to be about the best you could ask for. If you are used to IDEs full of features like VS, it should be right up your alley, and it isn't particularly resource-hungry; the way it organizes your projects makes the whole thing pretty simple as well, and it's also good to have on your resume. If you're looking for a non-intrusive IDE, mostly intuitive and that does its job as a great assistant, go with Eclipse. Not to mention its customization options.
If, on the other side, you'd like a much more light IDE, textPad-style (why?), I'd recommend Geany; I've worked with it in the past and it's got all the basic features to get started with the language and not be overwhelmed with all the features that big IDEs can offer. But I'd still recommend to go with Eclipse as soon as you get used to the language and need the IDE to be more of an assistant.
Another vote for Eclipse. In particular, you should be able to install it from within Ubuntu, as there are packages for it in one of the repositories (I forget which one specifically, as I'm not at my Ubuntu machine right this minute). If you use the GUI package-management application under the "Admin" menu, you should be able to find Eclipse and related packages.
I'd actually just recommend Eclipse. It seems bloated at first, but once you get used to it, you can use it to develop code very very quickly (and thus it's an excellent choice for a quick bit of Java).
Features I like:
Control+1 for error fixing - it knows how to fix most compile errors - just highlight the error in the code (which will be underlined in red) and it will give you a list of suggestions. Control+1 selects the first suggestion, which is almost always correct.
You can use this error fixing feature to write code that uses methods you haven't written yet - the error fixing will create the method on the class/interface you called it on, with the correct parameters/name/visibility etc. Or, if theres a similarly named method with similar parameters, it will suggest you've spelt it wrong when you called it.
The refactoring tools are also supergreat - you can highlight a block of code to extract as a method, and it'll work out what variables need to be passed in, and what it should return (if anything). You can move variables between field and methods. You can change class/interface/variable names, and it will correct them only where it needs to (which beats a search and replace any day).
You really don't need to know many eclipse features to get the benefit of using it - and it'll dramatically speed up your coding. I wish I'd known how to use it at University.
Basically, I'd recommend Eclipse. The time saved coding will make up for having to click "yes" a couple times when you start a project..
I'm using NetBeans with success right now.
I usually just use vim, but i've actually found the IDE Geany quite intuitive with a lot of good features but not really overblown. Check it out.
EDIT: I don't think Geany is fit for enterprise-level programming, but for a quick program it's one of the better IDEs I've seen, especially if you've had bad experiences with NetBeans or Eclipse as I have.
As many others, I suggest you to use Eclipse. It works fine in linux and after a few days you will find it not so unfriendly.
Moreover, if you will start developing more complex programs in java, you already will be familiar with a standard, complete and open source IDE, which is also the foundation for many other professional IDE for other languages, like Adobe Flex Builder, Aptana Red Rails and so on.
There is an interactive "IDE" designed especially for learning: BlueJ at http://www.bluej.org/
While I generally agree that Eclipse, NetBeans, or one of the other IDEs can be very helpful, they are pretty heavyweight for a learning environment; and you can end up spending your time wrestling with the IDE instead of learning Java.
In my career I've also found some people that don't really understand what the IDE is doing for them; they are totally lost without it (see Voodoo Programming). I recommend you spend at least some of your time with a simple editor, like gedit or vim, and the command line javac compiler.
BlueJ is considered a good editor for Java, tough mostly aimed at beginners. It does not bloated as Eclipse, but contains many useful features. It is also an open source project, so you are welcome to give it a try.
In our working enviroment we have to use the free Oracle JDeveloper ... sigh .. at home I tend to use Eclipse more and I really like it
Netbeans is a heavy but good IDE. Netbeans always have many features you don't really need, but because it's made with the netbeans platform, you can always strip it down to the essentials !
If you don't like all the work, go with eclipse. It's a lighter IDE.
Geany is pretty handy, don't quite know how it is with programming Java, but with programming C and C++ it's a nice light weight IDE. (BE WARNED: Building big projects usally tend to fail in geany. Workaround: compile in Geany build in terminal)
Bryan