• Skip to content
  • Skip to link menu
KDE 4.4 API Reference
  • KDE API Reference
  • KDevelop Platform Libraries
  • Sitemap
  • Contact Us
 

language/duchain

declarationid.h

00001 /* This file is part of KDevelop
00002     Copyright 2008 David Nolden <david.nolden.kdevelop@art-master.de>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License version 2 as published by the Free Software Foundation.
00007 
00008    This library is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011    Library General Public License for more details.
00012 
00013    You should have received a copy of the GNU Library General Public License
00014    along with this library; see the file COPYING.LIB.  If not, write to
00015    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00016    Boston, MA 02110-1301, USA.
00017 */
00018 
00019 #ifndef DECLARATION_ID_H
00020 #define DECLARATION_ID_H
00021 
00022 #include "../editor/hashedstring.h"
00023 #include "../editor/simplecursor.h"
00024 
00025 #include "identifier.h"
00026 #include "indexeditems.h"
00027 #include "instantiationinformation.h"
00028 
00029 //krazy:excludeall=dpointer
00030 
00031 class QString;
00032 
00033 namespace KDevelop {
00034 
00035 class Declaration;
00036 class TopDUContext;
00037 
00055 class KDEVPLATFORMLANGUAGE_EXPORT DeclarationId {
00056   public:
00065     explicit DeclarationId(const IndexedQualifiedIdentifier& id = IndexedQualifiedIdentifier(), uint additionalId = 0, IndexedInstantiationInformation specialization = IndexedInstantiationInformation());
00066 
00074     explicit DeclarationId(const IndexedDeclaration& decl, IndexedInstantiationInformation specialization = IndexedInstantiationInformation());
00075 
00082     bool operator==(const DeclarationId& rhs) const {
00083       if(m_direct != rhs.m_direct)
00084         return false;
00085 
00086       if(!m_direct)
00087         return indirect.m_identifier == rhs.indirect.m_identifier && indirect.m_additionalIdentity == rhs.indirect.m_additionalIdentity && m_specialization == rhs.m_specialization;
00088       else
00089         return direct == rhs.direct && m_specialization == rhs.m_specialization;
00090     }
00091 
00098     bool operator!=(const DeclarationId& rhs) const {
00099       return !operator==(rhs);
00100     }
00101 
00105     bool isValid() const {
00106       return (m_direct && direct.isValid()) || indirect.m_identifier.isValid();
00107     }
00108 
00115     uint hash() const {
00116       if(m_direct)
00117         return direct.hash() + m_specialization.index() * 101;
00118       else
00119         return indirect.m_identifier.getIndex() * 13 + indirect.m_additionalIdentity + m_specialization.index() * 101;
00120     }
00121 
00129     Declaration* getDeclaration(const TopDUContext* context) const;
00130 
00132     KDevVarLengthArray<Declaration*> getDeclarations(const TopDUContext* context) const;
00133     
00139     void setSpecialization(IndexedInstantiationInformation specialization);
00140 
00146     IndexedInstantiationInformation specialization() const;
00147 
00154     bool isDirect() const;
00155 
00162     QualifiedIdentifier qualifiedIdentifier() const;
00163 
00164   private:
00165     struct Indirect {
00166       IndexedQualifiedIdentifier m_identifier;
00167       uint m_additionalIdentity; //Hash from signature, or similar. Used to disambiguate multiple declarations of the same name.
00168     } ;
00169 
00170     //union {
00171       //An indirect reference to the declaration, which uses the symbol-table for lookup. Should be preferred for all
00172       //declarations that are in the symbol-table
00173       Indirect indirect;
00174       IndexedDeclaration direct;
00175     //};
00176     bool m_direct;
00177     IndexedInstantiationInformation m_specialization; //Can be used in a language-specific way to pick other versions of the declaration.
00178                            //When the declaration is found, pickSpecialization is called on the found declaration with this value, and
00179                            //the returned value is the actually found declaration.
00180 };
00181 
00182 inline uint qHash(const KDevelop::DeclarationId& id) {
00183   return id.hash();
00184 }
00185 
00186 }
00187 
00188 #endif

language/duchain

Skip menu "language/duchain"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

KDevelop Platform Libraries

Skip menu "KDevelop Platform Libraries"
  • interfaces
  • language
  •   codegen
  •   duchain
  •   editor
  • outputview
  • project
  • shell
  • sublime
  • util
  • vcs
Generated for KDevelop Platform Libraries by doxygen 1.5.9-20090814
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal