KDevelop API Documentation

codemodel_utils.cpp

Go to the documentation of this file.
00001 /* This file is part of KDevelop
00002     Copyright (C) 2003 Roberto Raggi <roberto@kdevelop.org>
00003     Copyright (C) 2003 Alexander Dymo <cloudtemple@mksat.net>
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public License
00016     along with this library; see the file COPYING.LIB.  If not, write to
00017     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00018     Boston, MA 02111-1307, USA.
00019 */
00020 
00021 #include "codemodel_utils.h"
00022 
00023 namespace CodeModelUtils
00024 {
00025 
00026 namespace Functions
00027 {
00028 
00029 void processClasses(FunctionList &list, const ClassDom dom)
00030 {
00031     const ClassList cllist = dom->classList();
00032     for (ClassList::ConstIterator it = cllist.begin(); it != cllist.end(); ++it)
00033     {
00034         processClasses(list, *it);
00035     }
00036 
00037     const FunctionList fnlist = dom->functionList();
00038     for (FunctionList::ConstIterator it = fnlist.begin(); it != fnlist.end(); ++it)
00039     {
00040         list.append(*it);
00041     }
00042 }
00043 
00044 void processNamespaces(FunctionList &list, const NamespaceDom dom)
00045 {
00046     const NamespaceList nslist = dom->namespaceList();
00047     for (NamespaceList::ConstIterator it = nslist.begin(); it != nslist.end(); ++it)
00048     {
00049         processNamespaces(list, *it);
00050     }
00051     const ClassList cllist = dom->classList();
00052     for (ClassList::ConstIterator it = cllist.begin(); it != cllist.end(); ++it)
00053     {
00054         processClasses(list, *it);
00055     }
00056 
00057     const FunctionList fnlist = dom->functionList();
00058     for (FunctionList::ConstIterator it = fnlist.begin(); it != fnlist.end(); ++it)
00059     {
00060         list.append(*it);
00061     }
00062 }
00063 
00064 void processNamespaces( FunctionList & list, const NamespaceDom dom, QMap< FunctionDom, Scope > & relations )
00065 {
00066     const NamespaceList nslist = dom->namespaceList();
00067     for (NamespaceList::ConstIterator it = nslist.begin(); it != nslist.end(); ++it)
00068     {
00069         processNamespaces(list, *it, relations);
00070     }
00071     const ClassList cllist = dom->classList();
00072     for (ClassList::ConstIterator it = cllist.begin(); it != cllist.end(); ++it)
00073     {
00074         processClasses(list, *it, relations, dom);
00075     }
00076 
00077     const FunctionList fnlist = dom->functionList();
00078     for (FunctionList::ConstIterator it = fnlist.begin(); it != fnlist.end(); ++it)
00079     {
00080         list.append(*it);
00081         relations[*it].ns = dom;
00082     }
00083 }
00084 
00085 void processClasses( FunctionList & list, const ClassDom dom, QMap< FunctionDom, Scope > & relations )
00086 {
00087     const ClassList cllist = dom->classList();
00088     for (ClassList::ConstIterator it = cllist.begin(); it != cllist.end(); ++it)
00089     {
00090         processClasses(list, *it, relations);
00091     }
00092 
00093     const FunctionList fnlist = dom->functionList();
00094     for (FunctionList::ConstIterator it = fnlist.begin(); it != fnlist.end(); ++it)
00095     {
00096         list.append(*it);
00097         relations[*it].klass = dom;
00098     }
00099 }
00100 
00101 void processClasses( FunctionList & list, const ClassDom dom, QMap< FunctionDom, Scope > & relations, const NamespaceDom & nsdom )
00102 {
00103     const ClassList cllist = dom->classList();
00104     for (ClassList::ConstIterator it = cllist.begin(); it != cllist.end(); ++it)
00105     {
00106         processClasses(list, *it, relations, nsdom);
00107     }
00108 
00109     const FunctionList fnlist = dom->functionList();
00110     for (FunctionList::ConstIterator it = fnlist.begin(); it != fnlist.end(); ++it)
00111     {
00112         list.append(*it);
00113         relations[*it].klass = dom;
00114         relations[*it].ns = nsdom;
00115     }
00116 }
00117 
00118 } // end of Functions namespace
00119 
00120 
00121 
00122 namespace FunctionDefinitions
00123 {
00124 
00125 void processClasses(FunctionDefinitionList &list, const ClassDom dom)
00126 {
00127     const ClassList cllist = dom->classList();
00128     for (ClassList::ConstIterator it = cllist.begin(); it != cllist.end(); ++it)
00129     {
00130         processClasses(list, *it);
00131     }
00132 
00133     const FunctionDefinitionList fnlist = dom->functionDefinitionList();
00134     for (FunctionDefinitionList::ConstIterator it = fnlist.begin(); it != fnlist.end(); ++it)
00135     {
00136         list.append(*it);
00137     }
00138 }
00139 
00140 void processNamespaces(FunctionDefinitionList &list, const NamespaceDom dom)
00141 {
00142     const NamespaceList nslist = dom->namespaceList();
00143     for (NamespaceList::ConstIterator it = nslist.begin(); it != nslist.end(); ++it)
00144     {
00145         processNamespaces(list, *it);
00146     }
00147     const ClassList cllist = dom->classList();
00148     for (ClassList::ConstIterator it = cllist.begin(); it != cllist.end(); ++it)
00149     {
00150         processClasses(list, *it);
00151     }
00152 
00153     const FunctionDefinitionList fnlist = dom->functionDefinitionList();
00154     for (FunctionDefinitionList::ConstIterator it = fnlist.begin(); it != fnlist.end(); ++it)
00155     {
00156         list.append(*it);
00157     }
00158 }
00159 
00160 void processNamespaces( FunctionDefinitionList & list, const NamespaceDom dom, QMap< FunctionDefinitionDom, Scope > & relations )
00161 {
00162     const NamespaceList nslist = dom->namespaceList();
00163     for (NamespaceList::ConstIterator it = nslist.begin(); it != nslist.end(); ++it)
00164     {
00165         processNamespaces(list, *it, relations);
00166     }
00167     const ClassList cllist = dom->classList();
00168     for (ClassList::ConstIterator it = cllist.begin(); it != cllist.end(); ++it)
00169     {
00170         processClasses(list, *it, relations, dom);
00171     }
00172 
00173     const FunctionDefinitionList fnlist = dom->functionDefinitionList();
00174     for (FunctionDefinitionList::ConstIterator it = fnlist.begin(); it != fnlist.end(); ++it)
00175     {
00176         list.append(*it);
00177         relations[*it].ns = dom;
00178     }
00179 }
00180 
00181 void processClasses( FunctionDefinitionList & list, const ClassDom dom, QMap< FunctionDefinitionDom, Scope > & relations )
00182 {
00183     const ClassList cllist = dom->classList();
00184     for (ClassList::ConstIterator it = cllist.begin(); it != cllist.end(); ++it)
00185     {
00186         processClasses(list, *it, relations);
00187     }
00188 
00189     const FunctionDefinitionList fnlist = dom->functionDefinitionList();
00190     for (FunctionDefinitionList::ConstIterator it = fnlist.begin(); it != fnlist.end(); ++it)
00191     {
00192         list.append(*it);
00193         relations[*it].klass = dom;
00194     }
00195 }
00196 
00197 void processClasses( FunctionDefinitionList & list, const ClassDom dom, QMap< FunctionDefinitionDom, Scope > & relations, const NamespaceDom & nsdom )
00198 {
00199     const ClassList cllist = dom->classList();
00200     for (ClassList::ConstIterator it = cllist.begin(); it != cllist.end(); ++it)
00201     {
00202         processClasses(list, *it, relations, nsdom);
00203     }
00204 
00205     const FunctionDefinitionList fnlist = dom->functionDefinitionList();
00206     for (FunctionDefinitionList::ConstIterator it = fnlist.begin(); it != fnlist.end(); ++it)
00207     {
00208         list.append(*it);
00209         relations[*it].klass = dom;
00210         relations[*it].ns = nsdom;
00211     }
00212 }
00213 
00214 } // end of FunctionDefinitions namespace
00215 
00216 
00217 
00218 FunctionList allFunctions(const FileDom &dom)
00219 {
00220     using namespace Functions;
00221     FunctionList list;
00222 
00223     const NamespaceList nslist = dom->namespaceList();
00224     for (NamespaceList::ConstIterator it = nslist.begin(); it != nslist.end(); ++it)
00225     {
00226         processNamespaces(list, *it);
00227     }
00228 
00229     const ClassList cllist = dom->classList();
00230     for (ClassList::ConstIterator it = cllist.begin(); it != cllist.end(); ++it)
00231     {
00232         processClasses(list, *it);
00233     }
00234 
00235     const FunctionList fnlist = dom->functionList();
00236     for (FunctionList::ConstIterator it = fnlist.begin(); it != fnlist.end(); ++it)
00237     {
00238         list.append(*it);
00239     }
00240 
00241     return list;
00242 }
00243 
00244 AllFunctions allFunctionsDetailed( const FileDom & dom )
00245 {
00246     using namespace Functions;
00247     AllFunctions list;
00248 
00249     const NamespaceList nslist = dom->namespaceList();
00250     for (NamespaceList::ConstIterator it = nslist.begin(); it != nslist.end(); ++it)
00251     {
00252         processNamespaces(list.functionList, *it, list.relations);
00253     }
00254 
00255     const ClassList cllist = dom->classList();
00256     for (ClassList::ConstIterator it = cllist.begin(); it != cllist.end(); ++it)
00257     {
00258         processClasses(list.functionList, *it, list.relations);
00259     }
00260 
00261     const FunctionList fnlist = dom->functionList();
00262     for (FunctionList::ConstIterator it = fnlist.begin(); it != fnlist.end(); ++it)
00263     {
00264         list.functionList.append(*it);
00265     }
00266 
00267     return list;
00268 }
00269 
00270 AllFunctionDefinitions allFunctionDefinitionsDetailed( const FileDom & dom )
00271 {
00272     using namespace FunctionDefinitions;
00273     AllFunctionDefinitions list;
00274 
00275     const NamespaceList nslist = dom->namespaceList();
00276     for (NamespaceList::ConstIterator it = nslist.begin(); it != nslist.end(); ++it)
00277     {
00278         processNamespaces(list.functionList, *it, list.relations);
00279     }
00280 
00281     const ClassList cllist = dom->classList();
00282     for (ClassList::ConstIterator it = cllist.begin(); it != cllist.end(); ++it)
00283     {
00284         processClasses(list.functionList, *it, list.relations);
00285     }
00286 
00287     const FunctionDefinitionList fnlist = dom->functionDefinitionList();
00288     for (FunctionDefinitionList::ConstIterator it = fnlist.begin(); it != fnlist.end(); ++it)
00289     {
00290         list.functionList.append(*it);
00291     }
00292 
00293     return list;
00294 }
00295 
00296 bool compareDeclarationToDefinition( const FunctionDom & dec, const FunctionDefinitionDom & def )
00297 {
00298     if (dec->scope() == def->scope() && dec->name() == def->name() && dec->resultType() == def->resultType() && dec->isConstant() == def->isConstant())
00299     {
00300         const ArgumentList defList = def->argumentList(), decList = dec->argumentList();
00301         if (defList.size() != decList.size())
00302             return false;
00303         
00304         size_t n = defList.size();
00305         for(size_t i = 0; i < n; ++i)
00306             if (defList[i]->type() != decList[i]->type())
00307                 return false;
00308         
00309         return true;
00310     }
00311     return false;
00312 }
00313 
00314 }//end of namespace CodeModeUtils
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 23 00:03:52 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003