Java Code Examples for org.eclipse.jdt.core.CompletionProposal#setSignature()

The following examples show how to use org.eclipse.jdt.core.CompletionProposal#setSignature() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JavaTypeCompletionProposalComputer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private IJavaCompletionProposal createTypeProposal(int relevance, String fullyQualifiedType, JavaContentAssistInvocationContext context) throws JavaModelException {
	IType type= context.getCompilationUnit().getJavaProject().findType(fullyQualifiedType);
	if (type == null)
		return null;

	CompletionProposal proposal= CompletionProposal.create(CompletionProposal.TYPE_REF, context.getInvocationOffset());
	proposal.setCompletion(fullyQualifiedType.toCharArray());
	proposal.setDeclarationSignature(type.getPackageFragment().getElementName().toCharArray());
	proposal.setFlags(type.getFlags());
	proposal.setRelevance(relevance);
	proposal.setReplaceRange(context.getInvocationOffset(), context.getInvocationOffset());
	proposal.setSignature(Signature.createTypeSignature(fullyQualifiedType, true).toCharArray());

	if (shouldProposeGenerics(context.getProject()))
		return new LazyGenericTypeProposal(proposal, context);
	else
		return new LazyJavaTypeCompletionProposal(proposal, context);
}
 
Example 2
Source File: JavaElementToken.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public IImageHandle getImage() {
    if (this.image != null) {
        return this.image;
    }
    CompletionProposalLabelProvider provider = new CompletionProposalLabelProvider();
    CompletionProposal generatedProposal = CompletionProposal.create(completionProposalKind, 0);
    generatedProposal.setFlags(completionProposalFlags);
    if (HAS_ADDITIONAL_FLAGS) {
        generatedProposal.setAdditionalFlags(completionProposalAdditionalFlags);
    }
    generatedProposal.setDeclarationSignature(completionPropsoalSignature);
    generatedProposal.setSignature(completionPropsoalSignature);

    //uses: kind, flags, signature to create an image.
    ImageDescriptor descriptor = provider.createImageDescriptor(generatedProposal);
    Image computed = descriptor.createImage();
    return new IImageHandle() {

        @Override
        public Object getImageData() {
            return computed.getImageData();
        }

        @Override
        public Object getImage() {
            return computed;
        }
    };
}