|
Lines 80-85
Link Here
|
| 80 |
import org.eclipse.jdt.internal.core.JavaModelManager; |
80 |
import org.eclipse.jdt.internal.core.JavaModelManager; |
| 81 |
import org.eclipse.jdt.internal.core.JavaProject; |
81 |
import org.eclipse.jdt.internal.core.JavaProject; |
| 82 |
import org.eclipse.jdt.internal.core.LambdaFactory; |
82 |
import org.eclipse.jdt.internal.core.LambdaFactory; |
|
|
83 |
import org.eclipse.jdt.internal.core.LambdaMethod; |
| 83 |
import org.eclipse.jdt.internal.core.LocalVariable; |
84 |
import org.eclipse.jdt.internal.core.LocalVariable; |
| 84 |
import org.eclipse.jdt.internal.core.ModularClassFile; |
85 |
import org.eclipse.jdt.internal.core.ModularClassFile; |
| 85 |
import org.eclipse.jdt.internal.core.NameLookup; |
86 |
import org.eclipse.jdt.internal.core.NameLookup; |
|
Lines 2508-2518
Link Here
|
| 2508 |
for (int i = 0; i < length; i++) { |
2509 |
for (int i = 0; i < length; i++) { |
| 2509 |
Integer level = (Integer) nodeSet.matchingNodes.removeKey(nodes[i]); |
2510 |
Integer level = (Integer) nodeSet.matchingNodes.removeKey(nodes[i]); |
| 2510 |
if (report && level != null) { |
2511 |
if (report && level != null) { |
|
|
2512 |
if(enclosingElement instanceof LambdaMethod) { |
| 2513 |
IJavaElement parentLambda = getParentMethodOfLambda(enclosingElement); |
| 2514 |
if(parentLambda !=null) { |
| 2515 |
enclosingElement = parentLambda; |
| 2516 |
} |
| 2517 |
} |
| 2518 |
|
| 2511 |
this.patternLocator.matchReportReference(nodes[i], enclosingElement, declarationVisitor.getLocalElement(i), declarationVisitor.getOtherElements(i), lambdaExpression.binding, level.intValue(), this); |
2519 |
this.patternLocator.matchReportReference(nodes[i], enclosingElement, declarationVisitor.getLocalElement(i), declarationVisitor.getOtherElements(i), lambdaExpression.binding, level.intValue(), this); |
| 2512 |
} |
2520 |
} |
| 2513 |
} |
2521 |
} |
| 2514 |
} |
2522 |
} |
| 2515 |
} |
2523 |
} |
|
|
2524 |
private static IJavaElement getParentMethodOfLambda(IJavaElement element) { |
| 2525 |
IJavaElement parent = element.getParent(); |
| 2526 |
if(parent == null) |
| 2527 |
return null; |
| 2528 |
if(parent instanceof IMethod && !(parent instanceof LambdaMethod)) |
| 2529 |
return parent; |
| 2530 |
return getParentMethodOfLambda(parent); |
| 2531 |
|
| 2532 |
} |
| 2516 |
/** |
2533 |
/** |
| 2517 |
* Visit the given method declaration and report the nodes that match exactly the |
2534 |
* Visit the given method declaration and report the nodes that match exactly the |
| 2518 |
* search pattern (i.e. the ones in the matching nodes set) |
2535 |
* search pattern (i.e. the ones in the matching nodes set) |