public ProcessableGetterSetterCompletionProposal(CompletionProposal coreProposal, IField field, boolean isGetter, int relevance) throws JavaModelException { super(field, coreProposal.getReplaceStart(), coreProposal.getReplaceEnd() - coreProposal.getReplaceStart(), isGetter, relevance); }
/** * Gets the replacement length. * @return Returns a int */ @Override public final int getReplacementLength() { if (!fReplacementLengthComputed) setReplacementLength(fProposal.getReplaceEnd() - fProposal.getReplaceStart()); return super.getReplacementLength(); }
/** * Gets the replacement length. * @return Returns a int */ public final int getReplacementLength() { if (!fReplacementLengthComputed) setReplacementLength(fProposal.getReplaceEnd() - fProposal.getReplaceStart()); return super.getReplacementLength(); }
/** * Gets the replacement length. * @return Returns a int */ @Override public final int getReplacementLength() { if (!fReplacementLengthComputed) setReplacementLength(fProposal.getReplaceEnd() - fProposal.getReplaceStart()); return super.getReplacementLength(); }
/** * Returns the replacement length of a given completion proposal. The * replacement length is usually the difference between the return values of * <code>proposal.getReplaceEnd</code> and * <code>proposal.getReplaceStart</code>, but this behavior may be * overridden by calling {@link #setReplacementLength(int)}. * * @param proposal the completion proposal to get the replacement length for * @return the replacement length for <code>proposal</code> */ protected final int getLength(CompletionProposal proposal) { int start= proposal.getReplaceStart(); int end= proposal.getReplaceEnd(); int length; if (fUserReplacementLength == -1) { length= end - start; } else { length= fUserReplacementLength; // extend length to begin at start int behindCompletion= proposal.getCompletionLocation() + 1; if (start < behindCompletion) { length+= behindCompletion - start; } } return length; }
/** * Returns the replacement length of a given completion proposal. The * replacement length is usually the difference between the return values of * <code>proposal.getReplaceEnd</code> and * <code>proposal.getReplaceStart</code>, but this behavior may be * overridden by calling {@link #setReplacementLength(int)}. * * @param proposal the completion proposal to get the replacement length for * @return the replacement length for <code>proposal</code> */ protected final int getLength(CompletionProposal proposal) { int start= proposal.getReplaceStart(); int end= proposal.getReplaceEnd(); int length; if (fUserReplacementLength == -1) { length= end - start; } else { length= fUserReplacementLength; // extend length to begin at start int behindCompletion= proposal.getCompletionLocation() + 1; if (start < behindCompletion) { length+= behindCompletion - start; } } return length; }
/** * Returns the replacement length of a given completion proposal. The * replacement length is usually the difference between the return values of * <code>proposal.getReplaceEnd</code> and * <code>proposal.getReplaceStart</code>, but this behavior may be * overridden by calling {@link #setReplacementLength(int)}. * * @param proposal the completion proposal to get the replacement length for * @return the replacement length for <code>proposal</code> */ protected final int getLength(CompletionProposal proposal) { int start= proposal.getReplaceStart(); int end= proposal.getReplaceEnd(); int length; if (fUserReplacementLength == -1) { length= end - start; } else { length= fUserReplacementLength; // extend length to begin at start int behindCompletion= proposal.getCompletionLocation() + 1; if (start < behindCompletion) { length+= behindCompletion - start; } } return length; }
IRegion region= document.getLineInformationOfOffset(proposal.getReplaceEnd()); String line= document.get(region.getOffset(),region.getLength()); int index= proposal.getReplaceEnd() - region.getOffset(); while (index != line.length() && Character.isUnicodeIdentifierPart(line.charAt(index))) { ++index;
private Range toReplacementRange(CompletionProposal proposal){ try { return JDTUtils.toRange(compilationUnit, proposal.getReplaceStart(), proposal.getReplaceEnd()-proposal.getReplaceStart()); } catch (JavaModelException e) { JavaLanguageServerPlugin.logException(e.getMessage(), e); } return null; }
buffer.append("\tCompletionLocation[").append(proposal.getCompletionLocation()).append("]\n"); //$NON-NLS-1$ //$NON-NLS-2$ int start = proposal.getReplaceStart(); int end = proposal.getReplaceEnd(); printDebugTab(tab, buffer); buffer.append("\tReplaceStart[").append(start).append("]"); //$NON-NLS-1$ //$NON-NLS-2$
public static ProcessableMethodDeclarationCompletionProposal newProposal(CompletionProposal proposal, IType type, int relevance) throws CoreException { String prefix = String.valueOf(proposal.getName()); int offset = proposal.getReplaceStart(); int length = proposal.getReplaceEnd() - offset; IMethod[] methods = type.getMethods(); if (!type.isInterface()) { String constructorName = type.getElementName(); if (constructorName.length() > 0 && constructorName.startsWith(prefix) && !hasMethod(methods, constructorName)) { return new ProcessableMethodDeclarationCompletionProposal(type, constructorName, null, offset, length, relevance + 500); } } if (prefix.length() > 0 && !"main".equals(prefix) && !hasMethod(methods, prefix)) { if (!JavaConventionsUtil.validateMethodName(prefix, type).matches(IStatus.ERROR)) return new ProcessableMethodDeclarationCompletionProposal(type, prefix, Signature.SIG_VOID, offset, length, relevance); } return null; }
new String(proposal.getCompletion()), proposal.getReplaceStart(), proposal.getReplaceEnd(), proposal.getRelevance(), JavaPluginImages.DESC_OBJS_PACKAGE); new String(proposal.getCompletion()), proposal.getReplaceStart(), proposal.getReplaceEnd(), proposal.getRelevance(), JavaElementImageProvider.getTypeImageDescriptor(false, false, proposal.getFlags(), false), new String(proposal.getCompletion()), proposal.getReplaceStart(), proposal.getReplaceEnd(), proposal.getRelevance(), null);
try{ IDocument document = JsonRpcHelpers.toDocument(this.compilationUnit.getBuffer()); IRegion region= document.getLineInformationOfOffset(proposal.getReplaceEnd()); prefix = document.get(region.getOffset(), proposal.getReplaceEnd() -region.getOffset()).trim(); }catch(BadLocationException | JavaModelException e){
new String(proposal.getCompletion()), proposal.getReplaceStart(), proposal.getReplaceEnd(), proposal.getRelevance(), JavaPluginImages.DESC_OBJS_PACKAGE); new String(proposal.getCompletion()), proposal.getReplaceStart(), proposal.getReplaceEnd(), proposal.getRelevance(), typeImageDescriptor, new String(proposal.getCompletion()), proposal.getReplaceStart(), proposal.getReplaceEnd(), proposal.getRelevance(), null);
new String(proposal.getCompletion()), proposal.getReplaceStart(), proposal.getReplaceEnd(), proposal.getRelevance(), JavaPluginImages.DESC_OBJS_PACKAGE); new String(proposal.getCompletion()), proposal.getReplaceStart(), proposal.getReplaceEnd(), proposal.getRelevance(), typeImageDescriptor, new String(proposal.getCompletion()), proposal.getReplaceStart(), proposal.getReplaceEnd(), proposal.getRelevance(), null);
private void acceptPotentialMethodDeclaration(CompletionProposal proposal) { if (fCompilationUnit == null) return; String prefix= String.valueOf(proposal.getName()); int completionStart= proposal.getReplaceStart(); int completionEnd= proposal.getReplaceEnd(); int relevance= computeRelevance(proposal); try { IJavaElement element= fCompilationUnit.getElementAt(proposal.getCompletionLocation() + 1); if (element != null) { IType type= (IType) element.getAncestor(IJavaElement.TYPE); if (type != null) { GetterSetterCompletionProposal.evaluateProposals(type, prefix, completionStart, completionEnd - completionStart, relevance + 1, fSuggestedMethodNames, fJavaProposals); MethodDeclarationCompletionProposal.evaluateProposals(type, prefix, completionStart, completionEnd - completionStart, relevance, fSuggestedMethodNames, fJavaProposals); } } } catch (CoreException e) { JavaPlugin.log(e); } }
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); } }
private void acceptPotentialMethodDeclaration(CompletionProposal proposal) { try { IJavaElement enclosingElement= null; if (getContext().isExtended()) { enclosingElement= getContext().getEnclosingElement(); } else if (fCompilationUnit != null) { // kept for backward compatibility: CU is not reconciled at this moment, information is missing (bug 70005) enclosingElement= fCompilationUnit.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= computeRelevance(proposal); GetterSetterCompletionProposal.evaluateProposals(type, prefix, completionStart, completionEnd - completionStart, relevance + 2, fSuggestedMethodNames, fJavaProposals); MethodDeclarationCompletionProposal.evaluateProposals(type, prefix, completionStart, completionEnd - completionStart, relevance, fSuggestedMethodNames, fJavaProposals); } } catch (CoreException e) { JavaPlugin.log(e); } }
private void acceptPotentialMethodDeclaration(CompletionProposal proposal) { try { IJavaElement enclosingElement= null; if (getContext().isExtended()) { enclosingElement= getContext().getEnclosingElement(); } else if (fCompilationUnit != null) { // kept for backward compatibility: CU is not reconciled at this moment, information is missing (bug 70005) enclosingElement= fCompilationUnit.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= computeRelevance(proposal); GetterSetterCompletionProposal.evaluateProposals(type, prefix, completionStart, completionEnd - completionStart, relevance + 2, fSuggestedMethodNames, fJavaProposals); MethodDeclarationCompletionProposal.evaluateProposals(type, prefix, completionStart, completionEnd - completionStart, relevance, fSuggestedMethodNames, fJavaProposals); } } catch (CoreException e) { JavaPlugin.log(e); } }
if (!completionOverwrite && (proposal.getKind() == CompletionProposal.METHOD_REF || proposal.getKind() == CompletionProposal.LOCAL_VARIABLE_REF || proposal.getKind() == CompletionProposal.FIELD_REF)) { int end = proposal.getReplaceEnd(); if (end > offset) { proposal.setReplaceRange(proposal.getReplaceStart(), offset);