Initial code contribution.
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..9ecf4b9
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+bin
+target
+
diff --git a/plugins/org.eclipse.jst.jee.web.xml/.classpath b/plugins/org.eclipse.jst.jee.web.xml/.classpath
new file mode 100644
index 0000000..2d1a430
--- /dev/null
+++ b/plugins/org.eclipse.jst.jee.web.xml/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.jst.jee.web.xml/.project b/plugins/org.eclipse.jst.jee.web.xml/.project
new file mode 100644
index 0000000..a590fb4
--- /dev/null
+++ b/plugins/org.eclipse.jst.jee.web.xml/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.jst.jee.web.xml</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.jst.jee.web.xml/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.jst.jee.web.xml/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..6e44215
--- /dev/null
+++ b/plugins/org.eclipse.jst.jee.web.xml/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+#Thu Dec 02 09:32:20 CET 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/plugins/org.eclipse.jst.jee.web.xml/META-INF/MANIFEST.MF b/plugins/org.eclipse.jst.jee.web.xml/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..16df6df
--- /dev/null
+++ b/plugins/org.eclipse.jst.jee.web.xml/META-INF/MANIFEST.MF
@@ -0,0 +1,20 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-Vendor: %providerName
+Bundle-Localization: plugin
+Bundle-SymbolicName: org.eclipse.jst.jee.web.xml;singleton:=true
+Bundle-Version: 1.0.0
+Bundle-Activator: org.eclipse.jst.jee.web.xml.internal.WebXMLPlugin
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.wst.xml.search.core;bundle-version="1.0.0",
+ org.eclipse.wst.xml.core,
+ org.eclipse.core.resources,
+ org.eclipse.wst.sse.core,
+ org.eclipse.wst.xml.search.editor;bundle-version="1.0.0",
+ org.eclipse.wst.xml.ui,
+ org.eclipse.swt,
+ org.eclipse.ui
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Export-Package: org.eclipse.jst.jee.web.xml
diff --git a/plugins/org.eclipse.jst.jee.web.xml/build.properties b/plugins/org.eclipse.jst.jee.web.xml/build.properties
new file mode 100644
index 0000000..42724a0
--- /dev/null
+++ b/plugins/org.eclipse.jst.jee.web.xml/build.properties
@@ -0,0 +1,17 @@
+###############################################################################
+# Copyright (c) 2010 Angelo Zerr 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:
+# Angelo Zerr <angelo.zerr@gmail.com> - Initial API and implementation
+###############################################################################
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ plugin.properties,\
+ icons/
diff --git a/plugins/org.eclipse.jst.jee.web.xml/icons/servlet.gif b/plugins/org.eclipse.jst.jee.web.xml/icons/servlet.gif
new file mode 100644
index 0000000..fc1bece
--- /dev/null
+++ b/plugins/org.eclipse.jst.jee.web.xml/icons/servlet.gif
Binary files differ
diff --git a/plugins/org.eclipse.jst.jee.web.xml/plugin.properties b/plugins/org.eclipse.jst.jee.web.xml/plugin.properties
new file mode 100644
index 0000000..20ce1c5
--- /dev/null
+++ b/plugins/org.eclipse.jst.jee.web.xml/plugin.properties
@@ -0,0 +1,14 @@
+###############################################################################
+# Copyright (c) 2010 Angelo Zerr 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:
+# Angelo Zerr <angelo.zerr@gmail.com> - Initial API and implementation
+###############################################################################
+pluginName=Web XML config Core Support
+providerName=Eclipse.org
+
+configFileContentTypeName=XML Web
\ No newline at end of file
diff --git a/plugins/org.eclipse.jst.jee.web.xml/plugin.xml b/plugins/org.eclipse.jst.jee.web.xml/plugin.xml
new file mode 100644
index 0000000..43a959f
--- /dev/null
+++ b/plugins/org.eclipse.jst.jee.web.xml/plugin.xml
@@ -0,0 +1,181 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+
+ <!-- XML Struts2 content type declaration -->
+ <extension
+ point="org.eclipse.core.contenttype.contentTypes">
+ <content-type
+ base-type="org.eclipse.core.runtime.xml"
+ file-extensions="xml"
+ id="org.eclipse.jst.jee.web.xml.contenttype.webXMLConfigFile"
+ name="%configFileContentTypeName"
+ priority="high">
+ <describer
+ class="org.eclipse.core.runtime.content.XMLRootElementContentDescriber2">
+ <parameter
+ name="element"
+ value="web-app">
+ </parameter>
+ </describer>
+ </content-type>
+ </extension>
+
+ <!-- Declaration of references between XML nodes -->
+ <extension
+ point="org.eclipse.wst.xml.search.editor.xmlReferences">
+ <references
+ contentTypeIds="org.eclipse.jst.j2ee.webDD,org.eclipse.jst.jee.ee5webDD,org.eclipse.jst.jee.web.xml.contenttype.webXMLConfigFile">
+
+ <!-- filter/filter-class => Java class -->
+ <reference>
+ <from path="/ns:web-app/ns:filter/ns:filter-class"
+ targetNodes="text()"
+ querySpecificationId="web.querySpecification" />
+ <toJava />
+ </reference>
+ <!-- filter-mapping/filter-name => filter/filter-name -->
+ <reference>
+ <from path="/ns:web-app/ns:filter-mapping/ns:filter-name"
+ targetNodes="text()"
+ querySpecificationId="web.querySpecification" />
+ <to path="/ns:web-app/ns:filter/ns:filter-name"
+ targetNodes="text()"
+ querySpecificationId="web.querySpecification" />
+ </reference>
+
+ <!-- listener/listener-class => Java class -->
+ <reference>
+ <from path="/ns:web-app/ns:listener/ns:listener-class"
+ targetNodes="text()"
+ querySpecificationId="web.querySpecification" />
+ <toJava />
+ </reference>
+
+ <!-- servlet/servlet-class => Java class -->
+ <reference>
+ <from path="/ns:web-app/ns:servlet/ns:servlet-class"
+ targetNodes="text()"
+ querySpecificationId="web.querySpecification" />
+ <toJava />
+ </reference>
+
+ <!-- servlet-mapping/servlet-name => servlet/servlet-name -->
+ <reference>
+ <from path="/ns:web-app/ns:servlet-mapping/ns:servlet-name"
+ targetNodes="text()"
+ querySpecificationId="web.querySpecification" />
+ <to path="/ns:web-app/ns:servlet/ns:servlet-name"
+ targetNodes="text()"
+ querySpecificationId="web.querySpecification"
+ additionalProposalInfoProviderId="web.servlet.info" />
+ </reference>
+
+ <!-- welcome-file -->
+ <reference>
+ <from
+ path="/ns:web-app/ns:welcome-file-list/ns:welcome-file"
+ targetNodes="text()"
+ querySpecificationId="web.querySpecification" >
+ </from>
+ <toResource querySpecificationId="web.files.querySpecification" />
+ </reference>
+ </references>
+ </extension>
+
+ <extension point="org.eclipse.wst.sse.ui.editorConfiguration">
+ <sourceViewerConfiguration
+ class="org.eclipse.wst.xml.search.editor.XMLReferencesStructuredTextViewerConfiguration"
+ target="org.eclipse.jst.j2ee.webDD" />
+ </extension>
+ <extension point="org.eclipse.wst.sse.ui.editorConfiguration">
+ <sourceViewerConfiguration
+ class="org.eclipse.wst.xml.search.editor.XMLReferencesStructuredTextViewerConfiguration"
+ target="org.eclipse.jst.jee.ee5webDD" />
+ </extension>
+ <extension point="org.eclipse.wst.sse.ui.editorConfiguration">
+ <sourceViewerConfiguration
+ class="org.eclipse.wst.xml.search.editor.XMLReferencesStructuredTextViewerConfiguration"
+ target="org.eclipse.jst.jee.web.xml.contenttype.webXMLConfigFile" />
+ </extension>
+
+ <!-- Source validation for XML web.xml files -->
+ <extension point="org.eclipse.wst.sse.ui.sourcevalidation">
+ <validator
+ scope="partial"
+ class="org.eclipse.wst.xml.ui.internal.validation.MarkupValidator"
+ id="org.eclipse.jst.j2ee.webDD.validation.MarkupValidator">
+ <contentTypeIdentifier id="org.eclipse.jst.j2ee.webDD">
+ <partitionType id="org.eclipse.wst.xml.XML_DEFAULT">
+ </partitionType>
+ </contentTypeIdentifier>
+ <contentTypeIdentifier id="org.eclipse.jst.jee.ee5webDD" >
+ <partitionType id="org.eclipse.wst.xml.XML_DEFAULT">
+ </partitionType>
+ </contentTypeIdentifier>
+ <contentTypeIdentifier id="org.eclipse.jst.jee.web.xml.contenttype.webXMLConfigFile">
+ <partitionType id="org.eclipse.wst.xml.XML_DEFAULT">
+ </partitionType>
+ </contentTypeIdentifier>
+ </validator>
+ </extension>
+ <extension point="org.eclipse.wst.sse.ui.sourcevalidation">
+ <validator
+ scope="partial"
+ class="org.eclipse.wst.xml.ui.internal.validation.DelegatingSourceValidatorForXML"
+ id="org.eclipse.jst.j2ee.webDD.validation.DelegatingSourceValidatorForXML">
+ <contentTypeIdentifier id="org.eclipse.jst.j2ee.webDD">
+ <partitionType id="org.eclipse.wst.xml.XML_DEFAULT">
+ </partitionType>
+ </contentTypeIdentifier>
+ <contentTypeIdentifier id="org.eclipse.jst.jee.ee5webDD" >
+ <partitionType id="org.eclipse.wst.xml.XML_DEFAULT">
+ </partitionType>
+ </contentTypeIdentifier>
+ <contentTypeIdentifier id="org.eclipse.jst.jee.web.xml.contenttype.webXMLConfigFile">
+ <partitionType id="org.eclipse.wst.xml.XML_DEFAULT">
+ </partitionType>
+ </contentTypeIdentifier>
+ </validator>
+ </extension>
+
+ <extension point="org.eclipse.wst.sse.ui.sourcevalidation">
+ <validator
+ scope="partial"
+ class="org.eclipse.wst.xml.search.editor.validation.XMLReferencesValidator"
+ id="org.eclipse.jst.j2ee.webDD.validation.Validator">
+ <contentTypeIdentifier id="org.eclipse.jst.j2ee.webDD">
+ <partitionType id="org.eclipse.wst.xml.XML_DEFAULT">
+ </partitionType>
+ </contentTypeIdentifier>
+ <contentTypeIdentifier id="org.eclipse.jst.jee.ee5webDD" >
+ <partitionType id="org.eclipse.wst.xml.XML_DEFAULT">
+ </partitionType>
+ </contentTypeIdentifier>
+ <contentTypeIdentifier id="org.eclipse.jst.jee.web.xml.contenttype.webXMLConfigFile">
+ <partitionType id="org.eclipse.wst.xml.XML_DEFAULT">
+ </partitionType>
+ </contentTypeIdentifier>
+ </validator>
+ </extension>
+
+ <extension
+ point="org.eclipse.wst.xml.search.core.querySpecifications">
+ <querySpecification id="web.querySpecification"
+ class="org.eclipse.jst.jee.web.xml.internal.search.WebXMLQuerySpecification" />
+ </extension>
+
+ <extension
+ point="org.eclipse.wst.xml.search.core.resourceQuerySpecifications">
+ <querySpecification id="web.files.querySpecification"
+ class="org.eclipse.jst.jee.web.xml.internal.search.WebContentResourcesQuerySpecification" />
+ </extension>
+
+ <extension
+ point="org.eclipse.wst.xml.search.editor.contentAssists">
+ <additionalProposalInfoProvider id="web.servlet.info"
+ class="org.eclipse.jst.jee.web.xml.internal.search.contentassist.ServletContentAssistAdditionalProposalInfoProvider" >
+ </additionalProposalInfoProvider>
+ </extension>
+
+</plugin>
diff --git a/plugins/org.eclipse.jst.jee.web.xml/src/org/eclipse/jst/jee/web/xml/WebXMLConstants.java b/plugins/org.eclipse.jst.jee.web.xml/src/org/eclipse/jst/jee/web/xml/WebXMLConstants.java
new file mode 100644
index 0000000..8040951
--- /dev/null
+++ b/plugins/org.eclipse.jst.jee.web.xml/src/org/eclipse/jst/jee/web/xml/WebXMLConstants.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.jee.web.xml;
+
+public interface WebXMLConstants {
+
+ String STRUTS2_CONFIG_CONTENT_TYPE = "org.apache.struts2.ide.contenttype.struts2ConfigFile";
+
+ // XML Attributes
+ String NAME_ATTR = "name";
+ String CLASS_ATTR = "class";
+ String ABSTRACT_ATTR = "abstract";
+ String DEFAULT_ATTR = "default";
+}
diff --git a/plugins/org.eclipse.jst.jee.web.xml/src/org/eclipse/jst/jee/web/xml/internal/WebXMLPlugin.java b/plugins/org.eclipse.jst.jee.web.xml/src/org/eclipse/jst/jee/web/xml/internal/WebXMLPlugin.java
new file mode 100644
index 0000000..7644cb2
--- /dev/null
+++ b/plugins/org.eclipse.jst.jee.web.xml/src/org/eclipse/jst/jee/web/xml/internal/WebXMLPlugin.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.jee.web.xml.internal;
+
+import java.net.URL;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class WebXMLPlugin extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.jst.jee.web.xml";
+
+ // The shared instance
+ private static WebXMLPlugin plugin;
+
+ public static String SERVLET_IMG = "servlet";
+
+ /**
+ * The constructor
+ */
+ public WebXMLPlugin() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
+ * )
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+
+ URL baseIconsURL = getBundle().getEntry("icons/");
+ ImageDescriptor servletImage = ImageDescriptor.createFromURL(new URL(
+ baseIconsURL, "servlet.gif"));
+ getImageRegistry().put(SERVLET_IMG, servletImage);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
+ * )
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static WebXMLPlugin getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/plugins/org.eclipse.jst.jee.web.xml/src/org/eclipse/jst/jee/web/xml/internal/search/WebContentResourcesQuerySpecification.java b/plugins/org.eclipse.jst.jee.web.xml/src/org/eclipse/jst/jee/web/xml/internal/search/WebContentResourcesQuerySpecification.java
new file mode 100644
index 0000000..4ec6fa1
--- /dev/null
+++ b/plugins/org.eclipse.jst.jee.web.xml/src/org/eclipse/jst/jee/web/xml/internal/search/WebContentResourcesQuerySpecification.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.jee.web.xml.internal.search;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.wst.xml.search.core.queryspecifications.container.IResourceProvider;
+import org.eclipse.wst.xml.search.core.resource.IResourceRequestor;
+import org.eclipse.wst.xml.search.core.resource.IResourceRequestorProvider;
+
+public class WebContentResourcesQuerySpecification implements
+ IResourceProvider, IResourceRequestorProvider {
+
+ public IResource getResource(Object selectedNode, IResource resource) {
+ return resource.getParent().getParent();
+ }
+
+ public IResourceRequestor getRequestor() {
+ return WebContentResourcesRequestor.INSTANCE;
+ }
+
+}
diff --git a/plugins/org.eclipse.jst.jee.web.xml/src/org/eclipse/jst/jee/web/xml/internal/search/WebContentResourcesRequestor.java b/plugins/org.eclipse.jst.jee.web.xml/src/org/eclipse/jst/jee/web/xml/internal/search/WebContentResourcesRequestor.java
new file mode 100644
index 0000000..f7894d7
--- /dev/null
+++ b/plugins/org.eclipse.jst.jee.web.xml/src/org/eclipse/jst/jee/web/xml/internal/search/WebContentResourcesRequestor.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.jee.web.xml.internal.search;
+
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+import org.eclipse.wst.xml.search.core.resource.DefaultResourceRequestor;
+import org.eclipse.wst.xml.search.core.resource.IResourceRequestor;
+import org.eclipse.wst.xml.search.core.resource.IURIResolver;
+
+public class WebContentResourcesRequestor extends DefaultResourceRequestor {
+
+ public static final IResourceRequestor INSTANCE = new WebContentResourcesRequestor();
+
+ @Override
+ public boolean accept(Object selectedNode, IResource rootContainer,
+ IFolder folder, IURIResolver resolver, String matching,
+ boolean fullMatch) {
+ if ("WEB-INF".equals(folder.getName())) {
+ return false;
+ }
+ if ("META-INF".equals(folder.getName())) {
+ return false;
+ }
+ return super.accept(selectedNode, rootContainer, folder, resolver,
+ matching, fullMatch);
+ }
+}
diff --git a/plugins/org.eclipse.jst.jee.web.xml/src/org/eclipse/jst/jee/web/xml/internal/search/WebXMLQuerySpecification.java b/plugins/org.eclipse.jst.jee.web.xml/src/org/eclipse/jst/jee/web/xml/internal/search/WebXMLQuerySpecification.java
new file mode 100644
index 0000000..f179efa
--- /dev/null
+++ b/plugins/org.eclipse.jst.jee.web.xml/src/org/eclipse/jst/jee/web/xml/internal/search/WebXMLQuerySpecification.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.jee.web.xml.internal.search;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.wst.xml.search.core.queryspecifications.container.IResourceProvider;
+import org.eclipse.wst.xml.search.core.queryspecifications.container.IdentityResourceProvider;
+import org.eclipse.wst.xml.search.core.queryspecifications.requestor.IXMLSearchRequestor;
+import org.eclipse.wst.xml.search.core.queryspecifications.requestor.IXMLSearchRequestorProvider;
+
+public class WebXMLQuerySpecification implements IXMLSearchRequestorProvider,
+ IResourceProvider {
+
+ public IXMLSearchRequestor getRequestor() {
+ return WebXMLSearchRequestor.INSTANCE;
+ }
+
+ public IResource getResource(Object selectedNode, IResource resource) {
+ return resource;
+ }
+
+}
diff --git a/plugins/org.eclipse.jst.jee.web.xml/src/org/eclipse/jst/jee/web/xml/internal/search/WebXMLSearchRequestor.java b/plugins/org.eclipse.jst.jee.web.xml/src/org/eclipse/jst/jee/web/xml/internal/search/WebXMLSearchRequestor.java
new file mode 100644
index 0000000..f8b5193
--- /dev/null
+++ b/plugins/org.eclipse.jst.jee.web.xml/src/org/eclipse/jst/jee/web/xml/internal/search/WebXMLSearchRequestor.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.jee.web.xml.internal.search;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.wst.xml.search.core.queryspecifications.requestor.AbstractXMLSearchRequestor;
+import org.eclipse.wst.xml.search.core.queryspecifications.requestor.IXMLSearchRequestor;
+
+public class WebXMLSearchRequestor extends AbstractXMLSearchRequestor {
+
+ public static IXMLSearchRequestor INSTANCE = new WebXMLSearchRequestor();
+
+ @Override
+ protected boolean accept(IFile file, IResource rootResource) {
+ return true;
+ }
+}
diff --git a/plugins/org.eclipse.jst.jee.web.xml/src/org/eclipse/jst/jee/web/xml/internal/search/contentassist/ServletContentAssistAdditionalProposalInfoProvider.java b/plugins/org.eclipse.jst.jee.web.xml/src/org/eclipse/jst/jee/web/xml/internal/search/contentassist/ServletContentAssistAdditionalProposalInfoProvider.java
new file mode 100644
index 0000000..7d1e933
--- /dev/null
+++ b/plugins/org.eclipse.jst.jee.web.xml/src/org/eclipse/jst/jee/web/xml/internal/search/contentassist/ServletContentAssistAdditionalProposalInfoProvider.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.jee.web.xml.internal.search.contentassist;
+
+import org.eclipse.jst.jee.web.xml.internal.WebXMLPlugin;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
+import org.eclipse.wst.xml.search.editor.contentassist.ElementContentAssistAdditionalProposalInfoProvider;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+public class ServletContentAssistAdditionalProposalInfoProvider extends
+ ElementContentAssistAdditionalProposalInfoProvider {
+
+ public Image getImage(Node node) {
+ return WebXMLPlugin.getDefault().getImageRegistry().get(
+ WebXMLPlugin.SERVLET_IMG);
+ }
+
+ @Override
+ protected String doGetTextInfo(IDOMElement servletNameElt) {
+ IDOMElement element = (IDOMElement)servletNameElt.getParentNode();
+ StringBuilder buf = new StringBuilder();
+ buf.append("<b>------------------------ Servlet ------------------------</b> ");
+ // description
+ buf.append("<br><b>Description:</b> ");
+ String description = getTextContent(element, "description");
+ if (description != null) {
+ buf.append(description);
+ }
+ // display-name
+ buf.append("<br><b>Display name:</b> ");
+ String displayName = getTextContent(element, "display-name");
+ if (displayName != null) {
+ buf.append(displayName);
+ }
+ // servlet-name
+ buf.append("<br><b>Servlet name:</b> ");
+ String servletName = getTextContent(element, "servlet-name");
+ if (servletName != null) {
+ buf.append(servletName);
+ }
+ // servlet-class
+ buf.append("<br><b>Servlet class:</b> ");
+ String servletClass = getTextContent(element, "servlet-class");
+ if (servletClass != null) {
+ buf.append(servletClass);
+ }
+ //buf.append("<br><b>File:</b> ");
+ //String baseLocation = element.getModel().getBaseLocation();
+ //buf.append(baseLocation);
+ return buf.toString();
+
+ }
+
+ private String getTextContent(IDOMElement element, String elementName) {
+ NodeList nodes = element.getElementsByTagName(elementName);
+ if (nodes.getLength() < 1) {
+ return "";
+ }
+ Element childElement = (Element)nodes.item(0);
+ Text text = (Text) childElement.getFirstChild();
+ if (text == null) {
+ return "";
+ }
+ return text.getData();
+ }
+
+}
diff --git a/plugins/org.eclipse.jst.jsp.search.editor/.classpath b/plugins/org.eclipse.jst.jsp.search.editor/.classpath
new file mode 100644
index 0000000..2d1a430
--- /dev/null
+++ b/plugins/org.eclipse.jst.jsp.search.editor/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.jst.jsp.search.editor/.project b/plugins/org.eclipse.jst.jsp.search.editor/.project
new file mode 100644
index 0000000..8cb13fa
--- /dev/null
+++ b/plugins/org.eclipse.jst.jsp.search.editor/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.jst.jsp.search.editor</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.jst.jsp.search.editor/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.jst.jsp.search.editor/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..423215b
--- /dev/null
+++ b/plugins/org.eclipse.jst.jsp.search.editor/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+#Wed Jan 19 14:52:01 CET 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/plugins/org.eclipse.jst.jsp.search.editor/META-INF/MANIFEST.MF b/plugins/org.eclipse.jst.jsp.search.editor/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..8c3ba5d
--- /dev/null
+++ b/plugins/org.eclipse.jst.jsp.search.editor/META-INF/MANIFEST.MF
@@ -0,0 +1,27 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-Vendor: %providerName
+Bundle-Localization: plugin
+Bundle-SymbolicName: org.eclipse.jst.jsp.search.editor;singleton:=true
+Bundle-Version: 1.0.0
+Bundle-Activator: org.eclipse.jst.jsp.search.editor.Activator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.wst.sse.ui,
+ org.eclipse.jst.jsp.ui,
+ org.eclipse.jface.text,
+ org.eclipse.wst.xml.ui,
+ org.eclipse.wst.sse.core,
+ org.eclipse.wst.xml.core,
+ org.eclipse.wst.xml.search.editor;bundle-version="1.0.0",
+ org.eclipse.wst.xml.search.core;bundle-version="1.0.0",
+ org.eclipse.core.resources,
+ org.eclipse.jst.jsp.core,
+ org.eclipse.ui.workbench.texteditor
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Export-Package: org.eclipse.jst.jsp.search.editor,
+ org.eclipse.jst.jsp.search.editor.queryspecifications,
+ org.eclipse.jst.jsp.search.editor.references.filters,
+ org.eclipse.jst.jsp.search.editor.util
diff --git a/plugins/org.eclipse.jst.jsp.search.editor/build.properties b/plugins/org.eclipse.jst.jsp.search.editor/build.properties
new file mode 100644
index 0000000..8454c29
--- /dev/null
+++ b/plugins/org.eclipse.jst.jsp.search.editor/build.properties
@@ -0,0 +1,16 @@
+###############################################################################
+# Copyright (c) 2010 Angelo Zerr 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:
+# Angelo Zerr <angelo.zerr@gmail.com> - Initial API and implementation
+###############################################################################
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ plugin.properties
diff --git a/plugins/org.eclipse.jst.jsp.search.editor/plugin.properties b/plugins/org.eclipse.jst.jsp.search.editor/plugin.properties
new file mode 100644
index 0000000..7c6a6d5
--- /dev/null
+++ b/plugins/org.eclipse.jst.jsp.search.editor/plugin.properties
@@ -0,0 +1,14 @@
+###############################################################################
+# Copyright (c) 2010 Angelo Zerr 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:
+# Angelo Zerr <angelo.zerr@gmail.com> - Initial API and implementation
+###############################################################################
+pluginName=WST JSP Search Editor
+providerName=Angelo ZERR
+
+JSPReferencesBatchValidator_description= JSP References Validator
\ No newline at end of file
diff --git a/plugins/org.eclipse.jst.jsp.search.editor/plugin.xml b/plugins/org.eclipse.jst.jsp.search.editor/plugin.xml
new file mode 100644
index 0000000..c0a997c
--- /dev/null
+++ b/plugins/org.eclipse.jst.jsp.search.editor/plugin.xml
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+<plugin>
+
+ <extension
+ point="org.eclipse.wst.sse.ui.editorConfiguration">
+ <sourceViewerConfiguration
+ class="org.eclipse.jst.jsp.ui.StructuredTextViewerConfigurationJSP"
+ target="org.eclipse.jst.jsp.core.jspsource" />
+ <provisionalConfiguration
+ type="contentassistprocessor"
+ class="org.eclipse.jst.jsp.search.editor.internal.contentassist.JSPReferenceContentAssistProcessor"
+ target="org.eclipse.jst.jsp.JSP_DIRECTIVE" />
+ <!--<documentationTextHover
+ class="org.eclipse.wst.xml.search.editor.hover.XMLReferencesInfoHoverProcessor"
+ target="org.eclipse.jst.jsp.JSP_DEFAULT,org.eclipse.jst.jsp.JSP_DIRECTIVE">
+ </documentationTextHover>-->
+ <!--<provisionalConfiguration
+ type="linestyleprovider"
+ class="org.eclipse.jst.jsp.search.editor.JSPReferencesContentAssistProcessor"
+ target="org.eclipse.jst.jsp.JSP_DIRECTIVE" />-->
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.workbench.texteditor.hyperlinkDetectors">
+ <hyperlinkDetector
+ class="org.eclipse.wst.xml.search.editor.hyperlink.XMLReferencesHyperlinkDetector"
+ id="org.eclipse.jst.jsp.search.editor.internal.hyperlink.JSPReferenceHyperlinkDetector"
+ name="%JSPJava_hyperlink"
+ targetId="org.eclipse.jst.jsp.core.jspsource">
+ </hyperlinkDetector>
+ </extension>
+
+ <extension point="org.eclipse.wst.sse.ui.sourcevalidation">
+ <validator
+ scope="partial"
+ class="org.eclipse.wst.xml.search.editor.validation.XMLReferencesValidator"
+ id="org.eclipse.jst.jsp.search.editor.JSPSearchValidator">
+ <contentTypeIdentifier id="org.eclipse.jst.jsp.core.jspsource">
+ <partitionType id="org.eclipse.jst.jsp.JSP_DIRECTIVE">
+ </partitionType>
+ </contentTypeIdentifier>
+ </validator>
+ </extension>
+
+ <extension id="jspReferencesBatchValidator" name="%JSPReferencesBatchValidator_description" point="org.eclipse.wst.validation.validatorV2">
+ <validator
+ build="true"
+ class="org.eclipse.wst.xml.search.editor.validation.XMLReferencesBatchValidator"
+ manual="true"
+ version="1"
+ markerId="org.eclipse.wst.xml.search.editor.validationMarker">
+ <include>
+ <rules>
+ <fileext
+ caseSensitive="false"
+ ext="jsp">
+ </fileext>
+ </rules>
+ </include>
+ </validator>
+ </extension>
+
+</plugin>
\ No newline at end of file
diff --git a/plugins/org.eclipse.jst.jsp.search.editor/src/org/eclipse/jst/jsp/search/editor/Activator.java b/plugins/org.eclipse.jst.jsp.search.editor/src/org/eclipse/jst/jsp/search/editor/Activator.java
new file mode 100644
index 0000000..59f4997
--- /dev/null
+++ b/plugins/org.eclipse.jst.jsp.search.editor/src/org/eclipse/jst/jsp/search/editor/Activator.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.jsp.search.editor;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.jst.jsp.search.editor";
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/plugins/org.eclipse.jst.jsp.search.editor/src/org/eclipse/jst/jsp/search/editor/internal/contentassist/JSPReferenceContentAssistProcessor.java b/plugins/org.eclipse.jst.jsp.search.editor/src/org/eclipse/jst/jsp/search/editor/internal/contentassist/JSPReferenceContentAssistProcessor.java
new file mode 100644
index 0000000..051f371
--- /dev/null
+++ b/plugins/org.eclipse.jst.jsp.search.editor/src/org/eclipse/jst/jsp/search/editor/internal/contentassist/JSPReferenceContentAssistProcessor.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.jsp.search.editor.internal.contentassist;
+
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+import org.eclipse.wst.xml.search.editor.contentassist.XMLReferencesContentAssistUtils;
+import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
+import org.eclipse.wst.xml.ui.internal.contentassist.XMLContentAssistProcessor;
+
+public class JSPReferenceContentAssistProcessor extends
+ XMLContentAssistProcessor {
+
+ @Override
+ protected void addAttributeValueProposals(
+ ContentAssistRequest contentAssistRequest) {
+ int proposalCount = 0;
+ if (contentAssistRequest.getCompletionProposals() != null) {
+ proposalCount = contentAssistRequest.getCompletionProposals().length;
+ }
+ IDOMNode node = (IDOMNode) contentAssistRequest.getNode();
+ // XML reference
+ XMLReferencesContentAssistUtils
+ .addAttributeValueProposals(contentAssistRequest);
+
+ super.addAttributeValueProposals(contentAssistRequest);
+
+ }
+}
diff --git a/plugins/org.eclipse.jst.jsp.search.editor/src/org/eclipse/jst/jsp/search/editor/internal/contentassist/util/TaglibUtils.java b/plugins/org.eclipse.jst.jsp.search.editor/src/org/eclipse/jst/jsp/search/editor/internal/contentassist/util/TaglibUtils.java
new file mode 100644
index 0000000..90c002e
--- /dev/null
+++ b/plugins/org.eclipse.jst.jsp.search.editor/src/org/eclipse/jst/jsp/search/editor/internal/contentassist/util/TaglibUtils.java
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.jsp.search.editor.internal.contentassist.util;
+
+import org.eclipse.jst.jsp.core.internal.contentmodel.tld.provisional.TLDAttributeDeclaration;
+import org.eclipse.jst.jsp.core.internal.contentmodel.tld.provisional.TLDDocument;
+import org.eclipse.jst.jsp.core.internal.contentmodel.tld.provisional.TLDElementDeclaration;
+import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
+import org.eclipse.wst.xml.core.internal.ssemodelquery.ModelQueryAdapter;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+public class TaglibUtils {
+
+ public static String getTagURI(Node node) {
+ int nodeType = node.getNodeType();
+ switch (nodeType) {
+ case Node.ATTRIBUTE_NODE:
+ Attr attr = (Attr) node;
+ return getTagURI(attr);
+ case Node.ELEMENT_NODE:
+ Element element = (Element) node;
+ return getTagURI(element);
+ }
+ return null;
+ }
+
+ public static String getTagURI(Attr attr) {
+ CMAttributeDeclaration decl = getAttributeDeclaration(attr);
+ if (decl == null) {
+ return null;
+ }
+ if (decl instanceof TLDAttributeDeclaration) {
+ CMDocument doc = ((TLDAttributeDeclaration) decl)
+ .getOwnerDocument();
+ if (doc instanceof TLDDocument) {
+ return ((TLDDocument) doc).getUri();
+ }
+ }
+ return null;
+ }
+
+ public static String getTagURI(Element element) {
+ CMElementDeclaration decl = getElementDeclaration(element);
+ if (decl == null) {
+ return null;
+ }
+ if (decl instanceof TLDElementDeclaration) {
+ CMDocument doc = ((TLDElementDeclaration) decl).getOwnerDocument();
+ if (doc instanceof TLDDocument) {
+ return ((TLDDocument) doc).getUri();
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Get attribute declaration of specified element
+ *
+ * @param attr
+ * @return null if can't get it.
+ */
+ public static CMAttributeDeclaration getAttributeDeclaration(Attr attr) {
+ if (attr == null) {
+ return null;
+ }
+ INodeNotifier notifier = (INodeNotifier) attr.getOwnerDocument();
+ if (notifier == null) {
+ return null;
+ }
+ ModelQueryAdapter mqa = (ModelQueryAdapter) notifier
+ .getAdapterFor(ModelQueryAdapter.class);
+ if (mqa == null) {
+ return null;
+ }
+ return mqa.getModelQuery().getCMAttributeDeclaration(attr);
+ }
+
+ /**
+ * get element declaration of specified element
+ *
+ * @param element
+ * @return null if can't get it.
+ */
+ public static CMElementDeclaration getElementDeclaration(Element element) {
+ if (element == null) {
+ return null;
+ }
+ INodeNotifier notifier = (INodeNotifier) element.getOwnerDocument();
+ if (notifier == null) {
+ return null;
+ }
+ ModelQueryAdapter mqa = (ModelQueryAdapter) notifier
+ .getAdapterFor(ModelQueryAdapter.class);
+ if (mqa == null) {
+ return null;
+ }
+ return mqa.getModelQuery().getCMElementDeclaration(element);
+ }
+
+}
diff --git a/plugins/org.eclipse.jst.jsp.search.editor/src/org/eclipse/jst/jsp/search/editor/queryspecifications/JSPQuerySpecification.java b/plugins/org.eclipse.jst.jsp.search.editor/src/org/eclipse/jst/jsp/search/editor/queryspecifications/JSPQuerySpecification.java
new file mode 100644
index 0000000..4d984a7
--- /dev/null
+++ b/plugins/org.eclipse.jst.jsp.search.editor/src/org/eclipse/jst/jsp/search/editor/queryspecifications/JSPQuerySpecification.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.jsp.search.editor.queryspecifications;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.wst.xml.search.core.queryspecifications.container.IResourceProvider;
+import org.eclipse.wst.xml.search.core.queryspecifications.requestor.IXMLSearchRequestor;
+import org.eclipse.wst.xml.search.core.queryspecifications.requestor.IXMLSearchRequestorProvider;
+import org.eclipse.wst.xml.search.core.queryspecifications.visitor.IXMLSearchDOMDocumentVisitor;
+import org.eclipse.wst.xml.search.core.queryspecifications.visitor.IXMLSearchVisitorProvider;
+import org.eclipse.wst.xml.search.editor.queryspecifications.visitor.XPathPathNodeSetSearchVisitorWithFilter;
+import org.eclipse.wst.xml.search.editor.references.filters.IXMLReferenceFilter;
+
+public abstract class JSPQuerySpecification implements
+ IXMLSearchRequestorProvider, IResourceProvider,
+ IXMLSearchVisitorProvider {
+
+ private final IXMLSearchDOMDocumentVisitor visitor;
+
+ public JSPQuerySpecification(IXMLReferenceFilter filter) {
+ visitor = new XPathPathNodeSetSearchVisitorWithFilter(filter);
+ }
+
+ public IXMLSearchRequestor getRequestor() {
+ return JSPSearchRequestor.INSTANCE;
+ }
+
+ public IResource getResource(Object selectedNode, IResource resource) {
+ return WebContentFolderProvider.INSTANCE.getResource(selectedNode,
+ resource);
+ }
+
+ public IXMLSearchDOMDocumentVisitor getVisitor() {
+ return visitor;
+ }
+}
diff --git a/plugins/org.eclipse.jst.jsp.search.editor/src/org/eclipse/jst/jsp/search/editor/queryspecifications/JSPSearchRequestor.java b/plugins/org.eclipse.jst.jsp.search.editor/src/org/eclipse/jst/jsp/search/editor/queryspecifications/JSPSearchRequestor.java
new file mode 100644
index 0000000..bbf84e6
--- /dev/null
+++ b/plugins/org.eclipse.jst.jsp.search.editor/src/org/eclipse/jst/jsp/search/editor/queryspecifications/JSPSearchRequestor.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.jsp.search.editor.queryspecifications;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jst.jsp.core.internal.provisional.contenttype.ContentTypeIdForJSP;
+import org.eclipse.wst.xml.search.core.queryspecifications.requestor.ContentTypeXMLSearchRequestor;
+import org.eclipse.wst.xml.search.core.queryspecifications.requestor.IXMLSearchRequestor;
+
+public class JSPSearchRequestor extends ContentTypeXMLSearchRequestor {
+
+ private static final String META_INF = "META-INF";
+ private static final String WEB_INF = "WEB-INF";
+
+ public static IXMLSearchRequestor INSTANCE = new JSPSearchRequestor();
+
+ @Override
+ protected Collection<String> getSupportedContentTypeIds() {
+ Collection<String> contentTypeIds = new ArrayList<String>();
+ contentTypeIds.add(ContentTypeIdForJSP.ContentTypeID_JSP);
+ return contentTypeIds;
+ }
+
+ @Override
+ public boolean accept(IFolder folder, IResource rootResource) {
+ if (WEB_INF.equals(folder.getName())
+ || META_INF.equals(folder.getName())) {
+ return false;
+ }
+ return super.accept(folder, rootResource);
+ }
+
+}
diff --git a/plugins/org.eclipse.jst.jsp.search.editor/src/org/eclipse/jst/jsp/search/editor/queryspecifications/WebContentFolderProvider.java b/plugins/org.eclipse.jst.jsp.search.editor/src/org/eclipse/jst/jsp/search/editor/queryspecifications/WebContentFolderProvider.java
new file mode 100644
index 0000000..0ef05b9
--- /dev/null
+++ b/plugins/org.eclipse.jst.jsp.search.editor/src/org/eclipse/jst/jsp/search/editor/queryspecifications/WebContentFolderProvider.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.jsp.search.editor.queryspecifications;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jst.jsp.search.editor.util.WebProjectUtils;
+import org.eclipse.wst.xml.search.core.queryspecifications.container.IResourceProvider;
+
+public class WebContentFolderProvider implements IResourceProvider {
+
+ public static final IResourceProvider INSTANCE = new WebContentFolderProvider();;
+
+ public IResource getResource(Object selectedNode, IResource resource) {
+ return WebProjectUtils.getWebContentRootFolder(resource.getProject());
+ }
+
+}
diff --git a/plugins/org.eclipse.jst.jsp.search.editor/src/org/eclipse/jst/jsp/search/editor/references/filters/AbstractTaglibReferenceFilter.java b/plugins/org.eclipse.jst.jsp.search.editor/src/org/eclipse/jst/jsp/search/editor/references/filters/AbstractTaglibReferenceFilter.java
new file mode 100644
index 0000000..81141ef
--- /dev/null
+++ b/plugins/org.eclipse.jst.jsp.search.editor/src/org/eclipse/jst/jsp/search/editor/references/filters/AbstractTaglibReferenceFilter.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.jsp.search.editor.references.filters;
+
+import java.util.Collection;
+
+import org.eclipse.jst.jsp.search.editor.internal.contentassist.util.TaglibUtils;
+import org.eclipse.wst.sse.core.utils.StringUtils;
+import org.eclipse.wst.xml.search.editor.references.filters.IXMLReferenceFilter;
+import org.w3c.dom.Node;
+
+public abstract class AbstractTaglibReferenceFilter implements
+ IXMLReferenceFilter {
+
+ private Collection<String> taglibURIs = null;
+
+ public boolean accept(Node node) {
+ String taglibURI = TaglibUtils.getTagURI(node);
+ if (StringUtils.isQuoted(taglibURI)) {
+ return false;
+ }
+ Collection<String> uris = internalGetTaglibURIs();
+ return uris.contains(taglibURI);
+ }
+
+ public Collection<String> internalGetTaglibURIs() {
+ if (taglibURIs == null) {
+ taglibURIs = getTaglibURIs();
+ }
+ return taglibURIs;
+ }
+
+ protected abstract Collection<String> getTaglibURIs();
+}
diff --git a/plugins/org.eclipse.jst.jsp.search.editor/src/org/eclipse/jst/jsp/search/editor/util/WebProjectUtils.java b/plugins/org.eclipse.jst.jsp.search.editor/src/org/eclipse/jst/jsp/search/editor/util/WebProjectUtils.java
new file mode 100644
index 0000000..d3e1aac
--- /dev/null
+++ b/plugins/org.eclipse.jst.jsp.search.editor/src/org/eclipse/jst/jsp/search/editor/util/WebProjectUtils.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.jsp.search.editor.util;
+
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jst.jsp.core.internal.util.FacetModuleCoreSupport;
+
+public class WebProjectUtils {
+
+ public static IFolder getWebContentRootFolder(IProject project) {
+ IPath webContentPath = FacetModuleCoreSupport.getWebContentRootPath(project);
+ if(webContentPath != null) {
+ return (IFolder)ResourcesPlugin.getWorkspace().getRoot().findMember(webContentPath);
+ }
+ return null;
+ }
+}
diff --git a/plugins/org.eclipse.wst.html.search.editor/.classpath b/plugins/org.eclipse.wst.html.search.editor/.classpath
new file mode 100644
index 0000000..2d1a430
--- /dev/null
+++ b/plugins/org.eclipse.wst.html.search.editor/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.wst.html.search.editor/.project b/plugins/org.eclipse.wst.html.search.editor/.project
new file mode 100644
index 0000000..d39c587
--- /dev/null
+++ b/plugins/org.eclipse.wst.html.search.editor/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.wst.html.search.editor</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.wst.html.search.editor/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.wst.html.search.editor/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..2217aed
--- /dev/null
+++ b/plugins/org.eclipse.wst.html.search.editor/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+#Mon Jul 04 14:28:17 CEST 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/plugins/org.eclipse.wst.html.search.editor/META-INF/MANIFEST.MF b/plugins/org.eclipse.wst.html.search.editor/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..63d8ab2
--- /dev/null
+++ b/plugins/org.eclipse.wst.html.search.editor/META-INF/MANIFEST.MF
@@ -0,0 +1,17 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Editor
+Bundle-SymbolicName: org.eclipse.wst.html.search.editor;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.eclipse.wst.html.search.editor.Activator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.wst.xml.search.editor;bundle-version="1.0.0",
+ org.eclipse.wst.html.ui,
+ org.eclipse.wst.xml.ui,
+ org.eclipse.wst.sse.ui,
+ org.eclipse.wst.sse.core,
+ org.eclipse.wst.xml.core,
+ org.eclipse.jface.text
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/plugins/org.eclipse.wst.html.search.editor/build.properties b/plugins/org.eclipse.wst.html.search.editor/build.properties
new file mode 100644
index 0000000..41eb6ad
--- /dev/null
+++ b/plugins/org.eclipse.wst.html.search.editor/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/plugins/org.eclipse.wst.html.search.editor/plugin.xml b/plugins/org.eclipse.wst.html.search.editor/plugin.xml
new file mode 100644
index 0000000..88850b4
--- /dev/null
+++ b/plugins/org.eclipse.wst.html.search.editor/plugin.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+
+ <extension point="org.eclipse.wst.sse.ui.completionProposal">
+ <proposalCategory
+ icon="search.png"
+ id="org.eclipse.wst.html.ui.proposalCategory.wtpxmlsearch"
+ name="WTP XML Search - HTML">
+ </proposalCategory>
+ <proposalComputer
+ activate="true"
+ categoryId="org.eclipse.wst.html.ui.proposalCategory.wtpxmlsearch"
+ class="org.eclipse.wst.html.search.editor.internal.contentassist.HTMLReferencesCompletionProposalComputer"
+ id="org.eclipse.wst.html.search.editor.internal.contentassist.HTMLReferencesCompletionProposalComputer">
+ <contentType
+ id="org.eclipse.wst.html.core.htmlsource">
+ <partitionType id="org.eclipse.wst.html.HTML_DEFAULT"></partitionType>
+ </contentType>
+ </proposalComputer>
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.workbench.texteditor.hyperlinkDetectors">
+ <hyperlinkDetector
+ class="org.eclipse.wst.xml.search.editor.hyperlink.XMLReferencesHyperlinkDetector"
+ id="org.eclipse.wst.html.search.editor.internal.hyperlink.HTMLReferenceHyperlinkDetector"
+ name="%HTMLSearch_hyperlink"
+ targetId="org.eclipse.wst.html.core.htmlsource">
+ </hyperlinkDetector>
+ </extension>
+
+ <extension point="org.eclipse.wst.sse.ui.sourcevalidation">
+ <validator
+ scope="partial"
+ class="org.eclipse.wst.xml.search.editor.validation.XMLReferencesValidator"
+ id="org.eclipse.wst.html.search.editor.HTMLSearchValidator">
+ <contentTypeIdentifier id="org.eclipse.wst.html.core.htmlsource">
+ <partitionType id="org.eclipse.wst.html.HTML_DEFAULT">
+ </partitionType>
+ </contentTypeIdentifier>
+ </validator>
+ </extension>
+
+</plugin>
diff --git a/plugins/org.eclipse.wst.html.search.editor/src/org/eclipse/wst/html/search/editor/Activator.java b/plugins/org.eclipse.wst.html.search.editor/src/org/eclipse/wst/html/search/editor/Activator.java
new file mode 100644
index 0000000..6acad1b
--- /dev/null
+++ b/plugins/org.eclipse.wst.html.search.editor/src/org/eclipse/wst/html/search/editor/Activator.java
@@ -0,0 +1,50 @@
+package org.eclipse.wst.html.search.editor;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.wst.html.search.editor"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/plugins/org.eclipse.wst.html.search.editor/src/org/eclipse/wst/html/search/editor/internal/contentassist/HTMLReferencesCompletionProposalComputer.java b/plugins/org.eclipse.wst.html.search.editor/src/org/eclipse/wst/html/search/editor/internal/contentassist/HTMLReferencesCompletionProposalComputer.java
new file mode 100644
index 0000000..885bade
--- /dev/null
+++ b/plugins/org.eclipse.wst.html.search.editor/src/org/eclipse/wst/html/search/editor/internal/contentassist/HTMLReferencesCompletionProposalComputer.java
@@ -0,0 +1,26 @@
+package org.eclipse.wst.html.search.editor.internal.contentassist;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.wst.html.ui.internal.contentassist.HTMLTemplatesCompletionProposalComputer;
+import org.eclipse.wst.sse.ui.contentassist.CompletionProposalInvocationContext;
+import org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+import org.eclipse.wst.xml.search.editor.contentassist.XMLReferencesContentAssistUtils;
+import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
+
+public class HTMLReferencesCompletionProposalComputer extends HTMLTemplatesCompletionProposalComputer {
+
+ @Override
+ protected void addAttributeValueProposals(
+ ContentAssistRequest contentAssistRequest,
+ CompletionProposalInvocationContext context) {
+ // XML reference
+ XMLReferencesContentAssistUtils.addAttributeValueProposals(contentAssistRequest);
+ super.addAttributeValueProposals(contentAssistRequest, context);
+ }
+
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/.classpath b/plugins/org.eclipse.wst.xml.search.core/.classpath
new file mode 100644
index 0000000..2d1a430
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.wst.xml.search.core/.project b/plugins/org.eclipse.wst.xml.search.core/.project
new file mode 100644
index 0000000..0e4bc05
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.wst.xml.search.core</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.wst.xml.search.core/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.wst.xml.search.core/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..12ceb96
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+#Thu Nov 18 10:20:11 CET 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/plugins/org.eclipse.wst.xml.search.core/META-INF/MANIFEST.MF b/plugins/org.eclipse.wst.xml.search.core/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..aeaf235
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/META-INF/MANIFEST.MF
@@ -0,0 +1,29 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-Vendor: %providerName
+Bundle-Localization: plugin
+Bundle-SymbolicName: org.eclipse.wst.xml.search.core;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.eclipse.wst.xml.search.core.internal.XMLSearchCorePlugin
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.wst.xml.core,
+ org.eclipse.core.resources,
+ org.eclipse.wst.sse.core
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Export-Package: org.eclipse.wst.xml.search.core,
+ org.eclipse.wst.xml.search.core.namespaces,
+ org.eclipse.wst.xml.search.core.properties,
+ org.eclipse.wst.xml.search.core.queryspecifications,
+ org.eclipse.wst.xml.search.core.queryspecifications.container,
+ org.eclipse.wst.xml.search.core.queryspecifications.querybuilder,
+ org.eclipse.wst.xml.search.core.queryspecifications.requestor,
+ org.eclipse.wst.xml.search.core.queryspecifications.visitor,
+ org.eclipse.wst.xml.search.core.reporter,
+ org.eclipse.wst.xml.search.core.resource,
+ org.eclipse.wst.xml.search.core.statics,
+ org.eclipse.wst.xml.search.core.storage,
+ org.eclipse.wst.xml.search.core.util,
+ org.eclipse.wst.xml.search.core.xpath,
+ org.eclipse.wst.xml.search.core.xpath.matcher
diff --git a/plugins/org.eclipse.wst.xml.search.core/build.properties b/plugins/org.eclipse.wst.xml.search.core/build.properties
new file mode 100644
index 0000000..73a5119
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/build.properties
@@ -0,0 +1,6 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.properties,\
+ plugin.xml
diff --git a/plugins/org.eclipse.wst.xml.search.core/plugin.properties b/plugins/org.eclipse.wst.xml.search.core/plugin.properties
new file mode 100644
index 0000000..46cf46f
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/plugin.properties
@@ -0,0 +1,23 @@
+###############################################################################
+# Copyright (c) 2010 Angelo Zerr 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:
+# Angelo Zerr <angelo.zerr@gmail.com> - Initial API and implementation
+###############################################################################
+pluginName=WST XML Search Core
+providerName=Angelo ZERR
+
+# Extension Point
+propertiesQuerySpecificationsContributionName=Properties file Query specifications contribution.
+querySpecificationsContributionName=XML Query specifications contribution.
+resourceQuerySpecificationsContributionName=Resource (file, folder) Query specifications contribution.
+staticValueQuerySpecificationsContributionName=Static value Query specifications contribution.
+xpathEvaluatorsContributionName=XPath evaluators Contribution.
+namespacesContributionName=Namespaces contribution.
+
+# XPath processor
+standardXPathProcessor=Standard XPath processor (XPathFactory.newInstance())
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.xml.search.core/plugin.xml b/plugins/org.eclipse.wst.xml.search.core/plugin.xml
new file mode 100644
index 0000000..012af4c
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/plugin.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+
+ <extension-point id="querySpecifications" name="%querySpecificationsContributionName"
+ schema="schema/querySpecifications.exsd" />
+ <extension-point id="propertiesQuerySpecifications" name="%propertiesQuerySpecificationsContributionName"
+ schema="schema/propertiesQuerySpecifications.exsd" />
+ <extension-point id="resourceQuerySpecifications" name="%resourceQuerySpecificationsContributionName"
+ schema="schema/resourceQuerySpecifications.exsd" />
+ <extension-point id="staticValueQuerySpecifications" name="%staticValueQuerySpecificationsContributionName"
+ schema="schema/staticValueQuerySpecifications.exsd" />
+ <extension-point id="xpathProcessors" name="%xpathProcessorsContributionName"
+ schema="schema/xpathProcessors.exsd" />
+ <extension-point id="namespaces" name="%namespacesContributionName"
+ schema="schema/namespaces.exsd" />
+
+ <extension
+ point="org.eclipse.wst.xml.search.core.xpathProcessors">
+ <processor
+ class="org.eclipse.wst.xml.search.core.xpath.DefaultXPathProcessor"
+ id="org.eclipse.wst.xml.search.core.xpath.DefaultXPathProcessor"
+ name="%standardXPathProcessor">
+ </processor>
+ </extension>
+
+ <extension point="org.eclipse.core.runtime.preferences">
+ <initializer
+ class="org.eclipse.wst.xml.search.core.internal.preferences.PreferenceInitializer" />
+ </extension>
+
+</plugin>
diff --git a/plugins/org.eclipse.wst.xml.search.core/schema/namespaces.exsd b/plugins/org.eclipse.wst.xml.search.core/schema/namespaces.exsd
new file mode 100644
index 0000000..0c35a7b
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/schema/namespaces.exsd
@@ -0,0 +1,105 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.wst.xml.search.core" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.wst.xml.search.core" id="namespaces" name="XML Namespaces Contribution"/>
+ </appinfo>
+ <documentation>
+ Extension point for provide XML Namespaces.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="namespaces" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+ a fully-qualified name of the target extension point
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ an optional id
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ an optional name
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="namespaces">
+ <complexType>
+ <sequence>
+ <element ref="matcher" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="matcher">
+ <complexType>
+ <attribute name="prefix" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.wst.xml.search.core.namespaces.INamespaceMatcher"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ 2.0
+ </documentation>
+ </annotation>
+
+
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ This plugin itself does not have any predefined builders.
+ </documentation>
+ </annotation>
+
+
+</schema>
diff --git a/plugins/org.eclipse.wst.xml.search.core/schema/propertiesQuerySpecifications.exsd b/plugins/org.eclipse.wst.xml.search.core/schema/propertiesQuerySpecifications.exsd
new file mode 100644
index 0000000..c53848e
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/schema/propertiesQuerySpecifications.exsd
@@ -0,0 +1,90 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.wst.xml.search.core" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.wst.xml.search.core" id="propertiesQuerySpecifications" name="Propertiess Query specification Contribution"/>
+ </appinfo>
+ <documentation>
+ Extension point for provide Properties file Query specification.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="querySpecification" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+ a fully-qualified name of the target extension point
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ an optional id
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ an optional name
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="querySpecification">
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <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>
+ 2.0
+ </documentation>
+ </annotation>
+
+
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ This plugin itself does not have any predefined builders.
+ </documentation>
+ </annotation>
+
+
+</schema>
diff --git a/plugins/org.eclipse.wst.xml.search.core/schema/querySpecifications.exsd b/plugins/org.eclipse.wst.xml.search.core/schema/querySpecifications.exsd
new file mode 100644
index 0000000..71d0b83
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/schema/querySpecifications.exsd
@@ -0,0 +1,90 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.wst.xml.search.core" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.wst.xml.search.core" id="querySpecifications" name="XML Query specification Contribution"/>
+ </appinfo>
+ <documentation>
+ Extension point for provide XML Query specification.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="querySpecification" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+ a fully-qualified name of the target extension point
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ an optional id
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ an optional name
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="querySpecification">
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <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>
+ 2.0
+ </documentation>
+ </annotation>
+
+
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ This plugin itself does not have any predefined builders.
+ </documentation>
+ </annotation>
+
+
+</schema>
diff --git a/plugins/org.eclipse.wst.xml.search.core/schema/resourceQuerySpecifications.exsd b/plugins/org.eclipse.wst.xml.search.core/schema/resourceQuerySpecifications.exsd
new file mode 100644
index 0000000..950680e
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/schema/resourceQuerySpecifications.exsd
@@ -0,0 +1,90 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.wst.xml.search.core" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.wst.xml.search.core" id="resourceQuerySpecifications" name="Resources Query specification Contribution"/>
+ </appinfo>
+ <documentation>
+ Extension point for provide Resource (file, folder...) Query specification.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="querySpecification" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+ a fully-qualified name of the target extension point
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ an optional id
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ an optional name
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="querySpecification">
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <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>
+ 2.0
+ </documentation>
+ </annotation>
+
+
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ This plugin itself does not have any predefined builders.
+ </documentation>
+ </annotation>
+
+
+</schema>
diff --git a/plugins/org.eclipse.wst.xml.search.core/schema/staticValueQuerySpecifications.exsd b/plugins/org.eclipse.wst.xml.search.core/schema/staticValueQuerySpecifications.exsd
new file mode 100644
index 0000000..0b7fe58
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/schema/staticValueQuerySpecifications.exsd
@@ -0,0 +1,90 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.wst.xml.search.core" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.wst.xml.search.core" id="staticValueQuerySpecifications" name="Static value Query specification Contribution"/>
+ </appinfo>
+ <documentation>
+ Extension point for provide Static value Query specification.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="querySpecification" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+ a fully-qualified name of the target extension point
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ an optional id
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ an optional name
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="querySpecification">
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <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>
+ 2.0
+ </documentation>
+ </annotation>
+
+
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ This plugin itself does not have any predefined builders.
+ </documentation>
+ </annotation>
+
+
+</schema>
diff --git a/plugins/org.eclipse.wst.xml.search.core/schema/xpathProcessors.exsd b/plugins/org.eclipse.wst.xml.search.core/schema/xpathProcessors.exsd
new file mode 100644
index 0000000..e1c5a6b
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/schema/xpathProcessors.exsd
@@ -0,0 +1,97 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.wst.xml.search.core" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.wst.xml.search.core" id="xpathProcessors" name="XPath processors Contribution"/>
+ </appinfo>
+ <documentation>
+ Extension point for provide XPath processor.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="processor" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+ a fully-qualified name of the target extension point
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ an optional id
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ an optional name
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="processor">
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.wst.xml.search.core.xpath.IXPathProcessor"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ 2.0
+ </documentation>
+ </annotation>
+
+
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ This plugin itself does not have any predefined builders.
+ </documentation>
+ </annotation>
+
+
+</schema>
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/AbstractRegistryManager.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/AbstractRegistryManager.java
new file mode 100644
index 0000000..3bdb3ae
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/AbstractRegistryManager.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core;
+
+import org.eclipse.core.runtime.IExtensionDelta;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.IRegistryChangeEvent;
+import org.eclipse.core.runtime.IRegistryChangeListener;
+import org.eclipse.core.runtime.Platform;
+
+/**
+ * Abstract class of the registry managed which is used to register WTP/XML
+ * Search configuration (querySPecification...) with Extension Point.
+ *
+ */
+public abstract class AbstractRegistryManager implements
+ IRegistryChangeListener {
+
+ private boolean registryListenerIntialized = false;
+
+ public void initialize() {
+
+ }
+
+ public void destroy() {
+ Platform.getExtensionRegistry().removeRegistryChangeListener(this);
+ }
+
+ protected void addRegistryListenerIfNeeded() {
+ if (registryListenerIntialized)
+ return;
+
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ if (registry != null) {
+ registry.addRegistryChangeListener(this, getPluginId());
+ }
+ registryListenerIntialized = true;
+ }
+
+ public void registryChanged(IRegistryChangeEvent event) {
+ IExtensionDelta[] deltas = event.getExtensionDeltas(getPluginId(),
+ getExtensionPoint());
+ if (deltas != null) {
+ for (IExtensionDelta delta : deltas)
+ handleExtensionDelta(delta);
+ }
+ }
+
+ protected abstract void handleExtensionDelta(IExtensionDelta delta);
+
+ protected abstract String getPluginId();
+
+ protected abstract String getExtensionPoint();
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/IQueryProvider.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/IQueryProvider.java
new file mode 100644
index 0000000..2862cda
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/IQueryProvider.java
@@ -0,0 +1,12 @@
+package org.eclipse.wst.xml.search.core;
+
+
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
+import org.eclipse.wst.xml.search.core.namespaces.Namespaces;
+import org.eclipse.wst.xml.search.core.queryspecifications.querybuilder.IStringQueryBuilder;
+
+public interface IQueryProvider {
+
+ String getQuery(Object selectedNode, IStringQueryBuilder builder,
+ String[] values, Namespaces namespaces, IDOMDocument document);
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/ISimpleXMLSearchEngine.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/ISimpleXMLSearchEngine.java
new file mode 100644
index 0000000..31d9492
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/ISimpleXMLSearchEngine.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.wst.xml.search.core.namespaces.Namespaces;
+import org.eclipse.wst.xml.search.core.queryspecifications.requestor.IXMLSearchRequestor;
+import org.eclipse.wst.xml.search.core.queryspecifications.visitor.IXMLSearchDOMDocumentVisitor;
+import org.eclipse.wst.xml.search.core.reporter.IXMLSearchReporter;
+
+public interface ISimpleXMLSearchEngine {
+
+ IStatus search(IResource container, IXMLSearchRequestor requestor,
+ IXMLSearchDOMDocumentVisitor visitor, String query,
+ String xpathEvaluatorId, Namespaces namespaceInfos,
+ IXMLSearchDOMNodeCollector collector, Object selectedNode,
+ IXMLSearchReporter reporter, IProgressMonitor monitor);
+
+ IStatus search(IResource[] containers, IXMLSearchRequestor requestor,
+ IXMLSearchDOMDocumentVisitor visitor, String query,
+ String xpathEvaluatorId, Namespaces namespaceInfos,
+ IXMLSearchDOMNodeCollector collector, Object selectedNode,
+ IXMLSearchReporter reporter, IProgressMonitor monitor);
+
+ IStatus search(IStorage storage, IXMLSearchRequestor requestor,
+ IXMLSearchDOMDocumentVisitor visitor, String query,
+ String xpathEvaluatorId, Namespaces namespaceInfos,
+ IXMLSearchDOMNodeCollector collector, Object selectedNode,
+ IXMLSearchReporter reporter, IProgressMonitor monitor);
+
+ IStatus search(IStorage[] storages, IXMLSearchRequestor requestor,
+ IXMLSearchDOMDocumentVisitor visitor, String query,
+ String xpathEvaluatorId, Namespaces namespaceInfos,
+ IXMLSearchDOMNodeCollector collector, Object selectedNode,
+ IXMLSearchReporter reporter, IProgressMonitor monitor);
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/IXMLSearchDOMNodeCollector.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/IXMLSearchDOMNodeCollector.java
new file mode 100644
index 0000000..4c72152
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/IXMLSearchDOMNodeCollector.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core;
+
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+
+/**
+ * A collector to add DOM node {@link IDOMNode} retrieved by the XML search
+ * engine.
+ *
+ */
+public interface IXMLSearchDOMNodeCollector {
+
+ /**
+ * Appends the specified node.
+ *
+ * @param node the node to add.
+ * @return
+ */
+ boolean add(IDOMNode node);
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/IXMLSearchEngine.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/IXMLSearchEngine.java
new file mode 100644
index 0000000..d4d804b
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/IXMLSearchEngine.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.wst.xml.search.core.queryspecifications.IXMLQuerySpecificationRegistry;
+import org.eclipse.wst.xml.search.core.reporter.IXMLSearchReporter;
+
+/**
+ * XML search engine interface.
+ *
+ */
+public interface IXMLSearchEngine extends ISimpleXMLSearchEngine {
+
+ IStatus search(IXMLQuerySpecificationRegistry querySpecificationRegistry,
+ IXMLSearchDOMNodeCollector collector, IXMLSearchReporter reporter,
+ IProgressMonitor monitor);
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/SimpleXMLSearchEngine.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/SimpleXMLSearchEngine.java
new file mode 100644
index 0000000..056aa01
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/SimpleXMLSearchEngine.java
@@ -0,0 +1,237 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.xml.search.core.internal.AbstractXMLSearchEngine;
+import org.eclipse.wst.xml.search.core.internal.XMLSearchCorePlugin;
+import org.eclipse.wst.xml.search.core.internal.reporter.XMLSearchReporterIdProvider;
+import org.eclipse.wst.xml.search.core.namespaces.Namespaces;
+import org.eclipse.wst.xml.search.core.queryspecifications.requestor.IXMLSearchRequestor;
+import org.eclipse.wst.xml.search.core.queryspecifications.visitor.IXMLSearchDOMDocumentVisitor;
+import org.eclipse.wst.xml.search.core.reporter.IXMLSearchReporter;
+
+public class SimpleXMLSearchEngine extends AbstractXMLSearchEngine {
+
+ private static final ISimpleXMLSearchEngine INSTANCE = new SimpleXMLSearchEngine();
+
+ public static ISimpleXMLSearchEngine getDefault() {
+ return INSTANCE;
+ }
+
+ public IStatus search(IResource container, IXMLSearchRequestor requestor,
+ IXMLSearchDOMDocumentVisitor visitor, String query,
+ String xpathEvaluatorId, Namespaces namespaceInfos,
+ IXMLSearchDOMNodeCollector collector, Object selectedNode,
+ IXMLSearchReporter reporter, IProgressMonitor monitor) {
+ long startTime = -1;
+ int searchId = -1;
+ if (isReporterEnabled(reporter)) {
+ searchId = XMLSearchReporterIdProvider.getSearchId();
+ startTime = System.currentTimeMillis();
+ Collection<String> queries = new ArrayList<String>();
+ queries.add(query);
+ Map<IResource, Collection<String>> containersReporter = new HashMap<IResource, Collection<String>>();
+ containersReporter.put(container, queries);
+ reporter.beginSearch(searchId, containersReporter);
+ }
+ MultiStatus status = createStatus();
+ try {
+ search(container, container, requestor, visitor, query,
+ xpathEvaluatorId, namespaceInfos, collector, selectedNode,
+ monitor, status);
+ } finally {
+ if (searchId != -1) {
+ reporter.endSearch(searchId, System.currentTimeMillis()
+ - startTime);
+ }
+ }
+ return status;
+ }
+
+ public IStatus search(IResource[] containers,
+ IXMLSearchRequestor requestor,
+ IXMLSearchDOMDocumentVisitor visitor, String query,
+ String xpathEvaluatorId, Namespaces namespaceInfos,
+ IXMLSearchDOMNodeCollector collector, Object selectedNode,
+ IXMLSearchReporter reporter, IProgressMonitor monitor) {
+ long startTime = -1;
+ int searchId = -1;
+ if (isReporterEnabled(reporter)) {
+ searchId = XMLSearchReporterIdProvider.getSearchId();
+ startTime = System.currentTimeMillis();
+ Map<IResource, Collection<String>> containersReporter = new HashMap<IResource, Collection<String>>();
+ if (containers != null) {
+ Collection<String> queries = new ArrayList<String>();
+ queries.add(query);
+ for (int i = 0; i < containers.length; i++) {
+ containersReporter.put(containers[i], queries);
+ }
+ }
+ reporter.beginSearch(searchId, containersReporter);
+ }
+ MultiStatus status = createStatus();
+ try {
+ if (containers == null) {
+ return Status.CANCEL_STATUS;
+ }
+
+ IResource container = null;
+ for (int i = 0; i < containers.length; i++) {
+ container = containers[i];
+ search(container, container, requestor, visitor, query,
+ xpathEvaluatorId, namespaceInfos, collector,
+ selectedNode, monitor, status);
+ }
+ } finally {
+ if (searchId != -1) {
+ reporter.endSearch(searchId, System.currentTimeMillis()
+ - startTime);
+ }
+ }
+ return status;
+ }
+
+ private void search(IResource resource, IResource rootResource,
+ IXMLSearchRequestor requestor,
+ IXMLSearchDOMDocumentVisitor visitor, String query,
+ String xpathEvaluatorId, Namespaces namespaceInfos,
+ IXMLSearchDOMNodeCollector collector, Object selectedNode,
+ IProgressMonitor monitor, MultiStatus status) {
+ if (acceptResource(resource, rootResource, requestor)) {
+ int resourceType = resource.getType();
+ switch (resourceType) {
+ case IResource.FILE:
+ IFile file = (IFile) resource;
+ processFile(file, rootResource, requestor, visitor, query,
+ xpathEvaluatorId, namespaceInfos, collector,
+ selectedNode, status);
+ break;
+ case IResource.ROOT:
+ case IResource.PROJECT:
+ case IResource.FOLDER:
+ try {
+ IResource[] resources = ((IContainer) resource).members();
+ search(resources, rootResource, requestor, visitor, query,
+ xpathEvaluatorId, namespaceInfos, collector,
+ selectedNode, monitor, status);
+ } catch (CoreException e) {
+ // Error while loop for files
+ status.add(XMLSearchCorePlugin.createStatus(IStatus.ERROR,
+ e.getMessage(), e));
+ }
+ break;
+ }
+ }
+ }
+
+ private void search(IResource[] resources, IResource rootResource,
+ IXMLSearchRequestor requestor,
+ IXMLSearchDOMDocumentVisitor visitor, String query,
+ String xpathEvaluatorId, Namespaces namespaceInfos,
+ IXMLSearchDOMNodeCollector collector, Object selectedNode,
+ IProgressMonitor monitor, MultiStatus status) {
+ for (int i = 0; i < resources.length; i++) {
+ search(resources[i], rootResource, requestor, visitor, query,
+ xpathEvaluatorId, namespaceInfos, collector, selectedNode,
+ monitor, status);
+ }
+ }
+
+ public IStatus search(IStorage storage, IXMLSearchRequestor requestor,
+ IXMLSearchDOMDocumentVisitor visitor, String query,
+ String xpathEvaluatorId, Namespaces namespaceInfos,
+ IXMLSearchDOMNodeCollector collector, Object selectedNode,
+ IXMLSearchReporter reporter, IProgressMonitor monitor) {
+ long startTime = -1;
+ int searchId = -1;
+ if (isReporterEnabled(reporter)) {
+ searchId = XMLSearchReporterIdProvider.getSearchId();
+ startTime = System.currentTimeMillis();
+
+ }
+ MultiStatus status = createStatus();
+ try {
+ if (storage == null) {
+ return Status.CANCEL_STATUS;
+ }
+ super.processStorage(storage, storage, requestor, visitor, query,
+ xpathEvaluatorId, namespaceInfos, collector, selectedNode,
+ status);
+
+ } finally {
+ if (searchId != -1) {
+ reporter.endSearch(searchId, System.currentTimeMillis()
+ - startTime);
+ }
+ }
+ return status;
+ }
+
+ private void search(IStorage storage, IStorage rootStorage,
+ IXMLSearchRequestor requestor,
+ IXMLSearchDOMDocumentVisitor visitor, String query,
+ String xpathEvaluatorId, Namespaces namespaceInfos,
+ IXMLSearchDOMNodeCollector collector, Object selectedNode,
+ IProgressMonitor monitor, MultiStatus status) {
+ super.processStorage(storage, rootStorage, requestor, visitor, query,
+ xpathEvaluatorId, namespaceInfos, collector, selectedNode,
+ status);
+
+ }
+
+ public IStatus search(IStorage[] storages, IXMLSearchRequestor requestor,
+ IXMLSearchDOMDocumentVisitor visitor, String query,
+ String xpathEvaluatorId, Namespaces namespaceInfos,
+ IXMLSearchDOMNodeCollector collector, Object selectedNode,
+ IXMLSearchReporter reporter, IProgressMonitor monitor) {
+ long startTime = -1;
+ int searchId = -1;
+ if (isReporterEnabled(reporter)) {
+ searchId = XMLSearchReporterIdProvider.getSearchId();
+ startTime = System.currentTimeMillis();
+
+ }
+ MultiStatus status = createStatus();
+ try {
+ if (storages == null) {
+ return Status.CANCEL_STATUS;
+ }
+
+ IStorage storage = null;
+ for (int i = 0; i < storages.length; i++) {
+ storage = storages[i];
+ super.processStorage(storage, storage, requestor, visitor,
+ query, xpathEvaluatorId, namespaceInfos, collector,
+ selectedNode, status);
+ }
+ } finally {
+ if (searchId != -1) {
+ reporter.endSearch(searchId, System.currentTimeMillis()
+ - startTime);
+ }
+ }
+ return status;
+ }
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/XMLSearchEngine.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/XMLSearchEngine.java
new file mode 100644
index 0000000..f8d9ef5
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/XMLSearchEngine.java
@@ -0,0 +1,263 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.wst.xml.search.core.internal.AbstractXMLSearchEngine;
+import org.eclipse.wst.xml.search.core.internal.XMLSearchCorePlugin;
+import org.eclipse.wst.xml.search.core.internal.queryspecifications.XMLQuerySpecification2;
+import org.eclipse.wst.xml.search.core.internal.reporter.XMLSearchReporterIdProvider;
+import org.eclipse.wst.xml.search.core.namespaces.Namespaces;
+import org.eclipse.wst.xml.search.core.queryspecifications.IExecutableXMLQuerySpecification;
+import org.eclipse.wst.xml.search.core.queryspecifications.IXMLQuerySpecificationRegistry;
+import org.eclipse.wst.xml.search.core.queryspecifications.XMLQuerySpecificationRegistry;
+import org.eclipse.wst.xml.search.core.queryspecifications.requestor.AllFilesXMLSearchRequestor;
+import org.eclipse.wst.xml.search.core.queryspecifications.requestor.IXMLSearchRequestor;
+import org.eclipse.wst.xml.search.core.queryspecifications.visitor.IXMLSearchDOMDocumentVisitor;
+import org.eclipse.wst.xml.search.core.reporter.IXMLSearchReporter;
+
+public class XMLSearchEngine extends AbstractXMLSearchEngine implements
+ IXMLSearchEngine {
+
+ private static final XMLSearchEngine INSTANCE = new XMLSearchEngine();
+
+ public static IXMLSearchEngine getDefault() {
+ return INSTANCE;
+ }
+
+ protected void search(IFile[] files, IXMLSearchDOMDocumentVisitor visitor,
+ String query, String xpathEvaluatorId,
+ Namespaces namespaceInfos,
+ IXMLSearchDOMNodeCollector collector, Object selectedNode,
+ IProgressMonitor monitor, MultiStatus status) {
+ IFile file = null;
+ for (int i = 0; i < files.length; i++) {
+ file = files[i];
+ processFile(file, file, AllFilesXMLSearchRequestor.INSTANCE,
+ visitor, query, xpathEvaluatorId, namespaceInfos,
+ collector, selectedNode, status);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.wst.xml.search.core.IXMLSearchEngine#search(org.eclipse.wst
+ * .xml.search.core.queryspecifications.IXMLQuerySpecificationRegistry,
+ * org.eclipse.wst.xml.search.core.IXMLSearchDOMNodeCollector,
+ * org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public IStatus search(
+ IXMLQuerySpecificationRegistry querySpecificationRegistry,
+ IXMLSearchDOMNodeCollector collector, IXMLSearchReporter reporter,
+ IProgressMonitor monitor) {
+ long startTime = -1;
+ int searchId = -1;
+ if (isReporterEnabled(reporter)) {
+ searchId = XMLSearchReporterIdProvider.getSearchId();
+ startTime = System.currentTimeMillis();
+
+ Map<IResource, Collection<String>> containersReporter = new HashMap<IResource, Collection<String>>();
+ Set<Entry<IResource, Collection<IExecutableXMLQuerySpecification>>> entries = querySpecificationRegistry
+ .getQuerySpecificationsMap().entrySet();
+ for (Entry<IResource, Collection<IExecutableXMLQuerySpecification>> entry : entries) {
+ IResource container = entry.getKey();
+ Collection<String> queries = new ArrayList<String>();
+ Collection<IExecutableXMLQuerySpecification> executableXMLQuerySpecifications = entry
+ .getValue();
+ for (IExecutableXMLQuerySpecification executableXMLQuerySpecification : executableXMLQuerySpecifications) {
+ queries.add(executableXMLQuerySpecification.getQuery());
+ }
+ containersReporter.put(container, queries);
+ }
+ reporter.beginSearch(searchId, containersReporter);
+ }
+ MultiStatus status = createStatus();
+ try {
+ search(querySpecificationRegistry, collector, monitor, status);
+ } finally {
+ if (searchId != -1) {
+ reporter.endSearch(searchId, System.currentTimeMillis()
+ - startTime);
+ }
+ }
+ return status;
+ }
+
+ protected void search(
+ IXMLQuerySpecificationRegistry querySpecificationRegistry,
+ IXMLSearchDOMNodeCollector collector, IProgressMonitor monitor,
+ MultiStatus status) {
+ Set<Entry<IResource, Collection<IExecutableXMLQuerySpecification>>> entries = querySpecificationRegistry
+ .getQuerySpecificationsMap().entrySet();
+ for (Entry<IResource, Collection<IExecutableXMLQuerySpecification>> entry : entries) {
+ IResource container = entry.getKey();
+ Collection<IExecutableXMLQuerySpecification> executableXMLQuerySpecifications = entry
+ .getValue();
+ search(container, container, executableXMLQuerySpecifications,
+ collector, status);
+ }
+ }
+
+ protected void search(
+ IResource resource,
+ IResource rootResource,
+ Collection<IExecutableXMLQuerySpecification> executableXMLQuerySpecifications,
+ IXMLSearchDOMNodeCollector collector, MultiStatus status) {
+ if (acceptResource(resource, rootResource,
+ executableXMLQuerySpecifications)) {
+ int resourceType = resource.getType();
+ switch (resourceType) {
+ case IResource.FILE:
+ IFile file = (IFile) resource;
+ processFile(file, rootResource,
+ executableXMLQuerySpecifications, collector, status);
+ break;
+ case IResource.ROOT:
+ case IResource.PROJECT:
+ case IResource.FOLDER:
+ try {
+ IResource[] resources = ((IContainer) resource).members();
+ search(resources, rootResource,
+ executableXMLQuerySpecifications, collector, status);
+ } catch (CoreException e) {
+ // Error while loop for files
+ status.add(XMLSearchCorePlugin.createStatus(IStatus.ERROR,
+ e.getMessage(), e));
+ }
+ break;
+ }
+ }
+ }
+
+ private void search(
+ IResource[] resources,
+ IResource rootResource,
+ Collection<IExecutableXMLQuerySpecification> executableXMLQuerySpecifications,
+ IXMLSearchDOMNodeCollector collector, MultiStatus status) {
+ for (int i = 0; i < resources.length; i++) {
+ search(resources[i], rootResource,
+ executableXMLQuerySpecifications, collector, status);
+ }
+ }
+
+ private boolean acceptResource(
+ IResource resource,
+ IResource rootResource,
+ Collection<IExecutableXMLQuerySpecification> executableXMLQuerySpecifications) {
+ if (resource == null) {
+ return false;
+ }
+ for (IExecutableXMLQuerySpecification executableXMLQuerySpecification : executableXMLQuerySpecifications) {
+ if (acceptResource(resource, rootResource,
+ executableXMLQuerySpecification)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean acceptResource(IResource resource, IResource rootResource,
+ IExecutableXMLQuerySpecification executableXMLQuerySpecification) {
+ IXMLSearchRequestor requestor = executableXMLQuerySpecification
+ .getRequestor();
+ return requestor != null && requestor.accept(resource, rootResource);
+ }
+
+ protected void processFile(
+ IFile file,
+ IResource rootResource,
+ Collection<IExecutableXMLQuerySpecification> executableXMLQuerySpecifications,
+ IXMLSearchDOMNodeCollector collector, MultiStatus status) {
+ for (IExecutableXMLQuerySpecification executableXMLQuerySpecification : executableXMLQuerySpecifications) {
+ if (acceptResource(file, rootResource,
+ executableXMLQuerySpecification)) {
+ super.processFile(file, rootResource,
+ executableXMLQuerySpecification.getRequestor(),
+ executableXMLQuerySpecification.getVisitor(),
+ executableXMLQuerySpecification.getQuery(),
+ executableXMLQuerySpecification.getXPathProcessorId(),
+ executableXMLQuerySpecification.getNamespaces(),
+ collector,
+ executableXMLQuerySpecification.getSelectedNode(),
+ status);
+ }
+ }
+ }
+
+ public IStatus search(IResource container, IXMLSearchRequestor requestor,
+ IXMLSearchDOMDocumentVisitor visitor, String query,
+ String xpathProcessorId, Namespaces namespaceInfos,
+ IXMLSearchDOMNodeCollector collector, Object selectedNode,
+ IXMLSearchReporter reporter, IProgressMonitor monitor) {
+ XMLQuerySpecificationRegistry querySpecificationRegistry = new XMLQuerySpecificationRegistry(
+ container, selectedNode);
+ XMLQuerySpecification2 specification = XMLQuerySpecification2
+ .newDefaultQuerySpecification(container);
+ specification.setVisitor(visitor);
+ specification.setRequestor(requestor);
+ specification.setXPathProcessorId(xpathProcessorId);
+ querySpecificationRegistry.register(specification, query,
+ namespaceInfos);
+ return search(querySpecificationRegistry, collector, reporter, monitor);
+ }
+
+ public IStatus search(IResource[] containers,
+ IXMLSearchRequestor requestor,
+ IXMLSearchDOMDocumentVisitor visitor, String query,
+ String xpathProcessorId, Namespaces namespaceInfos,
+ IXMLSearchDOMNodeCollector collector, Object selectedNode,
+ IXMLSearchReporter reporter, IProgressMonitor monitor) {
+ XMLQuerySpecificationRegistry querySpecificationRegistry = new XMLQuerySpecificationRegistry(
+ (IContainer) null, selectedNode);
+ XMLQuerySpecification2 specification = XMLQuerySpecification2
+ .newDefaultQuerySpecification(containers);
+ specification.setVisitor(visitor);
+ specification.setRequestor(requestor);
+ specification.setXPathProcessorId(xpathProcessorId);
+ querySpecificationRegistry.register(specification, query,
+ namespaceInfos);
+ return search(querySpecificationRegistry, collector, reporter, monitor);
+ }
+
+ public IStatus search(IStorage storage, IXMLSearchRequestor requestor,
+ IXMLSearchDOMDocumentVisitor visitor, String query,
+ String xpathEvaluatorId, Namespaces namespaceInfos,
+ IXMLSearchDOMNodeCollector collector, Object selectedNode,
+ IXMLSearchReporter reporter, IProgressMonitor monitor) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public IStatus search(IStorage[] storages, IXMLSearchRequestor requestor,
+ IXMLSearchDOMDocumentVisitor visitor, String query,
+ String xpathEvaluatorId, Namespaces namespaceInfos,
+ IXMLSearchDOMNodeCollector collector, Object selectedNode,
+ IXMLSearchReporter reporter, IProgressMonitor monitor) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/XMLSearchEngine2.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/XMLSearchEngine2.java
new file mode 100644
index 0000000..901ff85
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/XMLSearchEngine2.java
@@ -0,0 +1,155 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core;
+
+import java.util.Collection;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.wst.xml.search.core.internal.FilesOfScopeCalculator;
+import org.eclipse.wst.xml.search.core.internal.Messages;
+import org.eclipse.wst.xml.search.core.queryspecifications.IExecutableXMLQuerySpecification;
+import org.eclipse.wst.xml.search.core.queryspecifications.IXMLQuerySpecificationRegistry;
+
+public class XMLSearchEngine2 extends XMLSearchEngine {
+
+ private int fNumberOfFilesToScan;
+ private IFile fCurrentFile;
+ private int fNumberOfScannedFiles;
+
+ @Override
+ protected void search(
+ IXMLQuerySpecificationRegistry querySpecificationRegistry,
+ IXMLSearchDOMNodeCollector collector,
+ final IProgressMonitor monitor, MultiStatus status) {
+
+ IFile[] files = evaluateFilesInScope(querySpecificationRegistry, status);
+ if (files == null) {
+ return;
+ }
+ fNumberOfScannedFiles = 0;
+ fNumberOfFilesToScan = files.length;
+ fCurrentFile = null;
+
+ Job monitorUpdateJob = new Job(
+ Messages.XMLSearchEngine2_progress_updating_job) {
+ private int fLastNumberOfScannedFiles = 0;
+
+ public IStatus run(IProgressMonitor inner) {
+ while (!inner.isCanceled()) {
+ IFile file = fCurrentFile;
+ if (file != null) {
+ String fileName = file.getName();
+ Object[] args = { fileName,
+ new Integer(fNumberOfScannedFiles),
+ new Integer(fNumberOfFilesToScan) };
+ monitor.subTask(NLS.bind(
+ Messages.XMLSearchEngine2_scanning, args));
+ int steps = fNumberOfScannedFiles
+ - fLastNumberOfScannedFiles;
+ monitor.worked(steps);
+ fLastNumberOfScannedFiles += steps;
+ }
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ return Status.OK_STATUS;
+ }
+ }
+ return Status.OK_STATUS;
+ }
+ };
+
+ try {
+ String taskName = NLS.bind(
+ Messages.XMLSearchEngine2_textsearch_task_label,
+ querySpecificationRegistry.getQueriesLabel());
+ // SearchMessages.TextSearchVisitor_filesearch_task_label
+ // :
+ // Messages.format(SearchMessages.TextSearchVisitor_textsearch_task_label,
+ // fMatcher.pattern().pattern());
+ monitor.beginTask(taskName, fNumberOfFilesToScan);
+ monitorUpdateJob.setSystem(true);
+ monitorUpdateJob.schedule();
+ try {
+ // fCollector.beginReporting();
+ // processFiles(files);
+ // return fStatus;
+ processFiles(files, null, querySpecificationRegistry,
+ collector, monitor, status);
+ } finally {
+ monitorUpdateJob.cancel();
+ }
+ } finally {
+ monitor.done();
+ // fCollector.endReporting();
+ }
+
+ }
+
+ private void processFiles(IFile[] files, IResource rootResource,
+ IXMLQuerySpecificationRegistry querySpecificationRegistry,
+ IXMLSearchDOMNodeCollector collector, IProgressMonitor monitor,
+ MultiStatus status) {
+ for (int i = 0; i < files.length; i++) {
+ fCurrentFile = files[i];
+ boolean res = processFile(fCurrentFile, rootResource,
+ querySpecificationRegistry, collector, monitor, status);
+ if (!res)
+ break;
+ }
+
+ }
+
+ private boolean processFile(IFile file, IResource rootResource,
+ IXMLQuerySpecificationRegistry querySpecificationRegistry,
+ IXMLSearchDOMNodeCollector collector, IProgressMonitor monitor,
+ MultiStatus status) {
+
+ try {
+ Collection<Collection<IExecutableXMLQuerySpecification>> all = querySpecificationRegistry
+ .getQuerySpecificationsMap().values();
+ for (Collection<IExecutableXMLQuerySpecification> collection : all) {
+ super.processFile(file, rootResource, collection, collector,
+ status);
+ }
+ } finally {
+ fNumberOfScannedFiles++;
+ }
+ if (monitor.isCanceled())
+ throw new OperationCanceledException(
+ Messages.XMLSearchEngine2_canceled);
+ return true;
+ }
+
+ /**
+ * Evaluates all files in this scope.
+ *
+ * @param status
+ * a {@link MultiStatus} to collect the error status that
+ * occurred while collecting resources.
+ * @return returns the files in the scope.
+ */
+ protected IFile[] evaluateFilesInScope(
+ IXMLQuerySpecificationRegistry querySpecificationRegistry,
+ MultiStatus status) {
+ return new FilesOfScopeCalculator(querySpecificationRegistry, status)
+ .process();
+ }
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/XMLSearchEngineException.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/XMLSearchEngineException.java
new file mode 100644
index 0000000..982406f
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/XMLSearchEngineException.java
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core;
+
+public class XMLSearchEngineException extends RuntimeException {
+
+ public XMLSearchEngineException(Throwable e) {
+ super(e);
+ }
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/AbstractXMLSearchEngine.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/AbstractXMLSearchEngine.java
new file mode 100644
index 0000000..784b49d
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/AbstractXMLSearchEngine.java
@@ -0,0 +1,319 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.internal;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.eclipse.wst.xml.search.core.ISimpleXMLSearchEngine;
+import org.eclipse.wst.xml.search.core.IXMLSearchDOMNodeCollector;
+import org.eclipse.wst.xml.search.core.namespaces.Namespaces;
+import org.eclipse.wst.xml.search.core.queryspecifications.requestor.AllFilesXMLSearchRequestor;
+import org.eclipse.wst.xml.search.core.queryspecifications.requestor.IXMLSearchRequestor;
+import org.eclipse.wst.xml.search.core.queryspecifications.visitor.IXMLSearchDOMDocumentVisitor;
+import org.eclipse.wst.xml.search.core.reporter.IXMLSearchReporter;
+import org.eclipse.wst.xml.search.core.storage.StructuredStorageModelManager;
+import org.eclipse.wst.xml.search.core.xpath.NamespaceInfos;
+import org.eclipse.wst.xml.search.core.xpath.XPathManager;
+
+/**
+ *
+ * Abstract class for XML Search engine which implements
+ * {@link ISimpleXMLSearchEngine}.
+ *
+ */
+public abstract class AbstractXMLSearchEngine implements ISimpleXMLSearchEngine {
+
+ /**
+ * Returns true if reporter is enabled and false otherwise.
+ *
+ * @param reporter
+ * the XML reporter or null otherwise.
+ * @return
+ */
+ protected boolean isReporterEnabled(IXMLSearchReporter reporter) {
+ return reporter != null && reporter.isEnabled();
+ }
+
+ /**
+ * Returns true if the given <code>resource</code> must be accepted and
+ * false Otherwise.
+ *
+ * @param resource
+ * @param rootResource
+ * @param requestor
+ * @return
+ */
+ protected boolean acceptResource(IResource resource,
+ IResource rootResource, IXMLSearchRequestor requestor) {
+ return requestor == null ? false : requestor.accept(resource,
+ rootResource);
+ }
+
+ /**
+ * Process search DOM nodes in the given <code>file</code>.
+ *
+ * @param file
+ * used to process the search.
+ * @param rootResource
+ * the root resources where search is started.
+ * @param requestor
+ * used to know if search must be done for the given file.
+ * @param visitor
+ * used to execute XPath query for the current file which is a
+ * DOM Document.
+ * @param query
+ * the XPath to execute.
+ * @param xpathProcessorId
+ * the XPath processor id to use to execute XPath.
+ * @param namespaceInfos
+ * namespace infos used by the XPath processor to execute the
+ * given XPath query.
+ * @param collector
+ * the collector used to collect DOM Node.
+ * @param selectedNode
+ * the selected node which start the search.
+ * @return the status of the search.
+ */
+ protected void processFile(IFile file, IResource rootResource,
+ IXMLSearchRequestor requestor,
+ IXMLSearchDOMDocumentVisitor visitor, String query,
+ String xpathProcessorId, Namespaces namespaces,
+ IXMLSearchDOMNodeCollector collector, Object selectedNode,
+ MultiStatus status) {
+ if (acceptResource(file, rootResource, requestor)) {
+ boolean hasError = false;
+ // boolean releaseModelForRead = false;
+ // Load DOM Document
+ IStructuredModel model = null;
+ try {
+ // releaseModelForRead = false;
+ model = StructuredModelManager.getModelManager()
+ .getExistingModelForRead(file);
+ if (model == null) {
+ model = StructuredModelManager.getModelManager()
+ .getModelForRead(file);
+ // releaseModelForRead = true;
+ }
+ } catch (Throwable e) {
+ hasError = true;
+ status.add(XMLSearchCorePlugin.createStatus(IStatus.ERROR,
+ e.getMessage(), e));
+ }
+
+ IDOMModel domModel = null;
+ if (model instanceof IDOMModel) {
+ domModel = (IDOMModel) model;
+ }
+ if (!hasError && domModel != null && requestor.accept(domModel)) {
+ // DOM Model was loaded, visit the DOM Document
+ try {
+ process(visitor, query, xpathProcessorId, namespaces,
+ collector, selectedNode, model, domModel);
+ } catch (Throwable e) {
+ // Error while visting DOM Document
+ status.add(XMLSearchCorePlugin.createStatus(
+ IStatus.ERROR,
+ NLS.bind(
+ Messages.searchEngineDOMDocumentVisitedError,
+ file.getLocation().toString()), e));
+ } finally {
+ if (model != null /* && releaseModelForRead */) {
+ model.releaseFromRead();
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Process search DOM nodes in the given <code>storage</code>.
+ *
+ * @param storage
+ * used to process the search.
+ * @param rootStorage
+ * the root storage where search is started.
+ * @param requestor
+ * used to know if search must be done for the given file.
+ * @param visitor
+ * used to execute XPath query for the current file which is a
+ * DOM Document.
+ * @param query
+ * the XPath to execute.
+ * @param xpathProcessorId
+ * the XPath processor id to use to execute XPath.
+ * @param namespaceInfos
+ * namespace infos used by the XPath processor to execute the
+ * given XPath query.
+ * @param collector
+ * the collector used to collect DOM Node.
+ * @param selectedNode
+ * the selected node which start the search.
+ * @return the status of the search.
+ */
+ protected void processStorage(IStorage storage, IStorage rootStorage,
+ IXMLSearchRequestor requestor,
+ IXMLSearchDOMDocumentVisitor visitor, String query,
+ String xpathProcessorId, Namespaces namespaces,
+ IXMLSearchDOMNodeCollector collector, Object selectedNode,
+ MultiStatus status) {
+ // if (acceptStorage(storage, rootStorage, requestor)) {
+ boolean hasError = false;
+ // boolean releaseModelForRead = false;
+ // Load DOM Document
+ IStructuredModel model = null;
+ try {
+ // releaseModelForRead = false;
+ model = StructuredStorageModelManager.getModelManager().getModel(
+ storage);
+ } catch (Throwable e) {
+ hasError = true;
+ status.add(XMLSearchCorePlugin.createStatus(IStatus.ERROR,
+ e.getMessage(), e));
+ }
+
+ IDOMModel domModel = null;
+ if (model instanceof IDOMModel) {
+ domModel = (IDOMModel) model;
+ }
+ if (!hasError && domModel != null /* && requestor.accept(domModel) */) {
+ // DOM Model was loaded, visit the DOM Document
+ try {
+ process(visitor, query, xpathProcessorId, namespaces,
+ collector, selectedNode, model, domModel);
+ } catch (Throwable e) {
+ // Error while visting DOM Document
+ status.add(XMLSearchCorePlugin.createStatus(IStatus.ERROR, NLS
+ .bind(Messages.searchEngineDOMDocumentVisitedError,
+ storage.getFullPath().toString()), e));
+ } finally {
+ if (model != null /* && releaseModelForRead */) {
+ model.releaseFromRead();
+ }
+ }
+ }
+ }
+
+ private void process(IXMLSearchDOMDocumentVisitor visitor, String query,
+ String xpathProcessorId, Namespaces namespaces,
+ IXMLSearchDOMNodeCollector collector, Object selectedNode,
+ IStructuredModel model, IDOMModel domModel) {
+ if (model != null) {
+ IDOMDocument document = domModel.getDocument();
+ if (namespaces != null) {
+ NamespaceInfos namespaceInfos = XPathManager
+ .getManager().getNamespaceInfo(document);
+ query = namespaces.format(query, namespaceInfos);
+ }
+ visitor.visit(document, query, xpathProcessorId, collector,
+ selectedNode);
+ }
+ }
+
+ /**
+ * Execute the XPath query for the given <code>files</code> and collect
+ * nodes result in the given <code>collector</code> and return the status of
+ * the search.
+ *
+ * @param files
+ * list of files where the query must be executed to collect DOM
+ * nodes (if file is a DOM Document).
+ * @param visitor
+ * used to execute XPath query for the current file which is a
+ * DOM Document.
+ * @param query
+ * the XPath to execute.
+ * @param xpathProcessorId
+ * the XPath processor id to use to execute XPath.
+ * @param namespaceInfos
+ * namespace infos used by the XPath processor to execute the
+ * given XPath query.
+ * @param collector
+ * the collector used to collect DOM Node.
+ * @param selectedNode
+ * the selected node which start the search.
+ * @param monitor
+ * the progress monitor.
+ * @return the status of the search.
+ */
+ public IStatus search(IFile files[], IXMLSearchDOMDocumentVisitor visitor,
+ String query, String xpathProcessorId, Namespaces namespaces,
+ IXMLSearchDOMNodeCollector collector, Object selectedNode,
+ IProgressMonitor monitor) {
+ // Create status instance
+ MultiStatus status = createStatus();
+ // Execute search
+ search(files, visitor, query, xpathProcessorId, namespaces, collector,
+ selectedNode, monitor, status);
+ // Returns status
+ return status;
+ }
+
+ /**
+ * Execute the XPath query for the given <code>files</code> and collect
+ * nodes result in the given <code>collector</code> populate the given
+ * <code>status</code> of the search.
+ *
+ * @param files
+ * list of files where the query must be executed to collect DOM
+ * nodes (if file is a DOM Document).
+ * @param visitor
+ * used to execute XPath query for the current file which is a
+ * DOM Document.
+ * @param query
+ * the XPath to execute.
+ * @param xpathProcessorId
+ * the XPath processor id to use to execute XPath.
+ * @param namespaceInfos
+ * namespace infos used by the XPath processor to execute the
+ * given XPath query.
+ * @param collector
+ * the collector used to collect DOM Node.
+ * @param selectedNode
+ * the selected node which start the search.
+ * @param monitor
+ * the progress monitor.
+ * @param status
+ * the status to populate while searching.
+ */
+ protected void search(IFile files[], IXMLSearchDOMDocumentVisitor visitor,
+ String query, String xpathProcessorId, Namespaces namespace,
+ IXMLSearchDOMNodeCollector collector, Object selectedNode,
+ IProgressMonitor monitor, MultiStatus status) {
+ IFile file = null;
+ // Loop for files
+ for (int i = 0; i < files.length; i++) {
+ file = files[i];
+ // process search for the current file
+ processFile(file, file, AllFilesXMLSearchRequestor.INSTANCE,
+ visitor, query, xpathProcessorId, namespace, collector,
+ selectedNode, status);
+ }
+ }
+
+ /**
+ * Create an instance of {@link MultiStatus}.
+ *
+ * @return
+ */
+ protected MultiStatus createStatus() {
+ return new MultiStatus(XMLSearchCorePlugin.PLUGIN_ID, IStatus.OK,
+ Messages.XMLSearchEngine_statusMessage, null);
+ }
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/FilesOfScopeCalculator.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/FilesOfScopeCalculator.java
new file mode 100644
index 0000000..d8b4c78
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/FilesOfScopeCalculator.java
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.internal;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceProxy;
+import org.eclipse.core.resources.IResourceProxyVisitor;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.wst.xml.search.core.queryspecifications.IExecutableXMLQuerySpecification;
+import org.eclipse.wst.xml.search.core.queryspecifications.IXMLQuerySpecificationRegistry;
+import org.eclipse.wst.xml.search.core.queryspecifications.requestor.IXMLSearchRequestor;
+
+/**
+ * Implementation of {@link IResourceProxyVisitor} to loop for list of
+ * {@link IResource} registered in the {@link IXMLQuerySpecificationRegistry}
+ * registry and visit each files to execute query.
+ *
+ */
+public class FilesOfScopeCalculator implements IResourceProxyVisitor {
+
+ private final IXMLQuerySpecificationRegistry querySpecificationRegistry;
+ private final MultiStatus fStatus;
+ private List<IFile> fFiles;
+
+ public FilesOfScopeCalculator(
+ IXMLQuerySpecificationRegistry querySpecificationRegistry,
+ MultiStatus status) {
+ this.querySpecificationRegistry = querySpecificationRegistry;
+ fStatus = status;
+ }
+
+ public boolean visit(IResourceProxy proxy) {
+ boolean inScope = isInScope(proxy);
+ if (inScope && proxy.getType() == IResource.FILE) {
+ fFiles.add((IFile) proxy.requestResource());
+ }
+ return inScope;
+ }
+
+ public IFile[] process() {
+ fFiles = new ArrayList<IFile>();
+ try {
+ Set<IResource> containers = querySpecificationRegistry
+ .getQuerySpecificationsMap().keySet();
+ for (IResource resource : containers) {
+ switch (resource.getType()) {
+ case IResource.FILE:
+ resource.accept(this, 0);
+ break;
+ case IResource.ROOT:
+ case IResource.PROJECT:
+ case IResource.FOLDER:
+ IContainer container = (IContainer) resource;
+ IResource[] roots = container.members();
+ for (int i = 0; i < roots.length; i++) {
+ IResource r = roots[i];
+ if (r.isAccessible()) {
+ r.accept(this, 0);
+ }
+ }
+ break;
+ }
+ }
+ return (IFile[]) fFiles.toArray(new IFile[fFiles.size()]);
+ } catch (CoreException ex) {
+ // report and ignore
+ fStatus.add(ex.getStatus());
+
+ } finally {
+ fFiles = null;
+ }
+ return null;
+ }
+
+ private boolean isInScope(IResourceProxy proxy) {
+ Collection<Collection<IExecutableXMLQuerySpecification>> values = querySpecificationRegistry
+ .getQuerySpecificationsMap().values();
+ for (Collection<IExecutableXMLQuerySpecification> collection : values) {
+ if (isInScope(proxy, collection)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean isInScope(IResourceProxy proxy,
+ Collection<IExecutableXMLQuerySpecification> collection) {
+ for (IExecutableXMLQuerySpecification executableXMLQuerySpecification : collection) {
+ if (isInScope(proxy, executableXMLQuerySpecification)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean isInScope(IResourceProxy proxy,
+ IExecutableXMLQuerySpecification executableXMLQuerySpecification) {
+ IXMLSearchRequestor requestor = executableXMLQuerySpecification
+ .getRequestor();
+ return (requestor != null ? requestor.accept(proxy.requestResource(),
+ null) : false);
+ }
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/Messages.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/Messages.java
new file mode 100644
index 0000000..f7a9bdb
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/Messages.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.internal;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Messages for XML Search Core.
+ *
+ */
+public class Messages extends NLS {
+
+ public static String searchEngineDOMModelError;
+ public static String searchEngineDOMDocumentVisitedError;
+ public static String searchEngineContainerResourcesError;
+ public static String XMLSearchEngine_statusMessage;
+
+ public static String XMLSearchEngine2_scanning;
+ public static String XMLSearchEngine2_progress_updating_job;
+ public static String XMLSearchEngine2_canceled;
+ public static String XMLSearchEngine2_textsearch_task_label;
+
+ static {
+ NLS.initializeMessages(XMLSearchCorePlugin.PLUGIN_ID
+ + ".internal.Messages", Messages.class);
+ }
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/Messages.properties b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/Messages.properties
new file mode 100644
index 0000000..d1377cf
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/Messages.properties
@@ -0,0 +1,21 @@
+###############################################################################
+# Copyright (c) 2010 Angelo Zerr 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:
+# Angelo Zerr <angelo.zerr@gmail.com> - Initial API and implementation
+###############################################################################
+searchEngineDOMModelError=Error while getting DOM Model for file "{0}".
+searchEngineDOMDocumentVisitedError=Error while visit DOM Document for file "{0}".
+searchEngineContainerResourcesError=Error while loop for files from the container "{0}".
+
+# Search engine
+XMLSearchEngine_statusMessage= Problems encountered during XML search.
+
+XMLSearchEngine2_scanning=Scanning file {1} of {2}: {0}
+XMLSearchEngine2_progress_updating_job=Search progress polling
+XMLSearchEngine2_canceled=Operation Canceled
+XMLSearchEngine2_textsearch_task_label=Searching for pattern ''{0}''...
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/Trace.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/Trace.java
new file mode 100644
index 0000000..0c7622a
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/Trace.java
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2007 IBM Corporation 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:
+ * IBM Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.internal;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+
+/**
+ * Helper class to route trace output.
+ */
+public class Trace {
+ public static final byte CONFIG = 0;
+ public static final byte INFO = 1;
+ public static final byte WARNING = 2;
+ public static final byte SEVERE = 3;
+ public static final byte FINEST = 4;
+ public static final byte FINER = 5;
+ public static final byte PERFORMANCE = 6;
+ public static final byte EXTENSION_POINT = 7;
+
+ private static final String[] levelNames = new String[] { "CONFIG ",
+ "INFO ", "WARNING", "SEVERE ", "FINER ", "FINEST ", "PERF ",
+ "EXTENSION" };
+
+ private static final SimpleDateFormat sdf = new SimpleDateFormat(
+ "dd/MM/yy HH:mm.ss.SSS");
+
+ private static Set<String> logged = new HashSet<String>();
+
+ /**
+ * Trace constructor comment.
+ */
+ private Trace() {
+ super();
+ }
+
+ /**
+ * Trace the given text.
+ *
+ * @param level
+ * a trace level
+ * @param s
+ * a message
+ */
+ public static void trace(byte level, String s) {
+ trace(level, s, null);
+ }
+
+ /**
+ * Trace the given message and exception.
+ *
+ * @param level
+ * a trace level
+ * @param s
+ * a message
+ * @param t
+ * a throwable
+ */
+ public static void trace(byte level, String s, Throwable t) {
+ if (s == null)
+ return;
+
+ if (level == SEVERE) {
+ if (!logged.contains(s)) {
+ XMLSearchCorePlugin.getDefault().getLog().log(
+ new Status(IStatus.ERROR,
+ XMLSearchCorePlugin.PLUGIN_ID, s, t));
+ logged.add(s);
+ }
+ }
+
+ if (!XMLSearchCorePlugin.getDefault().isDebugging())
+ return;
+
+ StringBuilder sb = new StringBuilder(XMLSearchCorePlugin.PLUGIN_ID);
+ sb.append(" ");
+ sb.append(levelNames[level]);
+ sb.append(" ");
+ sb.append(sdf.format(new Date()));
+ sb.append(" ");
+ sb.append(s);
+ System.out.println(sb.toString());
+ if (t != null)
+ t.printStackTrace();
+ }
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/XMLSearchCorePlugin.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/XMLSearchCorePlugin.java
new file mode 100644
index 0000000..a809002
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/XMLSearchCorePlugin.java
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.internal;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.xml.search.core.properties.PropertiesQuerySpecificationManager;
+import org.eclipse.wst.xml.search.core.queryspecifications.XMLQuerySpecificationManager;
+import org.eclipse.wst.xml.search.core.resource.ResourceQuerySpecificationManager;
+import org.eclipse.wst.xml.search.core.statics.StaticValueQuerySpecificationManager;
+import org.eclipse.wst.xml.search.core.xpath.XPathProcessorManager;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class XMLSearchCorePlugin extends Plugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.wst.xml.search.core";
+
+ // The shared instance
+ private static XMLSearchCorePlugin plugin;
+
+ /**
+ * The constructor
+ */
+ public XMLSearchCorePlugin() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
+ * )
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ XMLQuerySpecificationManager.getDefault().initialize();
+ StaticValueQuerySpecificationManager.getDefault().initialize();
+ ResourceQuerySpecificationManager.getDefault().initialize();
+ PropertiesQuerySpecificationManager.getDefault().initialize();
+ XPathProcessorManager.getDefault().initialize();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
+ * )
+ */
+ public void stop(BundleContext context) throws Exception {
+ XMLQuerySpecificationManager.getDefault().destroy();
+ StaticValueQuerySpecificationManager.getDefault().destroy();
+ ResourceQuerySpecificationManager.getDefault().destroy();
+ PropertiesQuerySpecificationManager.getDefault().destroy();
+ XPathProcessorManager.getDefault().destroy();
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static XMLSearchCorePlugin getDefault() {
+ return plugin;
+ }
+
+ public static IStatus createStatus(int severity, String message) {
+ return new Status(severity, XMLSearchCorePlugin.PLUGIN_ID, message);
+ }
+
+ public static IStatus createStatus(int severity, String message, Throwable e) {
+ return new Status(severity, XMLSearchCorePlugin.PLUGIN_ID, message, e);
+ }
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/preferences/PreferenceInitializer.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/preferences/PreferenceInitializer.java
new file mode 100644
index 0000000..64af5b9
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/preferences/PreferenceInitializer.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.internal.preferences;
+
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.wst.xml.search.core.internal.XMLSearchCorePlugin;
+import org.eclipse.wst.xml.search.core.xpath.DefaultXPathProcessor;
+
+/**
+ * XML Search Core preferences initializer used to initialize the preference of XPath
+ * Preprocessor.
+ *
+ */
+public class PreferenceInitializer extends AbstractPreferenceInitializer {
+
+ public static final String DEFAULT_XPATH_PROCESSOR = "defaultXPathProcessor";
+
+ @Override
+ public void initializeDefaultPreferences() {
+ IEclipsePreferences node = new DefaultScope()
+ .getNode(XMLSearchCorePlugin.getDefault().getBundle()
+ .getSymbolicName());
+ node.put(DEFAULT_XPATH_PROCESSOR, DefaultXPathProcessor.ID);
+ }
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/properties/PropertiesQuerySpecification.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/properties/PropertiesQuerySpecification.java
new file mode 100644
index 0000000..fdc4d25
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/properties/PropertiesQuerySpecification.java
@@ -0,0 +1,143 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.internal.properties;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+import org.eclipse.wst.xml.search.core.properties.DefaultPropertiesRequestor;
+import org.eclipse.wst.xml.search.core.properties.IPropertiesQuerySpecification;
+import org.eclipse.wst.xml.search.core.properties.IPropertiesRequestor;
+import org.eclipse.wst.xml.search.core.properties.IPropertiesRequestorProvider;
+import org.eclipse.wst.xml.search.core.queryspecifications.container.FolderContainerProvider;
+import org.eclipse.wst.xml.search.core.queryspecifications.container.IMultiResourceProvider;
+import org.eclipse.wst.xml.search.core.queryspecifications.container.IResourceProvider;
+
+/**
+ *
+ * {@link IPropertiesQuerySpecification} implementation.
+ *
+ */
+public class PropertiesQuerySpecification implements
+ IPropertiesQuerySpecification {
+
+ public static final IPropertiesQuerySpecification DEFAULT = newDefaultQuerySpecification();
+
+ private IResourceProvider containerProvider;
+ private IMultiResourceProvider multiContainerProvider;
+ private IPropertiesRequestor requestor;
+
+ protected PropertiesQuerySpecification(IResourceProvider containerProvider,
+ IMultiResourceProvider multiContainerProvider,
+ IPropertiesRequestor requestor) {
+ this.containerProvider = containerProvider;
+ this.multiContainerProvider = multiContainerProvider;
+ this.requestor = requestor;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.xml.search.core.queryspecifications.container.
+ * IResourceProvider
+ * #getResource(org.eclipse.wst.xml.core.internal.provisional
+ * .document.IDOMNode, org.eclipse.core.resources.IResource)
+ */
+ public IResource getResource(Object selectedNode, IResource resource) {
+ return containerProvider.getResource(selectedNode, resource);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.wst.xml.search.core.properties.IPropertiesRequestorProvider
+ * #getRequestor()
+ */
+ public IPropertiesRequestor getRequestor() {
+ return requestor;
+ }
+
+ /**
+ * Create default properties query specification.
+ *
+ * @return
+ */
+ public static IPropertiesQuerySpecification newDefaultQuerySpecification() {
+ return new PropertiesQuerySpecification(
+ FolderContainerProvider.INSTANCE, null,
+ DefaultPropertiesRequestor.INSTANCE);
+ }
+
+ /**
+ * Create properties query specification by using information about the
+ * given <code>querySpecification</code>.
+ *
+ * @param querySpecification
+ * @return
+ */
+ public static IPropertiesQuerySpecification newQuerySpecification(
+ Object querySpecification) {
+ PropertiesQuerySpecification specification = (PropertiesQuerySpecification) newDefaultQuerySpecification();
+ if (querySpecification instanceof IResourceProvider) {
+ // resource provider is customized.
+ specification
+ .setContainerProvider((IResourceProvider) querySpecification);
+ }
+ if (querySpecification instanceof IMultiResourceProvider) {
+ // multi-resource provider is customized.
+ specification
+ .setMultiContainerProvider((IMultiResourceProvider) querySpecification);
+ }
+ if (querySpecification instanceof IPropertiesRequestorProvider) {
+ // requestor provider is customized.
+ specification
+ .setRequestor(((IPropertiesRequestorProvider) querySpecification)
+ .getRequestor());
+ }
+ return specification;
+ }
+
+ private void setMultiContainerProvider(
+ IMultiResourceProvider multiContainerProvider) {
+ this.multiContainerProvider = multiContainerProvider;
+ }
+
+ private void setRequestor(IPropertiesRequestor requestor) {
+ this.requestor = requestor;
+ }
+
+ private void setContainerProvider(IResourceProvider containerProvider) {
+ this.containerProvider = containerProvider;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.wst.xml.search.core.properties.IPropertiesQuerySpecification
+ * #isMultiResource()
+ */
+ public boolean isMultiResource() {
+ return multiContainerProvider != null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.xml.search.core.queryspecifications.container.
+ * IMultiResourceProvider
+ * #getResources(org.eclipse.wst.xml.core.internal.provisional
+ * .document.IDOMNode, org.eclipse.core.resources.IResource)
+ */
+ public IResource[] getResources(Object selectedNode, IResource resource) {
+ return multiContainerProvider.getResources(selectedNode, resource);
+ }
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/queryspecifications/ExecutableXMLQuerySpecification.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/queryspecifications/ExecutableXMLQuerySpecification.java
new file mode 100644
index 0000000..f01ed96
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/queryspecifications/ExecutableXMLQuerySpecification.java
@@ -0,0 +1,207 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.internal.queryspecifications;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.wst.xml.search.core.namespaces.Namespaces;
+import org.eclipse.wst.xml.search.core.queryspecifications.IExecutableXMLQuerySpecification;
+import org.eclipse.wst.xml.search.core.queryspecifications.IXMLQuerySpecification;
+import org.eclipse.wst.xml.search.core.queryspecifications.IXMLQuerySpecificationRegistry;
+import org.eclipse.wst.xml.search.core.queryspecifications.querybuilder.IStringQueryBuilder;
+import org.eclipse.wst.xml.search.core.queryspecifications.requestor.IXMLSearchRequestor;
+import org.eclipse.wst.xml.search.core.queryspecifications.visitor.IXMLSearchDOMDocumentVisitor;
+
+/**
+ *
+ * Implementation of {@link IExecutableXMLQuerySpecification}.
+ *
+ */
+public class ExecutableXMLQuerySpecification implements
+ IExecutableXMLQuerySpecification {
+
+ private final IXMLQuerySpecificationRegistry registry;
+ private final IXMLQuerySpecification querySpecification;
+ private final String query;
+ private final Namespaces namespaceInfos;
+
+ public ExecutableXMLQuerySpecification(
+ IXMLQuerySpecificationRegistry registry,
+ IXMLQuerySpecification querySpecification, String query,
+ Namespaces namespaceInfos) {
+ this.registry = registry;
+ this.querySpecification = querySpecification;
+ this.query = query;
+ this.namespaceInfos = namespaceInfos;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.xml.search.core.queryspecifications.container.
+ * IResourceProvider
+ * #getResource(org.eclipse.wst.xml.core.internal.provisional
+ * .document.IDOMNode, org.eclipse.core.resources.IResource)
+ */
+ public IResource getResource(Object selectedNode, IResource resource) {
+ return querySpecification.getResource(selectedNode, resource);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.xml.search.core.queryspecifications.container.
+ * IMultiResourceProvider
+ * #getResources(org.eclipse.wst.xml.core.internal.provisional
+ * .document.IDOMNode, org.eclipse.core.resources.IResource)
+ */
+ public IResource[] getResources(Object selectedNode, IResource resource) {
+ return querySpecification.getResources(selectedNode, resource);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.wst.xml.search.core.queryspecifications.IXMLQuerySpecification
+ * #isMultiResource()
+ */
+ public boolean isMultiResource() {
+ return querySpecification.isMultiResource();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.xml.search.core.queryspecifications.container.
+ * IStorageProvider
+ * #getStorage(org.eclipse.wst.xml.core.internal.provisional.
+ * document.IDOMNode, org.eclipse.core.resources.IResource)
+ */
+ public IStorage getStorage(Object selectedNode, IResource resource) {
+ return querySpecification.getStorage(selectedNode, resource);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.xml.search.core.queryspecifications.container.
+ * IMultiStorageProvider
+ * #getStorages(org.eclipse.wst.xml.core.internal.provisional
+ * .document.IDOMNode, org.eclipse.core.resources.IResource)
+ */
+ public IStorage[] getStorages(Object selectedNode, IResource resource) {
+ return querySpecification.getStorages(selectedNode, resource);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.wst.xml.search.core.queryspecifications.IXMLQuerySpecification
+ * #isSimpleStorage()
+ */
+ public boolean isSimpleStorage() {
+ return querySpecification.isSimpleStorage();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.wst.xml.search.core.queryspecifications.IXMLQuerySpecification
+ * #isMultiStorage()
+ */
+ public boolean isMultiStorage() {
+ return querySpecification.isMultiStorage();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.xml.search.core.queryspecifications.requestor.
+ * IXMLSearchRequestorProvider#getRequestor()
+ */
+ public IXMLSearchRequestor getRequestor() {
+ return querySpecification.getRequestor();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.xml.search.core.queryspecifications.visitor.
+ * IXMLSearchVisitorProvider#getVisitor()
+ */
+ public IXMLSearchDOMDocumentVisitor getVisitor() {
+ return querySpecification.getVisitor();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.xml.search.core.queryspecifications.
+ * IExecutableXMLQuerySpecification#getSelectedNode()
+ */
+ public Object getSelectedNode() {
+ return registry.getSelectedNode();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.xml.search.core.queryspecifications.
+ * IExecutableXMLQuerySpecification#getQuery()
+ */
+ public String getQuery() {
+ return query;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.xml.search.core.queryspecifications.
+ * IExecutableXMLQuerySpecification#getNamespaces()
+ */
+ public Namespaces getNamespaces() {
+ return namespaceInfos;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.wst.xml.search.core.queryspecifications.IXPathEvaluatorIdProvider
+ * #getXPathProcessorId()
+ */
+ public String getXPathProcessorId() {
+ return querySpecification.getXPathProcessorId();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.xml.search.core.queryspecifications.querybuilder.
+ * IStringQueryBuilderProvider#getEqualsStringQueryBuilder()
+ */
+ public IStringQueryBuilder getEqualsStringQueryBuilder() {
+ return querySpecification.getEqualsStringQueryBuilder();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.xml.search.core.queryspecifications.querybuilder.
+ * IStringQueryBuilderProvider#getStartsWithStringQueryBuilder()
+ */
+ public IStringQueryBuilder getStartsWithStringQueryBuilder() {
+ return querySpecification.getStartsWithStringQueryBuilder();
+ }
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/queryspecifications/XMLQuerySpecification.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/queryspecifications/XMLQuerySpecification.java
new file mode 100644
index 0000000..1cec5b7
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/queryspecifications/XMLQuerySpecification.java
@@ -0,0 +1,206 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.internal.queryspecifications;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.wst.xml.search.core.queryspecifications.IXMLQuerySpecification;
+import org.eclipse.wst.xml.search.core.queryspecifications.IXPathProcessorIdProvider;
+import org.eclipse.wst.xml.search.core.queryspecifications.container.IMultiResourceProvider;
+import org.eclipse.wst.xml.search.core.queryspecifications.container.IMultiStorageProvider;
+import org.eclipse.wst.xml.search.core.queryspecifications.container.IResourceProvider;
+import org.eclipse.wst.xml.search.core.queryspecifications.container.IStorageProvider;
+import org.eclipse.wst.xml.search.core.queryspecifications.container.ProjectContainerProvider;
+import org.eclipse.wst.xml.search.core.queryspecifications.querybuilder.DefaultStringQueryBuilderProvider;
+import org.eclipse.wst.xml.search.core.queryspecifications.querybuilder.IStringQueryBuilder;
+import org.eclipse.wst.xml.search.core.queryspecifications.querybuilder.IStringQueryBuilderProvider;
+import org.eclipse.wst.xml.search.core.queryspecifications.requestor.AllXMLExtensionFilesXMLSearchRequestor;
+import org.eclipse.wst.xml.search.core.queryspecifications.requestor.IXMLSearchRequestor;
+import org.eclipse.wst.xml.search.core.queryspecifications.requestor.IXMLSearchRequestorProvider;
+import org.eclipse.wst.xml.search.core.queryspecifications.visitor.IXMLSearchDOMDocumentVisitor;
+import org.eclipse.wst.xml.search.core.queryspecifications.visitor.IXMLSearchVisitorProvider;
+import org.eclipse.wst.xml.search.core.queryspecifications.visitor.XPathNodeSetSearchVisitor;
+
+/**
+ *
+ * Implementation of {@link IXMLQuerySpecification} which use providers like
+ * {@link IResourceProvider} instead of directly {@link IResource}.
+ *
+ */
+public class XMLQuerySpecification implements IXMLQuerySpecification {
+
+ public static final IXMLQuerySpecification INSTANCE = newDefaultQuerySpecification();
+
+ private IStorageProvider storageProvider;
+ private IMultiStorageProvider multiStorageProvider;
+ private IResourceProvider containerProvider;
+ private IMultiResourceProvider multiContainerProvider;
+ private IXMLSearchRequestor requestor;
+ private IXMLSearchDOMDocumentVisitor visitor;
+ private IStringQueryBuilderProvider queryBuilderProvider;
+ private String xpathProcessorId;
+
+ protected XMLQuerySpecification(IResourceProvider containerProvider,
+ IMultiResourceProvider multiContainerProvider,
+ IXMLSearchRequestor requestor,
+ IXMLSearchDOMDocumentVisitor visitor,
+ IStringQueryBuilderProvider queryBuilderProvider,
+ String xpathProcessorId) {
+ this.containerProvider = containerProvider;
+ this.multiContainerProvider = multiContainerProvider;
+ this.storageProvider = null;
+ this.multiStorageProvider = null;
+ this.requestor = requestor;
+ this.visitor = visitor;
+ this.queryBuilderProvider = queryBuilderProvider;
+ this.xpathProcessorId = xpathProcessorId;
+ }
+
+ public IResource getResource(Object selectedNode, IResource resource) {
+ return containerProvider.getResource(selectedNode, resource);
+ }
+
+ public IResource[] getResources(Object selectedNode, IResource resource) {
+ if (multiContainerProvider == null) {
+ return null;
+ }
+ return multiContainerProvider.getResources(selectedNode, resource);
+ }
+
+ public boolean isMultiResource() {
+ return multiContainerProvider != null;
+ }
+
+ public IStorage getStorage(Object selectedNode, IResource resource) {
+ if (storageProvider == null) {
+ return null;
+ }
+ return storageProvider.getStorage(selectedNode, resource);
+ }
+
+ public IStorage[] getStorages(Object selectedNode, IResource resource) {
+ if (multiStorageProvider == null) {
+ return null;
+ }
+ return multiStorageProvider.getStorages(selectedNode, resource);
+ }
+
+ public boolean isSimpleStorage() {
+ return storageProvider != null;
+ }
+
+ public boolean isMultiStorage() {
+ return multiStorageProvider != null;
+ }
+
+ public IXMLSearchRequestor getRequestor() {
+ return requestor;
+ }
+
+ public IXMLSearchDOMDocumentVisitor getVisitor() {
+ return visitor;
+ }
+
+ public static IXMLQuerySpecification newDefaultQuerySpecification() {
+ return new XMLQuerySpecification(ProjectContainerProvider.INSTANCE,
+ null, AllXMLExtensionFilesXMLSearchRequestor.INSTANCE,
+ XPathNodeSetSearchVisitor.INSTANCE,
+ DefaultStringQueryBuilderProvider.INSTANCE, null);
+ }
+
+ public static IXMLQuerySpecification newQuerySpecification(
+ Object querySpecification) {
+ XMLQuerySpecification specification = (XMLQuerySpecification) newDefaultQuerySpecification();
+ if (querySpecification instanceof IResourceProvider) {
+ specification
+ .setContainerProvider((IResourceProvider) querySpecification);
+ }
+ if (querySpecification instanceof IMultiResourceProvider) {
+ specification
+ .setMultiContainerProvider((IMultiResourceProvider) querySpecification);
+ }
+ if (querySpecification instanceof IStorageProvider) {
+ specification
+ .setStorageProvider((IStorageProvider) querySpecification);
+ }
+ if (querySpecification instanceof IMultiStorageProvider) {
+ specification
+ .setMultiStorageProvider((IMultiStorageProvider) querySpecification);
+ }
+ if (querySpecification instanceof IXMLSearchRequestorProvider) {
+ specification
+ .setRequestor(((IXMLSearchRequestorProvider) querySpecification)
+ .getRequestor());
+ }
+ if (querySpecification instanceof IXMLSearchVisitorProvider) {
+ specification
+ .setVisitor(((IXMLSearchVisitorProvider) querySpecification)
+ .getVisitor());
+ }
+ if (querySpecification instanceof IStringQueryBuilderProvider) {
+ specification
+ .setStringQueryBuilderProvider((IStringQueryBuilderProvider) querySpecification);
+ }
+ if (querySpecification instanceof IXPathProcessorIdProvider) {
+ specification
+ .setXPathEvaluatorId(((IXPathProcessorIdProvider) querySpecification)
+ .getXPathProcessorId());
+ }
+ return specification;
+ }
+
+ private void setMultiContainerProvider(
+ IMultiResourceProvider multiContainerProvider) {
+ this.multiContainerProvider = multiContainerProvider;
+ }
+
+ private void setStorageProvider(IStorageProvider storageProvider) {
+ this.storageProvider = storageProvider;
+ }
+
+ private void setMultiStorageProvider(
+ IMultiStorageProvider multiStorageProvider) {
+ this.multiStorageProvider = multiStorageProvider;
+ }
+
+ private void setXPathEvaluatorId(String xPathEvaluatorId) {
+ this.xpathProcessorId = xPathEvaluatorId;
+ }
+
+ private void setStringQueryBuilderProvider(
+ IStringQueryBuilderProvider queryBuilderProvider) {
+ this.queryBuilderProvider = queryBuilderProvider;
+ }
+
+ private void setRequestor(IXMLSearchRequestor requestor) {
+ this.requestor = requestor;
+ }
+
+ private void setVisitor(IXMLSearchDOMDocumentVisitor visitor) {
+ this.visitor = visitor;
+ }
+
+ private void setContainerProvider(IResourceProvider containerProvider) {
+ this.containerProvider = containerProvider;
+ }
+
+ public IStringQueryBuilder getEqualsStringQueryBuilder() {
+ return queryBuilderProvider.getEqualsStringQueryBuilder();
+ }
+
+ public IStringQueryBuilder getStartsWithStringQueryBuilder() {
+ return queryBuilderProvider.getStartsWithStringQueryBuilder();
+ }
+
+ public String getXPathProcessorId() {
+ return xpathProcessorId;
+ }
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/queryspecifications/XMLQuerySpecification2.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/queryspecifications/XMLQuerySpecification2.java
new file mode 100644
index 0000000..01f3418
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/queryspecifications/XMLQuerySpecification2.java
@@ -0,0 +1,156 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.internal.queryspecifications;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+import org.eclipse.wst.xml.search.core.queryspecifications.IXMLQuerySpecification;
+import org.eclipse.wst.xml.search.core.queryspecifications.container.IResourceProvider;
+import org.eclipse.wst.xml.search.core.queryspecifications.querybuilder.DefaultStringQueryBuilderProvider;
+import org.eclipse.wst.xml.search.core.queryspecifications.querybuilder.IStringQueryBuilder;
+import org.eclipse.wst.xml.search.core.queryspecifications.requestor.AllXMLExtensionFilesXMLSearchRequestor;
+import org.eclipse.wst.xml.search.core.queryspecifications.requestor.IXMLSearchRequestor;
+import org.eclipse.wst.xml.search.core.queryspecifications.visitor.IXMLSearchDOMDocumentVisitor;
+import org.eclipse.wst.xml.search.core.queryspecifications.visitor.XPathNodeSetSearchVisitor;
+
+/**
+ *
+ * Implementation of {@link IXMLQuerySpecification} which doesn't use providers
+ * (it use directly {@link IResource} instead of using {@link IResourceProvider}
+ * ).
+ *
+ */
+public class XMLQuerySpecification2 implements IXMLQuerySpecification {
+
+ private IResource container;
+ private IResource[] containers;
+ private IXMLSearchRequestor requestor;
+ private IXMLSearchDOMDocumentVisitor visitor;
+ private IStringQueryBuilder equalsStringQueryBuilder;
+ private IStringQueryBuilder startsWithStringQueryBuilder;
+ private String xpathEvaluatorId;
+
+ public XMLQuerySpecification2(IResource container, IResource[] containers,
+ IXMLSearchRequestor requestor,
+ IXMLSearchDOMDocumentVisitor visitor,
+ IStringQueryBuilder equalsStringQueryBuilder,
+ IStringQueryBuilder startsWithStringQueryBuilder,
+ String xpathEvaluatorId) {
+ this.container = container;
+ this.requestor = requestor;
+ this.visitor = visitor;
+ this.equalsStringQueryBuilder = equalsStringQueryBuilder;
+ this.startsWithStringQueryBuilder = startsWithStringQueryBuilder;
+ }
+
+ public static XMLQuerySpecification2 newDefaultQuerySpecification(
+ IResource container) {
+ return new XMLQuerySpecification2(container, null,
+ AllXMLExtensionFilesXMLSearchRequestor.INSTANCE,
+ XPathNodeSetSearchVisitor.INSTANCE,
+ DefaultStringQueryBuilderProvider.INSTANCE
+ .getEqualsStringQueryBuilder(),
+ DefaultStringQueryBuilderProvider.INSTANCE
+ .getStartsWithStringQueryBuilder(), null);
+ }
+
+ public static XMLQuerySpecification2 newDefaultQuerySpecification(
+ IResource[] containers) {
+ return new XMLQuerySpecification2(null, containers,
+ AllXMLExtensionFilesXMLSearchRequestor.INSTANCE,
+ XPathNodeSetSearchVisitor.INSTANCE,
+ DefaultStringQueryBuilderProvider.INSTANCE
+ .getEqualsStringQueryBuilder(),
+ DefaultStringQueryBuilderProvider.INSTANCE
+ .getStartsWithStringQueryBuilder(), null);
+ }
+
+ public boolean isMultiResource() {
+ return containers != null;
+ }
+
+ public IResource getResource(Object selectedNode, IResource resource) {
+ return container;
+ }
+
+ public IResource[] getResources(Object selectedNode, IResource resource) {
+ return containers;
+ }
+
+ public void setContainer(IContainer container) {
+ this.container = container;
+ }
+
+ public IXMLSearchRequestor getRequestor() {
+ return requestor;
+ }
+
+ public void setRequestor(IXMLSearchRequestor requestor) {
+ this.requestor = requestor;
+ }
+
+ public IXMLSearchDOMDocumentVisitor getVisitor() {
+ return visitor;
+ }
+
+ public void setVisitor(IXMLSearchDOMDocumentVisitor visitor) {
+ this.visitor = visitor;
+ }
+
+ public IStringQueryBuilder getEqualsStringQueryBuilder() {
+ return equalsStringQueryBuilder;
+ }
+
+ public void setEqualsStringQueryBuilder(
+ IStringQueryBuilder equalsStringQueryBuilder) {
+ this.equalsStringQueryBuilder = equalsStringQueryBuilder;
+ }
+
+ public IStringQueryBuilder getStartsWithStringQueryBuilder() {
+ return startsWithStringQueryBuilder;
+ }
+
+ public void setStartsWithStringQueryBuilder(
+ IStringQueryBuilder startsWithStringQueryBuilder) {
+ this.startsWithStringQueryBuilder = startsWithStringQueryBuilder;
+ }
+
+ public String getXPathProcessorId() {
+ return xpathEvaluatorId;
+ }
+
+ public void setXPathProcessorId(String xpathEvaluatorId) {
+ this.xpathEvaluatorId = xpathEvaluatorId;
+ }
+
+ public boolean isMultiStorage() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean isSimpleStorage() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public IStorage getStorage(Object selectedNode, IResource resource) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public IStorage[] getStorages(Object selectedNode, IResource resource) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/reporter/XMLSearchReporterIdProvider.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/reporter/XMLSearchReporterIdProvider.java
new file mode 100644
index 0000000..e519615
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/reporter/XMLSearchReporterIdProvider.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.internal.reporter;
+
+/**
+ * Increment the done search.
+ *
+ */
+public class XMLSearchReporterIdProvider {
+
+ private static int searchId = 0;
+
+ public static synchronized int getSearchId() {
+ return searchId++;
+ }
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/resource/ResourceQuerySpecification.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/resource/ResourceQuerySpecification.java
new file mode 100644
index 0000000..aff1958
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/resource/ResourceQuerySpecification.java
@@ -0,0 +1,115 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.internal.resource;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+import org.eclipse.wst.xml.search.core.queryspecifications.container.FolderContainerProvider;
+import org.eclipse.wst.xml.search.core.queryspecifications.container.IMultiResourceProvider;
+import org.eclipse.wst.xml.search.core.queryspecifications.container.IResourceProvider;
+import org.eclipse.wst.xml.search.core.resource.DefaultResourceRequestor;
+import org.eclipse.wst.xml.search.core.resource.DefaultURIResolverProvider;
+import org.eclipse.wst.xml.search.core.resource.IResourceQuerySpecification;
+import org.eclipse.wst.xml.search.core.resource.IResourceRequestor;
+import org.eclipse.wst.xml.search.core.resource.IResourceRequestorProvider;
+import org.eclipse.wst.xml.search.core.resource.IURIResolver;
+import org.eclipse.wst.xml.search.core.resource.IURIResolverProvider;
+
+/**
+ *
+ * Implementation of {@link IResourceQuerySpecification}.
+ *
+ */
+public class ResourceQuerySpecification implements IResourceQuerySpecification {
+
+ public static final IResourceQuerySpecification DEFAULT = newDefaultQuerySpecification();
+
+ private IResourceProvider containerProvider;
+ private IMultiResourceProvider multiContainerProvider;
+ private IResourceRequestor requestor;
+ private IURIResolverProvider resolverProvider;
+
+ protected ResourceQuerySpecification(IResourceProvider containerProvider,
+ IMultiResourceProvider multiContainerProvider,
+ IResourceRequestor requestor, IURIResolverProvider resolverProvider) {
+ this.containerProvider = containerProvider;
+ this.multiContainerProvider = multiContainerProvider;
+ this.requestor = requestor;
+ this.resolverProvider = resolverProvider;
+ }
+
+ public IResource getResource(Object selectedNode, IResource resource) {
+ return containerProvider.getResource(selectedNode, resource);
+ }
+
+ public IResourceRequestor getRequestor() {
+ return requestor;
+ }
+
+ public IURIResolver getURIResolver(IFile file, Object selectedNode) {
+ return resolverProvider.getURIResolver(file, selectedNode);
+ }
+
+ public static IResourceQuerySpecification newDefaultQuerySpecification() {
+ return new ResourceQuerySpecification(FolderContainerProvider.INSTANCE,
+ null, DefaultResourceRequestor.INSTANCE,
+ DefaultURIResolverProvider.INSTANCE);
+ }
+
+ public static IResourceQuerySpecification newQuerySpecification(
+ Object querySpecification) {
+ ResourceQuerySpecification specification = (ResourceQuerySpecification) newDefaultQuerySpecification();
+ if (querySpecification instanceof IResourceProvider) {
+ specification
+ .setContainerProvider((IResourceProvider) querySpecification);
+ }
+ if (querySpecification instanceof IMultiResourceProvider) {
+ specification
+ .setMultiContainerProvider((IMultiResourceProvider) querySpecification);
+ }
+ if (querySpecification instanceof IResourceRequestorProvider) {
+ specification
+ .setRequestor(((IResourceRequestorProvider) querySpecification)
+ .getRequestor());
+ }
+ if (querySpecification instanceof IURIResolverProvider) {
+ specification
+ .setURIResolverProvider((IURIResolverProvider) querySpecification);
+ }
+ return specification;
+ }
+
+ private void setMultiContainerProvider(
+ IMultiResourceProvider multiContainerProvider) {
+ this.multiContainerProvider = multiContainerProvider;
+ }
+
+ private void setURIResolverProvider(IURIResolverProvider resolverProvider) {
+ this.resolverProvider = resolverProvider;
+ }
+
+ private void setRequestor(IResourceRequestor requestor) {
+ this.requestor = requestor;
+ }
+
+ private void setContainerProvider(IResourceProvider containerProvider) {
+ this.containerProvider = containerProvider;
+ }
+
+ public boolean isMultiResource() {
+ return multiContainerProvider != null;
+ }
+
+ public IResource[] getResources(Object selectedNode, IResource resource) {
+ return multiContainerProvider.getResources(selectedNode, resource);
+ }
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/statics/StaticValueQuerySpecification.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/statics/StaticValueQuerySpecification.java
new file mode 100644
index 0000000..7c76451
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/statics/StaticValueQuerySpecification.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.internal.statics;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.wst.xml.search.core.statics.IStaticValueQuerySpecification;
+import org.eclipse.wst.xml.search.core.statics.IStaticValueVisitor;
+import org.eclipse.wst.xml.search.core.statics.IStaticValueVisitorProvider;
+
+/**
+ *
+ * Implementation of {@link IStaticValueQuerySpecification}.
+ *
+ */
+public class StaticValueQuerySpecification implements
+ IStaticValueQuerySpecification {
+
+ private final IStaticValueVisitorProvider provider;
+ private final IStaticValueVisitor visitor;
+
+ public StaticValueQuerySpecification(IStaticValueVisitorProvider provider) {
+ this.visitor = null;
+ this.provider = provider;
+ }
+
+ public StaticValueQuerySpecification(IStaticValueVisitor visitor) {
+ this.visitor = visitor;
+ this.provider = null;
+ }
+
+ public IStaticValueVisitor getVisitor(Object selectedNode, IFile file) {
+ if (provider != null) {
+ return provider.getVisitor(selectedNode, file);
+ }
+ return visitor;
+ }
+
+ public static IStaticValueQuerySpecification newQuerySpecification(
+ Object createExecutableExtension) {
+ if (createExecutableExtension instanceof IStaticValueVisitorProvider) {
+ return new StaticValueQuerySpecification(
+ (IStaticValueVisitorProvider) createExecutableExtension);
+ }
+ if (createExecutableExtension instanceof IStaticValueVisitor) {
+ return new StaticValueQuerySpecification(
+ (IStaticValueVisitor) createExecutableExtension);
+ }
+ return null;
+ }
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/storage/StorageModelManager.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/storage/StorageModelManager.java
new file mode 100644
index 0000000..eebbefc
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/storage/StorageModelManager.java
@@ -0,0 +1,222 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.internal.storage;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.xml.search.core.internal.Trace;
+import org.eclipse.wst.xml.search.core.storage.IStorageLocationProvider;
+import org.eclipse.wst.xml.search.core.storage.IStorageModelManager;
+
+/**
+ *
+ * {@link IStorageModelManager} implementation.
+ *
+ */
+public class StorageModelManager implements IStorageModelManager {
+
+ public static final IStorageModelManager INSTANCE = new StorageModelManager();
+
+ private Map<IStorage, ModelInfo> modelInfoMap = new HashMap<IStorage, ModelInfo>();
+
+ private IStorageLocationProvider locationProvider = null;
+
+ /**
+ * Collection of info that goes with a model.
+ */
+ private class ModelInfo {
+
+ public final IStructuredModel structuredModel;
+ public final IStorage storage;
+
+ public ModelInfo(IStructuredModel structuredModel, IStorage storage) {
+ this.structuredModel = structuredModel;
+ this.storage = storage;
+ }
+ }
+
+ public IStructuredModel getModel(IStorage storage) {
+ ModelInfo info = getModelInfoFor(storage);
+ if (info != null) {
+ return info.structuredModel;
+ } else {
+ IStructuredModel model = loadModel(storage);
+ if (model != null) {
+ modelInfoMap.put(storage, new ModelInfo(model, storage));
+ }
+ }
+ return null;
+ }
+
+ public IStructuredModel loadModel(IStorage storage) {
+ String id = calculateID(storage);
+ if (id == null) {
+ return null;
+ }
+ InputStream contents = null;
+ try {
+ contents = storage.getContents();
+ } catch (CoreException noStorageExc) {
+ // if (logExceptions)
+ // Logger.logException(NLS.bind(SSEUIMessages._32concat_EXC_, new
+ // Object[]{input.getName()}), noStorageExc);
+ }
+
+ IStructuredModel model = null;
+ try {
+ // first parameter must be unique
+ model = StructuredModelManager.getModelManager().getModelForEdit(
+ id, contents, null);
+ model.setBaseLocation(calculateBaseLocation(storage));
+ } catch (IOException e) {
+ // if (logExceptions)
+ // Logger.logException(NLS.bind(SSEUIMessages._32concat_EXC_, new
+ // Object[]{input}), e);
+ } finally {
+ if (contents != null) {
+ try {
+ contents.close();
+ } catch (IOException e) {
+ // nothing
+ } catch (Exception e) {
+ Trace.trace(Trace.SEVERE, "StorageModelManager#loadModel",
+ e);
+ }
+ }
+ }
+ return model;
+
+ }
+
+ String calculateBaseLocation(IStorage storage) {
+ String location = null;
+ if (locationProvider != null) {
+ location = locationProvider.getLocation(storage);
+ }
+ if (location != null) {
+ return location;
+ }
+ try {
+ if (storage != null) {
+ IPath storagePath = storage.getFullPath();
+ String name = storage.getName();
+ if (storagePath != null) {
+ // If they are different, the IStorage contract is not
+ // being honored
+ // (https://bugs.eclipse.org/bugs/show_bug.cgi?id=73098).
+ // Favor the name.
+ if (!storagePath.lastSegment().equals(name)) {
+ IPath workingPath = storagePath.addTrailingSeparator();
+ location = workingPath.append(name).toString();
+ } else {
+ location = storagePath.makeAbsolute().toString();
+ }
+ }
+ if (location == null)
+ location = name;
+ }
+ } catch (Throwable e) {
+ Trace.trace(Trace.SEVERE,
+ "StorageModelManager#calculateBaseLocation", e);
+ } finally {
+ if (location == null)
+ location = storage.getName();
+ }
+ return location;
+ }
+
+ String calculateID(IStorage storage) {
+ /**
+ * Typically CVS will return a path of "filename.ext" and the input's
+ * name will be "filename.ext version". The path must be used to load
+ * the model so that the suffix will be available to compute the
+ * contentType properly. The editor input name can then be set as the
+ * base location for display on the editor title bar.
+ *
+ */
+ String path = null;
+ try {
+ if (storage != null) {
+ IPath storagePath = storage.getFullPath();
+ String name = storage.getName();
+ if (storagePath != null) {
+ // If they are different, the IStorage contract is not
+ // being honored
+ // (https://bugs.eclipse.org/bugs/show_bug.cgi?id=73098).
+ // Favor the name.
+ if (!storagePath.lastSegment().equals(name)) {
+ IPath workingPath = storagePath.addTrailingSeparator();
+ path = workingPath.append(name).toString();
+ } else {
+ path = storagePath.makeAbsolute().toString();
+ }
+ }
+ if (path == null)
+ path = name;
+ }
+ } catch (Throwable e) {
+ Trace.trace(Trace.SEVERE, "StorageModelManager#calculateID", e);
+ } finally {
+ if (path == null)
+ path = ""; //$NON-NLS-1$
+ }
+ /*
+ * Prepend the hash to the path value so that we have a 1:1:1 match
+ * between editor inputs, element info, and models. The editor manager
+ * should help prevent needlessly duplicated models as long as two
+ * editor inputs from the same storage indicate they're equals().
+ */
+ path = storage.hashCode() + "#" + path; //$NON-NLS-1$
+ return path;
+ }
+
+ public IStorage getStorage(IStructuredModel model) {
+ ModelInfo info = getModelInfoFor(model);
+ if (info != null) {
+ return info.storage;
+ }
+ return null;
+ }
+
+ private ModelInfo getModelInfoFor(IStorage storage) {
+ ModelInfo result = (ModelInfo) modelInfoMap.get(storage);
+ return result;
+ }
+
+ private ModelInfo getModelInfoFor(IStructuredModel structuredModel) {
+ ModelInfo result = null;
+ if (structuredModel != null) {
+ ModelInfo[] modelInfos = (ModelInfo[]) modelInfoMap.values()
+ .toArray(new ModelInfo[0]);
+ for (int i = 0; i < modelInfos.length; i++) {
+ ModelInfo info = modelInfos[i];
+ if (structuredModel.equals(info.structuredModel)) {
+ result = info;
+ break;
+ }
+ }
+ }
+ return result;
+ }
+
+ public void setStorageLocationProvider(
+ IStorageLocationProvider locationProvider) {
+ this.locationProvider = locationProvider;
+ }
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/xpath/XPathProcessorType.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/xpath/XPathProcessorType.java
new file mode 100644
index 0000000..5657d44
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/internal/xpath/XPathProcessorType.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.internal.xpath;
+
+import org.eclipse.wst.xml.search.core.xpath.IXPathProcessor;
+import org.eclipse.wst.xml.search.core.xpath.IXPathProcessorType;
+
+/**
+ *
+ * Implementation of {@link IXPathProcessorType}.
+ *
+ */
+public class XPathProcessorType implements IXPathProcessorType {
+
+ private final String id;
+ private final String name;
+ private final boolean contributed;
+ private final String source;
+ private final IXPathProcessor evaluator;
+
+ public XPathProcessorType(String id, String name, String source,
+ boolean contributed, IXPathProcessor evaluator) {
+ this.id = id;
+ this.name = name;
+ this.source = source;
+ this.contributed = contributed;
+ this.evaluator = evaluator;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.wst.xml.search.core.xpath.IXPathProcessorType#getProcessor()
+ */
+ public IXPathProcessor getProcessor() {
+ return evaluator;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.xml.search.core.xpath.IXPathProcessorType#getId()
+ */
+ public String getId() {
+ return id;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.xml.search.core.xpath.IXPathProcessorType#getName()
+ */
+ public String getName() {
+ return name;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.wst.xml.search.core.xpath.IXPathProcessorType#isContributed()
+ */
+ public boolean isContributed() {
+ return contributed;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.wst.xml.search.core.xpath.IXPathProcessorType#getSource()
+ */
+ public String getSource() {
+ return source;
+ }
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/namespaces/INamespaceMatcher.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/namespaces/INamespaceMatcher.java
new file mode 100644
index 0000000..e00eb34
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/namespaces/INamespaceMatcher.java
@@ -0,0 +1,12 @@
+package org.eclipse.wst.xml.search.core.namespaces;
+
+import org.eclipse.wst.xml.search.core.xpath.NamespaceInfos;
+import org.w3c.dom.Node;
+
+public interface INamespaceMatcher {
+
+ boolean match(Node node);
+
+ String format(String prefix, String xpath, NamespaceInfos namespaceInfos);
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/namespaces/NamespaceMatcher.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/namespaces/NamespaceMatcher.java
new file mode 100644
index 0000000..d5a347e
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/namespaces/NamespaceMatcher.java
@@ -0,0 +1,46 @@
+package org.eclipse.wst.xml.search.core.namespaces;
+
+import java.util.List;
+
+import org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo;
+import org.eclipse.wst.xml.search.core.xpath.NamespaceInfos;
+import org.w3c.dom.Node;
+
+public abstract class NamespaceMatcher implements INamespaceMatcher {
+
+ public String format(String prefix, final String xpath,
+ NamespaceInfos namespaceInfos) {
+ String newXpath = xpath;
+ String namespaceURI = null;
+ String p = null;
+ boolean formatted = false;
+ List<NamespaceInfo> infos = namespaceInfos;
+ for (NamespaceInfo namespaceInfo : infos) {
+ namespaceURI = namespaceInfo.uri;
+ if (namespaceURI != null && isMatchedNamespace(namespaceURI)) {
+ p = namespaceInfo.prefix;
+ newXpath = xpath.replaceAll(prefix + ":", p + ":");
+ formatted = true;
+ }
+ }
+ if (!formatted) {
+ newXpath = xpath.replaceAll(prefix + ":", "");
+ newXpath += "[starts-with(name(.), \"" + prefix + "\")]";
+ }
+ return newXpath;
+ }
+
+ public boolean match(Node node) {
+ String namespaceURI = node.getNamespaceURI();
+ if (namespaceURI != null) {
+ return isMatchedNamespace(namespaceURI);
+ } else {
+ return isMatchedPrefix(node.getPrefix());
+ }
+ }
+
+ protected abstract boolean isMatchedNamespace(String namespaceURI);
+
+ protected abstract boolean isMatchedPrefix(String prefix);
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/namespaces/Namespaces.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/namespaces/Namespaces.java
new file mode 100644
index 0000000..ce9ace2
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/namespaces/Namespaces.java
@@ -0,0 +1,48 @@
+package org.eclipse.wst.xml.search.core.namespaces;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import org.eclipse.wst.xml.search.core.xpath.NamespaceInfos;
+import org.w3c.dom.Node;
+
+public class Namespaces {
+
+ private Map<String, INamespaceMatcher> matchers;
+
+ public Namespaces() {
+ matchers = new HashMap<String, INamespaceMatcher>();
+ }
+
+ public boolean match(Node node) {
+ // String prefix = null;
+ INamespaceMatcher matcher = null;
+ Set<Entry<String, INamespaceMatcher>> entries = matchers.entrySet();
+ for (Entry<String, INamespaceMatcher> entry : entries) {
+ matcher = entry.getValue();
+ if (matcher.match(node)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public String format(String xpath, NamespaceInfos namespaceInfos) {
+ String prefix = null;
+ INamespaceMatcher matcher = null;
+ Set<Entry<String, INamespaceMatcher>> entries = matchers.entrySet();
+ for (Entry<String, INamespaceMatcher> entry : entries) {
+ prefix = entry.getKey();
+ matcher = entry.getValue();
+ xpath = matcher.format(prefix, xpath, namespaceInfos);
+ }
+ return xpath;
+ }
+
+ public void addMatcher(String prefix, INamespaceMatcher matcher) {
+ matchers.put(prefix, matcher);
+ }
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/namespaces/NamespacesManager.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/namespaces/NamespacesManager.java
new file mode 100644
index 0000000..0318be5
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/namespaces/NamespacesManager.java
@@ -0,0 +1,119 @@
+package org.eclipse.wst.xml.search.core.namespaces;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionDelta;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.wst.xml.search.core.AbstractRegistryManager;
+import org.eclipse.wst.xml.search.core.internal.Trace;
+import org.eclipse.wst.xml.search.core.internal.XMLSearchCorePlugin;
+import org.eclipse.wst.xml.search.core.util.StringUtils;
+
+public class NamespacesManager extends AbstractRegistryManager {
+
+ private static final String NAMESPACES_EXTENSION_POINT = "namespaces";
+
+ private static final String ID_ATTR = "id";
+ private static final String NAMESPACES_ELT = "namespaces";
+ private static final String MATCHER_ELT = "matcher";
+ private static final String CLASS_ATTR = "class";
+ private static final String PREFIX_ATTR = "prefix";
+
+ private static final NamespacesManager INSTANCE = new NamespacesManager();
+
+ private Map<String, Namespaces> namespacesById;
+
+ public static NamespacesManager getInstance() {
+ return INSTANCE;
+ }
+
+ @Override
+ protected void handleExtensionDelta(IExtensionDelta delta) {
+ if (namespacesById == null) {// not loaded yet
+ return;
+ }
+ if (delta.getKind() == IExtensionDelta.ADDED) {
+ IConfigurationElement[] cf = delta.getExtension()
+ .getConfigurationElements();
+ addNamespaces(namespacesById, cf);
+ } else {
+ // TODO : remove references
+ }
+ }
+
+ public Namespaces getNamespaces(String id) {
+ if (StringUtils.isEmpty(id)) {
+ return null;
+ }
+ if (namespacesById == null) {
+ loadNamespaces();
+ }
+ return namespacesById.get(id);
+ }
+
+ private synchronized void loadNamespaces() {
+ if (namespacesById != null) {
+ return;
+ }
+
+ Map<String, Namespaces> namespacesById = null;
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ if (registry != null) {
+ IConfigurationElement[] cf = registry
+ .getConfigurationElementsFor(
+ getPluginId(),
+ NAMESPACES_EXTENSION_POINT);
+ namespacesById = new HashMap<String, Namespaces>(cf.length);
+ addNamespaces(namespacesById, cf);
+ } else {
+ namespacesById = new HashMap<String, Namespaces>();
+ }
+ this.namespacesById = namespacesById;
+ super.addRegistryListenerIfNeeded();
+
+ }
+
+ private synchronized void addNamespaces(
+ Map<String, Namespaces> namespacesById, IConfigurationElement[] cf) {
+ String id = null;
+ for (IConfigurationElement ce : cf) {
+ // loop for to get searcher declaration
+ if (NAMESPACES_ELT.equals(ce.getName())) {
+ id = ce.getAttribute(ID_ATTR);
+ Namespaces namespaces = new Namespaces();
+ for (IConfigurationElement cns : ce.getChildren(MATCHER_ELT)) {
+ parseNamespacesDecl(namespaces, cns);
+ }
+ namespacesById.put(id, namespaces);
+ }
+ }
+ }
+
+ private void parseNamespacesDecl(Namespaces namespaces,
+ IConfigurationElement cns) {
+ String prefix = cns.getAttribute(PREFIX_ATTR);
+ try {
+ INamespaceMatcher matcher = (INamespaceMatcher)cns.createExecutableExtension(CLASS_ATTR);
+ namespaces.addMatcher(prefix, matcher);
+ } catch (CoreException e) {
+ Trace.trace(Trace.SEVERE, "Error namespace matcher.", e);
+ }
+
+ }
+
+ @Override
+ protected String getPluginId() {
+ return XMLSearchCorePlugin.PLUGIN_ID;
+ }
+
+ @Override
+ protected String getExtensionPoint() {
+ return NAMESPACES_EXTENSION_POINT;
+ }
+
+}
+
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/properties/DefaultPropertiesRequestor.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/properties/DefaultPropertiesRequestor.java
new file mode 100644
index 0000000..db13eed
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/properties/DefaultPropertiesRequestor.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.properties;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+
+/**
+ * Default implementation of {@link IPropertiesRequestor}.
+ *
+ */
+public class DefaultPropertiesRequestor implements IPropertiesRequestor {
+
+ public static final IPropertiesRequestor INSTANCE = new DefaultPropertiesRequestor();
+
+ public static final String PROPERTIES_EXT = "properties";
+ protected static final String DOT_FOLDER = ".";
+
+ public boolean accept(IResource resource, IResource rootResource) {
+ int resourceType = resource.getType();
+ switch (resourceType) {
+ case IResource.ROOT:
+ return accept((IWorkspaceRoot) resource, rootResource);
+ case IResource.PROJECT:
+ return accept((IProject) resource, rootResource);
+ case IResource.FOLDER:
+ return accept((IFolder) resource, rootResource);
+ case IResource.FILE:
+ return accept((IFile) resource, rootResource);
+ }
+ return false;
+ }
+
+ public boolean accept(IWorkspaceRoot workspaceRoot, IResource rootResource) {
+ return true;
+ }
+
+ public boolean accept(IProject project, IResource rootResource) {
+ if (project.isOpen()) {
+ return true;
+ }
+ return false;
+ }
+
+ public boolean accept(IFolder folder, IResource rootResource) {
+ // ignore .svn folder....
+ return !folder.getName().startsWith(DOT_FOLDER);
+ }
+
+ protected boolean accept(IFile file, IResource rootResource) {
+ return PROPERTIES_EXT.equals(file.getFileExtension());
+ }
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/properties/IPropertiesCollector.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/properties/IPropertiesCollector.java
new file mode 100644
index 0000000..41fe48a
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/properties/IPropertiesCollector.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.properties;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IStorage;
+
+/**
+ * A collector to collect {@link IResource} found with the search.
+ *
+ */
+public interface IPropertiesCollector {
+
+ /**
+ * Collect the storage.
+ *
+ * @param storage
+ * @param key
+ * @param name
+ * @return
+ */
+ boolean add(IStorage storage, String key, String name);
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/properties/IPropertiesQuerySpecification.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/properties/IPropertiesQuerySpecification.java
new file mode 100644
index 0000000..6ddf0b3
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/properties/IPropertiesQuerySpecification.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.properties;
+
+import org.eclipse.wst.xml.search.core.queryspecifications.container.IMultiResourceProvider;
+import org.eclipse.wst.xml.search.core.queryspecifications.container.IResourceProvider;
+
+/**
+ * Interface of Properties Query specification used to search property from
+ * properties files coming from workspace or JAR.
+ *
+ */
+public interface IPropertiesQuerySpecification extends IResourceProvider,
+ IPropertiesRequestorProvider, IMultiResourceProvider {
+
+ public static final IPropertiesQuerySpecification[] EMPTY = new IPropertiesQuerySpecification[0];
+
+ /**
+ * Returns true if multi-resources is supported and false otherwise.
+ *
+ * @return
+ */
+ boolean isMultiResource();
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/properties/IPropertiesRequestor.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/properties/IPropertiesRequestor.java
new file mode 100644
index 0000000..376e0d5
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/properties/IPropertiesRequestor.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.properties;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.wst.xml.search.core.resource.IResourceCollector;
+
+/**
+ * Resource requestor is used when search is started. Search loop for each
+ * container and files and call a requestor to know if the resource is accepted
+ * for the search result or not. If the resource is accepted, it is added by
+ * using a a {@link IResourceCollector}.
+ *
+ * @author Angelo ZERR
+ *
+ */
+public interface IPropertiesRequestor {
+
+ /**
+ * Returns true if resource (file, folder, project) must be accepted while
+ * searching and false otherwise.
+ *
+ * @param resource
+ * the resource to accept
+ * @param resource
+ * the root resource where search start.
+ * @return
+ */
+ boolean accept(IResource resource, IResource rootResource);
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/properties/IPropertiesRequestorProvider.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/properties/IPropertiesRequestorProvider.java
new file mode 100644
index 0000000..1763002
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/properties/IPropertiesRequestorProvider.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.properties;
+
+/**
+ * A provider to returns {@link IPropertiesRequestor}.
+ *
+ */
+public interface IPropertiesRequestorProvider {
+
+ /**
+ * Resource requestor to use.
+ *
+ * @return
+ */
+ IPropertiesRequestor getRequestor();
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/properties/IPropertiesSearchEngine.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/properties/IPropertiesSearchEngine.java
new file mode 100644
index 0000000..4ebdaa2
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/properties/IPropertiesSearchEngine.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.properties;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+
+/**
+ * Interface of Properties Search engine.
+ *
+ */
+public interface IPropertiesSearchEngine {
+
+ /**
+ * Search property which matches the given <code>matching</code> in files
+ * properties hosted in the list of the given <code>containers</code>.
+ *
+ * @param selectedNode
+ * the selected node which has started the search.
+ * @param containers
+ * list of {@link IResource} where property must be searched in
+ * files.
+ * @param requestor
+ * property requestor used to.
+ * @param collector
+ * @param matching
+ * @param fullMatch
+ * @param monitor
+ * @return
+ */
+ IStatus search(Object selectedNode, IResource[] containers,
+ IPropertiesRequestor requestor, IPropertiesCollector collector,
+ String matching, boolean fullMatch, IProgressMonitor monitor);
+
+ /**
+ *
+ * @param selectedNode
+ * @param container
+ * @param requestor
+ * @param collector
+ * @param matching
+ * @param fullMatch
+ * @param monitor
+ * @return
+ */
+ IStatus search(Object selectedNode, IResource container,
+ IPropertiesRequestor requestor, IPropertiesCollector collector,
+ String matching, boolean fullMatch, IProgressMonitor monitor);
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/properties/PropertiesQuerySpecificationManager.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/properties/PropertiesQuerySpecificationManager.java
new file mode 100644
index 0000000..1b805a5
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/properties/PropertiesQuerySpecificationManager.java
@@ -0,0 +1,126 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.properties;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionDelta;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.wst.xml.search.core.AbstractRegistryManager;
+import org.eclipse.wst.xml.search.core.internal.Trace;
+import org.eclipse.wst.xml.search.core.internal.XMLSearchCorePlugin;
+import org.eclipse.wst.xml.search.core.internal.properties.PropertiesQuerySpecification;
+import org.eclipse.wst.xml.search.core.util.StringUtils;
+
+/**
+ * Manager of {@link IPropertiesQuerySpecification} which are registered with
+ * extension point "propertiesQuerySpecifications".
+ *
+ */
+public class PropertiesQuerySpecificationManager extends
+ AbstractRegistryManager {
+
+ private static final PropertiesQuerySpecificationManager INSTANCE = new PropertiesQuerySpecificationManager();
+ private static final String RESOURCE_QUERY_SPECIFICATIONS_EXTENSION_POINT = "propertiesQuerySpecifications";
+ private Map<String, IPropertiesQuerySpecification> querySpecificationsById = null;
+
+ public static PropertiesQuerySpecificationManager getDefault() {
+ return INSTANCE;
+ }
+
+ @Override
+ protected void handleExtensionDelta(IExtensionDelta delta) {
+ if (querySpecificationsById == null) // not loaded yet
+ return;
+ if (delta.getKind() == IExtensionDelta.ADDED) {
+ IConfigurationElement[] cf = delta.getExtension()
+ .getConfigurationElements();
+ addQuerySpecifications(querySpecificationsById, cf);
+ } else {
+ // TODO : remove references
+ }
+ }
+
+ public IPropertiesQuerySpecification getQuerySpecification(
+ String querySpecificationId) {
+ if (StringUtils.isEmpty(querySpecificationId)) {
+ return PropertiesQuerySpecification.DEFAULT;
+ }
+ if (querySpecificationsById == null) {
+ loadQuerySpecifications();
+ }
+
+ IPropertiesQuerySpecification querySpecification = querySpecificationsById
+ .get(querySpecificationId);
+ if (querySpecification == null) {
+ querySpecification = PropertiesQuerySpecification.DEFAULT;
+ querySpecificationsById.put(querySpecificationId,
+ querySpecification);
+ }
+ return querySpecification;
+ }
+
+ private synchronized void loadQuerySpecifications() {
+ if (querySpecificationsById != null) {
+ return;
+ }
+
+ Map<String, IPropertiesQuerySpecification> querySpecificationsById = null;
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ if (registry != null) {
+ IConfigurationElement[] cf = registry.getConfigurationElementsFor(
+ XMLSearchCorePlugin.PLUGIN_ID,
+ RESOURCE_QUERY_SPECIFICATIONS_EXTENSION_POINT);
+ querySpecificationsById = new HashMap<String, IPropertiesQuerySpecification>(
+ cf.length);
+ addQuerySpecifications(querySpecificationsById, cf);
+ } else {
+ querySpecificationsById = new HashMap<String, IPropertiesQuerySpecification>();
+ }
+ this.querySpecificationsById = querySpecificationsById;
+ super.addRegistryListenerIfNeeded();
+
+ }
+
+ private synchronized void addQuerySpecifications(
+ Map<String, IPropertiesQuerySpecification> querySpecificationsById,
+ IConfigurationElement[] cf) {
+ String id = null;
+ IPropertiesQuerySpecification querySpecification = null;
+ for (IConfigurationElement ce : cf) {
+ // querySpecification declaration,
+ id = ce.getAttribute("id");
+ try {
+ querySpecification = PropertiesQuerySpecification
+ .newQuerySpecification(ce
+ .createExecutableExtension("class"));
+ querySpecificationsById.put(id, querySpecification);
+ } catch (Throwable t) {
+ Trace.trace(Trace.SEVERE,
+ " Could not load querySpecification for id: " + id, t);
+ }
+ }
+ }
+
+ @Override
+ protected String getPluginId() {
+ return XMLSearchCorePlugin.PLUGIN_ID;
+ }
+
+ @Override
+ protected String getExtensionPoint() {
+ return RESOURCE_QUERY_SPECIFICATIONS_EXTENSION_POINT;
+ }
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/properties/PropertiesSearchEngine.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/properties/PropertiesSearchEngine.java
new file mode 100644
index 0000000..b2648dd
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/properties/PropertiesSearchEngine.java
@@ -0,0 +1,142 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.properties;
+
+import java.io.IOException;
+import java.util.Map.Entry;
+import java.util.Properties;
+import java.util.Set;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.xml.search.core.internal.Trace;
+
+/**
+ * {@link IPropertiesSearchEngine} implementation.
+ *
+ */
+public class PropertiesSearchEngine implements IPropertiesSearchEngine {
+
+ private static final IPropertiesSearchEngine INSTANCE = new PropertiesSearchEngine();
+
+ public static IPropertiesSearchEngine getDefault() {
+ return INSTANCE;
+ }
+
+ public IStatus search(Object selectedNode, IResource[] containers,
+ IPropertiesRequestor requestor, IPropertiesCollector collector,
+ String matching, boolean fullMatch, IProgressMonitor monitor) {
+ for (int i = 0; i < containers.length; i++) {
+ IResource resource = containers[i];
+ internalSearch(selectedNode, resource, containers[i], requestor,
+ collector, matching, fullMatch, monitor);
+ }
+ return Status.OK_STATUS;
+ }
+
+ public IStatus search(Object selectedNode, IResource container,
+ IPropertiesRequestor requestor, IPropertiesCollector collector,
+ String matching, boolean fullMatch, IProgressMonitor monitor) {
+ internalSearch(selectedNode, container, container, requestor,
+ collector, matching, fullMatch, monitor);
+ return Status.OK_STATUS;
+ }
+
+ private void internalSearch(Object selectedNode, IResource rootContainer,
+ IResource container, IPropertiesRequestor requestor,
+ IPropertiesCollector collector, String matching, boolean fullMatch,
+ IProgressMonitor monitor) {
+ if (!requestor.accept(container, rootContainer))
+ return;
+ int resourceType = container.getType();
+ switch (resourceType) {
+ case IResource.FILE:
+ IFile file = (IFile) container;
+ processFile(file, collector, matching, fullMatch);
+ break;
+ case IResource.ROOT:
+ case IResource.PROJECT:
+ case IResource.FOLDER:
+ try {
+
+ // if (!fullMatch) {
+ // if (resolver
+ // .resolve(selectedNode, rootContainer, container)
+ // .toUpperCase().startsWith(matching.toUpperCase())) {
+ // collector.add(container, rootContainer, resolver);
+ // }
+ // } else {
+ // if (resolver
+ // .resolve(selectedNode, rootContainer, container)
+ // .equals(matching)) {
+ // collector.add(container, rootContainer, resolver);
+ // }
+ // }
+
+ internalSearch(selectedNode, rootContainer,
+ ((IContainer) container).members(), requestor,
+ collector, matching, fullMatch, monitor);
+ } catch (CoreException e) {
+ Trace.trace(Trace.SEVERE, e.getMessage(), e);
+ }
+ break;
+ }
+ }
+
+ private IStatus internalSearch(Object selectedNode,
+ IResource rootContainer, IResource[] containers,
+ IPropertiesRequestor requestor, IPropertiesCollector collector,
+ String matching, boolean fullMatch, IProgressMonitor monitor) {
+ for (int i = 0; i < containers.length; i++) {
+ internalSearch(selectedNode, rootContainer, containers[i],
+ requestor, collector, matching, fullMatch, monitor);
+ }
+ return Status.OK_STATUS;
+ }
+
+ private void processFile(IFile file, IPropertiesCollector collector,
+ String matching, boolean fullMatch) {
+ try {
+ Properties properties = new Properties();
+ properties.load(file.getContents());
+ if (fullMatch) {
+ if (properties.containsKey(matching)) {
+ String value = properties.getProperty(matching);
+ collector.add(file, matching, value);
+ }
+ } else {
+ String matchingUpperCased = matching.toUpperCase();
+ String key = null;
+ String value = null;
+ Set<Entry<Object, Object>> entries = properties.entrySet();
+ for (Entry<Object, Object> entry : entries) {
+ key = (String) entry.getKey();
+ value = (String) entry.getValue();
+ if (key.toUpperCase().startsWith(matchingUpperCased)) {
+ collector.add(file, key, value);
+ }
+ }
+ }
+
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/IExecutableXMLQuerySpecification.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/IExecutableXMLQuerySpecification.java
new file mode 100644
index 0000000..bd63e6b
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/IExecutableXMLQuerySpecification.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.queryspecifications;
+
+import org.eclipse.wst.xml.search.core.namespaces.Namespaces;
+
+/**
+ * Executable XML query specification is {@link IXMLQuerySpecification} which
+ * can be executed.
+ *
+ */
+public interface IExecutableXMLQuerySpecification extends
+ IXMLQuerySpecification {
+
+ /**
+ * Returns the query (XPath...) to execute.
+ *
+ * @return
+ */
+ String getQuery();
+
+ /**
+ * Returns information about namespaces which must be used when XPath is
+ * executed.
+ *
+ * @return
+ */
+ Namespaces getNamespaces();
+
+ /**
+ * Returns the selected node which has started the search.
+ *
+ * @return
+ */
+ Object getSelectedNode();
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/IStringQueryProvider.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/IStringQueryProvider.java
new file mode 100644
index 0000000..30d883b
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/IStringQueryProvider.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.queryspecifications;
+
+import org.eclipse.wst.xml.search.core.queryspecifications.querybuilder.IStringQueryBuilder;
+import org.w3c.dom.Node;
+
+/**
+ * Query provider.
+ */
+public interface IStringQueryProvider {
+
+ /**
+ * Returns the XPath query to execute for the given node and given string
+ * query builder..
+ *
+ * @param node
+ * @param builder
+ * @return
+ */
+ String getQuery(Node node, IStringQueryBuilder builder);
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/IXMLQuerySpecification.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/IXMLQuerySpecification.java
new file mode 100644
index 0000000..9ffd3b3
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/IXMLQuerySpecification.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.queryspecifications;
+
+import org.eclipse.wst.xml.search.core.queryspecifications.container.IMultiResourceProvider;
+import org.eclipse.wst.xml.search.core.queryspecifications.container.IMultiStorageProvider;
+import org.eclipse.wst.xml.search.core.queryspecifications.container.IResourceProvider;
+import org.eclipse.wst.xml.search.core.queryspecifications.container.IStorageProvider;
+import org.eclipse.wst.xml.search.core.queryspecifications.querybuilder.IStringQueryBuilderProvider;
+import org.eclipse.wst.xml.search.core.queryspecifications.requestor.IXMLSearchRequestorProvider;
+import org.eclipse.wst.xml.search.core.queryspecifications.visitor.IXMLSearchVisitorProvider;
+
+/**
+ * XML Query specification contains the all informations to execute search DOM Nodes from
+ * DOM Document coming from workspace or JAR.
+ *
+ */
+public interface IXMLQuerySpecification extends IResourceProvider,
+ IMultiResourceProvider, IXMLSearchRequestorProvider,
+ IXMLSearchVisitorProvider, IStringQueryBuilderProvider,
+ IXPathProcessorIdProvider, IStorageProvider, IMultiStorageProvider {
+
+ /**
+ * Returns true if DOM Document to search is done with multiple resources
+ * (several IFile, IContainer....) and false otherwise (one IFile, one
+ * IContainer...).
+ *
+ * @return
+ */
+ boolean isMultiResource();
+
+ /**
+ * Returns true if DOM Document to search is done with a simple storage (XML
+ * file coming from JAR) and false otherwise.
+ *
+ * @return
+ */
+ boolean isSimpleStorage();
+
+ /**
+ * Returns true if DOM Document to search is done with several storages (XML
+ * files coming from JAR) and false otherwise.
+ *
+ * @return
+ */
+ boolean isMultiStorage();
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/IXMLQuerySpecificationRegistry.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/IXMLQuerySpecificationRegistry.java
new file mode 100644
index 0000000..e0632fc
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/IXMLQuerySpecificationRegistry.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.queryspecifications;
+
+import java.util.Collection;
+import java.util.Map;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.wst.xml.search.core.namespaces.Namespaces;
+
+/**
+ * Registry of query {@link IExecutableXMLQuerySpecification} to execute.
+ *
+ */
+public interface IXMLQuerySpecificationRegistry {
+
+ void register(IXMLQuerySpecification querySpecification, String query,
+ Namespaces namespaceInfos);
+
+ void register(IXMLQuerySpecification xmlQuerySpecification, String query,
+ IResource container, Namespaces namespaceInfos);
+
+ Map<IResource, Collection<IExecutableXMLQuerySpecification>> getQuerySpecificationsMap();
+
+ Object getSelectedNode();
+
+ Collection<String> getQueries();
+
+ String getQueriesLabel();
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/IXPathProcessorIdProvider.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/IXPathProcessorIdProvider.java
new file mode 100644
index 0000000..d7c61cf
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/IXPathProcessorIdProvider.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.queryspecifications;
+
+/**
+ * XPath processor identifiant.
+ *
+ */
+public interface IXPathProcessorIdProvider {
+
+ String getXPathProcessorId();
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/XMLQuerySpecificationManager.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/XMLQuerySpecificationManager.java
new file mode 100644
index 0000000..39ff1ad
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/XMLQuerySpecificationManager.java
@@ -0,0 +1,126 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.queryspecifications;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionDelta;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.wst.xml.search.core.AbstractRegistryManager;
+import org.eclipse.wst.xml.search.core.internal.Trace;
+import org.eclipse.wst.xml.search.core.internal.XMLSearchCorePlugin;
+import org.eclipse.wst.xml.search.core.internal.queryspecifications.XMLQuerySpecification;
+import org.eclipse.wst.xml.search.core.util.StringUtils;
+
+/**
+ * Manager of {@link IXMLQuerySpecification} which are registered with extension
+ * point "querySpecifications".
+ *
+ */
+public class XMLQuerySpecificationManager extends AbstractRegistryManager {
+
+ private static final XMLQuerySpecificationManager INSTANCE = new XMLQuerySpecificationManager();
+ private static final String XML_QUERY_SPECIFICATIONS_EXTENSION_POINT = "querySpecifications";
+
+ private Map<String, IXMLQuerySpecification> querySpecificationsById = null;
+
+ public static XMLQuerySpecificationManager getDefault() {
+ return INSTANCE;
+ }
+
+ @Override
+ protected void handleExtensionDelta(IExtensionDelta delta) {
+ if (querySpecificationsById == null) // not loaded yet
+ return;
+ if (delta.getKind() == IExtensionDelta.ADDED) {
+ IConfigurationElement[] cf = delta.getExtension()
+ .getConfigurationElements();
+ addQuerySpecifications(querySpecificationsById, cf);
+ } else {
+ // TODO : remove references
+ }
+ }
+
+ public IXMLQuerySpecification getQuerySpecification(
+ String querySpecificationId) {
+ if (StringUtils.isEmpty(querySpecificationId)) {
+ return XMLQuerySpecification.INSTANCE;
+ }
+ if (querySpecificationsById == null) {
+ loadQuerySpecifications();
+ }
+
+ IXMLQuerySpecification querySpecification = querySpecificationsById
+ .get(querySpecificationId);
+ if (querySpecification == null) {
+ querySpecification = XMLQuerySpecification.INSTANCE;
+ querySpecificationsById.put(querySpecificationId,
+ querySpecification);
+ }
+ return querySpecification;
+ }
+
+ private synchronized void loadQuerySpecifications() {
+ if (querySpecificationsById != null) {
+ return;
+ }
+
+ Map<String, IXMLQuerySpecification> querySpecificationsById = null;
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ if (registry != null) {
+ IConfigurationElement[] cf = registry.getConfigurationElementsFor(
+ XMLSearchCorePlugin.PLUGIN_ID,
+ XML_QUERY_SPECIFICATIONS_EXTENSION_POINT);
+ querySpecificationsById = new HashMap<String, IXMLQuerySpecification>(
+ cf.length);
+ addQuerySpecifications(querySpecificationsById, cf);
+ } else {
+ querySpecificationsById = new HashMap<String, IXMLQuerySpecification>();
+ }
+ this.querySpecificationsById = querySpecificationsById;
+ super.addRegistryListenerIfNeeded();
+
+ }
+
+ private synchronized void addQuerySpecifications(
+ Map<String, IXMLQuerySpecification> querySpecificationsById,
+ IConfigurationElement[] cf) {
+ String id = null;
+ IXMLQuerySpecification querySpecification = null;
+ for (IConfigurationElement ce : cf) {
+ // querySpecification declaration,
+ id = ce.getAttribute("id");
+ try {
+ querySpecification = XMLQuerySpecification
+ .newQuerySpecification(ce
+ .createExecutableExtension("class"));
+ querySpecificationsById.put(id, querySpecification);
+ } catch (Throwable t) {
+ Trace.trace(Trace.SEVERE,
+ " Could not load querySpecification for id: " + id, t);
+ }
+ }
+ }
+
+ @Override
+ protected String getPluginId() {
+ return XMLSearchCorePlugin.PLUGIN_ID;
+ }
+
+ @Override
+ protected String getExtensionPoint() {
+ return XML_QUERY_SPECIFICATIONS_EXTENSION_POINT;
+ }
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/XMLQuerySpecificationRegistry.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/XMLQuerySpecificationRegistry.java
new file mode 100644
index 0000000..23c02bc
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/XMLQuerySpecificationRegistry.java
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.queryspecifications;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.wst.xml.search.core.internal.queryspecifications.ExecutableXMLQuerySpecification;
+import org.eclipse.wst.xml.search.core.namespaces.Namespaces;
+
+/**
+ * Registry of query {@link IExecutableXMLQuerySpecification} to execute.
+ *
+ */
+public class XMLQuerySpecificationRegistry implements
+ IXMLQuerySpecificationRegistry {
+
+ private final Map<IResource, Collection<IExecutableXMLQuerySpecification>> querySpecificationsMap;
+ private final Collection<String> queries;
+ private final IContainer container;
+ private final IFile file;
+ private final Object selectedNode;
+
+ public XMLQuerySpecificationRegistry(IResource resource, Object selectedNode) {
+ if (resource.getType() == IResource.FILE) {
+ this.file = (IFile) resource;
+ this.container = null;
+ } else {
+ this.file = null;
+ this.container = (IContainer) resource;
+ }
+ this.selectedNode = selectedNode;
+ this.querySpecificationsMap = new HashMap<IResource, Collection<IExecutableXMLQuerySpecification>>();
+ this.queries = new ArrayList<String>();
+ }
+
+ public void register(IXMLQuerySpecification querySpecification,
+ String query, Namespaces namespaceInfos) {
+ if (querySpecification.isMultiResource() && file != null) {
+ IResource[] containers = querySpecification.getResources(
+ selectedNode, file);
+ for (IResource container : containers) {
+ register(querySpecification, query, container, namespaceInfos);
+ }
+ } else {
+ IResource container = (file != null ? querySpecification
+ .getResource(selectedNode, file) : this.container);
+ if (container == null)
+ return;
+ register(querySpecification, query, container, namespaceInfos);
+ }
+ }
+
+ public void register(IXMLQuerySpecification querySpecification,
+ String query, IResource container, Namespaces namespaceInfos) {
+ Collection<IExecutableXMLQuerySpecification> querySpecifications = querySpecificationsMap
+ .get(container);
+ if (querySpecifications == null) {
+ querySpecifications = new ArrayList<IExecutableXMLQuerySpecification>();
+ querySpecificationsMap.put(container, querySpecifications);
+ }
+ if (!hasQuery(querySpecifications, query)) {
+ queries.add(query);
+ querySpecifications.add(new ExecutableXMLQuerySpecification(this,
+ querySpecification, query, namespaceInfos));
+ }
+ }
+
+ private boolean hasQuery(
+ Collection<IExecutableXMLQuerySpecification> querySpecifications,
+ String query) {
+ for (IExecutableXMLQuerySpecification querySpecification : querySpecifications) {
+ if (querySpecification.getQuery().equals(query))
+ return true;
+ }
+ return false;
+ }
+
+ public Map<IResource, Collection<IExecutableXMLQuerySpecification>> getQuerySpecificationsMap() {
+ return querySpecificationsMap;
+ }
+
+ public Object getSelectedNode() {
+ return selectedNode;
+ }
+
+ public Collection<String> getQueries() {
+ return queries;
+ }
+
+ public String getQueriesLabel() {
+ Collection<String> cache = new ArrayList<String>();
+ StringBuilder label = new StringBuilder();
+ int i = 0;
+ for (String query : queries) {
+ if (!cache.contains(query)) {
+ if (i > 0) {
+ label.append(", ");
+ }
+ label.append(query);
+ i++;
+ cache.add(query);
+ }
+ }
+ return label.toString();
+ }
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/container/FolderContainerProvider.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/container/FolderContainerProvider.java
new file mode 100644
index 0000000..19d655f
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/container/FolderContainerProvider.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.queryspecifications.container;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+
+/**
+ * Provider to returns the {@link IContainer} of the file of the selected Node
+ * which launch the search.
+ */
+public class FolderContainerProvider implements IResourceProvider {
+
+ public static IResourceProvider INSTANCE = new FolderContainerProvider();
+
+ /**
+ * Returns the {@link IContainer} of the file of the selected Node which
+ * launch the search.
+ *
+ * @param selectedNode
+ * the selected node which have launch the search.
+ * @param resource
+ * the owner resource file of the selected node.
+ */
+ public IResource getResource(Object selectedNode, IResource resource) {
+ if (resource.getType() == IResource.PROJECT) {
+ return (IProject) resource;
+ }
+ if (resource.getType() == IResource.ROOT) {
+ return (IWorkspaceRoot) resource;
+ }
+ return resource.getParent();
+ }
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/container/IMultiResourceProvider.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/container/IMultiResourceProvider.java
new file mode 100644
index 0000000..fe2760a
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/container/IMultiResourceProvider.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.queryspecifications.container;
+
+import org.eclipse.core.resources.IResource;
+
+/**
+ *
+ * Provider to get several {@link IResource} (IFile, IContainer....) used to
+ * search DOM Document to use to search DOM Nodes.
+ *
+ * <ul>
+ * <li>when {@link IResource} returned is IFile, it use DOM Document loaded from
+ * the IFile.</li>
+ * <li>when {@link IResource} returned is IContainer, it loops for each IFile
+ * and IContainer and load several DOM Document where search Nodes must be done.
+ * </li>
+ * </ul>
+ */
+public interface IMultiResourceProvider {
+
+ public static final IResource[] EMPTY_RESOURCE = new IResource[0];
+
+ /**
+ * Returns array of {@link IResource} (IFile, IContainer....) used to search
+ * DOM Document to use to search DOM Nodes. If null is returned, search is
+ * stopped.
+ *
+ * <ul>
+ * <li>when {@link IResource} returned is IFile, it use DOM Document loaded
+ * from the IFile.</li>
+ * <li>when {@link IResource} returned is IContainer, it loops for each
+ * IFile and IContainer and load several DOM Document where search Nodes
+ * must be done.</li>
+ *
+ * @param selectedNode
+ * the selected node which have launch the search.
+ * @param resource
+ * the owner resource file of the selected node.
+ * @return
+ */
+ IResource[] getResources(Object selectedNode, IResource resource);
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/container/IMultiStorageProvider.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/container/IMultiStorageProvider.java
new file mode 100644
index 0000000..ab6f2e8
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/container/IMultiStorageProvider.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.queryspecifications.container;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IStorage;
+
+/**
+ *
+ * Provider to get several {@link IStorage} (files coming from JAR....) used to
+ * search DOM Document to use to search DOM Nodes.
+ *
+ */
+public interface IMultiStorageProvider {
+
+ public static final IStorage[] EMPTY_STORAGE = new IStorage[0];
+
+ /**
+ * Returns array of {@link IStorage} (files coming from JAR....) used to
+ * search DOM Document to use to search DOM Nodes. If null is returned,
+ * search is stopped.
+ *
+ * @param selectedNode
+ * the selected node which have launch the search.
+ * @param resource
+ * the owner resource file of the selected node.
+ * @return
+ */
+ IStorage[] getStorages(Object selectedNode, IResource resource);
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/container/IResourceProvider.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/container/IResourceProvider.java
new file mode 100644
index 0000000..11183d8
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/container/IResourceProvider.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.queryspecifications.container;
+
+import org.eclipse.core.resources.IResource;
+
+/**
+ *
+ * Provider to get one {@link IResource} (IFile, IContainer....) used to search
+ * DOM Document to use to search DOM Nodes.
+ *
+ * <ul>
+ * <li>when {@link IResource} returned is IFile, it use DOM Document loaded from
+ * the IFile.</li>
+ * <li>when {@link IResource} returned is IContainer, it loops for each IFile
+ * and IContainer and load several DOM Document where search Nodes must be done.
+ * </li>
+ * </ul>
+ */
+public interface IResourceProvider {
+
+ /**
+ * Returns {@link IResource} (IFile, IContainer....) used to search DOM
+ * Document to use to search DOM Nodes. If null is returned, search is
+ * stopped.
+ *
+ * <ul>
+ * <li>when {@link IResource} returned is IFile, it use DOM Document loaded
+ * from the IFile.</li>
+ * <li>when {@link IResource} returned is IContainer, it loops for each
+ * IFile and IContainer and load several DOM Document where search Nodes
+ * must be done.</li>
+ *
+ * @param selectedNode
+ * the selected node which have launch the search.
+ * @param resource
+ * the owner resource file of the selected node.
+ * @return
+ */
+ IResource getResource(Object selectedNode, IResource resource);
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/container/IStorageProvider.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/container/IStorageProvider.java
new file mode 100644
index 0000000..f4817b8
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/container/IStorageProvider.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.queryspecifications.container;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IStorage;
+
+/**
+ *
+ * Provider to get one {@link IStorage} (file coming from JAR....) used to
+ * search DOM Document to use to search DOM Nodes.
+ *
+ */
+public interface IStorageProvider {
+
+ /**
+ * Returns @link IStorage} (file coming from JAR....) used to search DOM
+ * Document to use to search DOM Nodes. If null is returned, search is
+ * stopped.
+ *
+ * @param selectedNode
+ * the selected node which have launch the search.
+ * @param resource
+ * the owner resource file of the selected node.
+ * @return
+ */
+ IStorage getStorage(Object selectedNode, IResource resource);
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/container/IdentityResourceProvider.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/container/IdentityResourceProvider.java
new file mode 100644
index 0000000..a9559c1
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/container/IdentityResourceProvider.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.queryspecifications.container;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+
+/**
+ * Provider to get the same resource than the selected Node which launch the
+ * search.
+ *
+ */
+public class IdentityResourceProvider implements IResourceProvider {
+
+ public static final IResourceProvider INSTANCE = new IdentityResourceProvider();
+
+ /**
+ * Returns the same resource than the selected Node which launch the search.
+ *
+ * @param selectedNode
+ * the selected node which have launch the search.
+ *
+ * @param resource
+ * the owner resource file of the selected node.
+ */
+ public IResource getResource(Object selectedNode, IResource resource) {
+ return resource;
+ }
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/container/ProjectContainerProvider.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/container/ProjectContainerProvider.java
new file mode 100644
index 0000000..976e502
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/container/ProjectContainerProvider.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.queryspecifications.container;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+
+/**
+ * Provider to returns the {@link IProject} of the file of the selected Node
+ * which launch the search.
+ */
+public class ProjectContainerProvider implements IResourceProvider {
+
+ public static final IResourceProvider INSTANCE = new ProjectContainerProvider();
+
+ /**
+ * Returns the {@link IProject} of the file of the selected Node which
+ * launch the search.
+ *
+ * @param selectedNode
+ * the selected node which have launch the search.
+ * @param resource
+ * the owner resource file of the selected node.
+ */
+ public IResource getResource(Object selectedNode, IResource resource) {
+ return resource.getProject();
+ }
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/container/WorkspaceContainerProvider.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/container/WorkspaceContainerProvider.java
new file mode 100644
index 0000000..d236f01
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/container/WorkspaceContainerProvider.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.queryspecifications.container;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+
+/**
+ * Provider to returns the workspace root.
+ */
+public class WorkspaceContainerProvider implements IResourceProvider {
+
+ public static final IResourceProvider INSTANCE = new WorkspaceContainerProvider();
+
+ /**
+ * Returns the workspace roor.
+ *
+ * @param selectedNode
+ * the selected node which have launch the search.
+ * @param resource
+ * the owner resource file of the selected node.
+ */
+ public IResource getResource(Object selectedNode, IResource resource) {
+ return ResourcesPlugin.getWorkspace().getRoot();
+ }
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/querybuilder/AbstractStringQueryBuilder.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/querybuilder/AbstractStringQueryBuilder.java
new file mode 100644
index 0000000..4cb906d
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/querybuilder/AbstractStringQueryBuilder.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.queryspecifications.querybuilder;
+
+import org.eclipse.wst.xml.search.core.util.DOMUtils;
+import org.eclipse.wst.xml.search.core.util.StringUtils;
+import org.w3c.dom.Node;
+
+/**
+ * Abstract class for {@link IStringQueryBuilder}.
+ *
+ */
+public abstract class AbstractStringQueryBuilder implements IStringQueryBuilder {
+
+ private static final String NORMALIZE_SPACE_TEXT = "normalize-space(text())";
+ private static final String TEXT_TARGETNODE = "text()";
+
+ public String getNodeValue(Node node) {
+ return DOMUtils.getNodeValue(node);
+ }
+
+ public String build(String baseQuery, String[] targetNodes,
+ Object selectedNode) {
+ return build(baseQuery, targetNodes, 0, selectedNode);
+ }
+
+ public String build(String baseQuery, String[] targetNodes, int startIndex,
+ Object selectedNode) {
+ if (targetNodes == null) {
+ targetNodes = StringUtils.EMPTY_ARRAY;
+ }
+ baseQuery = baseQuery.replaceAll("'", "''");
+ StringBuilder xpath = new StringBuilder(baseQuery);
+ if (baseQuery.endsWith("//")) {
+ xpath.append("*");
+ }
+ build(xpath, targetNodes, startIndex, selectedNode);
+ if (targetNodes.length > 0 && addLastTargetNodeAtEnds()) {
+ xpath.append("/");
+ xpath.append(targetNodes[targetNodes.length - 1]);
+ }
+ return xpath.toString();
+ }
+
+ protected String getTargetNode(String targetNode) {
+ if (TEXT_TARGETNODE.equals(targetNode)) {
+ targetNode = NORMALIZE_SPACE_TEXT;
+ }
+ return targetNode;
+ }
+
+ protected boolean addLastTargetNodeAtEnds() {
+ return true;
+ }
+
+ protected abstract void build(StringBuilder xpath, String[] targetNodes,
+ int startIndex, Object selectedNode);
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/querybuilder/ContainsStringQueryBuilder.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/querybuilder/ContainsStringQueryBuilder.java
new file mode 100644
index 0000000..8b9a314
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/querybuilder/ContainsStringQueryBuilder.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.queryspecifications.querybuilder;
+
+import org.w3c.dom.Node;
+
+/**
+ * String query builder to use fn:contains() XPath function.
+ *
+ */
+public class ContainsStringQueryBuilder extends AbstractStringQueryBuilder {
+
+ public static IStringQueryBuilder INSTANCE = new ContainsStringQueryBuilder();
+
+ protected ContainsStringQueryBuilder() {
+
+ }
+
+ public String getId() {
+ return ContainsStringQueryBuilder.class.getSimpleName();
+ }
+
+ @Override
+ protected void build(StringBuilder xpath, String[] targetNodes,
+ int startIndex, Object selectedNode) {
+ String attrName = null;
+ for (int i = 0; i < targetNodes.length; i++) {
+ attrName = targetNodes[i];
+ // Attribute exists
+ xpath.append("[");
+ xpath.append(attrName);
+ xpath.append(" and ");
+ // starts-with
+ xpath.append("contains(");
+ xpath.append(getTargetNode(attrName));
+ xpath.append(",\"{");
+ xpath.append(i + startIndex);
+ xpath.append("}\")");
+ xpath.append("]");
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/querybuilder/ContainsStringQueryBuilderProvider.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/querybuilder/ContainsStringQueryBuilderProvider.java
new file mode 100644
index 0000000..5b43aa1
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/querybuilder/ContainsStringQueryBuilderProvider.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.queryspecifications.querybuilder;
+
+/**
+ * Provider of {@link ContainsStringQueryBuilder}.
+ *
+ */
+public class ContainsStringQueryBuilderProvider implements
+ IStringQueryBuilderProvider {
+
+ public static final IStringQueryBuilderProvider INSTANCE = new ContainsStringQueryBuilderProvider();
+
+ public IStringQueryBuilder getEqualsStringQueryBuilder() {
+ return ContainsStringQueryBuilder.INSTANCE;
+ }
+
+ public IStringQueryBuilder getStartsWithStringQueryBuilder() {
+ return StartsWithStringQueryBuilder.INSTANCE;
+ }
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/querybuilder/DefaultStringQueryBuilderProvider.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/querybuilder/DefaultStringQueryBuilderProvider.java
new file mode 100644
index 0000000..bb21493
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/querybuilder/DefaultStringQueryBuilderProvider.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.queryspecifications.querybuilder;
+
+/**
+ * Default string query builder provider.
+ *
+ */
+public class DefaultStringQueryBuilderProvider implements
+ IStringQueryBuilderProvider {
+
+ public static final IStringQueryBuilderProvider INSTANCE = new DefaultStringQueryBuilderProvider();
+
+ public IStringQueryBuilder getEqualsStringQueryBuilder() {
+ return EqualsStringQueryBuilder.INSTANCE;
+ }
+
+ public IStringQueryBuilder getStartsWithStringQueryBuilder() {
+ return StartsWithStringQueryBuilder.INSTANCE;
+ }
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/querybuilder/EqualsStringQueryBuilder.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/querybuilder/EqualsStringQueryBuilder.java
new file mode 100644
index 0000000..e62d3df
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/querybuilder/EqualsStringQueryBuilder.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.queryspecifications.querybuilder;
+
+import org.w3c.dom.Node;
+
+/**
+ * String query builder to use = XPath function.
+ *
+ */
+public class EqualsStringQueryBuilder extends AbstractStringQueryBuilder {
+
+ public static IStringQueryBuilder INSTANCE = new EqualsStringQueryBuilder();
+
+ protected EqualsStringQueryBuilder() {
+
+ }
+
+ public String getId() {
+ return EqualsStringQueryBuilder.class.getSimpleName();
+ }
+
+ @Override
+ protected void build(StringBuilder xpath, String[] targetNodes,
+ int startIndex, Object selectedNode) {
+ String targetNode = null;
+ for (int i = 0; i < targetNodes.length; i++) {
+ targetNode = targetNodes[i];
+ targetNode = getTargetNode(targetNode);
+ xpath.append("[");
+ xpath.append(targetNode);
+ xpath.append("=\"{");
+ xpath.append(i + startIndex);
+ xpath.append("}\"]");
+ }
+ }
+
+ @Override
+ protected boolean addLastTargetNodeAtEnds() {
+ return true;
+ }
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/querybuilder/IStringQueryBuilder.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/querybuilder/IStringQueryBuilder.java
new file mode 100644
index 0000000..89046bb
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/querybuilder/IStringQueryBuilder.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.queryspecifications.querybuilder;
+
+
+public interface IStringQueryBuilder {
+
+ String getId();
+
+ String build(String baseQuery, String[] targetNodes, Object selectedNode);
+
+ String build(String baseQuery, String[] targetNodes, int startIndex,
+ Object selectedNode);
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/querybuilder/IStringQueryBuilderProvider.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/querybuilder/IStringQueryBuilderProvider.java
new file mode 100644
index 0000000..76b6307
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/querybuilder/IStringQueryBuilderProvider.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.queryspecifications.querybuilder;
+
+public interface IStringQueryBuilderProvider {
+
+ IStringQueryBuilder getEqualsStringQueryBuilder();
+
+ IStringQueryBuilder getStartsWithStringQueryBuilder();
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/querybuilder/StartsWithStringQueryBuilder.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/querybuilder/StartsWithStringQueryBuilder.java
new file mode 100644
index 0000000..32aff6d
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/querybuilder/StartsWithStringQueryBuilder.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.queryspecifications.querybuilder;
+
+import org.w3c.dom.Node;
+
+/**
+ * String query builder to use fn:starts-with() XPath function.
+ *
+ */
+public class StartsWithStringQueryBuilder extends AbstractStringQueryBuilder {
+
+ public static IStringQueryBuilder INSTANCE = new StartsWithStringQueryBuilder();
+
+ protected StartsWithStringQueryBuilder() {
+
+ }
+
+ public String getId() {
+ return StartsWithStringQueryBuilder.class.getSimpleName();
+ }
+
+ @Override
+ protected void build(StringBuilder xpath, String[] targetNodes,
+ int startIndex, Object selectedNode) {
+ String attrName = null;
+ for (int i = 0; i < targetNodes.length; i++) {
+ attrName = targetNodes[i];
+ // Attribute exists
+ xpath.append("[");
+ xpath.append(attrName);
+ xpath.append(" and ");
+ // starts-with
+ xpath.append("starts-with(");
+ xpath.append(getTargetNode(attrName));
+ xpath.append(",\"{");
+ xpath.append(i + startIndex);
+ xpath.append("}\")");
+ xpath.append("]");
+ }
+ }
+
+
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/requestor/AbstractXMLSearchRequestor.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/requestor/AbstractXMLSearchRequestor.java
new file mode 100644
index 0000000..dc1ac8d
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/requestor/AbstractXMLSearchRequestor.java
@@ -0,0 +1,50 @@
+package org.eclipse.wst.xml.search.core.queryspecifications.requestor;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+
+public abstract class AbstractXMLSearchRequestor implements IXMLSearchRequestor {
+
+ protected static final String DOT_FOLDER = ".";
+
+ public boolean accept(IResource resource, IResource rootResource) {
+ int resourceType = resource.getType();
+ switch (resourceType) {
+ case IResource.ROOT:
+ return accept((IWorkspaceRoot) resource, rootResource);
+ case IResource.PROJECT:
+ return accept((IProject) resource, rootResource);
+ case IResource.FOLDER:
+ return accept((IFolder) resource, rootResource);
+ case IResource.FILE:
+ return accept((IFile) resource, rootResource);
+ }
+ return false;
+ }
+
+ public boolean accept(IWorkspaceRoot workspaceRoot, IResource rootResource) {
+ return true;
+ }
+
+ public boolean accept(IProject project, IResource rootResource) {
+ if (project.isOpen()) {
+ return true;
+ }
+ return false;
+ }
+
+ public boolean accept(IFolder folder, IResource rootResource) {
+ // ignore .svn folder....
+ return !folder.getName().startsWith(DOT_FOLDER);
+ }
+
+ public boolean accept(IStructuredModel model) {
+ return true;
+ }
+
+ protected abstract boolean accept(IFile file, IResource rootResource);
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/requestor/AllFilesXMLSearchRequestor.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/requestor/AllFilesXMLSearchRequestor.java
new file mode 100644
index 0000000..17464fe
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/requestor/AllFilesXMLSearchRequestor.java
@@ -0,0 +1,15 @@
+package org.eclipse.wst.xml.search.core.queryspecifications.requestor;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+
+public class AllFilesXMLSearchRequestor extends AbstractXMLSearchRequestor {
+
+ public static final IXMLSearchRequestor INSTANCE = new AllFilesXMLSearchRequestor();
+
+ @Override
+ public boolean accept(IFile file, IResource rootResource) {
+ return true;
+ }
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/requestor/AllXMLExtensionFilesXMLSearchRequestor.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/requestor/AllXMLExtensionFilesXMLSearchRequestor.java
new file mode 100644
index 0000000..df64718
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/requestor/AllXMLExtensionFilesXMLSearchRequestor.java
@@ -0,0 +1,16 @@
+package org.eclipse.wst.xml.search.core.queryspecifications.requestor;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+
+public class AllXMLExtensionFilesXMLSearchRequestor extends AbstractXMLSearchRequestor {
+
+ public static final IXMLSearchRequestor INSTANCE = new AllXMLExtensionFilesXMLSearchRequestor();
+ private static final String XML_EXT = "xml";
+
+ @Override
+ public boolean accept(IFile file, IResource rootResource) {
+ return XML_EXT.equals(file.getFileExtension());
+ }
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/requestor/ContentTypeXMLSearchRequestor.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/requestor/ContentTypeXMLSearchRequestor.java
new file mode 100644
index 0000000..2a17369
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/requestor/ContentTypeXMLSearchRequestor.java
@@ -0,0 +1,44 @@
+package org.eclipse.wst.xml.search.core.queryspecifications.requestor;
+
+import java.util.Collection;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+
+public abstract class ContentTypeXMLSearchRequestor extends
+ AbstractXMLSearchRequestor {
+
+ private Collection<String> supportedContentTypeIds;
+
+ public boolean accept(IFile file, IResource rootResource) {
+ for (String id : internalGetSupportedContentTypeIds()) {
+ IContentType contentType = Platform.getContentTypeManager()
+ .getContentType(id);
+ if (contentType != null) {
+ if (contentType.isAssociatedWith(file.getName())) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ public boolean accept(IStructuredModel model) {
+ String contentTypeIdentifier = model.getContentTypeIdentifier();
+ return internalGetSupportedContentTypeIds().contains(
+ contentTypeIdentifier);
+ }
+
+ private Collection<String> internalGetSupportedContentTypeIds() {
+ if (supportedContentTypeIds == null) {
+ supportedContentTypeIds = getSupportedContentTypeIds();
+ }
+ return supportedContentTypeIds;
+ }
+
+ protected abstract Collection<String> getSupportedContentTypeIds();
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/requestor/IXMLSearchRequestor.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/requestor/IXMLSearchRequestor.java
new file mode 100644
index 0000000..c4ca7c3
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/requestor/IXMLSearchRequestor.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.queryspecifications.requestor;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+
+/**
+ * XML search requestor interface used to filter XML files and folder when
+ * search is done.
+ *
+ */
+public interface IXMLSearchRequestor {
+
+ /**
+ * Returns true if resource (file, folder, project) must be accepted while
+ * searching and false otherwise. When file is accepted, DOM document from
+ * the file is loaded and
+ * {@link IXMLSearchRequestor#accept(IStructuredModel)} is called to know if
+ * DOM Document is visited to collect Node.
+ *
+ * @param resource
+ * the resource to accept
+ * @param resource
+ * the root resource where search start.
+ * @return
+ */
+ boolean accept(IResource resource, IResource rootResource);
+
+ /**
+ * Returns true if DOM Document (file, folder, project) must be accepted
+ * while searching and false otherwise. When DOM Document is accepted, it is
+ * visited to collect Node.
+ *
+ * @param model
+ * the SSE Model to accept
+ * @return
+ */
+ boolean accept(IStructuredModel model);
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/requestor/IXMLSearchRequestorProvider.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/requestor/IXMLSearchRequestorProvider.java
new file mode 100644
index 0000000..92e6b4c
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/requestor/IXMLSearchRequestorProvider.java
@@ -0,0 +1,7 @@
+package org.eclipse.wst.xml.search.core.queryspecifications.requestor;
+
+
+public interface IXMLSearchRequestorProvider {
+
+ IXMLSearchRequestor getRequestor();
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/visitor/AbstractXMLSearchVisitor.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/visitor/AbstractXMLSearchVisitor.java
new file mode 100644
index 0000000..95bc383
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/visitor/AbstractXMLSearchVisitor.java
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.queryspecifications.visitor;
+
+/**
+ * Abstract class for {@link IXMLSearchDOMDocumentVisitor}.
+ */
+public abstract class AbstractXMLSearchVisitor implements
+ IXMLSearchDOMDocumentVisitor {
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/visitor/IXMLSearchDOMDocumentVisitor.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/visitor/IXMLSearchDOMDocumentVisitor.java
new file mode 100644
index 0000000..365ccca
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/visitor/IXMLSearchDOMDocumentVisitor.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.queryspecifications.visitor;
+
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
+import org.eclipse.wst.xml.search.core.IXMLSearchDOMNodeCollector;
+import org.eclipse.wst.xml.search.core.XMLSearchEngineException;
+import org.eclipse.wst.xml.search.core.xpath.NamespaceInfos;
+
+/**
+ * XML search visitor to visit a DOM document and collect DOM Node which follow
+ * the query.
+ *
+ */
+public interface IXMLSearchDOMDocumentVisitor {
+
+ /**
+ * Visit the DOM document and collect DOM Node which follow the query XPath.
+ *
+ * @param document
+ * the DOM document to visit.
+ * @param query
+ * the query (ex : XPath) to use to retrieve DOM Node to collect.
+ * @param xpathProcessorId
+ * the XPath processor id to use to execute XPath.
+ * @param collector
+ * the collector used to collect DOM Node.
+ */
+ void visit(IDOMDocument document, String query, String xpathProcessorId,
+ IXMLSearchDOMNodeCollector collector, Object selectedNode)
+ throws XMLSearchEngineException;
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/visitor/IXMLSearchVisitorProvider.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/visitor/IXMLSearchVisitorProvider.java
new file mode 100644
index 0000000..5836e4d
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/visitor/IXMLSearchVisitorProvider.java
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.queryspecifications.visitor;
+
+/**
+ * Provider of {@link IXMLSearchDOMDocumentVisitor}.
+ */
+public interface IXMLSearchVisitorProvider {
+
+ IXMLSearchDOMDocumentVisitor getVisitor();
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/visitor/XPathNodeSetIgnoreSelectedNodeSearchVisitor.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/visitor/XPathNodeSetIgnoreSelectedNodeSearchVisitor.java
new file mode 100644
index 0000000..8ce9ff0
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/visitor/XPathNodeSetIgnoreSelectedNodeSearchVisitor.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.queryspecifications.visitor;
+
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+import org.eclipse.wst.xml.search.core.util.DOMUtils;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * Search visitor which execute XPath and collect the resulted nodes and ignore
+ * same nodes.
+ *
+ */
+public class XPathNodeSetIgnoreSelectedNodeSearchVisitor extends
+ XPathNodeSetSearchVisitor {
+
+ public static IXMLSearchDOMDocumentVisitor INSTANCE = new XPathNodeSetIgnoreSelectedNodeSearchVisitor();
+
+ @Override
+ protected boolean canAddNode(IDOMNode nodeToAdd, Object selectedNode) {
+ if (selectedNode == null) {
+ return true;
+ }
+ if (selectedNode.equals(nodeToAdd)) {
+ return true;
+ }
+ if (!(selectedNode instanceof Node)) {
+ return false;
+ }
+ Element element1 = DOMUtils.getOwnerElement(nodeToAdd);
+ Element element2 = DOMUtils.getOwnerElement((Node) selectedNode);
+ return (!(element1 != null && element1.equals(element2) || (element1 == null && element2 == null)));
+ }
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/visitor/XPathNodeSetSearchVisitor.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/visitor/XPathNodeSetSearchVisitor.java
new file mode 100644
index 0000000..13a6ca1
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/queryspecifications/visitor/XPathNodeSetSearchVisitor.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.queryspecifications.visitor;
+
+import javax.xml.xpath.XPathExpressionException;
+
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+import org.eclipse.wst.xml.search.core.IXMLSearchDOMNodeCollector;
+import org.eclipse.wst.xml.search.core.XMLSearchEngineException;
+import org.eclipse.wst.xml.search.core.xpath.NamespaceInfos;
+import org.eclipse.wst.xml.search.core.xpath.XPathManager;
+import org.w3c.dom.NodeList;
+
+/**
+ * Search visitor which execute XPath and collect the resulted nodes.
+ *
+ */
+public class XPathNodeSetSearchVisitor extends AbstractXMLSearchVisitor {
+
+ public static IXMLSearchDOMDocumentVisitor INSTANCE = new XPathNodeSetSearchVisitor();
+
+ public void visit(IDOMDocument document, String query,
+ String xpathProcessorId,
+ IXMLSearchDOMNodeCollector collector, Object selectedNode)
+ throws XMLSearchEngineException {
+ try {
+ NamespaceInfos namespaceInfos = XPathManager.getManager().getNamespaceInfo(
+ document);
+ NodeList list = XPathManager.getManager().evaluateNodeSet(
+ xpathProcessorId, document, query, namespaceInfos, null);
+ for (int i = 0; i < list.getLength(); i++) {
+ IDOMNode el = (IDOMNode) list.item(i);
+ if (canAddNode(el, selectedNode)) {
+ collector.add(el);
+ }
+ }
+ } catch (XPathExpressionException e) {
+ throw new XMLSearchEngineException(e);
+ }
+ }
+
+ protected boolean canAddNode(IDOMNode nodeToAdd, Object selectedNode) {
+ return true;
+ }
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/reporter/IXMLSearchReporter.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/reporter/IXMLSearchReporter.java
new file mode 100644
index 0000000..9924e5c
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/reporter/IXMLSearchReporter.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.reporter;
+
+import java.util.Collection;
+import java.util.Map;
+
+import org.eclipse.core.resources.IResource;
+
+/**
+ * Search reporter to trace start/end search.
+ *
+ */
+public interface IXMLSearchReporter {
+
+ void beginSearch(int searchId, Map<IResource, Collection<String>> query);
+
+ void endSearch(int searchId, long elapsedTime);
+
+ boolean isEnabled();
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/reporter/MutliXMLSearchReporter.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/reporter/MutliXMLSearchReporter.java
new file mode 100644
index 0000000..b901c86
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/reporter/MutliXMLSearchReporter.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.reporter;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Map;
+
+import org.eclipse.core.resources.IResource;
+
+/**
+ * Multi search reporter.
+ *
+ */
+public class MutliXMLSearchReporter extends ArrayList<IXMLSearchReporter>
+ implements IXMLSearchReporter {
+
+ private static final long serialVersionUID = -4324750000148797136L;
+
+ public void beginSearch(int searchId,
+ Map<IResource, Collection<String>> queries) {
+ IXMLSearchReporter reporter = null;
+ for (int i = 0; i < super.size(); i++) {
+ reporter = super.get(i);
+ if (reporter.isEnabled()) {
+ reporter.beginSearch(searchId, queries);
+ }
+ }
+ }
+
+ public void endSearch(int searchId, long elapsedTime) {
+ IXMLSearchReporter reporter = null;
+ for (int i = 0; i < super.size(); i++) {
+ reporter = super.get(i);
+ if (reporter.isEnabled()) {
+ reporter.endSearch(searchId, elapsedTime);
+ }
+ }
+ }
+
+ public boolean isEnabled() {
+ return !super.isEmpty();
+ }
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/reporter/SysOutSearchReporter.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/reporter/SysOutSearchReporter.java
new file mode 100644
index 0000000..b434c2f
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/reporter/SysOutSearchReporter.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.reporter;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import org.eclipse.core.resources.IResource;
+
+/**
+ * Search reporter which trace to System.out.
+ *
+ */
+public class SysOutSearchReporter implements IXMLSearchReporter {
+
+ public static final IXMLSearchReporter INSTANCE = new SysOutSearchReporter();
+
+ public void beginSearch(int searchId,
+ Map<IResource, Collection<String>> queries) {
+ System.out.println("Start search [" + searchId + "]");
+ Set<Entry<IResource, Collection<String>>> entries = queries.entrySet();
+ for (Entry<IResource, Collection<String>> entry : entries) {
+ System.out.print("\tresources=");
+ System.out.println(entry.getKey().getFullPath());
+ System.out.print("\t\tqueries=");
+ Collection<String> q = entry.getValue();
+ boolean first = true;
+ for (String query : q) {
+ if (!first) {
+ System.out.print(", ");
+ }
+ System.out.print(query);
+ first = false;
+ }
+ System.out.println();
+ }
+ }
+
+ public void endSearch(int searchId, long elapsedTime) {
+ System.out.println("End search [" + searchId + "] with " + elapsedTime
+ + "(ms).");
+ }
+
+ public boolean isEnabled() {
+ return true;
+ }
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/AbstractResourceRequestor.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/AbstractResourceRequestor.java
new file mode 100644
index 0000000..9180bb7
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/AbstractResourceRequestor.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.resource;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+
+public abstract class AbstractResourceRequestor implements IResourceRequestor {
+
+ protected static final String DOT_FOLDER = ".";
+
+ public boolean accept(Object selectedNode, IResource rootContainer,
+ IResource resource, IURIResolver resolver, String matching,
+ boolean fullMatch) {
+ int resourceType = resource.getType();
+ switch (resourceType) {
+ case IResource.ROOT:
+ return accept(selectedNode, rootContainer,
+ (IWorkspaceRoot) resource, resolver, matching, fullMatch);
+ case IResource.PROJECT:
+ return accept(selectedNode, rootContainer, (IProject) resource,
+ resolver, matching, fullMatch);
+ case IResource.FOLDER:
+ return accept(selectedNode, rootContainer, (IFolder) resource,
+ resolver, matching, fullMatch);
+ case IResource.FILE:
+ return accept(selectedNode, rootContainer, (IFile) resource,
+ resolver, matching, fullMatch);
+ }
+ return false;
+ }
+
+ public boolean accept(Object selectedNode, IResource rootContainer,
+ IWorkspaceRoot workspaceRoot, IURIResolver resolver,
+ String matching, boolean fullMatch) {
+ return true;
+ }
+
+ public boolean accept(Object selectedNode, IResource rootContainer,
+ IProject project, IURIResolver resolver, String matching,
+ boolean fullMatch) {
+ if (project.isOpen()) {
+ return true;
+ }
+ return false;
+ }
+
+ public boolean accept(Object selectedNode, IResource rootContainer,
+ IFolder folder, IURIResolver resolver, String matching,
+ boolean fullMatch) {
+ // ignore .svn folder....
+ return !folder.getName().startsWith(DOT_FOLDER);
+ }
+
+ protected abstract boolean accept(Object selectedNode,
+ IResource rootContainer, IFile file, IURIResolver resolver,
+ String matching, boolean fullMatch);
+
+ public boolean acceptContainer() {
+ return false;
+ }
+
+ public boolean acceptFile() {
+ return true;
+ }
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/AbstractURIResolver.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/AbstractURIResolver.java
new file mode 100644
index 0000000..5b81a64
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/AbstractURIResolver.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.resource;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+
+public abstract class AbstractURIResolver implements IURIResolver {
+
+ public boolean accept(Object selectedNode, IResource rootContainer,
+ IResource file, String matching, boolean fullMatch) {
+ if (!fullMatch) {
+ matching = matching.toLowerCase();
+ String fileName = file.getName();
+ fileName = fileName.toLowerCase();
+ if (fileName.startsWith(matching)) {
+ return true;
+ }
+ return resolve(selectedNode, rootContainer, file).toLowerCase()
+ .startsWith(matching);
+ }
+ return resolve(selectedNode, rootContainer, file).equals(matching);
+ }
+
+ public <T extends IResource> T getResource(IContainer container,
+ String resourceName, Class<T> clazz) {
+ if (clazz == IFile.class) {
+ return (T) container.getFile(new Path(resourceName));
+ }
+ if (clazz == IFolder.class) {
+ return (T) container.getFolder(new Path(resourceName));
+ }
+ return null;
+ }
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/AllResourcesRequestor.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/AllResourcesRequestor.java
new file mode 100644
index 0000000..36d607c
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/AllResourcesRequestor.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.resource;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+
+public class AllResourcesRequestor extends AbstractResourceRequestor {
+
+ public static final IResourceRequestor INSTANCE = new AllResourcesRequestor();
+
+ @Override
+ protected boolean accept(Object selectedNode, IResource rootContainer,
+ IFile file, IURIResolver resolver, String matching,
+ boolean fullMatch) {
+ return true;
+ }
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/DOMNodeBaseURIResolver.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/DOMNodeBaseURIResolver.java
new file mode 100644
index 0000000..c57f943
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/DOMNodeBaseURIResolver.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.resource;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+import org.eclipse.wst.xml.search.core.util.DOMUtils;
+
+public class DOMNodeBaseURIResolver extends AbstractURIResolver {
+
+ public static final IURIResolver INSTANCE = new DOMNodeBaseURIResolver();
+
+ public String resolve(Object selectedNode, IResource rootContainer,
+ IResource file) {
+ IContainer container = DOMUtils.getFile((IDOMNode) selectedNode)
+ .getParent();
+ return file
+ .getProjectRelativePath()
+ .removeFirstSegments(
+ container.getProjectRelativePath().segmentCount())
+ .toString();
+ }
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/DefaultResourceRequestor.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/DefaultResourceRequestor.java
new file mode 100644
index 0000000..b02dc62
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/DefaultResourceRequestor.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.resource;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+
+public class DefaultResourceRequestor extends AbstractResourceRequestor {
+
+ public static final IResourceRequestor INSTANCE = new DefaultResourceRequestor();
+
+ @Override
+ protected boolean accept(Object selectedNode, IResource rootContainer,
+ IFile file, IURIResolver resolver, String matching,
+ boolean fullMatch) {
+ return resolver.accept(selectedNode, rootContainer, file, matching,
+ fullMatch);
+ }
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/DefaultURIResolverProvider.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/DefaultURIResolverProvider.java
new file mode 100644
index 0000000..5f80408
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/DefaultURIResolverProvider.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.resource;
+
+import org.eclipse.core.resources.IFile;
+
+public class DefaultURIResolverProvider implements IURIResolverProvider {
+
+ public static final IURIResolverProvider INSTANCE = new DefaultURIResolverProvider();
+
+ public IURIResolver getURIResolver(IFile file, Object selectedNode) {
+ return ResourceBaseURIResolver.INSTANCE;
+ }
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/IResourceCollector.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/IResourceCollector.java
new file mode 100644
index 0000000..71deea2
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/IResourceCollector.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.resource;
+
+import org.eclipse.core.resources.IResource;
+
+/**
+ * A collector to collect {@link IResource} founded with the search.
+ *
+ */
+public interface IResourceCollector {
+
+ /**
+ * This method is called when the resource match the search.
+ *
+ * @param resource
+ * which match the search.
+ * @param rootResource
+ * the root (container, file....) used when search is started.
+ * @param resolver
+ * to use to resolve value path fo the {@link IResource}.
+ * @return
+ */
+ boolean add(IResource resource, IResource rootResource,
+ IURIResolver resolver);
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/IResourceQuerySpecification.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/IResourceQuerySpecification.java
new file mode 100644
index 0000000..070c8f7
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/IResourceQuerySpecification.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.resource;
+
+import org.eclipse.wst.xml.search.core.queryspecifications.container.IResourceProvider;
+import org.eclipse.wst.xml.search.core.queryspecifications.container.IMultiResourceProvider;
+
+public interface IResourceQuerySpecification extends IResourceProvider,
+ IResourceRequestorProvider, IURIResolverProvider, IMultiResourceProvider {
+
+ public static final IResourceQuerySpecification[] EMPTY = new IResourceQuerySpecification[0];
+
+ boolean isMultiResource();
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/IResourceRequestor.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/IResourceRequestor.java
new file mode 100644
index 0000000..096ed7a
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/IResourceRequestor.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.resource;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+import org.eclipse.wst.xml.search.core.queryspecifications.container.IResourceProvider;
+
+/**
+ * Resource requestor is used when search is started. Search loop for each
+ * container and files and call a requestor to know if the resource is accepted
+ * for the search result or not. If the resource is accepted, it is added by
+ * using a a {@link IResourceCollector}.
+ *
+ * @author Angelo ZERR
+ *
+ */
+public interface IResourceRequestor {
+
+ /**
+ * Returns true if resource can be accepted or not.
+ *
+ * @param selectedNode
+ * the selected node which has start the search.
+ * @param rootResource
+ * the root resource where search start (which is returned with
+ * {@link IResourceProvider}).
+ * @param resource
+ * the resource to accept or not.
+ * @param resolver
+ * the resolver.
+ * @param matching
+ * the matching string used for the search.
+ * @param fullMatch
+ * true if full match must be done (ex : for validation,
+ * hyperlink) and false otherwise (ex : autocompletion).
+ * @return
+ */
+ boolean accept(Object selectedNode, IResource rootResource,
+ IResource resource, IURIResolver resolver, String matching,
+ boolean fullMatch);
+
+ /**
+ * Returns true if files can be added to the collector
+ * {@link IResourceCollector} and false otherwise.
+ *
+ * @return
+ */
+ boolean acceptFile();
+
+ /**
+ * Returns true if container (folder, project...) can be added to the
+ * collector {@link IResourceCollector} and false otherwise.
+ *
+ * @return
+ */
+ boolean acceptContainer();
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/IResourceRequestorProvider.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/IResourceRequestorProvider.java
new file mode 100644
index 0000000..e8bf375
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/IResourceRequestorProvider.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.resource;
+
+/**
+ * A provider to returns {@link IResourceRequestor}.
+ *
+ */
+public interface IResourceRequestorProvider {
+
+ /**
+ * Resource requestor to use.
+ *
+ * @return
+ */
+ IResourceRequestor getRequestor();
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/IResourceSearchEngine.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/IResourceSearchEngine.java
new file mode 100644
index 0000000..e7e7f38
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/IResourceSearchEngine.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.resource;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+
+public interface IResourceSearchEngine {
+
+ IStatus search(Object selectedNode, IResource[] containers, IResourceRequestor requestor,
+ IResourceCollector collector, IURIResolver resolver, String matching, boolean fullMatch,
+ IProgressMonitor monitor);
+
+ IStatus search(Object selectedNode, IResource container, IResourceRequestor requestor,
+ IResourceCollector collector, IURIResolver resolver, String matching, boolean fullMatch,
+ IProgressMonitor monitor);
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/IURIResolver.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/IURIResolver.java
new file mode 100644
index 0000000..6835b5a
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/IURIResolver.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.resource;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+
+public interface IURIResolver {
+
+ String resolve(Object selectedNode, IResource rootContainer,
+ IResource file);
+
+ boolean accept(Object selectedNode, IResource rootContainer,
+ IResource file, String matching, boolean fullMatch);
+
+ <T extends IResource> T getResource(IContainer container,
+ String resourceName, Class<T> clazz);
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/IURIResolverProvider.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/IURIResolverProvider.java
new file mode 100644
index 0000000..a433fe2
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/IURIResolverProvider.java
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.resource;
+
+import org.eclipse.core.resources.IFile;
+
+public interface IURIResolverProvider {
+
+ IURIResolver getURIResolver(IFile file, Object selectedNode);
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/ResourceBaseURIResolver.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/ResourceBaseURIResolver.java
new file mode 100644
index 0000000..4e35826
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/ResourceBaseURIResolver.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.resource;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+
+public class ResourceBaseURIResolver extends AbstractURIResolver {
+
+ public static final ResourceBaseURIResolver INSTANCE = new ResourceBaseURIResolver();
+
+ public String resolve(Object selectedNode, IResource rootContainer,
+ IResource file) {
+ IContainer container = null;
+ if (rootContainer.getType() == IResource.FILE) {
+ container = ((IFile) rootContainer).getParent();
+ } else {
+ container = ((IContainer) rootContainer);
+ }
+ return file
+ .getProjectRelativePath()
+ .removeFirstSegments(
+ container.getProjectRelativePath().segmentCount())
+ .toString();
+ }
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/ResourceQuerySpecificationManager.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/ResourceQuerySpecificationManager.java
new file mode 100644
index 0000000..98319a0
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/ResourceQuerySpecificationManager.java
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.resource;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionDelta;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.wst.xml.search.core.AbstractRegistryManager;
+import org.eclipse.wst.xml.search.core.internal.Trace;
+import org.eclipse.wst.xml.search.core.internal.XMLSearchCorePlugin;
+import org.eclipse.wst.xml.search.core.internal.resource.ResourceQuerySpecification;
+import org.eclipse.wst.xml.search.core.util.StringUtils;
+
+public class ResourceQuerySpecificationManager extends AbstractRegistryManager {
+
+ private static final ResourceQuerySpecificationManager INSTANCE = new ResourceQuerySpecificationManager();
+ private static final String RESOURCE_QUERY_SPECIFICATIONS_EXTENSION_POINT = "resourceQuerySpecifications";
+ private Map<String, IResourceQuerySpecification> querySpecificationsById = null;
+
+ public static ResourceQuerySpecificationManager getDefault() {
+ return INSTANCE;
+ }
+
+ @Override
+ protected void handleExtensionDelta(IExtensionDelta delta) {
+ if (querySpecificationsById == null) // not loaded yet
+ return;
+ if (delta.getKind() == IExtensionDelta.ADDED) {
+ IConfigurationElement[] cf = delta.getExtension()
+ .getConfigurationElements();
+ addQuerySpecifications(querySpecificationsById, cf);
+ } else {
+ // TODO : remove references
+ }
+ }
+
+ public IResourceQuerySpecification getQuerySpecification(
+ String querySpecificationId) {
+ if (StringUtils.isEmpty(querySpecificationId)) {
+ return ResourceQuerySpecification.DEFAULT;
+ }
+ if (querySpecificationsById == null) {
+ loadQuerySpecifications();
+ }
+
+ IResourceQuerySpecification querySpecification = querySpecificationsById
+ .get(querySpecificationId);
+ if (querySpecification == null) {
+ querySpecification = ResourceQuerySpecification.DEFAULT;
+ querySpecificationsById.put(querySpecificationId, querySpecification);
+ }
+ return querySpecification;
+ }
+
+ private synchronized void loadQuerySpecifications() {
+ if (querySpecificationsById != null) {
+ return;
+ }
+
+ Map<String, IResourceQuerySpecification> querySpecificationsById = null;
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ if (registry != null) {
+ IConfigurationElement[] cf = registry.getConfigurationElementsFor(
+ XMLSearchCorePlugin.PLUGIN_ID,
+ RESOURCE_QUERY_SPECIFICATIONS_EXTENSION_POINT);
+ querySpecificationsById = new HashMap<String, IResourceQuerySpecification>(
+ cf.length);
+ addQuerySpecifications(querySpecificationsById, cf);
+ } else {
+ querySpecificationsById = new HashMap<String, IResourceQuerySpecification>();
+ }
+ this.querySpecificationsById = querySpecificationsById;
+ super.addRegistryListenerIfNeeded();
+
+ }
+
+ private synchronized void addQuerySpecifications(
+ Map<String, IResourceQuerySpecification> querySpecificationsById,
+ IConfigurationElement[] cf) {
+ String id = null;
+ IResourceQuerySpecification querySpecification = null;
+ for (IConfigurationElement ce : cf) {
+ // querySpecification declaration,
+ id = ce.getAttribute("id");
+ try {
+ querySpecification = ResourceQuerySpecification
+ .newQuerySpecification(ce
+ .createExecutableExtension("class"));
+ querySpecificationsById.put(id, querySpecification);
+ } catch (Throwable t) {
+ Trace.trace(Trace.SEVERE,
+ " Could not load querySpecification for id: " + id, t);
+ }
+ }
+ }
+
+ @Override
+ protected String getPluginId() {
+ return XMLSearchCorePlugin.PLUGIN_ID;
+ }
+
+ @Override
+ protected String getExtensionPoint() {
+ return RESOURCE_QUERY_SPECIFICATIONS_EXTENSION_POINT;
+ }
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/ResourceSearchEngine.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/ResourceSearchEngine.java
new file mode 100644
index 0000000..723407b
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/resource/ResourceSearchEngine.java
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.resource;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.xml.search.core.internal.Trace;
+
+public class ResourceSearchEngine implements IResourceSearchEngine {
+
+ private static final IResourceSearchEngine INSTANCE = new ResourceSearchEngine();
+
+ public static IResourceSearchEngine getDefault() {
+ return INSTANCE;
+ }
+
+ public IStatus search(Object selectedNode, IResource[] containers,
+ IResourceRequestor requestor, IResourceCollector collector,
+ IURIResolver resolver, String matching, boolean fullMatch,
+ IProgressMonitor monitor) {
+ for (int i = 0; i < containers.length; i++) {
+ IResource resource = containers[i];
+ internalSearch(selectedNode, resource, containers[i], requestor,
+ collector, resolver, matching, fullMatch, monitor);
+ }
+ return Status.OK_STATUS;
+ }
+
+ public IStatus search(Object selectedNode, IResource container,
+ IResourceRequestor requestor, IResourceCollector collector,
+ IURIResolver resolver, String matching, boolean fullMatch,
+ IProgressMonitor monitor) {
+ internalSearch(selectedNode, container, container, requestor,
+ collector, resolver, matching, fullMatch, monitor);
+ return Status.OK_STATUS;
+ }
+
+ private void internalSearch(Object selectedNode, IResource rootContainer,
+ IResource container, IResourceRequestor requestor,
+ IResourceCollector collector, IURIResolver resolver,
+ String matching, boolean fullMatch, IProgressMonitor monitor) {
+ if (!requestor.accept(selectedNode, rootContainer, container, resolver,
+ matching, fullMatch))
+ return;
+ int resourceType = container.getType();
+ switch (resourceType) {
+ case IResource.FILE:
+ if (requestor.acceptFile()) {
+ collector.add(container, rootContainer, resolver);
+ }
+ break;
+ case IResource.ROOT:
+ case IResource.PROJECT:
+ case IResource.FOLDER:
+ try {
+ if (requestor.acceptContainer()) {
+ if (!fullMatch) {
+ if (resolver
+ .resolve(selectedNode, rootContainer, container)
+ .toUpperCase()
+ .startsWith(matching.toUpperCase())) {
+ collector.add(container, rootContainer, resolver);
+ }
+ } else {
+ if (resolver.resolve(selectedNode, rootContainer,
+ container).equals(matching)) {
+ collector.add(container, rootContainer, resolver);
+ }
+ }
+ }
+ internalSearch(selectedNode, rootContainer,
+ ((IContainer) container).members(), requestor,
+ collector, resolver, matching, fullMatch, monitor);
+ } catch (CoreException e) {
+ Trace.trace(Trace.SEVERE, e.getMessage(), e);
+ }
+ break;
+ }
+ }
+
+ private IStatus internalSearch(Object selectedNode,
+ IResource rootContainer, IResource[] containers,
+ IResourceRequestor requestor, IResourceCollector collector,
+ IURIResolver resolver, String matching, boolean fullMatch,
+ IProgressMonitor monitor) {
+ for (int i = 0; i < containers.length; i++) {
+ internalSearch(selectedNode, rootContainer, containers[i],
+ requestor, collector, resolver, matching, fullMatch,
+ monitor);
+ }
+ return Status.OK_STATUS;
+ }
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/statics/DefaultStaticValueVisitor.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/statics/DefaultStaticValueVisitor.java
new file mode 100644
index 0000000..bb0bb7a
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/statics/DefaultStaticValueVisitor.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.statics;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+
+public class DefaultStaticValueVisitor implements IStaticValueVisitor {
+
+ private Map<String, IStaticValue> values = new HashMap<String, IStaticValue>();
+
+ public void registerValue(String key, String description) {
+ registerValue(new StaticValue(key, description));
+ }
+
+ public void registerValue(IStaticValue staticValue) {
+ values.put(staticValue.getKey(), staticValue);
+ }
+
+ public void clearValues() {
+ values.clear();
+ }
+
+ public void visit(Object selectedNode, IFile file, String matching,
+ boolean startsWith, IStaticValueCollector collector) {
+ if (startsWith) {
+ Set<Entry<String, IStaticValue>> entries = values.entrySet();
+ for (Entry<String, IStaticValue> entry : entries) {
+ if (entry.getKey().startsWith(matching)) {
+ collector.add(entry.getValue());
+ }
+ }
+ } else {
+ IStaticValue value = values.get(matching);
+ if (value != null) {
+ collector.add(value);
+ }
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/statics/IStaticValue.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/statics/IStaticValue.java
new file mode 100644
index 0000000..eefa491
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/statics/IStaticValue.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.statics;
+
+public interface IStaticValue {
+
+ public String getKey();
+
+ public String getDescription();
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/statics/IStaticValueCollector.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/statics/IStaticValueCollector.java
new file mode 100644
index 0000000..d8bc787
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/statics/IStaticValueCollector.java
@@ -0,0 +1,16 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.statics;
+
+public interface IStaticValueCollector {
+
+ boolean add(IStaticValue value);
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/statics/IStaticValueQuerySpecification.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/statics/IStaticValueQuerySpecification.java
new file mode 100644
index 0000000..39b0884
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/statics/IStaticValueQuerySpecification.java
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.statics;
+
+public interface IStaticValueQuerySpecification extends IStaticValueVisitorProvider {
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/statics/IStaticValueSearchEngine.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/statics/IStaticValueSearchEngine.java
new file mode 100644
index 0000000..6411eed
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/statics/IStaticValueSearchEngine.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.statics;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+
+public interface IStaticValueSearchEngine {
+
+ IStatus search(Object selectedNode, IFile file, IStaticValueVisitor visitor,
+ IStaticValueCollector collector, String matching,
+ boolean startsWith, IProgressMonitor monitor);
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/statics/IStaticValueVisitor.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/statics/IStaticValueVisitor.java
new file mode 100644
index 0000000..5fec77c
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/statics/IStaticValueVisitor.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.statics;
+
+import org.eclipse.core.resources.IFile;
+
+public interface IStaticValueVisitor {
+
+ void visit(Object selectedNode, IFile file, String matching, boolean startsWith,
+ IStaticValueCollector collector);
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/statics/IStaticValueVisitorProvider.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/statics/IStaticValueVisitorProvider.java
new file mode 100644
index 0000000..884efe9
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/statics/IStaticValueVisitorProvider.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.statics;
+
+import org.eclipse.core.resources.IFile;
+
+public interface IStaticValueVisitorProvider {
+
+ IStaticValueVisitor getVisitor(Object selectedNode, IFile file);
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/statics/StaticValue.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/statics/StaticValue.java
new file mode 100644
index 0000000..a636de0
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/statics/StaticValue.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.statics;
+
+public class StaticValue implements IStaticValue {
+
+ private final String key;
+ private final String description;
+
+ public StaticValue(String key, String description) {
+ this.key = key;
+ this.description = description;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/statics/StaticValueQuerySpecificationManager.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/statics/StaticValueQuerySpecificationManager.java
new file mode 100644
index 0000000..942c00d
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/statics/StaticValueQuerySpecificationManager.java
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.statics;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionDelta;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.wst.xml.search.core.AbstractRegistryManager;
+import org.eclipse.wst.xml.search.core.internal.Trace;
+import org.eclipse.wst.xml.search.core.internal.XMLSearchCorePlugin;
+import org.eclipse.wst.xml.search.core.internal.statics.StaticValueQuerySpecification;
+import org.eclipse.wst.xml.search.core.util.StringUtils;
+
+public class StaticValueQuerySpecificationManager extends
+ AbstractRegistryManager {
+
+ private static final StaticValueQuerySpecificationManager INSTANCE = new StaticValueQuerySpecificationManager();
+ private static final String XML_QUERY_SPECIFICATIONS_EXTENSION_POINT = "staticValueQuerySpecifications";
+ private Map<String, IStaticValueQuerySpecification> querySpecificationsById = null;
+
+ public static StaticValueQuerySpecificationManager getDefault() {
+ return INSTANCE;
+ }
+
+ @Override
+ protected void handleExtensionDelta(IExtensionDelta delta) {
+ if (querySpecificationsById == null) // not loaded yet
+ return;
+ if (delta.getKind() == IExtensionDelta.ADDED) {
+ IConfigurationElement[] cf = delta.getExtension()
+ .getConfigurationElements();
+ addQuerySpecifications(querySpecificationsById, cf);
+ } else {
+ // TODO : remove references
+ }
+ }
+
+ public IStaticValueQuerySpecification getQuerySpecification(
+ String querySpecificationId) {
+ if (StringUtils.isEmpty(querySpecificationId)) {
+ return null;
+ }
+ if (querySpecificationsById == null) {
+ loadQuerySpecifications();
+ }
+
+ IStaticValueQuerySpecification querySpecification = querySpecificationsById
+ .get(querySpecificationId);
+ if (querySpecification == null) {
+ querySpecificationsById.put(querySpecificationId, querySpecification);
+ }
+ return querySpecification;
+ }
+
+ private synchronized void loadQuerySpecifications() {
+ if (querySpecificationsById != null) {
+ return;
+ }
+
+ Map<String, IStaticValueQuerySpecification> querySpecificationsById = null;
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ if (registry != null) {
+ IConfigurationElement[] cf = registry.getConfigurationElementsFor(
+ XMLSearchCorePlugin.PLUGIN_ID,
+ XML_QUERY_SPECIFICATIONS_EXTENSION_POINT);
+ querySpecificationsById = new HashMap<String, IStaticValueQuerySpecification>(
+ cf.length);
+ addQuerySpecifications(querySpecificationsById, cf);
+ } else {
+ querySpecificationsById = new HashMap<String, IStaticValueQuerySpecification>();
+ }
+ this.querySpecificationsById = querySpecificationsById;
+ super.addRegistryListenerIfNeeded();
+
+ }
+
+ private synchronized void addQuerySpecifications(
+ Map<String, IStaticValueQuerySpecification> querySpecificationsById,
+ IConfigurationElement[] cf) {
+ String id = null;
+ IStaticValueQuerySpecification querySpecification = null;
+ for (IConfigurationElement ce : cf) {
+ // querySpecification declaration,
+ id = ce.getAttribute("id");
+ try {
+ querySpecification = StaticValueQuerySpecification
+ .newQuerySpecification(ce
+ .createExecutableExtension("class"));
+ if (querySpecification != null) {
+ querySpecificationsById.put(id, querySpecification);
+ }
+ } catch (Throwable t) {
+ Trace.trace(Trace.SEVERE,
+ " Could not load querySpecification for id: " + id, t);
+ }
+ }
+ }
+
+ @Override
+ protected String getPluginId() {
+ return XMLSearchCorePlugin.PLUGIN_ID;
+ }
+
+ @Override
+ protected String getExtensionPoint() {
+ return XML_QUERY_SPECIFICATIONS_EXTENSION_POINT;
+ }
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/statics/StaticValueSearchEngine.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/statics/StaticValueSearchEngine.java
new file mode 100644
index 0000000..fc7e15f
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/statics/StaticValueSearchEngine.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.statics;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+
+public class StaticValueSearchEngine implements IStaticValueSearchEngine {
+
+ private static IStaticValueSearchEngine INSTANCE = new StaticValueSearchEngine();
+
+ public IStatus search(Object selectedNode, IFile file, IStaticValueVisitor visitor, IStaticValueCollector collector,
+ String matching, boolean startsWith, IProgressMonitor monitor) {
+ visitor.visit(selectedNode, file, matching, startsWith, collector);
+ return null;
+ }
+
+ public static IStaticValueSearchEngine getDefault() {
+ return INSTANCE;
+ }
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/storage/IStorageLocationProvider.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/storage/IStorageLocationProvider.java
new file mode 100644
index 0000000..7def379
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/storage/IStorageLocationProvider.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.storage;
+
+import org.eclipse.core.resources.IStorage;
+
+public interface IStorageLocationProvider {
+
+ String getLocation(IStorage storage);
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/storage/IStorageModelManager.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/storage/IStorageModelManager.java
new file mode 100644
index 0000000..126ec64
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/storage/IStorageModelManager.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.storage;
+
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+
+public interface IStorageModelManager {
+
+ IStructuredModel getModel(IStorage storage);
+
+ IStructuredModel loadModel(IStorage storage);
+
+ IStorage getStorage(IStructuredModel model);
+
+ void setStorageLocationProvider(IStorageLocationProvider locationProvider);
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/storage/StructuredStorageModelManager.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/storage/StructuredStorageModelManager.java
new file mode 100644
index 0000000..9170508
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/storage/StructuredStorageModelManager.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.storage;
+
+import org.eclipse.wst.xml.search.core.internal.storage.StorageModelManager;
+
+final public class StructuredStorageModelManager {
+
+ /**
+ * Do not allow instances to be created.
+ */
+ private StructuredStorageModelManager() {
+ super();
+ }
+
+ /**
+ * Provides access to the instance of {@link IStorageModelManager}.
+ *
+ * @return {@link IStorageModelManager} - returns the one model manager for
+ * structured model
+ */
+ public static IStorageModelManager getModelManager() {
+ return StorageModelManager.INSTANCE;
+ }
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/util/DOMUtils.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/util/DOMUtils.java
new file mode 100644
index 0000000..181a87a
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/util/DOMUtils.java
@@ -0,0 +1,565 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.util;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.text.IDocument;
+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.sse.core.internal.provisional.text.ITextRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+/**
+ * Utilities for SSE DOM node {@link IDOMNode}.
+ *
+ */
+public class DOMUtils {
+
+ /**
+ * Returns the SSE DOM Node {@link IDOMNode} by offset from the
+ * {@link IDocument} document and null if not found.
+ *
+ * @param document
+ * the document.
+ * @param offset
+ * the offset.
+ * @return
+ */
+ public static final IDOMNode getNodeByOffset(IDocument document, int offset) {
+ IStructuredModel model = null;
+ try {
+ model = StructuredModelManager.getModelManager()
+ .getExistingModelForRead(document);
+ return getNodeByOffset(model, offset);
+ } finally {
+ if (model != null)
+ model.releaseFromRead();
+ }
+ }
+
+ /**
+ * Returns the SSE DOM Node {@link IDOMNode} by offset from the
+ * {@link IStructuredModel} SSE mode and null if not found.
+ *
+ * @param model
+ * the SSE model.
+ * @param offset
+ * the offset.
+ * @return
+ */
+ public static final IDOMNode getNodeByOffset(IStructuredModel model,
+ int offset) {
+ if (model != null) {
+ IndexedRegion node = model.getIndexedRegion(offset);
+ if (node instanceof IDOMNode) {
+ return (IDOMNode) node;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the SSE DOM Attribute {@link IDOMAttr} by region from the SSE DOM
+ * element {@link IDOMElement}.
+ *
+ * @param element
+ * the SSE DOM element {@link IDOMElement}.
+ * @param region
+ * the region.
+ * @return
+ */
+ public static IDOMAttr getAttrByRegion(IDOMNode element, ITextRegion region) {
+ IStructuredDocumentRegion structuredDocumentRegionElement = element
+ .getFirstStructuredDocumentRegion();
+
+ // 1) Get attribute name region
+ ITextRegionList elementRegions = structuredDocumentRegionElement
+ .getRegions();
+ int index = elementRegions.indexOf(region);
+ if (index < 0) {
+ return null;
+ }
+
+ ITextRegion attrNameRegion = null;
+ while (index >= 0) {
+ attrNameRegion = elementRegions.get(index--);
+ if (attrNameRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) {
+ break;
+ }
+ }
+ if (attrNameRegion == null) {
+ return null;
+ }
+ String attrName = structuredDocumentRegionElement
+ .getText(attrNameRegion);
+ return (IDOMAttr) element.getAttributes().getNamedItem(attrName);
+ }
+
+ /**
+ * Returns the SSE DOM Attribute {@link IDOMAttr} by offset from the SSE DOM
+ * node {@link IDOMNode}.
+ *
+ * @param element
+ * the SSE DOM element {@link IDOMElement}.
+ * @param region
+ * the region.
+ * @return
+ */
+ public static final IDOMAttr getAttrByOffset(Node node, int offset) {
+ if ((node instanceof IndexedRegion)
+ && ((IndexedRegion) node).contains(offset)
+ && node.hasAttributes()) {
+ NamedNodeMap attrs = node.getAttributes();
+ for (int i = 0; i < attrs.getLength(); i++) {
+ IndexedRegion attRegion = (IndexedRegion) attrs.item(i);
+ if (attRegion.contains(offset))
+ return (IDOMAttr) attrs.item(i);
+ }
+
+ }
+ return null;
+ }
+
+ /**
+ * Returns the owner file of the SSE DOM Node {@link IDOMNode}.
+ *
+ * @param node
+ * the SSE DOM Node.
+ * @return
+ */
+ public static final IFile getFile(IDOMNode node) {
+ return getFile(node.getModel());
+ }
+
+ /**
+ * Returns the owner file of the JFace document {@link IDocument}.
+ *
+ * @param document
+ * @return
+ */
+ public static final IFile getFile(IDocument document) {
+ if (document == null) {
+ return null;
+ }
+ IStructuredModel model = null;
+ try {
+ model = StructuredModelManager.getModelManager()
+ .getExistingModelForRead(document);
+ if (model != null) {
+ return getFile(model);
+ }
+ } finally {
+ if (model != null)
+ model.releaseFromRead();
+ }
+ return null;
+ }
+
+ /**
+ * Returns the owner file of the SSE model {@link IStructuredModel}.
+ *
+ * @param node
+ * the SSE model.
+ * @return
+ */
+ public static final IFile getFile(IStructuredModel model) {
+ String baselocation = model.getBaseLocation();
+ if (baselocation != null) {
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IPath filePath = new Path(baselocation);
+ if (filePath.segmentCount() > 1) {
+ return root.getFile(filePath);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the owner file name of the SSE model {@link IDOMNode}.
+ *
+ * @param node
+ * @return
+ */
+ public static final String getFileName(IDOMNode node) {
+ return getFileName(node.getModel());
+ }
+
+ /**
+ * Returns the owner file name of the SSE model {@link IStructuredModel}.
+ *
+ * @param model
+ * @return
+ */
+ public static final String getFileName(IStructuredModel model) {
+ String baselocation = model.getBaseLocation();
+ if (baselocation != null) {
+ int index = baselocation.lastIndexOf('/');
+ if (index == -1) {
+ index = baselocation.lastIndexOf('\\');
+ }
+ if (index == -1) {
+ return baselocation;
+ }
+ return baselocation.substring(index + 1, baselocation.length());
+ }
+ return null;
+ }
+
+ /**
+ * Returns the node value from the DOM NOde.
+ *
+ * @param node
+ * @return
+ */
+ public static String getNodeValue(Node node) {
+ if (node == null) {
+ return null;
+ }
+ short nodeType = node.getNodeType();
+ switch (nodeType) {
+ case Node.ATTRIBUTE_NODE:
+ return ((Attr) node).getValue();
+ case Node.TEXT_NODE:
+ return getTextContent((Text) node);
+ }
+ return node.getNodeValue();
+ }
+
+ /**
+ * Returns the normalized text content of DOM text node.
+ *
+ * @param text
+ * @return
+ */
+ public static String getTextContent(Text text) {
+ return getTextContent(text, true);
+ }
+
+ /**
+ * Returns the text content of DOM text node.
+ *
+ * @param text
+ * @return
+ */
+ public static String getTextContent(Text text, boolean normalize) {
+ if (normalize) {
+ return StringUtils.normalizeSpace(text.getData());
+ }
+ return text.getData();
+ }
+
+ /**
+ * Returns the first child element retrieved by tag name from the parent
+ * node and null otherwise.
+ *
+ * @param parentNode
+ * parent node.
+ * @param elementName
+ * element name to found.
+ * @return the first child element
+ */
+ public static Element getFirstChildElementByTagName(Node parentNode,
+ String elementName) {
+ Element result = null;
+
+ if (parentNode.getNodeType() == Node.DOCUMENT_NODE) {
+ result = ((Document) parentNode).getDocumentElement();
+ if (!result.getNodeName().equals(elementName)) {
+ result = null;
+ }
+ } else {
+ NodeList nodes = parentNode.getChildNodes();
+ Node node;
+ for (int i = 0; i < nodes.getLength(); i++) {
+ node = nodes.item(i);
+ if (node.getNodeType() == Node.ELEMENT_NODE
+ && node.getNodeName().equals(elementName)) {
+ result = (Element) node;
+ break;
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Returns list of the first child element retrieved by tag name from the
+ * parent node and null otherwise.
+ *
+ * @param parentNode
+ * parent node.
+ * @param elementName
+ * element name to found.
+ * @return list of the first child element
+ */
+ public static Collection<Element> getFirstChildElementsByTagName(
+ Node contextNode, String elementName) {
+ Collection<Element> elements = null;
+ Element result = null;
+
+ if (contextNode.getNodeType() == Node.DOCUMENT_NODE) {
+ result = ((Document) contextNode).getDocumentElement();
+ if (!result.getNodeName().equals(elementName)) {
+ result = null;
+ }
+ } else {
+ NodeList nodes = contextNode.getChildNodes();
+ Node node;
+ for (int i = 0; i < nodes.getLength(); i++) {
+ node = nodes.item(i);
+ if (node.getNodeType() == Node.ELEMENT_NODE
+ && node.getNodeName().equals(elementName)) {
+ if (elements == null) {
+ elements = new ArrayList<Element>();
+ }
+ result = (Element) node;
+ elements.add(result);
+ }
+ }
+ }
+ if (elements == null) {
+ return Collections.emptyList();
+ }
+ return elements;
+ }
+
+ /**
+ * Returns the SSE DOM attribute by name from the ownner element.
+ *
+ * @param element
+ * @param attrName
+ * @return
+ */
+ public static IDOMAttr getAttr(IDOMElement element, String attrName) {
+ if (StringUtils.isEmpty(attrName)) {
+ return null;
+ }
+ String prefix = element.getPrefix();
+ if (!StringUtils.isEmpty(prefix)) {
+ String namespaceURI = element.getNamespaceURI();
+ IDOMAttr attr = (IDOMAttr) element.getAttributeNodeNS(namespaceURI,
+ attrName);
+ if (attr != null) {
+ return attr;
+ }
+ }
+ return (IDOMAttr) element.getAttributeNode(attrName);
+ }
+
+ /**
+ * Returns the first child Text node from the parentNode and null otherwise.
+ *
+ * @param parentNode
+ * @return
+ */
+ public static Text getTextNode(Node parentNode) {
+ if (parentNode == null)
+ return null;
+
+ Node result = null;
+ parentNode.normalize();
+ NodeList nodeList;
+ if (parentNode.getNodeType() == Node.DOCUMENT_NODE) {
+ nodeList = ((Document) parentNode).getDocumentElement()
+ .getChildNodes();
+ } else {
+ nodeList = parentNode.getChildNodes();
+ }
+ int len = nodeList.getLength();
+ if (len == 0) {
+ return null;
+ }
+ for (int i = 0; i < len; i++) {
+ result = nodeList.item(i);
+ if (result.getNodeType() == Node.TEXT_NODE) {
+ return (Text) result;
+ } else if (result.getNodeType() == Node.CDATA_SECTION_NODE) {
+ return /* (CDATASection) */(Text) result;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the content of the the first child Text node from the parentNode
+ * and null otherwise.
+ *
+ * @param node
+ * @return
+ */
+ public static String getTextNodeAsString(Node parentNode) {
+ if (parentNode == null)
+ return null;
+
+ Node txt = getTextNode(parentNode);
+ if (txt == null)
+ return null;
+
+ return txt.getNodeValue();
+ }
+
+ /**
+ * Returns the content type id of the SSE DOM Node.
+ *
+ * @param node
+ * @return
+ */
+ public static String getContentTypeId(IDOMNode node) {
+ if (node == null) {
+ return null;
+ }
+ return node.getModel().getContentTypeIdentifier();
+ }
+
+ /**
+ * Returns true if content type id of the SSE DOM Node match a
+ * contentTypeId.
+ *
+ * @param node
+ * @param contentTypeId
+ * @return
+ */
+ public static boolean isContentTypeId(IDOMNode selectedNode,
+ String[] contentTypeIds) {
+ for (int i = 0; i < contentTypeIds.length; i++) {
+ if (DOMUtils.isContentTypeId(selectedNode, contentTypeIds[i])) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Returns true if content type id of the SSE DOM Node match a
+ * contentTypeId.
+ *
+ * @param node
+ * @param contentTypeId
+ * @return
+ */
+ public static boolean isContentTypeId(IDOMNode node, String contentTypeId) {
+ if (contentTypeId == null) {
+ return false;
+ }
+ String nodeContentTypeId = getContentTypeId(node);
+ return contentTypeId.equals(nodeContentTypeId);
+ }
+
+ /**
+ * Returns the content type id of the file by using SSE DOM Model.
+ *
+ * @param file
+ * @return
+ */
+ public static String getStructuredModelContentTypeId(IFile file) {
+ IStructuredModel model = null;
+ try {
+ model = StructuredModelManager.getModelManager()
+ .getExistingModelForRead(file);
+ if (model == null) {
+ model = StructuredModelManager.getModelManager()
+ .getModelForRead(file);
+ }
+ if (model != null) {
+ return model.getContentTypeIdentifier();
+ }
+ } catch (IOException e) {
+ return null;
+ } catch (CoreException e) {
+ return null;
+ } finally {
+ if (model != null) {
+ model.releaseFromRead();
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns true if file match an item of the contentTypeIds list and false
+ * otherwise.
+ *
+ * @param file
+ * @param contentTypeIds
+ * @return
+ */
+ public static boolean isContentTypeId(IFile file,
+ Collection<String> contentTypeIds) {
+ if (contentTypeIds == null) {
+ return false;
+ }
+ String structuredModelContentTypeId = getStructuredModelContentTypeId(file);
+ if (structuredModelContentTypeId == null) {
+ return false;
+ }
+ return contentTypeIds.contains(structuredModelContentTypeId);
+ }
+
+ /**
+ * Returns true if file match the contentTypeId and false otherwise.
+ *
+ * @param file
+ * @param contentTypeId
+ * @return
+ */
+ public static boolean isContentTypeId(IFile file, String contentTypeId) {
+ if (contentTypeId == null) {
+ return false;
+ }
+ String structuredModelContentTypeId = getStructuredModelContentTypeId(file);
+ if (structuredModelContentTypeId == null) {
+ return false;
+ }
+ return contentTypeId.equals(structuredModelContentTypeId);
+ }
+
+ /**
+ * Returns the owner element of the node and null if not found.
+ *
+ * @param node
+ * @return
+ */
+ public static Element getOwnerElement(Node node) {
+ int nodeType = node.getNodeType();
+ switch (nodeType) {
+ case Node.ATTRIBUTE_NODE:
+ return ((Attr) node).getOwnerElement();
+ case Node.TEXT_NODE:
+ return (Element) ((Text) node).getParentNode();
+ case Node.ELEMENT_NODE:
+ return (Element) node;
+ }
+ return null;
+ }
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/util/FileUtils.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/util/FileUtils.java
new file mode 100644
index 0000000..009ebfd
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/util/FileUtils.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.util;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.content.IContentDescription;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.wst.xml.core.internal.provisional.contenttype.ContentTypeIdForXML;
+
+/**
+ *
+ * Utilities for {@link IFile}.
+ *
+ */
+public class FileUtils {
+
+ /**
+ * Returns true if file name is associated with XML content type
+ * "org.eclipse.core.runtime.xml" and false otherwise.
+ *
+ * @param filename
+ * file name to test.
+ * @return true if file name is associated with XML content type and false
+ * otherwise.
+ */
+ public static boolean isXMLFile(String fileName) {
+ IContentType contentType = Platform.getContentTypeManager()
+ .getContentType(ContentTypeIdForXML.ContentTypeID_XML);
+ return contentType.isAssociatedWith(fileName);
+ }
+
+ /**
+ * Returns true if file is associated with XML content type
+ * "org.eclipse.core.runtime.xml" and false otherwise.
+ *
+ * @param file
+ * file to test.
+ * @return true if file is associated with XML content type and false
+ * otherwise.
+ */
+ public static boolean isXMLFile(IFile file) {
+ return isXMLFile(file.getName());
+ }
+
+ public static String getContentTypeId(IFile file) {
+ try {
+ IContentDescription contentDescription = file
+ .getContentDescription();
+ if (contentDescription == null) {
+ return null;
+ }
+ IContentType contentType = contentDescription.getContentType();
+ if (contentType == null) {
+ return null;
+ }
+ return contentType.getId();
+
+ } catch (CoreException e) {
+ }
+ return null;
+ }
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/util/StringUtils.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/util/StringUtils.java
new file mode 100644
index 0000000..58c8ebd
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/util/StringUtils.java
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.util;
+
+/**
+ *
+ * Utilities for {@link String}.
+ *
+ */
+public class StringUtils {
+
+ public static final String[] EMPTY_ARRAY = new String[0];
+
+ public static boolean isEmpty(String str) {
+ return str == null || str.length() == 0;
+ }
+
+ public static boolean hasLength(CharSequence str) {
+ return str != null && str.length() > 0;
+ }
+
+ public static boolean hasLength(String str) {
+ return hasLength(((CharSequence) (str)));
+ }
+
+ public static boolean hasText(CharSequence str) {
+ if (!hasLength(str))
+ return false;
+ int strLen = str.length();
+ for (int i = 0; i < strLen; i++)
+ if (!Character.isWhitespace(str.charAt(i)))
+ return true;
+
+ return false;
+ }
+
+ public static boolean hasText(String str) {
+ return hasText(((CharSequence) (str)));
+ }
+
+ public static boolean isQuoted(String string) {
+ if (string == null || string.length() < 2)
+ return false;
+ int lastIndex = string.length() - 1;
+ char firstChar = string.charAt(0);
+ char lastChar = string.charAt(lastIndex);
+ return firstChar == '\'' && lastChar == '\'' || firstChar == '"'
+ && lastChar == '"';
+ }
+
+ public static String normalizeSpace(String s) {
+ if (s == null) {
+ return null;
+ }
+ int len = s.length();
+ if (len < 1) {
+ return "";
+ }
+ int st = 0;
+ int off = 0; /* avoid getfield opcode */
+ char[] val = s.toCharArray(); /* avoid getfield opcode */
+ int count = s.length();
+
+ boolean parse = true;
+ char c;
+ while (parse) {
+ c = val[off + st];
+ parse = isParse(len, st, c);
+ if (parse) {
+ st++;
+ }
+ }
+ parse = true;
+ while ((st < len) && (val[off + len - 1] <= ' ')) {
+ c = val[off + len - 1];
+ parse = isParse(len, st, c);
+ if (parse) {
+ len--;
+ }
+ }
+ return ((st > 0) || (len < count)) ? s.substring(st, len) : s;
+ }
+
+ private static boolean isParse(int len, int st, char c) {
+ return (st < len) && (c == ' ' || c == '\r' || c == '\n' || c == '\t');
+ }
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/xpath/AbstractXPathProcessor.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/xpath/AbstractXPathProcessor.java
new file mode 100644
index 0000000..61a1e98
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/xpath/AbstractXPathProcessor.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.xpath;
+
+import java.text.MessageFormat;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+
+public abstract class AbstractXPathProcessor implements IXPathProcessor {
+
+ public String computeXPath(String xpath, String... args) {
+ if (args == null || args.length < 1) {
+ return xpath;
+ }
+ return MessageFormat.format(xpath, (Object[]) args);
+ }
+
+ protected IStatus createStatusForXPathNotValid(String xpath, String pluginId, Throwable e) {
+ return new Status(IStatus.ERROR, pluginId, "Error XPath parsing",
+ e);
+ }
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/xpath/AbstractXPathProcessorForXPathFactory.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/xpath/AbstractXPathProcessorForXPathFactory.java
new file mode 100644
index 0000000..ae293db
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/xpath/AbstractXPathProcessorForXPathFactory.java
@@ -0,0 +1,122 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.xpath;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.xml.search.core.internal.XMLSearchCorePlugin;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public abstract class AbstractXPathProcessorForXPathFactory extends
+ AbstractXPathProcessor {
+
+ /**
+ * XPath expressions cache
+ */
+ private Map<String, XPathExpression> expressions = new HashMap<String, XPathExpression>();
+
+ private XPathFactory factory;
+
+ public NodeList evaluateNodeSet(Object source, String xpath,
+ NamespaceInfos namespaceInfo, String... criteria)
+ throws XPathExpressionException {
+ return (NodeList) evaluate(source, XPathConstants.NODESET, xpath,
+ namespaceInfo, criteria);
+ }
+
+ public String evaluateString(Object source, String xpath,
+ NamespaceInfos namespaceInfo, String... criteria) throws XPathExpressionException {
+ return (String) evaluate(source, XPathConstants.STRING, xpath,
+ namespaceInfo, criteria);
+ }
+// public Node evaluateNode(Object source, String xpath, String... criteria)
+// throws XPathExpressionException {
+// return (Node) evaluate(source, XPathConstants.NODE, xpath, criteria);
+// }
+//
+// public Boolean evaluateBoolean(Object source, String xpath,
+// String... criteria) throws XPathExpressionException {
+// return (Boolean) evaluate(source, XPathConstants.BOOLEAN, xpath,
+// criteria);
+// }
+//
+// public Number evaluateNumber(Object source, String xpath,
+// String... criteria) throws XPathExpressionException {
+// return (Number) evaluate(source, XPathConstants.NUMBER, xpath, criteria);
+// }
+//
+// public String evaluateString(Object source, String xpath,
+// NamespaceInfos namespaceInfo, String... criteria)
+// throws XPathExpressionException {
+// return (String) evaluate(source, XPathConstants.STRING, xpath,
+// namespaceInfo, criteria);
+// }
+
+ public Object evaluate(Object source, QName name, String xpath,
+ NamespaceInfos namespaceInfo, String... criteria)
+ throws XPathExpressionException {
+ XPathExpression expr = getXPathExpression(xpath, namespaceInfo,
+ criteria);
+ return expr.evaluate(source, name);
+ }
+
+ protected XPathExpression getXPathExpression(String xpath,
+ NamespaceInfos namespaceInfo, String... args)
+ throws XPathExpressionException {
+ xpath = computeXPath(xpath, args);
+ XPathExpression exp = expressions.get(xpath);
+ if (exp == null) {
+ exp = createXPathExpression(xpath, namespaceInfo);
+ // expressions.put(xpath, exp);
+ }
+ return exp;
+ }
+
+ protected XPathExpression createXPathExpression(String expression,
+ NamespaceInfos namespaceInfo) throws XPathExpressionException {
+ XPath xpath = getFactory().newXPath();
+ if (namespaceInfo != null && namespaceInfo.size() > 0) {
+ xpath.setNamespaceContext(namespaceInfo);
+ }
+ XPathExpression expr = xpath.compile(expression);
+ return expr;
+ }
+
+ public IStatus validateXPath(String xpath) {
+ try {
+ createXPathExpression(xpath, null);
+ } catch (XPathExpressionException e) {
+ return createStatusForXPathNotValid(xpath,
+ XMLSearchCorePlugin.PLUGIN_ID, e);
+ }
+ return Status.OK_STATUS;
+ }
+
+ public XPathFactory getFactory() {
+ if (factory == null) {
+ factory = createFactory();
+ }
+ return factory;
+ }
+
+ protected abstract XPathFactory createFactory();
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/xpath/DefaultXPathProcessor.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/xpath/DefaultXPathProcessor.java
new file mode 100644
index 0000000..75acba7
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/xpath/DefaultXPathProcessor.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.xpath;
+
+import javax.xml.xpath.XPathFactory;
+
+
+public class DefaultXPathProcessor extends
+ AbstractXPathProcessorForXPathFactory {
+
+ public static final IXPathProcessor INSTANCE = new DefaultXPathProcessor();
+
+ public static final String ID = "org.eclipse.wst.xml.search.core.xpath.DefaultXPathProcessor";
+
+ @Override
+ protected XPathFactory createFactory() {
+ return XPathFactory.newInstance();
+ }
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/xpath/IXPathManager.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/xpath/IXPathManager.java
new file mode 100644
index 0000000..0ffbc96
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/xpath/IXPathManager.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.xpath;
+
+import javax.xml.xpath.XPathExpressionException;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public interface IXPathManager {
+
+ NodeList evaluateNodeSet(String xpathFactoryProviderId, Object source,
+ String xpath, NamespaceInfos namespaceInfo, String... criteria)
+ throws XPathExpressionException;
+
+ String evaluateString(String xpathFactoryProviderId, Object source,
+ String xpath, NamespaceInfos namespaceInfo, String... criteria)
+ throws XPathExpressionException;
+
+ NamespaceInfos getNamespaceInfo(Node node);
+
+ NamespaceInfos getNamespaceInfo(IDOMDocument document);
+
+ //
+ // Node evaluateNode(String xpathFactoryProviderId, Object source,
+ // String xpath, String... criteria) throws XPathExpressionException;
+ //
+ // Boolean evaluateBoolean(String xpathFactoryProviderId, Object source,
+ // String xpath, String... criteria) throws XPathExpressionException;
+ //
+ // Number evaluateNumber(String xpathFactoryProviderId, Object source,
+ // String xpath, String... criteria) throws XPathExpressionException;
+ //
+ // String evaluateString(String xpathFactoryProviderId, Object source,
+ // String xpath, String... criteria) throws XPathExpressionException;
+ //
+ // XPathExpression getXPathExpression(String xpathFactoryProviderId,
+ // String xpath, String... args) throws XPathExpressionException;
+ //
+ // XPathExpression createXPathExpression(String xpathFactoryProviderId,
+ // String expression) throws XPathExpressionException;
+ //
+ IStatus validateXPath(String xpathFactoryProviderId, String xpath);
+
+ String getXPath(String xpath, String... args);
+
+ //
+ String computeBasicXPath(Node node, NamespaceInfos namespaceInfos);
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/xpath/IXPathProcessor.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/xpath/IXPathProcessor.java
new file mode 100644
index 0000000..e1cc17d
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/xpath/IXPathProcessor.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.xpath;
+
+import javax.xml.xpath.XPathExpressionException;
+
+import org.eclipse.core.runtime.IStatus;
+import org.w3c.dom.NodeList;
+
+public interface IXPathProcessor {
+
+ String computeXPath(String xpath, String... args);
+
+ NodeList evaluateNodeSet(Object source, String xpath,
+ NamespaceInfos namespaceInfo, String... criteria)
+ throws XPathExpressionException;
+
+ String evaluateString(Object source, String xpath,
+ NamespaceInfos namespaceInfo, String... criteria)
+ throws XPathExpressionException;
+
+ IStatus validateXPath(String xpath);
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/xpath/IXPathProcessorType.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/xpath/IXPathProcessorType.java
new file mode 100644
index 0000000..4ad1a6c
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/xpath/IXPathProcessorType.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.xpath;
+
+public interface IXPathProcessorType {
+
+ public static final IXPathProcessorType[] EMPTY = new IXPathProcessorType[0];
+
+ String getId();
+
+ String getName();
+
+ IXPathProcessor getProcessor();
+
+ boolean isContributed();
+
+ String getSource();
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/xpath/NamespaceInfos.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/xpath/NamespaceInfos.java
new file mode 100644
index 0000000..c830274
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/xpath/NamespaceInfos.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.xpath;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import javax.xml.namespace.NamespaceContext;
+
+import org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo;
+
+public class NamespaceInfos extends ArrayList<NamespaceInfo> implements
+ NamespaceContext {
+
+ public String getPrefix(String namespaceURI) {
+ int size = super.size();
+ for (int i = 0; i < size; i++) {
+ NamespaceInfo namespaceInfo = super.get(i);
+ if (namespaceURI.equals(namespaceInfo.uri)) {
+ return getPrefix(namespaceInfo);
+ }
+ }
+ return null;
+ }
+
+ public String getNamespaceURI(String prefix) {
+ if ("ns".equals(prefix)) {
+ prefix = "";
+ }
+ int size = super.size();
+ for (int i = 0; i < size; i++) {
+ NamespaceInfo namespaceInfo = super.get(i);
+ if (prefix.equals(namespaceInfo.prefix)) {
+ return namespaceInfo.uri;
+ }
+ }
+ return null;
+ }
+
+ public Iterator getPrefixes(String arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getPrefix(NamespaceInfo namespaceInfo) {
+ if ("".equals(namespaceInfo.prefix)) {
+ return "ns";
+ }
+ return namespaceInfo.prefix;
+ }
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/xpath/XPathManager.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/xpath/XPathManager.java
new file mode 100644
index 0000000..d32cd5b
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/xpath/XPathManager.java
@@ -0,0 +1,279 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.xpath;
+
+import java.text.MessageFormat;
+import java.util.Collection;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.xml.xpath.XPathExpressionException;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo;
+import org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceTable;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
+import org.eclipse.wst.xml.search.core.internal.XMLSearchCorePlugin;
+import org.eclipse.wst.xml.search.core.util.StringUtils;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+/**
+ * XPath manager used to cache XPath expression.
+ *
+ */
+public class XPathManager implements IXPathManager {
+
+ private static final IXPathManager INSTANCE = new XPathManager();
+
+ private Map<String, NamespaceInfos> namespaceInfo = new ConcurrentHashMap<String, NamespaceInfos>();
+
+ public static IXPathManager getManager() {
+ return INSTANCE;
+ }
+
+ public NodeList evaluateNodeSet(String xpathFactoryProviderId,
+ Object source, String xpath, NamespaceInfos namespaceInfo,
+ String... criteria) throws XPathExpressionException {
+ return getProcessor(xpathFactoryProviderId).evaluateNodeSet(source,
+ xpath, namespaceInfo, criteria);
+ }
+
+ // public Node evaluateNode(String xpathFactoryProviderId, Object source,
+ // String xpath, String... criteria) throws XPathExpressionException {
+ // return getManager(xpathFactoryProviderId).evaluateNode(source, xpath,
+ // criteria);
+ // }
+ //
+ // public Boolean evaluateBoolean(String xpathFactoryProviderId,
+ // Object source, String xpath, String... criteria)
+ // throws XPathExpressionException {
+ // return getManager(xpathFactoryProviderId).evaluateBoolean(source,
+ // xpath, criteria);
+ // }
+ //
+ // public Number evaluateNumber(String xpathFactoryProviderId, Object
+ // source,
+ // String xpath, String... criteria) throws XPathExpressionException {
+ // return getManager(xpathFactoryProviderId).evaluateNumber(source, xpath,
+ // criteria);
+ // }
+ //
+ public String evaluateString(String xpathFactoryProviderId, Object source,
+ String xpath, NamespaceInfos namespaceInfo, String... criteria)
+ throws XPathExpressionException {
+ return getProcessor(xpathFactoryProviderId).evaluateString(source,
+ xpath, namespaceInfo, criteria);
+ }
+
+ //
+ // public XPathExpression getXPathExpression(String xpathFactoryProviderId,
+ // String xpath, String... args) throws XPathExpressionException {
+ // return getManager(xpathFactoryProviderId).getXPathExpression(xpath,
+ // args);
+ // }
+ //
+ // public XPathExpression createXPathExpression(String
+ // xpathFactoryProviderId,
+ // String expression) throws XPathExpressionException {
+ // return getManager(xpathFactoryProviderId).createXPathExpression(
+ // expression);
+ // }
+
+ public String getXPath(String xpath, String... args) {
+ if (args == null || args.length < 1) {
+ return xpath;
+ }
+ return MessageFormat.format(xpath, (Object[]) args);
+ }
+
+ public String computeBasicXPath(Node node, NamespaceInfos namespaceInfos) {
+ if (node == null) {
+ return null;
+ }
+ StringBuilder xpath = new StringBuilder();
+ computeBasicXPath(node, xpath, namespaceInfos);
+ return xpath.toString();
+ }
+
+ private Node computeBasicXPath(Node node, StringBuilder xpath,
+ NamespaceInfos namespaceInfos) {
+ int nodeType = node.getNodeType();
+ switch (nodeType) {
+ case Node.ATTRIBUTE_NODE:
+ computeBasicXPath((Attr) node, xpath, namespaceInfos);
+ return null;
+ case Node.TEXT_NODE:
+ computeBasicXPath((Text) node, xpath, namespaceInfos);
+ return null;
+ case Node.ELEMENT_NODE:
+ return computeBasicXPath((Element) node, xpath, namespaceInfos);
+ }
+ return null;
+ }
+
+ private Node computeBasicXPath(Element element, StringBuilder xpath,
+ NamespaceInfos namespaceInfos) {
+ xpath.insert(0, element.getLocalName());
+ if (!StringUtils.isEmpty(element.getNamespaceURI())
+ && namespaceInfos != null) {
+ String prefix = namespaceInfos.getPrefix(element.getNamespaceURI());
+ if (prefix != null) {
+ xpath.insert(0, ":");
+ xpath.insert(0, prefix);
+ }
+ }
+ xpath.insert(0, "/");
+ Node parentNode = element;
+ while (parentNode != null
+ && parentNode.getNodeType() != Node.DOCUMENT_NODE) {
+ parentNode = parentNode.getParentNode();
+ parentNode = computeBasicXPath(parentNode, xpath, namespaceInfos);
+ }
+ return parentNode;
+ }
+
+ private void computeBasicXPath(Attr attr, StringBuilder xpath,
+ NamespaceInfos namespaceInfos) {
+ computeBasicXPath(attr.getOwnerElement(), xpath, namespaceInfos);
+ xpath.append("[@");
+ xpath.append(attr.getName());
+ xpath.append("=");
+ addXPathConditionValue(attr.getValue(), xpath);
+ xpath.append("]");
+ xpath.append("/@");
+ xpath.append(attr.getName());
+ }
+
+ private void computeBasicXPath(Text text, StringBuilder xpath,
+ NamespaceInfos namespaceInfos) {
+ computeBasicXPath(text.getParentNode(), xpath, namespaceInfos);
+ xpath.append("[text()=");
+ addXPathConditionValue(text.getData(), xpath);
+ xpath.append("]");
+ xpath.append("/text()");
+ }
+
+ private void addXPathConditionValue(String value, StringBuilder xpath) {
+ char c = getEnclosingXPathCondition(value);
+ xpath.append(c);
+ xpath.append(value);
+ xpath.append(c);
+
+ }
+
+ private char getEnclosingXPathCondition(String value) {
+ if (value.indexOf("\"") != -1) {
+ return '\'';
+ }
+ return '\"';
+ }
+
+ private IXPathProcessor getProcessor(String id) {
+ if (id == null) {
+ return DefaultXPathProcessor.INSTANCE;
+ }
+ IXPathProcessorType processorType = XPathProcessorManager.getDefault()
+ .getProcessor(id);
+ if (processorType == null) {
+ throw new RuntimeException(
+ "Cannot retrieve XPath processor type with id=" + id);
+ }
+ IXPathProcessor processor = processorType.getProcessor();
+ if (processor == null) {
+ throw new RuntimeException(
+ "Null XPath processor for XPath processor with id=" + id);
+ }
+ return processor;
+ }
+
+ // private synchronized XPathManagerForXPathProcessor registerManager(String
+ // id) {
+ // XPathManagerForXPathProcessor manager = managers.get(id);
+ // if (manager != null) {
+ // return manager;
+ // }
+ // IXPathProcessorType processor = XPathProcessorManager.getDefault()
+ // .getProcessor(id);
+ // if (processor == null) {
+ // throw new RuntimeException(
+ // "Cannot retrieve XPath processor with id=" + id);
+ // }
+ // manager = new XPathManagerForXPathProcessor(processor.getProcessor());
+ // managers.put(id, manager);
+ // return manager;
+ // }
+
+ public IStatus validateXPath(String xpathFactoryProviderId, String xpath) {
+ IXPathProcessor processor = null;
+ try {
+ processor = getProcessor(xpathFactoryProviderId);
+ } catch (Throwable e) {
+ return XMLSearchCorePlugin.createStatus(IStatus.ERROR, "", e);
+ }
+ return processor.validateXPath(xpath);
+ }
+
+ // public String escapeForXPathAttrCondition(String value,
+ // boolean enclosedByDoubleQuote) {
+ // if (value == null) {
+ // return "";
+ // }
+ // if (enclosedByDoubleQuote) {
+ // if (value.indexOf("\"") != -1) {
+ // return value.replaceAll("\"", """);
+ // }
+ // } else {
+ // if (value.indexOf("'") != -1) {
+ // return value.replaceAll("\'", "&pos;");
+ // }
+ // }
+ // return value;
+ // }
+
+ public NamespaceInfos getNamespaceInfo(Node node) {
+ if (node.getNodeType() == Node.DOCUMENT_NODE) {
+ return getNamespaceInfo((IDOMDocument) node);
+ }
+ return getNamespaceInfo((IDOMDocument) node.getOwnerDocument());
+ }
+
+ public NamespaceInfos getNamespaceInfo(IDOMDocument document) {
+ String modelID = document.getModel().getId();
+ Map<String, NamespaceInfos> namespaceInfo = getNamespaceInfo();
+ NamespaceInfos info = namespaceInfo.get(modelID);
+
+ if (info == null) {
+ if (document.getDocumentElement() != null) {
+ info = new NamespaceInfos();
+ NamespaceTable namespaceTable = new NamespaceTable(document);
+ namespaceTable.visitElement(document.getDocumentElement());
+ Collection<?> namespaces = namespaceTable
+ .getNamespaceInfoCollection();
+ info.addAll((Collection<NamespaceInfo>) namespaces);
+ namespaceInfo.put(modelID, info);
+ setNamespaceInfo(namespaceInfo);
+ }
+ }
+ return info;
+ }
+
+ public void setNamespaceInfo(Map<String, NamespaceInfos> namespaceInfo) {
+ this.namespaceInfo = namespaceInfo;
+ }
+
+ public Map<String, NamespaceInfos> getNamespaceInfo() {
+ return namespaceInfo;
+ }
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/xpath/XPathProcessorManager.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/xpath/XPathProcessorManager.java
new file mode 100644
index 0000000..ba77537
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/xpath/XPathProcessorManager.java
@@ -0,0 +1,156 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.xpath;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionDelta;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.wst.xml.search.core.AbstractRegistryManager;
+import org.eclipse.wst.xml.search.core.internal.Trace;
+import org.eclipse.wst.xml.search.core.internal.XMLSearchCorePlugin;
+import org.eclipse.wst.xml.search.core.internal.preferences.PreferenceInitializer;
+import org.eclipse.wst.xml.search.core.internal.xpath.XPathProcessorType;
+import org.eclipse.wst.xml.search.core.util.StringUtils;
+
+public class XPathProcessorManager extends AbstractRegistryManager {
+
+ private static final XPathProcessorManager INSTANCE = new XPathProcessorManager();
+ private static final String XPATH_EVALUATORS_EXTENSION_POINT = "xpathProcessors";
+ private Map<String, IXPathProcessorType> processorsById = null;
+
+ private static final String PROCESSOR_ELT = "processor";
+ private static final String ID_ATTR = "id";
+ private static final String CLASS_ATTR = "class";
+ private static final String NAME_ATTR = "name";
+
+ private IXPathProcessorType processorType;
+
+ public static XPathProcessorManager getDefault() {
+ return INSTANCE;
+ }
+
+ @Override
+ protected void handleExtensionDelta(IExtensionDelta delta) {
+ if (processorsById == null) {// not loaded yet
+ return;
+ }
+ if (delta.getKind() == IExtensionDelta.ADDED) {
+ IConfigurationElement[] cf = delta.getExtension()
+ .getConfigurationElements();
+ addProcessors(processorsById, cf);
+ } else {
+ // TODO : remove references
+ }
+ }
+
+ private synchronized void addProcessors(
+ Map<String, IXPathProcessorType> processorsById,
+ IConfigurationElement[] cf) {
+ String id = null;
+ String name = null;
+ String source = null;
+ for (IConfigurationElement ce : cf) {
+ source = ce.getContributor().getName();
+ // loop for to get processor declaration
+ if (PROCESSOR_ELT.equals(ce.getName())) {
+ try {
+ id = ce.getAttribute(ID_ATTR);
+ name = ce.getAttribute(NAME_ATTR);
+ IXPathProcessor processor = (IXPathProcessor) ce
+ .createExecutableExtension(CLASS_ATTR);
+ processorsById.put(id, new XPathProcessorType(id, name,
+ source, true, processor));
+ } catch (Throwable t) {
+ Trace.trace(Trace.SEVERE,
+ " Could not load XPath processor for id: " + id, t);
+ }
+ }
+ }
+ }
+
+ public IXPathProcessorType getProcessor(String id) {
+ if (StringUtils.isEmpty(id)) {
+ return null;
+ }
+ if (processorsById == null) {
+ loadProcessors();
+ }
+
+ return processorsById.get(id);
+ }
+
+ private synchronized void loadProcessors() {
+ if (processorsById != null) {
+ return;
+ }
+ Map<String, IXPathProcessorType> processorsById = null;
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ if (registry != null) {
+ IConfigurationElement[] cf = registry.getConfigurationElementsFor(
+ getPluginId(), getExtensionPoint());
+ processorsById = new HashMap<String, IXPathProcessorType>(cf.length);
+ addProcessors(processorsById, cf);
+ } else {
+ processorsById = new HashMap<String, IXPathProcessorType>();
+ }
+ this.processorsById = processorsById;
+ super.addRegistryListenerIfNeeded();
+
+ }
+
+ @Override
+ protected String getExtensionPoint() {
+ return XPATH_EVALUATORS_EXTENSION_POINT;
+ }
+
+ @Override
+ protected String getPluginId() {
+ return XMLSearchCorePlugin.PLUGIN_ID;
+ }
+
+ public IXPathProcessorType[] getProcessors() {
+ if (processorsById == null) {
+ loadProcessors();
+ }
+ return processorsById.values().toArray(IXPathProcessorType.EMPTY);
+ }
+
+ public void setDefaultProcessor(IXPathProcessorType processorType) {
+ this.processorType = processorType;
+ if (processorType == null) {
+ XMLSearchCorePlugin
+ .getDefault()
+ .getPluginPreferences()
+ .setValue(PreferenceInitializer.DEFAULT_XPATH_PROCESSOR, "");
+ } else {
+ XMLSearchCorePlugin
+ .getDefault()
+ .getPluginPreferences()
+ .setValue(PreferenceInitializer.DEFAULT_XPATH_PROCESSOR,
+ processorType.getId());
+ }
+ XMLSearchCorePlugin.getDefault().savePluginPreferences();
+ }
+
+ public IXPathProcessorType getDefaultProcessor() {
+ if (processorType == null) {
+ String id = XMLSearchCorePlugin.getDefault().getPluginPreferences()
+ .getString(PreferenceInitializer.DEFAULT_XPATH_PROCESSOR);
+ processorType = getProcessor(id);
+ }
+ return processorType;
+ }
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/xpath/matcher/AbstractXPathNodeMatcher.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/xpath/matcher/AbstractXPathNodeMatcher.java
new file mode 100644
index 0000000..881244d
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/xpath/matcher/AbstractXPathNodeMatcher.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.xpath.matcher;
+
+/**
+ * Abstract class for XPath node matcher.
+ *
+ */
+public abstract class AbstractXPathNodeMatcher implements IXPathNodeMatcher {
+
+ private XPathMatcher ownerMatcher;
+
+ public AbstractXPathNodeMatcher(XPathMatcher ownerMatcher) {
+ this.ownerMatcher = ownerMatcher;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.eclipse.wst.xml.search.core.xpath.matcher.IXPathNodeMatcher#
+ * getOwnerMatcher()
+ */
+ public XPathMatcher getOwnerMatcher() {
+ return ownerMatcher;
+ }
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/xpath/matcher/IXPathNodeMatcher.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/xpath/matcher/IXPathNodeMatcher.java
new file mode 100644
index 0000000..53f03f6
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/xpath/matcher/IXPathNodeMatcher.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.xpath.matcher;
+
+import java.util.Collection;
+
+import org.w3c.dom.Node;
+
+/**
+ * XPath node matcher tests if {@link Node} match a fragment of XPath.
+ *
+ *
+ */
+public interface IXPathNodeMatcher {
+
+ public static final IXPathNodeMatcher[] EMPTY_NODE_MATCHER = new IXPathNodeMatcher[0];
+
+ public enum MatcherType {
+ ELEMENT, ATTRIBUTE
+ }
+
+ /**
+ * Returns the owner matcher.
+ *
+ * @return
+ */
+ XPathMatcher getOwnerMatcher();
+
+ /**
+ * Returns matcher type.
+ *
+ * @return
+ */
+ MatcherType getType();
+
+ /**
+ * Match the {@link Node} and fill wildcard values if node matcher define
+ * widcard.
+ *
+ * @param testNode
+ * node to test.
+ * @param wildcardValues
+ * wildcard values if node matcher define widcard.
+ * @return
+ */
+ boolean match(Node testNode, Collection<String> wildcardValues);
+
+ /**
+ * Returns true if matcher is any (Node is every time matched) and false
+ * otherwise.
+ *
+ * @return
+ */
+ boolean isAny();
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/xpath/matcher/XPathAttributeMatcher.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/xpath/matcher/XPathAttributeMatcher.java
new file mode 100644
index 0000000..039b2c2
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/xpath/matcher/XPathAttributeMatcher.java
@@ -0,0 +1,134 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.xpath.matcher;
+
+import java.util.Collection;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * XPath attribute matcher matches {@link Attr} of {@link Element}.
+ *
+ *
+ */
+public class XPathAttributeMatcher extends AbstractXPathNodeMatcher {
+
+ private final String attrName;
+ private final String attrValue;
+ private int indexWildcard = -1;
+
+ public XPathAttributeMatcher(String attrName, String attrValue,
+ XPathMatcher matcher) {
+ super(matcher);
+ this.attrName = attrName;
+ this.attrValue = attrValue;
+ if (attrValue.startsWith("$")) {
+ // attribute value has wilcard (ex : [@id='$0'])
+ try {
+ // get the wildcard index (ex : 0 for [@id='$0']).
+ indexWildcard = Integer.parseInt(attrValue.substring(1,
+ attrValue.length()));
+ } catch (NumberFormatException e) {
+
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.wst.xml.search.core.xpath.matcher.IXPathNodeMatcher#getType()
+ */
+ public MatcherType getType() {
+ return MatcherType.ATTRIBUTE;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.wst.xml.search.core.xpath.matcher.IXPathNodeMatcher#match
+ * (org.w3c.dom.Node, java.util.Collection)
+ */
+ public boolean match(Node testNode, Collection<String> wildcardValues) {
+ if (testNode.getNodeType() == Node.ELEMENT_NODE) {
+ // Node to test is element
+ Element element = (Element) testNode;
+ if (indexWildcard != -1) {
+ // wildcard is defined in the attribute matcher.
+ if (element.hasAttribute(attrName)) {
+ // element define, attribute, match is OK.
+ if (wildcardValues != null) {
+ // wildcard values is filled, add the attribute value
+ wildcardValues.add(element.getAttribute(attrName));
+ }
+ // element tested define the attribute, match is OK
+ return true;
+ }
+ return false;
+ }
+ // No wildcard defined, test if element has attribute attrName and
+ // if value is OK.
+ String testAttrValue = element.getAttribute(attrName);
+ return attrValue.equals(testAttrValue);
+ }
+ return false;
+ }
+
+ /**
+ * Returns the attribute name to match.
+ *
+ * @return
+ */
+ public String getAttrName() {
+ return attrName;
+ }
+
+ /**
+ * Returns the attribute value to match.
+ *
+ * @return
+ */
+ public String getAttrValue() {
+ return attrValue;
+ }
+
+ /**
+ * Returns true if attrValue is wilcard or false otherwise.
+ *
+ * @return
+ */
+ public boolean hasWildcard() {
+ return indexWildcard != -1;
+ }
+
+ /**
+ * Returns the wildcard index and -1 if no wildcard is defined.
+ *
+ * @return
+ */
+ public int getIndexWildcard() {
+ return indexWildcard;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.wst.xml.search.core.xpath.matcher.IXPathNodeMatcher#isAny()
+ */
+ public boolean isAny() {
+ return false;
+ }
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/xpath/matcher/XPathElementMatcher.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/xpath/matcher/XPathElementMatcher.java
new file mode 100644
index 0000000..264de09
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/xpath/matcher/XPathElementMatcher.java
@@ -0,0 +1,158 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.xpath.matcher;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * XPath element matcher matches {@link Attr} of {@link Element} and element
+ * name.
+ *
+ */
+public class XPathElementMatcher extends AbstractXPathNodeMatcher {
+
+ public static final String ANY_ELEMENT_NAME = "*";
+ private List<XPathAttributeMatcher> attributes = null;
+
+ private final String prefix;
+ private final String localName;
+ private final boolean anyElementName;
+
+ public XPathElementMatcher(String prefix, String localName,
+ XPathMatcher matcher) {
+ super(matcher);
+ this.prefix = prefix;
+ this.localName = localName;
+ this.anyElementName = ANY_ELEMENT_NAME.equals(localName);
+ }
+
+ public MatcherType getType() {
+ return MatcherType.ELEMENT;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.wst.xml.search.core.xpath.matcher.IXPathNodeMatcher#match
+ * (org.w3c.dom.Node, java.util.Collection)
+ */
+ public boolean match(Node testNode, Collection<String> wildcardValues) {
+ // test match for element name.
+ if (!matchElement(testNode)) {
+ return false;
+ }
+ // element name is matched, test match for element attributes.
+ return matchAttributes(testNode, wildcardValues);
+ }
+
+ /**
+ * Returns true if element (name) is matched and false otherwise.
+ *
+ * @param testNode
+ * @return
+ */
+ private boolean matchElement(Node testNode) {
+ String LocalName = testNode.getLocalName();
+ if (LocalName == null) {
+ LocalName = testNode.getNodeName();
+ }
+ return matchElement(LocalName);
+ }
+
+ /**
+ * Returns true if element name is matched and false otherwise.
+ *
+ * @param testNode
+ * @return
+ */
+ private boolean matchElement(String localName) {
+ if (anyElementName) {
+ // any (//) is defined, element is matched.
+ return true;
+ }
+ // test if element name of teh element match the element name matcher.
+ return this.localName.equals(localName);
+ }
+
+ /**
+ * Returns true if attributes of the element match the list of attribute
+ * matcher.
+ *
+ * @param testNode
+ * @param wildcardValues
+ * @return
+ */
+ private boolean matchAttributes(Node testNode,
+ Collection<String> wildcardValues) {
+ if (attributes == null) {
+ // No attributes matcher defined, match is OK.
+ return true;
+ }
+ // Loop for each attributes matcher
+ for (XPathAttributeMatcher attribute : attributes) {
+ if (!attribute.match(testNode, wildcardValues)) {
+ // on eattribuete is not matched.
+ return false;
+ }
+ }
+ // teh whole attributes are matched.
+ return true;
+ }
+
+ /**
+ * Returns the prefix.
+ *
+ * @return
+ */
+ public String getPrefix() {
+ return prefix;
+ }
+
+ /**
+ * Returns the element name to match.
+ *
+ * @return
+ */
+ public String getLocalName() {
+ return localName;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.wst.xml.search.core.xpath.matcher.IXPathNodeMatcher#isAny()
+ */
+ public boolean isAny() {
+ return anyElementName;
+ }
+
+ /**
+ * Add XPath attribute matcher.
+ *
+ * @param matcher
+ */
+ public void add(XPathAttributeMatcher matcher) {
+ if (attributes == null) {
+ attributes = new ArrayList<XPathAttributeMatcher>();
+ }
+ attributes.add(matcher);
+
+ }
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/xpath/matcher/XPathMatcher.java b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/xpath/matcher/XPathMatcher.java
new file mode 100644
index 0000000..8b03ced
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.core/src/org/eclipse/wst/xml/search/core/xpath/matcher/XPathMatcher.java
@@ -0,0 +1,323 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.core.xpath.matcher;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.wst.xml.search.core.util.StringUtils;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Node;
+import org.w3c.dom.Text;
+
+/**
+ *
+ * XPath matcher is used to match if a DOM Node match a XPath expression. It is
+ * initialized with an XPath expression :
+ *
+ * <ul>
+ * <li>static expression like //element</li>
+ * <li>expression with wildcard like //element[@id='$0']</li>
+ * </ul>
+ *
+ */
+public class XPathMatcher extends ArrayList<XPathElementMatcher> {
+
+ private static final long serialVersionUID = 3057263917768550928L;
+
+ private int nbWildCard = -1;
+
+ /**
+ * Constructor of XPath Matcher with a XPath expression.
+ *
+ * @param xpathExpression
+ */
+ public XPathMatcher(String xpathExpression) {
+ // initialize XPath Matcher with XPath expression.
+ parse(xpathExpression);
+ }
+
+ /**
+ * Parse the given XPath expression.
+ *
+ * @param xpathExpression
+ * XPath expression.
+ */
+ private void parse(String xpathExpression) {
+ String prefix = null;
+ String localName = null;
+ if (xpathExpression.startsWith("/")) {
+ xpathExpression = xpathExpression.substring(1,
+ xpathExpression.length());
+ }
+ boolean endsWithAny = false;
+ if (xpathExpression.endsWith("//")) {
+ endsWithAny = true;
+ xpathExpression = xpathExpression.substring(0,
+ xpathExpression.length() - 2);
+ }
+ XPathElementMatcher elementmatcher = null;
+ String[] paths = xpathExpression.split("/");
+ for (int i = 0; i < paths.length; i++) {
+ localName = paths[i];
+ if (StringUtils.isEmpty(localName)) {
+ this.createElementMatcher();
+ } else {
+ int indexNS = localName.indexOf(':');
+ if (indexNS != -1) {
+ prefix = localName.substring(0, indexNS);
+ localName = localName.substring(indexNS + 1,
+ localName.length());
+ }
+ int indexSquareBracket = localName.indexOf("[");
+ if (indexSquareBracket == -1) {
+ // Element name condition
+ // ex : p=pipeline
+ this.createElementMatcher(prefix, localName);
+ } else {
+ // ex : p=transformer[@type='pipeline'][@src='p1']
+ String elementName = localName.substring(0,
+ indexSquareBracket);
+ elementmatcher = this.createElementMatcher(prefix,
+ elementName);
+
+ String attributesCondition = localName.substring(
+ indexSquareBracket, localName.length());
+ // ex : attributesCondition=[@type='pipeline'][@src='p1']
+
+ char c;
+ StringBuilder attrName = null;
+ StringBuilder attrValue = null;
+ boolean firstQuote = false;
+ boolean attrCondition = false;
+ char[] chars = attributesCondition.toCharArray();
+ for (int j = 0; j < chars.length; j++) {
+ c = chars[j];
+ if (attrName == null) {
+ if (c == '[' || /* c == '@' || */c == ']') {
+ continue;
+ }
+ attrName = new StringBuilder();
+ attrName.append(c);
+ attrCondition = (c == '@');
+ } else {
+ if (attrValue == null) {
+ if (c != '=') {
+ attrName.append(c);
+ } else {
+ attrValue = new StringBuilder();
+ }
+ } else {
+ if (c == '\'') {
+ if (!firstQuote) {
+ firstQuote = true;
+ continue;
+ } else {
+ // second quote, add attribute name
+ // condition
+ if (attrCondition) {
+ XPathAttributeMatcher attributematcher = this
+ .createAttributeMatcher(
+ elementmatcher,
+ attrName.toString()
+ .substring(
+ 1,
+ attrName.length()),
+ attrValue
+ .toString());
+ if (attributematcher.hasWildcard()) {
+ int index = attributematcher
+ .getIndexWildcard();
+ if (index > nbWildCard) {
+ nbWildCard = index;
+ }
+ }
+ }
+ attrName = null;
+ attrValue = null;
+ firstQuote = false;
+ attrCondition = false;
+ }
+ } else {
+ attrValue.append(c);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ if (endsWithAny) {
+ this.createElementMatcher();
+ }
+ }
+
+ /**
+ * Returns true if the given DOM Node match the XPath expression of this
+ * XPath matcher and false otherwise.
+ *
+ * @param node
+ * the DOM Node to match.
+ * @return
+ */
+ public boolean match(final Node node) {
+ return match(node, null);
+ }
+
+ /**
+ * Returns true if the given DOM Node match the XPath expression of this
+ * XPath matcher and false otherwise. This method use wilcard values if
+ * XPath expression contains wildcard (like [@id='$0'].
+ *
+ * @param node
+ * the DOM Node to match.
+ * @param wildcardValues
+ * the list of wildcard values and null otherwise.
+ * @return
+ */
+ public boolean match(final Node node,
+ final Collection<String> wildcardValues) {
+ if (node == null) {
+ return false;
+ }
+ Node testNode = node;
+ XPathElementMatcher condition = null;
+ for (int i = super.size() - 1; i >= 0; i--) {
+ condition = super.get(i);
+ if (condition.isAny()) {
+ if (i > 0) {
+ boolean previousConditionFounded = false;
+ XPathElementMatcher previousElementCondition = super
+ .get(i - 1);
+ if (previousElementCondition == null) {
+ return true;
+ }
+ while (testNode != null
+ && testNode.getNodeType() != Node.DOCUMENT_NODE) {
+ if (previousElementCondition.match(testNode,
+ wildcardValues)) {
+ previousConditionFounded = true;
+ break;
+ }
+ testNode = testNode.getParentNode();
+ }
+
+ if (!previousConditionFounded) {
+ return false;
+ } else {
+ i--;
+ }
+
+ } else {
+ return true;
+ }
+ } else {
+ if (!condition.match(testNode, wildcardValues)) {
+ return false;
+ }
+ }
+ testNode = testNode.getParentNode();
+ }
+ return true;
+ }
+
+ /**
+ * Returns list of wildcard values of the given DOM Node.
+ *
+ * @param selectedNode
+ * @return
+ */
+ public List<String> getWildcardValues(Node selectedNode) {
+ List<String> wildcardValues = new ArrayList<String>();
+ if (nbWildCard == -1 || selectedNode == null) {
+ // No wildcard in the XPath expression of this matcher or DOM node
+ // is null
+ return wildcardValues;
+ }
+ Node testNode = getTestNode(selectedNode);
+ match(testNode, wildcardValues);
+ return wildcardValues;
+ }
+
+ /**
+ * Returns the DOM Node to test to match.
+ *
+ * @param node
+ * @return
+ */
+ private Node getTestNode(Node node) {
+ short nodeType = node.getNodeType();
+ switch (nodeType) {
+ case Node.ATTRIBUTE_NODE:
+ return ((Attr) node).getOwnerElement();
+ case Node.TEXT_NODE:
+ return ((Text) node).getParentNode();
+ }
+ return node;
+ }
+
+ /**
+ * Returns the number of wilcard used in the XPath expression and -1 if
+ * there is no wildcard.
+ *
+ * @return
+ */
+ public int getNbWildCard() {
+ return nbWildCard;
+ }
+
+ // ------------ XPath node matcher factory.
+
+ /***
+ * Create XPath element matcher.
+ *
+ * @param elementName
+ * @return
+ */
+ protected XPathElementMatcher createElementMatcher(String prefix,
+ String localName) {
+ XPathElementMatcher matcher = new XPathElementMatcher(prefix,
+ localName, this);
+ super.add(matcher);
+ return matcher;
+ }
+
+ /**
+ * Create XPath any element matcher.
+ *
+ * @return
+ */
+ protected XPathElementMatcher createElementMatcher() {
+ XPathElementMatcher matcher = new XPathElementMatcher(null,
+ XPathElementMatcher.ANY_ELEMENT_NAME, this);
+ super.add(matcher);
+ return matcher;
+ }
+
+ /**
+ * Create XPath attribute matcher.
+ *
+ * @param elementmatcher
+ * @param attrName
+ * @param attrValue
+ * @return
+ */
+ protected XPathAttributeMatcher createAttributeMatcher(
+ XPathElementMatcher elementmatcher, String attrName,
+ String attrValue) {
+ XPathAttributeMatcher matcher = new XPathAttributeMatcher(attrName,
+ attrValue, this);
+ elementmatcher.add(matcher);
+ return matcher;
+ }
+
+}
diff --git a/plugins/org.eclipse.wst.xml.search.editor/.classpath b/plugins/org.eclipse.wst.xml.search.editor/.classpath
new file mode 100644
index 0000000..2d1a430
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.editor/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.wst.xml.search.editor/.options b/plugins/org.eclipse.wst.xml.search.editor/.options
new file mode 100644
index 0000000..6950726
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.editor/.options
@@ -0,0 +1,4 @@
+org.eclipse.wst.xml.search.editor/debug/reporter=false
+org.eclipse.wst.xml.search.editor/debug/validator=false
+org.eclipse.wst.xml.search.editor/debug/indexmanager=false
+org.eclipse.wst.xml.search.editor/debug/search=false
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.xml.search.editor/.project b/plugins/org.eclipse.wst.xml.search.editor/.project
new file mode 100644
index 0000000..fe01790
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.editor/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.wst.xml.search.editor</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.wst.xml.search.editor/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.wst.xml.search.editor/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..3e9f6bb
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.editor/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+#Wed Nov 24 15:00:56 CET 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/plugins/org.eclipse.wst.xml.search.editor/META-INF/MANIFEST.MF b/plugins/org.eclipse.wst.xml.search.editor/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..e1c3af0
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.editor/META-INF/MANIFEST.MF
@@ -0,0 +1,47 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-Vendor: %providerName
+Bundle-Localization: plugin
+Bundle-SymbolicName: org.eclipse.wst.xml.search.editor;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.eclipse.wst.xml.search.editor.internal.XMLSearchEditorPlugin
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.jface.text,
+ org.eclipse.wst.sse.core,
+ org.eclipse.wst.xml.core,
+ org.eclipse.wst.xml.ui,
+ org.eclipse.wst.sse.ui,
+ org.eclipse.wst.xml.search.core;bundle-version="1.0.0",
+ org.eclipse.wst.xml.search.ui;bundle-version="1.0.0",
+ org.eclipse.core.resources,
+ org.eclipse.ui.ide,
+ org.eclipse.wst.validation,
+ org.eclipse.jdt.core,
+ org.eclipse.jdt.ui,
+ org.eclipse.search
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Export-Package: org.eclipse.wst.xml.search.editor,
+ org.eclipse.wst.xml.search.editor.contentassist,
+ org.eclipse.wst.xml.search.editor.hover,
+ org.eclipse.wst.xml.search.editor.hyperlink,
+ org.eclipse.wst.xml.search.editor.java,
+ org.eclipse.wst.xml.search.editor.queryspecifications,
+ org.eclipse.wst.xml.search.editor.queryspecifications.visitor,
+ org.eclipse.wst.xml.search.editor.references,
+ org.eclipse.wst.xml.search.editor.references.filters,
+ org.eclipse.wst.xml.search.editor.references.validators,
+ org.eclipse.wst.xml.search.editor.searchers,
+ org.eclipse.wst.xml.search.editor.searchers.expressions,
+ org.eclipse.wst.xml.search.editor.searchers.java,
+ org.eclipse.wst.xml.search.editor.searchers.javamethod,
+ org.eclipse.wst.xml.search.editor.searchers.javamethod.classnameprovider,
+ org.eclipse.wst.xml.search.editor.searchers.javamethod.requestor,
+ org.eclipse.wst.xml.search.editor.searchers.resource,
+ org.eclipse.wst.xml.search.editor.searchers.statics,
+ org.eclipse.wst.xml.search.editor.searchers.xml,
+ org.eclipse.wst.xml.search.editor.statics,
+ org.eclipse.wst.xml.search.editor.util,
+ org.eclipse.wst.xml.search.editor.validation
diff --git a/plugins/org.eclipse.wst.xml.search.editor/build.properties b/plugins/org.eclipse.wst.xml.search.editor/build.properties
new file mode 100644
index 0000000..1cb217c
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.editor/build.properties
@@ -0,0 +1,7 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.properties,\
+ plugin.xml,\
+ icons/
diff --git a/plugins/org.eclipse.wst.xml.search.editor/icons/obj16/property_obj.gif b/plugins/org.eclipse.wst.xml.search.editor/icons/obj16/property_obj.gif
new file mode 100644
index 0000000..fdde5fb
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.editor/icons/obj16/property_obj.gif
Binary files differ
diff --git a/plugins/org.eclipse.wst.xml.search.editor/plugin.properties b/plugins/org.eclipse.wst.xml.search.editor/plugin.properties
new file mode 100644
index 0000000..8e2ca7a
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.editor/plugin.properties
@@ -0,0 +1,38 @@
+###############################################################################
+# Copyright (c) 2010 Angelo Zerr 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:
+# Angelo Zerr <angelo.zerr@gmail.com> - Initial API and implementation
+###############################################################################
+pluginName=WST XML Search Editor
+providerName=Angelo ZERR
+
+# Extension Point
+referencesContributionName=XML references contribution.
+contentAssistsContributionName=XML content assists contribution.
+searchersContributionName=XML searchers contribution.
+referenceValidatorsContributionName=XML reference validators.
+referenceFiltersContributionName=XML reference filters.
+javaQuerySpecificationsContributionName=Java query specification contribution.
+javaMethodQuerySpecificationsContributionName=Java method query specification contribution.
+expressionParsersContributionName=XML Expression parser.
+javaReferencesContributionName=Java references contribution.
+javaReferencesMatchersContributionName=Java references matchers contribution.
+
+# JDT search particpant
+queryParticipant.name.0=XML Search Java Search Participant
+
+#--- Search menu
+ActionDefinition.referencesInContainer.name= References in Container
+ActionDefinition.referencesInContainer.description= Search for references to the selected element in the container
+
+XMLReferencesBatchValidator_description= XML References Validator
+_validationMarker.name=XML References Problem
+
+# XML search Editor preferences page
+XML_Source.name=Editor
+XML_Syntax_Coloring=Syntax Coloring
diff --git a/plugins/org.eclipse.wst.xml.search.editor/plugin.xml b/plugins/org.eclipse.wst.xml.search.editor/plugin.xml
new file mode 100644
index 0000000..7667f7c
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.editor/plugin.xml
@@ -0,0 +1,232 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+
+ <extension-point id="xmlReferences" name="%referencesContributionName"
+ schema="schema/xml2x/xmlReferences.exsd" />
+ <extension-point id="referenceFilters" name="%referenceFiltersContributionName"
+ schema="schema/referenceFilters.exsd" />
+ <extension-point id="referenceValidators" name="%referenceValidatorsContributionName"
+ schema="schema/referenceValidators.exsd" />
+ <extension-point id="contentAssists" name="%contentAssistsContributionName"
+ schema="schema/contentAssists.exsd" />
+ <extension-point id="searchers" name="%searchersContributionName"
+ schema="schema/searchers.exsd" />
+ <extension-point id="javaQuerySpecifications" name="%javaQuerySpecificationsContributionName"
+ schema="schema/javaQuerySpecifications.exsd" />
+ <extension-point id="javaMethodQuerySpecifications" name="%javaMethodQuerySpecificationsContributionName"
+ schema="schema/javaMethodQuerySpecifications.exsd" />
+ <extension-point id="expressionParsers" name="%expressionParsersContributionName"
+ schema="schema/expressionParsers.exsd" />
+ <extension-point id="javaReferences" name="%javaReferencesContributionName"
+ schema="schema/javaReferences.exsd" />
+ <extension-point id="javaReferencesMatchers" name="%javaReferencesMatchersContributionName"
+ schema="schema/javaReferencesMatchers.exsd" />
+
+ <extension
+ point="org.eclipse.wst.xml.search.editor.expressionParsers">
+ <parser
+ id="org.eclipse.wst.xml.search.editor.expressions.multiattrvalues"
+ class="org.eclipse.wst.xml.search.editor.searchers.expressions.MultiAttrValuesExpressionParser" >
+ </parser>
+ </extension>
+
+ <extension
+ point="org.eclipse.jdt.ui.queryParticipants">
+ <queryParticipant
+ class="org.eclipse.wst.xml.search.editor.internal.jdt.search.XMLReferenceJavaSearchParticipant"
+ id="org.eclipse.wst.xml.search.editor.jdt.search.ClassSearchParticipant"
+ name="%queryParticipant.name.0"
+ nature="org.eclipse.jdt.core.javanature"/>
+ </extension>
+
+ <extension
+ point="org.eclipse.wst.xml.search.editor.searchers">
+ <searcher
+ id="org.eclipse.wst.xml.search.editor.searcher.resource"
+ class="org.eclipse.wst.xml.search.editor.searchers.resource.XMLSearcherForResource" >
+ </searcher>
+ <searcher
+ id="org.eclipse.wst.xml.search.editor.searcher.java"
+ class="org.eclipse.wst.xml.search.editor.searchers.java.XMLSearcherForJava" >
+ </searcher>
+ <searcher
+ id="org.eclipse.wst.xml.search.editor.searcher.javamethod"
+ class="org.eclipse.wst.xml.search.editor.searchers.javamethod.XMLSearcherForJavaMethod" >
+ </searcher>
+ <searcher
+ id="org.eclipse.wst.xml.search.editor.searcher.properties"
+ class="org.eclipse.wst.xml.search.editor.searchers.properties.XMLSearcherForProperties" >
+ </searcher>
+ <searcher
+ id="org.eclipse.wst.xml.search.editor.searcher.statics"
+ class="org.eclipse.wst.xml.search.editor.searchers.statics.XMLSearcherForStatic" >
+ </searcher>
+ <searcher
+ id="org.eclipse.wst.xml.search.editor.searcher.xml"
+ class="org.eclipse.wst.xml.search.editor.searchers.xml.XMLSearcherForXML" >
+ </searcher>
+ <searcher
+ id="org.eclipse.wst.xml.search.editor.searcher.expression"
+ class="org.eclipse.wst.xml.search.editor.searchers.expressions.XMLSearcherForExpression" >
+ </searcher>
+ </extension>
+
+ <extension
+ point="org.eclipse.wst.xml.search.editor.referenceValidators">
+ <validator
+ id="org.eclipse.wst.xml.search.editor.referenceValidators.default"
+ class="org.eclipse.wst.xml.search.editor.references.validators.DefaultDOMNodeValidator" >
+ </validator>
+ </extension>
+
+ <extension point="org.eclipse.ui.commands">
+ <command
+ name="%ActionDefinition.referencesInContainer.name"
+ description="%ActionDefinition.referencesInContainer.description"
+ categoryId="org.eclipse.search.ui.category.search"
+ id="org.eclipse.wst.xml.search.references.in.container">
+ </command>
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.handlers">
+ <handler
+ class="org.eclipse.wst.xml.search.editor.internal.handlers.ReferencesInContainerHandler"
+ commandId="org.eclipse.wst.xml.search.references.in.container">
+ </handler>
+ </extension>
+
+ <!--<extension point="org.eclipse.ui.menus">
+ <menuContribution
+ locationURI="popup:sourcePopupMenuId?after=sourceBegin">
+ <command
+ commandId="org.eclipse.wst.xml.search.references.in.container"
+ id="ReferencesInContainer"
+ style="push">
+ <visibleWhen checkEnabled="false">
+ <reference definitionId="org.eclipse.wst.sse.ui.sseActiveContext.definition"></reference>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ </extension>-->
+
+ <extension
+ point="org.eclipse.ui.bindings">
+ <!-- win32: M1=CTRL, M2=SHIFT, M3=ALT, M4=-
+ carbon: M1=COMMAND, M2=SHIFT, M3=ALT, M4=CTRL -->
+
+<!-- search -->
+ <key
+ sequence="M1+M2+G"
+ contextId="org.eclipse.wst.sse.ui.structuredTextEditorScope"
+ commandId="org.eclipse.wst.xml.search.references.in.container"
+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+ </extension>
+
+ <!-- XML references batch validator -->
+
+ <extension
+ id="validationMarker"
+ name="%_validationMarker.name"
+ point="org.eclipse.core.resources.markers">
+ <super type="org.eclipse.wst.validation.problemmarker"/>
+ <persistent value="true"/>
+ </extension>
+
+ <extension id="xmlReferncesBatchValidator" name="%XMLReferencesBatchValidator_description" point="org.eclipse.wst.validation.validatorV2">
+ <validator
+ build="true"
+ class="org.eclipse.wst.xml.search.editor.validation.XMLReferencesBatchValidator"
+ manual="true"
+ version="1"
+ markerId="org.eclipse.wst.xml.search.editor.validationMarker">
+ <include>
+ <rules>
+ <fileext
+ caseSensitive="false"
+ ext="xml">
+ </fileext>
+ </rules>
+ </include>
+ <exclude>
+ <rules>
+ <projectNature id="org.eclipse.jst.j2ee.ejb.EJBNature"/>
+ <projectNature id="org.eclipse.jst.j2ee.EARNature"/>
+ <file caseSensitive="true" name=".project" type="file"/>
+ <file caseSensitive="true" name=".classpath" type="file"/>
+ <file caseSensitive="true" name=".settings" type="folder"/>
+ </rules>
+ </exclude>
+ </validator>
+ </extension>
+
+ <!-- initialize xml search editor preferences -->
+ <extension point="org.eclipse.core.runtime.preferences">
+ <initializer
+ class="org.eclipse.wst.xml.search.editor.internal.preferences.XMLSearchEditorPreferenceInitializer" />
+ </extension>
+
+ <extension point="org.eclipse.ui.preferencePages">
+ <page
+ name="%XML_Source.name"
+ category="org.eclipse.wst.xml.search.references"
+ class="org.eclipse.wst.xml.search.editor.internal.preferences.XMLSourcePreferencePage"
+ id="org.eclipse.wst.xml.search.editor.source">
+ </page>
+ <page category="org.eclipse.wst.xml.search.editor.source"
+ class="org.eclipse.wst.xml.search.editor.internal.preferences.XMLReferencesSyntaxColoringPage"
+ id="org.eclipse.wst.xml.search.editor.internal.preferences.XMLReferencesSyntaxColoringPage"
+ name="%XML_Syntax_Coloring">
+ </page>
+ </extension>
+
+<!-- Define theme -->
+ <extension
+ point="org.eclipse.ui.themes">
+ <theme
+ id="org.eclipse.ui.ide.systemDefault">
+ <colorOverride
+ id="tagReferencedAttributeValue"
+ value="COLOR_LIST_FOREGROUND">
+ </colorOverride>
+ </theme>
+ <colorDefinition
+ id="tagReferencedAttributeValue"
+ isEditable="false"
+ label="%Colors.tagAttributeValue"
+ value="42, 0, 255">
+ </colorDefinition>
+ </extension>
+
+ <extension point="org.eclipse.jdt.ui.javaCompletionProposalComputer"
+ id="SearchJavaNoTypeCompletionProposalComputer"
+ name="SearchJavaNoTypeCompletionProposalComputer">
+ <proposalCategory
+ icon="jdt_search.png"
+ id="org.eclipse.jdt.search.editor"
+ name="JDT Search" />
+ <javaCompletionProposalComputer
+ class="org.eclipse.wst.xml.search.editor.internal.jdt.search2.SearchJavaNoTypeCompletionProposalComputer"
+ categoryId="org.eclipse.jdt.search.editor">
+ <partition type="__java_string"/>
+ </javaCompletionProposalComputer>
+ </extension>
+
+ <extension point="org.eclipse.ui.workbench.texteditor.hyperlinkDetectors">
+ <hyperlinkDetector
+ class="org.eclipse.wst.xml.search.editor.java.hyperlink.Java2XHyperLinkDetectetor"
+ id="org.eclipse.wst.xml.search.editor.java.hyperlink.Java2XHyperLinkDetectetor"
+ name="WTP/XML Search - Java Hyperlinker"
+ targetId="org.eclipse.jdt.ui.javaCode">
+ </hyperlinkDetector>
+ </extension>
+
+ <extension point="org.eclipse.jdt.ui.javaEditorTextHovers">
+ <hover
+ class="org.eclipse.wst.xml.search.editor.java.hover.Java2XHover"
+ id="org.eclipse.wst.xml.search.editor.java.hover.Java2XHover"
+ label="WTP/XML Search - Java Hover"/>
+ </extension>
+
+</plugin>
diff --git a/plugins/org.eclipse.wst.xml.search.editor/schema/contentAssists.exsd b/plugins/org.eclipse.wst.xml.search.editor/schema/contentAssists.exsd
new file mode 100644
index 0000000..728da94
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.editor/schema/contentAssists.exsd
@@ -0,0 +1,92 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.wst.xml.search.editor" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.wst.xml.search.editor" id="contentAssisits" name="XML Editor Content Assist Contribution"/>
+ </appinfo>
+ <documentation>
+ Extension point for provide XML Editor Content Assist.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="additionalProposalInfoProvider" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+ a fully-qualified name of the target extension point
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ an optional id
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ an optional name
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="additionalProposalInfoProvider">
+ <complexType>
+ <sequence>
+ </sequence>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.wst.xml.search.editor.contentassist.IContentAssistAdditionalProposalInfoProvider"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ 2.0
+ </documentation>
+ </annotation>
+
+
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ This plugin itself does not have any predefined builders.
+ </documentation>
+ </annotation>
+
+
+</schema>
diff --git a/plugins/org.eclipse.wst.xml.search.editor/schema/expressionParsers.exsd b/plugins/org.eclipse.wst.xml.search.editor/schema/expressionParsers.exsd
new file mode 100644
index 0000000..24e10b8
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.editor/schema/expressionParsers.exsd
@@ -0,0 +1,90 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.wst.xml.search.editor" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.wst.xml.search.editor" id="expressionParsers" name="XML Editor parsers Contribution"/>
+ </appinfo>
+ <documentation>
+ Extension point for provide XML Parsers.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="parser" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+ a fully-qualified name of the target extension point
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ an optional id
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ an optional name
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="parser">
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.wst.xml.search.editor.parsers.IXMLExpressionParser"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ 2.0
+ </documentation>
+ </annotation>
+
+
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ This plugin itself does not have any predefined builders.
+ </documentation>
+ </annotation>
+
+
+</schema>
diff --git a/plugins/org.eclipse.wst.xml.search.editor/schema/javaMethodQuerySpecifications.exsd b/plugins/org.eclipse.wst.xml.search.editor/schema/javaMethodQuerySpecifications.exsd
new file mode 100644
index 0000000..080eda8
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.editor/schema/javaMethodQuerySpecifications.exsd
@@ -0,0 +1,92 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.wst.xml.search.editor" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.wst.xml.search.editor" id="javaMethodQuerySpecifications" name="XML Editor Java Method Query specification Contribution"/>
+ </appinfo>
+ <documentation>
+ Extension point for provide XML Editor Java Method Query specification.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="querySpecification" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+ a fully-qualified name of the target extension point
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ an optional id
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ an optional name
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="querySpecification">
+ <complexType>
+ <sequence>
+ </sequence>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <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>
+ 2.0
+ </documentation>
+ </annotation>
+
+
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ This plugin itself does not have any predefined builders.
+ </documentation>
+ </annotation>
+
+
+</schema>
diff --git a/plugins/org.eclipse.wst.xml.search.editor/schema/javaQuerySpecifications.exsd b/plugins/org.eclipse.wst.xml.search.editor/schema/javaQuerySpecifications.exsd
new file mode 100644
index 0000000..92b77d0
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.editor/schema/javaQuerySpecifications.exsd
@@ -0,0 +1,92 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.wst.xml.search.editor" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.wst.xml.search.editor" id="javaQuerySpecifications" name="XML Editor Java Query specification Contribution"/>
+ </appinfo>
+ <documentation>
+ Extension point for provide XML Editor Java Query specification.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="querySpecification" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+ a fully-qualified name of the target extension point
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ an optional id
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ an optional name
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="querySpecification">
+ <complexType>
+ <sequence>
+ </sequence>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <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>
+ 2.0
+ </documentation>
+ </annotation>
+
+
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ This plugin itself does not have any predefined builders.
+ </documentation>
+ </annotation>
+
+
+</schema>
diff --git a/plugins/org.eclipse.wst.xml.search.editor/schema/javaReferences.exsd b/plugins/org.eclipse.wst.xml.search.editor/schema/javaReferences.exsd
new file mode 100644
index 0000000..dfdb53e
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.editor/schema/javaReferences.exsd
@@ -0,0 +1,427 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.wst.xml.search.editor" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.wst.xml.search.editor" id="javaReferences" name="Java Reference Contribution"/>
+ </appinfo>
+ <documentation>
+ Extension point for provide Java Reference Node.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="references" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+ a fully-qualified name of the target extension point
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ an optional id
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ an optional name
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="references">
+ <complexType>
+ <sequence>
+ <element ref="reference" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="reference">
+ <complexType>
+ <sequence>
+ <element ref="from"/>
+ <element ref="to" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="toJava" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="toJavaMethod" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="toProperty" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="toResource" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="toStatic" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="parserId" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.wst.xml.search.editor.expressionParsers/parser/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="searcherId" type="string" use="default" value="org.eclipse.wst.xml.search.editor.searcher.expression">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.wst.xml.search.editor.searchers/searchers/searcher/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="from">
+ <complexType>
+ <attribute name="matcherId" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.wst.xml.search.editor.javaReferencesMatchers/matcher/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="to">
+ <complexType>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="searcherId" type="string" use="default" value="org.eclipse.wst.xml.search.editor.searcher.xml">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.wst.xml.search.editor.searchers/searchers/searcher/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="path" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="targetNodes" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="querySpecificationId" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.wst.xml.search.core.querySpecifications/querySpecification/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="additionalProposalInfoProviderId" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.wst.xml.search.editor.contentAssists/additionalProposalInfoProvider/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="tokenId" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="namespacesId" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.wst.xml.search.core.namespaces/namespaces/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="toJava">
+ <complexType>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="searcherId" type="string" use="default" value="org.eclipse.wst.xml.search.editor.searcher.java">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.wst.xml.search.editor.searchers/searchers/searcher/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="querySpecificationId" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.wst.xml.search.editor.javaQuerySpecifications/querySpecification/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="extends" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="tokenId" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="toJavaMethod">
+ <complexType>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="pathForClass" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="querySpecificationId" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.wst.xml.search.editor.javaMethodQuerySpecifications/querySpecification/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="searcherId" type="string" use="default" value="org.eclipse.wst.xml.search.editor.searcher.javamethod">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.wst.xml.search.editor.searchers/searchers/searcher/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="tokenId" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="toProperty">
+ <complexType>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="searcherId" type="string" use="default" value="org.eclipse.wst.xml.search.editor.searcher.properties">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.wst.xml.search.editor.searchers/searchers/searcher/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="querySpecificationId" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.wst.xml.search.core.propertiesQuerySpecifications/querySpecification/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="tokenId" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="toResource">
+ <complexType>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="searcherId" type="string" use="default" value="org.eclipse.wst.xml.search.editor.searcher.resource">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.wst.xml.search.editor.searchers/searchers/searcher/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="querySpecificationId" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.wst.xml.search.core.resourceQuerySpecifications/querySpecification/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="additionalProposalInfoProviderId" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.wst.xml.search.editor.contentAssists/additionalProposalInfoProvider/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="tokenId" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="toStatic">
+ <complexType>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="searcherId" type="string" use="default" value="org.eclipse.wst.xml.search.editor.searcher.statics">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.wst.xml.search.editor.searchers/searchers/searcher/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="querySpecificationId" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.wst.xml.search.core.staticValueQuerySpecifications/querySpecification/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="additionalProposalInfoProviderId" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.wst.xml.search.editor.contentAssists/additionalProposalInfoProvider/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="tokenId" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ 2.0
+ </documentation>
+ </annotation>
+
+
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ This plugin itself does not have any predefined builders.
+ </documentation>
+ </annotation>
+
+
+</schema>
diff --git a/plugins/org.eclipse.wst.xml.search.editor/schema/javaReferencesMatchers.exsd b/plugins/org.eclipse.wst.xml.search.editor/schema/javaReferencesMatchers.exsd
new file mode 100644
index 0000000..51e483a
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.editor/schema/javaReferencesMatchers.exsd
@@ -0,0 +1,92 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.wst.xml.search.editor" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.wst.xml.search.editor" id="javaReferencesMatchers" name="Java References Matchers Contribution"/>
+ </appinfo>
+ <documentation>
+ Extension point for provide Java Matchers.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="matcher" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+ a fully-qualified name of the target extension point
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ an optional id
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ an optional name
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="matcher">
+ <complexType>
+ <sequence>
+ </sequence>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.wst.xml.search.editor.java.IJavaElementMatcher"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ 2.0
+ </documentation>
+ </annotation>
+
+
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ This plugin itself does not have any predefined builders.
+ </documentation>
+ </annotation>
+
+
+</schema>
diff --git a/plugins/org.eclipse.wst.xml.search.editor/schema/referenceFilters.exsd b/plugins/org.eclipse.wst.xml.search.editor/schema/referenceFilters.exsd
new file mode 100644
index 0000000..864fb09
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.editor/schema/referenceFilters.exsd
@@ -0,0 +1,90 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.wst.xml.search.editor" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.wst.xml.search.editor" id="referenceFilters" name="XML Editor Filters Contribution"/>
+ </appinfo>
+ <documentation>
+ Extension point for provide XML Reference Filters.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="filter" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+ a fully-qualified name of the target extension point
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ an optional id
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ an optional name
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="filter">
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.wst.xml.search.editor.references.filter.IXMLReferenceFilter"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ 2.0
+ </documentation>
+ </annotation>
+
+
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ This plugin itself does not have any predefined builders.
+ </documentation>
+ </annotation>
+
+
+</schema>
diff --git a/plugins/org.eclipse.wst.xml.search.editor/schema/referenceValidators.exsd b/plugins/org.eclipse.wst.xml.search.editor/schema/referenceValidators.exsd
new file mode 100644
index 0000000..c74e6b4
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.editor/schema/referenceValidators.exsd
@@ -0,0 +1,90 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.wst.xml.search.editor" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.wst.xml.search.editor" id="referenceValidators" name="XML Reference Editor Validators Contribution"/>
+ </appinfo>
+ <documentation>
+ Extension point for provide XML Reference Validators.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="validator" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+ a fully-qualified name of the target extension point
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ an optional id
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ an optional name
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="validator">
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.wst.xml.search.editor.references.validators.IXMLReferenceValidator"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ 2.0
+ </documentation>
+ </annotation>
+
+
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ This plugin itself does not have any predefined builders.
+ </documentation>
+ </annotation>
+
+
+</schema>
diff --git a/plugins/org.eclipse.wst.xml.search.editor/schema/searchers.exsd b/plugins/org.eclipse.wst.xml.search.editor/schema/searchers.exsd
new file mode 100644
index 0000000..8988b6b
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.editor/schema/searchers.exsd
@@ -0,0 +1,90 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.wst.xml.search.editor" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.wst.xml.search.editor" id="searchers" name="XML Editor Searchers Contribution"/>
+ </appinfo>
+ <documentation>
+ Extension point for provide XML Editor Searchers.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="searcher" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+ a fully-qualified name of the target extension point
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ an optional id
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ an optional name
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="searcher">
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.wst.xml.search.editor.searchers.IXMLSearcher"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ 2.0
+ </documentation>
+ </annotation>
+
+
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ This plugin itself does not have any predefined builders.
+ </documentation>
+ </annotation>
+
+
+</schema>
diff --git a/plugins/org.eclipse.wst.xml.search.editor/schema/xml2x/xmlReferences.exsd b/plugins/org.eclipse.wst.xml.search.editor/schema/xml2x/xmlReferences.exsd
new file mode 100644
index 0000000..32125eb
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.editor/schema/xml2x/xmlReferences.exsd
@@ -0,0 +1,485 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.wst.xml.search.editor" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.wst.xml.search.editor" id="xmlReferences" name="XML References Contribution"/>
+ </appinfo>
+ <documentation>
+ Extension point for provide XML References Node.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="references" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+ a fully-qualified name of the target extension point
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ an optional id
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ an optional name
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="references">
+ <complexType>
+ <sequence>
+ <element ref="reference" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="contentTypeIds" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="xpathFactoryId" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="reference">
+ <complexType>
+ <sequence>
+ <element ref="from"/>
+ <element ref="to" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="toJava" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="toJavaMethod" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="toProperty" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="toResource" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="toStatic" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="validatorId" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.wst.xml.search.editor.referenceValidators/validator/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="parserId" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.wst.xml.search.editor.expressionParsers/parser/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="searcherId" type="string" use="default" value="org.eclipse.wst.xml.search.editor.searcher.expression">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.wst.xml.search.editor.searchers/searchers/searcher/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="from">
+ <complexType>
+ <attribute name="path" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="targetNodes" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="querySpecificationId" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.wst.xml.search.core.querySpecifications/querySpecification/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="filterId" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.wst.xml.search.editor.referenceFilters/filter/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="namespacesId" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.wst.xml.search.core.namespaces/namespaces/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="to">
+ <complexType>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="searcherId" type="string" use="default" value="org.eclipse.wst.xml.search.editor.searcher.xml">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.wst.xml.search.editor.searchers/searchers/searcher/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="path" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="targetNodes" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="querySpecificationId" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.wst.xml.search.core.querySpecifications/querySpecification/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="additionalProposalInfoProviderId" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.wst.xml.search.editor.contentAssists/additionalProposalInfoProvider/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="tokenId" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="namespacesId" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.wst.xml.search.core.namespaces/namespaces/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="toJava">
+ <complexType>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="searcherId" type="string" use="default" value="org.eclipse.wst.xml.search.editor.searcher.java">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.wst.xml.search.editor.searchers/searchers/searcher/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="querySpecificationId" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.wst.xml.search.editor.javaQuerySpecifications/querySpecification/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="extends" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="tokenId" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="toJavaMethod">
+ <complexType>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="pathForClass" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="querySpecificationId" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.wst.xml.search.editor.javaMethodQuerySpecifications/querySpecification/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="searcherId" type="string" use="default" value="org.eclipse.wst.xml.search.editor.searcher.javamethod">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.wst.xml.search.editor.searchers/searchers/searcher/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="tokenId" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="toProperty">
+ <complexType>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="searcherId" type="string" use="default" value="org.eclipse.wst.xml.search.editor.searcher.properties">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.wst.xml.search.editor.searchers/searchers/searcher/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="querySpecificationId" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.wst.xml.search.core.propertiesQuerySpecifications/querySpecification/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="tokenId" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="toResource">
+ <complexType>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="searcherId" type="string" use="default" value="org.eclipse.wst.xml.search.editor.searcher.resource">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.wst.xml.search.editor.searchers/searchers/searcher/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="querySpecificationId" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.wst.xml.search.core.resourceQuerySpecifications/querySpecification/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="additionalProposalInfoProviderId" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.wst.xml.search.editor.contentAssists/additionalProposalInfoProvider/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="tokenId" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="toStatic">
+ <complexType>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="searcherId" type="string" use="default" value="org.eclipse.wst.xml.search.editor.searcher.statics">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.wst.xml.search.editor.searchers/searchers/searcher/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="querySpecificationId" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.wst.xml.search.core.staticValueQuerySpecifications/querySpecification/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="additionalProposalInfoProviderId" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.wst.xml.search.editor.contentAssists/additionalProposalInfoProvider/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="tokenId" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ 2.0
+ </documentation>
+ </annotation>
+
+
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ This plugin itself does not have any predefined builders.
+ </documentation>
+ </annotation>
+
+
+</schema>
diff --git a/plugins/org.eclipse.wst.xml.search.editor/src/org/eclipse/wst/xml/search/editor/XMLReferencesStructuredTextViewerConfiguration.java b/plugins/org.eclipse.wst.xml.search.editor/src/org/eclipse/wst/xml/search/editor/XMLReferencesStructuredTextViewerConfiguration.java
new file mode 100644
index 0000000..ed4ff11
--- /dev/null
+++ b/plugins/org.eclipse.wst.xml.search.editor/src/org/eclipse/wst/xml/search/editor/XMLReferencesStructuredTextViewerConfiguration.java
@@ -0,0 +1,172 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Angelo ZERR.
+ * 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:
+ * Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xml.search.editor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.text.ITextHover;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.text.IStructuredPartitions;
+import org.eclipse.wst.sse.ui.internal.ExtendedConfigurationBuilder;
+import org.eclipse.wst.sse.ui.internal.SSEUIPlugin;
+import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
+import org.eclipse.wst.sse.ui.internal.provisional.style.LineStyleProvider;
+import org.eclipse.wst.sse.ui.internal.taginfo.AnnotationHoverProcessor;
+import org.eclipse.wst.sse.ui.internal.taginfo.BestMatchHover;
+import org.eclipse.wst.sse.ui.internal.taginfo.ProblemAnnotationHoverProcessor;
+import org.eclipse.wst.sse.ui.internal.taginfo.TextHoverManager;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.eclipse.wst.xml.core.text.IXMLPartitions;
+import org.eclipse.wst.xml.search.editor.hover.XMLReferencesInfoHoverProcessor;
+import org.eclipse.wst.xml.search.editor.hyperlink.XMLReferencesHyperlinkDetector;
+import org.eclipse.wst.xml.search.editor.internal.contentassist.XMLReferencesContentAssistProcessor;
+import org.eclipse.wst.xml.search.editor.internal.style.LineStyleProviderForXMLReferences;
+import org.eclipse.wst.xml.ui.StructuredTextViewerConfigurationXML;
+import org.eclipse.wst.xml.ui.internal.style.LineStyleProviderForXML;
+
+public class XMLReferencesStructuredTextViewerConfiguration extends
+ StructuredTextViewerConfigurationXML {
+
+ private static final IHyperlinkDetector[] IHYPERLINK_DETECTOR_EMPTY = new IHyperlinkDetector[0];
+
+ private LineStyleProvider fLineStyleProviderForXML;
+
+ @Override
+ public IContentAssistProcessor[] getContentAssistProcessors(
+ ISourceViewer sourceViewer, String partitionType) {
+ IContentAssistProcessor processors[];
+ if (partitionType == IStructuredPartitions.DEFAULT_PARTITION
+ || partitionType == IXMLPartitions.XML_DEFAULT)
+ processors = (new IContentAssistProcessor[] { createContentAssistProcessor() });
+ else
+ processors = super.getContentAssistProcessors(sourceViewer,
+ partitionType);
+ return processors;
+ }
+
+ @Override
+ public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
+ if (sourceViewer == null
+ || !fPreferenceStore.getBoolean("hyperlinksEnabled"))
+ return null;
+ List<IHyperlinkDetector> allDetectors = new ArrayList<IHyperlinkDetector>();
+ allDetectors.add(createHyperlinkDetector());
+ IHyperlinkDetector superDetectors[] = super
+ .getHyperlinkDetectors(sourceViewer);
+ IHyperlinkDetector aihyperlinkdetector[];
+ int j = (aihyperlinkdetector = superDetectors).length;
+ for (int i = 0; i < j; i++) {
+ IHyperlinkDetector detector = aihyperlinkdetector[i];
+ if (!allDetectors.contains(detector))
+ allDetectors.add(detector