Example usage for org.eclipse.jdt.core CompletionFlags Default

List of usage examples for org.eclipse.jdt.core CompletionFlags Default

Introduction

In this page you can find the example usage for org.eclipse.jdt.core CompletionFlags Default.

Prototype

int Default

To view the source code for org.eclipse.jdt.core CompletionFlags Default.

Click Source Link

Document

Constant representing the absence of any flag

Usage

From source file:org.codehaus.groovy.eclipse.codeassist.proposals.GroovyMethodProposal.java

License:Apache License

public IJavaCompletionProposal createJavaProposal(ContentAssistContext context,
        JavaContentAssistInvocationContext javaContext) {

    GroovyCompletionProposal proposal = new GroovyCompletionProposal(CompletionProposal.METHOD_REF,
            context.completionLocation);

    if (context.location == ContentAssistLocation.METHOD_CONTEXT) {
        // only show context information and only for methods
        // that exactly match the name. This happens when we are at the
        // start/* w w  w  .  ja  v  a2 s.  c  o  m*/
        // of an argument or an open paren
        MethodInfoContentAssistContext methodContext = (MethodInfoContentAssistContext) context;
        if (!methodContext.methodName.equals(method.getName())) {
            return null;
        }
        proposal.setReplaceRange(context.completionLocation, context.completionLocation);
        proposal.setCompletion(CharOperation.NO_CHAR);
    } else {
        // otherwise this is a normal method proposal
        proposal.setCompletion(completionName(!isParens(context, javaContext)));
        proposal.setReplaceRange(context.completionLocation - context.completionExpression.length(),
                context.completionEnd);
    }
    proposal.setDeclarationSignature(ProposalUtils.createTypeSignature(method.getDeclaringClass()));
    proposal.setName(method.getName().toCharArray());
    if (method instanceof NamedArgsMethodNode) {
        fillInExtraParameters((NamedArgsMethodNode) method, proposal);
    } else {
        proposal.setParameterNames(createAllParameterNames(context.unit));
        proposal.setParameterTypeNames(getParameterTypeNames(method.getParameters()));
    }
    proposal.setFlags(getModifiers());
    proposal.setAdditionalFlags(CompletionFlags.Default);
    char[] methodSignature = createMethodSignature();
    proposal.setKey(methodSignature);
    proposal.setSignature(methodSignature);
    proposal.setRelevance(computeRelevance());

    LazyJavaCompletionProposal lazyProposal = null;
    ProposalFormattingOptions groovyProposalOptions = getGroovyProposalOptions();
    if (groovyProposalOptions.doParameterGuessing) {
        lazyProposal = GroovyJavaGuessingCompletionProposal.createProposal(proposal, javaContext, true,
                contributor, groovyProposalOptions);
    }
    if (lazyProposal == null) {
        lazyProposal = new GroovyJavaMethodCompletionProposal(proposal, javaContext, groovyProposalOptions,
                contributor);
        // if location is METHOD_CONTEXT, then the type must be
        // MethodInfoContentAssistContext,
        // but there are other times when the type is
        // MethodInfoContentAssistContext as well.
        if (context.location == ContentAssistLocation.METHOD_CONTEXT) {
            ((GroovyJavaMethodCompletionProposal) lazyProposal).contextOnly();
        }
    }

    if (context.location == ContentAssistLocation.METHOD_CONTEXT) {
        // attempt to find the location immediately after the opening
        // paren.
        // if this is wrong, no big deal, but the context information
        // will not be properly
        // highlighted.
        // Assume that there is the method name, and then an opening
        // paren (or a space) and then
        // the arguments (hence the +2).
        lazyProposal
                .setContextInformationPosition(((MethodInfoContentAssistContext) context).methodNameEnd + 1);
    }
    return lazyProposal;

}