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

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

Introduction

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

Prototype

int LOCAL_VARIABLE_REF

To view the source code for org.eclipse.jdt.core CompletionProposal LOCAL_VARIABLE_REF.

Click Source Link

Document

Completion is a reference to a local variable.

Usage

From source file:com.google.gwt.eclipse.core.uibinder.contentassist.computers.ProposalGeneratingCompletionRequestor.java

License:Open Source License

private void ignoreAll() {
    int[] ignoredKinds = new int[] { CompletionProposal.ANONYMOUS_CLASS_DECLARATION,
            CompletionProposal.FIELD_REF, CompletionProposal.KEYWORD, CompletionProposal.LABEL_REF,
            CompletionProposal.LOCAL_VARIABLE_REF, CompletionProposal.METHOD_REF,
            CompletionProposal.METHOD_DECLARATION, CompletionProposal.PACKAGE_REF, CompletionProposal.TYPE_REF,
            CompletionProposal.VARIABLE_DECLARATION, CompletionProposal.POTENTIAL_METHOD_DECLARATION,
            CompletionProposal.METHOD_NAME_REFERENCE, CompletionProposal.ANNOTATION_ATTRIBUTE_REF,
            CompletionProposal.JAVADOC_FIELD_REF, CompletionProposal.JAVADOC_METHOD_REF,
            CompletionProposal.JAVADOC_TYPE_REF, CompletionProposal.JAVADOC_VALUE_REF,
            CompletionProposal.JAVADOC_PARAM_REF, CompletionProposal.JAVADOC_BLOCK_TAG,
            CompletionProposal.JAVADOC_INLINE_TAG, CompletionProposal.FIELD_IMPORT,
            CompletionProposal.METHOD_IMPORT, CompletionProposal.TYPE_IMPORT };

    for (int kind : ignoredKinds) {
        setIgnored(kind, true);/*  w  w  w .  j av  a2s  . co  m*/
    }
}

From source file:org.codehaus.groovy.eclipse.codeassist.processors.LocalVariableCompletionProcessor.java

License:Apache License

/**
 * @param offset//from   ww  w  .jav a2 s.  c  om
 * @param replaceLength
 * @param context
 * @param proposals
 * @param nameType
 */
private ICompletionProposal createProposal(String replaceName, ClassNode type) {
    CompletionProposal proposal = CompletionProposal.create(CompletionProposal.LOCAL_VARIABLE_REF, offset);
    proposal.setCompletion(replaceName.toCharArray());
    proposal.setReplaceRange(offset - replaceLength, getContext().completionEnd);
    proposal.setSignature(ProposalUtils.createTypeSignature(type));

    proposal.setRelevance(Relevance.HIGH.getRelavance());
    LazyJavaCompletionProposal completion = new LazyJavaCompletionProposal(proposal, javaContext);
    completion.setRelevance(proposal.getRelevance());
    return completion;
}

From source file:org.eclim.plugin.jdt.command.complete.CodeCompleteCommand.java

License:Open Source License

/**
 * Create a CodeCompleteResult from the supplied CompletionProposal.
 *
 * @param proposal The proposal./*w  w  w .  j av  a2  s  . c  o m*/
 *
 * @return The result.
 */
