IDE Bake Off IntelliJ IDEA 3.0 Austin Java Users Group Razvan Surdulescu March 25, 2003 IDEA Overview IDEA is ~1.5 years old. Current version is 3.x. IDEA’s primary strength is refactoring: Rename/move/copy classes/methods/packages Extract field/method Many others … Excellent (and unobtrusive) “assistance”: parses the current source file provides hints, underlines errors, etc. IDEA Overview cont’d Many useful plug-ins written by the developer community Not free: $499 (.com), $99 (.edu) Swing application Startup time: TogetherJ < IDEA < Eclipse Memory footprint: ~100MB when “warm” Processor: PIII equivalent or better Bake Off Environment Windows 2000 SP3 Sun J2SE 1.3.1_06 IntelliJ IDEA 3.0.2 ANT 1.5.1 (built-in to IDEA) JUnit 3.8.1 (built-in to IDEA) CVS 1.11.2 Tomcat 4.0.6 Electric XML 6.0.3 1a. Projects Setup new project You can change the “default project” properties You can use an existing source tree or create a new one. IDEA stores all project settings in a.IPR and .IWS file: very clean and unobtrusive. 1b. Projects Changing the default editor Not possible, although you can obviously edit the source files outside IDEA The editor is very powerful and configurable: Auto-complete, auto-indent, auto-import Class templates, code templates Many others … 1c. Projects Configuring the class path Add/remove JAR/ZIP/directories to the class path. All class path “elements” become candidates for auto-complete, code navigation, etc. You can setup “libraries”: Define associated classpath, JavaDoc, and source directory Use the library for compilation, documentation or source code navigation Share libraries across projects 2a. Integration ANT 1.5.1 comes packaged with IDEA You can add an existing build.xml to your project IDEA will allow you to execute, filter and log ANT targets through the GUI In case of error, you can double click on the error line and go to the code that caused it IDEA can validate the ANT build file (find mistakes, unreferenced variables, etc.) 2b. Integration JUnit 3.8.1 comes packaged with IDEA You can setup JUnit test targets and execute them In case of failure, you can double-click on the error line and go to the assertion that failed 2c. Integration CVS IDEA comes with support for CVS and Star Team If your sources are imported into CVS, you can do all CVS operations directly from the GUI If you rename or delete a source file, IDEA will prompt you to keep the CVS repository in sync IDEA comes with a nice visual diff tool, but you can use an external diff tool as well 3. Refactoring IDEA’s refactoring is exceptional: Rename/move package Rename/move/copy/delete class Rename/move/copy/delete method Rename/move/copy/delete field Extract method Change method signature Many others 3. Refactoring cont’d Once I started refactoring in IDEA, I could never go back to another IDE! 4. Debugging Local Full-featured debugger: Code breakpoints (normal, conditional, counted) Exception breakpoints Thread, field inspector, watches Remote Connect to a remote JVM via JPDA Source path permits source breakpoints and navigation while debugging 5. Time Savers Code navigation Code format, layout (optimize imports) Go to class/file (ctrl+(shift)+N) Go to type/variable declaration (ctrl+(shift)+B) Go to override Go to JavaDoc (ctrl+Q) Class structure (ctrl+H, ctrl+F12) Standardized formatting => easy diffs Refactoring (rename, move, delete, etc.) 5. Time Savers cont’d Search (usages, text in file, text in path) Code generation Live templates (“psf-TAB”, “soutv-TAB”) Implement methods (interface) Generate getX()/setX() accessors Generate equals()/hashCode() Surround with Smart complete 5. Time Savers cont’d Logical layout Almost everything can be done without the mouse Key combinations and menus are very logical Configurable key bindings (e.g. Emacs, Visual J++, …) Able to save multiple code styles, and use them per-project. Really useful if you have multiple teams with different coding standards. 5. Time Savers cont’d XML support Text format Auto-complete DTD, XML Schema validation Validation of XML references/external resources 5. Time Savers cont’d CVS Integration (operations, parse output) JUnit, ANT integration (parse output) Easy debugging (break points, source path) JAVAC launched in process (fast) Inspect code (critique) Many useful plug-ins written by the community (Plug-in Manager) 6. Visual Modeling No built-in features SimpleUML plug-in covers the basics 7. Build a GUI No built-in features 8. Build/deploy a JSP Strong JSP and Tomcat 4.x support Java syntax checking, code completion, and refactoring in scriptlets Integrated JSP and Servlet debugging Web application file management Pre-deployment JSP compilation checks JSP tag completion and syntax checking, including custom tag libraries 8. Build/deploy a JSP cont’d No support for packaging WAR IDEA expects un-expanded WAR-like directory structure Easy to package this directory structure from ANT (using the <war …> task) 9. Deploy an EJB Nominal support for creating new EJBs Automatic management of deployment descriptor Easy to add/delete EJBs Easy to setup Entity CMP relationships Functionality is still somewhat buggy/hokey No support for packaging/deploying EJBs This is always container specific anyway 10a. Customization/Extension Installing/using plug-ins Copy the .JAR file to /{idea_home}/plugins Start IDEA The plug-in “Plug-In Manager” allows you to see what plug-ins exist, download and install them directly from the GUI 10b. Customization/Extension Writing a plug-in IntelliJ Plug-in Documentation Plug-in FAQ Two kinds of plug-ins: application-level (created and initialized at start-up) and project-level (created for every project) The plug-in configuration is provided in {plug-in JAR}/METAINF/plugin.xml 10b. Customization/Extension cont’d <idea-plugin> <name>VssIntegration</name> <description>Vss integration plug-In</description> <version>1.0</version> <vendor>Foo Inc.</vendor> <idea-version min=”3.0” max=”3.1”/> <application-components> <component> <interface-class>com.foo.Component1Interface</interface-class> <implementation-class>com.foo.Component1Impl</implementation-class> </component> </application-components> <project-components> <component> <interface-class>com.foo.Component2</interface-class> </component> </project-components> </idea-plugin>