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"); } }
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 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 IClass findClass(Type type) throws ProjectNotFoundException, InvalidEditingException { if (type.getNamespaceClass() == null || isEmpty(type.getNamespaceClass().clazz)) { return null; } IClass findClass = this.astahModelUtil.getModelWithPath( IClass.class, project, type.getNamespaceClass().getFullName()); if (findClass == null) { INamedElement[] findEls = this.projectAccessor.findElements(IClass.class, type.getNamespaceClass().clazz); for (INamedElement findEl : findEls) { if (findEl.getFullName("::").equals(type.getNamespaceClass().getFullName())) { findClass = (IClass) findEl; break; } } } if (findClass == null) { findClass = (IClass) this.createClass(this.typeUtil.getCompounddefByLoadXml(type.getRefId())); } return findClass; }
protected void createParameter(IOperation operation, List<ParamType> params) throws InvalidEditingException, ProjectNotFoundException { for (ParamType param : params) { IParameter parameter = null; Type type = this.typeUtil.createMemberParamType(param); if (LanguageManager.PRIMITIVE_TYPE.contains(type.getNamespaceClass().clazz)) { parameter = createParameter( this.basicModelEditor, operation, type.getName(), type.getNamespaceClass().clazz); } else if (!isEmpty(type.getTemplates())) { parameter = createParameter( this.basicModelEditor, operation, type.getName(), astahModelUtil.clearNamespace(type.getTemplateParameter())); } else { IClass findClass = this.findClass(type); if (findClass == null) { if (type.getNamespaceClass() != null && !isEmpty(type.getNamespaceClass().clazz)) { parameter = createParameter( this.basicModelEditor, operation, type.getName(), type.getNamespaceClass().clazz); } } else { parameter = createParameter(this.basicModelEditor, operation, type.getName(), findClass); } } if (parameter != null) { this.setLanguage(CPLUS_PARAMETER, parameter); parameter.setTypeModifier(type.getTypeModifier()); } } }
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); }
private void createInheritanceFromBaseCompoundDef(CompounddefType compounddefType, IClass clazz) throws ProjectNotFoundException, InvalidEditingException { List<CompoundRefType> basecompoundrefs = compounddefType.getBasecompoundref(); // 2つ同名の親が設定されているxmlがあるので、同じものは親としないためのチェック用。 Set<String> generalizations = new HashSet<>(); for (CompoundRefType basecompoundref : basecompoundrefs) { Type type = this.typeUtil.createType(basecompoundref); IGeneralization generalization = null; try { IClass baseClass = this.findClass(type); if (baseClass == null) { if (type.getNamespaceClass() != null || !isEmpty(type.getNamespaceClass().clazz)) { IClass generalizationClass = this.basicModelEditor.createClass( createPackage(type), type.getNamespaceClass().clazz); generalization = this.basicModelEditor.createGeneralization(clazz, generalizationClass, ""); generalizations.add(type.getNamespaceClass().getFullName()); } else { LOG.info( "not created generalization. clazz:{}, type:{}", clazz.getName(), type.getName()); continue; } } else { if (!generalizations.contains(type.getNamespaceClass().getFullName())) { generalization = this.basicModelEditor.createGeneralization(clazz, baseClass, ""); generalizations.add(type.getNamespaceClass().getFullName()); } else { LOG.info( "generalization already exists. generalization:{}, clazz:{}, baseClass:{}", type.getNamespaceClass().getFullName(), clazz, baseClass); continue; } } if (!isEmpty(type.getVisiblity())) { generalization.setVisibility(type.getVisiblity()); } } catch (InvalidEditingException e) { if (!e.getKey().equals(InvalidEditingException.NAME_DOUBLE_ERROR_KEY)) { throw e; } LOG.info("invalid editing {},{}", clazz.getName(), type.getName()); } } }