protected CodeCompleteResult createCompletionResult(IJavaCompletionProposal proposal) throws Exception {
    String completion = null;
    String menu = proposal.getDisplayString();

    int kind = -1;
    if (proposal instanceof JavaCompletionProposal) {
        JavaCompletionProposal lazy = (JavaCompletionProposal) proposal;
        completion = lazy.getReplacementString();
    } else if (proposal instanceof LazyJavaCompletionProposal) {
        LazyJavaCompletionProposal lazy = (LazyJavaCompletionProposal) proposal;
        completion = lazy.getReplacementString();
        Method getProposal = LazyJavaCompletionProposal.class.getDeclaredMethod("getProposal");
        getProposal.setAccessible(true);
        CompletionProposal cproposal = (CompletionProposal) getProposal.invoke(lazy);
        if (cproposal != null) {
            kind = cproposal.getKind();
        }
    }

    switch (kind) {
    case CompletionProposal.METHOD_REF:
        int length = completion.length();
        if (length == 0) {
            break;
        }
        if (completion.charAt(length - 1) == ';') {
            completion = completion.substring(0, length - 1);
            length--;
        }
        // trim off the trailing paren if the method takes any arguments.
        // Note: using indexOf instead of lastIndexOf to account for groovy
        // completion menu text.
        if (menu.indexOf(')') > menu.indexOf('(') + 1 && completion.charAt(length - 1) == ')') {
            completion = completion.substring(0, completion.lastIndexOf('(') + 1);
        }
        break;
    case CompletionProposal.TYPE_REF:
        // trim off package info.
        int idx = completion.lastIndexOf('.');
        if (idx != -1) {
            completion = completion.substring(idx + 1);
        }
        break;
    }

    if ("class".equals(completion)) {
        kind = CompletionProposal.KEYWORD;
    }

    String type = "";
    switch (kind) {
    case CompletionProposal.TYPE_REF:
        type = CodeCompleteResult.TYPE;
        break;
    case CompletionProposal.FIELD_REF:
    case CompletionProposal.LOCAL_VARIABLE_REF:
        type = CodeCompleteResult.VARIABLE;
        type = CodeCompleteResult.VARIABLE;
        break;
    case CompletionProposal.METHOD_REF:
        type = CodeCompleteResult.FUNCTION;
        break;
    case CompletionProposal.KEYWORD:
        type = CodeCompleteResult.KEYWORD;
        break;
    }

    // TODO:
    // hopefully Bram will take my advice to add lazy retrieval of
    // completion 'info' so that I can provide this text without the
    // overhead involved with retrieving it for every completion regardless
    // of whether the user ever views it.
    /*return new CodeCompleteResult(
        kind, completion, menu, proposal.getAdditionalProposalInfo());*/
    return new CodeCompleteResult(completion, menu, menu, type);
}

From source file:org.eclim.plugin.jdt.command.complete.CodeCompleteFilter.java

License:Open Source License

/**
 * Converts the result type into the vim 'kind' equivalent string.
 *
 * @param result The completion result./*ww  w .  j a va2  s.co m*/
 * @return The type string.
 */
private String getTypeString(CodeCompleteResult result) {
    switch (result.getType()) {
    case CompletionProposal.TYPE_REF:
        return "c|";
    case CompletionProposal.FIELD_REF:
        return "v|";
    case CompletionProposal.LOCAL_VARIABLE_REF:
        return "v|";
    case CompletionProposal.METHOD_REF:
        return "f|";
    default:
        return "|";
    }
}

From source file:org.eclim.plugin.jdt.command.complete.CompletionProposalCollector.java

License:Open Source License

public void accept(CompletionProposal proposal) {
    try {//from w w w .  ja  v a2 s.  co m
        if (isFiltered(proposal)) {
            return;
        }

        if (proposal.getKind() != CompletionProposal.POTENTIAL_METHOD_DECLARATION) {
            switch (proposal.getKind()) {
            case CompletionProposal.KEYWORD:
            case CompletionProposal.PACKAGE_REF:
            case CompletionProposal.TYPE_REF:
            case CompletionProposal.FIELD_REF:
            case CompletionProposal.METHOD_REF:
            case CompletionProposal.METHOD_NAME_REFERENCE:
            case CompletionProposal.METHOD_DECLARATION:
            case CompletionProposal.ANONYMOUS_CLASS_DECLARATION:
            case CompletionProposal.LABEL_REF:
            case CompletionProposal.LOCAL_VARIABLE_REF:
            case CompletionProposal.VARIABLE_DECLARATION:
            case CompletionProposal.ANNOTATION_ATTRIBUTE_REF:
            case CompletionProposal.POTENTIAL_METHOD_DECLARATION:
                proposals.add(proposal);
                super.accept(proposal);
                break;
            default:
                // do nothing
            }
        }
    } catch (IllegalArgumentException e) {
        // all signature processing method may throw IAEs
        // https://bugs.eclipse.org/bugs/show_bug.cgi?id=84657
        // don't abort, but log and show all the valid proposals
        JavaPlugin.log(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK,
                "Exception when processing proposal for: " + String.valueOf(proposal.getCompletion()), e));
    }
}

From source file:org.eclipse.ajdt.internal.core.contentassist.ProposalRequestorWrapper.java

License:Open Source License

