private void addProposals( final ContentAssistRequest contentAssistRequest, List<ICompletionProposal> proposals) { Collections.sort(proposals, new CompletionProposalComparator()); for (ICompletionProposal proposal : proposals) { contentAssistRequest.addProposal(proposal); } }
private void generateResults( ContentAssistRequest contentAssistRequest, int offset, int length, Node parentNode, Node typeAttr) { if (typeAttr == null) return; String typeValue = typeAttr.getNodeValue(); if (typeValue == null || typeValue.length() == 0) return; IJavaProject project = getJavaProject(contentAssistRequest); // Try resolving the alias. String qualifiedName = TypeAliasCache.getInstance().resolveAlias(project, typeValue, null); if (qualifiedName == null) { // Assumed to be FQN. qualifiedName = typeValue; } BeanPropertyInfo beanProps = BeanPropertyCache.getBeanPropertyInfo(project, qualifiedName); try { Set<String> existingProps = new HashSet<String>(); NodeList existingPropNodes = XpathUtil.xpathNodes(parentNode, "*[@property]/@property"); for (int i = 0; i < existingPropNodes.getLength(); i++) { existingProps.add(existingPropNodes.item(i).getNodeValue()); } StringBuilder resultTags = new StringBuilder(); for (Entry<String, String> prop : beanProps.getWritableFields().entrySet()) { String propName = prop.getKey(); if (!existingProps.contains(propName)) { resultTags .append("<result property=\"") .append(propName) .append("\" column=\"") .append(propName) .append("\" />\n"); } } contentAssistRequest.addProposal( new CompletionProposal( resultTags.toString(), offset, length, resultTags.length(), Activator.getIcon(), "<result /> for properties", null, null)); } catch (XPathExpressionException e) { Activator.log(Status.ERROR, e.getMessage(), e); } }
private void proposeMapperNamespace( ContentAssistRequest contentAssistRequest, IJavaProject project, int start, int length) { String namespace = MybatipseXmlUtil.getNamespaceFromActiveEditor(project); ICompletionProposal proposal = new CompletionProposal( namespace, start, length, namespace.length(), Activator.getIcon("/icons/mybatis-ns.png"), namespace, null, null); contentAssistRequest.addProposal(proposal); }
protected void addAttributeNameProposals(ContentAssistRequest contentAssistRequest) { DataserviceTagElement currentDataserviceElement = getCurrentDataserviceElement(contentAssistRequest); if (currentDataserviceElement != null) { List<DataserviceAttributeElement> attributes = currentDataserviceElement.getAttributes(); Node currentNode = getCurrentNode(contentAssistRequest); for (DataserviceAttributeElement element : attributes) { if (!isAttributePresent(currentNode, element.getName())) { contentAssistRequest.addProposal(getAttributeNameProposal(element)); } } } else { super.addAttributeNameProposals(contentAssistRequest); } }
@SuppressWarnings("restriction") protected void addTagInsertionProposals( ContentAssistRequest contentAssistRequest, int childPosition) { DataserviceTagElement currentDataserviceElement = getCurrentDataserviceElement(contentAssistRequest); if (currentDataserviceElement != null) { List<DataserviceTagElement> subElements = currentDataserviceElement.getSubElements(); Node currentNode = getCurrentNode(contentAssistRequest); for (DataserviceTagElement element : subElements) { if (element.isUpperLimitUnbound() || getChildNodeCount(currentNode, element.getName()) < element.getMaxOccurances()) { contentAssistRequest.addProposal(getTagProposal(element)); } } } else { super.addTagInsertionProposals(contentAssistRequest, childPosition); } }