use of org.eclipse.xsd.XSDRedefine in project webtools.sourceediting by eclipse.
the class XSDAttributeGroupDefinitionAdapter method getTopContainer.
public IADTObject getTopContainer() {
XSDAttributeGroupDefinition attrGroupDef = getXSDAttributeGroupDefinition();
XSDConcreteComponent container = attrGroupDef.getContainer();
if (container instanceof XSDSchema || container instanceof XSDRedefine)
return this;
else
return getGlobalXSDContainer(attrGroupDef);
}
use of org.eclipse.xsd.XSDRedefine in project webtools.sourceediting by eclipse.
the class XSDModelGroupDefinitionAdapter method getTopContainer.
public IADTObject getTopContainer() {
XSDModelGroupDefinition group = getXSDModelGroupDefinition();
XSDConcreteComponent container = group.getContainer();
if (container instanceof XSDSchema || container instanceof XSDRedefine)
return this;
else
return getGlobalXSDContainer(group);
}
use of org.eclipse.xsd.XSDRedefine in project webtools.sourceediting by eclipse.
the class XSDRedefineAdapter method getCategoryChildren.
private List getCategoryChildren(int category) {
List list = new ArrayList();
XSDRedefine redefine = (XSDRedefine) target;
Iterator iterator = redefine.getContents().iterator();
while (iterator.hasNext()) {
XSDRedefineContent redefineContent = (XSDRedefineContent) iterator.next();
if (redefineContent instanceof XSDAttributeGroupDefinition && category == CategoryAdapter.ATTRIBUTES) {
list.add(redefineContent);
} else if (redefineContent instanceof XSDModelGroupDefinition && category == CategoryAdapter.GROUPS) {
list.add(redefineContent);
} else if (redefineContent instanceof XSDComplexTypeDefinition && category == CategoryAdapter.TYPES) {
list.add(redefineContent);
} else if (redefineContent instanceof XSDSimpleTypeDefinition && category == CategoryAdapter.TYPES) {
list.add(redefineContent);
}
}
List adapterList = new ArrayList();
populateAdapterList(list, adapterList);
return adapterList;
}
use of org.eclipse.xsd.XSDRedefine in project webtools.sourceediting by eclipse.
the class XSDRedefineAdapter method getChildren.
public ITreeElement[] getChildren() {
XSDRedefine xsdRedefine = (XSDRedefine) getTarget();
children = new ArrayList();
if (attributesCategory != null) {
List attributes = getCategoryChildren(CategoryAdapter.ATTRIBUTES);
List groups = getCategoryChildren(CategoryAdapter.GROUPS);
List types = getCategoryChildren(CategoryAdapter.TYPES);
attributesCategory.setChildren(attributes);
attributesCategory.setAllChildren(attributes);
typesCategory.setChildren(types);
typesCategory.setAllChildren(types);
groupsCategory.setChildren(groups);
groupsCategory.setAllChildren(groups);
} else {
createCategoryAdapters(xsdRedefine);
}
children.add(attributesCategory);
children.add(typesCategory);
children.add(groupsCategory);
return (ITreeElement[]) children.toArray(new ITreeElement[0]);
}
use of org.eclipse.xsd.XSDRedefine in project webtools.sourceediting by eclipse.
the class XSDDirectivesManager method addToUnusedImports.
/**
* From a list of used schemas, update the unusedImports list for the given schema
*
* @param schema
* @param unusedImports
* @param usedSchemas
*/
protected void addToUnusedImports(XSDSchema schema, List usedSchemas) {
// now that we have the list of usedSchemas, get the list of unused
// schemas by comparing this list to what is actually in the schema
Iterator iter = schema.getContents().iterator();
while (iter.hasNext()) {
Object o = iter.next();
if (o instanceof XSDSchemaDirective) {
XSDSchemaDirective directive = (XSDSchemaDirective) o;
boolean isUsed = false;
Iterator iter2 = usedSchemas.iterator();
while (iter2.hasNext()) {
XSDSchema usedSchema = (XSDSchema) iter2.next();
if (directive instanceof XSDImport && directive.getResolvedSchema() == usedSchema) {
isUsed = true;
break;
}
if (directive instanceof XSDInclude && ((XSDInclude) directive).getIncorporatedSchema() == usedSchema) {
isUsed = true;
usedDirectIncludes.add(usedSchema);
break;
}
// blindly accept redefines as used
if (directive instanceof XSDRedefine) {
isUsed = true;
break;
}
}
// If it is an include, we need to check if it is used indirectly
if (directive instanceof XSDInclude && !isUsed) {
XSDInclude inc = (XSDInclude) directive;
XSDSchema incSchema = inc.getIncorporatedSchema();
if (incSchema != null) {
XSDSchema usedSchema = getUsedIncludeSchema(incSchema, inc);
if (usedSchema != null) {
usedIndirectIncludes.add(directive);
usedIndirectIncludesMap.put(directive, usedSchema);
isUsed = true;
} else {
isUsed = false;
}
}
}
// Also any redefines should be considered used
if (!isUsed && !unusedDirectives.contains(directive) && !(directive instanceof XSDRedefine)) {
unusedDirectives.add(directive);
}
}
}
Iterator iter3 = usedIndirectIncludes.iterator();
while (iter3.hasNext()) {
Object o = iter3.next();
if (o instanceof XSDInclude) {
XSDInclude inc = (XSDInclude) o;
XSDSchema targetSchema = (XSDSchema) usedIndirectIncludesMap.get(inc);
if (usedIncludeSchemas.contains(targetSchema) && usedDirectIncludes.contains(targetSchema)) {
unusedDirectives.add(inc);
} else {
usedDirectIncludes.add(targetSchema);
}
}
}
}
Aggregations