palashborhanuddin / RefactoringMatcher

0 stars 0 forks source link

Groum Generation #4

Open palashborhanuddin opened 3 years ago

palashborhanuddin commented 3 years ago

Here is the output of the GROUM generation so far. Paper method example has been used for testing. There is a screenshot added showing the RefactoringMatcher output with the Graph from the paper.

Format: nodeID:nodeValue

Groum

nodes=[ 1: StringBuffer, 3: FileReader, 2: BufferedReader, 5:BufferedReader.readLine, 4:WHILE, 6:StringBuffer.append, 8:StringBuffer.length, 7:IF, 10:StringBuffer.toString, 9:outputMessage, 11:BufferedReader.close] ]

edges=[ SRC: 1: StringBuffer -> DST: 3: FileReader, SRC: 1: StringBuffer -> DST: 6:StringBuffer.append, SRC: 1: StringBuffer -> DST: 8:StringBuffer.length, SRC: 1: StringBuffer -> DST: 10:StringBuffer.toString,

SRC: 3: FileReader -> DST: 2: BufferedReader,

SRC: 2: BufferedReader -> DST: 5:BufferedReader.readLine, SRC: 2: BufferedReader -> DST: 11:BufferedReader.close,

SRC: 5:BufferedReader.readLine -> DST: 4:WHILE,

SRC: 4:WHILE -> DST: 6:StringBuffer.append,

SRC: 6:StringBuffer.append -> DST: 8:StringBuffer.length,

SRC: 8:StringBuffer.length -> DST: 7:IF,

SRC: 7:IF -> DST: 10:StringBuffer.toString, SRC: 7:IF -> DST: 9:outputMessage

SRC: 10:StringBuffer.toString -> DST: 9:outputMessage,

SRC: 9:outputMessage -> DST: 11:BufferedReader.close, ]

Dissimilarities:

Comparing with the paper output, Missing a few edges such as:

SRC: 1: StringBuffer -> DST: 2: BufferedReader (which Rule?) SRC: 4:WHILE -> DST: 7:IF (Rule 2) SRC: 5:BufferedReader.readLine -> DST: 6:StringBuffer.append, (Rule 1, Rule 5) SRC: 5:BufferedReader.readLine -> DST: 11:BufferedReader.close, (Rule 1) SRC: 6:StringBuffer.append -> DST: 10:StringBuffer.toString, (Rule 1, Rule 4) SRC: 8:StringBuffer.length -> DST: 10:StringBuffer.toString (Rule 1, Rule 4)

Questions in the paper output:

  1. why it didn't include the outputMessage Node. (Because it's branched out? what rule determine this?)
  2. Due to (1), there are no edges related to outputMessage
  3. The Edge between 1: StringBuffer -> DST: 2: BufferedReader under which rule?

Question on current implementation to clarify:

in> private void processNode(CompilationUnit compilationUnit, PDGNode pdgNode) what if there are multiple inner nodes? there is no link to previous popped node as the current one is going to replace that. so it will just keep a record of only one inner expression. Do we need to consider this? If Yes, then need to change in a few other places as well where inner nodes are used to generate the graph. [UPDATE concern addressed]

Screen Shot 2021-03-28 at 3 01 20 AM

palashborhanuddin commented 3 years ago

Missing Edge rules (updated in previous comment): SRC: 1: StringBuffer -> DST: 2: BufferedReader (which Rule?) SRC: 4:WHILE -> DST: 7:IF (Rule 2) SRC: 5:BufferedReader.readLine -> DST: 6:StringBuffer.append, (Rule 1, Rule 5) SRC: 5:BufferedReader.readLine -> DST: 11:BufferedReader.close, (Rule 1) SRC: 6:StringBuffer.append -> DST: 10:StringBuffer.toString, (Rule 1, Rule 4) SRC: 8:StringBuffer.length -> DST: 10:StringBuffer.toString (Rule 1, Rule 4)

palashborhanuddin commented 3 years ago

Missing cases as: SRC: 1: StringBuffer -> DST: 2: BufferedReader SRC: 5:BufferedReader.readLine -> DST: 6:StringBuffer.append SRC: 4:WHILE -> DST: 7:IF

TODO: Above three requires storing the control structure scope information and resolve implicit data dependency information.

Following data dependencies are addressed: SRC: 5:BufferedReader.readLine -> DST: 11:BufferedReader.close SRC: 6:StringBuffer.append -> DST: 10:StringBuffer.toString SRC: 8:StringBuffer.length -> DST: 10:StringBuffer.toString