protected boolean shouldAccept(CompletionProposal proposal) {
    if (proposal.getKind() == CompletionProposal.FIELD_REF
            || proposal.getKind() == CompletionProposal.METHOD_REF) {

        if (world == null) {
            world = new AJWorldFacade(unit.getJavaProject().getProject());
        }/*from  ww w . j  ava 2 s.  c  o m*/

        ITDInfo info = world.findITDInfoFromTargetType(proposal.getDeclarationSignature(), proposal.getName());
        if (info != null) {
            if (info.accessibility == Accessibility.PUBLIC) {
                // accessible everywhere
                return true;
            } else if (info.accessibility == Accessibility.PACKAGE) {
                // accessible only in package of declaring aspect
                if (((IPackageFragment) unit.getParent()).getElementName().equals(info.packageDeclaredIn)) {
                    int oldFlags = proposal.getFlags();
                    oldFlags |= Flags.AccDefault;
                    oldFlags &= ~Flags.AccPublic;
                    proposal.setFlags(oldFlags);
                    return true;
                }
            } else if (info.accessibility == Accessibility.PRIVATE) {
                // accessible only in declaring aspect's compilation unit
                if (unit.getElementName().startsWith(info.topLevelAspectName + ".")
                        && ((IPackageFragment) unit.getParent()).getElementName()
                                .equals(info.packageDeclaredIn)) {

                    int oldFlags = proposal.getFlags();
                    oldFlags |= Flags.AccPrivate;
                    oldFlags &= ~Flags.AccPublic;
                    proposal.setFlags(oldFlags);
                    return true;
                }

            }
            return false;
        } else {
            // not an ITD
            return true;
        }
    } else if (proposal.getKind() == CompletionProposal.LOCAL_VARIABLE_REF) {
        // check to see if this is the proposal that has been added by the context switch for ITDs
        if (contextSwitchIgnore(proposal)) {
            return false;
        }
    } else if (proposal.getKind() == CompletionProposal.TYPE_REF) {
        // check to see if this is an ITIT type that should not be see
        char[] typeName = (char[]) ReflectionUtils.getPrivateField(InternalCompletionProposal.class, "typeName",
                (InternalCompletionProposal) proposal);
        if (typeName != null && CharOperation.contains('$', typeName)) {
            return false;
        }
    }
    return true;
}

From source file:org.eclipse.flux.jdt.services.CompletionProposalDescriptionProvider.java

License:Open Source License

/**
 * Creates a display label with styles for a given <code>CompletionProposal</code>.
 *
 * @param proposal the completion proposal to create the display label for
 * @return the display label for <code>proposal</code>
 *
 * @since 3.4/*w  ww .j  a va  2s  .  c  o  m*/
 */
public StringBuilder createDescription(CompletionProposal proposal) {
    switch (proposal.getKind()) {
    case CompletionProposal.METHOD_NAME_REFERENCE:
    case CompletionProposal.METHOD_REF:
    case CompletionProposal.CONSTRUCTOR_INVOCATION:
    case CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER:
    case CompletionProposal.POTENTIAL_METHOD_DECLARATION:
        if (fContext != null && fContext.isInJavadoc())
            return createJavadocMethodProposalLabel(proposal);
        return createMethodProposalLabel(proposal);
    case CompletionProposal.METHOD_DECLARATION:
        return createOverrideMethodProposalLabel(proposal);
    case CompletionProposal.ANONYMOUS_CLASS_DECLARATION:
    case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION:
        return createAnonymousTypeLabel(proposal);
    case CompletionProposal.TYPE_REF:
        return createTypeProposalLabel(proposal);
    case CompletionProposal.JAVADOC_TYPE_REF:
        return createJavadocTypeProposalLabel(proposal);
    case CompletionProposal.JAVADOC_FIELD_REF:
    case CompletionProposal.JAVADOC_VALUE_REF:
    case CompletionProposal.JAVADOC_BLOCK_TAG:
    case CompletionProposal.JAVADOC_INLINE_TAG:
    case CompletionProposal.JAVADOC_PARAM_REF:
        return createJavadocSimpleProposalLabel(proposal);
    case CompletionProposal.JAVADOC_METHOD_REF:
        return createJavadocMethodProposalLabel(proposal);
    case CompletionProposal.PACKAGE_REF:
        return createPackageProposalLabel(proposal);
    case CompletionProposal.ANNOTATION_ATTRIBUTE_REF:
    case CompletionProposal.FIELD_REF:
    case CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER:
        return createLabelWithTypeAndDeclaration(proposal);
    case CompletionProposal.LOCAL_VARIABLE_REF:
    case CompletionProposal.VARIABLE_DECLARATION:
        return createSimpleLabelWithType(proposal);
    case CompletionProposal.KEYWORD:
    case CompletionProposal.LABEL_REF:
        return createSimpleLabel(proposal);
    default:
        Assert.isTrue(false);
        return null;
    }
}

