Author: vrubezhny
Date: 2009-12-07 07:37:53 -0500 (Mon, 07 Dec 2009)
New Revision: 19075
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/XmlContentAssistProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractTagLib.java
Log:
JBIDE-5381: CA doen't work for elements which defined using default namespace
The fix allows to use CA for the elements defined using default namespace
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java 2009-12-07
12:28:33 UTC (rev 19074)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java 2009-12-07
12:37:53 UTC (rev 19075)
@@ -73,7 +73,7 @@
*/
@Override
public String getUri(String prefix) {
- if (prefix == null || prefix.length() == 0)
+ if (prefix == null)
return null;
Map<String, List<INameSpace>> nameSpaces =
getContext().getNameSpaces(getOffset());
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/XmlContentAssistProcessor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/XmlContentAssistProcessor.java 2009-12-07
12:28:33 UTC (rev 19074)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/XmlContentAssistProcessor.java 2009-12-07
12:37:53 UTC (rev 19075)
@@ -193,16 +193,31 @@
for (INameSpace namespace : namespaces) {
String possiblePrefix = namespace.getPrefix();
+ if (possiblePrefix == null || possiblePrefix.length() == 0)
+ continue; // Don't query proposals for the default value here
+
String possibleURI = namespace.getURI();
String possibleQuery = namespace.getPrefix() + ":" + query; //$NON-NLS-1$
addTagNameProposalsForPrefix(contentAssistRequest, childPosition,
possibleQuery, possiblePrefix, possibleURI,
- TextProposal.R_TAG_INSERTION - 1); // TODO: Make relevance to be lower here
+ TextProposal.R_TAG_INSERTION - 1);
}
}
}
}
+
+
+ @Override
+ public String getTagPrefix() {
+ String prefix = super.getTagPrefix();
+ if (prefix != null)
+ return prefix;
+
+ String uri = getUri(""); //$NON-NLS-1$
+ return uri == null ? null : ""; //$NON-NLS-1$
+ }
+
/**
* Calculates and adds the attribute value proposals to the Content Assist Request
object
*/
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java 2009-12-07
12:28:33 UTC (rev 19074)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java 2009-12-07
12:37:53 UTC (rev 19075)
@@ -101,7 +101,7 @@
@SuppressWarnings("restriction")
public class PageContextFactory implements IResourceChangeListener, IDocumentListener {
private static PageContextFactory fInstance;
-
+ private static final String XHTML_TAG_LIB_URI =
"http://www.w3.org/1999/xhtml"; //$NON-NLS-1$
public static final String XML_PAGE_CONTEXT_TYPE = "XML_PAGE_CONTEXT_TYPE";
//$NON-NLS-1$
public static final String JSP_PAGE_CONTEXT_TYPE = "JSP_PAGE_CONTEXT_TYPE";
//$NON-NLS-1$
public static final String FACELETS_PAGE_CONTEXT_TYPE =
"FACELETS_PAGE_CONTEXT_TYPE"; //$NON-NLS-1$
@@ -232,16 +232,6 @@
// long ctm = 0;
-// String getContextType1(IFile file) {
-// if (file.getFileExtension().endsWith("jsp"))
-// return JSP_PAGE_CONTEXT_TYPE;
-// else if (file.getFileExtension().endsWith("html"))
-// return FACELETS_PAGE_CONTEXT_TYPE;
-// else if (file.getFileExtension().endsWith("xml"))
-// return XML_PAGE_CONTEXT_TYPE;
-// return null;
-// }
-
/**
* Creates a page context for the specified context type
*
@@ -517,47 +507,56 @@
*/
private void fillXMLNamespacesForNode(Element node, XmlContextImpl context) {
NamedNodeMap attrs = node.getAttributes();
+ boolean mainNnIsRedefined = false;
for (int j = 0; attrs != null && j < attrs.getLength(); j++) {
Attr a = (Attr) attrs.item(j);
String name = a.getName();
- if (name.startsWith("xmlns:")) { //$NON-NLS-1$
- String prefix = name.substring("xmlns:".length()); //$NON-NLS-1$
- String uri = a.getValue();
+
+ if (!name.startsWith("xmlns:") && !name.equals("xmlns"))
//$NON-NLS-1$ //$NON-NLS-2$
+ continue;
+
+ String prefix = name.startsWith("xmlns:") ?
name.substring("xmlns:".length()) : ""; //$NON-NLS-1$ //$NON-NLS-2$
//$NON-NLS-3$
+ String uri = a.getValue();
- prefix = prefix == null ? null : prefix.trim();
- uri = uri == null ? null : uri.trim();
-
- if (prefix != null && prefix.length() > 0
- && uri != null && uri.length() > 0) {
+ prefix = prefix == null ? null : prefix.trim();
+ uri = uri == null ? null : uri.trim();
+ if (XHTML_TAG_LIB_URI.equalsIgnoreCase(uri))
+ continue;
+
+ if (prefix != null // prefix may be empty
+ && uri != null && uri.length() > 0) {
- int start = ((IndexedRegion) node).getStartOffset();
- int length = ((IndexedRegion) node).getLength();
+ int start = ((IndexedRegion) node).getStartOffset();
+ int length = ((IndexedRegion) node).getLength();
- IDOMElement domElement = (node instanceof IDOMElement ? (IDOMElement) node
- : null);
- if (domElement != null) {
- start = domElement.getStartOffset();
- length = (domElement.hasEndTag() ? domElement
- .getEndStructuredDocumentRegion()
- .getEnd() : ((IDOMNode) node.getOwnerDocument()).getEndOffset() - 1 - start);
- }
+ IDOMElement domElement = (node instanceof IDOMElement ? (IDOMElement) node
+ : null);
+ if (domElement != null) {
+ start = domElement.getStartOffset();
+ length = (domElement.hasEndTag() ? domElement
+ .getEndStructuredDocumentRegion()
+ .getEnd() : ((IDOMNode) node.getOwnerDocument()).getEndOffset() - 1 - start);
+ }
- Region region = new Region(start, length);
- INameSpace nameSpace = new NameSpace(
- uri, prefix,
- TagLibraryManager.getLibraries(
- context.getResource().getProject(), uri));
+ Region region = new Region(start, length);
+ INameSpace nameSpace = new NameSpace(
+ uri, prefix,
+ TagLibraryManager.getLibraries(
+ context.getResource().getProject(), uri));
+ context.addNameSpace(region, nameSpace);
+ if (prefix.length() == 0)
+ mainNnIsRedefined = true;
+
+ if (context instanceof FaceletPageContextImpl &&
+ CustomTagLibManager.FACELETS_UI_TAG_LIB_URI.equals(uri) &&
+ !mainNnIsRedefined) {
+ nameSpace = new NameSpace(
+ CustomTagLibManager.FACELETS_HTML_TAG_LIB_URI, "", //$NON-NLS-1$
+ TagLibraryManager.getLibraries(
+ context.getResource().getProject(),
+ CustomTagLibManager.FACELETS_HTML_TAG_LIB_URI));
context.addNameSpace(region, nameSpace);
- if (context instanceof FaceletPageContextImpl &&
- CustomTagLibManager.FACELETS_UI_TAG_LIB_URI.equals(uri)) {
- nameSpace = new NameSpace(
- CustomTagLibManager.FACELETS_HTML_TAG_LIB_URI, "", //$NON-NLS-1$
- TagLibraryManager.getLibraries(
- context.getResource().getProject(),
- CustomTagLibManager.FACELETS_HTML_TAG_LIB_URI));
- context.addNameSpace(region, nameSpace);
- }
}
}
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractTagLib.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractTagLib.java 2009-12-07
12:28:33 UTC (rev 19074)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractTagLib.java 2009-12-07
12:37:53 UTC (rev 19075)
@@ -115,7 +115,9 @@
if(nameSpace!=null) {
for (INameSpace n : nameSpace) {
String sPrefix = n.getPrefix();
- if(sPrefix!=null && sPrefix.length()>0) {
+ if(sPrefix!=null
+// && sPrefix.length()>0 // Fix for JBIDE-5381
+ ) {
String fullTagName = null;
boolean mask = false;
if(query.getType()==KbQuery.Type.TAG_NAME || query.getType()==KbQuery.Type.TEXT) {
@@ -141,10 +143,12 @@
}
if(mask && prefixIndex<0) {
if(ignoreCase) {
- if(sPrefix.toLowerCase().startsWith(tagName.toLowerCase())) {
+// if(sPrefix.toLowerCase().startsWith(tagName.toLowerCase())) {
+ if(fullTagName.toLowerCase().startsWith(tagName.toLowerCase())) { // Fix for
JBIDE-5381
prefixes.add(sPrefix);
}
- } else if(sPrefix.startsWith(tagName)) {
+// } else if(sPrefix.startsWith(tagName)) {
+ } else if(fullTagName.startsWith(tagName)) { // Fix for JBIDE-5381
prefixes.add(sPrefix);
}
} else if(sPrefix.equals(queryPrefix)) {
@@ -195,7 +199,8 @@
if(fullTagName.length()==0) {
return getExtendedComponents(context);
}
- if(prefix==null) {
+ if(prefix==null
+ || prefix.length() == 0) { // fix for JBIDE-5381
return getComponents(fullTagName, context);
}
}