palashborhanuddin commented 3 years ago

Current GROUM state: nodes= 1:StringBuffer., 3:FileReader., 2:BufferedReader., 5:BufferedReader.readLine, 4:WHILE, 6:StringBuffer.append, 8:StringBuffer.length, 7:IF, 10:StringBuffer.toString, 11:BufferedReader.close,

edges=

SRC: 1:StringBuffer. -> DST: 3:FileReader., SRC: 1:StringBuffer. -> DST: 6:StringBuffer.append, SRC: 1:StringBuffer. -> DST: 8:StringBuffer.length, SRC: 1:StringBuffer. -> DST: 10:StringBuffer.toString, SRC: 3:FileReader. -> DST: 2:BufferedReader., SRC: 2:BufferedReader. -> DST: 5:BufferedReader.readLine, SRC: 2:BufferedReader. -> DST: 11:BufferedReader.close, SRC: 5:BufferedReader.readLine -> DST: 4:WHILE, SRC: 5:BufferedReader.readLine -> DST: 11:BufferedReader.close SRC: 4:WHILE -> DST: 6:StringBuffer.append, SRC: 6:StringBuffer.append -> DST: 8:StringBuffer.length, SRC: 6:StringBuffer.append -> DST: 10:StringBuffer.toString, SRC: 8:StringBuffer.length -> DST: 7:IF, SRC: 8:StringBuffer.length -> DST: 10:StringBuffer.toString, SRC: 7:IF -> DST: 10:StringBuffer.toString, SRC: 10:StringBuffer.toString -> DST: 11:BufferedReader.close,

Screen Shot 2021-03-29 at 9 22 39 AM

palashborhanuddin commented 3 years ago

What if there is an involved variable shared between X and Y where X(parallelmerge)Y? should there be an Edge between X and Y?

palashborhanuddin commented 3 years ago

Nodes: 1 StringBuffer., 3 FileReader., 2 BufferedReader., 5 BufferedReader.readLine, 4 WHILE, 6 StringBuffer.append, 8 StringBuffer.length, 7 IF, 10 StringBuffer.toString, 11 BufferedReader.close, Edges: 1 StringBuffer.-->3 FileReader. 1 StringBuffer.-->6 StringBuffer.append 1 StringBuffer.-->8 StringBuffer.length 1 StringBuffer.-->10 StringBuffer.toString

3 FileReader.-->2 BufferedReader.

2 BufferedReader.-->5 BufferedReader.readLine 2 BufferedReader.-->11 BufferedReader.close

5 BufferedReader.readLine-->4 WHILE 5 BufferedReader.readLine-->11 BufferedReader.close 5 BufferedReader.readLine-->6 StringBuffer.append

4 WHILE-->6 StringBuffer.append 4 WHILE-->7 IF

6 StringBuffer.append-->8 StringBuffer.length 6 StringBuffer.append-->10 StringBuffer.toString

8 StringBuffer.length-->7 IF 8 StringBuffer.length-->10 StringBuffer.toString

7 IF-->10 StringBuffer.toString

10 StringBuffer.toString-->11 BufferedReader.close

palashborhanuddin commented 3 years ago

Final state of the Edges for the Example source excerpted from the paper:

1 StringBuffer.<-init>-->3 FileReader.<-init > 1 StringBuffer.<-init >-->6 StringBuffer.append 1 StringBuffer.<-init >-->8 StringBuffer.length 1 StringBuffer.<-init >-->10 StringBuffer.toString 1 StringBuffer.<-init >-->2 BufferedReader.<-init>

3 FileReader.<-init >-->2 BufferedReader.<-init>

2 BufferedReader.<-init >-->5 BufferedReader.readLine 2 BufferedReader.<-init >-->11 BufferedReader.close

5 BufferedReader.readLine-->4 WHILE 5 BufferedReader.readLine-->11 BufferedReader.close 5 BufferedReader.readLine-->6 StringBuffer.append

4 WHILE-->6 StringBuffer.append 4 WHILE-->7 IF

6 StringBuffer.append-->8 StringBuffer.length 6 StringBuffer.append-->10 StringBuffer.toString

8 StringBuffer.length-->7 IF 8 StringBuffer.length-->10 StringBuffer.toString

7 IF-->10 StringBuffer.toString

10 StringBuffer.toString-->11 BufferedReader.close

The above edge list is complete according to the GROUM representation demonstrated in the paper.