JavaRush/Java Blog/Random EN/IntelliJ IDEA 2019.1: what's new in our favorite IDE?

IntelliJ IDEA 2019.1: what's new in our favorite IDE?

Published in the Random EN group
members
Just recently, IntelliJ IDEA, an integrated development environment used by professionals (creators and graduates of JavaRush among them) and future programmers (in particular, almost all JavaRush students), was updated. In this article, we will briefly describe the innovations in IDEA that affect Java developers.

Support for Java 12 preview function - Switch Expressions ( JEP 325 ) and Switch duplicate detection

The twelfth version of the Java language was released in March, and one of the interesting changes in it is a new form of expressions with the operator switch. This operator in its classic form has a somewhat cumbersome syntax, which gives rise to constant errors, difficulty in debugging and well-deserved dislike from developers. In JDK 12 switchthey decided to rehabilitate it, and its syntax was simplified. However, for some reason unknown to the uninitiated, the new feature was included in Java 12 only in Preview form (this means that it must be “connected” manually even after installing JDK 12). The updated IDEA has learned to fully work with all types of operator switch. The IDE has also learned to detect duplicate branches in switchand merge them through a quick fix.

For details on what's new in JDK12, see the article Java 12 is already here: What's new?

Refactoring: extending the extract variable function

IntelliJ IDEA can reorganize string literals and executable code. So, if you need to change a variable, just select it and select the Extract variable option and then it will be replaced throughout the code. Now the function will preserve the semantics of the expressions being modified even better. The framework will be able to extract a variable even from a field initializer, and it is also possible for the extracted variable to automatically convert a ternary operator to an "if" if the condition is important (a condition is considered important if it has a null check or an "instanceof" check).

More accurate highlighting of conditions in ternary expressions

IntelliJ IDEA 2019.1 provides more accurate highlighting of questionable places in ternary expressions. Now only the condition in which the value was violated will be highlighted null, whereas previously the entire ternary expression was highlighted, even if the violation was in only one branch. Thanks to this new feature, highlighting is now more accurate in the case of switch-expressions.

Improved analysis of mathematical operations

Data flow analysis can monitor the results of mathematical operations and uses this information to alert the developer to conditions that are always either true or false. IDEA's authors have improved the analysis of many mathematical operations, including multiplication, remainder, and bitwise operations.

Improvement to @Contract annotation

The @Contract annotation is used to define the contract that a method must conform to. This allows the IDE to find problems in methods that call annotated methods. @Contract has two attributes - valueand pure. The attribute valuecontains clauses that describe the cause-and-effect relationship between the arguments and the return value. The (“pure”) attribute pureis intended for methods that do not change the state of their objects, but simply return a new value. If its return value is not used, removing its call will not affect program state or change semantics unless the method call throws an exception (the exception is not considered a side effect). So, the IntelliJ IDEA 2019.1 team has improved support for @Contract annotations. Now the development environment can automatically determine the “purity” of constructors from sources.

Jumping from a Java stack trace to the corresponding position in a string

If you have already reached level 9 of the Java Syntax quest on JavaRush, then you have already heard about what a stack trace is . Its essence in a nutshell is that the function called last must complete first. Now, when you click on a Java stack trace, the IDE will try to determine the exact location on the line you want to move the cursor to. Previously this would only take you to the first column of the corresponding row.

JVM Debugger Changes

  • There is a new Step Out of the Block action that allows you to exit the current block while debugging a project using the JVM debugger.
  • If you prefer the mouse when debugging, your work will become even more convenient: you can now trigger the move to the cursor action by simply clicking on the line number in debugging mode.
  • There is now support for synchronized, assertand switchdebugger expression evaluator operators.
In fact, there are much more innovations in IntelliJ IDEA 2019.1. You can read about them on the JetBrains website , the authors of this IDE (but only in English).
Comments
  • Popular
  • New
  • Old
You must be signed in to leave a comment
This page doesn't have any comments yet