With intellij idea, how do I find out what makes a variable be visible?
An example of when it is hard:
class A
, and you see a variable something
. If you jump to source you see that it's defined in trait X
. But you don't extend
trait X
directly. What do you extend, then, that makes this variable visible? If you have a deeply nested hierarchy, tracking can be hard.Any recommendations or solutions?
EDIT: Please vote for the feature if you're interested: http://youtrack.jetbrains.com/issue/IDEA-124369
If the variable/parameter is underlined, you know that you can't use it in lambda/anonymous class directly.
Click edit configurations on the dropdown box for your runtime configurations. Select the runtime you want to add environment variables to. Click environment variables folder icon to pull up the environment variables screen. From here you can add as many environment variables as you want.
Press Ctrl+Alt+V or from the main menu, select Refactor | Extract/Introduce | Variable. Select a name suggested in the popup or type your own and press Enter . that you can use to configure more options. You can also declare the variable you are extracting as final .
I don't think that IntelliJ IDEA has any shortcut for "finding what makes a variable visible".
However you can determine it using the "Find Usages" option (Alt + F7). For example:
import java.nio._ object TempObj extends App { def func = 2 val p = file.Paths.get("some-path") func }
So Find Usages on "file", tells you that its from the Package "file" (in heading of the new Tab it also shows the complete package name, ex: Find Usages of java.nio.file in Project Files). Whereas Find Usages on func will tell you that its a Method (And the Tab heading now says: Find Usages of func() in Project and Libraries)
So now in way you can determine, what exactly makes the variable visible. This also works for imports since it shows the package from which it is imported and you can then look for import of that packages.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With