Author: scabanovich
Date: 2011-05-20 20:02:39 -0400 (Fri, 20 May 2011)
New Revision: 31405
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/.classpath
trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/src/org/jboss/tools/cdi/seam/config/ui/contentassist/SeamConfigXmlCompletionProposalComputer.java
Log:
JBIDE-8842
https://issues.jboss.org/browse/JBIDE-8842
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/.classpath
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/.classpath 2011-05-20 18:32:51
UTC (rev 31404)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/.classpath 2011-05-21 00:02:39
UTC (rev 31405)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" path="src"/>
<classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/src/org/jboss/tools/cdi/seam/config/ui/contentassist/SeamConfigXmlCompletionProposalComputer.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/src/org/jboss/tools/cdi/seam/config/ui/contentassist/SeamConfigXmlCompletionProposalComputer.java 2011-05-20
18:32:51 UTC (rev 31404)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/src/org/jboss/tools/cdi/seam/config/ui/contentassist/SeamConfigXmlCompletionProposalComputer.java 2011-05-21
00:02:39 UTC (rev 31405)
@@ -172,8 +172,8 @@
Set<TagData> tagData = collectTagData();
for (TagData tag: tagData) {
- if(tag.isUnique()) {
- if(XMLUtilities.getUniqueChild((Element)parentElement, tag.getName()) != null)
continue;
+ if(tag.isUnique() && childOtherThanCurrentNodeExists(tag.getName())) {
+ continue;
}
String tagText = tag.getText();
int positionAdjustment = (tagText.indexOf("><") > 0) ?
tagText.indexOf("><") + 1 : tagText.length();
@@ -185,6 +185,11 @@
}
}
+ private boolean childOtherThanCurrentNodeExists(String tagName) {
+ Element element = XMLUtilities.getUniqueChild((Element)parentElement, tagName);
+ return element != null && element != currentNode;
+ }
+
private Set<TagData> collectTagData() {
String parentElementName = sax.getLocalName();
String parentElementPrefix = sax.getPrefix();
@@ -213,11 +218,12 @@
addTypeNames(tagData, true, false); //only annotations allowed here.
addTagData(tagData, getTagNamesForMembers(parentElementPrefix, contextType, false),
RELEVANCE_TAG_MEMBER);
- if(eePrefix != null
- && XMLUtilities.getUniqueChild((Element)parentElement, eePrefix +
":" + KEYWORD_MODIFIES) == null
- && XMLUtilities.getUniqueChild((Element)parentElement, eePrefix +
":" + KEYWORD_REPLACES) == null) {
- addTagData(tagData, eePrefix, KEYWORD_MODIFIES, false, true,
RELEVANCE_TAG_KEYWORD);
- addTagData(tagData, eePrefix, KEYWORD_REPLACES, false, true,
RELEVANCE_TAG_KEYWORD);
+ if(eePrefix != null) {
+ if(!childOtherThanCurrentNodeExists(eePrefix + ":" + KEYWORD_MODIFIES)
+ && !childOtherThanCurrentNodeExists(eePrefix + ":" +
KEYWORD_REPLACES)) {
+ addTagData(tagData, eePrefix, KEYWORD_MODIFIES, false, true,
RELEVANCE_TAG_KEYWORD);
+ addTagData(tagData, eePrefix, KEYWORD_REPLACES, false, true,
RELEVANCE_TAG_KEYWORD);
+ }
addTagData(tagData, eePrefix, KEYWORD_PARAMETERS, true, true,
RELEVANCE_TAG_KEYWORD);
}
} else if(sax.getParent() != null && ((contextType =
Util.resolveType(sax.getParent(), cdi)) != null)) {
@@ -318,8 +324,8 @@
}
for (TagData tag: tagData) {
- if(tag.isUnique()) {
- if(XMLUtilities.getUniqueChild((Element)parentElement, tag.getName()) != null)
continue;
+ if(tag.isUnique() && childOtherThanCurrentNodeExists(tag.getName())) {
+ continue;
}
String tagText = isEnded ? tag.getName() : tag.getText();
if(tagText.startsWith("<")) tagText = tagText.substring(1);
@@ -451,7 +457,9 @@
CustomCompletionProposal textProposal = new CustomCompletionProposal(
tagText, begin, length, positionAdjustment,
CDISeamConfigUiImages.PACKAGE_IMAGE,
- displayText, null, proposedInfo, relevance);
+ displayText, null, proposedInfo, relevance) {
+ // we make it our own type to filter from WTP's proposals
+ };
contentAssistRequest.addProposal(textProposal);
}