Author: vrubezhny
Date: 2009-11-24 08:56:15 -0500 (Tue, 24 Nov 2009)
New Revision: 18797
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/INameSpaceExtended.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/TagLibraryManager.java
Removed:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/TagLibriryManager.java
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELContext.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/SimpleELContext.java
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.facelets/plugin.xml
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AbstractXMLContentAssistProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletPageContectAssistProcessor.java
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.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPPropertySourceAdapter.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/plugin.xml
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/ICSSContainerSupport.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IIncludedContextSupport.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IPageContext.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IProposalProcessor.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/PageProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/JspContextImpl.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/XmlContextImpl.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractAttribute.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractComponent.java
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/CSSClassProposalType.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomProposalType.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomProposalTypeFactory.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomTagLibAttribute.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/EnumerationProposalType.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ExtendedProposalType.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/FaceletsJsfCProposalType.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/FacetNameProposalType.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/IDProposalType.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ModelProposalType.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/NameSpace.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ResourcePathProposalType.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/INameSpace.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidationMessages.java
Log:
JBIDE-5119: Refactor PageContextFactory to improve perfomance of context creation
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELContext.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELContext.java 2009-11-24
04:57:39 UTC (rev 18796)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELContext.java 2009-11-24
13:56:15 UTC (rev 18797)
@@ -27,12 +27,18 @@
/**
* Returns "var" attributes
- * @param offset
* @return
*/
Var[] getVars();
/**
+ * Returns "var" attributes which are available in particular offset.
+ * @param offset
+ * @return
+ */
+ Var[] getVars(int offset);
+
+ /**
* Returns EL Resolvers which are declared for this resource
* @return
*/
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/SimpleELContext.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/SimpleELContext.java 2009-11-24
04:57:39 UTC (rev 18796)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/SimpleELContext.java 2009-11-24
13:56:15 UTC (rev 18797)
@@ -56,6 +56,14 @@
return vars.toArray(new Var[vars.size()]);
}
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.common.el.core.resolver.ELContext#getVars(int)
+ */
+ public Var[] getVars(int i) {
+ return getVars();
+ }
+
/**
* @param vars
*/
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.facelets/plugin.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.facelets/plugin.xml 2009-11-24 04:57:39
UTC (rev 18796)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.facelets/plugin.xml 2009-11-24 13:56:15
UTC (rev 18797)
@@ -118,7 +118,7 @@
<attribute name="template" />
</tag>
<tag name="include">
- <attribute name="page" />
+ <attribute name="src" />
</tag>
</include>
</extension>
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AbstractXMLContentAssistProcessor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AbstractXMLContentAssistProcessor.java 2009-11-24
04:57:39 UTC (rev 18796)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AbstractXMLContentAssistProcessor.java 2009-11-24
13:56:15 UTC (rev 18797)
@@ -33,6 +33,7 @@
import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMText;
@@ -62,9 +63,10 @@
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+@SuppressWarnings("restriction")
abstract public class AbstractXMLContentAssistProcessor extends
AbstractContentAssistProcessor {
private static final char[] PROPOSAL_AUTO_ACTIVATION_CHARS = new char[] {
- '<', '=', '"', '\'', '.'
+ '<', '=', '"', '\'', '.',
'{'
};
private IDocument fDocument;
@@ -278,7 +280,7 @@
*/
@Override
protected String getMatchString(IStructuredDocumentRegion parent, ITextRegion aRegion,
int offset) {
- if (aRegion == null) return "";
+ if (aRegion == null) return ""; //$NON-NLS-1$
String matchString = super.getMatchString(parent, aRegion, offset);
String regionType = aRegion.getType();
if(regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE &&
matchString.startsWith("\"")) { //$NON-NLS-1$
@@ -543,7 +545,7 @@
}
String regionType = completionRegion.getType();
- IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);
+// IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);
/*
* Jeremy: Add attribute name proposals before empty tag close
@@ -555,7 +557,8 @@
|| (regionType == DOMRegionContext.XML_CHAR_REFERENCE)
|| (regionType == DOMRegionContext.XML_ENTITY_REFERENCE)
|| (regionType == DOMRegionContext.XML_PE_REFERENCE)
- || (regionType == DOMRegionContext.BLOCK_TEXT)) {
+ || (regionType == DOMRegionContext.BLOCK_TEXT)
+ || (regionType == DOMRegionContext.XML_END_TAG_OPEN)) {
addTextELProposals(contentAssistRequest);
}
}
@@ -588,14 +591,6 @@
/**
- * Creates an empty
<code>org.jboss.tools.common.el.core.resolver.ELContext</code> instance
- * to be used in <code>createContext()</code> method
- *
- *
- */
- abstract protected ELContext createContextInstance();
-
- /**
* Creates and fulfills the <code>org.jboss.tools.jst.web.kb.KbQuery</code>
* instance
* Important: the Context is to be set before any call to createKbQuery
@@ -934,6 +929,7 @@
* Returns URI for the current/parent tag
* @return
*/
+ @SuppressWarnings("deprecation")
protected TextRegion getELPrefix() {
IStructuredModel sModel = StructuredModelManager
.getModelManager()
@@ -956,27 +952,40 @@
String text = null;
ITextRegion region = null;
int startOffset = -1;
- if (n instanceof IDOMAttr) {
- text = ((IDOMAttr)n).getValueRegionText();
- region = ((IDOMAttr)n).getValueRegion();
- startOffset = ((IndexedRegion)((IDOMAttr)n).getOwnerElement()).getStartOffset();
- if(region != null) {
- startOffset += region.getStart();
- } else {
- region = ((IDOMAttr)n).getEqualRegion();
+ int offset = getOffset();
+ while (n != null && startOffset == -1) {
+ if (n instanceof IDOMAttr) {
+ text = ((IDOMAttr)n).getValueRegionText();
+ region = ((IDOMAttr)n).getValueRegion();
+ startOffset = ((IndexedRegion)((IDOMAttr)n).getOwnerElement()).getStartOffset();
if(region != null) {
- startOffset += region.getStart() + region.getLength();
+ startOffset += region.getStart();
} else {
- startOffset = ((IDOMAttr)n).getEndOffset();
+ region = ((IDOMAttr)n).getEqualRegion();
+ if(region != null) {
+ startOffset += region.getStart() + region.getLength();
+ } else {
+ startOffset = ((IDOMAttr)n).getEndOffset();
+ }
}
+ } else if (n instanceof IDOMText) {
+ text = ((IDOMText)n).getNodeValue();
+ region = ((IDOMText)n).getFirstStructuredDocumentRegion();
+ startOffset = ((IDOMText)n).getStartOffset();
+ } else {
+ // The EL may appear only in TEXT and ATTRIBUTE VALUE types of node
+ // But if the current offset is start of a tag - we should treat it as part of
previous region
+ if (n instanceof IDOMElement) {
+ IDOMElement elem = (IDOMElement)n;
+ if ((elem.hasEndTag() && elem.getEndStartOffset() == offset) ||
+ elem.getStartOffset() == offset) {
+ n = findNodeForOffset(xmlDocument, --offset);
+ continue;
+ }
+ }
+
+ return null;
}
- } else if (n instanceof IDOMText) {
- text = ((IDOMText)n).getNodeValue();
- region = ((IDOMText)n).getFirstStructuredDocumentRegion();
- startOffset = ((IDOMText)n).getStartOffset();
- } else {
- // The EL may appear only in TEXT and ATTRIBUTE VALUE types of node
- return null;
}
int inValueOffset = getOffset() - startOffset;
@@ -987,7 +996,7 @@
return null;
}
- String matchString = text.substring(0, inValueOffset);
+// String matchString = text.substring(0, inValueOffset);
ELParser p = ELParserUtil.getJbossFactory().createParser();
ELModel model = p.parse(text);
@@ -1054,32 +1063,4 @@
return isELClosed;
}
}
- /*
- * Checks if the EL operand starting characters are present
- * @return
- */
- private int getELStartPosition(String matchString) {
- ELParser p = ELParserUtil.getJbossFactory().createParser();
- ELModel model = p.parse(matchString);
- ELInstance is = ELUtil.findInstance(model, matchString.length());
- return is == null ? -1 : is.getStartPosition();
- }
-
- /*
- * Checks if the EL operand ending character is present
- * @return
- */
- private int getELEndPosition(String matchString, String currentValue) {
- if (matchString == null || matchString.length() == 0 ||
- currentValue == null || currentValue.length() == 0 ||
- currentValue.length() < matchString.length())
- return -1;
-
- ELParser p = ELParserUtil.getJbossFactory().createParser();
- ELModel model = p.parse(currentValue);
- ELInstance is = ELUtil.findInstance(model, matchString.length());
- if(is == null || is.getCloseInstanceToken() == null) return -1;
-
- return is.getEndPosition();
- }
}
\ No newline at end of file
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletPageContectAssistProcessor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletPageContectAssistProcessor.java 2009-11-24
04:57:39 UTC (rev 18796)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletPageContectAssistProcessor.java 2009-11-24
13:56:15 UTC (rev 18797)
@@ -10,36 +10,16 @@
******************************************************************************/
package org.jboss.tools.jst.jsp.contentassist;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.Region;
import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
-import org.jboss.tools.common.el.core.resolver.ELContext;
import org.jboss.tools.common.text.TextProposal;
import org.jboss.tools.jst.jsp.messages.JstUIMessages;
import org.jboss.tools.jst.web.kb.IFaceletPageContext;
-import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.KbQuery;
-import org.jboss.tools.jst.web.kb.PageContextFactory;
import org.jboss.tools.jst.web.kb.PageProcessor;
import org.jboss.tools.jst.web.kb.KbQuery.Type;
-import org.jboss.tools.jst.web.kb.internal.FaceletPageContextImpl;
-import org.jboss.tools.jst.web.kb.internal.taglib.NameSpace;
-import org.jboss.tools.jst.web.kb.taglib.CustomTagLibManager;
-import org.jboss.tools.jst.web.kb.taglib.INameSpace;
import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
@@ -49,127 +29,14 @@
* @author Jeremy
*
*/
+@SuppressWarnings("restriction")
public class FaceletPageContectAssistProcessor extends JspContentAssistProcessor {
private static final String JSFC_ATTRIBUTE_NAME = "jsfc"; //$NON-NLS-1$
private boolean replaceJsfcTags;
- @Override
- protected ELContext createContextInstance() {
- return new FaceletPageContextImpl();
- }
-
/*
* (non-Javadoc)
- * @see org.jboss.tools.jst.jsp.contentassist.JspContentAssistProcessor#createContext()
- */
- @Override
- protected IPageContext createContext() {
- IPageContext superContext = super.createContext();
-
- FaceletPageContextImpl context = (FaceletPageContextImpl)createContextInstance();
- context.setResource(superContext.getResource());
- context.setElResolvers(superContext.getElResolvers());
- setVars(context, superContext.getResource());
-
- context.setDocument(getDocument());
- setNameSpaces(superContext, context);
- context.setLibraries(getTagLibraries(context));
- context.setResourceBundles(super.getResourceBundles(context));
-
- PageContextFactory.collectIncludedAdditionalInfo(context);
-
- return context;
- }
-
- protected void setNameSpaces(IPageContext superContext, FaceletPageContextImpl context)
{
- IStructuredModel sModel = StructuredModelManager
- .getModelManager()
- .getExistingModelForRead(getDocument());
- if (superContext != null) {
- IRegion region = new Region (0, getDocument().getLength());
- Map<String, List<INameSpace>> nameSpaces =
superContext.getNameSpaces(getOffset());
- for (String uri : nameSpaces.keySet()) {
- List<INameSpace> ns = nameSpaces.get(uri);
- for (INameSpace n : ns) {
- context.addNameSpace(region, n);
- }
- }
- }
-
- try {
- if (sModel == null)
- return;
-
- Document xmlDocument = (sModel instanceof IDOMModel) ? ((IDOMModel) sModel)
- .getDocument()
- : null;
-
- if (xmlDocument == null)
- return;
-
- // Get Fixed Structured Document Region
- IStructuredDocumentRegion sdFixedRegion =
this.getStructuredDocumentRegion(getOffset());
- if (sdFixedRegion == null)
- return;
-
- Node n = findNodeForOffset(xmlDocument, sdFixedRegion.getStartOffset());
- while (n != null) {
- if (!(n instanceof Element)) {
- if (n instanceof Attr) {
- n = ((Attr) n).getOwnerElement();
- } else {
- n = n.getParentNode();
- }
- continue;
- }
-
- NamedNodeMap attrs = n.getAttributes();
- 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$
- final String prefix = name.substring("xmlns:".length()); //$NON-NLS-1$
- final String uri = a.getValue();
- if (prefix != null && prefix.trim().length() > 0 &&
- uri != null && uri.trim().length() > 0) {
-
- int start = ((IndexedRegion)n).getStartOffset();
- int length = ((IndexedRegion)n).getLength();
-
- IDOMElement domElement = (n instanceof IDOMElement ? (IDOMElement)n : null);
- if (domElement != null) {
- start = domElement.getStartOffset();
- length = (domElement.hasEndTag() ?
- domElement.getEndStructuredDocumentRegion().getEnd() :
- ((IDOMNode) xmlDocument).getEndOffset() - 1 - start);
-
- }
-
- Region region = new Region(start, length);
- INameSpace nameSpace = new NameSpace(uri.trim(), prefix.trim());
- context.addNameSpace(region, nameSpace);
- if (CustomTagLibManager.FACELETS_UI_TAG_LIB_URI.equals(uri)) {
- nameSpace = new NameSpace(CustomTagLibManager.FACELETS_HTML_TAG_LIB_URI,
"");
- context.addNameSpace(region, nameSpace);
- }
- }
- }
- }
-
- n = n.getParentNode();
- }
-
- return;
- } finally {
- if (sModel != null) {
- sModel.releaseFromRead();
- }
- }
- }
-
- /*
- * (non-Javadoc)
* @see org.jboss.tools.jst.jsp.contentassist.JspContentAssistProcessor#getContext()
*/
@Override
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-11-24
04:57:39 UTC (rev 18796)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java 2009-11-24
13:56:15 UTC (rev 18797)
@@ -10,26 +10,19 @@
******************************************************************************/
package org.jboss.tools.jst.jsp.contentassist;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.eclipse.core.resources.IFile;
import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.Region;
import org.eclipse.jface.text.contentassist.IContextInformation;
-import org.eclipse.jst.jsp.core.internal.contentmodel.TaglibController;
-import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TLDCMDocumentManager;
-import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TaglibTracker;
import org.eclipse.swt.graphics.Image;
import org.eclipse.wst.sse.core.StructuredModelManager;
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.xml.core.internal.document.NodeContainer;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
@@ -45,144 +38,32 @@
import org.jboss.tools.common.el.core.resolver.Var;
import org.jboss.tools.common.text.TextProposal;
import org.jboss.tools.jst.web.kb.IPageContext;
-import org.jboss.tools.jst.web.kb.IResourceBundle;
import org.jboss.tools.jst.web.kb.KbQuery;
-import org.jboss.tools.jst.web.kb.PageContextFactory;
import org.jboss.tools.jst.web.kb.PageProcessor;
import org.jboss.tools.jst.web.kb.KbQuery.Type;
-import org.jboss.tools.jst.web.kb.internal.JspContextImpl;
-import org.jboss.tools.jst.web.kb.internal.ResourceBundle;
-import org.jboss.tools.jst.web.kb.internal.XmlContextImpl;
-import org.jboss.tools.jst.web.kb.internal.taglib.NameSpace;
import org.jboss.tools.jst.web.kb.taglib.INameSpace;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
/**
*
* @author Jeremy
*
*/
+@SuppressWarnings("restriction")
public class JspContentAssistProcessor extends XmlContentAssistProcessor {
-
- @Override
- protected ELContext createContextInstance() {
- return new JspContextImpl();
- }
-
/*
* (non-Javadoc)
- * @see
org.jboss.tools.jst.jsp.contentassist.AbstractXMLContentAssistProcessor#createContext()
+ * @see org.jboss.tools.jst.jsp.contentassist.JspContentAssistProcessor#getContext()
*/
@Override
- protected IPageContext createContext() {
- IPageContext context = super.createContext();
- PageContextFactory.collectIncludedAdditionalInfo(context);
- return context;
+ public IPageContext getContext() {
+ return (IPageContext)super.getContext();
}
-
- /**
- * Collects the namespaces over the JSP-page and sets them up to the context specified.
- *
- * @param context
- */
- protected void setNameSpaces(XmlContextImpl context) {
- super.setNameSpaces(context);
-
- TLDCMDocumentManager manager =
TaglibController.getTLDCMDocumentManager(getDocument());
- List trackers = (manager == null? null : manager.getCMDocumentTrackers(getOffset()));
- for (int i = 0; trackers != null && i < trackers.size(); i++) {
- TaglibTracker tt = (TaglibTracker)trackers.get(i);
- final String prefix = tt.getPrefix();
- final String uri = tt.getURI();
- if (prefix != null && prefix.trim().length() > 0 &&
- uri != null && uri.trim().length() > 0) {
-
- IRegion region = new Region(0, getDocument().getLength());
- INameSpace nameSpace = new NameSpace(uri.trim(), prefix.trim());
- context.addNameSpace(region, nameSpace);
- }
- }
- return;
- }
-
/**
- * Returns the resource bundles
- *
- * @return
- */
- protected IResourceBundle[] getResourceBundles(IPageContext context) {
- List<IResourceBundle> list = new ArrayList<IResourceBundle>();
- IStructuredModel sModel =
StructuredModelManager.getModelManager().getExistingModelForRead(getDocument());
- if (sModel == null)
- return new IResourceBundle[0];
- try {
- Document dom = (sModel instanceof IDOMModel) ? ((IDOMModel) sModel).getDocument() :
null;
- if (dom != null) {
- Element element = dom.getDocumentElement();
- NodeList children = (NodeContainer)dom.getChildNodes();
- if (element != null) {
- for (int i = 0; children != null && i < children.getLength(); i++) {
- IDOMNode xmlnode = (IDOMNode)children.item(i);
- update((IDOMNode)xmlnode, context, list);
- }
- }
- }
- }
- finally {
- if (sModel != null) {
- sModel.releaseFromRead();
- }
- }
-
- return list.toArray(new IResourceBundle[list.size()]);
- }
-
- private void update(IDOMNode element, IPageContext context, List<IResourceBundle>
list) {
- if (element != null) {
- registerBundleForNode(element, context, list);
- for (Node child = element.getFirstChild(); child != null; child =
child.getNextSibling()) {
- if (child instanceof IDOMNode) {
- update((IDOMNode)child, context, list);
- }
- }
- }
- }
- private void registerBundleForNode(IDOMNode node, IPageContext context,
List<IResourceBundle> list) {
- if (node == null) return;
- String name = node.getNodeName();
- if (name == null) return;
- if (!name.endsWith("loadBundle")) return; //$NON-NLS-1$
- if (name.indexOf(':') == -1) return;
- String prefix = name.substring(0, name.indexOf(':'));
-
- Map<String, List<INameSpace>> ns =
context.getNameSpaces(node.getStartOffset());
- if (!containsPrefix(ns, prefix)) return;
-
- NamedNodeMap attributes = node.getAttributes();
- if (attributes == null) return;
- String basename = (attributes.getNamedItem("basename") == null ? null :
attributes.getNamedItem("basename").getNodeValue()); //$NON-NLS-1$
//$NON-NLS-2$
- String var = (attributes.getNamedItem("var") == null ? null :
attributes.getNamedItem("var").getNodeValue()); //$NON-NLS-1$ //$NON-NLS-2$
- if (basename == null || basename.length() == 0 ||
- var == null || var.length() == 0) return;
-
- list.add(new ResourceBundle(basename, var));
- }
- private boolean containsPrefix(Map<String, List<INameSpace>> ns, String
prefix) {
- for (List<INameSpace> n: ns.values()) {
- for (INameSpace nameSpace : n) {
- if(prefix.equals(nameSpace.getPrefix())) return true;
- }
- }
- return false;
- }
-
- /**
* Returns URI string for the prefix specified using the namespaces collected for
* the {@link IPageContext} context.
* Important: The context must be created using createContext() method before using this
method.
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-11-24
04:57:39 UTC (rev 18796)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/XmlContentAssistProcessor.java 2009-11-24
13:56:15 UTC (rev 18797)
@@ -10,104 +10,39 @@
******************************************************************************/
package org.jboss.tools.jst.jsp.contentassist;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jface.text.Region;
import org.eclipse.jface.text.contentassist.IContextInformation;
-import org.eclipse.jface.text.templates.GlobalTemplateVariables.User;
import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
import org.jboss.tools.common.el.core.resolver.ELContext;
-import org.jboss.tools.common.el.core.resolver.ELContextImpl;
-import org.jboss.tools.common.el.core.resolver.ELResolver;
import org.jboss.tools.common.text.TextProposal;
import org.jboss.tools.jst.jsp.JspEditorPlugin;
import org.jboss.tools.jst.jsp.messages.JstUIMessages;
import org.jboss.tools.jst.web.kb.IPageContext;
-import org.jboss.tools.jst.web.kb.IResourceBundle;
import org.jboss.tools.jst.web.kb.KbQuery;
import org.jboss.tools.jst.web.kb.PageContextFactory;
import org.jboss.tools.jst.web.kb.PageProcessor;
import org.jboss.tools.jst.web.kb.KbQuery.Type;
-import org.jboss.tools.jst.web.kb.include.IncludeContextBuilder;
-import org.jboss.tools.jst.web.kb.include.IncludeContextDefinition;
-import org.jboss.tools.jst.web.kb.internal.XmlContextImpl;
-import org.jboss.tools.jst.web.kb.internal.taglib.NameSpace;
-import org.jboss.tools.jst.web.kb.taglib.INameSpace;
-import org.jboss.tools.jst.web.kb.taglib.ITagLibrary;
-import org.jboss.tools.jst.web.kb.taglib.TagLibriryManager;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
/**
*
* @author Jeremy
*
*/
+@SuppressWarnings("restriction")
public class XmlContentAssistProcessor extends AbstractXMLContentAssistProcessor {
protected static final Image JSF_EL_PROPOSAL_IMAGE =
JspEditorPlugin.getDefault().getImage(JspEditorPlugin.CA_JSF_EL_IMAGE_PATH);
- @Override
- protected ELContext createContextInstance() {
- return new XmlContextImpl();
- }
-
/*
* (non-Javadoc)
* @see
org.jboss.tools.jst.jsp.contentassist.AbstractXMLContentAssistProcessor#createContext()
*/
@Override
- protected IPageContext createContext() {
- IFile file = getResource();
- ELResolver[] elResolvers = getELResolvers(file);
-
- XmlContextImpl context = (XmlContextImpl)createContextInstance();
- context.setResource(file);
- context.setDocument(getDocument());
- context.setElResolvers(elResolvers);
- setVars(context, file);
-
- setNameSpaces(context);
- context.setLibraries(getTagLibraries(context));
- context.setResourceBundles(getResourceBundles(context));
- return context;
+ protected ELContext createContext() {
+ return PageContextFactory.createPageContext(getResource());
}
-
-
- protected void setVars(ELContextImpl context, IFile file) {
- // No vars can be set for this processor
- }
-
- /**
- * Returns the
<code>org.jboss.tools.common.el.core.resolver.ELContext</code> instance
- *
- * @return
- */
- @Override
- public IPageContext getContext() {
- return (IPageContext)super.getContext();
- }
-
@Override
protected KbQuery createKbQuery(Type type, String query, String stringQuery) {
KbQuery kbQuery = new KbQuery();
@@ -191,7 +126,7 @@
if (image == null) {
image =
XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
}
- String displayString = closingTag; //$NON-NLS-1$
+ String displayString = closingTag;
IContextInformation contextInformation = null;
String additionalProposalInfo = textProposal.getContextInfo();
int relevance = textProposal.getRelevance();
@@ -255,7 +190,7 @@
image =
XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
}
- String displayString = closingTag; //$NON-NLS-1$
+ String displayString = closingTag;
IContextInformation contextInformation = null;
String additionalProposalInfo = textProposal.getContextInfo();
int relevance = textProposal.getRelevance();
@@ -458,124 +393,4 @@
contentAssistRequest.addProposal(proposal);
}
}
-
- /**
- * Collects the namespaces over the JSP-page and sets them up to the context specified.
- *
- * @param context
- */
- protected void setNameSpaces(XmlContextImpl context) {
- IStructuredModel sModel = StructuredModelManager
- .getModelManager()
- .getExistingModelForRead(getDocument());
-
- try {
- if (sModel == null)
- return;
-
- Document xmlDocument = (sModel instanceof IDOMModel) ? ((IDOMModel) sModel)
- .getDocument()
- : null;
-
- if (xmlDocument == null)
- return;
-
- // Get Fixed Structured Document Region
- IStructuredDocumentRegion sdFixedRegion =
this.getStructuredDocumentRegion(getOffset());
- if (sdFixedRegion == null)
- return;
-
- Node n = findNodeForOffset(xmlDocument, sdFixedRegion.getStartOffset());
- while (n != null) {
- if (!(n instanceof Element)) {
- if (n instanceof Attr) {
- n = ((Attr) n).getOwnerElement();
- } else {
- n = n.getParentNode();
- }
- continue;
- }
-
- NamedNodeMap attrs = n.getAttributes();
- 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$
- final String prefix = name.substring("xmlns:".length()); //$NON-NLS-1$
- final String uri = a.getValue();
- if (prefix != null && prefix.trim().length() > 0 &&
- uri != null && uri.trim().length() > 0) {
-
- int start = ((IndexedRegion)n).getStartOffset();
- int length = ((IndexedRegion)n).getLength();
-
- IDOMElement domElement = (n instanceof IDOMElement ? (IDOMElement)n : null);
- if (domElement != null) {
- start = domElement.getStartOffset();
- length = (domElement.hasEndTag() ?
- domElement.getEndStructuredDocumentRegion().getEnd() :
- ((IDOMNode) xmlDocument).getEndOffset() - 1 - start);
-
- }
-
- Region region = new Region(start, length);
- INameSpace nameSpace = new NameSpace(uri.trim(), prefix.trim());
- context.addNameSpace(region, nameSpace);
- }
- }
- }
-
- n = n.getParentNode();
- }
-
- return;
- } finally {
- if (sModel != null) {
- sModel.releaseFromRead();
- }
- }
- }
-
- protected static final ITagLibrary[] EMPTY_LIBRARIES = new ITagLibrary[0];
- protected static final IResourceBundle[] EMPTY_RESOURCE_BUNDLES = new
IResourceBundle[0];
-
- /**
- * Returns the Tag Libraries for the namespaces collected in the context.
- * Important: The context must be created using createContext() method before using this
method.
- *
- * @param context The context object instance
- * @return
- */
- public ITagLibrary[] getTagLibraries(IPageContext context) {
- Map<String, List<INameSpace>> nameSpaces =
context.getNameSpaces(getOffset());
- if (nameSpaces == null || nameSpaces.isEmpty())
- return EMPTY_LIBRARIES;
-
- IProject project = context.getResource() == null ? null :
context.getResource().getProject();
- if (project == null)
- return EMPTY_LIBRARIES;
-
- List<ITagLibrary> tagLibraries = new ArrayList<ITagLibrary>();
- for (List<INameSpace> nameSpace : nameSpaces.values()) {
- for (INameSpace n : nameSpace) {
- ITagLibrary[] libs = TagLibriryManager.getLibraries(project, n.getURI());
- if (libs != null && libs.length > 0) {
- for (ITagLibrary lib : libs) {
- tagLibraries.add(lib);
- }
- }
- }
- }
- return (tagLibraries.isEmpty() ? EMPTY_LIBRARIES :
- (ITagLibrary[])tagLibraries.toArray(new ITagLibrary[tagLibraries.size()]));
- }
-
- /**
- * Returns the resource bundles
- *
- * @return
- */
- protected IResourceBundle[] getResourceBundles(IPageContext context) {
- return EMPTY_RESOURCE_BUNDLES;
- }
}
\ No newline at end of file
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java 2009-11-24
04:57:39 UTC (rev 18796)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java 2009-11-24
13:56:15 UTC (rev 18797)
@@ -148,6 +148,7 @@
import org.jboss.tools.jst.web.kb.taglib.IAttribute;
import org.jboss.tools.jst.web.kb.taglib.IComponent;
import org.jboss.tools.jst.web.kb.taglib.INameSpace;
+import org.jboss.tools.jst.web.kb.taglib.TagLibraryManager;
import org.jboss.tools.jst.web.tld.VpeTaglibManager;
import org.jboss.tools.jst.web.tld.VpeTaglibManagerProvider;
import org.w3c.dom.DocumentType;
@@ -783,13 +784,17 @@
ValueHelper valueHelper = new ValueHelper();
processor = valueHelper.createContentAssistProcessor();
pageContext = valueHelper.createPageContext(processor, query.getOffset());
+
Map<String, List<INameSpace>> ns =
pageContext.getNameSpaces(query.getOffset());
List<INameSpace> n = ns.get(query.getUri());
if(n == null && pageContext instanceof JspContextImpl) {
IRegion r = new Region(query.getOffset(), 0);
- ((JspContextImpl)pageContext).addNameSpace(r, new NameSpace(query.getUri(),
query.getPrefix()));
- ((JspContextImpl)pageContext).setLibraries(processor.getTagLibraries(pageContext));
+ ((JspContextImpl)pageContext).addNameSpace(r, new NameSpace(query.getUri(),
query.getPrefix(),
+ TagLibraryManager.getLibraries(
+ pageContext.getResource().getProject(), query.getUri())));
+// ((JspContextImpl)pageContext).setLibraries(processor.getTagLibraries(pageContext));
}
+
}
public void initContext(Properties context) {
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPPropertySourceAdapter.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPPropertySourceAdapter.java 2009-11-24
04:57:39 UTC (rev 18796)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPPropertySourceAdapter.java 2009-11-24
13:56:15 UTC (rev 18797)
@@ -65,6 +65,7 @@
* creation of property descriptors.
*/
+@SuppressWarnings("restriction")
public class JSPPropertySourceAdapter implements INodeAdapter, IPropertySource,
IPropertySourceExtension, IPropertySource2 {//extends XMLPropertySourceAdapter {
protected final static String CATEGORY_ATTRIBUTES =
XMLUIMessages.XMLPropertySourceAdapter_0;
private static final boolean SET_EXPERT_FILTER = false;
@@ -95,12 +96,14 @@
JspContentAssistProcessor processor;
int offset = 0;
KbQuery kbQuery, kbQueryAttr;
+ @SuppressWarnings("unchecked")
private Set attributeNames = new HashSet();
public JSPPropertySourceAdapter(INodeNotifier target) {
setTarget(target);
}
+ @SuppressWarnings("unchecked")
Map getWeights() {
return sorter == null ? new HashMap() : sorter.weights;
}
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/plugin.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/plugin.xml 2009-11-24 04:57:39 UTC (rev
18796)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/plugin.xml 2009-11-24 13:56:15 UTC (rev
18797)
@@ -88,7 +88,23 @@
<contexttype id="FACELETS_PAGE_CONTEXT_TYPE">
<contenttype id="org.eclipse.wst.html.core.htmlsource" />
</contexttype>
-
+
+ <contexttype id="XML_PAGE_CONTEXT_TYPE">
+ <contenttype id="org.eclipse.wst.xml.core.xmlsource" />
+ <contenttype id="org.eclipse.jst.jsf.facesconfig.facesConfigFile" />
+ <contenttype id="org.eclipse.core.runtime.xml" />
+ <contenttype id="org.eclipse.jst.j2ee.webDD" />
+ <contenttype id="org.eclipse.jst.jee.ee5webDD" />
+ <contenttype id="org.jboss.tools.common.model.ui.xml" />
+ <contenttype id="org.eclipse.jst.jsp.core.tldsource" />
+ <contenttype id="org.jboss.tools.seam.xml.ui.pages12xmlsource" />
+ <contenttype id="org.jboss.tools.seam.xml.ui.page12xmlsource" />
+ <contenttype id="org.jboss.tools.seam.xml.ui.pages20xmlsource" />
+ <contenttype id="org.jboss.tools.seam.xml.ui.page20xmlsource" />
+ <contenttype id="org.jboss.tools.seam.xml.ui.pages21xmlsource" />
+ <contenttype id="org.jboss.tools.seam.xml.ui.page21xmlsource" />
+ </contexttype>
+
<cssholder uri="">
<tag name="style" />
<tag name="link">
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/ICSSContainerSupport.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/ICSSContainerSupport.java 2009-11-24
04:57:39 UTC (rev 18796)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/ICSSContainerSupport.java 2009-11-24
13:56:15 UTC (rev 18797)
@@ -14,7 +14,6 @@
import org.eclipse.core.resources.IFile;
import org.jboss.tools.jst.web.kb.PageContextFactory.CSSStyleSheetDescriptor;
-import org.w3c.dom.css.CSSStyleSheet;
/**
* The interface defines the methods to collect
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IIncludedContextSupport.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IIncludedContextSupport.java 2009-11-24
04:57:39 UTC (rev 18796)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IIncludedContextSupport.java 2009-11-24
13:56:15 UTC (rev 18797)
@@ -14,6 +14,7 @@
import java.util.Map;
import org.eclipse.core.resources.IFile;
+import org.jboss.tools.common.el.core.resolver.ELContext;
import org.jboss.tools.jst.web.kb.taglib.INameSpace;
/**
@@ -30,14 +31,14 @@
*
* @param includedContext
*/
- void addIncludedContext(IPageContext includedContext);
+ void addIncludedContext(ELContext includedContext);
/**
* Returns the list of all the collected contexts
*
* @return
*/
- List<IPageContext> getIncludedContexts();
+ List<ELContext> getIncludedContexts();
/**
* Returns Resource of the page
@@ -51,26 +52,4 @@
* @return
*/
Map<String, List<INameSpace>> getNameSpaces(int offset);
-
- /**
- * Checks if the context exists in parent contexts for the specified resource
- *
- * @param resource
- * @return
- */
- boolean contextExistsInParents(IFile resource);
-
- /**
- * Set up parent context
- *
- * @param parent
- */
- void setParent(IIncludedContextSupport parent);
-
- /**
- * Returns parent context
- *
- * @return
- */
- IIncludedContextSupport getParent();
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IPageContext.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IPageContext.java 2009-11-24
04:57:39 UTC (rev 18796)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IPageContext.java 2009-11-24
13:56:15 UTC (rev 18797)
@@ -15,7 +15,6 @@
import org.eclipse.jface.text.IDocument;
import org.jboss.tools.common.el.core.resolver.ELContext;
-import org.jboss.tools.common.el.core.resolver.Var;
import org.jboss.tools.jst.web.kb.taglib.INameSpace;
import org.jboss.tools.jst.web.kb.taglib.ITagLibrary;
@@ -23,7 +22,7 @@
* Page context
* @author Alexey Kazakov
*/
-public interface IPageContext extends ELContext, IIncludedContextSupport {
+public interface IPageContext extends ELContext {
/**
* Returns libraries which should be used in this context
@@ -48,7 +47,7 @@
* @param offset
* @return
*/
- Var[] getVars(int offset);
+// Var[] getVars(int offset);
/**
* Returns map of name spaces which are set in particular offset.
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IProposalProcessor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IProposalProcessor.java 2009-11-24
04:57:39 UTC (rev 18796)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IProposalProcessor.java 2009-11-24
13:56:15 UTC (rev 18797)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.jst.web.kb;
+import org.jboss.tools.common.el.core.resolver.ELContext;
import org.jboss.tools.common.text.TextProposal;
/**
@@ -21,6 +22,6 @@
/**
* @return proposals
*/
- public TextProposal[] getProposals(KbQuery query, IPageContext context);
+ public TextProposal[] getProposals(KbQuery query, ELContext context);
}
\ No newline at end of file
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-11-24
04:57:39 UTC (rev 18796)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java 2009-11-24
13:56:15 UTC (rev 18797)
@@ -14,7 +14,9 @@
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Comparator;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -24,20 +26,24 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.text.DocumentEvent;
import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentListener;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.Region;
import org.eclipse.jst.jsp.core.internal.contentmodel.TaglibController;
import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TLDCMDocumentManager;
import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TaglibTracker;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.ui.texteditor.DocumentProviderRegistry;
-import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.wst.common.componentcore.internal.ComponentResource;
import org.eclipse.wst.common.componentcore.internal.StructureEdit;
import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent;
@@ -47,16 +53,21 @@
import org.eclipse.wst.html.core.internal.htmlcss.LinkElementAdapter;
import org.eclipse.wst.html.core.internal.htmlcss.URLModelProvider;
import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.xml.core.internal.document.NodeContainer;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
import org.jboss.tools.common.el.core.GlobalELReferenceList;
-import org.jboss.tools.common.el.core.resolver.ELResolver;
+import org.jboss.tools.common.el.core.parser.ELParserUtil;
+import org.jboss.tools.common.el.core.resolver.ELContext;
+import org.jboss.tools.common.el.core.resolver.ELContextImpl;
import org.jboss.tools.common.el.core.resolver.ELResolverFactoryManager;
+import org.jboss.tools.common.el.core.resolver.ElVarSearcher;
+import org.jboss.tools.common.el.core.resolver.Var;
import org.jboss.tools.common.resref.core.ResourceReference;
import org.jboss.tools.common.text.ext.util.Utils;
import org.jboss.tools.jst.web.kb.include.IncludeContextBuilder;
@@ -67,10 +78,8 @@
import org.jboss.tools.jst.web.kb.internal.taglib.NameSpace;
import org.jboss.tools.jst.web.kb.taglib.CustomTagLibManager;
import org.jboss.tools.jst.web.kb.taglib.INameSpace;
-import org.jboss.tools.jst.web.kb.taglib.ITagLibrary;
-import org.jboss.tools.jst.web.kb.taglib.TagLibriryManager;
+import org.jboss.tools.jst.web.kb.taglib.TagLibraryManager;
import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
@@ -78,171 +87,407 @@
import org.w3c.dom.css.CSSStyleSheet;
/**
+ *
* @author Alexey Kazakov
*/
-public class PageContextFactory {
+@SuppressWarnings("restriction")
+public class PageContextFactory implements IResourceChangeListener, IDocumentListener {
+ private static PageContextFactory fInstance;
+
+ 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$
- public static String JSP_PAGE_CONTEXT_TYPE = "JSP_PAGE_CONTEXT_TYPE";
- public static String FACELETS_PAGE_CONTEXT_TYPE =
"FACELETS_PAGE_CONTEXT_TYPE";
+ private static final PageContextFactory getInstance() {
+ if (fInstance != null)
+ return fInstance;
+ return (fInstance = new PageContextFactory());
+ }
+ private PageContextFactory() {
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ if (workspace != null) workspace.addResourceChangeListener(this);
+ }
-
- /**
- * Creates a page context for the specified context type
- * @
+ /*
+ * The cache to store the created contexts
+ * The key is IFile.getFullPath().toString() of the resource of the context
*/
- public static IPageContext createPageContext(IFile file, int offset, String contentType)
{
- String contextType = IncludeContextBuilder.getInstance().getContextType(contentType);
- if (JSP_PAGE_CONTEXT_TYPE.equals(contextType)) {
- return createJSPContext(file, offset);
+ private Map<IFile, ELContext> cache = new HashMap<IFile, ELContext>();
+
+ private ELContext getSavedContext(IFile resource) {
+ synchronized (cache) {
+ return cache.get(resource);
}
- else if (FACELETS_PAGE_CONTEXT_TYPE.equals(contextType)) {
- return createFaceletPageContext(file, offset);
+ }
+
+ private void saveConvext(ELContext context) {
+ if (context != null && context.getResource() != null) {
+// int size = 0; // remove this line
+ synchronized (cache) {
+ cache.put(context.getResource(), context);
+// size = cache.size(); // remove this line
+ }
+// System.out.println("Saved Context : " +
+// (System.currentTimeMillis() - ctm) + "ms, "
+// + context.getResource().getFullPath().toString() + ", " +
context.getClass().getSimpleName() + ", Totals: " + size);
}
- return null;
}
+
+ private ELContext removeSavedContext(IFile resource) {
+ ELContext removedContext = null; // Remove this line
+
+ synchronized (cache) {
+ removedContext = cache.remove(resource);
+ if (removedContext instanceof XmlContextImpl &&
+ ((XmlContextImpl)removedContext).getDocument() != null) {
+ ((XmlContextImpl)removedContext).getDocument().removeDocumentListener(this);
+ }
+ }
+
+// if (removedContext != null) { // TODO: Remove this statement
+// System.out.println("Removed Context : " +
removedContext.getResource().getFullPath().toString() + ", " +
removedContext.getClass().getSimpleName() + ", Totals: " + cache.size());
+// }
+ return removedContext;
+ }
+
/**
- * Creates a jsp context for given resource and offset.
- * @param file JSP
- * @param offset
+ * Creates a page context for the specified context type
+ *
+ * @param file
+ * @param contentType
* @return
*/
- private static IPageContext createJSPContext(IFile file, int offset) {
- JspContextImpl context = new JspContextImpl();
+ public static ELContext createPageContext(IFile file) {
+ return getInstance().createPageContext(file, null);
+ }
+// 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
+ *
+ * @param file
+ * @param contentType
+ * @param parents List of parent contexts
+ * @return
+ */
+ private ELContext createPageContext(IFile file, List<String> parents) {
+ ELContext context = getSavedContext(file);
+ if (context != null)
+ return context;
-
- IEditorInput input = new FileEditorInput(file);
+// ctm = System.currentTimeMillis();
+// System.out.println("Create Context : " + file.getFullPath().toString() +
", Totals: " + cache.size());
+ IModelManager manager = StructuredModelManager.getModelManager();
+ if(manager == null) {
+ // this may happen if plug-in org.eclipse.wst.sse.core
+ // is stopping or un-installed, that is Eclipse is shutting down.
+ // there is no need to report it, just stop validation.
+ return context;
+ }
+ IStructuredModel model = null;
try {
- ELResolver[] elResolvers = ELResolverFactoryManager.getInstance().getResolvers(file);
- context.setResource(file);
- context.setDocument(getConnectedDocument(input));
- context.setElResolvers(elResolvers);
-
- setXMLNameSpaces(context, offset);
- setJSPNameSpaces(context, offset);
- context.setLibraries(getTagLibraries(context, offset));
- context.setResourceBundles(getResourceBundles(context));
-
- collectIncludedAdditionalInfo(context);
+ model = manager.getModelForRead(file);
+ if (model instanceof IDOMModel) {
+ IDOMModel domModel = (IDOMModel) model;
+ IDOMDocument document = domModel.getDocument();
+
+ context = createPageContextInstance(domModel.getContentTypeIdentifier());
+ if (context == null)
+ return null;
+
+ context.setResource(file);
+ context.setElResolvers(ELResolverFactoryManager.getInstance().getResolvers(file));
+
+ if (context instanceof JspContextImpl && !(context instanceof
FaceletPageContextImpl)) {
+ // Fill JSP namespaces defined in TLDCMDocumentManager
+ fillJSPNameSpaces((JspContextImpl)context);
+ }
+
+ // The subsequently called functions may use the file and document
+ // already stored in context for their needs
+ fillContextForChildNodes(document, context, parents);
+ }
+ } catch (CoreException e) {
+ WebKbPlugin.getDefault().logError(e);
+ } catch (IOException e) {
+ WebKbPlugin.getDefault().logError(e);
} finally {
- releaseConnectedDocument(input);
- context.setDocument(null);
+ if (model != null) {
+ model.releaseFromRead();
+ }
}
+
+ if (context != null) {
+ if (context instanceof XmlContextImpl) {
+ IDocument contextDocument = ((XmlContextImpl) context).getDocument();
+ if (contextDocument != null) {
+ contextDocument.addDocumentListener(this);
+ }
+ }
+ saveConvext(context);
+ }
+
return context;
}
+
+ private ELContext createPageContextInstance(String contentType) {
+ String contextType = IncludeContextBuilder.getContextType(contentType);
+ if (XML_PAGE_CONTEXT_TYPE.equals(contextType)) {
+ return new XmlContextImpl();
+ } else if (JSP_PAGE_CONTEXT_TYPE.equals(contextType)) {
+ return new JspContextImpl();
+ } else if (FACELETS_PAGE_CONTEXT_TYPE.equals(contextType)) {
+ return new FaceletPageContextImpl();
+ }
+ return null;
+ }
/**
- * Creates a facelet context for given resource and offset.
- * @param file Facelet
- * @param offset
- * @return
+ * Sets up the context with namespaces and according libraries from the
TagLibraryManager
+ *
+ * @param node
+ * @param context
*/
- private static IFaceletPageContext createFaceletPageContext(IFile file, int offset) {
- FaceletPageContextImpl context = new FaceletPageContextImpl();
-
- IEditorInput input = new FileEditorInput(file);
- try {
- ELResolver[] elResolvers = ELResolverFactoryManager.getInstance().getResolvers(file);
- context.setResource(file);
- context.setDocument(getConnectedDocument(input));
- context.setElResolvers(elResolvers);
-
- setXMLNameSpaces(context, offset);
- setFaceletsNameSpaces(context, offset);
- context.setLibraries(getTagLibraries(context, offset));
- context.setResourceBundles(getResourceBundles(context));
-
- collectIncludedAdditionalInfo(context);
- } finally {
- releaseConnectedDocument(input);
- context.setDocument(null);
+ @SuppressWarnings({ "unchecked" })
+ private void fillJSPNameSpaces(JspContextImpl context) {
+ TLDCMDocumentManager manager =
TaglibController.getTLDCMDocumentManager(context.getDocument());
+ List trackers = (manager == null? null :
manager.getCMDocumentTrackers(context.getDocument().getLength() - 1));
+ for (int i = 0; trackers != null && i < trackers.size(); i++) {
+ TaglibTracker tt = (TaglibTracker)trackers.get(i);
+ final String prefix = tt.getPrefix() == null ? null : tt.getPrefix().trim();
+ final String uri = tt.getURI() == null ? null : tt.getURI().trim();
+ if (prefix != null && prefix.length() > 0 &&
+ uri != null && uri.length() > 0) {
+
+ IRegion region = new Region(0, context.getDocument().getLength());
+ INameSpace nameSpace = new NameSpace(
+ uri, prefix,
+ TagLibraryManager.getLibraries(
+ context.getResource().getProject(), uri));
+ context.addNameSpace(region, nameSpace);
+ }
}
- return context;
-
}
- /* Utility functions */
+ private void fillContextForChildNodes(IDOMNode parent, ELContext context,
List<String> parents) {
+ NodeList children = parent.getChildNodes();
+ for(int i = 0; children != null && i < children.getLength(); i++) {
+ Node child = children.item(i);
+ if (child instanceof IDOMNode) {
+ fillContextForNode((IDOMNode)child, context, parents);
+ fillContextForChildNodes((IDOMNode)child, context, parents);
+ }
+ }
+ }
- public static void collectIncludedAdditionalInfo(IPageContext context) {
- if (!(context instanceof IIncludedContextSupport) &&
- !(context instanceof ICSSContainerSupport))
+ private void fillContextForNode(IDOMNode node, ELContext context, List<String>
parents) {
+ if (context instanceof JspContextImpl && !(node instanceof IDOMElement)) {
+ // There is no any useful info for JSP in text nodes
return;
+ }
+
+ if (context instanceof XmlContextImpl && node instanceof IDOMElement) {
+ fillXMLNamespacesForNode((IDOMElement)node, (XmlContextImpl)context);
+ }
- IStructuredModel sModel = StructuredModelManager.getModelManager()
- .getExistingModelForRead(context.getDocument());
+ if ((context instanceof JspContextImpl ||
+ context instanceof FaceletPageContextImpl) &&
+ node instanceof IDOMElement) {
+ fillVarsForNode((IDOMElement)node, (ELContextImpl)context);
+ }
- try {
- if (sModel == null)
- return;
+ if (context instanceof FaceletPageContextImpl) {
+ // Insert here the initialization code for FaceletPage context elements which may
exist in Text nodes
+ }
+
+ if (context instanceof JspContextImpl && node instanceof IDOMElement) {
+ fillResourceBundlesForNode((IDOMElement)node, (JspContextImpl)context);
+ }
- Document xmlDocument = (sModel instanceof IDOMModel) ? ((IDOMModel) sModel)
- .getDocument()
- : null;
+ // There could be some context type to be initialized somehow that is different from
JSP or FaceletPage context
+ // Insert its on-node initialization code here
+
+ // The only Elements may have include/CSS Stylesheet links and other additional info
+ if (context instanceof IPageContext && node instanceof IDOMElement) {
+ fillAdditionalInfoForNode((IDOMElement)node, (IPageContext)context, parents);
+ }
+ }
- if (xmlDocument == null)
- return;
+ private void fillVarsForNode (IDOMElement node, ELContextImpl context) {
+ Var var = ElVarSearcher.findVar(node, ELParserUtil.getJbossFactory());
+ if (var != null) {
+ int start = ((IndexedRegion) node).getStartOffset();
+ int length = ((IndexedRegion) node).getLength();
- if (xmlDocument instanceof IDOMNode) {
- createIncludedAdditionalInfoForNode((IDOMNode)xmlDocument, context);
- }
- } finally {
- if (sModel != null) {
- sModel.releaseFromRead();
- }
- }
+ start = node.getStartOffset();
+ length = (node.hasEndTag() ? node
+ .getEndStructuredDocumentRegion()
+ .getEnd() : ((IDOMNode) node.getOwnerDocument()).getEndOffset() - 1 - start);
+ context.addVar(new Region(start, length), var);
+ }
}
- private static void createIncludedAdditionalInfoForNode(IDOMNode node, IPageContext
context) {
+
+ private void fillAdditionalInfoForNode(IDOMElement node, IPageContext context,
List<String> parents) {
String prefix = node.getPrefix() == null ? "" : node.getPrefix();
//$NON-NLS-1$
String tagName = node.getLocalName();
- if (node instanceof IDOMElement) {
- Map<String, List<INameSpace>> nsMap =
context.getNameSpaces(node.getStartOffset());
- String[] uris = getUrisByPrefix(nsMap, prefix);
-
- if (uris != null) {
- for (String uri : uris) {
- if (context instanceof IIncludedContextSupport) {
- String[] includeAttributes = IncludeContextBuilder.getIncludeAttributes(uri,
tagName);
- if (includeAttributes != null) {
- for (String attr : includeAttributes) {
- createIncludedContextFromAttribute((IDOMElement)node, attr, context);
- }
+ Map<String, List<INameSpace>> nsMap =
context.getNameSpaces(node.getStartOffset());
+ String[] uris = getUrisByPrefix(nsMap, prefix);
+
+ if (uris != null) {
+ for (String uri : uris) {
+ if (context instanceof IIncludedContextSupport) {
+ String[] includeAttributes = IncludeContextBuilder.getIncludeAttributes(uri,
tagName);
+ if (includeAttributes != null) {
+ List<String> newParentList = parents == null ? new ArrayList<String>()
: new ArrayList<String>(parents);
+ newParentList.add(context.getResource().getFullPath().toString());
+
+ for (String attr : includeAttributes) {
+ String fileName = node.getAttribute(attr);
+ if (fileName == null || fileName.trim().length() == 0)
+ continue;
+
+ IFile file = getFileFromProject(fileName, context.getResource());
+ if (file == null)
+ continue;
+
+ // Fix for JBIDE-5083 >>>
+ if (!checkCycling(parents, file))
+ continue;
+ // Fix for JBIDE-5083 <<<
+
+ ELContext includedContext = createPageContext(file, newParentList);
+ if (includedContext != null)
+ ((IIncludedContextSupport)context).addIncludedContext(includedContext);
}
}
- if (context instanceof ICSSContainerSupport) {
- if(IncludeContextBuilder.isCSSStyleSheetContainer(uri, tagName)) {
- createCSSStyleSheetFromElement((IDOMElement)node, (ICSSContainerSupport)context);
- } else {
- String[] cssAttributes = IncludeContextBuilder.getCSSStyleSheetAttributes(uri,
tagName);
- if (cssAttributes != null) {
- for (String attr : cssAttributes) {
- createCSSStyleSheetFromAttribute((IDOMElement)node, attr,
(ICSSContainerSupport)context);
- }
+ }
+ if (context instanceof ICSSContainerSupport) {
+ if(IncludeContextBuilder.isCSSStyleSheetContainer(uri, tagName)) {
+ fillCSSStyleSheetFromElement(node, (ICSSContainerSupport)context);
+ } else {
+ String[] cssAttributes = IncludeContextBuilder.getCSSStyleSheetAttributes(uri,
tagName);
+ if (cssAttributes != null) {
+ for (String attr : cssAttributes) {
+ fillCSSStyleSheetFromAttribute(node, attr, (ICSSContainerSupport)context);
}
}
- }
+ }
}
}
- }
-
- NodeList children = node.getChildNodes();
- for (int i = 0; children != null && i < children.getLength(); i++) {
- if (children.item(i) instanceof IDOMElement) {
- createIncludedAdditionalInfoForNode((IDOMElement)children.item(i), context);
+ }
+ }
+
+ private boolean checkCycling(List<String> parents, IFile resource) {
+ String resourceId = resource.getFullPath().toString();
+ if (parents != null) {
+ for (String parentId : parents) {
+ if (resourceId.equals(parentId))
+ return false;
}
}
+ return true;
}
- private static void createCSSStyleSheetFromAttribute(IDOMElement node,
+ /**
+ * Sets up the context with namespaces and according libraries for the node
+ * For the Facelet Context the methods adds an additional special namespace for
+ * CustomTagLibManager.FACELETS_UI_TAG_LIB_URI when
CustomTagLibManager.FACELETS_UI_TAG_LIB_URI
+ * is found in xmlns attributes
+ *
+ * @param node
+ * @param context
+ */
+ private void fillXMLNamespacesForNode(Element node, XmlContextImpl context) {
+ NamedNodeMap attrs = node.getAttributes();
+ 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();
+
+ prefix = prefix == null ? null : prefix.trim();
+ uri = uri == null ? null : uri.trim();
+
+ if (prefix != null && prefix.length() > 0
+ && uri != null && uri.length() > 0) {
+
+ 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);
+ }
+
+ Region region = new Region(start, length);
+ INameSpace nameSpace = new NameSpace(
+ uri, prefix,
+ TagLibraryManager.getLibraries(
+ context.getResource().getProject(), 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);
+ }
+ }
+ }
+ }
+ }
+
+ private void fillResourceBundlesForNode(IDOMElement node, JspContextImpl context) {
+ String name = node.getNodeName();
+ if (name == null) return;
+ if (!name.endsWith("loadBundle")) return; //$NON-NLS-1$
+ if (name.indexOf(':') == -1) return;
+ String prefix = name.substring(0, name.indexOf(':'));
+
+ Map<String, List<INameSpace>> ns =
context.getNameSpaces(node.getStartOffset());
+ if (!containsPrefix(ns, prefix)) return;
+
+ NamedNodeMap attributes = node.getAttributes();
+ if (attributes == null) return;
+ String basename = (attributes.getNamedItem("basename") == null ? null :
attributes.getNamedItem("basename").getNodeValue()); //$NON-NLS-1$
//$NON-NLS-2$
+ String var = (attributes.getNamedItem("var") == null ? null :
attributes.getNamedItem("var").getNodeValue()); //$NON-NLS-1$ //$NON-NLS-2$
+ if (basename == null || basename.length() == 0 ||
+ var == null || var.length() == 0)
+ return;
+
+ context.addResourceBundle(new ResourceBundle(basename, var));
+ }
+
+ private void fillCSSStyleSheetFromAttribute(IDOMElement node,
String attribute, ICSSContainerSupport context) {
CSSStyleSheetDescriptor descr = getSheetForTagAttribute(node, attribute);
if (descr != null)
context.addCSSStyleSheetDescriptor(descr);
}
- private static void createCSSStyleSheetFromElement(IDOMElement node,
+ private void fillCSSStyleSheetFromElement(IDOMElement node,
ICSSContainerSupport context) {
CSSStyleSheet sheet = getSheetForTag(node);
if (sheet != null)
@@ -258,12 +503,13 @@
this.sheet = sheet;
}
}
+
/**
*
* @param stylesContainer
* @return
*/
- private static CSSStyleSheetDescriptor getSheetForTagAttribute(final Node
stylesContainer, String attribute) {
+ private CSSStyleSheetDescriptor getSheetForTagAttribute(final Node stylesContainer,
String attribute) {
INodeNotifier notifier = (INodeNotifier) stylesContainer;
@@ -295,7 +541,7 @@
* @param stylesContainer
* @return
*/
- private static CSSStyleSheet getSheetForTag(final Node stylesContainer) {
+ private CSSStyleSheet getSheetForTag(final Node stylesContainer) {
INodeNotifier notifier = (INodeNotifier) stylesContainer;
@@ -311,428 +557,7 @@
return sheet;
}
- private static void createIncludedContextFromAttribute(IDOMElement node, String
attribute, IIncludedContextSupport context) {
- String fileName = node.getAttribute(attribute);
- if (fileName == null || fileName.trim().length() == 0)
- return;
-
- IFile file = getFileFromProject(fileName, context.getResource());
- if (file == null)
- return;
-
- // Fix for JBIDE-5083 >>>
- if (context.contextExistsInParents(file))
- return;
- // Fix for JBIDE-5083 <<<
-
- IStructuredModel sModel = null;
-
- try {
- sModel = StructuredModelManager.getModelManager()
- .getModelForRead(file);
- } catch (IOException e) {
- WebKbPlugin.getDefault().logError(e);
- } catch (CoreException e) {
- WebKbPlugin.getDefault().logError(e);
- }
-
- if (sModel == null)
- return;
-
- try {
- Document xmlDocument = (sModel instanceof IDOMModel) ?
- ((IDOMModel) sModel).getDocument() : null;
-
- if (xmlDocument == null)
- return;
-
- if (xmlDocument instanceof IDOMNode) {
- String contentType = sModel.getContentTypeIdentifier();
- IPageContext includedContext = PageContextFactory.createPageContext(file, ((IDOMNode)
xmlDocument).getEndOffset() - 1, contentType);
- if (includedContext != null)
- context.addIncludedContext(includedContext);
- }
- } finally {
- if (sModel != null) {
- sModel.releaseFromRead();
- }
- }
- }
-
- static Node findNodeForOffset(IDOMNode node, int offset) {
- if(node == null) return null;
- if (!node.contains(offset)) return null;
-
- if (node.hasChildNodes()) {
- // Try to find the node in children
- NodeList children = node.getChildNodes();
- for (int i = 0; children != null && i < children.getLength(); i++) {
- IDOMNode child = (IDOMNode)children.item(i);
- if (child.contains(offset)) {
- return findNodeForOffset(child, offset);
- }
- }
- }
- // Not found in children or nave no children
- if (node.hasAttributes()) {
- // Try to find in the node attributes
- NamedNodeMap attributes = node.getAttributes();
-
- for (int i = 0; attributes != null && i < attributes.getLength(); i++) {
- IDOMNode attr = (IDOMNode)attributes.item(i);
- if (attr.contains(offset)) {
- return attr;
- }
- }
- }
- // Return the node itself
- return node;
- }
-
- static Node findNodeForOffset(Node node, int offset) {
- return (node instanceof IDOMNode) ? findNodeForOffset((IDOMNode)node, offset) : null;
- }
-
- private static IDocument getConnectedDocument(IEditorInput input) {
- IDocumentProvider provider=
DocumentProviderRegistry.getDefault().getDocumentProvider(input);
- try {
- provider.connect(input);
- } catch (CoreException e) {
- WebKbPlugin.getDefault().logError(e);
- }
- return provider.getDocument(input);
- }
-
- private static void releaseConnectedDocument(IEditorInput input) {
- IDocumentProvider provider=
DocumentProviderRegistry.getDefault().getDocumentProvider(input);
- provider.disconnect(input);
- }
-
-
- private static Document getDocument(IFile file) {
- IStructuredModel sModel = null;
-
- try {
- sModel = StructuredModelManager.getModelManager()
- .getModelForRead(file);
- } catch (IOException e) {
- WebKbPlugin.getDefault().logError(e);
- } catch (CoreException e) {
- WebKbPlugin.getDefault().logError(e);
- }
-
- if (sModel == null)
- return null;
-
- try {
- return (sModel instanceof IDOMModel) ? ((IDOMModel) sModel)
- .getDocument()
- : null;
-
- } finally {
- if (sModel != null) {
- sModel.releaseFromRead();
- }
- }
- }
-
-
- /**
- * Collects the namespaces over the XML-page and sets them up to the context specified.
- *
- * @param context
- */
- private static void setXMLNameSpaces(XmlContextImpl context, int offset) {
- IStructuredModel sModel = null;
-
- try {
- sModel = StructuredModelManager.getModelManager()
- .getModelForRead(context.getResource());
- } catch (IOException e) {
- WebKbPlugin.getDefault().logError(e);
- } catch (CoreException e) {
- WebKbPlugin.getDefault().logError(e);
- }
-
- if (sModel == null)
- return;
-
- try {
- Document xmlDocument = (sModel instanceof IDOMModel) ? ((IDOMModel) sModel)
- .getDocument()
- : null;
-
- if (xmlDocument == null)
- return;
-
- Node n = findNodeForOffset(xmlDocument, offset);
- while (n != null) {
- if (!(n instanceof Element)) {
- if (n instanceof Attr) {
- n = ((Attr) n).getOwnerElement();
- } else {
- n = n.getParentNode();
- }
- continue;
- }
-
- NamedNodeMap attrs = n.getAttributes();
- 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$
- final String prefix = name.substring("xmlns:".length()); //$NON-NLS-1$
- final String uri = a.getValue();
- if (prefix != null && prefix.trim().length() > 0
- && uri != null && uri.trim().length() > 0) {
-
- int start = ((IndexedRegion) n).getStartOffset();
- int length = ((IndexedRegion) n).getLength();
-
- IDOMElement domElement = (n instanceof IDOMElement ? (IDOMElement) n
- : null);
- if (domElement != null) {
- start = domElement.getStartOffset();
- length = (domElement.hasEndTag() ? domElement
- .getEndStructuredDocumentRegion()
- .getEnd() : ((IDOMNode) xmlDocument).getEndOffset() - 1 - start);
- }
-
- Region region = new Region(start, length);
- INameSpace nameSpace = new NameSpace(uri.trim(),
- prefix.trim());
- context.addNameSpace(region, nameSpace);
- }
- }
- }
-
- n = n.getParentNode();
- }
-
- return;
- } finally {
- if (sModel != null) {
- sModel.releaseFromRead();
- }
- }
-
- }
-
- /**
- * Collects the namespaces over the JSP-page and sets them up to the context specified.
- *
- * @param context
- */
- private static void setJSPNameSpaces(JspContextImpl context, int offset) {
- TLDCMDocumentManager manager =
TaglibController.getTLDCMDocumentManager(context.getDocument());
- List trackers = (manager == null? null : manager.getCMDocumentTrackers(offset));
- for (int i = 0; trackers != null && i < trackers.size(); i++) {
- TaglibTracker tt = (TaglibTracker)trackers.get(i);
- final String prefix = tt.getPrefix();
- final String uri = tt.getURI();
- if (prefix != null && prefix.trim().length() > 0 &&
- uri != null && uri.trim().length() > 0) {
-
- IRegion region = new Region(0, context.getDocument().getLength());
- INameSpace nameSpace = new NameSpace(uri.trim(), prefix.trim());
- context.addNameSpace(region, nameSpace);
- }
- }
-
- return;
- }
-
- /**
- * Collects the namespaces over the Facelets-page and sets them up to the context
specified.
- *
- * @param context
- */
- private static void setFaceletsNameSpaces(FaceletPageContextImpl context, int offset) {
- IStructuredModel sModel = null;
-
- try {
- sModel = StructuredModelManager.getModelManager()
- .getModelForRead(context.getResource());
- } catch (IOException e) {
- WebKbPlugin.getDefault().logError(e);
- } catch (CoreException e) {
- WebKbPlugin.getDefault().logError(e);
- }
-
- if (sModel == null)
- return;
-
-
- try {
- Document xmlDocument = (sModel instanceof IDOMModel) ?
- ((IDOMModel) sModel).getDocument() : null;
-
- if (xmlDocument == null)
- return;
-
- Node n = findNodeForOffset(xmlDocument, offset);
- while (n != null) {
- if (!(n instanceof Element)) {
- if (n instanceof Attr) {
- n = ((Attr) n).getOwnerElement();
- } else {
- n = n.getParentNode();
- }
- continue;
- }
-
- NamedNodeMap attrs = n.getAttributes();
- 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$
- final String prefix = name.substring("xmlns:".length()); //$NON-NLS-1$
- final String uri = a.getValue();
- if (prefix != null && prefix.trim().length() > 0 &&
- uri != null && uri.trim().length() > 0) {
-
- int start = ((IndexedRegion)n).getStartOffset();
- int length = ((IndexedRegion)n).getLength();
-
- IDOMElement domElement = (n instanceof IDOMElement ? (IDOMElement)n : null);
- if (domElement != null) {
- start = domElement.getStartOffset();
- length = (domElement.hasEndTag() ?
- domElement.getEndStructuredDocumentRegion().getEnd() :
- ((IDOMNode) xmlDocument).getEndOffset() - 1 - start);
-
- }
-
- Region region = new Region(start, length);
- INameSpace nameSpace = new NameSpace(uri.trim(), prefix.trim());
- context.addNameSpace(region, nameSpace);
- if (CustomTagLibManager.FACELETS_UI_TAG_LIB_URI.equals(uri)) {
- nameSpace = new NameSpace(CustomTagLibManager.FACELETS_HTML_TAG_LIB_URI,
""); //$NON-NLS-1$
- context.addNameSpace(region, nameSpace);
- }
- }
- }
- }
-
- n = n.getParentNode();
- }
-
- return;
- } finally {
- if (sModel != null) {
- sModel.releaseFromRead();
- }
- }
- }
-
-
- private static final ITagLibrary[] EMPTY_LIBRARIES = new ITagLibrary[0];
- private static final IResourceBundle[] EMPTY_RESOURCE_BUNDLES = new IResourceBundle[0];
-
- /**
- * Returns the Tag Libraries for the namespaces collected in the context.
- * Important: The context must be created using createContext() method before using this
method.
- *
- * @param context The context object instance
- * @return
- */
- public static ITagLibrary[] getTagLibraries(IPageContext context, int offset) {
- Map<String, List<INameSpace>> nameSpaces = context.getNameSpaces(offset);
- if (nameSpaces == null || nameSpaces.isEmpty())
- return EMPTY_LIBRARIES;
-
- IProject project = context.getResource() == null ? null :
context.getResource().getProject();
- if (project == null)
- return EMPTY_LIBRARIES;
-
- List<ITagLibrary> tagLibraries = new ArrayList<ITagLibrary>();
- for (List<INameSpace> nameSpace : nameSpaces.values()) {
- for (INameSpace n : nameSpace) {
- ITagLibrary[] libs = TagLibriryManager.getLibraries(project, n.getURI());
- if (libs != null && libs.length > 0) {
- for (ITagLibrary lib : libs) {
- tagLibraries.add(lib);
- }
- }
- }
- }
- return (tagLibraries.isEmpty() ? EMPTY_LIBRARIES :
- (ITagLibrary[])tagLibraries.toArray(new ITagLibrary[tagLibraries.size()]));
- }
-
- /**
- * Returns the resource bundles
- *
- * @return
- */
- private static IResourceBundle[] getResourceBundles(IPageContext context) {
- List<IResourceBundle> list = new ArrayList<IResourceBundle>();
- IStructuredModel sModel = null;
-
- try {
- sModel =
StructuredModelManager.getModelManager().getModelForRead(context.getResource());
- } catch (IOException e) {
- WebKbPlugin.getDefault().logError(e);
- } catch (CoreException e) {
- WebKbPlugin.getDefault().logError(e);
- }
-
- if (sModel == null)
- return new IResourceBundle[0];
- try {
- Document dom = (sModel instanceof IDOMModel) ? ((IDOMModel) sModel).getDocument() :
null;
- if (dom != null) {
- Element element = dom.getDocumentElement();
- NodeList children = (NodeContainer)dom.getChildNodes();
- if (element != null) {
- for (int i = 0; children != null && i < children.getLength(); i++) {
- IDOMNode xmlnode = (IDOMNode)children.item(i);
- update((IDOMNode)xmlnode, context, list);
- }
- }
- }
- }
- finally {
- if (sModel != null) {
- sModel.releaseFromRead();
- }
- }
-
- return list.toArray(new IResourceBundle[list.size()]);
- }
-
- private static void update(IDOMNode element, IPageContext context,
List<IResourceBundle> list) {
- if (element != null) {
- registerBundleForNode(element, context, list);
- for (Node child = element.getFirstChild(); child != null; child =
child.getNextSibling()) {
- if (child instanceof IDOMNode) {
- update((IDOMNode)child, context, list);
- }
- }
- }
- }
- private static void registerBundleForNode(IDOMNode node, IPageContext context,
List<IResourceBundle> list) {
- if (node == null) return;
- String name = node.getNodeName();
- if (name == null) return;
- if (!name.endsWith("loadBundle")) return; //$NON-NLS-1$
- if (name.indexOf(':') == -1) return;
- String prefix = name.substring(0, name.indexOf(':'));
-
- Map<String, List<INameSpace>> ns =
context.getNameSpaces(node.getStartOffset());
- if (!containsPrefix(ns, prefix)) return;
-
- NamedNodeMap attributes = node.getAttributes();
- if (attributes == null) return;
- String basename = (attributes.getNamedItem("basename") == null ? null :
attributes.getNamedItem("basename").getNodeValue()); //$NON-NLS-1$
//$NON-NLS-2$
- String var = (attributes.getNamedItem("var") == null ? null :
attributes.getNamedItem("var").getNodeValue()); //$NON-NLS-1$ //$NON-NLS-2$
- if (basename == null || basename.length() == 0 ||
- var == null || var.length() == 0) return;
-
- list.add(new ResourceBundle(basename, var));
- }
-
- private static boolean containsPrefix(Map<String, List<INameSpace>> ns,
String prefix) {
+ private boolean containsPrefix(Map<String, List<INameSpace>> ns, String
prefix) {
for (List<INameSpace> n: ns.values()) {
for (INameSpace nameSpace : n) {
if(prefix.equals(nameSpace.getPrefix())) return true;
@@ -884,8 +709,13 @@
private static final String SHARP_PREFIX = "#{"; //$NON-NLS-1$
+ public static final String CONTEXT_PATH_EXPRESSION =
"^\\s*(\\#|\\$)\\{facesContext.externalContext.requestContextPath\\}";
//$NON-NLS-1$
+
// partly copied from org.jboss.tools.vpe.editor.util.ElService
- public static String findAndReplaceElVariable(String fileName){
+ private static String findAndReplaceElVariable(String fileName){
+ if (fileName != null)
+ fileName = fileName.replaceFirst(CONTEXT_PATH_EXPRESSION, "");
//$NON-NLS-1$
+
final IPath workspacePath = Platform.getLocation();
final ResourceReference[] gResources =
GlobalELReferenceList.getInstance().getAllResources(workspacePath);
@@ -956,15 +786,15 @@
public ICSSModel getModel() {
// Fix for JBIDE-5079 >>>
if (super.isValidAttribute()) {
- source = getSourceFromAttribute("href");
+ source = getSourceFromAttribute("href"); //$NON-NLS-1$
} else if (isValidAttribute()) {
source = getSourceFromAttribute(hrefAttrName);
} else {
return null;
}
-
ICSSModel model = retrieveModel();
setModel(model);
+// System.out.println("get CSS: " + source + " ==>> " +
(model == null ? "FAILED" : " SUCCESSFULL"));
return model;
}
@@ -1020,4 +850,125 @@
return null;
}
}
+
+ public void resourceChanged(IResourceChangeEvent event) {
+ if(cache == null || cache.size() == 0 || event == null || event.getDelta() == null)
return;
+ if(!checkDelta(event.getDelta())) return;
+ processDelta(event.getDelta());
+ }
+
+ private boolean checkDelta(IResourceDelta delta) {
+ IResource resource = delta.getResource();
+ if(resource == null) return false;
+ if(resource instanceof IWorkspaceRoot) {
+ IResourceDelta[] d = delta.getAffectedChildren();
+ return (d.length > 0 && checkDelta(d[0]));
+ }
+ return true;
+ }
+
+ private void processDelta(IResourceDelta delta) {
+ if(delta == null) return;
+ int kind = delta.getKind();
+ IResource resource = delta.getResource();
+
+ if(kind == IResourceDelta.CHANGED ||
+ kind == IResourceDelta.ADDED ||
+ kind == IResourceDelta.REMOVED ||
+ kind == IResourceDelta.CONTENT) {
+ cleanUpChachedResource(resource);
+// } else {
+// System.out.println("Resource modified [" + kind + "]: " +
resource.getFullPath());
+ }
+
+ IResourceDelta[] cs = delta.getAffectedChildren();
+ for (int i = 0; cs != null && i < cs.length; i++) {
+ processDelta(cs[i]);
+ }
+ return;
+ }
+
+ private void cleanUpChachedResource(IResource resource) {
+ if (resource instanceof IFile) {
+ synchronized (cache) {
+ ELContext removedContext = removeSavedContext((IFile)resource);
+ if (removedContext == null || removedContext.getResource() == null)
+ return;
+
+ // Remove all the contexts that are parent to the removed context
+ Collection<ELContext> contexts = cache.values();
+ if (contexts != null) {
+ for (ELContext context : contexts) {
+ if (isDependencyContext(context, (IFile)resource)) {
+ removeSavedContext((IFile)resource);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private boolean isDependencyContext(ELContext context, IFile resource) {
+ if (resource.equals(context.getResource())) {
+ return true;
+ }
+
+ if(context instanceof IIncludedContextSupport) {
+ List<ELContext> includedContexts =
((IIncludedContextSupport)context).getIncludedContexts();
+ if (includedContexts != null) {
+ for (ELContext includedContext : includedContexts) {
+ if (isDependencyContext(includedContext, resource))
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ @Override
+ protected void finalize() throws Throwable {
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ if (workspace != null) workspace.removeResourceChangeListener(this);
+
+ synchronized (cache) {
+ // Remove all the contexts that are parent to the removed context
+ Collection<ELContext> contexts = cache.values();
+ if (contexts != null) {
+ for (ELContext context : contexts) {
+ removeSavedContext(context.getResource());
+ }
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.eclipse.jface.text.IDocumentListener#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent)
+ */
+ public void documentAboutToBeChanged(DocumentEvent event) {
+ // Nothing to do
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.eclipse.jface.text.IDocumentListener#documentChanged(org.eclipse.jface.text.DocumentEvent)
+ */
+ public void documentChanged(DocumentEvent event) {
+ if (event.getDocument() == null)
+ return;
+
+ synchronized (cache) {
+ // Remove all the contexts that are parent to the removed context
+ Collection<ELContext> contexts = cache.values();
+ if (contexts != null) {
+ for (ELContext context : contexts) {
+ if (context instanceof XmlContextImpl &&
+ event.getDocument().equals(((XmlContextImpl)context).getDocument())) {
+ cleanUpChachedResource(context.getResource());
+ return;
+ }
+ }
+ }
+ }
+ }
}
\ No newline at end of file
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageProcessor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageProcessor.java 2009-11-24
04:57:39 UTC (rev 18796)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageProcessor.java 2009-11-24
13:56:15 UTC (rev 18797)
@@ -14,6 +14,7 @@
import java.util.HashMap;
import java.util.Map;
+import org.jboss.tools.common.el.core.resolver.ELContext;
import org.jboss.tools.common.el.core.resolver.ELResolver;
import org.jboss.tools.common.text.TextProposal;
import org.jboss.tools.jst.web.kb.internal.XmlContextImpl;
@@ -50,45 +51,48 @@
* (non-Javadoc)
* @see
org.jboss.tools.jst.web.kb.ProposalProcessor#getProposals(org.jboss.tools.jst.web.kb.KbQuery,
org.jboss.tools.jst.web.kb.PageContext)
*/
- public TextProposal[] getProposals(KbQuery query, IPageContext context) {
+ public TextProposal[] getProposals(KbQuery query, ELContext context) {
ArrayList<TextProposal> proposals = new ArrayList<TextProposal>();
if (!isQueryForELProposals(query, context)) {
- ITagLibrary[] libs = context.getLibraries();
- for (int i = 0; libs != null && i < libs.length; i++) {
- if(libs[i] instanceof IFacesConfigTagLibrary) {
- continue;
- }
- TextProposal[] libProposals = libs[i].getProposals(query, context);
- for (int j = 0; libProposals != null && j < libProposals.length; j++) {
- proposals.add(libProposals[j]);
- }
- }
- if (query.getType() == KbQuery.Type.ATTRIBUTE_VALUE) {
- Map<String, IAttribute> attrbMap = new HashMap<String, IAttribute>();
- for (TextProposal proposal : proposals) {
- if(proposal.getSource()!=null && proposal.getSource() instanceof IAttribute)
{
- IAttribute att = (IAttribute)proposal.getSource();
- attrbMap.put(att.getName(), att);
+ if(context instanceof IPageContext) {
+ IPageContext pageContext = (IPageContext)context;
+ ITagLibrary[] libs = pageContext.getLibraries();
+ for (int i = 0; libs != null && i < libs.length; i++) {
+ if(libs[i] instanceof IFacesConfigTagLibrary) {
+ continue;
}
+ TextProposal[] libProposals = libs[i].getProposals(query, pageContext);
+ for (int j = 0; libProposals != null && j < libProposals.length; j++) {
+ proposals.add(libProposals[j]);
+ }
}
- IAttribute[] attrs = getAttributes(query, context, false);
- for (int i = 0; i < attrs.length; i++) {
- attrbMap.put(attrs[i].getName(), attrs[i]);
- }
- for (int i = 0; i < componentExtensions.length; i++) {
- if(attrbMap.containsKey(componentExtensions[i].getName())) {
- TextProposal[] attProposals = componentExtensions[i].getProposals(query, context);
- for (int j = 0; j < attProposals.length; j++) {
- proposals.add(attProposals[j]);
+ if (query.getType() == KbQuery.Type.ATTRIBUTE_VALUE) {
+ Map<String, IAttribute> attrbMap = new HashMap<String, IAttribute>();
+ for (TextProposal proposal : proposals) {
+ if(proposal.getSource()!=null && proposal.getSource() instanceof
IAttribute) {
+ IAttribute att = (IAttribute)proposal.getSource();
+ attrbMap.put(att.getName(), att);
}
}
+ IAttribute[] attrs = getAttributes(query, pageContext, false);
+ for (int i = 0; i < attrs.length; i++) {
+ attrbMap.put(attrs[i].getName(), attrs[i]);
+ }
+ for (int i = 0; i < componentExtensions.length; i++) {
+ if(attrbMap.containsKey(componentExtensions[i].getName())) {
+ TextProposal[] attProposals = componentExtensions[i].getProposals(query,
pageContext);
+ for (int j = 0; j < attProposals.length; j++) {
+ proposals.add(attProposals[j]);
+ }
+ }
+ }
}
- }
- for (int i = 0; customTagLibs != null && i < customTagLibs.length; i++) {
- TextProposal[] libProposals = customTagLibs[i].getProposals(query, context);
- for (int j = 0; libProposals != null && j < libProposals.length; j++) {
- proposals.add(libProposals[j]);
+ for (int i = 0; customTagLibs != null && i < customTagLibs.length; i++) {
+ TextProposal[] libProposals = customTagLibs[i].getProposals(query, pageContext);
+ for (int j = 0; libProposals != null && j < libProposals.length; j++) {
+ proposals.add(libProposals[j]);
+ }
}
}
} else {
@@ -102,15 +106,17 @@
return proposals.toArray(new TextProposal[proposals.size()]);
}
- private boolean isQueryForELProposals(KbQuery query, IPageContext context) {
- if (query.getType() != KbQuery.Type.ATTRIBUTE_VALUE &&
- ((query.getType() != KbQuery.Type.TEXT ) || !(context instanceof IFaceletPageContext
|| context instanceof XmlContextImpl))) {
- return false;
+ private boolean isQueryForELProposals(KbQuery query, ELContext context) {
+ if (query.getType() == KbQuery.Type.ATTRIBUTE_VALUE ||
+ (query.getType() == KbQuery.Type.TEXT &&
+ (context instanceof IFaceletPageContext ||
+ context instanceof XmlContextImpl))) {
+ return (query.getValue() != null &&
+ (query.getValue().startsWith("#{") || //$NON-NLS-1$
+ query.getValue().startsWith("${"))); //$NON-NLS-1$
+
}
-
- return (query.getValue() != null &&
- (query.getValue().startsWith("#{") || //$NON-NLS-1$
- query.getValue().startsWith("${"))); //$NON-NLS-1$
+ return false;
}
/**
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/JspContextImpl.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/JspContextImpl.java 2009-11-24
04:57:39 UTC (rev 18796)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/JspContextImpl.java 2009-11-24
13:56:15 UTC (rev 18797)
@@ -14,34 +14,36 @@
import java.util.List;
import java.util.Map;
+import org.jboss.tools.common.el.core.resolver.ELContext;
+import org.jboss.tools.common.el.core.resolver.Var;
import org.jboss.tools.jst.web.kb.ICSSContainerSupport;
+import org.jboss.tools.jst.web.kb.IIncludedContextSupport;
import org.jboss.tools.jst.web.kb.IPageContext;
+import org.jboss.tools.jst.web.kb.IResourceBundle;
import org.jboss.tools.jst.web.kb.PageContextFactory.CSSStyleSheetDescriptor;
import org.jboss.tools.jst.web.kb.internal.taglib.NameSpace;
import org.jboss.tools.jst.web.kb.taglib.INameSpace;
-import org.w3c.dom.css.CSSStyleSheet;
+import org.jboss.tools.jst.web.kb.taglib.INameSpaceExtended;
+import org.jboss.tools.jst.web.kb.taglib.ITagLibrary;
/**
* JSP page context
* @author Alexey Kazakov
*/
-public class JspContextImpl extends XmlContextImpl implements ICSSContainerSupport {
- protected List<IPageContext> fIncludedContexts = null;
+public class JspContextImpl extends XmlContextImpl implements IPageContext,
IIncludedContextSupport, ICSSContainerSupport {
+ protected List<IResourceBundle> bundles;
+
+ protected List<ELContext> fIncludedContexts = null;
protected List<CSSStyleSheetDescriptor> fCSSStyleSheetDescriptors = null;
-
- @Override
- public void addIncludedContext(IPageContext includedContext) {
+
+ public void addIncludedContext(ELContext includedContext) {
if (fIncludedContexts == null) {
- fIncludedContexts = new ArrayList<IPageContext>();
+ fIncludedContexts = new ArrayList<ELContext>();
}
fIncludedContexts.add(includedContext);
- // Fix for JBIDE-5083 >>>
- includedContext.setParent(this);
- // Fix for JBIDE-5083 <<<
}
- @Override
- public List<IPageContext> getIncludedContexts() {
+ public List<ELContext> getIncludedContexts() {
return fIncludedContexts;
}
@@ -56,6 +58,127 @@
return superNameSpaces;
}
+
+ @Override
+ public Var[] getVars() {
+ Var[] thisVars = super.getVars();
+
+ List<Var> includedVars = new ArrayList<Var>();
+ List<ELContext> includedContexts = getIncludedContexts();
+ if (includedContexts != null) {
+ for (ELContext includedContext : includedContexts) {
+ Var[] vars = includedContext.getVars();
+ if (vars != null) {
+ for (Var b : vars) {
+ includedVars.add(b);
+ }
+ }
+ }
+ }
+
+ Var[] result = new Var[thisVars == null ? 0 : thisVars.length + includedVars.size()];
+ if (thisVars != null && thisVars.length > 0) {
+ System.arraycopy(thisVars, 0, result, 0, thisVars.length);
+ }
+ if (!includedVars.isEmpty()) {
+ System.arraycopy(includedVars.toArray(new ITagLibrary[includedVars.size()]), 0,
+ result, thisVars == null ? 0 : thisVars.length, includedVars.size());
+ }
+ return result;
+ }
+
+ @Override
+ public Var[] getVars(int offset) {
+ Var[] thisVars = super.getVars(offset);
+
+ List<Var> includedVars = new ArrayList<Var>();
+ List<ELContext> includedContexts = getIncludedContexts();
+ if (includedContexts != null) {
+ for (ELContext includedContext : includedContexts) {
+ Var[] vars = includedContext.getVars(offset);
+ if (vars != null) {
+ for (Var b : vars) {
+ includedVars.add(b);
+ }
+ }
+ }
+ }
+
+ Var[] result = new Var[thisVars == null ? 0 : thisVars.length + includedVars.size()];
+ if (thisVars != null && thisVars.length > 0) {
+ System.arraycopy(thisVars, 0, result, 0, thisVars.length);
+ }
+ if (!includedVars.isEmpty()) {
+ System.arraycopy(includedVars.toArray(new ITagLibrary[includedVars.size()]), 0,
+ result, thisVars == null ? 0 : thisVars.length, includedVars.size());
+ }
+ return result;
+ }
+
+ public ITagLibrary[] getLibraries() {
+ List<ITagLibrary> libraries = new ArrayList<ITagLibrary>();
+
+ for (Map<String, INameSpace> nsMap : nameSpaces.values()) {
+ for (INameSpace ns : nsMap.values()) {
+ if (ns instanceof INameSpaceExtended) {
+ ITagLibrary[] libs = ((INameSpaceExtended)ns).getTagLibraries();
+ if (libs != null) {
+ for(ITagLibrary lib : libs) {
+ libraries.add(lib);
+ }
+ }
+ }
+ }
+ }
+
+ List<ELContext> includedContexts = getIncludedContexts();
+ if (includedContexts != null) {
+ for (ELContext includedContext : includedContexts) {
+ ITagLibrary[] includedLibraries = includedContext instanceof IPageContext ?
((IPageContext)includedContext).getLibraries() : null;
+ if (includedLibraries != null) {
+ for (ITagLibrary lib : includedLibraries) {
+ libraries.add(lib);
+ }
+ }
+ }
+ }
+
+ return libraries.toArray(new ITagLibrary[libraries.size()]);
+ }
+
+ /**
+ * Adds resource bundle to the context
+ *
+ * @param bundle
+ */
+ public void addResourceBundle(IResourceBundle bundle) {
+ if (bundles == null) {
+ bundles = new ArrayList<IResourceBundle>();
+ }
+ bundles.add(bundle);
+ }
+
+ public IResourceBundle[] getResourceBundles() {
+ List<IResourceBundle> resourceBundles = new ArrayList<IResourceBundle>();
+ if (bundles != null) {
+ resourceBundles.addAll(bundles);
+ }
+
+ List<ELContext> includedContexts = getIncludedContexts();
+ if (includedContexts != null) {
+ for (ELContext includedContext : includedContexts) {
+ IResourceBundle[] includedBundles = includedContext instanceof IPageContext ?
((IPageContext)includedContext).getResourceBundles() : null;
+ if (includedBundles != null) {
+ for (IResourceBundle b : includedBundles) {
+ resourceBundles.add(b);
+ }
+ }
+ }
+ }
+
+ return (IResourceBundle[])resourceBundles.toArray(new
IResourceBundle[resourceBundles.size()]);
+ }
+
public void addCSSStyleSheetDescriptor(CSSStyleSheetDescriptor cssStyleSheetDescriptor)
{
if (fCSSStyleSheetDescriptors == null) {
fCSSStyleSheetDescriptors = new ArrayList<CSSStyleSheetDescriptor>();
@@ -72,9 +195,9 @@
}
}
- List<IPageContext> includedContexts = getIncludedContexts();
+ List<ELContext> includedContexts = getIncludedContexts();
if (includedContexts != null) {
- for (IPageContext includedContext : includedContexts) {
+ for (ELContext includedContext : includedContexts) {
if (includedContext instanceof ICSSContainerSupport) {
List<CSSStyleSheetDescriptor> includedSheetDescriptors =
((ICSSContainerSupport)includedContext).getCSSStyleSheetDescriptors();
if (includedSheetDescriptors != null) {
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/XmlContextImpl.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/XmlContextImpl.java 2009-11-24
04:57:39 UTC (rev 18796)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/XmlContextImpl.java 2009-11-24
13:56:15 UTC (rev 18797)
@@ -7,78 +7,42 @@
import java.util.Set;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.texteditor.DocumentProviderRegistry;
+import org.eclipse.ui.texteditor.IDocumentProvider;
import org.jboss.tools.common.el.core.resolver.ELContextImpl;
-import org.jboss.tools.jst.web.kb.IIncludedContextSupport;
-import org.jboss.tools.jst.web.kb.IPageContext;
-import org.jboss.tools.jst.web.kb.IResourceBundle;
+import org.jboss.tools.jst.web.kb.WebKbPlugin;
import org.jboss.tools.jst.web.kb.taglib.INameSpace;
-import org.jboss.tools.jst.web.kb.taglib.ITagLibrary;
-public class XmlContextImpl extends ELContextImpl implements IPageContext {
+public class XmlContextImpl extends ELContextImpl {
protected IDocument document;
- protected ITagLibrary[] libs;
+ private FileEditorInput editorInput;
// Fix for JBIDE-5097: It must be a map of <IRegion to Map of <NS-Prefix to
NS>>
protected Map<IRegion, Map<String, INameSpace>> nameSpaces = new
HashMap<IRegion, Map<String, INameSpace>>();
- protected IResourceBundle[] bundles;
- private IIncludedContextSupport parentContext = null;
- /*
- * (non-Javadoc)
- * @see org.jboss.tools.jst.web.kb.IPageContext#getLibraries()
+ /**
+ * Sets up the context resource and retrieves the document for the specified resource
*/
- public ITagLibrary[] getLibraries() {
- return libs;
- }
-
- public void setLibraries(ITagLibrary[] libs) {
- this.libs = libs;
- }
-
- /*
- * (non-Javadoc)
- * @see org.jboss.tools.jst.web.kb.IPageContext#getResourceBundles()
- */
- public IResourceBundle[] getResourceBundles() {
- List<IResourceBundle> resourceBundles = new ArrayList<IResourceBundle>();
- if (bundles != null) {
- for (IResourceBundle bundle : bundles) {
- resourceBundles.add(bundle);
+ @Override
+ public void setResource(IFile resource) {
+ super.setResource(resource);
+ if (this.document != null) {
+ if (!resource.equals(editorInput.getFile())) {
+ releaseConnectedDocument(editorInput);
+ editorInput = null;
}
}
+ if (editorInput == null)
+ editorInput = new FileEditorInput(resource);
- List<IPageContext> includedContexts = getIncludedContexts();
- if (includedContexts != null) {
- for (IPageContext includedContext : includedContexts) {
- IResourceBundle[] includedBundles = includedContext.getResourceBundles();
- if (includedBundles != null) {
- for (IResourceBundle includedBundle : includedBundles) {
- resourceBundles.add(includedBundle);
- }
- }
- }
- }
-
- return (IResourceBundle[])resourceBundles.toArray(new
IResourceBundle[resourceBundles.size()]);
+ document = getConnectedDocument(editorInput);
}
-
- /**
- * Sets resource bundles
- * @param bundles
- */
- public void setResourceBundles(IResourceBundle[] bundles) {
- this.bundles = bundles;
- }
-
- /**
- * @param document the document to set
- */
- public void setDocument(IDocument document) {
- this.document = document;
- }
-
+
/*
* (non-Javadoc)
* @see org.jboss.tools.jst.web.kb.PageContext#getDocument()
@@ -87,7 +51,10 @@
return document;
}
- /* (non-Javadoc)
+ /*
+ * TODO: the visibility must differ between 'include'-like and
'template'-like inclusion
+ *
+ * (non-Javadoc)
* @see org.jboss.tools.jst.web.kb.IPageContext#getNameSpaces(int)
*/
public Map<String, List<INameSpace>> getNameSpaces(int offset) {
@@ -152,40 +119,30 @@
nameSpaces.get(region).put(nameSpace.getPrefix(), nameSpace); // Fix for JBIDE-5097
}
- public void addIncludedContext(IPageContext includedContext) {
- throw new UnsupportedOperationException();
-
- }
- public List<IPageContext> getIncludedContexts() {
- return null;
- }
-
/**
- * (non-Javadoc)
- * @see
org.jboss.tools.jst.web.kb.IIncludedContextSupport#contextExistsInParents(org.eclipse.core.resources.IFile)
+ * Disconnects the editor input from the document provider
*/
- public boolean contextExistsInParents(IFile resource) {
- // Assuming that the resource must not be null here
- if (resource.equals(getResource()))
- return true;
-
- return getParent() == null ? false : getParent().contextExistsInParents(resource);
+ @Override
+ protected void finalize() throws Throwable {
+ if (editorInput != null) {
+ releaseConnectedDocument(editorInput);
+ }
+ super.finalize();
}
- /**
- * (non-Javadoc)
- * @see org.jboss.tools.jst.web.kb.IIncludedContextSupport#getParent()
- */
- public IIncludedContextSupport getParent() {
- return parentContext;
+ private IDocument getConnectedDocument(IEditorInput input) {
+ IDocumentProvider provider=
DocumentProviderRegistry.getDefault().getDocumentProvider(input);
+ try {
+ provider.connect(input);
+ } catch (CoreException e) {
+ WebKbPlugin.getDefault().logError(e);
+ }
+ return provider.getDocument(input);
}
-
- /**
- * (non-Javadoc)
- * @see
org.jboss.tools.jst.web.kb.IIncludedContextSupport#setParent(org.jboss.tools.jst.web.kb.IIncludedContextSupport)
- */
- public void setParent(IIncludedContextSupport parent) {
- parentContext = parent;
+
+ private void releaseConnectedDocument(IEditorInput input) {
+ IDocumentProvider provider=
DocumentProviderRegistry.getDefault().getDocumentProvider(input);
+ provider.disconnect(input);
}
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractAttribute.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractAttribute.java 2009-11-24
04:57:39 UTC (rev 18796)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractAttribute.java 2009-11-24
13:56:15 UTC (rev 18797)
@@ -13,12 +13,12 @@
import java.util.List;
import java.util.Properties;
+import org.jboss.tools.common.el.core.resolver.ELContext;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.project.ext.IValueInfo;
import org.jboss.tools.common.model.project.ext.event.Change;
import org.jboss.tools.common.model.project.ext.store.XMLStoreConstants;
import org.jboss.tools.common.text.TextProposal;
-import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.KbQuery;
import org.jboss.tools.jst.web.kb.internal.KbObject;
import org.jboss.tools.jst.web.kb.internal.KbXMLStoreConstants;
@@ -112,9 +112,9 @@
}
/* (non-Javadoc)
- * @see
org.jboss.tools.jst.web.kb.IProposalProcessor#getProposals(org.jboss.tools.jst.web.kb.KbQuery,
org.jboss.tools.jst.web.kb.IPageContext)
+ * @see
org.jboss.tools.jst.web.kb.IProposalProcessor#getProposals(org.jboss.tools.jst.web.kb.KbQuery,
org.jboss.tools.jst.web.kb.ELContext)
*/
- public TextProposal[] getProposals(KbQuery query, IPageContext context) {
+ public TextProposal[] getProposals(KbQuery query, ELContext context) {
return EMPTY_PROPOSAL_LIST;
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractComponent.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractComponent.java 2009-11-24
04:57:39 UTC (rev 18796)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractComponent.java 2009-11-24
13:56:15 UTC (rev 18797)
@@ -18,6 +18,7 @@
import java.util.Properties;
import java.util.Set;
+import org.jboss.tools.common.el.core.resolver.ELContext;
import org.jboss.tools.common.model.project.ext.IValueInfo;
import org.jboss.tools.common.model.project.ext.event.Change;
import org.jboss.tools.common.model.project.ext.store.XMLStoreConstants;
@@ -330,8 +331,11 @@
/* (non-Javadoc)
* @see
org.jboss.tools.jst.web.kb.IProposalProcessor#getProposals(org.jboss.tools.jst.web.kb.KbQuery,
org.jboss.tools.jst.web.kb.IPageContext)
*/
- public TextProposal[] getProposals(KbQuery query, IPageContext context) {
- IAttribute[] attributes = getAttributes(query, context);
+ public TextProposal[] getProposals(KbQuery query, ELContext context) {
+ if (!(context instanceof IPageContext))
+ return EMPTY_PROPOSAL_LIST;
+
+ IAttribute[] attributes = getAttributes(query, (IPageContext)context);
if(attributes == null || attributes.length == 0) {
return EMPTY_PROPOSAL_LIST;
}
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-11-24
04:57:39 UTC (rev 18796)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractTagLib.java 2009-11-24
13:56:15 UTC (rev 18797)
@@ -22,6 +22,7 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
+import org.jboss.tools.common.el.core.resolver.ELContext;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.project.ext.IValueInfo;
import org.jboss.tools.common.model.project.ext.event.Change;
@@ -389,10 +390,13 @@
/* (non-Javadoc)
* @see
org.jboss.tools.jst.web.kb.ProposalProcessor#getProposals(org.jboss.tools.jst.web.kb.KbQuery,
org.jboss.tools.jst.web.kb.PageContext)
*/
- public TextProposal[] getProposals(KbQuery query, IPageContext context) {
- List<String> prefixes = getPrefixes(query, context);
+ public TextProposal[] getProposals(KbQuery query, ELContext context) {
+ if (!(context instanceof IPageContext))
+ return EMPTY_PROPOSAL_LIST;
+
+ List<String> prefixes = getPrefixes(query, (IPageContext)context);
List<TextProposal> proposals = new ArrayList<TextProposal>();
- IComponent[] components = getComponentsByPrefixes(query, prefixes, context);
+ IComponent[] components = getComponentsByPrefixes(query, prefixes,
(IPageContext)context);
if(query.getType() == KbQuery.Type.TAG_NAME || query.getType() == KbQuery.Type.TEXT) {
for (int i = 0; i < components.length; i++) {
if(!(components[i] instanceof CustomComponentExtension)) {
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CSSClassProposalType.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CSSClassProposalType.java 2009-11-24
04:57:39 UTC (rev 18796)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CSSClassProposalType.java 2009-11-24
13:56:15 UTC (rev 18797)
@@ -18,9 +18,9 @@
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;
import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleRule;
+import org.jboss.tools.common.el.core.resolver.ELContext;
import org.jboss.tools.common.text.TextProposal;
import org.jboss.tools.jst.web.kb.ICSSContainerSupport;
-import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.KbQuery;
import org.jboss.tools.jst.web.kb.WebKbPlugin;
import org.jboss.tools.jst.web.kb.PageContextFactory.CSSStyleSheetDescriptor;
@@ -34,6 +34,7 @@
* @author Victor Rubezhny
*
*/
+@SuppressWarnings("restriction")
public class CSSClassProposalType extends CustomProposalType {
private static final String IMAGE_NAME = "EnumerationProposal.gif";
//$NON-NLS-1$
private static Image ICON;
@@ -44,7 +45,7 @@
Set<String> idList = new TreeSet<String>();
@Override
- protected void init(IPageContext context) {
+ protected void init(ELContext context) {
idList.clear();
if (context instanceof ICSSContainerSupport) {
ICSSContainerSupport cssSource = (ICSSContainerSupport)context;
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomProposalType.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomProposalType.java 2009-11-24
04:57:39 UTC (rev 18796)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomProposalType.java 2009-11-24
13:56:15 UTC (rev 18797)
@@ -10,8 +10,8 @@
******************************************************************************/
package org.jboss.tools.jst.web.kb.internal.taglib;
+import org.jboss.tools.common.el.core.resolver.ELContext;
import org.jboss.tools.common.text.TextProposal;
-import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.IProposalProcessor;
import org.jboss.tools.jst.web.kb.KbQuery;
@@ -22,9 +22,9 @@
protected Param[] params;
protected String type;
- protected IPageContext context;
+ protected ELContext context;
- protected abstract void init(IPageContext context);
+ protected abstract void init(ELContext context);
/**
* @return the type
@@ -60,7 +60,7 @@
/* (non-Javadoc)
* @see
org.jboss.tools.jst.web.kb.IProposalProcessor#getProposals(org.jboss.tools.jst.web.kb.KbQuery,
org.jboss.tools.jst.web.kb.IPageContext)
*/
- public TextProposal[] getProposals(KbQuery query, IPageContext context) {
+ public TextProposal[] getProposals(KbQuery query, ELContext context) {
this.context = context;
init(context);
return getProposals(query);
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomProposalTypeFactory.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomProposalTypeFactory.java 2009-11-24
04:57:39 UTC (rev 18796)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomProposalTypeFactory.java 2009-11-24
13:56:15 UTC (rev 18797)
@@ -10,7 +10,6 @@
******************************************************************************/
package org.jboss.tools.jst.web.kb.internal.taglib;
-import org.jboss.tools.jst.web.kb.WebKbPlugin;
/**
* @author Alexey Kazakov
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomTagLibAttribute.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomTagLibAttribute.java 2009-11-24
04:57:39 UTC (rev 18796)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CustomTagLibAttribute.java 2009-11-24
13:56:15 UTC (rev 18797)
@@ -13,8 +13,8 @@
import java.util.ArrayList;
import java.util.List;
+import org.jboss.tools.common.el.core.resolver.ELContext;
import org.jboss.tools.common.text.TextProposal;
-import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.KbQuery;
import org.jboss.tools.jst.web.kb.taglib.IComponent;
@@ -65,7 +65,7 @@
* @see
org.jboss.tools.jst.web.kb.internal.taglib.AbstractAttribute#getProposals(org.jboss.tools.jst.web.kb.KbQuery,
org.jboss.tools.jst.web.kb.IPageContext)
*/
@Override
- public TextProposal[] getProposals(KbQuery query, IPageContext context) {
+ public TextProposal[] getProposals(KbQuery query, ELContext context) {
CustomProposalType[] types = getProposals();
if(types.length==0) {
return EMPTY_PROPOSAL_LIST;
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/EnumerationProposalType.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/EnumerationProposalType.java 2009-11-24
04:57:39 UTC (rev 18796)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/EnumerationProposalType.java 2009-11-24
13:56:15 UTC (rev 18797)
@@ -15,8 +15,8 @@
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;
+import org.jboss.tools.common.el.core.resolver.ELContext;
import org.jboss.tools.common.text.TextProposal;
-import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.KbQuery;
import org.jboss.tools.jst.web.kb.WebKbPlugin;
@@ -59,6 +59,6 @@
* @see
org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType#init(org.jboss.tools.jst.web.kb.IPageContext)
*/
@Override
- protected void init(IPageContext context) {
+ protected void init(ELContext context) {
}
}
\ No newline at end of file
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ExtendedProposalType.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ExtendedProposalType.java 2009-11-24
04:57:39 UTC (rev 18796)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ExtendedProposalType.java 2009-11-24
13:56:15 UTC (rev 18797)
@@ -1,7 +1,7 @@
package org.jboss.tools.jst.web.kb.internal.taglib;
+import org.jboss.tools.common.el.core.resolver.ELContext;
import org.jboss.tools.common.text.TextProposal;
-import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.KbQuery;
public class ExtendedProposalType extends CustomProposalType {
@@ -14,7 +14,7 @@
}
@Override
- protected void init(IPageContext context) {
+ protected void init(ELContext context) {
}
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/FaceletsJsfCProposalType.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/FaceletsJsfCProposalType.java 2009-11-24
04:57:39 UTC (rev 18796)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/FaceletsJsfCProposalType.java 2009-11-24
13:56:15 UTC (rev 18797)
@@ -18,6 +18,7 @@
import org.eclipse.swt.graphics.Image;
import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
+import org.jboss.tools.common.el.core.resolver.ELContext;
import org.jboss.tools.common.text.TextProposal;
import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.KbQuery;
@@ -30,6 +31,7 @@
/**
* @author Alexey Kazakov
*/
+@SuppressWarnings("restriction")
public class FaceletsJsfCProposalType extends CustomProposalType {
private static Image ICON;
@@ -39,6 +41,9 @@
*/
@Override
public TextProposal[] getProposals(KbQuery query) {
+ if (!(context instanceof IPageContext))
+ return EMPTY_PROPOSAL_LIST;
+
// trim first spaces
String value = query.getValue();
while(true) {
@@ -56,7 +61,7 @@
IComponent[] components = null;
List<TextProposal> proposals = null;
- components = PageProcessor.getInstance().getComponents(kbQuery, context);
+ components = PageProcessor.getInstance().getComponents(kbQuery,
(IPageContext)context);
if(components.length==0) {
return EMPTY_PROPOSAL_LIST;
}
@@ -69,7 +74,7 @@
}
List<String> pfx = prefixes.get(lib.getURI());
if(pfx==null) {
- pfx = getPrefixes(context, components[i], kbQuery);
+ pfx = getPrefixes((IPageContext)context, components[i], kbQuery);
prefixes.put(lib.getURI(), pfx);
}
for (String prefix : pfx) {
@@ -121,6 +126,6 @@
* @see
org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType#init(org.jboss.tools.jst.web.kb.IPageContext)
*/
@Override
- protected void init(IPageContext context) {
+ protected void init(ELContext context) {
}
}
\ No newline at end of file
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/FacetNameProposalType.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/FacetNameProposalType.java 2009-11-24
04:57:39 UTC (rev 18796)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/FacetNameProposalType.java 2009-11-24
13:56:15 UTC (rev 18797)
@@ -15,6 +15,7 @@
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;
+import org.jboss.tools.common.el.core.resolver.ELContext;
import org.jboss.tools.common.text.TextProposal;
import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.KbQuery;
@@ -31,13 +32,16 @@
private static final String IMAGE_NAME = "EnumerationProposal.gif";
//$NON-NLS-1$
private static Image ICON;
- private IPageContext context;
+ private ELContext context;
/* (non-Javadoc)
* @see
org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType#getProposals(org.jboss.tools.jst.web.kb.KbQuery)
*/
@Override
public TextProposal[] getProposals(KbQuery query) {
+ if (!(context instanceof IPageContext))
+ return EMPTY_PROPOSAL_LIST;
+
String[] parentTags = query.getParentTags();
if(parentTags.length>1) {
String parentTag = parentTags[parentTags.length-2];
@@ -46,8 +50,8 @@
newQuery.setMask(false);
newQuery.setType(KbQuery.Type.TAG_NAME);
newQuery.setValue(parentTag);
- PageProcessor.getInstance().getComponents(query, context);
- ITagLibrary[] libs = context.getLibraries();
+ PageProcessor.getInstance().getComponents(query, (IPageContext)context);
+ ITagLibrary[] libs = ((IPageContext)context).getLibraries();
for (ITagLibrary l : libs) {
if(l instanceof IFaceletTagLibrary) {
//TODO
@@ -76,7 +80,7 @@
* @see
org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType#init(org.jboss.tools.jst.web.kb.IPageContext)
*/
@Override
- protected void init(IPageContext context) {
+ protected void init(ELContext context) {
this.context = context;
}
}
\ No newline at end of file
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/IDProposalType.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/IDProposalType.java 2009-11-24
04:57:39 UTC (rev 18796)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/IDProposalType.java 2009-11-24
13:56:15 UTC (rev 18797)
@@ -21,6 +21,7 @@
import org.eclipse.wst.sse.core.StructuredModelManager;
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.jboss.tools.common.el.core.resolver.ELContext;
import org.jboss.tools.common.text.TextProposal;
import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.KbQuery;
@@ -30,6 +31,7 @@
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+@SuppressWarnings("restriction")
public class IDProposalType extends CustomProposalType {
private static final String IMAGE_NAME = "EnumerationProposal.gif";
//$NON-NLS-1$
private static Image ICON;
@@ -40,9 +42,12 @@
Set<String> idList = new TreeSet<String>();
@Override
- protected void init(IPageContext context) {
+ protected void init(ELContext context) {
idList.clear();
- IDocument document = context.getDocument();
+ if (!(context instanceof IPageContext))
+ return;
+
+ IDocument document = ((IPageContext)context).getDocument();
IStructuredModel sModel =
StructuredModelManager.getModelManager().getExistingModelForRead(document);
try {
if (sModel != null) {
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ModelProposalType.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ModelProposalType.java 2009-11-24
04:57:39 UTC (rev 18796)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ModelProposalType.java 2009-11-24
13:56:15 UTC (rev 18797)
@@ -10,10 +10,10 @@
******************************************************************************/
package org.jboss.tools.jst.web.kb.internal.taglib;
+import org.jboss.tools.common.el.core.resolver.ELContext;
import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.model.project.IModelNature;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
-import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
/**
@@ -28,7 +28,7 @@
* @see
org.jboss.tools.jst.web.kb.internal.taglib.CustomProposalType#init(org.jboss.tools.jst.web.kb.IPageContext)
*/
@Override
- protected void init(IPageContext context) {
+ protected void init(ELContext context) {
provider = WebPromptingProvider.getInstance();
IModelNature nature =
EclipseResourceUtil.getModelNature(context.getResource().getProject());
if(nature!=null) {
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/NameSpace.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/NameSpace.java 2009-11-24
04:57:39 UTC (rev 18796)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/NameSpace.java 2009-11-24
13:56:15 UTC (rev 18797)
@@ -12,16 +12,19 @@
package org.jboss.tools.jst.web.kb.internal.taglib;
import org.jboss.tools.jst.web.kb.taglib.INameSpace;
+import org.jboss.tools.jst.web.kb.taglib.INameSpaceExtended;
+import org.jboss.tools.jst.web.kb.taglib.ITagLibrary;
/**
- * The Namespace holder object
+ * The Namespace and TagLibrary holder object
*
* @author Victor Rubezhny
*
*/
-public class NameSpace implements INameSpace {
+public class NameSpace implements INameSpaceExtended {
private String fPrefix;
private String fUri;
+ private ITagLibrary[] fTagLibraries;
/**
* Constructs NameSpace object
@@ -30,8 +33,19 @@
* @param prefix
*/
public NameSpace(String uri, String prefix) {
+ this(uri, prefix, null);
+ }
+
+ /**
+ * Constructs NameSpace object
+ *
+ * @param uri
+ * @param prefix
+ */
+ public NameSpace(String uri, String prefix, ITagLibrary[] libraries) {
this.fUri = uri;
this.fPrefix = prefix;
+ this.fTagLibraries = libraries;
}
/**
@@ -49,7 +63,19 @@
}
/**
+ * Returns TagLibrary for the Namespace object
+ *
+ * @return
+ */
+ public ITagLibrary[] getTagLibraries() {
+ return fTagLibraries;
+ }
+
+ /**
* Compares the NameSpace objects
+ * The method doesn't take in account the library
+ *
+ * @return
*/
public boolean equals(Object obj) {
if (obj instanceof INameSpace) {
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ResourcePathProposalType.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ResourcePathProposalType.java 2009-11-24
04:57:39 UTC (rev 18796)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/ResourcePathProposalType.java 2009-11-24
13:56:15 UTC (rev 18797)
@@ -24,11 +24,11 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;
+import org.jboss.tools.common.el.core.resolver.ELContext;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.filesystems.FileSystemsHelper;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.common.text.TextProposal;
-import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.KbQuery;
import org.jboss.tools.jst.web.kb.WebKbPlugin;
@@ -51,7 +51,7 @@
PAGE_FILE_EXTENSIONS.add(pages[i]);
}
}
- private static String PATH_ADDITION = "pathAddition";
+ private static String PATH_ADDITION = "pathAddition"; //$NON-NLS-1$
private IContainer webRootResource;
private Set<String> extensions;
@@ -61,7 +61,7 @@
* @see
org.jboss.tools.jst.web.kb.internal.taglib.ModelProposalType#init(org.jboss.tools.jst.web.kb.IPageContext)
*/
@Override
- protected void init(IPageContext context) {
+ protected void init(ELContext context) {
super.init(context);
if(xModel != null) {
XModelObject webInf = FileSystemsHelper.getWebInf(xModel);
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/INameSpace.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/INameSpace.java 2009-11-24
04:57:39 UTC (rev 18796)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/INameSpace.java 2009-11-24
13:56:15 UTC (rev 18797)
@@ -24,4 +24,5 @@
* @return prefix
*/
String getPrefix();
+
}
\ No newline at end of file
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/INameSpaceExtended.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/INameSpaceExtended.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/INameSpaceExtended.java 2009-11-24
13:56:15 UTC (rev 18797)
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.kb.taglib;
+
+/**
+ *
+ * @author Victor Rubezhny
+ *
+ */
+public interface INameSpaceExtended extends INameSpace {
+ /**
+ *
+ * @return
+ */
+ ITagLibrary[] getTagLibraries();
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/INameSpaceExtended.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/TagLibraryManager.java
(from rev 18686,
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/TagLibriryManager.java)
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/TagLibraryManager.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/TagLibraryManager.java 2009-11-24
13:56:15 UTC (rev 18797)
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.kb.taglib;
+
+import org.eclipse.core.resources.IProject;
+import org.jboss.tools.jst.web.kb.IKbProject;
+import org.jboss.tools.jst.web.kb.KbProjectFactory;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class TagLibraryManager {
+
+ /**
+ * Returns all tag libraries which have given URI and which are available in the
project.
+ * @param project
+ * @param uri
+ * @return
+ */
+ public static ITagLibrary[] getLibraries(IProject project, String uri) {
+ IKbProject kbProject = KbProjectFactory.getKbProject(project, true);
+ if(kbProject == null) {
+ return new ITagLibrary[0];
+ }
+ return kbProject.getTagLibraries(uri);
+ }
+}
\ No newline at end of file
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/TagLibraryManager.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/TagLibriryManager.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/TagLibriryManager.java 2009-11-24
04:57:39 UTC (rev 18796)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/taglib/TagLibriryManager.java 2009-11-24
13:56:15 UTC (rev 18797)
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.web.kb.taglib;
-
-import org.eclipse.core.resources.IProject;
-import org.jboss.tools.jst.web.kb.IKbProject;
-import org.jboss.tools.jst.web.kb.KbProjectFactory;
-import org.jboss.tools.jst.web.kb.WebKbPlugin;
-
-/**
- * @author Alexey Kazakov
- */
-public class TagLibriryManager {
-
- /**
- * Returns all tag libraries which have given URI and which are available in the
project.
- * @param project
- * @param uri
- * @return
- */
- public static ITagLibrary[] getLibraries(IProject project, String uri) {
- IKbProject kbProject = KbProjectFactory.getKbProject(project, true);
- if(kbProject == null) {
- return new ITagLibrary[0];
- }
- return kbProject.getTagLibraries(uri);
- }
-}
\ No newline at end of file
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidationMessages.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidationMessages.java 2009-11-24
04:57:39 UTC (rev 18796)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidationMessages.java 2009-11-24
13:56:15 UTC (rev 18797)
@@ -11,7 +11,6 @@
package org.jboss.tools.seam.internal.core.validation;
import org.eclipse.osgi.util.NLS;
-import org.jboss.tools.jsf.web.validation.JSFValidationMessages;
/**
* @author Alexey Kazakov