From 0cca16943833c02ff02a95c7d8d8e91430ba34a0 Mon Sep 17 00:00:00 2001 From: Gayan Perera Date: Sat, 27 Jul 2024 09:11:58 +0200 Subject: [PATCH] fix random completion errors including #634 --- .../jdt/internal/codeassist/DOMCompletionEngine.java | 9 +++++++-- .../DOMCompletionEngineRecoveredNodeScanner.java | 4 ++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/DOMCompletionEngine.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/DOMCompletionEngine.java index 66cdf6d05ba..fe1c367a0bd 100644 --- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/DOMCompletionEngine.java +++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/DOMCompletionEngine.java @@ -438,8 +438,12 @@ private CompletionProposal toProposal(IBinding binding, String completion) { if (kind == CompletionProposal.METHOD_REF) { var methodBinding = (IMethodBinding) binding; - res.setParameterNames(DOMCompletionEngineMethodDeclHandler.findVariableNames(methodBinding).stream() - .map(String::toCharArray).toArray(i -> new char[i][])); + var paramNames = DOMCompletionEngineMethodDeclHandler.findVariableNames(methodBinding); + if (paramNames.isEmpty()) { + res.setParameterNames(null); + } else { + res.setParameterNames(paramNames.stream().map(String::toCharArray).toArray(i -> new char[i][])); + } res.setSignature(Signature.createMethodSignature( Arrays.stream(methodBinding.getParameterTypes()).map(ITypeBinding::getName).map(String::toCharArray) .map(type -> Signature.createTypeSignature(type, true).toCharArray()) @@ -564,6 +568,7 @@ private CompletionProposal toPackageProposal(String packageName, ASTNode complet res.setName(packageName.toCharArray()); res.setCompletion(packageName.toCharArray()); res.setDeclarationSignature(packageName.toCharArray()); + res.setSignature(packageName.toCharArray()); configureProposal(res, completing); return res; } diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/DOMCompletionEngineRecoveredNodeScanner.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/DOMCompletionEngineRecoveredNodeScanner.java index 8798aa23e08..fc4580b6d27 100644 --- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/DOMCompletionEngineRecoveredNodeScanner.java +++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/DOMCompletionEngineRecoveredNodeScanner.java @@ -116,6 +116,10 @@ public boolean visit(SimpleType node) { // actual recoverable type, if not treat the type name as a variable name and search for such variable in // the context. var binding = node.resolveBinding(); + if(binding == null) { + return super.visit(node); + } + if (!binding.isRecovered()) { this.foundBinding = binding; return false;