private IPackage createPackage(Type type) throws InvalidEditingException { if (type.getNamespaceClass() == null || isEmpty(type.getNamespaceClass().namespace)) { return this.project; } String[] namespaces = type.getNamespaceClass().namespace.split("::"); IPackage parentModel = this.project; for (String ns : namespaces) { IPackage pkg; if ((pkg = this.getNamespace(parentModel, ns)) == null) { parentModel = this.basicModelEditor.createPackage(parentModel, ns); LOG.trace(format("create model : %s", parentModel.getFullName("::"))); } else { LOG.debug(String.format("%s is exits.", pkg.getFullName("::"))); parentModel = pkg; } } return parentModel; }
protected IPackage getNamespace(IPackage pkg, String name) { INamedElement[] ownedElements = pkg.getOwnedElements(); for (INamedElement namedElement : ownedElements) { if (name.equals(namedElement.getName()) && namedElement instanceof IPackage) { return (IPackage) namedElement; } } return null; }
public void createNamespace(IModel model, CompounddefType compounddefType) throws InvalidEditingException { if (compounddefType.getKind() == DoxCompoundKind.NAMESPACE) { String[] namespaces = compounddefType.getCompoundname().split("::"); IPackage parentModel = model; for (String namespace : namespaces) { IPackage pkg; if ((pkg = this.getNamespace(parentModel, namespace)) == null) { // 無名名前空間で、doxygenの設定で表示しない場合(@から始まるパッケージ)は作成しない。 if (!namespace.startsWith("@")) { parentModel = this.basicModelEditor.createPackage(parentModel, namespace); LOG.trace(format("create model : %s", parentModel.getFullName("::"))); // パッケージ内のenumを作成する this.createEnum(compounddefType, parentModel); } } else { LOG.debug(String.format("%s is exits.", pkg.getFullName("::"))); parentModel = pkg; } } } }