Search in sources :

Example 6 with CompletionProposalCollector

use of org.eclipse.jdt.ui.text.java.CompletionProposalCollector in project tdi-studio-se by Talend.

the class TalendJavaCompletionProcessor method createContext.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.eclipse.jdt.internal.ui.text.java.JavaCompletionProcessor#createContext(org.eclipse.jface.text.ITextViewer,
     * int)
     */
@Override
protected ContentAssistInvocationContext createContext(ITextViewer viewer, int offset) {
    if (viewer instanceof TalendJavaSourceViewer) {
        ((TalendJavaSourceViewer) viewer).updateContents();
        ICompilationUnit compilationUnit = ((TalendJavaSourceViewer) viewer).getCompilationUnit();
        if (compilationUnit != null) {
            CompletionProposalCollector cpc = new CompletionProposalCollector(compilationUnit);
            // set an empty editor Part as it's the only constructor where the viewer can be used.
            JavaContentAssistInvocationContext invocContext = new JavaContentAssistInvocationContext(viewer, offset, new NullEditorPart());
            cpc.setInvocationContext(invocContext);
            return invocContext;
        } else {
            return null;
        }
    } else {
        return null;
    }
}
Also used : ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) JavaContentAssistInvocationContext(org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext) CompletionProposalCollector(org.eclipse.jdt.ui.text.java.CompletionProposalCollector)

Aggregations

CompletionProposalCollector (org.eclipse.jdt.ui.text.java.CompletionProposalCollector)6 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)2 ArrayList (java.util.ArrayList)1 ITextViewer (org.eclipse.che.jface.text.ITextViewer)1 ICompletionProposal (org.eclipse.che.jface.text.contentassist.ICompletionProposal)1 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)1 JavaModelException (org.eclipse.jdt.core.JavaModelException)1 JavaContentAssistInvocationContext (org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext)1 Point (org.eclipse.swt.graphics.Point)1