Another plugin idea: DFA-based navigation

Let's say I'm inside a method, which got passed some string parameter named "userName".

The calling method may be just passing on the value which it received.
The method itself may in turn pass this parameter to other methods, etc.

Actually this it quite common for some category of parameters:
- a web controller extracts some parameter from HttpServletRequest
- passes this parameter to a service object
- the service object in turn passes it on to a DAO
- the DAO passes it on to a JDBC API method

Looking at the flow of this parameter through the code, it would look like a mostly-hierarchical graph (with cycles in some scenarios).
The edges of the graph can be of two types:
"input edges": the parameter is initialized / assigned
"output edges": the parameter is passed to some method outside of project source

I have some ideas about UI as well, but first I'd like to know:
- will something like this fly? If not, what are the obvious blockers?
- do any other products provide something similar? (IIRC next version of VS is supposed to have something)
- and last but not least: is there some code or IDEA APIs that could be useful?

Meanwhile I'm going to give the previous idea a go (thanks Bas and Dmitry)

Taras

13 comments

Hello Taras,

The weirdly named "Slice backward" feature in Diana does exactly this type
of analysis. Please try it out.

Let's say I'm inside a method, which got passed some string parameter
named "userName".

The calling method may be just passing on the value which it received.
The method itself may in turn pass this parameter to other methods,
etc.

Actually this it quite common for some category of parameters:
- a web controller extracts some parameter from HttpServletRequest
- passes this parameter to a service object
- the service object in turn passes it on to a DAO
- the DAO passes it on to a JDBC API method
Looking at the flow of this parameter through the code, it would look
like a mostly-hierarchical graph (with cycles in some scenarios).

The edges of the graph can be of two types:

"input edges": the parameter is initialized / assigned

"output edges": the parameter is passed to some method outside of
project source

I have some ideas about UI as well, but first I'd like to know:

- will something like this fly? If not, what are the obvious blockers?

- do any other products provide something similar? (IIRC next version
of VS is supposed to have something)

- and last but not least: is there some code or IDEA APIs that could
be useful?

Meanwhile I'm going to give the previous idea a go (thanks Bas and
Dmitry)

Taras

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0

Where is it hidden? :)

And does it work both forward and backward?

0

Hello Taras,

Where is it hidden? :)


-Didea.is.internal=true

And does it work both forward and backward?


At the moment it works only backward.

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0

Please try it out.


Yeah, that's what I was looking for.

My main problem/request is: make the search cancellable.
Sometimes I open a node (by mistake) that causes a very long/extensive search to be performed.

Shall I create a JIRA request?

0

Not a bad start. Definitely needs some highlighting magic (more than the tree-based view). Also some way to show the transitive closure of backward slices, so that it can highlight any code which might impact the value of the selected expression, even indirectly (it currently seems to only go back two steps). Also, of course, forward slicing. I actually managed to find a bug in the 10 line test program I whomped up to try this out. I look forward to seeing the end results.

--Dave Griffith

0

Hello Taras,

Please try it out.


Yeah, that's what I was looking for.

My main problem/request is: make the search cancellable. Sometimes I
open a node (by mistake) that causes a very long/extensive search to
be performed.

Shall I create a JIRA request?


Please do.

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0

Here are some initial thoughts:

  • I'd like to exclude/categorize "null edges" of the graph (where a null value gets in)

  • I'd like to categorize "constant edges" of the graph (where a constant value gets in).


I'm curious what you and Dave think about these ideas. I have to admit that the tool provides a whole new way of navigating, and my mind still needs to adjust to it ;)

0

Dmitry, I often see attached exception while performing backward flow analysis.

I would guess something is wrong with my Javascript caches..however, how does the flow analysis end up in JavaScript in the first place?



Attachment(s):
ex.txt
0

Dmitry, how do you trigger this ?

I managed to find there is a (disabled) "slice" toolwindow, but couldn't find how to activate it

0

Hello Thibaut,

Dmitry, how do you trigger this ?

I managed to find there is a (disabled) "slice" toolwindow, but
couldn't find how to activate it


Please wait for the next EAP. :)

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0

After using it for a few days I can tell that I now have assigned a shortcut for it ;)
I have a list of ideas on making it more useful, but for now I'd like to work with it for a few days more to get a better feeling for it.

However, forward slicing would certainly be one of my requests as well:
http://www.jetbrains.net/jira/browse/IDEA-18978

Taras

0

Dmitry,

Can you give an explanation on the "gray sections" in the DFA tree view?

0

Hello Taras,

duplicated paths


Thank you
-


Anna Kozlova
JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

Dmitry,

Can you give an explanation on the "gray sections" in the DFA tree
view?



0

Please sign in to leave a comment.