mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
NPE during completion for lambda params
This commit is contained in:
+4
-2
@@ -109,7 +109,9 @@ public class JavaMemberNameCompletionContributor extends CompletionContributor {
|
||||
String propertyName = null;
|
||||
if (variableKind == VariableKind.PARAMETER) {
|
||||
final PsiMethod method = PsiTreeUtil.getParentOfType(var, PsiMethod.class);
|
||||
propertyName = PropertyUtil.getPropertyName(method);
|
||||
if (method != null) {
|
||||
propertyName = PropertyUtil.getPropertyName(method);
|
||||
}
|
||||
if (method != null && method.getName().startsWith("with")) {
|
||||
propertyName = StringUtil.decapitalize(method.getName().substring(4));
|
||||
}
|
||||
@@ -133,7 +135,7 @@ public class JavaMemberNameCompletionContributor extends CompletionContributor {
|
||||
addLookupItems(set, null, matcher, project, getOverlappedNameVersions(matcher.getPrefix(), suggestedNames, ""));
|
||||
}
|
||||
PsiElement parent = PsiTreeUtil.getParentOfType(var, PsiCodeBlock.class);
|
||||
if(parent == null) parent = PsiTreeUtil.getParentOfType(var, PsiMethod.class);
|
||||
if(parent == null) parent = PsiTreeUtil.getParentOfType(var, PsiMethod.class, PsiLambdaExpression.class);
|
||||
addLookupItems(set, suggestedNameInfo, matcher, project, getUnresolvedReferences(parent, false));
|
||||
if (var instanceof PsiParameter && parent instanceof PsiMethod) {
|
||||
addSuggestionsInspiredByFieldNames(set, matcher, var, project, codeStyleManager);
|
||||
|
||||
@@ -103,7 +103,7 @@ public class PropertyUtil {
|
||||
return Comparing.equal(PsiUtil.resolveClassInType(TypeConversionUtil.erasure(returnType)), method.getContainingClass());
|
||||
}
|
||||
|
||||
@Nullable public static String getPropertyName(PsiMethod method) {
|
||||
@Nullable public static String getPropertyName(@NotNull PsiMethod method) {
|
||||
if (isSimplePropertyGetter(method)) {
|
||||
return getPropertyNameByGetter(method);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user