Search in sources :

Example 6 with XSDRedefine

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);
}
Also used : XSDRedefine(org.eclipse.xsd.XSDRedefine) XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition) XSDSchema(org.eclipse.xsd.XSDSchema)

Example 7 with XSDRedefine

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);
}
Also used : XSDRedefine(org.eclipse.xsd.XSDRedefine) XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition) XSDSchema(org.eclipse.xsd.XSDSchema)

Example 8 with XSDRedefine

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;
}
Also used : XSDRedefine(org.eclipse.xsd.XSDRedefine) XSDRedefineContent(org.eclipse.xsd.XSDRedefineContent) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition)

Example 9 with XSDRedefine

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]);
}
Also used : XSDRedefine(org.eclipse.xsd.XSDRedefine) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ITreeElement(org.eclipse.wst.xsd.ui.internal.adt.outline.ITreeElement)

Example 10 with XSDRedefine

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);
            }
        }
    }
}
Also used : XSDSchemaDirective(org.eclipse.xsd.XSDSchemaDirective) XSDRedefine(org.eclipse.xsd.XSDRedefine) Iterator(java.util.Iterator) EObject(org.eclipse.emf.ecore.EObject) XSDImport(org.eclipse.xsd.XSDImport) XSDSchema(org.eclipse.xsd.XSDSchema) XSDInclude(org.eclipse.xsd.XSDInclude)

Aggregations

XSDRedefine (org.eclipse.xsd.XSDRedefine)20 XSDSchema (org.eclipse.xsd.XSDSchema)11 ArrayList (java.util.ArrayList)8 XSDConcreteComponent (org.eclipse.xsd.XSDConcreteComponent)8 List (java.util.List)7 EObject (org.eclipse.emf.ecore.EObject)6 XSDAttributeGroupDefinition (org.eclipse.xsd.XSDAttributeGroupDefinition)6 XSDInclude (org.eclipse.xsd.XSDInclude)6 XSDModelGroupDefinition (org.eclipse.xsd.XSDModelGroupDefinition)6 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)5 Iterator (java.util.Iterator)4 IADTObject (org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject)4 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)4 IFile (org.eclipse.core.resources.IFile)3 EList (org.eclipse.emf.common.util.EList)3 IEditorInput (org.eclipse.ui.IEditorInput)3 XSDAttributeDeclaration (org.eclipse.xsd.XSDAttributeDeclaration)3 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)3 XSDImport (org.eclipse.xsd.XSDImport)3 XSDSchemaDirective (org.eclipse.xsd.XSDSchemaDirective)3