Search in sources :

Example 1 with AnonymousTypeCompletionProposal

use of org.eclipse.jdt.internal.ui.text.java.AnonymousTypeCompletionProposal in project che by eclipse.

the class CompletionProposalCollector method createAnonymousTypeProposal.

private IJavaCompletionProposal createAnonymousTypeProposal(CompletionProposal proposal, JavaContentAssistInvocationContext invocationContext) {
    if (fCompilationUnit == null || fJavaProject == null)
        return null;
    char[] declarationKey = proposal.getDeclarationKey();
    if (declarationKey == null)
        return null;
    try {
        IJavaElement element = fJavaProject.findElement(new String(declarationKey), null);
        if (!(element instanceof IType))
            return null;
        IType type = (IType) element;
        String completion = String.valueOf(proposal.getCompletion());
        int start = proposal.getReplaceStart();
        int length = getLength(proposal);
        int relevance = computeRelevance(proposal);
        StyledString label = fLabelProvider.createAnonymousTypeLabel(proposal);
        JavaCompletionProposal javaProposal = new AnonymousTypeCompletionProposal(fJavaProject, fCompilationUnit, invocationContext, start, length, completion, label, String.valueOf(proposal.getDeclarationSignature()), type, relevance);
        javaProposal.setProposalInfo(new AnonymousTypeProposalInfo(fJavaProject, proposal));
        return javaProposal;
    } catch (JavaModelException e) {
        return null;
    }
}
Also used : IJavaElement(org.eclipse.jdt.core.IJavaElement) JavaModelException(org.eclipse.jdt.core.JavaModelException) AnonymousTypeProposalInfo(org.eclipse.jdt.internal.ui.text.java.AnonymousTypeProposalInfo) StyledString(org.eclipse.jface.viewers.StyledString) StyledString(org.eclipse.jface.viewers.StyledString) AnonymousTypeCompletionProposal(org.eclipse.jdt.internal.ui.text.java.AnonymousTypeCompletionProposal) IType(org.eclipse.jdt.core.IType) JavaCompletionProposal(org.eclipse.jdt.internal.ui.text.java.JavaCompletionProposal) LazyJavaCompletionProposal(org.eclipse.jdt.internal.ui.text.java.LazyJavaCompletionProposal)

Aggregations

IJavaElement (org.eclipse.jdt.core.IJavaElement)1 IType (org.eclipse.jdt.core.IType)1 JavaModelException (org.eclipse.jdt.core.JavaModelException)1 AnonymousTypeCompletionProposal (org.eclipse.jdt.internal.ui.text.java.AnonymousTypeCompletionProposal)1 AnonymousTypeProposalInfo (org.eclipse.jdt.internal.ui.text.java.AnonymousTypeProposalInfo)1 JavaCompletionProposal (org.eclipse.jdt.internal.ui.text.java.JavaCompletionProposal)1 LazyJavaCompletionProposal (org.eclipse.jdt.internal.ui.text.java.LazyJavaCompletionProposal)1 StyledString (org.eclipse.jface.viewers.StyledString)1