Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How find out static string result concatenation in Intellij Idea without running code?

Code example:

public class StringHolder{     public static final String ONE = "ONE";     public static final String TWO = "TWO";     public static final String THREE = "THREE";      public static void main (String[] args){         String someVariable = ONE + TWO + THREE;     } } 

How I can evaluate String value from static constants?. For example, with Intellij Idea I can run program in debug, put break point, press "ctrl+alt+f8" on the expression and see expression value. So is that possible to evaluated this with static analyzer with out compile code and run program? The key point is the value calculated from static constants not from function parameter, so analyzer just "go" to the constant value, concatenate them and show me value in pop-up window.

Another situation when I have a block and "just initialized" variables:

{     final String a = "a";     final String b = "b"     final String c = "c"     String result = a+b+c; } 

P.S. Did you understand me? :)

like image 797
Cherry Avatar asked Mar 11 '13 09:03

Cherry


1 Answers

It is easy with intellij idea 14:

  1. just put cursor on the string concatenation
  2. Press alt + enter
  3. Select "Copy String concatenation text into clipboard"
  4. Paste result somewhere.
like image 53
Cherry Avatar answered Sep 20 '22 19:09

Cherry