protected final boolean isImportCompletion() { char[] completion= fProposal.getCompletion(); if (completion.length == 0) return false; char last= completion[completion.length - 1]; /* * Proposals end in a semicolon when completing types in normal imports or when completing * static members, in a period when completing types in static imports. */ return last == ';' || last == '.'; }
private boolean isImportCompletion(CompletionProposal proposal) { char[] completion = proposal.getCompletion(); if (completion.length == 0) { return false; } char last = completion[completion.length - 1]; /* * Proposals end in a semicolon when completing types in normal imports * or when completing static members, in a period when completing types * in static imports. */ return last == SEMICOLON || last == '.'; }
protected final boolean isImportCompletion() { char[] completion= fProposal.getCompletion(); if (completion.length == 0) return false; char last= completion[completion.length - 1]; /* * Proposals end in a semicolon when completing types in normal imports or when completing * static members, in a period when completing types in static imports. */ return last == ';' || last == '.'; }
StringBuilder createSimpleLabel(CompletionProposal proposal) { StringBuilder buf= new StringBuilder(); buf.append(String.valueOf(proposal.getCompletion())); return buf; }
private void createSimpleLabelWithType(CompletionProposal proposal, CompletionItem item) { StringBuilder nameBuffer= new StringBuilder(); nameBuffer.append(proposal.getCompletion()); item.setInsertText(nameBuffer.toString()); char[] typeName= Signature.getSignatureSimpleName(proposal.getSignature()); if (typeName.length > 0) { nameBuffer.append(VAR_TYPE_SEPARATOR); nameBuffer.append(typeName); } item.setLabel(nameBuffer.toString()); }
protected boolean hasArgumentList(CompletionProposal proposal) { if (CompletionProposal.METHOD_NAME_REFERENCE == proposal.getKind()) { return false; } char[] completion= proposal.getCompletion(); return !isInJavadoc() && completion.length > 0 && completion[completion.length - 1] == RPAREN; }
private IJavaCompletionProposal createKeywordProposal(CompletionProposal proposal) { String completion= String.valueOf(proposal.getCompletion()); int start= proposal.getReplaceStart(); int length= getLength(proposal); String label= fLabelProvider.createSimpleLabel(proposal); int relevance= computeRelevance(proposal); return new JavaCompletionProposal(completion, start, length, null, label, relevance); }
@Override public void accept(CompletionProposal proposal) { if (!isIgnored(proposal.getKind())) { if (proposal.getKind() == CompletionProposal.PACKAGE_REF && unit.getParent() != null && String.valueOf(proposal.getCompletion()).equals(unit.getParent().getElementName())) { // Hacky way to boost relevance of current package, for package completions, until // https://bugs.eclipse.org/518140 is fixed proposal.setRelevance(proposal.getRelevance() + 1); } proposals.add(proposal); } }
private IJavaCompletionProposal createKeywordProposal(CompletionProposal proposal) { String completion= String.valueOf(proposal.getCompletion()); int start= proposal.getReplaceStart(); int length= getLength(proposal); StyledString label= fLabelProvider.createSimpleLabel(proposal); int relevance= computeRelevance(proposal); return new JavaCompletionProposal(completion, start, length, null, label, relevance); }
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 && hasParameters() && (getReplacementString().endsWith(RPAREN) || getReplacementString().length() == 0)) { ProposalContextInformation contextInformation= new ProposalContextInformation(fProposal); if (fContextInformationPosition != 0 && fProposal.getCompletion().length == 0) contextInformation.setContextInformationPosition(fContextInformationPosition); return contextInformation; } return super.computeContextInformation(); }
@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(); }
public ProcessableAnonymousTypeCompletionProposal(CompletionProposal coreProposal, JavaCompletionProposal uiProposal, JavaContentAssistInvocationContext context) throws JavaModelException { super(context.getProject(), context.getCompilationUnit(), context, coreProposal.getReplaceStart(), uiProposal .getReplacementLength(), String.valueOf(coreProposal.getCompletion()), uiProposal .getStyledDisplayString(), String.valueOf(coreProposal.getDeclarationSignature()), (IType) context .getProject().findElement(String.valueOf(coreProposal.getDeclarationKey()), null), uiProposal .getRelevance()); this.coreProposal = coreProposal; }
@Override protected IContextInformation computeContextInformation() { char[] signature= fProposal.getSignature(); char[][] typeParameters= Signature.getTypeArguments(signature); if (typeParameters.length == 0) return super.computeContextInformation(); ProposalContextInformation contextInformation= new ProposalContextInformation(fProposal); if (fContextInformationPosition != 0 && fProposal.getCompletion().length == 0) contextInformation.setContextInformationPosition(fContextInformationPosition); return contextInformation; } }
private IJavaCompletionProposal createAnnotationAttributeReferenceProposal(CompletionProposal proposal) { String displayString= fLabelProvider.createLabelWithTypeAndDeclaration(proposal); ImageDescriptor descriptor= fLabelProvider.createMethodImageDescriptor(proposal); String completion= String.valueOf(proposal.getCompletion()); return new JavaCompletionProposal(completion, proposal.getReplaceStart(), getLength(proposal), getImage(descriptor), displayString, computeRelevance(proposal)); }
private IJavaCompletionProposal createPackageProposal(CompletionProposal proposal) { String completion= String.valueOf(proposal.getCompletion()); int start= proposal.getReplaceStart(); int length= getLength(proposal); String label= fLabelProvider.createSimpleLabel(proposal); Image image= getImage(fLabelProvider.createPackageImageDescriptor(proposal)); int relevance= computeRelevance(proposal); return new JavaCompletionProposal(completion, start, length, image, label, relevance); }
@Override protected IContextInformation computeContextInformation() { char[] signature= fProposal.getSignature(); char[][] typeParameters= Signature.getTypeArguments(signature); if (typeParameters.length == 0) return super.computeContextInformation(); ProposalContextInformation contextInformation= new ProposalContextInformation(fProposal); if (fContextInformationPosition != 0 && fProposal.getCompletion().length == 0) contextInformation.setContextInformationPosition(fContextInformationPosition); return contextInformation; } }
private IJavaCompletionProposal createLocalVariableProposal(CompletionProposal proposal) { String completion= String.valueOf(proposal.getCompletion()); int start= proposal.getReplaceStart(); int length= getLength(proposal); Image image= getImage(fLabelProvider.createLocalImageDescriptor(proposal)); String label= fLabelProvider.createSimpleLabelWithType(proposal); int relevance= computeRelevance(proposal); final JavaCompletionProposal javaProposal= new JavaCompletionProposal(completion, start, length, image, label, relevance); javaProposal.setTriggerCharacters(VAR_TRIGGER); return javaProposal; }
private IJavaCompletionProposal createLocalVariableProposal(CompletionProposal proposal) { String completion= String.valueOf(proposal.getCompletion()); int start= proposal.getReplaceStart(); int length= getLength(proposal); Image image= getImage(fLabelProvider.createLocalImageDescriptor(proposal)); StyledString label= fLabelProvider.createSimpleLabelWithType(proposal); int relevance= computeRelevance(proposal); final JavaCompletionProposal javaProposal= new JavaCompletionProposal(completion, start, length, image, label, relevance); javaProposal.setTriggerCharacters(VAR_TRIGGER); return javaProposal; }
private IJavaCompletionProposal createAnnotationAttributeReferenceProposal(CompletionProposal proposal) { StyledString displayString= fLabelProvider.createLabelWithTypeAndDeclaration(proposal); ImageDescriptor descriptor= fLabelProvider.createMethodImageDescriptor(proposal); String completion= String.valueOf(proposal.getCompletion()); JavaCompletionProposal javaProposal= new JavaCompletionProposal(completion, proposal.getReplaceStart(), getLength(proposal), getImage(descriptor), displayString, computeRelevance(proposal)); if (fJavaProject != null) javaProposal.setProposalInfo(new AnnotationAtttributeProposalInfo(fJavaProject, proposal)); return javaProposal; }
StyledString createSimpleLabelWithType(CompletionProposal proposal) { StyledString buf= new StyledString(); buf.append(proposal.getCompletion()); char[] typeName= Signature.getSignatureSimpleName(proposal.getSignature()); if (typeName.length > 0) { buf.append(VAR_TYPE_SEPARATOR); buf.append(typeName); } return Strings.markJavaElementLabelLTR(buf); }