[259721] [290336] [260725] New Extension point for Content Assist for XSLT, and re-add methods and deprecate for xpath2. Plus fix date LE comparison.
diff --git a/bundles/org.eclipse.wst.xsl.ui/.settings/.api_filters b/bundles/org.eclipse.wst.xsl.ui/.settings/.api_filters
new file mode 100644
index 0000000..7792fbb
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsl.ui/.settings/.api_filters
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<component id="org.eclipse.wst.xsl.ui" version="2">
+ <resource path="src/org/eclipse/wst/xsl/ui/provisional/contentassist/CustomCompletionProposal.java" type="org.eclipse.wst.xsl.ui.provisional.contentassist.CustomCompletionProposal">
+ <filter id="576720909">
+ <message_arguments>
+ <message_argument value="CustomCompletionProposal"/>
+ <message_argument value="CustomCompletionProposal"/>
+ </message_arguments>
+ </filter>
+ </resource>
+</component>
diff --git a/bundles/org.eclipse.wst.xsl.ui/.settings/org.eclipse.pde.prefs b/bundles/org.eclipse.wst.xsl.ui/.settings/org.eclipse.pde.prefs
index ade4019..71ca16a 100644
--- a/bundles/org.eclipse.wst.xsl.ui/.settings/org.eclipse.pde.prefs
+++ b/bundles/org.eclipse.wst.xsl.ui/.settings/org.eclipse.pde.prefs
@@ -1,4 +1,4 @@
-#Fri Sep 05 23:58:31 GMT 2008
+#Tue Sep 22 02:22:18 GMT 2009
compilers.f.unresolved-features=1
compilers.f.unresolved-plugins=1
compilers.incompatible-environment=1
@@ -7,6 +7,9 @@
compilers.p.discouraged-class=1
compilers.p.internal=1
compilers.p.missing-packages=2
+compilers.p.missing-version-export-package=2
+compilers.p.missing-version-import-package=2
+compilers.p.missing-version-require-bundle=2
compilers.p.no-required-att=0
compilers.p.not-externalized-att=1
compilers.p.unknown-attribute=1
diff --git a/bundles/org.eclipse.wst.xsl.ui/META-INF/MANIFEST.MF b/bundles/org.eclipse.wst.xsl.ui/META-INF/MANIFEST.MF
index 664e6ca..fb0ff3b 100644
--- a/bundles/org.eclipse.wst.xsl.ui/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.wst.xsl.ui/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.wst.xsl.ui;singleton:=true
-Bundle-Version: 1.0.200.qualifier
+Bundle-Version: 1.1.0.qualifier
Bundle-Activator: org.eclipse.wst.xsl.ui.internal.XSLUIPlugin
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui;bundle-version="[3.4.0,4.0.0)",
@@ -35,9 +35,11 @@
org.eclipse.wst.xsl.ui.internal.editor;x-internal:=true,
org.eclipse.wst.xsl.ui.internal.handlers;x-internal:=true,
org.eclipse.wst.xsl.ui.internal.preferences;x-internal:=true,
+ org.eclipse.wst.xsl.ui.internal.quickassist;x-internal:=true,
org.eclipse.wst.xsl.ui.internal.style;x-internal:=true,
org.eclipse.wst.xsl.ui.internal.templates;x-internal:=true,
org.eclipse.wst.xsl.ui.internal.util;x-internal:=true,
org.eclipse.wst.xsl.ui.internal.validation;x-internal:=true,
- org.eclipse.wst.xsl.ui.internal.wizards;x-internal:=true
+ org.eclipse.wst.xsl.ui.internal.wizards;x-internal:=true,
+ org.eclipse.wst.xsl.ui.provisional.contentassist
Bundle-ActivationPolicy: lazy
diff --git a/bundles/org.eclipse.wst.xsl.ui/build.properties b/bundles/org.eclipse.wst.xsl.ui/build.properties
index 60e64be..2f3d491 100644
--- a/bundles/org.eclipse.wst.xsl.ui/build.properties
+++ b/bundles/org.eclipse.wst.xsl.ui/build.properties
@@ -7,4 +7,11 @@
plugin.properties,\
templates/,\
about.html,\
- xslfiles/
+ xslfiles/,\
+ schema/
+src.includes = schema/,\
+ src/,\
+ xslfiles/,\
+ templates/,\
+ icons/,\
+ plugin.xml
diff --git a/bundles/org.eclipse.wst.xsl.ui/plugin.properties b/bundles/org.eclipse.wst.xsl.ui/plugin.properties
index bd50aaf..92e27c1 100644
--- a/bundles/org.eclipse.wst.xsl.ui/plugin.properties
+++ b/bundles/org.eclipse.wst.xsl.ui/plugin.properties
@@ -31,4 +31,5 @@
pageSyntaxColoring = Syntax Coloring
XSL_Property_validation = XSLT Validation
-specification.label.0 = Override
\ No newline at end of file
+specification.label.0 = Override
+XSLContentAssistExtension = XSL Content Assistance
\ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsl.ui/plugin.xml b/bundles/org.eclipse.wst.xsl.ui/plugin.xml
index 0d99ac6..c4dd785 100644
--- a/bundles/org.eclipse.wst.xsl.ui/plugin.xml
+++ b/bundles/org.eclipse.wst.xsl.ui/plugin.xml
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
+ <extension-point id="contentAssistProcessor" name="%XSLContentAssistExtension" schema="/schema/contentAssistProcessor.exsd"/>
<extension point="org.eclipse.ui.editors">
<editor name="%editorName"
@@ -252,4 +253,14 @@
</enablement>
</commonWizard>
</extension>
+ <extension
+ point="org.eclipse.wst.xsl.ui.contentAssistProcessor">
+ <processor
+ class="org.eclipse.wst.xml.ui.internal.contentassist.XMLContentAssistProcessor">
+ </processor>
+ <processor
+ class="org.eclipse.wst.xsl.ui.internal.contentassist.XSLContentAssistProcessor">
+ </processor>
+ </extension>
+
</plugin>
diff --git a/bundles/org.eclipse.wst.xsl.ui/schema/contentAssistProcessor.exsd b/bundles/org.eclipse.wst.xsl.ui/schema/contentAssistProcessor.exsd
new file mode 100644
index 0000000..59bcd7e
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsl.ui/schema/contentAssistProcessor.exsd
@@ -0,0 +1,79 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.wst.xsl.ui" xmlns="http://www.w3.org/2001/XMLSchema">
+ <annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.wst.xsl.ui" id="contentAssistProcessor" name="XSL Content Assistance"/>
+ </appinfo>
+ <documentation>
+ XSL Content Asisstance processor extension point, allows for the contribution of adopter defined XSL processor extensions.
+
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="processor" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="processor">
+ <annotation>
+ <documentation>
+ Processor that provides content assistance
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ 1.1
+ </documentation>
+ </annotation>
+</schema>
diff --git a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/StructuredTextViewerConfigurationXSL.java b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/StructuredTextViewerConfigurationXSL.java
index 4d42727..b798b58 100644
--- a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/StructuredTextViewerConfigurationXSL.java
+++ b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/StructuredTextViewerConfigurationXSL.java
@@ -11,6 +11,13 @@
package org.eclipse.wst.xsl.ui.internal;
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
import org.eclipse.jface.text.source.ISourceViewer;
@@ -20,9 +27,11 @@
// org.eclipse.wst.xml.core.internal.text.rules.StructuredTextPartitionerForXML;
import org.eclipse.wst.xml.core.text.IXMLPartitions;
import org.eclipse.wst.xml.ui.StructuredTextViewerConfigurationXML;
+import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
import org.eclipse.wst.xml.ui.internal.contentassist.NoRegionContentAssistProcessor;
import org.eclipse.wst.xsl.core.internal.text.IXSLPartitions;
import org.eclipse.wst.xsl.core.internal.text.rules.StructuredTextPartitionerForXSL;
+import org.eclipse.wst.xsl.ui.internal.contentassist.ContentAssistProcessorFactory;
import org.eclipse.wst.xsl.ui.internal.contentassist.XSLContentAssistProcessor;
import org.eclipse.wst.xsl.ui.internal.editor.XSLHyperlinkDetector;
import org.eclipse.wst.xsl.ui.internal.style.LineStyleProviderForXSL;
@@ -59,7 +68,7 @@
if ((partitionType.equals(IStructuredPartitions.DEFAULT_PARTITION))
|| (partitionType.equals(IXMLPartitions.XML_DEFAULT))
|| (partitionType.equals(IXSLPartitions.XSL_XPATH))) {
- processors = new IContentAssistProcessor[] { new XSLContentAssistProcessor() };
+ processors = ContentAssistProcessorFactory.createProcessors();
} else if (partitionType.equals(IStructuredPartitions.UNKNOWN_PARTITION)) {
processors = new IContentAssistProcessor[] { new NoRegionContentAssistProcessor() };
}
diff --git a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/CallTemplateContentAssistRequest.java b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/CallTemplateContentAssistRequest.java
index bf4dc8c..e13b1ce 100644
--- a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/CallTemplateContentAssistRequest.java
+++ b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/CallTemplateContentAssistRequest.java
@@ -28,6 +28,7 @@
import org.eclipse.wst.xsl.ui.internal.Messages;
import org.eclipse.wst.xsl.ui.internal.util.XSLPluginImageHelper;
import org.eclipse.wst.xsl.ui.internal.util.XSLPluginImages;
+import org.eclipse.wst.xsl.ui.provisional.contentassist.AbstractXSLContentAssistRequest;
import org.w3c.dom.Node;
/**
diff --git a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/ContentAssistProcessorFactory.java b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/ContentAssistProcessorFactory.java
new file mode 100644
index 0000000..0992168
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/ContentAssistProcessorFactory.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Standards for Technology in Automotive Retail and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * David Carver (STAR) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xsl.ui.internal.contentassist;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.wst.xsl.ui.internal.XSLUIPlugin;
+
+/**
+ * A factory class that reads an eclipse extension point for Content Assist
+ * Processors.
+ * @author dcarver
+ * @since 1.1
+ */
+public class ContentAssistProcessorFactory {
+ private static IContentAssistProcessor[] processors = null;
+
+ /**
+ * Creates the necessary Content Assist Processors that have been
+ * Contributed to the XSL Editor configuration.
+ * @return
+ */
+ public static IContentAssistProcessor[] createProcessors() {
+ IExtensionPoint point = getExtensionPoint();
+ if (point == null) {
+ return processors;
+ }
+ getProcessors(point);
+ return processors;
+ }
+
+ private static void getProcessors(IExtensionPoint point) {
+ ArrayList<Object> eprocessors = new ArrayList<Object>();
+ IConfigurationElement[] configElems = point.getConfigurationElements();
+
+ for (IConfigurationElement processor : configElems) {
+ try {
+ final Object o = processor.createExecutableExtension("class"); //$NON-NLS-1$
+ eprocessors.add(o);
+ } catch (CoreException ex) {
+
+ }
+ }
+ if (!eprocessors.isEmpty()) {
+ processors = new IContentAssistProcessor[eprocessors.size()];
+ eprocessors.toArray(processors);
+ }
+ }
+
+ private static IExtensionPoint getExtensionPoint() {
+ IExtensionRegistry pluginRegistry = Platform.getExtensionRegistry();
+ IExtensionPoint point = pluginRegistry.getExtensionPoint(XSLUIPlugin.PLUGIN_ID, "contentAssistProcessor"); //$NON-NLS-1$
+ return point;
+ }
+}
diff --git a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/ExcludeResultPrefixesContentAssist.java b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/ExcludeResultPrefixesContentAssist.java
index 6a4eba1..c5353b3 100644
--- a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/ExcludeResultPrefixesContentAssist.java
+++ b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/ExcludeResultPrefixesContentAssist.java
@@ -26,6 +26,7 @@
import org.eclipse.wst.xsl.ui.internal.Messages;
import org.eclipse.wst.xsl.ui.internal.util.XSLPluginImageHelper;
import org.eclipse.wst.xsl.ui.internal.util.XSLPluginImages;
+import org.eclipse.wst.xsl.ui.provisional.contentassist.AbstractXSLContentAssistRequest;
import org.w3c.dom.Node;
/**
diff --git a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/TemplateModeAttributeContentAssist.java b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/TemplateModeAttributeContentAssist.java
index 982d93e..0ac1ff2 100644
--- a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/TemplateModeAttributeContentAssist.java
+++ b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/TemplateModeAttributeContentAssist.java
@@ -24,6 +24,7 @@
import org.eclipse.wst.xsl.core.model.XSLAttribute;
import org.eclipse.wst.xsl.ui.internal.util.XSLPluginImageHelper;
import org.eclipse.wst.xsl.ui.internal.util.XSLPluginImages;
+import org.eclipse.wst.xsl.ui.provisional.contentassist.AbstractXSLContentAssistRequest;
import org.w3c.dom.Node;
/**
diff --git a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/TemplateNameAttributeContentAssist.java b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/TemplateNameAttributeContentAssist.java
index 6fd954f..a1ceca5 100644
--- a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/TemplateNameAttributeContentAssist.java
+++ b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/TemplateNameAttributeContentAssist.java
@@ -22,6 +22,7 @@
import org.eclipse.wst.xsl.core.model.StylesheetModel;
import org.eclipse.wst.xsl.ui.internal.util.XSLPluginImageHelper;
import org.eclipse.wst.xsl.ui.internal.util.XSLPluginImages;
+import org.eclipse.wst.xsl.ui.provisional.contentassist.AbstractXSLContentAssistRequest;
import org.w3c.dom.Node;
/**
diff --git a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/XPathElementContentAssist.java b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/XPathElementContentAssist.java
index d488a7e..763fd31 100644
--- a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/XPathElementContentAssist.java
+++ b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/XPathElementContentAssist.java
@@ -26,6 +26,7 @@
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
import org.eclipse.wst.xml.xpath.core.util.XSLTXPathHelper;
import org.eclipse.wst.xsl.ui.internal.XSLUIPlugin;
+import org.eclipse.wst.xsl.ui.provisional.contentassist.AbstractXMLElementContentAssistRequest;
import org.w3c.dom.Node;
/**
diff --git a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/XSLContentAssistProcessor.java b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/XSLContentAssistProcessor.java
index 6b150ec..e291f70 100644
--- a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/XSLContentAssistProcessor.java
+++ b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/XSLContentAssistProcessor.java
@@ -22,17 +22,12 @@
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.jface.text.contentassist.IContextInformationValidator;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
import org.eclipse.wst.xml.ui.internal.contentassist.AbstractContentAssistProcessor;
import org.eclipse.wst.xml.ui.internal.contentassist.XMLContentAssistProcessor;
import org.eclipse.wst.xsl.core.XSLCore;
import org.eclipse.wst.xsl.ui.internal.Messages;
-import org.w3c.dom.Node;
+import org.eclipse.wst.xsl.ui.provisional.contentassist.AbstractXSLContentAssistProcessor;
+import org.eclipse.wst.xsl.ui.provisional.contentassist.IContentAssistProposalRequest;
/**
* The XSL Content Assist Processor provides content assistance for various
@@ -42,20 +37,11 @@
* @author David Carver
* @since 1.0
*/
-public class XSLContentAssistProcessor implements IContentAssistProcessor {
+public class XSLContentAssistProcessor extends AbstractXSLContentAssistProcessor implements IContentAssistProcessor {
- private String errorMessage = ""; //$NON-NLS-1$
- private ITextViewer textViewer = null;
private ArrayList<ICompletionProposal> xslProposals;
private ArrayList<ICompletionProposal> additionalProposals;
- private IndexedRegion treeNode;
- private Node node;
- private IDOMNode xmlNode;
- private IStructuredDocumentRegion sdRegion;
- private ITextRegion completionRegion;
- private String matchString;
- private int cursorPosition;
-
+ private ArrayList<String> namespaces;
/**
* Provides an XSL Content Assist Processor class that is XSL aware and XML
* aware.
@@ -64,6 +50,8 @@
super();
xslProposals = new ArrayList<ICompletionProposal>();
additionalProposals = new ArrayList<ICompletionProposal>();
+ namespaces = new ArrayList<String>();
+ namespaces.add(XSLCore.XSL_NAMESPACE_URI);
}
/**
@@ -83,14 +71,11 @@
ITextViewer textViewer, int documentPosition) {
initializeProposalVariables(textViewer, documentPosition);
- ICompletionProposal[] xmlProposals = getXMLProposals();
-
additionalProposals = getAdditionalXSLElementProposals();
xslProposals = getXSLNamespaceProposals();
ArrayList<ICompletionProposal> proposalList = new ArrayList<ICompletionProposal>();
- addProposals(xmlProposals, proposalList);
proposalList.addAll(additionalProposals);
proposalList.addAll(xslProposals);
@@ -103,22 +88,6 @@
return combinedProposals;
}
- /**
- * @param textViewer
- * @param documentPosition
- */
- private void initializeProposalVariables(ITextViewer textViewer,
- int documentPosition) {
- this.textViewer = textViewer;
- cursorPosition = documentPosition;
- treeNode = ContentAssistUtils.getNodeAt(textViewer, cursorPosition);
- node = getActualDOMNode((Node) treeNode);
- xmlNode = (IDOMNode) node;
- sdRegion = getStructuredDocumentRegion();
- completionRegion = getCompletionRegion(cursorPosition, node);
- matchString = getMatchString(sdRegion, completionRegion, cursorPosition);
- }
-
private ArrayList<ICompletionProposal> getXSLNamespaceProposals() {
if (XSLCore.isXSLNamespace(xmlNode)) {
XSLContentAssistRequestFactory requestFactory = new XSLContentAssistRequestFactory(
@@ -141,23 +110,6 @@
return additionalProposals;
}
- private ICompletionProposal[] getXMLProposals() {
- AbstractContentAssistProcessor processor = new XMLContentAssistProcessor();
-
- ICompletionProposal proposals[] = processor.computeCompletionProposals(
- textViewer, cursorPosition);
- return proposals;
- }
-
- private void addProposals(ICompletionProposal[] proposals,
- ArrayList<ICompletionProposal> proposalList) {
- if (proposals != null) {
- for (int cnt = 0; cnt < proposals.length; cnt++) {
- proposalList.add(proposals[cnt]);
- }
- }
- }
-
private ICompletionProposal[] combineProposals(
ArrayList<ICompletionProposal> proposalList) {
ICompletionProposal[] combinedProposals = new ICompletionProposal[proposalList
@@ -167,228 +119,6 @@
}
/**
- * @param node
- * @return
- */
- private Node getActualDOMNode(Node node) {
- while ((node != null) && (node.getNodeType() == Node.TEXT_NODE)
- && (node.getParentNode() != null)) {
- node = node.getParentNode();
- }
- return node;
- }
-
- /**
- * StructuredTextViewer must be set before using this.
- *
- * @param pos
- * @return
- */
- private IStructuredDocumentRegion getStructuredDocumentRegion() {
- return ContentAssistUtils.getStructuredDocumentRegion(textViewer,
- cursorPosition);
- }
-
- /**
- * Return the region whose content's require completion. This is something
- * of a misnomer as sometimes the user wants to be prompted for contents of
- * a non-existent ITextRegion, such as for enumerated attribute values
- * following an '=' sign.
- *
- * Copied from AbstractContentAssist Processor.
- */
- protected ITextRegion getCompletionRegion(int documentPosition, Node domnode) {
- if (domnode == null) {
- return null;
- }
-
- ITextRegion region = null;
- int offset = documentPosition;
- IStructuredDocumentRegion flatNode = null;
- IDOMNode node = (IDOMNode) domnode;
-
- if (node.getNodeType() == Node.DOCUMENT_NODE) {
- if (node.getStructuredDocument().getLength() == 0) {
- return null;
- }
- ITextRegion result = node.getStructuredDocument()
- .getRegionAtCharacterOffset(offset)
- .getRegionAtCharacterOffset(offset);
- while (result == null) {
- offset--;
- result = node.getStructuredDocument()
- .getRegionAtCharacterOffset(offset)
- .getRegionAtCharacterOffset(offset);
- }
- return result;
- }
-
- IStructuredDocumentRegion startTag = node
- .getStartStructuredDocumentRegion();
- IStructuredDocumentRegion endTag = node
- .getEndStructuredDocumentRegion();
-
- if ((startTag != null) && (startTag.getStartOffset() <= offset)
- && (offset < startTag.getStartOffset() + startTag.getLength())) {
- flatNode = startTag;
- } else if ((endTag != null) && (endTag.getStartOffset() <= offset)
- && (offset < endTag.getStartOffset() + endTag.getLength())) {
- flatNode = endTag;
- }
-
- if (flatNode != null) {
- region = getCompletionRegion(offset, flatNode);
- } else {
- flatNode = node.getStructuredDocument().getRegionAtCharacterOffset(
- offset);
- if ((flatNode.getStartOffset() <= documentPosition)
- && (flatNode.getEndOffset() >= documentPosition)) {
- if ((offset == flatNode.getStartOffset())
- && (flatNode.getPrevious() != null)
- && (((flatNode
- .getRegionAtCharacterOffset(documentPosition) != null) && (flatNode
- .getRegionAtCharacterOffset(documentPosition)
- .getType() != DOMRegionContext.XML_CONTENT))
- || (flatNode.getPrevious().getLastRegion()
- .getType() == DOMRegionContext.XML_TAG_OPEN) || (flatNode
- .getPrevious().getLastRegion().getType() == DOMRegionContext.XML_END_TAG_OPEN))) {
- region = flatNode.getPrevious().getLastRegion();
- } else if (flatNode.getEndOffset() == documentPosition) {
- region = flatNode.getLastRegion();
- } else {
- region = flatNode.getFirstRegion();
- }
- } else {
- region = flatNode.getLastRegion();
- }
- }
-
- return region;
- }
-
- protected ITextRegion getCompletionRegion(int offset,
- IStructuredDocumentRegion sdRegion) {
- ITextRegion region = sdRegion.getRegionAtCharacterOffset(offset);
- if (region == null) {
- return null;
- }
-
- if (sdRegion.getStartOffset(region) == offset) {
- // The offset is at the beginning of the region
- if ((sdRegion.getStartOffset(region) == sdRegion.getStartOffset())
- && (sdRegion.getPrevious() != null)
- && (!sdRegion.getPrevious().isEnded())) {
- region = sdRegion.getPrevious().getRegionAtCharacterOffset(
- offset - 1);
- } else {
- // Is there no separating whitespace from the previous region?
- // If not,
- // then that region is the important one
- ITextRegion previousRegion = sdRegion
- .getRegionAtCharacterOffset(offset - 1);
- if ((previousRegion != null)
- && (previousRegion != region)
- && (previousRegion.getTextLength() == previousRegion
- .getLength())) {
- region = previousRegion;
- }
- }
- } else {
- // The offset is NOT at the beginning of the region
- if (offset > sdRegion.getStartOffset(region)
- + region.getTextLength()) {
- // Is the offset within the whitespace after the text in this
- // region?
- // If so, use the next region
- ITextRegion nextRegion = sdRegion
- .getRegionAtCharacterOffset(sdRegion
- .getStartOffset(region)
- + region.getLength());
- if (nextRegion != null) {
- region = nextRegion;
- }
- } else {
- // Is the offset within the important text for this region?
- // If so, then we've already got the right one.
- }
- }
-
- // valid WHITE_SPACE region handler (#179924)
- if ((region != null)
- && (region.getType() == DOMRegionContext.WHITE_SPACE)) {
- ITextRegion previousRegion = sdRegion
- .getRegionAtCharacterOffset(sdRegion.getStartOffset(region) - 1);
- if (previousRegion != null) {
- region = previousRegion;
- }
- }
-
- return region;
- }
-
- private String getMatchString(IStructuredDocumentRegion parent,
- ITextRegion aRegion, int offset) {
- String matchString = ""; //$NON-NLS-1$
-
- if (isNotMatchStringRegion(parent, aRegion, offset)) {
- return matchString;
- }
-
- if (hasMatchString(parent, aRegion, offset)) {
- matchString = extractMatchString(parent, aRegion, offset);
- }
- return matchString;
- }
-
- private boolean isNotMatchStringRegion(IStructuredDocumentRegion parent, ITextRegion aRegion, int offset) {
- if (aRegion == null || parent == null)
- return true;
-
- String regionType = aRegion.getType();
- int totalRegionOffset = parent.getStartOffset(aRegion)
- + aRegion.getTextLength();
- return (isCloseRegion(aRegion)
- || hasNoMatchString(offset, regionType, totalRegionOffset));
- }
-
- private boolean isCloseRegion(ITextRegion region) {
- String type = region.getType();
- return ((type == DOMRegionContext.XML_PI_CLOSE)
- || (type == DOMRegionContext.XML_TAG_CLOSE)
- || (type == DOMRegionContext.XML_EMPTY_TAG_CLOSE)
- || (type == DOMRegionContext.XML_CDATA_CLOSE)
- || (type == DOMRegionContext.XML_COMMENT_CLOSE)
- || (type == DOMRegionContext.XML_ATTLIST_DECL_CLOSE)
- || (type == DOMRegionContext.XML_ELEMENT_DECL_CLOSE)
- || (type == DOMRegionContext.XML_DOCTYPE_DECLARATION_CLOSE) || (type == DOMRegionContext.XML_DECLARATION_CLOSE));
- }
-
- private boolean hasMatchString(IStructuredDocumentRegion parent,
- ITextRegion aRegion, int offset) {
- return (parent.getText(aRegion).length() > 0)
- && (parent.getStartOffset(aRegion) < offset);
- }
-
- private boolean hasNoMatchString(int offset, String regionType,
- int totalRegionOffset) {
- return regionType.equals(DOMRegionContext.XML_CONTENT)
- || regionType.equals(DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS)
- || regionType.equals(DOMRegionContext.XML_TAG_OPEN)
- || offset > totalRegionOffset;
- }
-
- private String extractMatchString(IStructuredDocumentRegion parent,
- ITextRegion aRegion, int offset) {
- String matchString;
- matchString = parent.getText(aRegion).substring(0,
- offset - parent.getStartOffset(aRegion));
- if (matchString.startsWith("\"")) { //$NON-NLS-1$
- matchString = matchString.substring(1);
- }
- return matchString;
- }
-
- /**
* (non-Javadoc)
*
* @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeContextInformation(org.eclipse.jface.text.ITextViewer,
@@ -400,21 +130,6 @@
}
/**
- * Returns the characters which when entered by the user should
- * automatically trigger the presentation of possible completions.
- *
- * the auto activation characters for completion proposal or
- * <code>null</code> if no auto activation is desired
- *
- * @return an array of activation characters
- */
- public char[] getCompletionProposalAutoActivationCharacters() {
- char[] completionProposals = { '"', '\'', ':', '[', '{', '<' };
-
- return completionProposals;
- }
-
- /**
* (non-Javadoc)
*
* @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationAutoActivationCharacters()
@@ -432,22 +147,16 @@
return null;
}
- /**
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getErrorMessage()
- */
- public String getErrorMessage() {
- return errorMessage;
+ public String getMaximumVersion() {
+ return "2.0"; //$NON-NLS-1$
}
- /**
- * Sets the error message for why content assistance didn't complete.
- *
- * @param errorMessage
- */
- public void setErrorMessage(String errorMessage) {
- this.errorMessage = errorMessage;
+ public String getMinimumVersion() {
+ return "1.0"; //$NON-NLS-1$
+ }
+
+ public ArrayList<String> getNamespaces() {
+ return null;
}
}
diff --git a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/XSLContentAssistRequestFactory.java b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/XSLContentAssistRequestFactory.java
index ae677fa..ff8c228 100644
--- a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/XSLContentAssistRequestFactory.java
+++ b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/XSLContentAssistRequestFactory.java
@@ -17,6 +17,10 @@
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
import org.eclipse.wst.xsl.ui.internal.contentassist.href.HrefContentAssistRequest;
+import org.eclipse.wst.xsl.ui.provisional.contentassist.IContentAssistProposalRequest;
+import org.eclipse.wst.xsl.ui.provisional.contentassist.NullContentAssistRequest;
+import org.eclipse.wst.xsl.ui.provisional.contentassist.SelectAttributeContentAssist;
+import org.eclipse.wst.xsl.ui.provisional.contentassist.TestAttributeContentAssist;
import org.w3c.dom.NamedNodeMap;
/**
diff --git a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/XSLElementContentAssistRequest.java b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/XSLElementContentAssistRequest.java
index 8157e2a..f046eba 100644
--- a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/XSLElementContentAssistRequest.java
+++ b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/XSLElementContentAssistRequest.java
@@ -12,7 +12,6 @@
package org.eclipse.wst.xsl.ui.internal.contentassist;
import java.util.ArrayList;
-import java.util.Collections;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
@@ -21,6 +20,7 @@
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
import org.eclipse.wst.xsl.ui.internal.contentassist.contentmodel.XSLContentModelGenerator;
+import org.eclipse.wst.xsl.ui.provisional.contentassist.AbstractXMLElementContentAssistRequest;
import org.w3c.dom.Node;
diff --git a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/href/HrefContentAssistRequest.java b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/href/HrefContentAssistRequest.java
index a540d63..eee481b 100644
--- a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/href/HrefContentAssistRequest.java
+++ b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/href/HrefContentAssistRequest.java
@@ -28,9 +28,9 @@
import org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal;
import org.eclipse.wst.xsl.core.XSLCore;
import org.eclipse.wst.xsl.ui.internal.XSLUIPlugin;
-import org.eclipse.wst.xsl.ui.internal.contentassist.AbstractXSLContentAssistRequest;
import org.eclipse.wst.xsl.ui.internal.util.XSLPluginImageHelper;
import org.eclipse.wst.xsl.ui.internal.util.XSLPluginImages;
+import org.eclipse.wst.xsl.ui.provisional.contentassist.AbstractXSLContentAssistRequest;
import org.w3c.dom.Node;
/**
diff --git a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/templates/XSLTemplatesPage.java b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/templates/XSLTemplatesPage.java
index b766c56..21f3277 100644
--- a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/templates/XSLTemplatesPage.java
+++ b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/templates/XSLTemplatesPage.java
@@ -28,8 +28,8 @@
import org.eclipse.ui.texteditor.templates.AbstractTemplatesPage;
import org.eclipse.wst.xml.xpath.ui.internal.XPathUIPlugin;
import org.eclipse.wst.xml.xpath.ui.internal.templates.TemplateContextTypeIdsXPath;
-import org.eclipse.wst.xsl.ui.internal.contentassist.CustomCompletionProposal;
import org.eclipse.wst.xsl.ui.internal.editor.XSLEditor;
+import org.eclipse.wst.xsl.ui.provisional.contentassist.CustomCompletionProposal;
/**
* The XSL Templates Page is used by the TemplatesViewer to display available
diff --git a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/AbstractXMLElementContentAssistRequest.java b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/provisional/contentassist/AbstractXMLElementContentAssistRequest.java
similarity index 99%
rename from bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/AbstractXMLElementContentAssistRequest.java
rename to bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/provisional/contentassist/AbstractXMLElementContentAssistRequest.java
index 3f63371..4091cf0 100644
--- a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/AbstractXMLElementContentAssistRequest.java
+++ b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/provisional/contentassist/AbstractXMLElementContentAssistRequest.java
@@ -8,7 +8,7 @@
*Contributors:
* David Carver (STAR) - initial API and implementation
*******************************************************************************/
-package org.eclipse.wst.xsl.ui.internal.contentassist;
+package org.eclipse.wst.xsl.ui.provisional.contentassist;
import java.util.ArrayList;
import java.util.Iterator;
@@ -45,7 +45,7 @@
* proposals using the XML Content Model.
*
* @author David Carver
- *
+ * @since 1.1
*/
public abstract class AbstractXMLElementContentAssistRequest extends AbstractXSLContentAssistRequest {
diff --git a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/provisional/contentassist/AbstractXSLContentAssistProcessor.java b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/provisional/contentassist/AbstractXSLContentAssistProcessor.java
new file mode 100644
index 0000000..ed02b42
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/provisional/contentassist/AbstractXSLContentAssistProcessor.java
@@ -0,0 +1,307 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Standards for Technology in Automotive Retail and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * David Carver (STAR) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xsl.ui.provisional.contentassist;
+
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
+import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
+import org.w3c.dom.Node;
+
+/**
+ * This is an Abstract class that implementors should extend for implementing
+ * XSL Content Assist Processors. It provides common convience methods for
+ * information that is needed to construct a content assist processor.
+ *
+ * @author dcarver
+ * @since 1.1
+ */
+public abstract class AbstractXSLContentAssistProcessor implements IXSLContentAssistProcessor {
+
+ protected String errorMessage = ""; //$NON-NLS-1$
+ protected ITextViewer textViewer = null;
+ private IndexedRegion treeNode;
+ private Node node;
+ protected IDOMNode xmlNode;
+ protected IStructuredDocumentRegion sdRegion;
+ protected ITextRegion completionRegion;
+ protected String matchString;
+ protected int cursorPosition;
+
+ /**
+ * @param textViewer
+ * @param documentPosition
+ */
+ protected void initializeProposalVariables(ITextViewer textViewer, int documentPosition) {
+ this.textViewer = textViewer;
+ cursorPosition = documentPosition;
+ treeNode = ContentAssistUtils.getNodeAt(textViewer, cursorPosition);
+ node = getActualDOMNode((Node) treeNode);
+ xmlNode = (IDOMNode) node;
+ sdRegion = getStructuredDocumentRegion();
+ completionRegion = getCompletionRegion(cursorPosition, node);
+ matchString = getMatchString(sdRegion, completionRegion, cursorPosition);
+ }
+
+ /**
+ * @param node
+ * @return
+ */
+ private Node getActualDOMNode(Node node) {
+ while ((node != null) && (node.getNodeType() == Node.TEXT_NODE)
+ && (node.getParentNode() != null)) {
+ node = node.getParentNode();
+ }
+ return node;
+ }
+
+ /**
+ * StructuredTextViewer must be set before using this.
+ *
+ * @param pos
+ * @return
+ */
+ private IStructuredDocumentRegion getStructuredDocumentRegion() {
+ return ContentAssistUtils.getStructuredDocumentRegion(textViewer,
+ cursorPosition);
+ }
+
+ /**
+ * Return the region whose content's require completion. This is something
+ * of a misnomer as sometimes the user wants to be prompted for contents of
+ * a non-existent ITextRegion, such as for enumerated attribute values
+ * following an '=' sign.
+ *
+ * Copied from AbstractContentAssist Processor.
+ */
+ protected ITextRegion getCompletionRegion(int documentPosition, Node domnode) {
+ if (domnode == null) {
+ return null;
+ }
+
+ ITextRegion region = null;
+ int offset = documentPosition;
+ IStructuredDocumentRegion flatNode = null;
+ IDOMNode node = (IDOMNode) domnode;
+
+ if (node.getNodeType() == Node.DOCUMENT_NODE) {
+ if (node.getStructuredDocument().getLength() == 0) {
+ return null;
+ }
+ ITextRegion result = node.getStructuredDocument()
+ .getRegionAtCharacterOffset(offset)
+ .getRegionAtCharacterOffset(offset);
+ while (result == null) {
+ offset--;
+ result = node.getStructuredDocument()
+ .getRegionAtCharacterOffset(offset)
+ .getRegionAtCharacterOffset(offset);
+ }
+ return result;
+ }
+
+ IStructuredDocumentRegion startTag = node
+ .getStartStructuredDocumentRegion();
+ IStructuredDocumentRegion endTag = node
+ .getEndStructuredDocumentRegion();
+
+ if ((startTag != null) && (startTag.getStartOffset() <= offset)
+ && (offset < startTag.getStartOffset() + startTag.getLength())) {
+ flatNode = startTag;
+ } else if ((endTag != null) && (endTag.getStartOffset() <= offset)
+ && (offset < endTag.getStartOffset() + endTag.getLength())) {
+ flatNode = endTag;
+ }
+
+ if (flatNode != null) {
+ region = getCompletionRegion(offset, flatNode);
+ } else {
+ flatNode = node.getStructuredDocument().getRegionAtCharacterOffset(
+ offset);
+ if ((flatNode.getStartOffset() <= documentPosition)
+ && (flatNode.getEndOffset() >= documentPosition)) {
+ if ((offset == flatNode.getStartOffset())
+ && (flatNode.getPrevious() != null)
+ && (((flatNode
+ .getRegionAtCharacterOffset(documentPosition) != null) && (flatNode
+ .getRegionAtCharacterOffset(documentPosition)
+ .getType() != DOMRegionContext.XML_CONTENT))
+ || (flatNode.getPrevious().getLastRegion()
+ .getType() == DOMRegionContext.XML_TAG_OPEN) || (flatNode
+ .getPrevious().getLastRegion().getType() == DOMRegionContext.XML_END_TAG_OPEN))) {
+ region = flatNode.getPrevious().getLastRegion();
+ } else if (flatNode.getEndOffset() == documentPosition) {
+ region = flatNode.getLastRegion();
+ } else {
+ region = flatNode.getFirstRegion();
+ }
+ } else {
+ region = flatNode.getLastRegion();
+ }
+ }
+
+ return region;
+ }
+
+ protected ITextRegion getCompletionRegion(int offset, IStructuredDocumentRegion sdRegion) {
+ ITextRegion region = sdRegion.getRegionAtCharacterOffset(offset);
+ if (region == null) {
+ return null;
+ }
+
+ if (sdRegion.getStartOffset(region) == offset) {
+ // The offset is at the beginning of the region
+ if ((sdRegion.getStartOffset(region) == sdRegion.getStartOffset())
+ && (sdRegion.getPrevious() != null)
+ && (!sdRegion.getPrevious().isEnded())) {
+ region = sdRegion.getPrevious().getRegionAtCharacterOffset(
+ offset - 1);
+ } else {
+ // Is there no separating whitespace from the previous region?
+ // If not,
+ // then that region is the important one
+ ITextRegion previousRegion = sdRegion
+ .getRegionAtCharacterOffset(offset - 1);
+ if ((previousRegion != null)
+ && (previousRegion != region)
+ && (previousRegion.getTextLength() == previousRegion
+ .getLength())) {
+ region = previousRegion;
+ }
+ }
+ } else {
+ // The offset is NOT at the beginning of the region
+ if (offset > sdRegion.getStartOffset(region)
+ + region.getTextLength()) {
+ // Is the offset within the whitespace after the text in this
+ // region?
+ // If so, use the next region
+ ITextRegion nextRegion = sdRegion
+ .getRegionAtCharacterOffset(sdRegion
+ .getStartOffset(region)
+ + region.getLength());
+ if (nextRegion != null) {
+ region = nextRegion;
+ }
+ } else {
+ // Is the offset within the important text for this region?
+ // If so, then we've already got the right one.
+ }
+ }
+
+ // valid WHITE_SPACE region handler (#179924)
+ if ((region != null)
+ && (region.getType() == DOMRegionContext.WHITE_SPACE)) {
+ ITextRegion previousRegion = sdRegion
+ .getRegionAtCharacterOffset(sdRegion.getStartOffset(region) - 1);
+ if (previousRegion != null) {
+ region = previousRegion;
+ }
+ }
+
+ return region;
+ }
+
+ private String getMatchString(IStructuredDocumentRegion parent, ITextRegion aRegion, int offset) {
+ String matchString = ""; //$NON-NLS-1$
+
+ if (isNotMatchStringRegion(parent, aRegion, offset)) {
+ return matchString;
+ }
+
+ if (hasMatchString(parent, aRegion, offset)) {
+ matchString = extractMatchString(parent, aRegion, offset);
+ }
+ return matchString;
+ }
+
+ private boolean isNotMatchStringRegion(IStructuredDocumentRegion parent, ITextRegion aRegion, int offset) {
+ if (aRegion == null || parent == null)
+ return true;
+
+ String regionType = aRegion.getType();
+ int totalRegionOffset = parent.getStartOffset(aRegion)
+ + aRegion.getTextLength();
+ return (isCloseRegion(aRegion)
+ || hasNoMatchString(offset, regionType, totalRegionOffset));
+ }
+
+ private boolean isCloseRegion(ITextRegion region) {
+ String type = region.getType();
+ return ((type == DOMRegionContext.XML_PI_CLOSE)
+ || (type == DOMRegionContext.XML_TAG_CLOSE)
+ || (type == DOMRegionContext.XML_EMPTY_TAG_CLOSE)
+ || (type == DOMRegionContext.XML_CDATA_CLOSE)
+ || (type == DOMRegionContext.XML_COMMENT_CLOSE)
+ || (type == DOMRegionContext.XML_ATTLIST_DECL_CLOSE)
+ || (type == DOMRegionContext.XML_ELEMENT_DECL_CLOSE)
+ || (type == DOMRegionContext.XML_DOCTYPE_DECLARATION_CLOSE) || (type == DOMRegionContext.XML_DECLARATION_CLOSE));
+ }
+
+ private boolean hasMatchString(IStructuredDocumentRegion parent, ITextRegion aRegion, int offset) {
+ return (parent.getText(aRegion).length() > 0)
+ && (parent.getStartOffset(aRegion) < offset);
+ }
+
+ private boolean hasNoMatchString(int offset, String regionType, int totalRegionOffset) {
+ return regionType.equals(DOMRegionContext.XML_CONTENT)
+ || regionType.equals(DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS)
+ || regionType.equals(DOMRegionContext.XML_TAG_OPEN)
+ || offset > totalRegionOffset;
+ }
+
+ private String extractMatchString(IStructuredDocumentRegion parent, ITextRegion aRegion, int offset) {
+ String matchString;
+ matchString = parent.getText(aRegion).substring(0,
+ offset - parent.getStartOffset(aRegion));
+ if (matchString.startsWith("\"")) { //$NON-NLS-1$
+ matchString = matchString.substring(1);
+ }
+ return matchString;
+ }
+
+ /**
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getErrorMessage()
+ */
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+
+ /**
+ * Sets the error message for why content assistance didn't complete.
+ *
+ * @param errorMessage
+ */
+ public void setErrorMessage(String errorMessage) {
+ this.errorMessage = errorMessage;
+ }
+
+ /**
+ * Returns the characters which when entered by the user should
+ * automatically trigger the presentation of possible completions.
+ *
+ * the auto activation characters for completion proposal or
+ * <code>null</code> if no auto activation is desired
+ *
+ * @return an array of activation characters
+ */
+ public char[] getCompletionProposalAutoActivationCharacters() {
+ char[] completionProposals = { '"', '\'', ':', '[', '{', '<' };
+
+ return completionProposals;
+ }
+
+}
diff --git a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/AbstractXSLContentAssistRequest.java b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/provisional/contentassist/AbstractXSLContentAssistRequest.java
similarity index 98%
rename from bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/AbstractXSLContentAssistRequest.java
rename to bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/provisional/contentassist/AbstractXSLContentAssistRequest.java
index 177f8cc..229ca15 100644
--- a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/AbstractXSLContentAssistRequest.java
+++ b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/provisional/contentassist/AbstractXSLContentAssistRequest.java
@@ -1,4 +1,4 @@
-package org.eclipse.wst.xsl.ui.internal.contentassist;
+package org.eclipse.wst.xsl.ui.provisional.contentassist;
import java.util.ArrayList;
import java.util.Collection;
@@ -30,7 +30,7 @@
* class and implement specific functionality.
*
* @author dcarver
- *
+ * @since 1.1
*/
public abstract class AbstractXSLContentAssistRequest implements IContentAssistProposalRequest {
protected IStructuredDocumentRegion documentRegion = null;
diff --git a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/CustomCompletionProposal.java b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/provisional/contentassist/CustomCompletionProposal.java
similarity index 85%
rename from bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/CustomCompletionProposal.java
rename to bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/provisional/contentassist/CustomCompletionProposal.java
index 37a5e8a..6293ab1 100644
--- a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/CustomCompletionProposal.java
+++ b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/provisional/contentassist/CustomCompletionProposal.java
@@ -1,17 +1,24 @@
-package org.eclipse.wst.xsl.ui.internal.contentassist;
+package org.eclipse.wst.xsl.ui.provisional.contentassist;
import org.eclipse.jface.text.contentassist.ICompletionProposalExtension4;
import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.swt.graphics.Image;
+/**
+ * Adopters can use the class to help build a custom content completion proposal.
+ * @author dcarver
+ * @since 1.1
+ *
+ */
public class CustomCompletionProposal extends
org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal
implements ICompletionProposalExtension4 {
/**
- * @param replacementString
- * @param replacementOffset
- * @param replacementLength
+ * Constructor for the Custom Completion Proposal
+ * @param replacementString
+ * @param replacementOffset
+ * @param replacementLength
* @param cursorPosition
* @param image
* @param displayString
diff --git a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/IContentAssistProposalRequest.java b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/provisional/contentassist/IContentAssistProposalRequest.java
similarity index 75%
rename from bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/IContentAssistProposalRequest.java
rename to bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/provisional/contentassist/IContentAssistProposalRequest.java
index d294d1a..762f2d9 100644
--- a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/IContentAssistProposalRequest.java
+++ b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/provisional/contentassist/IContentAssistProposalRequest.java
@@ -1,4 +1,4 @@
-package org.eclipse.wst.xsl.ui.internal.contentassist;
+package org.eclipse.wst.xsl.ui.provisional.contentassist;
import java.util.ArrayList;
@@ -8,13 +8,13 @@
* Provides content assistance ICompletionProposals.
*
* @author David Carver
- *
+ * @since 1.1
*/
public interface IContentAssistProposalRequest {
/**
* Completion Proposals for a Content Assist Request.
- * @return
+ * @return ArrayLlist<ICompletionProposal>
*/
public ArrayList<ICompletionProposal> getCompletionProposals();
}
\ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/provisional/contentassist/IXSLContentAssistProcessor.java b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/provisional/contentassist/IXSLContentAssistProcessor.java
new file mode 100644
index 0000000..cdcbe73
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/provisional/contentassist/IXSLContentAssistProcessor.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Standards for Technology in Automotive Retail and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * David Carver (STAR) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xsl.ui.provisional.contentassist;
+
+import java.util.ArrayList;
+
+/**
+ * @since 1.1
+ */
+public interface IXSLContentAssistProcessor {
+
+ /**
+ * ArrayList of Strings for the namespaces this processor activates against.
+ * @return
+ */
+ public ArrayList<String> getNamespaces();
+
+ public String getMinimumVersion();
+
+ public String getMaximumVersion();
+
+}
diff --git a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/NullContentAssistRequest.java b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/provisional/contentassist/NullContentAssistRequest.java
similarity index 95%
rename from bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/NullContentAssistRequest.java
rename to bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/provisional/contentassist/NullContentAssistRequest.java
index b78b7bf..03b9285 100644
--- a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/NullContentAssistRequest.java
+++ b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/provisional/contentassist/NullContentAssistRequest.java
@@ -8,7 +8,7 @@
*Contributors:
* David Carver - initial API and implementation
*******************************************************************************/
-package org.eclipse.wst.xsl.ui.internal.contentassist;
+package org.eclipse.wst.xsl.ui.provisional.contentassist;
import java.util.ArrayList;
@@ -21,6 +21,7 @@
/**
* An empty content assist request.
* @author dcarver
+ * @since 1.1
*
*/
public class NullContentAssistRequest extends AbstractXSLContentAssistRequest {
diff --git a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/SelectAttributeContentAssist.java b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/provisional/contentassist/SelectAttributeContentAssist.java
similarity index 97%
rename from bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/SelectAttributeContentAssist.java
rename to bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/provisional/contentassist/SelectAttributeContentAssist.java
index 9300a71..f60bc02 100644
--- a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/SelectAttributeContentAssist.java
+++ b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/provisional/contentassist/SelectAttributeContentAssist.java
@@ -11,7 +11,7 @@
* position adjuster for matchString.
* bug 281420 - fixed variable replacement offsets.
*******************************************************************************/
-package org.eclipse.wst.xsl.ui.internal.contentassist;
+package org.eclipse.wst.xsl.ui.provisional.contentassist;
import java.util.ArrayList;
import java.util.List;
@@ -22,13 +22,13 @@
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.xsl.ui.internal.contentassist.CustomCompletionProposal;
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.xpath.core.util.XSLTXPathHelper;
import org.eclipse.wst.xml.xpath.ui.internal.contentassist.XPathTemplateCompletionProcessor;
import org.eclipse.wst.xml.xpath.ui.internal.templates.TemplateContextTypeIdsXPath;
import org.eclipse.wst.xsl.ui.internal.XSLUIPlugin;
+import org.eclipse.wst.xsl.ui.internal.contentassist.XPathElementContentAssist;
import org.eclipse.wst.xsl.ui.internal.util.XSLPluginImageHelper;
import org.eclipse.wst.xsl.ui.internal.util.XSLPluginImages;
import org.w3c.dom.Element;
@@ -39,12 +39,12 @@
* This class provides content assistance for the XSL select attribute.
*
* @author dcarver
- *
+ * @since 1.1
*/
public class SelectAttributeContentAssist extends
AbstractXSLContentAssistRequest {
- private static final String SELECT_ATTRIBUTE = "select"; //$NON-NLS-1$
+ protected static final String SELECT_ATTRIBUTE = "select"; //$NON-NLS-1$
private static final String XPATH_GLOBAL_VARIABLES = "/xsl:stylesheet/xsl:variable"; //$NON-NLS-1$
@@ -112,7 +112,7 @@
return getAllCompletionProposals();
}
- private IDOMAttr getAttribute(String attrName) {
+ protected IDOMAttr getAttribute(String attrName) {
return (IDOMAttr) ((IDOMElement) getNode()).getAttributeNode(attrName);
}
diff --git a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/TestAttributeContentAssist.java b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/provisional/contentassist/TestAttributeContentAssist.java
similarity index 92%
rename from bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/TestAttributeContentAssist.java
rename to bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/provisional/contentassist/TestAttributeContentAssist.java
index e0b2754..e875df0 100644
--- a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentassist/TestAttributeContentAssist.java
+++ b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/provisional/contentassist/TestAttributeContentAssist.java
@@ -8,7 +8,7 @@
*Contributors:
* David Carver (STAR) - bug 240170 - initial API and implementation
*******************************************************************************/
-package org.eclipse.wst.xsl.ui.internal.contentassist;
+package org.eclipse.wst.xsl.ui.provisional.contentassist;
import java.util.ArrayList;
@@ -25,7 +25,7 @@
* This class provides content assistance for the xsl <emphasis>test</emphais> attribute.
*
* @author dcarver
- *
+ * @since 1.1
*/
public class TestAttributeContentAssist extends SelectAttributeContentAssist {
@@ -51,7 +51,7 @@
/**
* (non-Javadoc)
- * @see org.eclipse.wst.xsl.ui.internal.contentassist.SelectAttributeContentAssist#getCompletionProposals()
+ * @see org.eclipse.wst.xsl.ui.provisional.contentassist.SelectAttributeContentAssist#getCompletionProposals()
*/
@Override
public ArrayList<ICompletionProposal> getCompletionProposals() {