private void proposeStatementId( ContentAssistRequest contentAssistRequest, IJavaProject project, String matchString, int start, int length, IDOMNode node) throws JavaModelException, XPathExpressionException { final List<ICompletionProposal> results = new ArrayList<ICompletionProposal>(); final List<MapperMethodInfo> methodInfos = new ArrayList<MapperMethodInfo>(); String qualifiedName = MybatipseXmlUtil.getNamespace(node.getOwnerDocument()); JavaMapperUtil.findMapperMethod( methodInfos, project, qualifiedName, matchString, false, new RejectStatementAnnotation()); for (MapperMethodInfo methodInfo : methodInfos) { String methodName = methodInfo.getMethodName(); results.add( new CompletionProposal( methodName, start, length, methodName.length(), Activator.getIcon(), methodName, null, null)); } addProposals(contentAssistRequest, results); }
private List<ICompletionProposal> proposeParameter( IJavaProject project, final int offset, final int length, Node statementNode, final boolean searchReadable, final String matchString) { List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>(); if (statementNode == null) return proposals; String statementId = null; String paramType = null; NamedNodeMap statementAttrs = statementNode.getAttributes(); for (int i = 0; i < statementAttrs.getLength(); i++) { Node attr = statementAttrs.item(i); String attrName = attr.getNodeName(); if ("id".equals(attrName)) statementId = attr.getNodeValue(); else if ("parameterType".equals(attrName)) paramType = attr.getNodeValue(); } if (statementId == null || statementId.length() == 0) return proposals; if (paramType != null) { String resolved = TypeAliasCache.getInstance().resolveAlias(project, paramType, null); proposals = ProposalComputorHelper.proposePropertyFor( project, offset, length, resolved != null ? resolved : paramType, searchReadable, -1, matchString); } else { try { final List<MapperMethodInfo> methodInfos = new ArrayList<MapperMethodInfo>(); String mapperFqn = MybatipseXmlUtil.getNamespace(statementNode.getOwnerDocument()); JavaMapperUtil.findMapperMethod( methodInfos, project, mapperFqn, statementId, true, new RejectStatementAnnotation()); if (methodInfos.size() > 0) { proposals = ProposalComputorHelper.proposeParameters( project, offset, length, methodInfos.get(0).getParams(), searchReadable, matchString); } } catch (XPathExpressionException e) { Activator.log(Status.ERROR, e.getMessage(), e); } } return proposals; }