/** * @param completionBuffer * @param proposal */ private void appendMethodPotentialReplacement(StringBuilder completionBuffer, GetterSetterCompletionProposal proposal) { IDocument document; try { document = JsonRpcHelpers.toDocument(this.compilationUnit.getBuffer()); int offset = proposal.getReplaceStart(); String replacement = proposal.updateReplacementString(document, offset, importRewrite, client.isCompletionSnippetsSupported()); completionBuffer.append(replacement); } catch (BadLocationException | CoreException e) { JavaLanguageServerPlugin.logException("Failed to compute potential replacement", e); } }
if (!JdtFlags.isEnum(curr)) { String getterName = GetterSetterUtil.getGetterName(curr, null); if (Strings.startsWithIgnoreCase(getterName, prefix) && !hasMethod(methods, getterName)) { int getterRelevance= relevance; if (JdtFlags.isStatic(curr) && JdtFlags.isFinal(curr)) { getterRelevance= relevance - 1; CompletionProposal proposal = new GetterSetterCompletionProposal(curr, true, offset); proposal.setName(getterName.toCharArray()); if (Strings.startsWithIgnoreCase(setterName, prefix) && !hasMethod(methods, setterName)) { CompletionProposal proposal = new GetterSetterCompletionProposal(curr, false, offset); proposal.setName(setterName.toCharArray());
private void acceptPotentialMethodDeclaration(CompletionProposal proposal) { try { IJavaElement enclosingElement = null; if (response.getContext().isExtended()) { enclosingElement = response.getContext().getEnclosingElement(); } else if (unit != null) { // kept for backward compatibility: CU is not reconciled at this moment, information is missing (bug 70005) enclosingElement = unit.getElementAt(proposal.getCompletionLocation() + 1); } if (enclosingElement == null) { return; } IType type = (IType) enclosingElement.getAncestor(IJavaElement.TYPE); if (type != null) { String prefix = String.valueOf(proposal.getName()); int completionStart = proposal.getReplaceStart(); int completionEnd = proposal.getReplaceEnd(); int relevance = proposal.getRelevance() + 6; GetterSetterCompletionProposal.evaluateProposals(type, prefix, completionStart, completionEnd - completionStart, relevance, proposals); } } catch (CoreException e) { JavaLanguageServerPlugin.logException("Accept potential method declaration failed for completion ", e); } }