diff options
author | Dimitri van Heesch <dimitri@stack.nl> | 2015-02-21 16:12:30 (GMT) |
---|---|---|
committer | Dimitri van Heesch <dimitri@stack.nl> | 2015-02-21 16:17:14 (GMT) |
commit | 080a465b1321ff93c05ce398cd18a577e0ebae4b (patch) | |
tree | 0bae20bf26007d2856f0460143125a31cff131b5 /src/classdef.cpp | |
parent | 5bfda3d4c1158e5429349a2698339650dcfbbe88 (diff) | |
download | Doxygen-080a465b1321ff93c05ce398cd18a577e0ebae4b.zip Doxygen-080a465b1321ff93c05ce398cd18a577e0ebae4b.tar.gz Doxygen-080a465b1321ff93c05ce398cd18a577e0ebae4b.tar.bz2 |
Added type constraint relations for Java generics to dot graphs and XML output
Diffstat (limited to 'src/classdef.cpp')
-rw-r--r-- | src/classdef.cpp | 85 |
1 files changed, 77 insertions, 8 deletions
diff --git a/src/classdef.cpp b/src/classdef.cpp index 3a103af..486ee3f 100644 --- a/src/classdef.cpp +++ b/src/classdef.cpp @@ -118,6 +118,8 @@ class ClassDefImpl UsesClassDict *usedByImplClassDict; UsesClassDict *usesIntfClassDict; + ConstraintClassDict *constraintClassDict; + /*! Template instances that exists of this class, the key in the * dictionary is the template argument list. */ @@ -216,6 +218,7 @@ void ClassDefImpl::init(const char *defFileName, const char *name, usesImplClassDict=0; usedByImplClassDict=0; usesIntfClassDict=0; + constraintClassDict=0; memberGroupSDict = 0; innerClasses = 0; subGrouping=Config_getBool("SUBGROUPING"); @@ -267,6 +270,7 @@ ClassDefImpl::~ClassDefImpl() delete usesImplClassDict; delete usedByImplClassDict; delete usesIntfClassDict; + delete constraintClassDict; delete incInfo; delete memberGroupSDict; delete innerClasses; @@ -2526,20 +2530,66 @@ bool ClassDef::hasExamples() const return result; } +void ClassDef::addTypeConstraint(const QCString &typeConstraint,const QCString &type) +{ + static bool hideUndocRelation = Config_getBool("HIDE_UNDOC_RELATIONS"); + if (typeConstraint.isEmpty() || type.isEmpty()) return; + ClassDef *cd = getClass(typeConstraint); + if (cd==0 && !hideUndocRelation) + { + cd = new ClassDef(getDefFileName(),getDefLine(),getDefColumn(),typeConstraint,ClassDef::Class); + cd->setUsedOnly(TRUE); + cd->setLanguage(getLanguage()); + Doxygen::hiddenClasses->append(typeConstraint,cd); + //printf("Adding undocumented constraint '%s' to class %s on type %s\n", + // typeConstraint.data(),name().data(),type.data()); + } + if (cd) + { + if (m_impl->constraintClassDict==0) + { + m_impl->constraintClassDict = new ConstraintClassDict(17); + m_impl->constraintClassDict->setAutoDelete(TRUE); + } + ConstraintClassDef *ccd=m_impl->constraintClassDict->find(typeConstraint); + if (ccd==0) + { + ccd = new ConstraintClassDef(cd); + m_impl->constraintClassDict->insert(typeConstraint,ccd); + } + ccd->addAccessor(type); + //printf("Adding constraint '%s' to class %s on type %s\n", + // typeConstraint.data(),name().data(),type.data()); + } +} -void ClassDef::setTemplateArguments(ArgumentList *al) +// Java Type Constrains: A<T extends C & I> +void ClassDef::addTypeConstraints() { - if (al==0) return; - if (!m_impl->tempArgs) delete m_impl->tempArgs; // delete old list if needed - m_impl->tempArgs=new ArgumentList; - ArgumentListIterator ali(*al); - Argument *a; - for (;(a=ali.current());++ali) + if (m_impl->tempArgs) { - m_impl->tempArgs->append(new Argument(*a)); + ArgumentListIterator ali(*m_impl->tempArgs); + Argument *a; + for (;(a=ali.current());++ali) + { + if (!a->typeConstraint.isEmpty()) + { + QCString typeConstraint; + int i=0,p=0; + while ((i=a->typeConstraint.find('&',p))!=-1) // typeConstraint="A &I" for C<T extends A & I> + { + typeConstraint = a->typeConstraint.mid(p,i-p).stripWhiteSpace(); + addTypeConstraint(typeConstraint,a->type); + p=i+1; + } + typeConstraint = a->typeConstraint.right(a->typeConstraint.length()-p).stripWhiteSpace(); + addTypeConstraint(typeConstraint,a->type); + } + } } } +// C# Type Constraints: D<T> where T : C, I void ClassDef::setTypeConstraints(ArgumentList *al) { if (al==0) return; @@ -2553,6 +2603,20 @@ void ClassDef::setTypeConstraints(ArgumentList *al) } } +void ClassDef::setTemplateArguments(ArgumentList *al) +{ + if (al==0) return; + if (!m_impl->tempArgs) delete m_impl->tempArgs; // delete old list if needed + //printf("setting template args '%s' for '%s'\n",tempArgListToString(al,getLanguage()).data(),name().data()); + m_impl->tempArgs=new ArgumentList; + ArgumentListIterator ali(*al); + Argument *a; + for (;(a=ali.current());++ali) + { + m_impl->tempArgs->append(new Argument(*a)); + } +} + /*! Returns \c TRUE iff this class or a class inheriting from this class * is \e not defined in an external tag file. */ @@ -4405,6 +4469,11 @@ UsesClassDict *ClassDef::usedInterfaceClasses() const return m_impl->usesIntfClassDict; } +ConstraintClassDict *ClassDef::templateTypeConstraints() const +{ + return m_impl->constraintClassDict; +} + bool ClassDef::isTemplateArgument() const { return m_impl->isTemplArg; |