Skip to content

Commit d5df778

Browse files
committed
Fix to take into account infix expressions and nested invocations
1 parent 3660ae8 commit d5df778

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

src/sequenceextractor/SequenceExtractor.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ private static void processBlock(XMLNode block, LookUpTable lookUpTable, Snippet
161161
lookUpTable.addMethodVariable(variableName, variableType);
162162
}
163163
if (vardecl.hasMoreThanOneChildren()) {
164-
for (XMLNode classinstantiation : statement.getChildNodesRecursivelyByName("ClassInstanceCreation")) {
165-
XMLNodeList innerinstantiations = classinstantiation.getDeepChildNodesRecursivelyByName("ClassInstanceCreation");
164+
for (XMLNode classinstantiation : statement.getChildNodesRecursivelyByName("ClassInstanceCreation", "MethodInvocation")) {
165+
XMLNodeList innerinstantiations = classinstantiation.getDeepChildNodesRecursivelyByName("ClassInstanceCreation", "MethodInvocation");
166166
Collections.reverse(innerinstantiations);
167167
for (XMLNode innerclassinstantiation : innerinstantiations) {
168168
snippet.addStatement(iterateLowLevelCode(innerclassinstantiation, lookUpTable));
@@ -172,6 +172,9 @@ private static void processBlock(XMLNode block, LookUpTable lookUpTable, Snippet
172172
}
173173
} else if (statement.hasName(StatementTypes.branchStatementTypes)) {
174174
ArrayList<XMLNode> branchstatements = statement.getChildNodesByName("Block");
175+
if (statement.getChildNodes().size() > 0 && !statement.getChildNodes().get(0).hasName("Block")) {
176+
snippet.addStatement(iterateLowLevelCode(statement.getChildNodes().get(0), lookUpTable));
177+
}
175178

176179
// Check the type of the branch
177180
if (statement.hasName(StatementTypes.loopStatementTypes) && branchstatements.size() > 0) {
@@ -253,8 +256,8 @@ private static void processBlock(XMLNode block, LookUpTable lookUpTable, Snippet
253256
snippet.levelOuter();
254257
}
255258
} else {
256-
for (XMLNode classinstantiation : statement.getChildNodesRecursivelyByName("ClassInstanceCreation")) {
257-
XMLNodeList innerinstantiations = classinstantiation.getDeepChildNodesRecursivelyByName("ClassInstanceCreation");
259+
for (XMLNode classinstantiation : statement.getChildNodesRecursivelyByName("ClassInstanceCreation", "MethodInvocation")) {
260+
XMLNodeList innerinstantiations = classinstantiation.getDeepChildNodesRecursivelyByName("ClassInstanceCreation", "MethodInvocation");
258261
Collections.reverse(innerinstantiations);
259262
for (XMLNode innerclassinstantiation : innerinstantiations) {
260263
snippet.addStatement(iterateLowLevelCode(innerclassinstantiation, lookUpTable));

0 commit comments

Comments
 (0)