Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcsalter2006-05-30 04:21:16 +0000
committercsalter2006-05-30 04:21:16 +0000
commit9630c31d1b40a18b863c4edb8a2c4e621ade5efc (patch)
treef34a2d6c91ac8a95b1178715870adbc75de678d0 /bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor
parent0e3ffd8420f9e66212c00b24ea21dc3da14dc4ff (diff)
downloadwebtools.sourceediting-9630c31d1b40a18b863c4edb8a2c4e621ade5efc.tar.gz
webtools.sourceediting-9630c31d1b40a18b863c4edb8a2c4e621ade5efc.tar.xz
webtools.sourceediting-9630c31d1b40a18b863c4edb8a2c4e621ade5efc.zip
[44359] XSDEditor: Type and Element selection dialogs lists each components twice
Diffstat (limited to 'bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor')
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/search/XSDElementsSearchListProvider.java195
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/search/XSDSearchListProvider.java216
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/search/XSDTypesSearchListProvider.java186
3 files changed, 291 insertions, 306 deletions
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/search/XSDElementsSearchListProvider.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/search/XSDElementsSearchListProvider.java
index 134e28b024..337fa15fad 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/search/XSDElementsSearchListProvider.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/search/XSDElementsSearchListProvider.java
@@ -1,170 +1,49 @@
package org.eclipse.wst.xsd.ui.internal.editor.search;
-
import java.util.ArrayList;
-import java.util.Iterator;
+import java.util.HashMap;
import java.util.List;
-
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.wst.common.core.search.SearchEngine;
-import org.eclipse.wst.common.core.search.SearchMatch;
-import org.eclipse.wst.common.core.search.SearchParticipant;
-import org.eclipse.wst.common.core.search.SearchPlugin;
-import org.eclipse.wst.common.core.search.SearchRequestor;
-import org.eclipse.wst.common.core.search.pattern.QualifiedName;
-import org.eclipse.wst.common.core.search.pattern.SearchPattern;
import org.eclipse.wst.common.core.search.scope.SearchScope;
import org.eclipse.wst.common.ui.internal.search.dialogs.IComponentList;
-import org.eclipse.wst.common.ui.internal.search.dialogs.IComponentSearchListProvider;
-import org.eclipse.wst.xml.core.internal.search.XMLComponentDeclarationPattern;
import org.eclipse.wst.xsd.ui.internal.search.IXSDSearchConstants;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDImport;
-import org.eclipse.xsd.XSDInclude;
import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDSchemaContent;
-import org.eclipse.xsd.XSDSchemaDirective;
-
-public class XSDElementsSearchListProvider implements
- IComponentSearchListProvider {
- protected XSDSchema[] schemas;
-
- protected IFile currentFile;
-
- // TODO (cs) remove these and use proper search scopes!
- //
- public static final int ENCLOSING_PROJECT_SCOPE = 0;
-
- public static final int ENTIRE_WORKSPACE_SCOPE = 1;
-
- public XSDElementsSearchListProvider(IFile currentFile,
- XSDSchema[] schemas) {
- this.schemas = schemas;
- this.currentFile = currentFile;
- }
-
- public void populateComponentList(IComponentList list, SearchScope scope,
- IProgressMonitor pm) {
- // we traverse the elements already defined within the visible
- // schemas
- // we do this in addition to the component search since this should
- // execute
- // very quickly and there's a good chance the user wants to select an
- // element that's
- // already imported/included
- // TODO (cs) ensure we don't add duplicates when we proceed to use the
- // search list
- //
- for (int i = 0; i < schemas.length; i++) {
- XSDSchema schema = schemas[i];
- ComponentCollectingXSDVisitor visitor =
- new ComponentCollectingXSDVisitor(list);
- visitor.visitSchema(schema, true);
- }
-
- // finally we call the search API's to do a potentially slow search
- if (scope != null) {
- populateComponentListUsingSearch(list, scope, pm);
- }
- }
-
- class ComponentCollectingXSDVisitor {
- protected List visitedSchemas = new ArrayList();
-
- IComponentList list;
-
- ComponentCollectingXSDVisitor(IComponentList list) {
- this.list = list;
- }
-
- public void visitSchema(XSDSchema schema, boolean visitImportedSchema) {
-
- visitedSchemas.add(schema);
- for (Iterator contents = schema.getContents().iterator(); contents.hasNext();) {
- XSDSchemaContent content = (XSDSchemaContent) contents.next();
- if (content instanceof XSDSchemaDirective) {
- XSDSchemaDirective schemaDirective = (XSDSchemaDirective) content;
- XSDSchema extSchema = schemaDirective.getResolvedSchema();
- if (extSchema != null && !visitedSchemas.contains(extSchema)){
- if ( schemaDirective instanceof XSDImport && visitImportedSchema){
- visitSchema(extSchema, false);
- }
- else if ( extSchema instanceof XSDInclude || extSchema instanceof XSDImport){
- visitSchema(extSchema, false);
- }
- }
- } else if (content instanceof XSDElementDeclaration) {
- list.add(content);
- }
- }
- }
- }
-
- private void populateComponentListUsingSearch(IComponentList list,
- SearchScope scope, IProgressMonitor pm) {
- SearchEngine searchEngine = new SearchEngine();
- InternalSearchRequestor requestor = new InternalSearchRequestor(list);
- findTypes(searchEngine, requestor, scope,
- IXSDSearchConstants.ELEMENT_META_NAME);
- }
-
- class InternalSearchRequestor extends SearchRequestor {
- IComponentList componentList;
-
- InternalSearchRequestor(IComponentList componentList) {
- this.componentList = componentList;
- }
-
- public void acceptSearchMatch(SearchMatch match) throws CoreException {
- // we filter out the matches from the current file since we assume
- // the
- // info derived from our schema models is more update to date
- // (in the event that we haven't saved our latest modifications)
- //
- if (match.getFile() != currentFile) {
- // TODO... this ugly qualified name stashing will go away soon
- //
- QualifiedName qualifiedName = null;
- Object o = match.map.get("name");
- if (o != null && o instanceof QualifiedName) {
- qualifiedName = (QualifiedName) o;
- }
- if (qualifiedName != null
- && qualifiedName.getLocalName() != null) {
- componentList.add(match);
- }
- }
- }
- }
-
- protected void findTypes(SearchEngine searchEngine,
- SearchRequestor requestor, SearchScope scope, QualifiedName metaName) {
- try {
- XMLComponentDeclarationPattern pattern = new XMLComponentDeclarationPattern(
- new QualifiedName("*", "*"), metaName,
- SearchPattern.R_PATTERN_MATCH);
-
- // TODO (cs) revist this... we shouldn't be needing to hard-code
- // partipant id's
- // All we're really doing here is trying to avoid finding matches in
- // wsdl's since we don't
- // ever want to import/include a wsdl from a schema! Maybe we should
- // just scope out any file
- // types that aren't xsd's using a custom SearchScope?
- //
- SearchParticipant particpant = SearchPlugin.getDefault()
- .getSearchParticipant(
- "org.eclipse.wst.xsd.search.XSDSearchParticipant");
- Assert.isNotNull(particpant);
- SearchParticipant[] participants = { particpant };
- searchEngine.search(pattern, requestor, participants, scope, null,
- new NullProgressMonitor());
- } catch (CoreException e) {
- e.printStackTrace();
- }
- }
+public class XSDElementsSearchListProvider extends XSDSearchListProvider
+{
+ public XSDElementsSearchListProvider(IFile currentFile, XSDSchema[] schemas)
+ {
+ super(currentFile, schemas);
+ }
+
+ public void populateComponentList(IComponentList list, SearchScope scope, IProgressMonitor pm)
+ {
+ // now we traverse the types already defined within the visible schemas
+ // we do this in addition to the component search since this should execute
+ // very quickly and there's a good chance the user wants to select a time that's
+ // already imported/included
+ // TODO (cs) ensure we don't add duplicates when we proceed to use the search list
+ //
+ List visitedSchemas = new ArrayList();
+ for (int i = 0; i < schemas.length; i++)
+ {
+ XSDSchema schema = schemas[i];
+ ComponentCollectingXSDVisitor visitor = new ComponentCollectingXSDVisitor(list, IXSDSearchConstants.ELEMENT_META_NAME);
+ visitor.visitSchema(schema, true);
+ visitedSchemas.addAll(visitor.getVisitedSchemas());
+ }
+ // finally we call the search API's to do a potentially slow search
+ if (scope != null)
+ {
+ populateComponentListUsingSearch(list, scope, pm, createFileMap(visitedSchemas));
+ }
+ }
+
+ private void populateComponentListUsingSearch(IComponentList list, SearchScope scope, IProgressMonitor pm, HashMap files)
+ {
+ SearchEngine searchEngine = new SearchEngine();
+ InternalSearchRequestor requestor = new InternalSearchRequestor(list, files);
+ findMatches(searchEngine, requestor, scope, IXSDSearchConstants.ELEMENT_META_NAME);
+ }
}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/search/XSDSearchListProvider.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/search/XSDSearchListProvider.java
new file mode 100644
index 0000000000..d4700a556c
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/search/XSDSearchListProvider.java
@@ -0,0 +1,216 @@
+package org.eclipse.wst.xsd.ui.internal.editor.search;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.wst.common.core.search.SearchEngine;
+import org.eclipse.wst.common.core.search.SearchMatch;
+import org.eclipse.wst.common.core.search.SearchParticipant;
+import org.eclipse.wst.common.core.search.SearchPlugin;
+import org.eclipse.wst.common.core.search.SearchRequestor;
+import org.eclipse.wst.common.core.search.pattern.QualifiedName;
+import org.eclipse.wst.common.core.search.pattern.SearchPattern;
+import org.eclipse.wst.common.core.search.scope.SearchScope;
+import org.eclipse.wst.common.ui.internal.search.dialogs.IComponentList;
+import org.eclipse.wst.common.ui.internal.search.dialogs.IComponentSearchListProvider;
+import org.eclipse.wst.xml.core.internal.search.XMLComponentDeclarationPattern;
+import org.eclipse.wst.xsd.ui.internal.search.IXSDSearchConstants;
+import org.eclipse.xsd.XSDElementDeclaration;
+import org.eclipse.xsd.XSDImport;
+import org.eclipse.xsd.XSDInclude;
+import org.eclipse.xsd.XSDSchema;
+import org.eclipse.xsd.XSDSchemaContent;
+import org.eclipse.xsd.XSDSchemaDirective;
+import org.eclipse.xsd.XSDSimpleTypeDefinition;
+import org.eclipse.xsd.XSDTypeDefinition;
+
+
+public abstract class XSDSearchListProvider implements IComponentSearchListProvider
+{
+ protected XSDSchema[] schemas;
+ protected IFile currentFile;
+ // TODO (cs) remove these and use proper search scopes!
+ //
+ public static final int ENCLOSING_PROJECT_SCOPE = 0;
+ public static final int ENTIRE_WORKSPACE_SCOPE = 1;
+
+ public XSDSearchListProvider(IFile currentFile, XSDSchema[] schemas)
+ {
+ this.schemas = schemas;
+ this.currentFile = currentFile;
+ }
+
+
+ class ComponentCollectingXSDVisitor
+ {
+ protected List visitedSchemas = new ArrayList();
+ IComponentList list;
+ QualifiedName searchKind;
+
+ ComponentCollectingXSDVisitor(IComponentList list, QualifiedName searchKind)
+ {
+ this.list = list;
+ this.searchKind = searchKind;
+ }
+
+ public void visitSchema(XSDSchema schema, boolean visitImportedSchema)
+ {
+ visitedSchemas.add(schema);
+ for (Iterator contents = schema.getContents().iterator(); contents.hasNext();)
+ {
+ XSDSchemaContent content = (XSDSchemaContent) contents.next();
+ if (content instanceof XSDSchemaDirective)
+ {
+ XSDSchemaDirective schemaDirective = (XSDSchemaDirective) content;
+ XSDSchema extSchema = schemaDirective.getResolvedSchema();
+ if (extSchema != null && !visitedSchemas.contains(extSchema))
+ {
+ if (schemaDirective instanceof XSDImport && visitImportedSchema)
+ {
+ visitSchema(extSchema, false);
+ }
+ else if (extSchema instanceof XSDInclude || extSchema instanceof XSDImport)
+ {
+ visitSchema(extSchema, false);
+ }
+ }
+ }
+ else if (content instanceof XSDElementDeclaration && searchKind == IXSDSearchConstants.ELEMENT_META_NAME)
+ {
+ list.add(content);
+ }
+ else if (content instanceof XSDSimpleTypeDefinition && searchKind == IXSDSearchConstants.SIMPLE_TYPE_META_NAME)
+ {
+ // in this case we only want to show simple types
+ list.add(content);
+ }
+ else if (content instanceof XSDTypeDefinition && searchKind == IXSDSearchConstants.TYPE_META_NAME)
+ {
+ // in this case we want to show all types
+ list.add(content);
+ }
+ }
+ }
+
+ public List getVisitedSchemas()
+ {
+ return visitedSchemas;
+ }
+ }
+
+
+ class InternalSearchRequestor extends SearchRequestor
+ {
+ IComponentList componentList;
+ HashMap files;
+
+ InternalSearchRequestor(IComponentList componentList, HashMap files)
+ {
+ this.componentList = componentList;
+ this.files = files;
+ }
+
+ public void acceptSearchMatch(SearchMatch match) throws CoreException
+ {
+ // we filter out the matches from the current file since we assume the
+ // info derived from our schema models is more update to date
+ // (in the event that we haven't saved our latest modifications)
+ //
+ if (files.get(match.getFile()) == null)
+ {
+ // TODO... this ugly qualified name stashing will go away soon
+ //
+ QualifiedName qualifiedName = null;
+ Object o = match.map.get("name");
+ if (o != null && o instanceof QualifiedName)
+ {
+ qualifiedName = (QualifiedName)o;
+ }
+ if (qualifiedName != null && qualifiedName.getLocalName() != null)
+ {
+ componentList.add(match);
+ }
+ }
+ }
+ }
+
+ protected void findMatches(SearchEngine searchEngine, SearchRequestor requestor, SearchScope scope, QualifiedName metaName)
+ {
+ try
+ {
+ XMLComponentDeclarationPattern pattern = new XMLComponentDeclarationPattern(new QualifiedName("*", "*"), metaName, SearchPattern.R_PATTERN_MATCH);
+ // TODO (cs) revist this... we shouldn't be needing to hard-code partipant id's
+ // All we're really doing here is trying to avoid finding matches in
+ // wsdl's since we don't ever want to import/include a wsdl from a schema!
+ // Maybe we should just scope out any file types that aren't xsd's using a
+ // custom SearchScope?
+ //
+ SearchParticipant particpant = SearchPlugin.getDefault().getSearchParticipant("org.eclipse.wst.xsd.search.XSDSearchParticipant");
+ Assert.isNotNull(particpant);
+ SearchParticipant[] participants = {particpant};
+ searchEngine.search(pattern, requestor, participants, scope, null, new NullProgressMonitor());
+ }
+ catch (CoreException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+
+ protected HashMap createFileMap(List visitedSchemas)
+ {
+ HashMap fileMap = new HashMap();
+ for (Iterator i = visitedSchemas.iterator(); i.hasNext(); )
+ {
+ XSDSchema theSchema = (XSDSchema)i.next();
+ String location = theSchema.getSchemaLocation();
+ IFile file = computeFile(location);
+ if (file != null)
+ {
+ fileMap.put(file, Boolean.TRUE);
+ }
+ }
+ return fileMap;
+ }
+
+ private IFile computeFile(String baseLocation)
+ {
+ IFile file = null;
+ if (baseLocation != null)
+ {
+ String fileScheme = "file:"; //$NON-NLS-1$
+ String platformResourceScheme = "platform:/resource";
+ if (baseLocation.startsWith(fileScheme))
+ {
+ baseLocation = baseLocation.substring(fileScheme.length());
+ baseLocation = removeLeading(baseLocation, "/");
+ IPath path = new Path(baseLocation);
+ file = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path);
+ }
+ else if (baseLocation.startsWith(platformResourceScheme))
+ {
+ baseLocation = baseLocation.substring(platformResourceScheme.length());
+ baseLocation = removeLeading(baseLocation, "/");
+ IPath path = new Path(baseLocation);
+ file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
+ }
+ }
+ return file;
+ }
+
+ private String removeLeading(String path, String pattern)
+ {
+ while (path.startsWith(pattern))
+ {
+ path = path.substring(pattern.length());
+ }
+ return path;
+ }
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/search/XSDTypesSearchListProvider.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/search/XSDTypesSearchListProvider.java
index 2a66249ee8..9d80faeaab 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/search/XSDTypesSearchListProvider.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/editor/search/XSDTypesSearchListProvider.java
@@ -9,212 +9,102 @@
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.wst.xsd.ui.internal.editor.search;
-
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.wst.common.core.search.SearchEngine;
-import org.eclipse.wst.common.core.search.SearchMatch;
-import org.eclipse.wst.common.core.search.SearchParticipant;
-import org.eclipse.wst.common.core.search.SearchPlugin;
-import org.eclipse.wst.common.core.search.SearchRequestor;
import org.eclipse.wst.common.core.search.pattern.QualifiedName;
-import org.eclipse.wst.common.core.search.pattern.SearchPattern;
import org.eclipse.wst.common.core.search.scope.SearchScope;
import org.eclipse.wst.common.ui.internal.search.dialogs.IComponentList;
-import org.eclipse.wst.common.ui.internal.search.dialogs.IComponentSearchListProvider;
-import org.eclipse.wst.xml.core.internal.search.XMLComponentDeclarationPattern;
import org.eclipse.wst.xsd.ui.internal.search.IXSDSearchConstants;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDImport;
-import org.eclipse.xsd.XSDInclude;
-import org.eclipse.xsd.XSDRedefine;
import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDSchemaContent;
-import org.eclipse.xsd.XSDSchemaDirective;
import org.eclipse.xsd.XSDTypeDefinition;
import org.eclipse.xsd.impl.XSDSchemaImpl;
import org.eclipse.xsd.util.XSDConstants;
-
-public class XSDTypesSearchListProvider implements IComponentSearchListProvider
+public class XSDTypesSearchListProvider extends XSDSearchListProvider
{
- protected XSDSchema[] schemas;
- protected IFile currentFile;
- // TODO (cs) remove these and use proper search scopes!
- //
- public static final int ENCLOSING_PROJECT_SCOPE = 0;
- public static final int ENTIRE_WORKSPACE_SCOPE = 1;
-
protected IXSDTypesFilter builtInFilter;
-
/**
- * Determines if we should use the filter
- * This us used to turn the filter on and off
+ * Determines if we should use the filter This us used to turn the filter on
+ * and off
*/
protected boolean supportFilter = true;
private boolean showComplexTypes = true;
public XSDTypesSearchListProvider(IFile currentFile, XSDSchema[] schemas)
{
- this.schemas = schemas;
- this.currentFile = currentFile;
+ super(currentFile, schemas);
}
public void populateComponentList(IComponentList list, SearchScope scope, IProgressMonitor pm)
- {
+ {
// first we add the 'built in' types
//
XSDSchema schemaForSchema = XSDSchemaImpl.getSchemaForSchema(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
for (Iterator i = schemaForSchema.getSimpleTypeIdMap().values().iterator(); i.hasNext();)
{
- XSDTypeDefinition td = (XSDTypeDefinition) i.next();
- if ( builtInFilter == null || !builtInFilter.shouldFilterOut(td) ) {
- list.add(td);
- }
- }
-
+ XSDTypeDefinition td = (XSDTypeDefinition) i.next();
+ if (builtInFilter == null || !builtInFilter.shouldFilterOut(td))
+ {
+ list.add(td);
+ }
+ }
// now we traverse the types already defined within the visible schemas
// we do this in addition to the component search since this should execute
- // very quickly and there's a good chance the user wants to select a time that's
+ // very quickly and there's a good chance the user wants to select a time
+ // that's
// already imported/included
- // TODO (cs) ensure we don't add duplicates when we proceed to use the search list
+ // TODO (cs) ensure we don't add duplicates when we proceed to use the
+ // search list
//
+ List visitedSchemas = new ArrayList();
for (int i = 0; i < schemas.length; i++)
{
XSDSchema schema = schemas[i];
- ComponentCollectingXSDVisitor visitor = new ComponentCollectingXSDVisitor(list);
+ QualifiedName kind = showComplexTypes ? IXSDSearchConstants.TYPE_META_NAME : IXSDSearchConstants.SIMPLE_TYPE_META_NAME;
+ ComponentCollectingXSDVisitor visitor = new ComponentCollectingXSDVisitor(list, kind);
visitor.visitSchema(schema, true);
+ visitedSchemas.addAll(visitor.getVisitedSchemas());
}
-
// finally we call the search API's to do a potentially slow search
- //
+ //
if (scope != null)
- {
- populateComponentListUsingSearch(list, scope, pm);
- }
- }
- class ComponentCollectingXSDVisitor
- {
- protected List visitedSchemas = new ArrayList();
- IComponentList list;
-
- ComponentCollectingXSDVisitor(IComponentList list)
- {
- this.list = list;
- }
-
- public void visitSchema(XSDSchema schema, boolean visitImportedSchema)
{
- visitedSchemas.add(schema);
- for (Iterator contents = schema.getContents().iterator(); contents.hasNext();)
- {
- XSDSchemaContent content = (XSDSchemaContent) contents.next();
- if (content instanceof XSDSchemaDirective)
- {
- XSDSchemaDirective schemaDirective = (XSDSchemaDirective) content;
- XSDSchema extSchema = schemaDirective.getResolvedSchema();
- if (extSchema != null && !visitedSchemas.contains(extSchema))
- {
- if ( schemaDirective instanceof XSDImport && visitImportedSchema){
- visitSchema(extSchema, false);
- }
- else if ( schemaDirective instanceof XSDInclude ||
- schemaDirective instanceof XSDRedefine){
- visitSchema(extSchema, false);
- }
- }
- }
- else if (content instanceof XSDTypeDefinition)
- {
- if ( showComplexTypes || ! (content instanceof XSDComplexTypeDefinition) )
- list.add(content);
- }
- }
+ populateComponentListUsingSearch(list, scope, pm, createFileMap(visitedSchemas));
}
}
- private void populateComponentListUsingSearch(IComponentList list, SearchScope scope, IProgressMonitor pm)
+ private void populateComponentListUsingSearch(IComponentList list, SearchScope scope, IProgressMonitor pm, HashMap files)
{
SearchEngine searchEngine = new SearchEngine();
- InternalSearchRequestor requestor = new InternalSearchRequestor(list);
+ InternalSearchRequestor requestor = new InternalSearchRequestor(list, files);
if (showComplexTypes)
- findTypes(searchEngine, requestor, scope, IXSDSearchConstants.COMPLEX_TYPE_META_NAME);
- findTypes(searchEngine, requestor, scope, IXSDSearchConstants.SIMPLE_TYPE_META_NAME);
- }
-
- class InternalSearchRequestor extends SearchRequestor
- {
- IComponentList componentList;
-
- InternalSearchRequestor(IComponentList componentList)
- {
- this.componentList = componentList;
- }
-
- public void acceptSearchMatch(SearchMatch match) throws CoreException
{
- // we filter out the matches from the current file since we assume the
- // info derived from our schema models is more update to date
- // (in the event that we haven't saved our latest modifications)
- //
- if (match.getFile() != currentFile)
- {
- // TODO... this ugly qualified name stashing will go away soon
- //
- QualifiedName qualifiedName = null;
- Object o = match.map.get("name");
- if (o != null && o instanceof QualifiedName)
- {
- qualifiedName = (QualifiedName)o;
- }
- if (qualifiedName != null && qualifiedName.getLocalName() != null)
- {
- componentList.add(match);
- }
- }
+ findMatches(searchEngine, requestor, scope, IXSDSearchConstants.COMPLEX_TYPE_META_NAME);
}
+ findMatches(searchEngine, requestor, scope, IXSDSearchConstants.SIMPLE_TYPE_META_NAME);
}
- protected void findTypes(SearchEngine searchEngine, SearchRequestor requestor, SearchScope scope, QualifiedName metaName)
- {
- try
- {
- XMLComponentDeclarationPattern pattern = new XMLComponentDeclarationPattern(new QualifiedName("*", "*"), metaName, SearchPattern.R_PATTERN_MATCH);
-
- // TODO (cs) revist this... we shouldn't be needing to hard-code partipant id's
- // All we're really doing here is trying to avoid finding matches in wsdl's since we don't
- // ever want to import/include a wsdl from a schema! Maybe we should just scope out any file
- // types that aren't xsd's using a custom SearchScope?
- //
- SearchParticipant particpant = SearchPlugin.getDefault().getSearchParticipant("org.eclipse.wst.xsd.search.XSDSearchParticipant");
- Assert.isNotNull(particpant);
- SearchParticipant[] participants = {particpant};
- searchEngine.search(pattern, requestor, participants, scope, null, new NullProgressMonitor());
- }
- catch (CoreException e)
- {
- e.printStackTrace();
- }
- }
public void _populateComponentListQuick(IComponentList list, IProgressMonitor pm)
- {
+ {
}
- public void turnBuiltInFilterOn(boolean option){
- supportFilter = option;
+ public void turnBuiltInFilterOn(boolean option)
+ {
+ supportFilter = option;
}
-
- public void setBuiltInFilter(IXSDTypesFilter filter) {
- this.builtInFilter = filter;
+
+ public void setBuiltInFilter(IXSDTypesFilter filter)
+ {
+ this.builtInFilter = filter;
}
-
- public void showComplexTypes(boolean show){
- showComplexTypes = show;
+
+ public void showComplexTypes(boolean show)
+ {
+ showComplexTypes = show;
}
}

Back to the top