Example usage for org.eclipse.jdt.core CompletionProposal getCompletionLocation

List of usage examples for org.eclipse.jdt.core CompletionProposal getCompletionLocation

Introduction

In this page you can find the example usage for org.eclipse.jdt.core CompletionProposal getCompletionLocation.

Prototype


public int getCompletionLocation() 

Source Link

Document

Returns the character index in the source file buffer where source completion was requested (the offset parameter to ICodeAssist.codeComplete minus one).

Usage

From source file:edu.brown.cs.bubbles.bedrock.BedrockUtil.java

License:Open Source License

/********************************************************************************/

static void outputCompletion(CompletionProposal cp, IvyXmlWriter xw) {
    xw.begin("COMPLETION");
    fieldValue(xw, "ACCESSIBILITY", cp.getAccessibility(), accessibility_types);
    if (cp.isConstructor())
        xw.field("CONSTRUCTOR", true);
    xw.field("TEXT", cp.getCompletion());
    xw.field("INDEX", cp.getCompletionLocation());
    xw.field("DECLKEY", cp.getDeclarationKey());
    switch (cp.getKind()) {
    case CompletionProposal.ANNOTATION_ATTRIBUTE_REF:
    case CompletionProposal.ANONYMOUS_CLASS_DECLARATION:
    case CompletionProposal.FIELD_IMPORT:
    case CompletionProposal.FIELD_REF:
    case CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER:
    case CompletionProposal.METHOD_IMPORT:
    case CompletionProposal.METHOD_REF:
    case CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER:
    case CompletionProposal.METHOD_DECLARATION:
    case CompletionProposal.POTENTIAL_METHOD_DECLARATION:
        xw.field("DECLSIGN", cp.getDeclarationSignature());
        break;//from  www .  j a v a  2 s  .  c  om
    case CompletionProposal.PACKAGE_REF:
    case CompletionProposal.TYPE_IMPORT:
    case CompletionProposal.TYPE_REF:
        xw.field("DOTNAME", cp.getDeclarationSignature());
        break;
    }
    fieldFlags(xw, "ACCESS", cp.getFlags(), access_flags);
    xw.field("FLAGS", cp.getFlags());
    xw.field("KEY", cp.getKey());
    xw.field("NAME", cp.getName());
    xw.field("RELEVANCE", cp.getRelevance());
    xw.field("REPLACE_START", cp.getReplaceStart());
    xw.field("REPLACE_END", cp.getReplaceEnd());
    xw.field("SIGNATURE", cp.getSignature());
    xw.field("TOKEN_START", cp.getTokenStart());
    xw.field("TOKEN_END", cp.getTokenEnd());
    fieldValue(xw, "KIND", cp.getKind(), completion_types);
    if (cp instanceof ICompletionProposalExtension4) {
        ICompletionProposalExtension4 icp4 = (ICompletionProposalExtension4) cp;
        xw.field("AUTO", icp4.isAutoInsertable());
    }

    if (CompletionFlags.isStaticImport(cp.getAdditionalFlags()))
        xw.field("STATICIMPORT", true);

    if (cp.getKind() == CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER
            || cp.getKind() == CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER) {
        xw.field("RECEIVER_SIGN", cp.getReceiverSignature());
        xw.field("RECEIVER_START", cp.getReceiverStart());
        xw.field("RECEIVER_END", cp.getReceiverEnd());
    }
    xw.field("RCVR", cp.getReceiverSignature());

    xw.cdataElement("DESCRIPTION", cp.toString());

    CompletionProposal[] rq = cp.getRequiredProposals();
    if (rq != null) {
        xw.begin("REQUIRED");
        for (CompletionProposal xcp : rq)
            outputCompletion(xcp, xw);
        xw.end("REQUIRED");
    }

    xw.end("COMPLETION");
}

From source file:org.nuxeo.ide.connect.completion.StudioArgumentProposalCollector.java

License:Open Source License

/**
 * only for debug//from   w w w .  j  av  a  2  s .com
 * 
 * @param proposal
 */
protected void printContext(CompletionProposal proposal) {
    if (proposal == null || proposal.getName() == null) {
        return;
    }
    try {
        System.out.println("------------");
        System.out.println("Name: " + new String(proposal.getName()));
        System.out.println("Proposal Kind: " + proposal.getKind());
        System.out.println("Offset: " + ctx.getInvocationOffset());
        System.out.println("Suggested completion: " + new String(proposal.getCompletion()) + " at "
                + proposal.getCompletionLocation());
        System.out.println("Signature: " + new String(proposal.getSignature()));
        System.out.println("Token Range: " + proposal.getTokenStart() + ", " + proposal.getTokenEnd());
        System.out.println("Replace Range: " + proposal.getReplaceStart() + ", " + proposal.getReplaceEnd());
        System.out.println("Context Token: " + new String(ctx.getCoreContext().getToken()));
        System.out.println("Context Token Location: " + ctx.getCoreContext().getTokenLocation());
        System.out.println("Context Token Kind : " + ctx.getCoreContext().getTokenKind());
        System.out.println("Partition: " + ctx.getDocument().getPartition(ctx.getInvocationOffset()));
        System.out.println("ident: " + ctx.computeIdentifierPrefix());
        System.out.println("------------");
    } catch (Exception e) {
        UI.showError("Error while compiling studio proposal", e);
    }
}