From source file:org.eclipse.objectteams.otdt.tests.model.CompletionTestsRequestor2.java

License:Open Source License

protected StringBuffer printProposal(CompletionProposal proposal, int tab, StringBuffer buffer) {
    for (int i = 0; i < tab; i++) {
        buffer.append("   "); //$NON-NLS-1$
    }/* w ww.  j a va 2 s .  c  om*/
    buffer.append(getElementName(proposal));
    buffer.append('[');
    switch (proposal.getKind()) {
    case CompletionProposal.ANONYMOUS_CLASS_DECLARATION:
        buffer.append("ANONYMOUS_CLASS_DECLARATION"); //$NON-NLS-1$
        break;
    case CompletionProposal.FIELD_REF:
        buffer.append("FIELD_REF"); //$NON-NLS-1$
        break;
    case CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER:
        buffer.append("FIELD_REF_WITH_CASTED_RECEIVER"); //$NON-NLS-1$
        break;
    case CompletionProposal.KEYWORD:
        buffer.append("KEYWORD"); //$NON-NLS-1$
        break;
    case CompletionProposal.LABEL_REF:
        buffer.append("LABEL_REF"); //$NON-NLS-1$
        break;
    case CompletionProposal.LOCAL_VARIABLE_REF:
        buffer.append("LOCAL_VARIABLE_REF"); //$NON-NLS-1$
        break;
    case CompletionProposal.METHOD_DECLARATION:
        buffer.append("METHOD_DECLARATION"); //$NON-NLS-1$
        if (proposal.isConstructor()) {
            buffer.append("<CONSTRUCTOR>"); //$NON-NLS-1$
        }
        break;
    case CompletionProposal.METHOD_REF:
        buffer.append("METHOD_REF"); //$NON-NLS-1$
        if (proposal.isConstructor()) {
            buffer.append("<CONSTRUCTOR>"); //$NON-NLS-1$
        }
        break;
    case CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER:
        buffer.append("METHOD_REF_WITH_CASTED_RECEIVER"); //$NON-NLS-1$
        if (proposal.isConstructor()) {
            buffer.append("<CONSTRUCTOR>"); //$NON-NLS-1$
        }
        break;
    case CompletionProposal.PACKAGE_REF:
        buffer.append("PACKAGE_REF"); //$NON-NLS-1$
        break;
    case CompletionProposal.TYPE_REF:
        buffer.append("TYPE_REF"); //$NON-NLS-1$
        break;
    case CompletionProposal.VARIABLE_DECLARATION:
        buffer.append("VARIABLE_DECLARATION"); //$NON-NLS-1$
        break;
    case CompletionProposal.POTENTIAL_METHOD_DECLARATION:
        buffer.append("POTENTIAL_METHOD_DECLARATION"); //$NON-NLS-1$
        break;
    case CompletionProposal.METHOD_NAME_REFERENCE:
        //{ObjectTeams: original "METHOD_IMPORT" is now misleading (used for rhs short method spec, too)            
        buffer.append("METHOD_NAME_REF"); //$NON-NLS-1$
        // SH}            
        break;
    //{ObjectTeams: new kinds:            
    case CompletionProposal.OT_METHOD_SPEC:
        buffer.append("METHOD_SPEC"); //$NON-NLS-1$
        break;
    case CompletionProposal.OT_FIELD_SPEC:
        buffer.append("FIELD_SPEC"); //$NON-NLS-1$
        break;
    case CompletionProposal.OT_CALLOUT_GET:
        buffer.append("CALLOUT_GET"); //$NON-NLS-1$
        break;
    case CompletionProposal.OT_CALLOUT_SET:
        buffer.append("CALLOUT_SET"); //$NON-NLS-1$
        break;
    case CompletionProposal.OT_CALLOUT_DECLARATION:
        buffer.append("CALLOUT_DECLARATION"); //$NON-NLS-1$
        break;
    case CompletionProposal.OT_CALLOUT_OVERRIDE_DECLARATION:
        buffer.append("CALLOUT_OVERRIDE_DECLARATION"); //$NON-NLS-1$
        break;
    case CompletionProposal.OT_CALLIN_DECLARATION:
        buffer.append("CALLIN_DECLARATION"); //$NON-NLS-1$
        break;
    // SH}
    case CompletionProposal.ANNOTATION_ATTRIBUTE_REF:
        buffer.append("ANNOTATION_ATTRIBUTE_REF"); //$NON-NLS-1$
        break;
    case CompletionProposal.JAVADOC_BLOCK_TAG:
        buffer.append("JAVADOC_BLOCK_TAG"); //$NON-NLS-1$
        break;
    case CompletionProposal.JAVADOC_INLINE_TAG:
        buffer.append("JAVADOC_INLINE_TAG"); //$NON-NLS-1$
        break;
    case CompletionProposal.JAVADOC_FIELD_REF:
        buffer.append("JAVADOC_FIELD_REF"); //$NON-NLS-1$
        break;
    case CompletionProposal.JAVADOC_METHOD_REF:
        buffer.append("JAVADOC_METHOD_REF"); //$NON-NLS-1$
        break;
    case CompletionProposal.JAVADOC_TYPE_REF:
        buffer.append("JAVADOC_TYPE_REF"); //$NON-NLS-1$
        break;
    case CompletionProposal.JAVADOC_PARAM_REF:
        buffer.append("JAVADOC_PARAM_REF"); //$NON-NLS-1$
        break;
    case CompletionProposal.JAVADOC_VALUE_REF:
        buffer.append("JAVADOC_VALUE_REF"); //$NON-NLS-1$
        break;
    case CompletionProposal.FIELD_IMPORT:
        buffer.append("FIELD_IMPORT"); //$NON-NLS-1$
        break;
    case CompletionProposal.METHOD_IMPORT:
        buffer.append("METHOD_IMPORT"); //$NON-NLS-1$
        break;
    case CompletionProposal.TYPE_IMPORT:
        buffer.append("TYPE_IMPORT"); //$NON-NLS-1$
        break;
    default:
        buffer.append("PROPOSAL"); //$NON-NLS-1$
        break;

    }
    buffer.append("]{");
    buffer.append(proposal.getCompletion() == null ? NULL_LITERAL : proposal.getCompletion());
    buffer.append(", ");
    buffer.append(
            proposal.getDeclarationSignature() == null ? NULL_LITERAL : proposal.getDeclarationSignature());
    buffer.append(", ");
    buffer.append(proposal.getSignature() == null ? NULL_LITERAL : proposal.getSignature());

    char[] receiverSignature = proposal.getReceiverSignature();
    if (receiverSignature != null) {
        buffer.append(", ");
        buffer.append(receiverSignature);
    }

    if (this.showUniqueKeys) {
        buffer.append(", ");
        buffer.append(proposal.getDeclarationKey() == null ? NULL_LITERAL : proposal.getDeclarationKey());
        buffer.append(", ");
        buffer.append(proposal.getKey() == null ? NULL_LITERAL : proposal.getKey());
    }
    buffer.append(", ");
    buffer.append(proposal.getName() == null ? NULL_LITERAL : proposal.getName());
    if (this.showParameterNames) {
        char[][] parameterNames = proposal.findParameterNames(null);
        buffer.append(", ");
        if (parameterNames == null || parameterNames.length <= 0) {
            buffer.append(NULL_LITERAL);
        } else {
            buffer.append("(");
            for (int i = 0; i < parameterNames.length; i++) {
                if (i > 0)
                    buffer.append(", ");
                buffer.append(parameterNames[i]);
            }
            buffer.append(")");
        }
    }

    if (this.showPositions) {
        buffer.append(", ");
        if (this.showTokenPositions || receiverSignature != null)
            buffer.append("replace");
        buffer.append("[");
        buffer.append(proposal.getReplaceStart());
        buffer.append(", ");
        buffer.append(proposal.getReplaceEnd());
        buffer.append("]");
    }
    if (this.showTokenPositions) {
        buffer.append(", token[");
        buffer.append(proposal.getTokenStart());
        buffer.append(", ");
        buffer.append(proposal.getTokenEnd());
        buffer.append("]");
    }
    if (this.showPositions && receiverSignature != null) {
        buffer.append(", receiver[");
        buffer.append(proposal.getReceiverStart());
        buffer.append(", ");
        buffer.append(proposal.getReceiverEnd());
        buffer.append("]");
    }
    buffer.append(", ");
    buffer.append(proposal.getRelevance());
    buffer.append('}');
    if (this.showMissingTypes) {
        CompletionProposal[] requiredProposals = proposal.getRequiredProposals();
        if (requiredProposals != null) {
            int length = requiredProposals.length;
            System.arraycopy(requiredProposals, 0, requiredProposals = new CompletionProposal[length], 0,
                    length);
            quickSort(requiredProposals, 0, length - 1);
            for (int i = 0; i < length; i++) {
                buffer.append('\n');
                printProposal(requiredProposals[i], tab + 1, buffer);
            }
        }
    }
    return buffer;
}

