Skip to content

Commit

Permalink
"extract lambda to method" works newly for lambda which uses a method…
Browse files Browse the repository at this point in the history
… argument(s)
  • Loading branch information
Honza committed Oct 11, 2023
1 parent a04f20e commit e241624
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,17 @@ public Void visitVariable(VariableTree node, Void p) {
public Void visitIdentifier(IdentifierTree node, Void p) {
Element e = info.getTrees().getElement(getCurrentPath());
if (e != null) {

if (isLambda && treesSeensInSelection.contains(node) && e.getKind().equals(ElementKind.LOCAL_VARIABLE)){
usedLocalVariables.put((VariableElement) e, !localVariables.contains(e));
}

if (IntroduceHint.LOCAL_VARIABLES.contains(e.getKind()) && (e.getKind()!=ElementKind.PARAMETER) || isLambda) {
if (IntroduceHint.LOCAL_VARIABLES.contains(e.getKind())) {
switch (phase) {
case PHASE_INSIDE_SELECTION:
if (localVariables.contains(e) && usedLocalVariables.get(e) == null) {

final boolean isUsedInLambda = isLambda
&& treesSeensInSelection.contains(node)
&& !selectionLocalVariables.contains((VariableElement) e);

if (isUsedInLambda) {
usedLocalVariables.put((VariableElement) e, !localVariables.contains(e));
} else if (localVariables.contains(e) && usedLocalVariables.get(e) == null) {
Iterable<? extends TreePath> writes = assignmentsForUse.get(getCurrentPath().getLeaf());
Boolean definitellyAssignedInSelection = true;
if (writes != null) {
Expand Down

0 comments on commit e241624

Please sign in to comment.