Search in sources :

Example 1 with HibernateResultCollector

use of org.hibernate.eclipse.hqleditor.HibernateResultCollector in project jbosstools-hibernate by jbosstools.

the class FieldPropertyHandler method attributeCompletionProposals.

public ICompletionProposal[] attributeCompletionProposals(IJavaProject project, Node node, String attributeName, String start, int offset) {
    // TODO: should also try to find properties getXXX()
    if (project != null) {
        Node parentNode = node.getParentNode();
        String typename = null;
        typename = this.extractor.getNearestType(project, parentNode);
        if (typename == null) {
            // could not locate type
            return new IJavaCompletionProposal[0];
        }
        HibernateResultCollector rc = null;
        try {
            IType type = project.findType(typename);
            // nothing to look for then
            if (type == null)
                return new ICompletionProposal[0];
            rc = new HibernateResultCollector(project);
            rc.acceptContext(new CompletionContext());
            // TODO: only handle properties ?
            rc.setAccepts(false, false, false, false, true, false);
            // rc.reset(offset, javaProject, null);
            type.codeComplete(start.toCharArray(), -1, start.length(), new char[0][0], new char[0][0], new int[0], false, rc);
        } catch (JavaModelException jme) {
        // TODO: report
        }
        IJavaCompletionProposal[] results = rc.getJavaCompletionProposals();
        CompletionHelper.transpose(start, offset, results);
        return results;
    }
    return new ICompletionProposal[0];
}
Also used : CompletionContext(org.eclipse.jdt.core.CompletionContext) JavaModelException(org.eclipse.jdt.core.JavaModelException) Node(org.w3c.dom.Node) ICompletionProposal(org.eclipse.jface.text.contentassist.ICompletionProposal) IJavaCompletionProposal(org.eclipse.jdt.ui.text.java.IJavaCompletionProposal) HibernateResultCollector(org.hibernate.eclipse.hqleditor.HibernateResultCollector) IType(org.eclipse.jdt.core.IType)

Aggregations

CompletionContext (org.eclipse.jdt.core.CompletionContext)1 IType (org.eclipse.jdt.core.IType)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 HibernateResultCollector (org.hibernate.eclipse.hqleditor.HibernateResultCollector)1 Node (org.w3c.dom.Node)1