Working with Apex in JetForcer IDE: Offline validation, quick-fixes, refactorings and powerful code completion.

If you haven’t yet tried the newly-released JetForcer 1.0, now definitely is the time for that. Let's take a closer look why it is a good idea.

JetForcer is a plugin for handy Force.com development with JetBrains IDEs. So, what’s so special about JetForcer and why is it so different from other Salesforce development tools.

While you are writing code, JetForcer does a lot of work in the background: building syntax tree for your code, analyzing the execution flow, creating references between code entities and their usages etc, in other words, JetForcer gets an intelligent insight into your code (“feels context”). Using this knowledge about context, it can help you refactor your code, quickly navigate through it, provide completion, and, of course, provide error analysis and offer handy quick fixes.

That all allow you to spend much less of your time on routine tasks and to fully get into stuff that does involve your creativity, while JetForcer assists in typing, searching and other.

On-the-fly error detection

on-the-fly-error-detection

JetForcer analyses source code and detects not only syntax but also semantic errors. All the found errors are instantly highlighted in the editor. A popup window with short problem description is shown when the mouse pointer is hovered on the error. Let’s take a look at most popular errors:

  • missing semicolon or annotation
  • not implemented interface method
  • attempt to call an unreachable method, field, variable etc. (In other words - detects unresolved references)
  • ambiguous method or constructor call
  • illegal assignment from ‘IncompatibleType’ to ‘Type’ (e.g. String s = 5)
  • detects errors in DML statements and SOQL queries

… and much more kind of errors.

This feature allows to save plenty of time that typical validation on server and subsequent error correction would take.

Quick-Fixes

quick-fixes

JetForcer understands your code so good that it does not only describe exactly the problem but also suggests solutions. Simply press Alt+Enter and choose the most suitable one for your case.

Great examples of quick-fixes here are:

  • implement interface method
  • create corresponding entity for an unresolved reference
  • cast types (e.q Object o = ‘hello’; String s = o; -> String s = (String)o;)
  • introduce method parameter
  • add missing annotation/modificator

… and many other quick-fixes.

Intentions

intentions

JetForcer really “feels code” and that’s why it does more than error detecting. It also recognizes code constructs, that could be optimized or refactored and suggests corresponding ‘intention’ actions. All you need is to press Alt+Enter and choose any ‘intention’ available for the code under the caret. If you want to move field initialization to the constructor, change access modifier or introduce a new variable - you can do it in two clicks, just press Alt+Enter and make your choice - awesome, isn’t it?

Refactorings

refactorings

Refactoring is a source code modification that does not affect its external behavior. The purposes usually are to increase code readability, facilitate maintenance and to reuse fragments of code. JetForcer allows to perform some of the most popular refactoring techniques, here are only a few of them:

  • renaming
  • changing method signature
  • introducing parameter
  • extracting local variable, field and constant(extract method is supported since 1.2 plugin version)

Each of these features deserves its own article, more detailed information you can find on the plugin website in the “Features | Refactorings” section.

"Refactor This" action lets you find which refactorings can be applied at the current context.

Code Completion

Code Completion is perhaps one of the most in-demand and useful features in programming. Each time you call code completion, JetForcer analyses context and lets you know, what elements are reachable at that particular position.

Completion in JetForcer is indeed a time saver and helps developers to be much faster and more productive due to such features as:

“Type-aware Completion” sorts completion list based on what types are expected in the current context. The most appropriate suggestions are shown on the top.

type-aware-completion

Automatic insertion of paired elements (braces, brackets, quotes etc.)

automatic-insert-paired-elements

"Complete Current Statement" action inserts required syntax elements (braces, parentheses, semicolons etc.) and places caret to position where you can continue typing the next statement. The default keystroke for this command is Ctrl+Shift+Enter.

complete-current-statement

"Postfix Completion" helps transform an existing expression to another one based on the postfix you choosed. E.g, the “.selfr” postfix applied to a sObject name wraps it with an SOQL query.

postfix-completion

… and many other kinds of completion.

You can find a lot more about completion in the "Features | Code Completion" section on the plugin website.

Code Generation

code-generation

The main goal in IDE development is a delegation to computer the boring and monotonous work. JetForcer realizes this fact and provides ability to generate a various of code templates: test methods, getters and setters, constructors, methods that should be implemented from interface and many other things could be added to code in few clicks, just press Alt+Insert and make your choice.

Unused Code Detection

unused-code-detection

One more useful thing is a detection of unused(dead) code. JetForcer finds it and highlights in the editor with a gray background. Also, you can run “Unused declaration” inspection that helps to detect unused code in the entire project.

Summary

If you find it interesting, you may download free 30-day trial version from official website.

Contacts:To submit feature requests or just report bugs, use the plugin’s issue tracker.

A more detailed tutorial on how to use the plugin along with its features description can be found on the plugin’s site.

Make sure you follow @JetForcer on Twitter to be notified about updates, features, new releases and interesting facts about JetForcer plugin.

Popular Salesforce Blogs