public INamedElement createClass(CompounddefType compounddefType) throws InvalidEditingException, ProjectNotFoundException { IModel project = initProject(); if (compounddefType == null || compounddefType.getKind() == null) { return null; } INamedElement namedElement = this.astahModelUtil.getModelWithPath( IClass.class, project, compounddefType.getCompoundname()); if (namedElement != null) { return namedElement; } switch (compounddefType.getKind()) { case CLASS: namedElement = this.createModel(IClass.class, compounddefType.getCompoundname(), compounddefType); break; case STRUCT: namedElement = this.createModel(IClass.class, compounddefType.getCompoundname(), compounddefType); break; case UNION: namedElement = this.createModel(IClass.class, compounddefType.getCompoundname(), compounddefType); break; case NAMESPACE: namedElement = this.createModel(IPackage.class, compounddefType.getCompoundname(), compounddefType); break; case CATEGORY: case DIR: case EXAMPLE: case EXCEPTION: case FILE: case GROUP: case INTERFACE: case PAGE: case PROTOCOL: default: LOG.trace(format("現在使っていないDoxCompoundKind : %s", compounddefType.getKind().toString())); break; } return namedElement; }
private void addStereotypeFromCompounddefTypeKind(CompounddefType compounddefType, IClass clazz) throws InvalidEditingException { try { switch (compounddefType.getKind()) { case STRUCT: clazz.addStereotype(DoxCompoundKind.STRUCT.value()); break; case UNION: clazz.addStereotype(DoxCompoundKind.UNION.value()); break; default: break; } } catch (InvalidEditingException e) { if (!e.getKey().equals(InvalidEditingException.NAME_DOUBLE_ERROR_KEY)) { throw e; } LOG.info("invalid editing {},{}", clazz.getName(), compounddefType.getKind()); } }
public void modifyClass(CompounddefType compounddefType) throws ProjectNotFoundException, InvalidEditingException { // class, struct, union だけ処理する switch (compounddefType.getKind()) { case CLASS: case STRUCT: case UNION: break; case NAMESPACE: case CATEGORY: case DIR: case EXAMPLE: case EXCEPTION: case FILE: case GROUP: case INTERFACE: case PAGE: case PROTOCOL: default: LOG.trace(format("ここでは使用しないDoxCompoundKind : %s", compounddefType.getKind().toString())); return; } // IClass を 取得して、属性、操作等をセットする IClass clazz = this.astahModelUtil.getModelWithPath( IClass.class, project, compounddefType.getCompoundname()); if (clazz == null) { LOG.debug( format( "class is null. Compoundname : %s, id : %s", compounddefType.getCompoundname(), compounddefType.getId())); return; } addStereotypeFromCompounddefTypeKind(compounddefType, clazz); // テンプレートパラメーター createTemplateParamterFromTemprateparamlist(compounddefType, clazz); // 継承 createInheritanceFromBaseCompoundDef(compounddefType, clazz); // 属性、操作 createOperationOrAttributeFromSectionDefTypes(compounddefType, clazz); }
protected boolean isCreateGlobalClass(CompounddefType compounddefType) { if (!(compounddefType.getKind() == DoxCompoundKind.FILE || compounddefType.getKind() == DoxCompoundKind.NAMESPACE)) { return false; } List<SectiondefType> sectiondefTypes = compounddefType.getSectiondef(); if (compounddefType.getSectiondef() == null || compounddefType.getSectiondef().isEmpty()) { return false; } for (SectiondefType sectiondefType : sectiondefTypes) { if (!isCreateGlobalSectiondefType(sectiondefType)) { continue; } List<MemberdefType> memberdefTypes = sectiondefType.getMemberdef(); for (MemberdefType memberdefType : memberdefTypes) { if (!isCreateGlobalMemberdefType(memberdefType)) { continue; } return true; } } return false; }
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; } } } }
public void createGlobalClass(CompounddefType compounddefType) throws InvalidEditingException, ProjectNotFoundException { initProject(); if (!isCreateGlobalClass(compounddefType)) { return; } Type type = this.typeUtil.createEnumType(compounddefType); if (isEmpty(type.getNamespaceClass().clazz)) { return; } if (this.findClass(type) != null) { return; } IPackage pkg = project; if (compounddefType.getKind() == DoxCompoundKind.NAMESPACE) { pkg = this.astahModelUtil.getModelWithPath( IPackage.class, project, compounddefType.getCompoundname()); } IClass clazz = this.basicModelEditor.createClass(pkg, type.getNamespaceClass().clazz); this.setLanguage(CPLUS_CLASS, clazz); // グローバルな enum を作成 this.createEnum(compounddefType, pkg); }