palashborhanuddin / RefactoringMatcher

0 stars 0 forks source link

Handle parallel merge #6

Closed palashborhanuddin closed 2 years ago

palashborhanuddin commented 3 years ago

parameters: o.m(X,Y,Z,...) | (X∨Y∨Z∨...)⇒ C.m if statement: if (X) Y; else Z; | X⇒IF⇒(Y∨Z) expression: X◦Y | X∨Y

  X and Y be two groums. X∨Y is a groum that contains all nodes and edges of X and Y and there is no edge between any nodes of XandY

private static void groumTestMethod() throws IOException {
    StringBuffer strbuf = new StringBuffer();
    BufferedReader in = new BufferedReader(new FileReader(""));

    String str;

    while((str = in.readLine()) != null ) {
        strbuf.append(str + "\n");
    }

    if(strbuf.length() > 0) {
        outputMessage(strbuf.toString());
    } else {
        strbuf.append("dummy");
        outputMessage(strbuf.toString());
    }

    in.close();
}
palashborhanuddin commented 3 years ago

Test code:

private static void groumTestMethod() throws IOException {
        StringBuffer strbuf = new StringBuffer();
        BufferedReader in = new BufferedReader(new FileReader(""));

        String str = strbuf.someMethodAsPlainExpression() + strbuf.anotherMethodAsPlainExpression(strbuf.paramForMethodInvocation());

        while((str = in.readLine()) != null ) {
            strbuf.append(str + "\n");
        }

        if(strbuf.length() > 0) {
            outputMessage(strbuf.leftChildOfFirstIf1());
            if (strbuf.leftChildOfFirstIf2_ParamOfNestedIf()) {
                strbuf.leftChildOfFirstIf3__onlyChildOfNestedIf("");
                strbuf.leftChildOfFirstIf4__onlyChildOfNestedIf("");
            }
            strbuf.leftChildOfFirstIf5("");
            strbuf.leftChildOfFirstIf6("");
        } else if (strbuf.RigthChildOfFirstIf1_ParamOfRightIf()) {
            strbuf.RigthChildOfFirstIf2_LeftChildOfRightIf("");
            strbuf.RigthChildOfFirstIf3_LeftChildOfRightIf("");
        } else {
            strbuf.RigthChildOfRightIf();
        }

        in.close();
    }

nodes= 1 StringBuffer., 3 FileReader., 2 BufferedReader., 6 StringBuffer.paramForMethodInvocation, 5 StringBuffer.anotherMethodAsPlainExpression, 4 StringBuffer.someMethodAsPlainExpression, 8 BufferedReader.readLine, 7 WHILE, 9 StringBuffer.append, 11 StringBuffer.length, 10 IF, 13 StringBuffer.leftChildOfFirstIf1, 15 StringBuffer.leftChildOfFirstIf2_ParamOfNestedIf, 14 IF, 16 StringBuffer.leftChildOfFirstIf3onlyChildOfNestedIf, 17 StringBuffer.leftChildOfFirstIf4onlyChildOfNestedIf, 18 StringBuffer.leftChildOfFirstIf5, 19 StringBuffer.leftChildOfFirstIf6, 21 StringBuffer.RigthChildOfFirstIf1_ParamOfRightIf, 20 IF, 22 StringBuffer.RigthChildOfFirstIf2_LeftChildOfRightIf, 23 StringBuffer.RigthChildOfFirstIf3_LeftChildOfRightIf, 24 StringBuffer.RigthChildOfRightIf, 25 BufferedReader.close

Temporal GROUM Tree= , 1 StringBuffer.-->3 FileReader. , 3 FileReader.-->2 BufferedReader. L , 2 BufferedReader.-->4 StringBuffer.someMethodAsPlainExpression R, 2 BufferedReader.-->6 StringBuffer.paramForMethodInvocation , 6 StringBuffer.paramForMethodInvocation-->5 StringBuffer.anotherMethodAsPlainExpression

, 4 StringBuffer.someMethodAsPlainExpression-->8 BufferedReader.readLine , 5 StringBuffer.anotherMethodAsPlainExpression-->8 BufferedReader.readLine

, 8 BufferedReader.readLine-->7 WHILE , 7 WHILE-->9 StringBuffer.append , 9 StringBuffer.append-->11 StringBuffer.length , 11 StringBuffer.length-->10 IF L, 10 IF-->13 StringBuffer.leftChildOfFirstIf1 , 13 StringBuffer.leftChildOfFirstIf1-->15 StringBuffer.leftChildOfFirstIf2_ParamOfNestedIf , 15 StringBuffer.leftChildOfFirstIf2_ParamOfNestedIf-->14 IF , 14 IF-->16 StringBuffer.leftChildOfFirstIf3onlyChildOfNestedIf , 16 StringBuffer.leftChildOfFirstIf3onlyChildOfNestedIf-->17 StringBuffer.leftChildOfFirstIf4onlyChildOfNestedIf , 17 StringBuffer.leftChildOfFirstIf4onlyChildOfNestedIf-->18 StringBuffer.leftChildOfFirstIf5 , 18 StringBuffer.leftChildOfFirstIf5-->19 StringBuffer.leftChildOfFirstIf6

R, 10 IF-->21 StringBuffer.RigthChildOfFirstIf1_ParamOfRightIf , 21 StringBuffer.RigthChildOfFirstIf1_ParamOfRightIf-->20 IF RL, 20 IF-->22 StringBuffer.RigthChildOfFirstIf2_LeftChildOfRightIf , 22 StringBuffer.RigthChildOfFirstIf2_LeftChildOfRightIf-->23 StringBuffer.RigthChildOfFirstIf3_LeftChildOfRightIf RR, 20 IF-->24 StringBuffer.RigthChildOfRightIf

, 19 StringBuffer.leftChildOfFirstIf6-->25 BufferedReader.close , 23 StringBuffer.RigthChildOfFirstIf3_LeftChildOfRightIf-->25 BufferedReader.close , 24 StringBuffer.RigthChildOfRightIf-->25 BufferedReader.close

palashborhanuddin commented 2 years ago
private static void groumTestMethod() throws IOException {
        StringBuffer strbuf = new StringBuffer();
        BufferedReader in = new BufferedReader(new FileReader(""));

        String str;

        while((str = in.readLine()) != null ) {
            strbuf.append(str + "\n");
        }

        if(strbuf.length() > 0) {
            outputMessage(strbuf.toString());
        } else {
            outputMessage(strbuf.capacity());
        }

        in.close();
    }

Previously representation was showing an unwanted edge between StringBuffer.toString() -> StringBuffer.capacity(). This issue has been fixed, now it doesn't. Also tested for following switch case scenario.

case "january":
                monthNumber = 1;
                month.length();
                break;
 case "february":
                monthNumber = 2;
                month.toUpperCase();
                break;

For this code, there shouldn't be any edge between String.length() -> String.toUpperCase(). But if there is no break statement for the first case then there should be an edge. This is working as expected.