SSR: find lambda parameters with variable declaration pattern

GitOrigin-RevId: 195e38771ea9fbe6a0bb29cd846f69857aec988a
This commit is contained in:
Bas Leijdekkers
2020-07-30 15:27:54 +02:00
committed by intellij-monorepo-bot
parent 5205299988
commit 7094b8cd26
2 changed files with 15 additions and 1 deletions

View File

@@ -930,6 +930,10 @@ public class JavaMatchingVisitor extends JavaElementVisitor {
else if (element instanceof PsiJavaCodeReferenceElement) {
result = ((PsiJavaCodeReferenceElement)element).getCanonicalText();
}
else if (element instanceof PsiTypeElement) {
final PsiTypeElement typeElement = (PsiTypeElement)element;
result = typeElement.isInferredType() ? typeElement.getText() : typeElement.getType().getCanonicalText();
}
else {
result = element.getText();
}
@@ -1003,7 +1007,7 @@ public class JavaMatchingVisitor extends JavaElementVisitor {
final PsiTypeElement typeElement1 = var.getTypeElement();
if (typeElement1 != null) {
PsiTypeElement typeElement2 = other.getTypeElement();
if (typeElement2 == null) {
if (typeElement2 == null) { // e.g. lambda parameter without explicit type
typeElement2 = JavaPsiFacade.getElementFactory(other.getProject()).createTypeElement(other.getType());
}
if (!myMatchingVisitor.setResult(myMatchingVisitor.match(typeElement1, typeElement2))) return;