//add the found architecture to the list of known architectures
archList.add(arch);
}
//entity declarations
if (topLevelElements[i] instanceof EntityDeclElement) {
EntityDeclElement entityDecl = (EntityDeclElement) topLevelElements[i];
m_ElementDeclList.put(entityDecl.getName().toUpperCase(), entityDecl);
if(!m_EntityArchList.containsKey(entityDecl.getName().toUpperCase())){
//new entity
archList=new Vector<ArchitectureElement>();
m_EntityArchList.put(entityDecl.getName().toUpperCase(), archList);
}
}
}
/////////////////////////////////////////////
//Find top level entities
entityNameList = m_EntityArchList.keySet();
//start by assuming everything is a top level entity
topLevelEntities.addAll(entityNameList);
Iterator<String> it=entityNameList.iterator();
while(it.hasNext()){
entityName=it.next();
archList=m_EntityArchList.get(entityName);
//go through all the architectures
for(int i=0; i<archList.size();i++){
OutlineElement[] childElements=archList.get(i).getChildren();
//go through all the instances
for(int j=0;j< childElements.length; j++){
if (childElements[j] instanceof EntityInstElement) {
EntityInstElement entityInst = (EntityInstElement) childElements[j];
String nameParts[] = entityInst.GetEntityName().toUpperCase().split("\\.");
String n=
nameParts.length==0 ? entityInst.GetEntityName() : nameParts[nameParts.length-1];
//remove the name from the top level
topLevelEntities.remove(n.toUpperCase());
}
if (childElements[j] instanceof ComponentInstElement) {
ComponentInstElement compInst = (ComponentInstElement) childElements[j];
String nameParts[] = compInst.GetEntityName().toUpperCase().split("\\.");
String n=
nameParts.length==0 ? compInst.GetEntityName() : nameParts[nameParts.length-1];
//remove the name from the top level
topLevelEntities.remove(n.toUpperCase());
}
}
}
}
//////////////////////////////////////////
//Start building the hierarchy
for (int i=0;i<topLevelElements.length;i++){
if (topLevelElements[i] instanceof EntityDeclElement) {
EntityDeclElement entityDecl = (EntityDeclElement) topLevelElements[i];
//if this is a top level element, add it to the root
if(topLevelEntities.contains(entityDecl.getName().toUpperCase())){
m_TopLevelEntities.add(entityDecl);
}
}
}
return true;