Search in sources :

Example 1 with IEvaluationContext

use of org.eclipse.jdt.core.eval.IEvaluationContext in project jbosstools-hibernate by jbosstools.

the class CriteriaEditor method codeComplete.

public void codeComplete(String prefix, CompletionProposalCollector collector, int position, IJavaProject project) throws JavaModelException {
    String code = getSourceViewer().getDocument().get();
    code = prefix + code;
    IEvaluationContext e = getEvaluationContext(project);
    if (e != null) {
        e.codeComplete(code, prefix.length() + position, collector);
    }
}
Also used : IEvaluationContext(org.eclipse.jdt.core.eval.IEvaluationContext)

Example 2 with IEvaluationContext

use of org.eclipse.jdt.core.eval.IEvaluationContext in project jbosstools-hibernate by jbosstools.

the class CompletionHelper method completeOnJavaTypes.

public static ICompletionProposal[] completeOnJavaTypes(IJavaProject javaProject, Settings settings, String packageName, String start, int offset) {
    if (javaProject != null) {
        IEvaluationContext context = javaProject.newEvaluationContext();
        if (packageName != null) {
            context.setPackageName(packageName);
        }
        HibernateResultCollector rc = new HibernateResultCollector(javaProject);
        rc.acceptContext(new CompletionContext());
        // rc.reset(offset, javaProject, null);
        rc.setAccepts(settings);
        try {
            // cannot send in my own document as it won't compile as
            // java - so we just send in
            // the smallest snippet possible
            context.codeComplete(start, start.length(), rc);
        } catch (JavaModelException jme) {
            HibernateConsolePlugin.getDefault().logErrorMessage(HibernateConsoleMessages.CompletionHelper_could_not_complete_java_types, jme);
        }
        IJavaCompletionProposal[] results = rc.getJavaCompletionProposals();
        transpose(start, offset, results);
        return results;
    }
    return new ICompletionProposal[0];
}
Also used : CompletionContext(org.eclipse.jdt.core.CompletionContext) JavaModelException(org.eclipse.jdt.core.JavaModelException) ICompletionProposal(org.eclipse.jface.text.contentassist.ICompletionProposal) IEvaluationContext(org.eclipse.jdt.core.eval.IEvaluationContext) IJavaCompletionProposal(org.eclipse.jdt.ui.text.java.IJavaCompletionProposal)

Aggregations

IEvaluationContext (org.eclipse.jdt.core.eval.IEvaluationContext)2 CompletionContext (org.eclipse.jdt.core.CompletionContext)1 JavaModelException (org.eclipse.jdt.core.JavaModelException)1 IJavaCompletionProposal (org.eclipse.jdt.ui.text.java.IJavaCompletionProposal)1 ICompletionProposal (org.eclipse.jface.text.contentassist.ICompletionProposal)1