KDevelop API Documentation

cppcodecompletion.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                           cppcodecompletion.h  -  description
00003                              -------------------
00004     begin                : Sat Jul 21 2001
00005     copyright            : (C) 2001 by Victor Röder
00006     email                : victor_roeder@gmx.de
00007     copyright            : (C) 2002,2003 by Roberto Raggi
00008     email                : roberto@kdevelop.org
00009  ***************************************************************************/
00010 
00011 /***************************************************************************
00012  *                                                                         *
00013  *   This program is free software; you can redistribute it and/or modify  *
00014  *   it under the terms of the GNU General Public License as published by  *
00015  *   the Free Software Foundation; either version 2 of the License, or     *
00016  *   (at your option) any later version.                                   *
00017  *                                                                         *
00018  ***************************************************************************/
00019 
00020 #ifndef __CPPCODECOMPLETION_H__
00021 #define __CPPCODECOMPLETION_H__
00022 
00023 #include "cppsupportpart.h"
00024 
00025 #include <ast.h>
00026 #include <codemodel.h>
00027 
00028 #include <ktexteditor/viewcursorinterface.h>
00029 #include <ktexteditor/editinterface.h>
00030 #include <ktexteditor/codecompletioninterface.h>
00031 
00032 #include <qobject.h>
00033 #include <qstringlist.h>
00034 #include <qtimer.h>
00035 #include <qguardedptr.h>
00036 #include <qregexp.h>
00037 
00038 class CodeInformationRepository;
00039 class SimpleContext;
00040 class CppCodeCompletionData;
00041 
00042 class CppCodeCompletion : public QObject
00043 {
00044     Q_OBJECT
00045 public:
00046     enum CompletionMode
00047     {
00048         NormalCompletion,
00049         SignalCompletion,
00050         SlotCompletion
00051     };
00052 
00053 public:
00054     CppCodeCompletion( CppSupportPart* part );
00055     virtual ~CppCodeCompletion();
00056 
00057     CodeInformationRepository* repository() { return m_repository; }
00058     CompletionMode completionMode() const { return m_completionMode; }
00059 
00060     int expressionAt( const QString& text, int index );
00061     QStringList splitExpression( const QString& text );
00062     QStringList typeOf( const QString& name, const QStringList& scope );
00063     QStringList evaluateExpression( QString expr, SimpleContext* ctx );
00064 
00065     static QStringList typeName( const QString& name );
00066 
00067 public slots:
00068     void completeText();
00069 
00070 private slots:
00071     void slotPartAdded(KParts::Part *part);
00072     void slotActivePartChanged(KParts::Part *part);
00073     void slotArgHintHided();
00074     void slotCompletionBoxHided( KTextEditor::CompletionEntry entry );
00075     void slotTextChanged();
00076     void slotFileParsed( const QString& fileName );
00077     void slotTimeout();
00078     void computeFileEntryList();
00079 
00080 private:
00081     void integratePart( KParts::Part* part );
00082     void setupCodeInformationRepository();
00083     FunctionDefinitionAST* functionDefinition( AST* node );
00084     void computeRecoveryPoints();
00085 
00086     QStringList evaluateExpressionInternal( QStringList& exprList, const QStringList& scope, SimpleContext* ctx=0 );
00087 
00088     QStringList typeOf( const QValueList<Tag>& tags );
00089     QStringList typeOf( const QString& name, ClassDom klass );
00090     QStringList typeOf( const QString& name, NamespaceDom scope );
00091     QStringList typeOf( const QString& name, const FunctionList& methods );
00092 
00094     void computeCompletionEntryList( QValueList<KTextEditor::CompletionEntry>& entryList, SimpleContext* ctx, bool isInstance );
00095     void computeCompletionEntryList( QValueList<KTextEditor::CompletionEntry>& entryList, const QStringList& type, bool isInstance );
00096     void computeCompletionEntryList( QValueList<KTextEditor::CompletionEntry>& entryList, QValueList<Tag>& tags, bool isInstance );
00097     void computeCompletionEntryList( QValueList<KTextEditor::CompletionEntry>& entryList, ClassDom klass, bool isInstance );
00098     void computeCompletionEntryList( QValueList<KTextEditor::CompletionEntry>& entryList, NamespaceDom scope, bool isInstance );
00099     void computeCompletionEntryList( QValueList<KTextEditor::CompletionEntry>& entryList, const FunctionList& methods, bool isInstance );
00100     void computeCompletionEntryList( QValueList<KTextEditor::CompletionEntry>& entryList, const VariableList& attributes, bool isInstance );
00101     void computeCompletionEntryList( QValueList<KTextEditor::CompletionEntry>& entryList, const ClassList& lst, bool isInstance );
00102     void computeCompletionEntryList( QValueList<KTextEditor::CompletionEntry>& entryList, const NamespaceList& lst, bool isInstance );
00103 
00104     void computeSignatureList( QStringList& signatureList, const QString& name, const QStringList& type );
00105     void computeSignatureList( QStringList& signatureList, const QString& name, ClassDom klass );
00106     void computeSignatureList( QStringList& signatureList, const QString& name, const FunctionList& methods );
00107     void computeSignatureList( QStringList& signatureList, const QString& name, QValueList<Tag>& tags );
00108 
00109     SimpleContext* computeContext( FunctionDefinitionAST* ast, int line, int col );
00110     void computeContext( SimpleContext*& ctx, StatementAST* ast, int line, int col );
00111     void computeContext( SimpleContext*& ctx, StatementListAST* ast, int line, int col );
00112     void computeContext( SimpleContext*& ctx, IfStatementAST* ast, int line, int col );
00113     void computeContext( SimpleContext*& ctx, ForStatementAST* ast, int line, int col );
00114     void computeContext( SimpleContext*& ctx, DoStatementAST* ast, int line, int col );
00115     void computeContext( SimpleContext*& ctx, WhileStatementAST* ast, int line, int col );
00116     void computeContext( SimpleContext*& ctx, SwitchStatementAST* ast, int line, int col );
00117     void computeContext( SimpleContext*& ctx, DeclarationStatementAST* ast, int line, int col );
00118     void computeContext( SimpleContext*& ctx, ConditionAST* ast, int line, int col );
00119 
00120     QString getText( int startLine, int startColumn, int endLine, int endColumn );
00121 
00122     ClassDom findContainer( const QString& name, NamespaceDom container=0, bool includeImports=false );
00123     QString findClass( const QString& className );
00124 
00125 private:
00126     QGuardedPtr<CppSupportPart> m_pSupport;
00127     QTimer* m_ccTimer;
00128     QString m_activeFileName;
00129     KTextEditor::ViewCursorInterface* m_activeCursor;
00130     KTextEditor::EditInterface* m_activeEditor;
00131     KTextEditor::CodeCompletionInterface* m_activeCompletion;
00132 
00133     bool m_bArgHintShow;
00134     bool m_bCompletionBoxShow;
00135 
00136     unsigned int m_ccLine;
00137     unsigned int m_ccColumn;
00138 
00139     CodeInformationRepository* m_repository;
00140     CppCodeCompletionData* d;
00141     CompletionMode m_completionMode;
00142 
00143     QRegExp m_includeRx;
00144     QValueList<KTextEditor::CompletionEntry> m_fileEntryList;
00145 };
00146 
00147 #endif
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Feb 22 09:22:28 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003