private void appendBody(StringBuilder completionBuffer) { if (client.isCompletionSnippetsSupported()) { String replace = CompletionUtils.sanitizeCompletion(completionBuffer.toString()); completionBuffer.replace(0, completionBuffer.toString().length(), replace); } completionBuffer.append(" {\n\t"); if (client.isCompletionSnippetsSupported()) { completionBuffer.append(CURSOR_POSITION); completionBuffer.append("\n}"); }//if Snippets not supported, we leave an open bracket so users can type in directly }
private void appendMethodNameReplacement(StringBuilder buffer, CompletionProposal proposal) { if (proposal.getKind() == CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER) { String coreCompletion = String.valueOf(proposal.getCompletion()); if (client.isCompletionSnippetsSupported()) { coreCompletion = CompletionUtils.sanitizeCompletion(coreCompletion); } // String lineDelimiter = TextUtilities.getDefaultLineDelimiter(getTextViewer().getDocument()); // String replacement= CodeFormatterUtil.format(CodeFormatter.K_EXPRESSION, coreCompletion, 0, lineDelimiter, fInvocationContext.getProject()); // buffer.append(replacement.substring(0, replacement.lastIndexOf('.') + 1)); buffer.append(coreCompletion); } if (proposal.getKind() != CompletionProposal.CONSTRUCTOR_INVOCATION) { String str = new String(proposal.getName()); if (client.isCompletionSnippetsSupported()) { str = CompletionUtils.sanitizeCompletion(str); } buffer.append(str); } }
replace = CompletionUtils.sanitizeCompletion(replace); argument = replace.toCharArray();
private void appendReplacementString(StringBuilder buffer, CompletionProposal proposal) { if (!hasArgumentList(proposal)) { String str = proposal.getKind() == CompletionProposal.TYPE_REF ? computeJavaTypeReplacementString(proposal) : String.valueOf(proposal.getCompletion()); if (client.isCompletionSnippetsSupported()) { str = CompletionUtils.sanitizeCompletion(str); } buffer.append(str); return; } // we're inserting a method plus the argument list - respect formatter preferences appendMethodNameReplacement(buffer, proposal); final boolean addParen = client.isCompletionSnippetsSupported(); if(addParen) { buffer.append(LPAREN); } if (hasParameters(proposal)) { appendGuessingCompletion(buffer, proposal); } if(addParen){ buffer.append(RPAREN); // add semicolons only if there are parentheses if (canAutomaticallyAppendSemicolon(proposal)) { buffer.append(SEMICOLON); } } if(proposal.getKind() == CompletionProposal.METHOD_DECLARATION){ appendBody(buffer); } }