Skip to content

Commit

Permalink
Enable Extract Variable and Extract Attribute detection in commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tsantalis committed Jan 17, 2025
1 parent 94e8afb commit 0ef71f2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ else if(stringConcatMatch(initializer, before)) {
}
processExtractVariableRefactoring(ref, refactorings);
checkForNestedExtractVariable(ref, refactorings, nonMappedLeavesT2, insideExtractedOrInlinedMethod);
if(identical()) {
if(identical() || ternaryMatch(initializer, before)) {
identicalWithExtractedVariable = true;
}
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1185,6 +1185,19 @@ private LeafExpression extractInlineCondition(VariableDeclaration variableDeclar
return subExpressions.get(0);
}
}
//check for string concatenation with "."
if(replacementAsString.startsWith("\"") && replacementAsString.endsWith("\"") &&
variableDeclaration.getInitializer().getString().startsWith("\"") &&
variableDeclaration.getInitializer().getString().endsWith("\"")) {
String replacementAsStringWithoutDoubleQuotes = replacementAsString.substring(1, replacementAsString.length()-1);
String initializerWithoutDoubleQuotes = variableDeclaration.getInitializer().getString().substring(1, variableDeclaration.getInitializer().getString().length()-1);
if(replacementAsStringWithoutDoubleQuotes.equals(initializerWithoutDoubleQuotes + ".")) {
List<LeafExpression> subExpressions = variableDeclaration.getInitializer().findExpression(variableDeclaration.getInitializer().getString());
if(subExpressions.size() > 0) {
return subExpressions.get(0);
}
}
}
if(replacement instanceof VariableReplacementWithMethodInvocation) {
VariableReplacementWithMethodInvocation r = (VariableReplacementWithMethodInvocation)replacement;
for(AbstractCall call : variableDeclaration.getInitializer().getMethodInvocations()) {
Expand Down

0 comments on commit 0ef71f2

Please sign in to comment.