|
98 | 98 | import org.eclipse.jdt.core.dom.IfStatement; |
99 | 99 | import org.eclipse.jdt.core.dom.ImportDeclaration; |
100 | 100 | import org.eclipse.jdt.core.dom.InfixExpression; |
101 | | -import org.eclipse.jdt.core.dom.InfixExpression.Operator; |
102 | 101 | import org.eclipse.jdt.core.dom.Initializer; |
103 | 102 | import org.eclipse.jdt.core.dom.InstanceofExpression; |
104 | 103 | import org.eclipse.jdt.core.dom.Javadoc; |
|
110 | 109 | import org.eclipse.jdt.core.dom.MethodInvocation; |
111 | 110 | import org.eclipse.jdt.core.dom.MethodRef; |
112 | 111 | import org.eclipse.jdt.core.dom.Modifier; |
113 | | -import org.eclipse.jdt.core.dom.Modifier.ModifierKeyword; |
114 | 112 | import org.eclipse.jdt.core.dom.ModuleDeclaration; |
115 | 113 | import org.eclipse.jdt.core.dom.Name; |
116 | 114 | import org.eclipse.jdt.core.dom.NodeFinder; |
|
151 | 149 | import org.eclipse.jdt.core.dom.VariableDeclarationFragment; |
152 | 150 | import org.eclipse.jdt.core.dom.VariableDeclarationStatement; |
153 | 151 | import org.eclipse.jdt.core.dom.WhileStatement; |
| 152 | +import org.eclipse.jdt.core.dom.InfixExpression.Operator; |
| 153 | +import org.eclipse.jdt.core.dom.Modifier.ModifierKeyword; |
154 | 154 | import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants; |
155 | 155 | import org.eclipse.jdt.core.search.IJavaSearchConstants; |
156 | 156 | import org.eclipse.jdt.core.search.IJavaSearchScope; |
@@ -735,21 +735,16 @@ public void complete(org.eclipse.jdt.internal.compiler.env.ICompilationUnit sour |
735 | 735 | suggestDefaultCompletions = false; |
736 | 736 | } |
737 | 737 | if (context instanceof MethodInvocation invocation) { |
738 | | - if (this.offset <= invocation.getName().getStartPosition() + invocation.getName().getLength()) { |
| 738 | + if (this.offset >= invocation.getName().getStartPosition() && this.offset <= invocation.getName().getStartPosition() + invocation.getName().getLength()) { |
739 | 739 | Expression expression = invocation.getExpression(); |
740 | | - if (expression == null) { |
741 | | - return; |
742 | | - } |
743 | | - // complete name |
744 | | - ITypeBinding type = expression.resolveTypeBinding(); |
745 | | - if (type != null) { |
746 | | - processMembers(expression, type, specificCompletionBindings, false); |
747 | | - specificCompletionBindings.all() |
748 | | - .filter(binding -> this.pattern.matchesName(this.prefix.toCharArray(), binding.getName().toCharArray())) |
749 | | - .filter(IMethodBinding.class::isInstance) |
750 | | - .map(binding -> toProposal(binding)) |
751 | | - .forEach(this.requestor::accept); |
752 | | - } |
| 740 | + ITypeBinding type = expression == null |
| 741 | + ? DOMCompletionUtil.findParentTypeDeclaration(context).resolveBinding() |
| 742 | + : expression.resolveTypeBinding(); |
| 743 | + processMembers(invocation, type, specificCompletionBindings, false); |
| 744 | + specificCompletionBindings.all() |
| 745 | + .filter(binding -> this.pattern.matchesName(this.prefix.toCharArray(), binding.getName().toCharArray())) |
| 746 | + .map(binding -> toProposal(binding)) |
| 747 | + .forEach(this.requestor::accept); |
753 | 748 | suggestDefaultCompletions = false; |
754 | 749 | } else if (invocation.getStartPosition() + invocation.getLength() <= this.offset && this.prefix.isEmpty()) { |
755 | 750 | // handle `myMethod().|` |
|
0 commit comments