From source file:org.eclipse.objectteams.otdt.tests.model.CompletionTestsRequestor2.java

License:Open Source License

protected String getElementName(CompletionProposal proposal) {
    switch (proposal.getKind()) {
    case CompletionProposal.ANONYMOUS_CLASS_DECLARATION:
        return new String(Signature.getSignatureSimpleName(proposal.getDeclarationSignature()));
    case CompletionProposal.TYPE_REF:
    case CompletionProposal.TYPE_IMPORT:
    case CompletionProposal.JAVADOC_TYPE_REF:
        return new String(Signature.getSignatureSimpleName(proposal.getSignature()));
    case CompletionProposal.FIELD_REF:
    case CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER:
    case CompletionProposal.KEYWORD:
    case CompletionProposal.LABEL_REF:
    case CompletionProposal.LOCAL_VARIABLE_REF:
    case CompletionProposal.METHOD_REF:
    case CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER:
    case CompletionProposal.METHOD_DECLARATION:
    case CompletionProposal.VARIABLE_DECLARATION:
    case CompletionProposal.POTENTIAL_METHOD_DECLARATION:
    case CompletionProposal.METHOD_NAME_REFERENCE:
        //{ObjectTeams: new kinds:
    case CompletionProposal.OT_METHOD_SPEC:
    case CompletionProposal.OT_FIELD_SPEC:
    case CompletionProposal.OT_CALLOUT_GET:
    case CompletionProposal.OT_CALLOUT_SET:
    case CompletionProposal.OT_CALLOUT_DECLARATION:
    case CompletionProposal.OT_CALLOUT_OVERRIDE_DECLARATION:
    case CompletionProposal.OT_CALLIN_DECLARATION:
        // SH}//from   w w  w . j  a va2  s.  c  om
    case CompletionProposal.ANNOTATION_ATTRIBUTE_REF:
    case CompletionProposal.JAVADOC_BLOCK_TAG:
    case CompletionProposal.JAVADOC_INLINE_TAG:
    case CompletionProposal.JAVADOC_FIELD_REF:
    case CompletionProposal.JAVADOC_METHOD_REF:
    case CompletionProposal.JAVADOC_PARAM_REF:
    case CompletionProposal.JAVADOC_VALUE_REF:
    case CompletionProposal.FIELD_IMPORT:
    case CompletionProposal.METHOD_IMPORT:
        return new String(proposal.getName());
    case CompletionProposal.PACKAGE_REF:
        return new String(proposal.getDeclarationSignature());
    }
    return "";
}

