JBoss Tools SVN: r17806 - trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib.
by jbosstools-commits@lists.jboss.org
Author: vrubezhny
Date: 2009-09-29 12:53:34 -0400 (Tue, 29 Sep 2009)
New Revision: 17806
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/HTMLTagLibrary.java
Log:
JBIDE-4923: Code assist for EL doesn't work in XML files.
Issue is fixed
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/HTMLTagLibrary.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/HTMLTagLibrary.java 2009-09-29 16:48:35 UTC (rev 17805)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/HTMLTagLibrary.java 2009-09-29 16:53:34 UTC (rev 17806)
@@ -13,11 +13,13 @@
import java.io.File;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import java.util.Set;
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;
+import org.jboss.tools.jst.web.kb.taglib.INameSpace;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
@@ -65,13 +67,32 @@
return result.toArray(new IComponent[0]);
}
+ private static final List<String> EMPTY_PREFIXES = new ArrayList<String>();
/*
* (non-Javadoc)
* @see org.jboss.tools.jst.web.kb.internal.taglib.AbstractTagLib#getPrefixes(org.jboss.tools.jst.web.kb.KbQuery, org.jboss.tools.jst.web.kb.IPageContext)
*/
@Override
protected List<String> getPrefixes(KbQuery query, IPageContext context) {
- return null;
+
+ Map<String, List<INameSpace>> nameSpaces = context.getNameSpaces(query.getOffset());
+ if(nameSpaces!=null) {
+ List<INameSpace> nameSpace = nameSpaces.get(getURI());
+ if(nameSpace!=null) {
+ for (INameSpace n : nameSpace) {
+ String sPrefix = n.getPrefix();
+
+ // JBIDE-4923: This fake URI is added by JSP- or FaceletPage- Content Assist Processors
+ // due to indicate that HTML schemas are to be used is query.
+ // For the Xml Content Assist Processor we need to return an empty prefix list (but not null)
+ // due to prevent HTML schemas usage
+ //
+ if ("".equals(sPrefix)) //$NON-NLS-1$
+ return null;
+ }
+ }
+ }
+ return EMPTY_PREFIXES;
}
/*
15 years, 3 months
JBoss Tools SVN: r17805 - trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal.
by jbosstools-commits@lists.jboss.org
Author: vrubezhny
Date: 2009-09-29 12:48:35 -0400 (Tue, 29 Sep 2009)
New Revision: 17805
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/JspContextImpl.java
Log:
JBIDE-4923: Code assist for EL doesn't work in XML files.
Issue is fixed
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-09-29 16:48:17 UTC (rev 17804)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/JspContextImpl.java 2009-09-29 16:48:35 UTC (rev 17805)
@@ -11,20 +11,11 @@
package org.jboss.tools.jst.web.kb.internal;
import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Set;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.jboss.tools.common.el.core.resolver.ELContextImpl;
-import org.jboss.tools.jst.web.kb.IPageContext;
-import org.jboss.tools.jst.web.kb.IResourceBundle;
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;
/**
* JSP page context
15 years, 3 months
JBoss Tools SVN: r17804 - in trunk/seam/plugins: org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/reveng and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2009-09-29 12:48:17 -0400 (Tue, 29 Sep 2009)
New Revision: 17804
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/Seam2ProjectCreator.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/reveng/JDBCTablesColumnsReader.java
Log:
Code clean up, catch(Exception) blocks were fixed
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/Seam2ProjectCreator.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/Seam2ProjectCreator.java 2009-09-29 16:46:33 UTC (rev 17803)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/Seam2ProjectCreator.java 2009-09-29 16:48:17 UTC (rev 17804)
@@ -283,7 +283,10 @@
}
try {
new FormatProcessorXML().formatFile((IFile) jbossAppXml);
- } catch (Exception ignore) {
+ } catch (IOException e) {
+
+ } catch (CoreException e) {
+
}
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/reveng/JDBCTablesColumnsReader.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/reveng/JDBCTablesColumnsReader.java 2009-09-29 16:46:33 UTC (rev 17803)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/reveng/JDBCTablesColumnsReader.java 2009-09-29 16:48:17 UTC (rev 17804)
@@ -100,12 +100,8 @@
}
}
} finally {
- try {
- if (null != tableIterator) {
- metadataDialect.close(tableIterator);
- }
- } catch (Exception ignore) {
- SeamGuiPlugin.getPluginLog().logError(ignore);
+ if (null != tableIterator) {
+ metadataDialect.close(tableIterator);
}
}
}
@@ -148,12 +144,8 @@
tcc.addColumnName(catalogName, schemaName, quote(tableName), columnName);
}
} finally {
- try {
- if (null != columnIterator) {
- metadataDialect.close(columnIterator);
- }
- } catch (Exception ignore) {
- SeamGuiPlugin.getPluginLog().logError(ignore);
+ if (null != columnIterator) {
+ metadataDialect.close(columnIterator);
}
}
}
15 years, 3 months
JBoss Tools SVN: r17803 - trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal.
by jbosstools-commits@lists.jboss.org
Author: vrubezhny
Date: 2009-09-29 12:46:33 -0400 (Tue, 29 Sep 2009)
New Revision: 17803
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/XmlContextImpl.java
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/JspContextImpl.java
Log:
JBIDE-4923: Code assist for EL doesn't work in XML files.
Issue is fixed
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-09-29 16:45:41 UTC (rev 17802)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/JspContextImpl.java 2009-09-29 16:46:33 UTC (rev 17803)
@@ -11,6 +11,7 @@
package org.jboss.tools.jst.web.kb.internal;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -21,6 +22,7 @@
import org.jboss.tools.common.el.core.resolver.ELContextImpl;
import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.IResourceBundle;
+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;
@@ -28,117 +30,20 @@
* JSP page context
* @author Alexey Kazakov
*/
-public class JspContextImpl extends ELContextImpl implements IPageContext {
- protected IDocument document;
- protected ITagLibrary[] libs;
- protected Map<IRegion, Map<String, INameSpace>> nameSpaces = new HashMap<IRegion, Map<String, INameSpace>>();
- protected IResourceBundle[] bundles;
+public class JspContextImpl extends XmlContextImpl {
- /*
- * (non-Javadoc)
- * @see org.jboss.tools.jst.web.kb.IPageContext#getLibraries()
- */
- 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() {
- return bundles;
- }
-
- /**
- * 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()
- */
- public IDocument getDocument() {
- return document;
- }
-
- /* (non-Javadoc)
- * @see org.jboss.tools.jst.web.kb.IPageContext#getNameSpaces(int)
- */
+
+
+ @Override
public Map<String, List<INameSpace>> getNameSpaces(int offset) {
- Map<String, List<INameSpace>> result = new HashMap<String, List<INameSpace>>();
- Map<INameSpace, IRegion> namespaceToRegions = new HashMap<INameSpace, IRegion>();
-
- for (IRegion region : nameSpaces.keySet()) {
- if(offset>=region.getOffset() && offset<=region.getOffset() + region.getLength()) {
- Map<String, INameSpace> namespaces = nameSpaces.get(region);
- if (namespaces != null) {
- for (INameSpace ns : namespaces.values()) {
- INameSpace existingNameSpace = findNameSpaceByPrefix(namespaceToRegions.keySet(), ns.getPrefix());
- IRegion existingRegion = namespaceToRegions.get(existingNameSpace);
- if (existingRegion != null) {
- // Perform visibility check for region
- if (region.getOffset() > existingRegion.getOffset()) {
- // Replace existingNS by this ns
- namespaceToRegions.remove(existingNameSpace);
- namespaceToRegions.put(ns, region);
- }
- } else {
- namespaceToRegions.put(ns, region);
- }
- }
- }
- }
- }
-
- for (INameSpace ns : namespaceToRegions.keySet()) {
- List<INameSpace> list = result.get(ns.getURI());
- if(list==null) {
- list = new ArrayList<INameSpace>();
- }
- list.add(ns);
- result.put(ns.getURI(), list);
- }
-
- return result;
+ Map<String, List<INameSpace>> superNameSpaces = super.getNameSpaces(offset);
+
+ List<INameSpace> fakeForHtmlNS = new ArrayList<INameSpace>();
+ fakeForHtmlNS.add(new NameSpace("", "")); //$NON-NLS-1$ //$NON-NLS-2$
+ superNameSpaces.put("", fakeForHtmlNS); //$NON-NLS-1$
+
+ return superNameSpaces;
}
-
- private INameSpace findNameSpaceByPrefix(Set<INameSpace> namespaces, String prefix) {
- if (namespaces != null && prefix != null) {
- for (INameSpace ns : namespaces) {
- if (prefix.equals(ns.getPrefix())) {
- return ns;
- }
- }
- }
- return null;
- }
-
- /**
- * Adds new name space to the context
- * @param region
- * @param name space
- */
- public void addNameSpace(IRegion region, INameSpace nameSpace) {
- if (nameSpaces.get(region) == null) {
- Map<String, INameSpace> nameSpaceMap = new HashMap<String, INameSpace>();
- nameSpaces.put(region, nameSpaceMap);
- }
- nameSpaces.get(region).put(nameSpace.getURI(), nameSpace);
- }
+
+
}
\ No newline at end of file
Added: 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 (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/XmlContextImpl.java 2009-09-29 16:46:33 UTC (rev 17803)
@@ -0,0 +1,130 @@
+package org.jboss.tools.jst.web.kb.internal;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.jboss.tools.common.el.core.resolver.ELContextImpl;
+import org.jboss.tools.jst.web.kb.IPageContext;
+import org.jboss.tools.jst.web.kb.IResourceBundle;
+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 {
+ protected IDocument document;
+ protected ITagLibrary[] libs;
+ protected Map<IRegion, Map<String, INameSpace>> nameSpaces = new HashMap<IRegion, Map<String, INameSpace>>();
+ protected IResourceBundle[] bundles;
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.IPageContext#getLibraries()
+ */
+ 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() {
+ return bundles;
+ }
+
+ /**
+ * 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()
+ */
+ public IDocument getDocument() {
+ return document;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.IPageContext#getNameSpaces(int)
+ */
+ public Map<String, List<INameSpace>> getNameSpaces(int offset) {
+ Map<String, List<INameSpace>> result = new HashMap<String, List<INameSpace>>();
+ Map<INameSpace, IRegion> namespaceToRegions = new HashMap<INameSpace, IRegion>();
+
+ for (IRegion region : nameSpaces.keySet()) {
+ if(offset>=region.getOffset() && offset<=region.getOffset() + region.getLength()) {
+ Map<String, INameSpace> namespaces = nameSpaces.get(region);
+ if (namespaces != null) {
+ for (INameSpace ns : namespaces.values()) {
+ INameSpace existingNameSpace = findNameSpaceByPrefix(namespaceToRegions.keySet(), ns.getPrefix());
+ IRegion existingRegion = namespaceToRegions.get(existingNameSpace);
+ if (existingRegion != null) {
+ // Perform visibility check for region
+ if (region.getOffset() > existingRegion.getOffset()) {
+ // Replace existingNS by this ns
+ namespaceToRegions.remove(existingNameSpace);
+ namespaceToRegions.put(ns, region);
+ }
+ } else {
+ namespaceToRegions.put(ns, region);
+ }
+ }
+ }
+ }
+ }
+
+ for (INameSpace ns : namespaceToRegions.keySet()) {
+ List<INameSpace> list = result.get(ns.getURI());
+ if(list==null) {
+ list = new ArrayList<INameSpace>();
+ }
+ list.add(ns);
+ result.put(ns.getURI(), list);
+ }
+
+ return result;
+ }
+
+ private INameSpace findNameSpaceByPrefix(Set<INameSpace> namespaces, String prefix) {
+ if (namespaces != null && prefix != null) {
+ for (INameSpace ns : namespaces) {
+ if (prefix.equals(ns.getPrefix())) {
+ return ns;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Adds new name space to the context
+ * @param region
+ * @param name space
+ */
+ public void addNameSpace(IRegion region, INameSpace nameSpace) {
+ if (nameSpaces.get(region) == null) {
+ Map<String, INameSpace> nameSpaceMap = new HashMap<String, INameSpace>();
+ nameSpaces.put(region, nameSpaceMap);
+ }
+ nameSpaces.get(region).put(nameSpace.getURI(), nameSpace);
+ }
+}
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/XmlContextImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 3 months
JBoss Tools SVN: r17802 - in trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp: jspeditor and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: vrubezhny
Date: 2009-09-29 12:45:41 -0400 (Tue, 29 Sep 2009)
New Revision: 17802
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/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
Log:
JBIDE-4923: Code assist for EL doesn't work in XML files.
Issue is fixed
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-09-29 16:44:19 UTC (rev 17801)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletPageContectAssistProcessor.java 2009-09-29 16:45:41 UTC (rev 17802)
@@ -25,7 +25,6 @@
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
import org.jboss.tools.common.el.core.resolver.ELContext;
-import org.jboss.tools.common.el.core.resolver.ELContextImpl;
import org.jboss.tools.common.text.TextProposal;
import org.jboss.tools.jst.jsp.messages.JstUIMessages;
import org.jboss.tools.jst.web.kb.IFaceletPageContext;
@@ -34,7 +33,6 @@
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.XmlContextImpl;
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;
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-09-29 16:44:19 UTC (rev 17801)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java 2009-09-29 16:45:41 UTC (rev 17802)
@@ -16,7 +16,6 @@
import java.util.Map;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.Region;
@@ -45,20 +44,16 @@
import org.jboss.tools.common.el.core.resolver.ElVarSearcher;
import org.jboss.tools.common.el.core.resolver.Var;
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.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.XmlContextImpl;
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.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;
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-09-29 16:44:19 UTC (rev 17801)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/XmlContentAssistProcessor.java 2009-09-29 16:45:41 UTC (rev 17802)
@@ -33,14 +33,12 @@
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.contentassist.AbstractXMLContentAssistProcessor.TextRegion;
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.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.XmlContextImpl;
import org.jboss.tools.jst.web.kb.internal.taglib.NameSpace;
import org.jboss.tools.jst.web.kb.taglib.INameSpace;
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-09-29 16:44:19 UTC (rev 17801)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java 2009-09-29 16:45:41 UTC (rev 17802)
@@ -113,7 +113,6 @@
import org.jboss.tools.common.model.ui.texteditors.dnd.TextEditorDrop;
import org.jboss.tools.common.model.ui.texteditors.dnd.TextEditorDropProvider;
import org.jboss.tools.common.model.ui.views.palette.IIgnoreSelection;
-import org.jboss.tools.common.model.ui.views.palette.PaletteInsertHelper;
import org.jboss.tools.common.model.util.XModelObjectLoaderUtil;
import org.jboss.tools.common.text.xml.IOccurrencePreferenceProvider;
import org.jboss.tools.common.text.xml.XmlEditorPlugin;
15 years, 3 months
JBoss Tools SVN: r17801 - trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb.
by jbosstools-commits@lists.jboss.org
Author: vrubezhny
Date: 2009-09-29 12:44:19 -0400 (Tue, 29 Sep 2009)
New Revision: 17801
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageProcessor.java
Log:
JBIDE-4923: Code assist for EL doesn't work in XML files.
Issue is fixed
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-09-29 16:42:31 UTC (rev 17800)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageProcessor.java 2009-09-29 16:44:19 UTC (rev 17801)
@@ -16,6 +16,7 @@
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;
import org.jboss.tools.jst.web.kb.internal.taglib.CustomTagLibAttribute;
import org.jboss.tools.jst.web.kb.taglib.CustomTagLibManager;
import org.jboss.tools.jst.web.kb.taglib.IAttribute;
@@ -103,7 +104,7 @@
private boolean isQueryForELProposals(KbQuery query, IPageContext context) {
if (query.getType() != KbQuery.Type.ATTRIBUTE_VALUE &&
- ((query.getType() != KbQuery.Type.TEXT ) || !(context instanceof IFaceletPageContext))) {
+ ((query.getType() != KbQuery.Type.TEXT ) || !(context instanceof IFaceletPageContext || context instanceof XmlContextImpl))) {
return false;
}
15 years, 3 months
JBoss Tools SVN: r17800 - trunk/jst/plugins/org.jboss.tools.jst.jsp.
by jbosstools-commits@lists.jboss.org
Author: vrubezhny
Date: 2009-09-29 12:42:31 -0400 (Tue, 29 Sep 2009)
New Revision: 17800
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml
Log:
JBIDE-4923: Code assist for EL doesn't work in XML files.
Issue is fixed
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml 2009-09-29 16:41:55 UTC (rev 17799)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml 2009-09-29 16:42:31 UTC (rev 17800)
@@ -472,6 +472,46 @@
<partitiontype id="org.eclipse.wst.sse.ST_DEFAULT" />
<partitiontype id="org.eclipse.wst.sse.UNKNOWN_PARTITION_TYPE" />
</contenttype>
+ <contenttype id="org.jboss.tools.seam.xml.ui.pages20xmlsource">
+ <partitiontype id="org.eclipse.wst.xml.XML_DEFAULT" />
+ <partitiontype id="org.eclipse.wst.xml.XML_CDATA" />
+ <partitiontype id="org.eclipse.wst.xml.XML_PI" />
+ <partitiontype id="org.eclipse.wst.xml.XML_DECL" />
+ <partitiontype id="org.eclipse.wst.xml.XML_COMMENT" />
+ <partitiontype id="org.eclipse.wst.xml.dtd.internal_subset" />
+ <partitiontype id="org.eclipse.wst.sse.ST_DEFAULT" />
+ <partitiontype id="org.eclipse.wst.sse.UNKNOWN_PARTITION_TYPE" />
+ </contenttype>
+ <contenttype id="org.eclipse.jst.jsf.facesconfig.facesConfigFile">
+ <partitiontype id="org.eclipse.wst.xml.XML_DEFAULT" />
+ <partitiontype id="org.eclipse.wst.xml.XML_CDATA" />
+ <partitiontype id="org.eclipse.wst.xml.XML_PI" />
+ <partitiontype id="org.eclipse.wst.xml.XML_DECL" />
+ <partitiontype id="org.eclipse.wst.xml.XML_COMMENT" />
+ <partitiontype id="org.eclipse.wst.xml.dtd.internal_subset" />
+ <partitiontype id="org.eclipse.wst.sse.ST_DEFAULT" />
+ <partitiontype id="org.eclipse.wst.sse.UNKNOWN_PARTITION_TYPE" />
+ </contenttype>
+ <contenttype id="org.jboss.tools.common.model.ui.xml">
+ <partitiontype id="org.eclipse.wst.xml.XML_DEFAULT" />
+ <partitiontype id="org.eclipse.wst.xml.XML_CDATA" />
+ <partitiontype id="org.eclipse.wst.xml.XML_PI" />
+ <partitiontype id="org.eclipse.wst.xml.XML_DECL" />
+ <partitiontype id="org.eclipse.wst.xml.XML_COMMENT" />
+ <partitiontype id="org.eclipse.wst.xml.dtd.internal_subset" />
+ <partitiontype id="org.eclipse.wst.sse.ST_DEFAULT" />
+ <partitiontype id="org.eclipse.wst.sse.UNKNOWN_PARTITION_TYPE" />
+ </contenttype>
+ <contenttype id="org.eclipse.jst.jee.ee5webDD">
+ <partitiontype id="org.eclipse.wst.xml.XML_DEFAULT" />
+ <partitiontype id="org.eclipse.wst.xml.XML_CDATA" />
+ <partitiontype id="org.eclipse.wst.xml.XML_PI" />
+ <partitiontype id="org.eclipse.wst.xml.XML_DECL" />
+ <partitiontype id="org.eclipse.wst.xml.XML_COMMENT" />
+ <partitiontype id="org.eclipse.wst.xml.dtd.internal_subset" />
+ <partitiontype id="org.eclipse.wst.sse.ST_DEFAULT" />
+ <partitiontype id="org.eclipse.wst.sse.UNKNOWN_PARTITION_TYPE" />
+ </contenttype>
</contentAssistProcessor>
<contentAssistProcessor
15 years, 3 months
JBoss Tools SVN: r17799 - trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist.
by jbosstools-commits@lists.jboss.org
Author: vrubezhny
Date: 2009-09-29 12:41:55 -0400 (Tue, 29 Sep 2009)
New Revision: 17799
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/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
Log:
JBIDE-4923: Code assist for EL doesn't work in XML files.
Issue is fixed
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-09-29 15:16:01 UTC (rev 17798)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AbstractXMLContentAssistProcessor.java 2009-09-29 16:41:55 UTC (rev 17799)
@@ -703,7 +703,16 @@
*/
abstract protected ELContext createContext();
+
/**
+ * 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
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-09-29 15:16:01 UTC (rev 17798)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletPageContectAssistProcessor.java 2009-09-29 16:41:55 UTC (rev 17799)
@@ -24,6 +24,8 @@
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.ui.internal.contentassist.ContentAssistRequest;
+import org.jboss.tools.common.el.core.resolver.ELContext;
+import org.jboss.tools.common.el.core.resolver.ELContextImpl;
import org.jboss.tools.common.text.TextProposal;
import org.jboss.tools.jst.jsp.messages.JstUIMessages;
import org.jboss.tools.jst.web.kb.IFaceletPageContext;
@@ -32,6 +34,7 @@
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.XmlContextImpl;
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;
@@ -51,6 +54,11 @@
private boolean replaceJsfcTags;
+ @Override
+ protected ELContext createContextInstance() {
+ return new FaceletPageContextImpl();
+ }
+
/*
* (non-Javadoc)
* @see org.jboss.tools.jst.jsp.contentassist.JspContentAssistProcessor#createContext()
@@ -59,7 +67,7 @@
protected IPageContext createContext() {
IPageContext superContext = super.createContext();
- FaceletPageContextImpl context = new FaceletPageContextImpl();
+ FaceletPageContextImpl context = (FaceletPageContextImpl)createContextInstance();
context.setResource(superContext.getResource());
context.setElResolvers(superContext.getElResolvers());
setVars(context, superContext.getResource());
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-09-29 15:16:01 UTC (rev 17798)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java 2009-09-29 16:41:55 UTC (rev 17799)
@@ -11,11 +11,13 @@
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.core.resources.IProject;
+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;
@@ -32,7 +34,16 @@
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.model.ELExpression;
+import org.jboss.tools.common.el.core.parser.ELParserFactory;
+import org.jboss.tools.common.el.core.parser.ELParserUtil;
+import org.jboss.tools.common.el.core.resolver.ELCompletionEngine;
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.ELResolution;
+import org.jboss.tools.common.el.core.resolver.ELResolutionImpl;
+import org.jboss.tools.common.el.core.resolver.ElVarSearcher;
+import org.jboss.tools.common.el.core.resolver.Var;
import org.jboss.tools.common.text.TextProposal;
import org.jboss.tools.jst.jsp.JspEditorPlugin;
import org.jboss.tools.jst.jsp.messages.JstUIMessages;
@@ -42,6 +53,7 @@
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.XmlContextImpl;
import org.jboss.tools.jst.web.kb.internal.ResourceBundle;
import org.jboss.tools.jst.web.kb.internal.taglib.NameSpace;
import org.jboss.tools.jst.web.kb.taglib.INameSpace;
@@ -61,36 +73,19 @@
*/
public class JspContentAssistProcessor extends XmlContentAssistProcessor {
- protected static final Image JSF_EL_PROPOSAL_IMAGE = JspEditorPlugin.getDefault().getImage(JspEditorPlugin.CA_JSF_EL_IMAGE_PATH);
-
- /**
- * (non-Javadoc)
- * @see org.jboss.tools.jst.jsp.contentassist.XmlContentAssistProcessor#createContext()
- */
@Override
- protected IPageContext createContext() {
- ELContext superContext = super.createContext();
-
- IFile file = getResource();
-
- JspContextImpl context = new JspContextImpl();
- context.setResource(superContext.getResource());
- context.setElResolvers(superContext.getElResolvers());
- context.setDocument(getDocument());
- setVars(context, file);
- setNameSpaces(context);
- context.setLibraries(getTagLibraries(context));
- context.setResourceBundles(getResourceBundles(context));
-
- return context;
+ protected ELContext createContextInstance() {
+ return new JspContextImpl();
}
-
+
/**
* Collects the namespaces over the JSP-page and sets them up to the context specified.
*
* @param context
*/
- protected void setNameSpaces(JspContextImpl context) {
+ protected void setNameSpaces(XmlContextImpl context) {
+ super.setNameSpaces(context);
+
IStructuredModel sModel = StructuredModelManager
.getModelManager()
.getExistingModelForRead(getDocument());
@@ -129,38 +124,7 @@
}
}
- private static final ITagLibrary[] EMPTY_LIBRARIES = new ITagLibrary[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
@@ -234,16 +198,6 @@
}
/**
- * Returns the <code>org.jboss.tools.common.el.core.resolver.ELContext</code> instance
- *
- * @return
- */
- @Override
- public IPageContext getContext() {
- return (IPageContext)super.getContext();
- }
-
- /**
* 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.
@@ -320,140 +274,6 @@
}
/**
- * Calculates and adds the tag proposals to the Content Assist Request object
- *
- * @param contentAssistRequest Content Assist Request object
- * @param childPosition the
- */
-
- @Override
- protected void addTagInsertionProposals(
- ContentAssistRequest contentAssistRequest, int childPosition) {
-
- // Need to check if an EL Expression is opened here.
- // If it is true we don't need to start any new tag proposals
- TextRegion prefix = getELPrefix();
- if (prefix != null && prefix.isELStarted()) {
- return;
- }
-
- try {
- String matchString = contentAssistRequest.getMatchString();
- String query = matchString;
- if (query == null)
- query = ""; //$NON-NLS-1$
- String stringQuery = "<" + matchString; //$NON-NLS-1$
-
- KbQuery kbQuery = createKbQuery(Type.TAG_NAME, query, stringQuery);
- TextProposal[] proposals = PageProcessor.getInstance().getProposals(kbQuery, getContext());
-
- for (int i = 0; proposals != null && i < proposals.length; i++) {
- TextProposal textProposal = proposals[i];
-
- String replacementString = textProposal.getReplacementString();
- String closingTag = textProposal.getLabel();
- if (closingTag != null && closingTag.startsWith("<")) { //$NON-NLS-1$
- closingTag = closingTag.substring(1);
- }
-
- if (!replacementString.endsWith("/>")) { //$NON-NLS-1$
- replacementString += "</" + closingTag + ">"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
-
- int replacementOffset = contentAssistRequest.getReplacementBeginPosition();
- int replacementLength = contentAssistRequest.getReplacementLength();
- int cursorPosition = getCursorPositionForProposedText(replacementString);
- Image image = textProposal.getImage();
- if (image == null) {
- image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
- }
- String displayString = closingTag; //$NON-NLS-1$
- IContextInformation contextInformation = null;
- String additionalProposalInfo = textProposal.getContextInfo();
- int relevance = textProposal.getRelevance();
- if (relevance == TextProposal.R_NONE) {
- relevance = TextProposal.R_TAG_INSERTION;
- }
- AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(true, replacementString,
- replacementOffset, replacementLength, cursorPosition, image, displayString,
- contextInformation, additionalProposalInfo, relevance);
-
- contentAssistRequest.addProposal(proposal);
- }
- } finally {
- }
- return;
- }
-
-
- /**
- * Calculates and adds the tag name proposals to the Content Assist Request object
- *
- * @param contentAssistRequest Content Assist Request object
- * @param childPosition the
- */
-
- @Override
- protected void addTagNameProposals(
- ContentAssistRequest contentAssistRequest, int childPosition) {
- try {
- String matchString = contentAssistRequest.getMatchString();
- String query = matchString;
- if (query == null)
- query = ""; //$NON-NLS-1$
- String stringQuery = "<" + matchString; //$NON-NLS-1$
-
- KbQuery kbQuery = createKbQuery(Type.TAG_NAME, query, stringQuery);
- TextProposal[] proposals = PageProcessor.getInstance().getProposals(kbQuery, getContext());
-
- for (int i = 0; proposals != null && i < proposals.length; i++) {
- TextProposal textProposal = proposals[i];
-
- String replacementString = textProposal.getReplacementString();
- String closingTag = textProposal.getLabel();
- if (closingTag != null && closingTag.startsWith("<")) { //$NON-NLS-1$
- closingTag = closingTag.substring(1);
- }
-
- if (replacementString.startsWith("<")) { //$NON-NLS-1$
- // Because the tag starting char is already in the text
- replacementString = replacementString.substring(1);
- }
- if (!replacementString.endsWith("/>")) { //$NON-NLS-1$
- replacementString += "</" + closingTag + ">"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
-
- int replacementOffset = contentAssistRequest.getReplacementBeginPosition();
- int replacementLength = contentAssistRequest.getReplacementLength();
- int cursorPosition = getCursorPositionForProposedText(replacementString);
- Image image = textProposal.getImage();
- if (image == null) {
- image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
- }
-
- String displayString = closingTag; //$NON-NLS-1$
- IContextInformation contextInformation = null;
- String additionalProposalInfo = textProposal.getContextInfo();
- int relevance = textProposal.getRelevance();
- if (relevance == TextProposal.R_NONE) {
- relevance = TextProposal.R_TAG_INSERTION;
- }
-
- AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(true, replacementString,
- replacementOffset, replacementLength, cursorPosition, image, displayString,
- contextInformation, additionalProposalInfo, relevance);
-
- contentAssistRequest.addProposal(proposal);
- }
- } finally {
- }
- return;
- }
-
-
- /**
* Calculates and adds the attribute name proposals to the Content Assist Request object
*
* @param contentAssistRequest Content Assist Request object
@@ -503,60 +323,7 @@
}
}
- /**
- * Calculates and adds the attribute value proposals to the Content Assist Request object
- */
- protected void addAttributeValueProposals(ContentAssistRequest contentAssistRequest) {
- // Need to check if an EL Expression is opened here.
- // If it is true we don't need to start any new tag proposals
- TextRegion prefix = getELPrefix();
- if (prefix != null && prefix.isELStarted()) {
- return;
- }
- try {
- String matchString = contentAssistRequest.getMatchString();
- String query = matchString;
- if (query == null)
- query = ""; //$NON-NLS-1$
- String stringQuery = matchString;
- KbQuery kbQuery = createKbQuery(Type.ATTRIBUTE_VALUE, query, stringQuery);
- TextProposal[] proposals = PageProcessor.getInstance().getProposals(kbQuery, getContext());
-
- for (int i = 0; proposals != null && i < proposals.length; i++) {
- TextProposal textProposal = proposals[i];
- int replacementOffset = contentAssistRequest.getReplacementBeginPosition();
- int replacementLength = contentAssistRequest.getReplacementLength();
- if(textProposal.getStart() >= 0 && textProposal.getEnd() >= 0) {
- replacementOffset += textProposal.getStart() + 1;
- replacementLength = textProposal.getEnd() - textProposal.getStart();
- }
- String replacementString = "\"" + textProposal.getReplacementString() + "\""; //$NON-NLS-1$ //$NON-NLS-2$
- if(textProposal.getStart() >= 0 && textProposal.getEnd() >= 0) {
- replacementString = textProposal.getReplacementString();
- }
- int cursorPosition = getCursorPositionForProposedText(replacementString);
- Image image = textProposal.getImage();
- String displayString = textProposal.getLabel() == null ?
- replacementString :
- textProposal.getLabel();
- IContextInformation contextInformation = null;
- String additionalProposalInfo = textProposal.getContextInfo();
- int relevance = textProposal.getRelevance();
- if (relevance == TextProposal.R_NONE) {
- relevance = TextProposal.R_JSP_ATTRIBUTE_VALUE;
- }
-
- AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(replacementString,
- replacementOffset, replacementLength, cursorPosition, image, displayString,
- contextInformation, additionalProposalInfo, relevance);
-
- contentAssistRequest.addProposal(proposal);
- }
- } finally {
- }
- }
-
/**
* Calculates and adds the EL proposals to the Content Assist Request object
*/
@@ -564,76 +331,35 @@
protected void addTextELProposals(ContentAssistRequest contentAssistRequest) {
}
- /**
- * Calculates and adds the EL proposals to the Content Assist Request object
- */
- @Override
- protected void addAttributeValueELProposals(ContentAssistRequest contentAssistRequest) {
- try {
- TextRegion prefix = getELPrefix();
- if (prefix == null) {
- return;
+ protected void setVars(ELContextImpl context, IFile file) {
+ ELCompletionEngine fakeEngine = new ELCompletionEngine() {
+
+ public ELResolution resolveELOperand(IFile file,
+ ELExpression operand, boolean returnEqualedVariablesOnly,
+ List<Var> vars, ElVarSearcher varSearcher)
+ throws BadLocationException, StringIndexOutOfBoundsException {
+ return new ELResolutionImpl();
}
- if(!prefix.isELStarted()) {
- AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(true, "#{}", //$NON-NLS-1$
- getOffset(), 0, 2, JSF_EL_PROPOSAL_IMAGE, JstUIMessages.JspContentAssistProcessor_NewELExpression,
- null, JstUIMessages.JspContentAssistProcessor_NewELExpressionAttrInfo, TextProposal.R_XML_ATTRIBUTE_VALUE_TEMPLATE);
+ public ELParserFactory getParserFactory() {
+ return ELParserUtil.getJbossFactory();
+ }
- contentAssistRequest.addProposal(proposal);
- return;
+ public List<TextProposal> getProposals(ELContext context, String el) {
+ return Collections.emptyList();
}
- String matchString = "#{" + prefix.getText(); //$NON-NLS-1$
- String query = matchString;
- if (query == null)
- query = ""; //$NON-NLS-1$
- String stringQuery = matchString;
-
- int beginChangeOffset = prefix.getStartOffset() + prefix.getOffset();
-
- KbQuery kbQuery = createKbQuery(Type.ATTRIBUTE_VALUE, query, stringQuery);
- TextProposal[] proposals = PageProcessor.getInstance().getProposals(kbQuery, getContext());
-
- for (int i = 0; proposals != null && i < proposals.length; i++) {
- TextProposal textProposal = proposals[i];
-
- int replacementOffset = beginChangeOffset;
- int replacementLength = prefix.getLength();
- String replacementString = prefix.getText().substring(0, replacementLength) + textProposal.getReplacementString();
- int cursorPosition = replacementString.length();
- Image image = textProposal.getImage();
-
- // JBIDE-512, JBIDE-2541 related changes ===>>>
-// String displayString = prefix.getText().substring(0, replacementLength) + textProposal.getReplacementString();
- String displayString = textProposal.getLabel();
- if (displayString == null)
- displayString = textProposal.getReplacementString() == null ? replacementString : textProposal.getReplacementString();
-
- // <<<=== JBIDE-512, JBIDE-2541 related changes
- IContextInformation contextInformation = null;
- String additionalProposalInfo = (textProposal.getContextInfo() == null ? "" : textProposal.getContextInfo()); //$NON-NLS-1$
- int relevance = textProposal.getRelevance();
- if (relevance == TextProposal.R_NONE) {
- relevance = TextProposal.R_JSP_JSF_EL_VARIABLE_ATTRIBUTE_VALUE;
- }
-
- AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(replacementString,
- replacementOffset, replacementLength, cursorPosition, image, displayString,
- contextInformation, additionalProposalInfo, relevance);
-
- contentAssistRequest.addProposal(proposal);
+ public ELResolution resolve(ELContext context, ELExpression operand) {
+ return new ELResolutionImpl();
}
+ };
+ ElVarSearcher varSearcher = new ElVarSearcher(file, fakeEngine);
+ List<Var> vars = varSearcher.findAllVars(file, getOffset());
- if (prefix.isELStarted() && !prefix.isELClosed()) {
- AutoContentAssistantProposal proposal = new AutoContentAssistantProposal("}", //$NON-NLS-1$
- getOffset(), 0, 1, JSF_EL_PROPOSAL_IMAGE, JstUIMessages.JspContentAssistProcessor_CloseELExpression,
- null, JstUIMessages.JspContentAssistProcessor_CloseELExpressionInfo, TextProposal.R_XML_ATTRIBUTE_VALUE_TEMPLATE);
-
- contentAssistRequest.addProposal(proposal);
+ if (vars != null) {
+ for (Var var : vars) {
+ context.addVar(new Region(getOffset(), 0), var);
}
- } finally {
}
}
-
}
\ No newline at end of file
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-09-29 15:16:01 UTC (rev 17798)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/XmlContentAssistProcessor.java 2009-09-29 16:41:55 UTC (rev 17799)
@@ -10,28 +10,47 @@
******************************************************************************/
package org.jboss.tools.jst.jsp.contentassist;
-import java.util.Collections;
+import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.core.resources.IProject;
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.ui.internal.contentassist.ContentAssistRequest;
-import org.jboss.tools.common.el.core.model.ELExpression;
-import org.jboss.tools.common.el.core.parser.ELParserFactory;
-import org.jboss.tools.common.el.core.parser.ELParserUtil;
-import org.jboss.tools.common.el.core.resolver.ELCompletionEngine;
+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.ELResolution;
-import org.jboss.tools.common.el.core.resolver.ELResolutionImpl;
import org.jboss.tools.common.el.core.resolver.ELResolver;
-import org.jboss.tools.common.el.core.resolver.ElVarSearcher;
-import org.jboss.tools.common.el.core.resolver.Var;
import org.jboss.tools.common.text.TextProposal;
+import org.jboss.tools.jst.jsp.JspEditorPlugin;
+import org.jboss.tools.jst.jsp.contentassist.AbstractXMLContentAssistProcessor.TextRegion;
+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.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.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;
/**
*
@@ -39,54 +58,47 @@
*
*/
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 ELContext createContext() {
+ protected IPageContext createContext() {
IFile file = getResource();
ELResolver[] elResolvers = getELResolvers(file);
-
- ELContextImpl context = new ELContextImpl();
- context.setResource(getResource());
+
+ 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 void setVars(ELContextImpl context, IFile file) {
- ELCompletionEngine fakeEngine = new ELCompletionEngine() {
+ // No vars can be set for this processor
+ }
- public ELResolution resolveELOperand(IFile file,
- ELExpression operand, boolean returnEqualedVariablesOnly,
- List<Var> vars, ElVarSearcher varSearcher)
- throws BadLocationException, StringIndexOutOfBoundsException {
- return new ELResolutionImpl();
- }
-
- public ELParserFactory getParserFactory() {
- return ELParserUtil.getJbossFactory();
- }
-
- public List<TextProposal> getProposals(ELContext context, String el) {
- return Collections.emptyList();
- }
-
- public ELResolution resolve(ELContext context, ELExpression operand) {
- return new ELResolutionImpl();
- }
- };
- ElVarSearcher varSearcher = new ElVarSearcher(file, fakeEngine);
- List<Var> vars = varSearcher.findAllVars(file, getOffset());
-
- if (vars != null) {
- for (Var var : vars) {
- context.addVar(new Region(getOffset(), 0), var);
- }
- }
+ /**
+ * Returns the <code>org.jboss.tools.common.el.core.resolver.ELContext</code> instance
+ *
+ * @return
+ */
+ @Override
+ public IPageContext getContext() {
+ return (IPageContext)super.getContext();
}
@Override
@@ -123,25 +135,440 @@
return null;
}
+ /**
+ * Calculates and adds the tag proposals to the Content Assist Request object
+ *
+ * @param contentAssistRequest Content Assist Request object
+ * @param childPosition the
+ */
@Override
- protected void addTagNameProposals(
+ protected void addTagInsertionProposals(
ContentAssistRequest contentAssistRequest, int childPosition) {
- // TODO Auto-generated method stub
+ // Need to check if an EL Expression is opened here.
+ // If it is true we don't need to start any new tag proposals
+ TextRegion prefix = getELPrefix();
+ if (prefix != null && prefix.isELStarted()) {
+ return;
+ }
+
+ try {
+ String matchString = contentAssistRequest.getMatchString();
+ String query = matchString;
+ if (query == null)
+ query = ""; //$NON-NLS-1$
+ String stringQuery = "<" + matchString; //$NON-NLS-1$
+
+ KbQuery kbQuery = createKbQuery(Type.TAG_NAME, query, stringQuery);
+ TextProposal[] proposals = PageProcessor.getInstance().getProposals(kbQuery, getContext());
+
+ for (int i = 0; proposals != null && i < proposals.length; i++) {
+ TextProposal textProposal = proposals[i];
+
+ String replacementString = textProposal.getReplacementString();
+ String closingTag = textProposal.getLabel();
+ if (closingTag != null && closingTag.startsWith("<")) { //$NON-NLS-1$
+ closingTag = closingTag.substring(1);
+ }
+
+ if (!replacementString.endsWith("/>")) { //$NON-NLS-1$
+ replacementString += "</" + closingTag + ">"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+
+ int replacementOffset = contentAssistRequest.getReplacementBeginPosition();
+ int replacementLength = contentAssistRequest.getReplacementLength();
+ int cursorPosition = getCursorPositionForProposedText(replacementString);
+ Image image = textProposal.getImage();
+ if (image == null) {
+ image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
+ }
+ String displayString = closingTag; //$NON-NLS-1$
+ IContextInformation contextInformation = null;
+ String additionalProposalInfo = textProposal.getContextInfo();
+ int relevance = textProposal.getRelevance();
+ if (relevance == TextProposal.R_NONE) {
+ relevance = TextProposal.R_TAG_INSERTION;
+ }
+ AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(true, replacementString,
+ replacementOffset, replacementLength, cursorPosition, image, displayString,
+ contextInformation, additionalProposalInfo, relevance);
+
+ contentAssistRequest.addProposal(proposal);
+ }
+ } finally {
+ }
+ return;
}
+
+ /**
+ * Calculates and adds the tag name proposals to the Content Assist Request object
+ *
+ * @param contentAssistRequest Content Assist Request object
+ * @param childPosition the
+ */
@Override
+ protected void addTagNameProposals(
+ ContentAssistRequest contentAssistRequest, int childPosition) {
+ try {
+ String matchString = contentAssistRequest.getMatchString();
+ String query = matchString;
+ if (query == null)
+ query = ""; //$NON-NLS-1$
+ String stringQuery = "<" + matchString; //$NON-NLS-1$
+
+ KbQuery kbQuery = createKbQuery(Type.TAG_NAME, query, stringQuery);
+ TextProposal[] proposals = PageProcessor.getInstance().getProposals(kbQuery, getContext());
+
+ for (int i = 0; proposals != null && i < proposals.length; i++) {
+ TextProposal textProposal = proposals[i];
+
+ String replacementString = textProposal.getReplacementString();
+ String closingTag = textProposal.getLabel();
+ if (closingTag != null && closingTag.startsWith("<")) { //$NON-NLS-1$
+ closingTag = closingTag.substring(1);
+ }
+
+ if (replacementString.startsWith("<")) { //$NON-NLS-1$
+ // Because the tag starting char is already in the text
+ replacementString = replacementString.substring(1);
+ }
+ if (!replacementString.endsWith("/>")) { //$NON-NLS-1$
+ replacementString += "</" + closingTag + ">"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+
+ int replacementOffset = contentAssistRequest.getReplacementBeginPosition();
+ int replacementLength = contentAssistRequest.getReplacementLength();
+ int cursorPosition = getCursorPositionForProposedText(replacementString);
+ Image image = textProposal.getImage();
+ if (image == null) {
+ image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
+ }
+
+ String displayString = closingTag; //$NON-NLS-1$
+ IContextInformation contextInformation = null;
+ String additionalProposalInfo = textProposal.getContextInfo();
+ int relevance = textProposal.getRelevance();
+ if (relevance == TextProposal.R_NONE) {
+ relevance = TextProposal.R_TAG_INSERTION;
+ }
+
+ AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(true, replacementString,
+ replacementOffset, replacementLength, cursorPosition, image, displayString,
+ contextInformation, additionalProposalInfo, relevance);
+
+ contentAssistRequest.addProposal(proposal);
+ }
+ } finally {
+ }
+ return;
+ }
+
+ /**
+ * Calculates and adds the attribute value proposals to the Content Assist Request object
+ */
+ protected void addAttributeValueProposals(ContentAssistRequest contentAssistRequest) {
+ // Need to check if an EL Expression is opened here.
+ // If it is true we don't need to start any new tag proposals
+ TextRegion prefix = getELPrefix();
+ if (prefix != null && prefix.isELStarted()) {
+ return;
+ }
+ try {
+ String matchString = contentAssistRequest.getMatchString();
+ String query = matchString;
+ if (query == null)
+ query = ""; //$NON-NLS-1$
+ String stringQuery = matchString;
+
+ KbQuery kbQuery = createKbQuery(Type.ATTRIBUTE_VALUE, query, stringQuery);
+ TextProposal[] proposals = PageProcessor.getInstance().getProposals(kbQuery, getContext());
+
+ for (int i = 0; proposals != null && i < proposals.length; i++) {
+ TextProposal textProposal = proposals[i];
+ int replacementOffset = contentAssistRequest.getReplacementBeginPosition();
+ int replacementLength = contentAssistRequest.getReplacementLength();
+ if(textProposal.getStart() >= 0 && textProposal.getEnd() >= 0) {
+ replacementOffset += textProposal.getStart() + 1;
+ replacementLength = textProposal.getEnd() - textProposal.getStart();
+ }
+ String replacementString = "\"" + textProposal.getReplacementString() + "\""; //$NON-NLS-1$ //$NON-NLS-2$
+ if(textProposal.getStart() >= 0 && textProposal.getEnd() >= 0) {
+ replacementString = textProposal.getReplacementString();
+ }
+ int cursorPosition = getCursorPositionForProposedText(replacementString);
+ Image image = textProposal.getImage();
+ String displayString = textProposal.getLabel() == null ?
+ replacementString :
+ textProposal.getLabel();
+ IContextInformation contextInformation = null;
+ String additionalProposalInfo = textProposal.getContextInfo();
+ int relevance = textProposal.getRelevance();
+ if (relevance == TextProposal.R_NONE) {
+ relevance = TextProposal.R_JSP_ATTRIBUTE_VALUE;
+ }
+
+ AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(replacementString,
+ replacementOffset, replacementLength, cursorPosition, image, displayString,
+ contextInformation, additionalProposalInfo, relevance);
+
+ contentAssistRequest.addProposal(proposal);
+ }
+ } finally {
+ }
+ }
+
+ @Override
protected void addAttributeValueELProposals(ContentAssistRequest contentAssistRequest) {
- // TODO Auto-generated method stub
-
+ try {
+ TextRegion prefix = getELPrefix();
+ if (prefix == null) {
+ return;
+ }
+
+ if(!prefix.isELStarted()) {
+ AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(true, "#{}", //$NON-NLS-1$
+ getOffset(), 0, 2, JSF_EL_PROPOSAL_IMAGE, JstUIMessages.JspContentAssistProcessor_NewELExpression,
+ null, JstUIMessages.JspContentAssistProcessor_NewELExpressionAttrInfo, TextProposal.R_XML_ATTRIBUTE_VALUE_TEMPLATE);
+
+ contentAssistRequest.addProposal(proposal);
+ return;
+ }
+ String matchString = "#{" + prefix.getText(); //$NON-NLS-1$
+ String query = matchString;
+ if (query == null)
+ query = ""; //$NON-NLS-1$
+ String stringQuery = matchString;
+
+ int beginChangeOffset = prefix.getStartOffset() + prefix.getOffset();
+
+ KbQuery kbQuery = createKbQuery(Type.ATTRIBUTE_VALUE, query, stringQuery);
+ TextProposal[] proposals = PageProcessor.getInstance().getProposals(kbQuery, getContext());
+
+ for (int i = 0; proposals != null && i < proposals.length; i++) {
+ TextProposal textProposal = proposals[i];
+
+ int replacementOffset = beginChangeOffset;
+ int replacementLength = prefix.getLength();
+ String replacementString = prefix.getText().substring(0, replacementLength) + textProposal.getReplacementString();
+ int cursorPosition = replacementString.length();
+ Image image = textProposal.getImage();
+
+ // JBIDE-512, JBIDE-2541 related changes ===>>>
+// String displayString = prefix.getText().substring(0, replacementLength) + textProposal.getReplacementString();
+ String displayString = textProposal.getLabel();
+ if (displayString == null)
+ displayString = textProposal.getReplacementString() == null ? replacementString : textProposal.getReplacementString();
+
+ // <<<=== JBIDE-512, JBIDE-2541 related changes
+
+ IContextInformation contextInformation = null;
+ String additionalProposalInfo = (textProposal.getContextInfo() == null ? "" : textProposal.getContextInfo()); //$NON-NLS-1$
+ int relevance = textProposal.getRelevance();
+ if (relevance == TextProposal.R_NONE) {
+ relevance = TextProposal.R_JSP_JSF_EL_VARIABLE_ATTRIBUTE_VALUE;
+ }
+
+ AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(replacementString,
+ replacementOffset, replacementLength, cursorPosition, image, displayString,
+ contextInformation, additionalProposalInfo, relevance);
+
+ contentAssistRequest.addProposal(proposal);
+ }
+
+ if (prefix.isELStarted() && !prefix.isELClosed()) {
+ AutoContentAssistantProposal proposal = new AutoContentAssistantProposal("}", //$NON-NLS-1$
+ getOffset(), 0, 1, JSF_EL_PROPOSAL_IMAGE, JstUIMessages.JspContentAssistProcessor_CloseELExpression,
+ null, JstUIMessages.JspContentAssistProcessor_CloseELExpressionInfo, TextProposal.R_XML_ATTRIBUTE_VALUE_TEMPLATE);
+
+ contentAssistRequest.addProposal(proposal);
+ }
+ } finally {
+ }
}
@Override
protected void addTextELProposals(ContentAssistRequest contentAssistRequest) {
- // TODO Auto-generated method stub
+ TextRegion prefix = getELPrefix();
+ if (prefix == null || !prefix.isELStarted()) {
+ AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(true, "#{}", //$NON-NLS-1$
+ contentAssistRequest.getReplacementBeginPosition(),
+ 0, 2, JSF_EL_PROPOSAL_IMAGE, JstUIMessages.JspContentAssistProcessor_NewELExpression, null,
+ JstUIMessages.FaceletPageContectAssistProcessor_NewELExpressionTextInfo, TextProposal.R_XML_ATTRIBUTE_VALUE_TEMPLATE);
+
+ contentAssistRequest.addProposal(proposal);
+ return;
+ }
+ String matchString = "#{" + prefix.getText(); //$NON-NLS-1$
+ String query = matchString;
+ if (query == null)
+ query = ""; //$NON-NLS-1$
+ String stringQuery = matchString;
+
+ int beginChangeOffset = prefix.getStartOffset() + prefix.getOffset();
+
+ KbQuery kbQuery = createKbQuery(Type.TEXT, query, stringQuery);
+ TextProposal[] proposals = PageProcessor.getInstance().getProposals(kbQuery, getContext());
+
+ for (int i = 0; proposals != null && i < proposals.length; i++) {
+ TextProposal textProposal = proposals[i];
+
+ int replacementOffset = beginChangeOffset;
+ int replacementLength = prefix.getLength();
+ String replacementString = prefix.getText().substring(0, replacementLength) + textProposal.getReplacementString();
+ int cursorPosition = replacementString.length();
+ Image image = textProposal.getImage();
+
+ // JBIDE-512, JBIDE-2541 related changes ===>>>
+// String displayString = prefix.getText().substring(0, replacementLength) + textProposal.getReplacementString();
+ String displayString = textProposal.getLabel();
+ if (displayString == null)
+ displayString = textProposal.getReplacementString() == null ? replacementString : textProposal.getReplacementString();
+
+ // <<<=== JBIDE-512, JBIDE-2541 related changes
+ IContextInformation contextInformation = null;
+ String additionalProposalInfo = textProposal.getContextInfo();
+ int relevance = textProposal.getRelevance();
+ if (relevance == TextProposal.R_NONE) {
+ relevance = TextProposal.R_JSP_JSF_EL_VARIABLE_ATTRIBUTE_VALUE;
+ }
+
+ AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(replacementString,
+ replacementOffset, replacementLength, cursorPosition, image, displayString,
+ contextInformation, additionalProposalInfo, relevance);
+
+ contentAssistRequest.addProposal(proposal);
+ }
+
+ if (prefix.isELStarted() && !prefix.isELClosed()) {
+ AutoContentAssistantProposal proposal = new AutoContentAssistantProposal("}", //$NON-NLS-1$
+ getOffset(), 0, 1, JSF_EL_PROPOSAL_IMAGE, JstUIMessages.JspContentAssistProcessor_CloseELExpression,
+ null, JstUIMessages.JspContentAssistProcessor_CloseELExpressionInfo, TextProposal.R_XML_ATTRIBUTE_VALUE_TEMPLATE);
+
+ 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() :
+ domElement.getLength());
+
+ }
+
+ 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
15 years, 3 months
JBoss Tools SVN: r17798 - in trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml.ui: src/org/jboss/tools/hibernate/ui/xml/editor and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-09-29 11:16:01 -0400 (Tue, 29 Sep 2009)
New Revision: 17798
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml.ui/src/org/jboss/tools/hibernate/ui/xml/editor/HibernatePropertiesContentAssistProcessor.java
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml.ui/plugin.xml
Log:
https://jira.jboss.org/jira/browse/JBIDE-4916
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml.ui/plugin.xml
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml.ui/plugin.xml 2009-09-29 15:14:46 UTC (rev 17797)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml.ui/plugin.xml 2009-09-29 15:16:01 UTC (rev 17798)
@@ -62,5 +62,12 @@
<extension point="org.jboss.tools.common.model.ui.attributeEditor">
<attributeEditor class="org.jboss.tools.common.model.ui.attribute.editor.ComboBoxEditor" id="HibernatePropertyList"/>
</extension>
+ <extension
+ point="org.jboss.tools.common.model.ui.propertiesFileContentAssist">
+ <propertiesFileContentAssist
+ processor="org.jboss.tools.hibernate.ui.xml.editor.HibernatePropertiesContentAssistProcessor"
+ fileName="hibernate.properties"
+ />
+ </extension>
</plugin>
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml.ui/src/org/jboss/tools/hibernate/ui/xml/editor/HibernatePropertiesContentAssistProcessor.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml.ui/src/org/jboss/tools/hibernate/ui/xml/editor/HibernatePropertiesContentAssistProcessor.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml.ui/src/org/jboss/tools/hibernate/ui/xml/editor/HibernatePropertiesContentAssistProcessor.java 2009-09-29 15:16:01 UTC (rev 17798)
@@ -0,0 +1,171 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.xml.editor;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2;
+import org.eclipse.jface.fieldassist.IContentProposal;
+import org.eclipse.jface.fieldassist.IContentProposalProvider;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.CompletionProposal;
+import org.jboss.tools.common.meta.XAttribute;
+import org.jboss.tools.common.meta.XChild;
+import org.jboss.tools.common.meta.XModelEntity;
+import org.jboss.tools.common.meta.constraint.XAttributeConstraint;
+import org.jboss.tools.common.meta.constraint.impl.XAttributeConstraintAList;
+import org.jboss.tools.common.meta.key.WizardKeys;
+import org.jboss.tools.common.model.ui.attribute.adapter.JavaClassContentAssistProvider;
+import org.jboss.tools.common.model.ui.texteditors.propertyeditor.AbstractPropertiesContentAssistProcessor;
+import org.jboss.tools.common.model.util.EclipseJavaUtil;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.hibernate.xml.model.impl.HibConfigComplexPropertyImpl;
+
+/**
+ *
+ * @author Viacheslav Kabanovich
+ *
+ */
+public class HibernatePropertiesContentAssistProcessor extends
+ AbstractPropertiesContentAssistProcessor {
+
+ public HibernatePropertiesContentAssistProcessor() {}
+
+ public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer,
+ int offset) {
+ Context context = getContext(viewer, offset);
+ String text = viewer.getDocument().get();
+
+ List<ICompletionProposal> result = new ArrayList<ICompletionProposal>();
+
+ Map<String, XAttribute> attributes = getAttributes();
+
+ if(context.isInComment()) {
+ return new ICompletionProposal[0];
+ }
+ if(context.isInPropertyName()) {
+ int nameOffset = context.getNameOffset();
+ String namePrefix = nameOffset < offset ? text.substring(nameOffset, offset) : ""; //$NON-NLS-1$
+ String[] ps = attributes.keySet().toArray(new String[0]);
+ for (int i = 0; i < ps.length; i++) {
+ if(context.hasProperty(ps[i])) continue;
+ String description = WizardKeys.getString(ps[i] + ".description"); //$NON-NLS-1$
+ if("@NULL_KEY@".equals(description) || description == null) {
+ description = ps[i] + "<p>TODO - add description into keys-hibernate-config.properties";
+ }
+ if(ps[i].startsWith(namePrefix)) {
+ CompletionProposal proposal = new CompletionProposal(
+ ps[i],
+ nameOffset,
+ context.getNameLength(),
+ ps[i].length(),
+ null,
+ ps[i],
+ null,
+ description);
+ result.add( proposal);
+ }
+ }
+ } else if(context.isInValue()) {
+ int valueOffset = context.getValueOffset();
+ String valuePrefix = valueOffset < offset && valueOffset >= 0 ? text.substring(valueOffset, offset) : ""; //$NON-NLS-1$
+ String propertyName = context.getPropertyName();
+ if(attributes.containsKey(propertyName)) {
+ XAttribute attr = attributes.get(propertyName);
+ if(attr == null) {
+ return new ICompletionProposal[0];
+ }
+ XAttributeConstraint c = attr.getConstraint();
+ if(c instanceof XAttributeConstraintAList) {
+ String[] vs = ((XAttributeConstraintAList)c).getValues();
+ for (int i = 0; i < vs.length; i++) {
+ if(vs[i].length() == 0) continue;
+ if(vs[i].startsWith(valuePrefix)) {
+ CompletionProposal proposal = new CompletionProposal(
+ vs[i],
+ valueOffset,
+ context.getValueLength(),
+ vs[i].length(),
+ null,
+ vs[i],
+ null,
+ vs[i]); //should we put more substantial description?
+ result.add( proposal);
+ }
+ }
+ } else if("AccessibleJava".equals(attr.getEditor().getName())) { //$NON-NLS-1$
+ JavaClassContentAssistProvider p = new JavaClassContentAssistProvider();
+ p.init(object, attr);
+ IContentProposalProvider pp = p.getContentProposalProvider();
+ IContentProposal[] ps = pp.getProposals(valuePrefix, valuePrefix.length());
+ IProject project = EclipseResourceUtil.getProject(object);
+ IJavaProject jp = EclipseResourceUtil.getJavaProject(project);
+ if(ps != null) for (int i = 0; i < ps.length; i++) {
+ String value = ps[i].getContent();
+ String descr = null;
+ if(jp != null) try {
+ IType type = EclipseJavaUtil.findType(jp, value);
+ if(type != null) descr = JavadocContentAccess2.getHTMLContent(type, true);
+ } catch (JavaModelException e) {
+ //ignore
+ }
+ CompletionProposal proposal = new CompletionProposal(
+ value,
+ valueOffset,
+ context.getValueLength(),
+ value.length(),
+ null,
+ ps[i].getLabel(),
+ null,
+ descr != null ? descr : ps[i].getDescription());
+ result.add(proposal);
+ }
+ } else {
+ //TODO
+ }
+ }
+ }
+ return result.toArray(new ICompletionProposal[0]);
+ }
+
+ static Map<String, XAttribute> attributes = null;
+
+ public Map<String, XAttribute> getAttributes() {
+ if(attributes == null) {
+ attributes = new TreeMap<String, XAttribute>();
+ XModelEntity entity = object.getModel().getMetaData().getEntity("HibConfig3PropertiesFolder"); //$NON-NLS-1$
+ XChild[] cs = entity.getChildren();
+ for (int i = 0; i < cs.length; i++) {
+ if(cs[i].isRequired()) {
+ XModelEntity cEntity = object.getModel().getMetaData().getEntity(cs[i].getName());
+ if(cEntity == null) continue;
+ XAttribute[] as = cEntity.getAttributes();
+ for (int j = 0; j < as.length; j++) {
+ String hProperty = as[j].getProperty(HibConfigComplexPropertyImpl.H_PROPERTY);
+ if(hProperty == null || hProperty.length() == 0) continue;
+ attributes.put(hProperty, as[j]);
+ }
+ }
+ }
+ }
+ return attributes;
+
+ }
+
+}
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml.ui/src/org/jboss/tools/hibernate/ui/xml/editor/HibernatePropertiesContentAssistProcessor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 3 months
JBoss Tools SVN: r17797 - in trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml: resources/help and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-09-29 11:14:46 -0400 (Tue, 29 Sep 2009)
New Revision: 17797
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml/resources/help/keys-hibernate-config.properties
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml/plugin.xml
Log:
https://jira.jboss.org/jira/browse/JBIDE-4916
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml/plugin.xml
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml/plugin.xml 2009-09-29 15:11:15 UTC (rev 17796)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml/plugin.xml 2009-09-29 15:14:46 UTC (rev 17797)
@@ -12,6 +12,7 @@
<keys path="help/keys-hibernate-attrs.properties"/>
<keys path="help/keys-hibernate-menu.properties"/>
<keys path="help/keys-hibernate-lists.properties"/>
+ <keys path="help/keys-hibernate-config.properties"/>
</extension>
<extension
point="org.jboss.tools.common.model.resourceMapping">
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml/resources/help/keys-hibernate-config.properties
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml/resources/help/keys-hibernate-config.properties (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml/resources/help/keys-hibernate-config.properties 2009-09-29 15:14:46 UTC (rev 17797)
@@ -0,0 +1,2 @@
+hibernate.connection.pool_size.description=maximum number of pooled connections
+hibernate.dialect.description=<p>Full class name of dialect<p>In most cases Hibernate will actually be able to choose the correct org.hibernate.dialect.Dialect implementation based on the JDBC metadata returned by the JDBC driver.<p>Write all SQL statements to console. This is an alternative to setting the log category org.hibernate.SQL to debug.
\ No newline at end of file
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.xml/resources/help/keys-hibernate-config.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 3 months