@Override public final IContextInformation getContextInformation() { if (!fContextInformationComputed) setContextInformation(computeContextInformation()); return super.getContextInformation(); }
@Override protected final int getCursorPosition() { if (!fCursorPositionComputed) setCursorPosition(computeCursorPosition()); return super.getCursorPosition(); }
@Override public String getDisplayString() { if (!fDisplayStringComputed) setStyledDisplayString(computeDisplayString()); return super.getDisplayString(); }
public final String getDisplayString() { if (!fDisplayStringComputed) setDisplayString(computeDisplayString()); return super.getDisplayString(); }
public final String getSortString() { if (!fSortStringComputed) setSortString(computeSortString()); return super.getSortString(); }
public void apply(IDocument document, char trigger, int offset) { if (trigger == ' ' || trigger == '(') trigger= '\0'; super.apply(document, trigger, offset); if (needsLinkedMode()) { setUpLinkedMode(document, ')'); } }
@Override public final Image getImage() { if (!fImageComputed) setImage(computeImage()); return super.getImage(); }
/** * Gets the proposal's relevance. * @return Returns a int */ @Override public final int getRelevance() { if (!fRelevanceComputed) setRelevance(computeRelevance()); return super.getRelevance(); }
/** * Gets the replacement string. * @return Returns a String */ public final String getReplacementString() { if (!fReplacementStringComputed) setReplacementString(computeReplacementString()); return super.getReplacementString(); }
/** * Returns the additional proposal info, or <code>null</code> if none * exists. * * @return the additional proposal info, or <code>null</code> if none * exists */ protected final ProposalInfo getProposalInfo() { if (!fProposalInfoComputed) setProposalInfo(computeProposalInfo()); return super.getProposalInfo(); }
protected ProposalInfo computeProposalInfo() { IJavaProject project= fInvocationContext.getProject(); if (project != null) return new MethodProposalInfo(project, fProposal); return super.computeProposalInfo(); }
protected String computeReplacementString() { String replacement= super.computeReplacementString(); // TODO respect the auto-close preference, but do so consistently with method completions // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=113544 // if (!autocloseBrackets() && replacement.endsWith("}")) //$NON-NLS-1$ // return replacement.substring(0, replacement.length() - 1); return replacement; }
@Override protected IContextInformation computeContextInformation() { // no context information for METHOD_NAME_REF proposals (e.g. for static imports) // https://bugs.eclipse.org/bugs/show_bug.cgi?id=94654 if ((fProposal.getKind() == CompletionProposal.METHOD_REF || fProposal.getKind() == CompletionProposal.CONSTRUCTOR_INVOCATION) && hasParameters() && (getReplacementString().endsWith(RPAREN) || getReplacementString().endsWith(SEMICOLON) || getReplacementString().length() == 0)) { ProposalContextInformation contextInformation= new ProposalContextInformation(fProposal); if (fContextInformationPosition != 0 && fProposal.getCompletion().length == 0) contextInformation.setContextInformationPosition(fContextInformationPosition); return contextInformation; } return super.computeContextInformation(); }
protected int computeRelevance() { /* * There are two histories: the RHS history remembers types used for the current expected * type (left hand side), while the type history remembers recently used types in general). * * The presence of an RHS ranking is a much more precise sign for relevance as it proves the * subtype relationship between the proposed type and the expected type. * * The "recently used" factor (of either the RHS or general history) is less important, it should * not override other relevance factors such as if the type is already imported etc. */ float rhsHistoryRank= fInvocationContext.getHistoryRelevance(getQualifiedTypeName()); float typeHistoryRank= QualifiedTypeNameHistory.getDefault().getNormalizedPosition(getQualifiedTypeName()); int recencyBoost= Math.round((rhsHistoryRank + typeHistoryRank) * 5); int rhsBoost= rhsHistoryRank > 0.0f ? 50 : 0; int baseRelevance= super.computeRelevance(); return baseRelevance + rhsBoost + recencyBoost; }
private IJavaCompletionProposal createJavadocSimpleProposal(CompletionProposal javadocProposal) { // TODO do better with javadoc proposals // String completion= String.valueOf(proposal.getCompletion()); // int start= proposal.getReplaceStart(); // int length= getLength(proposal); // String label= fLabelProvider.createSimpleLabel(proposal); // Image image= getImage(fLabelProvider.createImageDescriptor(proposal)); // int relevance= computeRelevance(proposal); // // JavaCompletionProposal javaProposal= new JavaCompletionProposal(completion, start, length, image, label, relevance); // if (fJavaProject != null) // javaProposal.setProposalInfo(new FieldProposalInfo(fJavaProject, proposal)); // // javaProposal.setTriggerCharacters(VAR_TRIGGER); // // return javaProposal; LazyJavaCompletionProposal proposal = new LazyJavaCompletionProposal(javadocProposal, getInvocationContext()); // adaptLength(proposal, javadocProposal); return proposal; }
public void apply(IDocument document, char trigger, int offset) { // TODO respect the auto-close preference, but do so consistently with method completions // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=113544 // boolean needsLinkedMode= autocloseBrackets(); boolean needsLinkedMode= true; if (needsLinkedMode) setCursorPosition(getCursorPosition() - 1); // before the closing curly brace super.apply(document, trigger, offset); if (needsLinkedMode) setUpLinkedMode(document, '}'); } }
@Override public final String getSortString() { if (!fSortStringComputed) setSortString(computeSortString()); return super.getSortString(); }
public final Image getImage() { if (!fImageComputed) setImage(computeImage()); return super.getImage(); }
/** * Gets the proposal's relevance. * @return Returns a int */ @Override public final int getRelevance() { if (!fRelevanceComputed) setRelevance(computeRelevance()); return super.getRelevance(); }
/** * Gets the replacement string. * @return Returns a String */ @Override public final String getReplacementString() { if (!fReplacementStringComputed) setReplacementString(computeReplacementString()); return super.getReplacementString(); }