From source file:org.eclipse.recommenders.internal.completion.rcp.AccessibleCompletionProposals.java

License:Open Source License

public static AccessibleCompletionProposal newLocalRef(ILocalVariable local, int completionOffset,
        int prefixLength, int relevance) {
    AccessibleCompletionProposal proposal = new AccessibleCompletionProposal(
            CompletionProposal.LOCAL_VARIABLE_REF, completionOffset);
    String typeSignature = local.getTypeSignature();
    String simpleName = Signature.getSignatureSimpleName(typeSignature);
    proposal.setTypeName(simpleName.toCharArray());

    proposal.setSignature(typeSignature.toCharArray());
    // proposal.setPackageName(local.type.qualifiedPackageName());

    proposal.setName(local.getElementName().toCharArray());
    proposal.setCompletion(local.getElementName().toCharArray());
    proposal.setFlags(local.getFlags());
    int replaceStartIndex = completionOffset - prefixLength;
    int replaceEndIndex = completionOffset;
    proposal.setReplaceRange(replaceStartIndex, replaceEndIndex);
    // TODO we may need to respect ui settings here:
    int tokenStartIndex = replaceStartIndex;
    int tokenEndIndex = replaceEndIndex;
    proposal.setTokenRange(tokenStartIndex, tokenEndIndex);
    proposal.setRelevance(relevance);//from w ww.j  av a 2s  .  c  om

    return proposal;
}