protected void createEnum(CompounddefType compounddefType, INamedElement element) throws InvalidEditingException { List<SectiondefType> sectiondefTypes = compounddefType.getSectiondef(); for (SectiondefType sectiondefType : sectiondefTypes) { List<MemberdefType> memberdefTypes = sectiondefType.getMemberdef(); for (MemberdefType memberdefType : memberdefTypes) { if (memberdefType.getKind() != DoxMemberKind.ENUM) { continue; } Type type = this.typeUtil.createEnumType(memberdefType); IClass enumClass = null; try { if (element instanceof IPackage) { enumClass = this.basicModelEditor.createClass((IPackage) element, type.getName()); } else if (element instanceof IClass) { enumClass = this.basicModelEditor.createClass((IClass) element, type.getName()); } } catch (InvalidEditingException e) { // グローバルで同名は存在するので無視する if (!e.getKey().equals(InvalidEditingException.NAME_DOUBLE_ERROR_KEY)) { throw e; } } if (enumClass == null) { break; } enumClass.addStereotype(STEREOTYPE_ENUM); enumClass.setVisibility(type.getVisiblity()); List<EnumvalueType> enumvalues = memberdefType.getEnumvalue(); if (enumvalues == null) { break; } for (EnumvalueType enumvalue : enumvalues) { Type enumtype = this.typeUtil.createEnumType(enumvalue); try { IAttribute enumAttribute = this.basicModelEditor.createAttribute(enumClass, enumtype.getName(), enumClass); enumAttribute.setVisibility(enumtype.getVisiblity()); enumAttribute.setInitialValue(enumtype.getInitialValue()); // enum なので static とする enumAttribute.setStatic(true); } catch (InvalidEditingException e) { // 同じネームスペース名で同じ名前のEnumの中に同じ名前の定数を宣言しているときは例外を出したくない if (!e.getKey().equals(InvalidEditingException.NAME_DOUBLE_ERROR_KEY)) { throw e; } } } } } }
protected void createOperation( IClass clazz, Type type, MemberdefType memberdefType, IClass findClass) throws InvalidEditingException, ProjectNotFoundException { IOperation operation = null; if (LanguageManager.PRIMITIVE_TYPE.contains(type.getNamespaceClass().clazz)) { operation = this.basicModelEditor.createOperation( clazz, type.getName(), type.getNamespaceClass().clazz); } else { if (findClass == null) { if (clazz.getName().equals(type.getName()) || format("~%s", clazz.getName()).equals(type.getName())) { operation = this.basicModelEditor.createOperation(clazz, type.getName(), ""); } else if (type.getNamespaceClass() != null && !isEmpty(type.getNamespaceClass().clazz)) { operation = this.basicModelEditor.createOperation( clazz, type.getName(), type.getNamespaceClass().clazz); } } else { operation = this.basicModelEditor.createOperation(clazz, type.getName(), (IClass) findClass); } } if (operation == null) { return; } // 操作のその他属性を作成 this.setLanguage(CPLUS_OPERATION, operation); this.createParameter(operation, memberdefType.getParam()); operation.setDefinition(this.parseDescription(memberdefType.getDetaileddescription())); operation.setVisibility(type.getVisiblity()); if (type.isConst()) { this.createTaggedValue(operation, "jude.c_plus.const", "true"); } if (type.getVirt().equals(DoxVirtualKind.VIRTUAL.value()) || type.getVirt().equals(DoxVirtualKind.PURE_VIRTUAL.value())) { this.createTaggedValue(operation, "jude.c_plus.virtual", "true"); } if (type.isExplicit()) { this.createTaggedValue(operation, "jude.c_plus.explicit", "true"); } if (type.isInline()) { this.createTaggedValue(operation, "jude.c_plus.inline", "true"); } if (type.isFriend()) { this.createTaggedValue(operation, "jude.c_plus.friend", "true"); } }
protected void createAttribute( IClass clazz, Type type, MemberdefType memberdefType, IClass findClass, boolean isAssociation) throws InvalidEditingException { IAttribute attribute = null; boolean memberEnd = false; if (LanguageManager.PRIMITIVE_TYPE.contains(type.getNamespaceClass().clazz)) { attribute = this.basicModelEditor.createAttribute( clazz, type.getName(), type.getNamespaceClass().clazz); } else if (!isEmpty(type.getTemplates())) { attribute = this.basicModelEditor.createAttribute( clazz, type.getName(), astahModelUtil.clearNamespace(type.getTemplateParameter())); } else { if (findClass == null) { if (type.getNamespaceClass() != null && !isEmpty(type.getNamespaceClass().clazz)) { IPackage pkg = this.astahModelUtil.getModelWithPath( IPackage.class, project, type.getNamespaceClass().namespace); if (pkg == null) { pkg = project; } findClass = this.basicModelEditor.createClass(pkg, type.getNamespaceClass().clazz); if (isAssociation) { attribute = this.createAssosiation(clazz, type, findClass); memberEnd = true; } else { attribute = this.basicModelEditor.createAttribute(clazz, type.getName(), findClass); } } } else { if (isAssociation) { attribute = this.createAssosiation(clazz, type, findClass); memberEnd = true; } else { attribute = this.basicModelEditor.createAttribute(clazz, type.getName(), findClass); } } } if (attribute == null) { return; } this.setLanguage(CPLUS_ATTRIBUTE, attribute); // 属性のその他属性を作成 attribute.setStatic(type.isStatic()); attribute.setVisibility(type.getVisiblity()); attribute.setDefinition(this.parseDescription(memberdefType.getDetaileddescription())); if (!isEmpty(type.getTypeModifier())) { attribute.setTypeModifier(type.getTypeModifier()); } if (!memberEnd && type.isConst()) { this.createTaggedValue(attribute, "jude.c_plus.const", "true"); } if (!memberEnd && type.isVolatile()) { this.createTaggedValue(attribute, "jude.c_plus.volatile", "true"); } if (!memberEnd && type.isMutable()) { this.createTaggedValue(attribute, "jude.c_plus.mutable", "true"); } }
private void createOperationOrAttributeFromSectionDefTypes( CompounddefType compounddefType, IClass clazz) throws ProjectNotFoundException, InvalidEditingException { List<SectiondefType> sectiondefTypes = compounddefType.getSectiondef(); for (SectiondefType sectiondefType : sectiondefTypes) { List<MemberdefType> memberdefTypes = sectiondefType.getMemberdef(); for (MemberdefType memberdefType : memberdefTypes) { if (!(memberdefType.getKind() == DoxMemberKind.FUNCTION || memberdefType.getKind() == DoxMemberKind.VARIABLE || memberdefType.getKind() == DoxMemberKind.PROPERTY)) { continue; } Type type = this.typeUtil.createType(memberdefType); try { IClass findClass = this.findClass(type); if (memberdefType.getKind() == DoxMemberKind.FUNCTION) { this.createOperation(clazz, type, memberdefType, findClass); } else if (memberdefType.getKind() == DoxMemberKind.VARIABLE || memberdefType.getKind() == DoxMemberKind.PROPERTY) { this.createAttribute(clazz, type, memberdefType, findClass); } else { LOG.trace(format("ここでは使用しないDoxMemberKind : %s", memberdefType.getKind().toString())); } } catch (InvalidEditingException e) { if (!e.getKey().equals(InvalidEditingException.NAME_DOUBLE_ERROR_KEY)) { throw e; } LOG.info("invalid editing {},{}", clazz.getName(), type.getName()); } } } }
public void modifyGlobalClass(CompounddefType compounddefType) throws InvalidEditingException, ProjectNotFoundException { if (!isCreateGlobalClass(compounddefType)) { return; } Type type = this.typeUtil.createEnumType(compounddefType); IClass findClass = this.findClass(type); if (findClass == null) { return; } // グローバルな属性・関数を作成 List<SectiondefType> sectiondefTypes = compounddefType.getSectiondef(); for (SectiondefType sectiondefType : sectiondefTypes) { if (!isCreateGlobalSectiondefType(sectiondefType)) { continue; } List<MemberdefType> memberdefTypes = sectiondefType.getMemberdef(); for (MemberdefType memberdefType : memberdefTypes) { if (!isCreateGlobalMemberdefType(memberdefType)) { continue; } Type memberType = this.typeUtil.createType(memberdefType); IClass memberdefClass = this.findClass(memberType); if (memberdefType.getKind() == DoxMemberKind.FUNCTION) { this.createOperation(findClass, memberType, memberdefType, memberdefClass); } else if (memberdefType.getKind() == DoxMemberKind.VARIABLE) { try { this.createAttribute(findClass, memberType, memberdefType, memberdefClass, false); } catch (InvalidEditingException e) { // グローバルで同名は存在するので無視する if (!e.getKey().equals(InvalidEditingException.NAME_DOUBLE_ERROR_KEY)) { throw e; } } } } } }
protected boolean isCreateGlobalMemberdefType(MemberdefType memberdefType) { return memberdefType.getKind() == DoxMemberKind.FUNCTION || memberdefType.getKind() == DoxMemberKind.VARIABLE; }