1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
|
/*
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef MISSINGINCLUDECOMPLETIONMODEL_H
#define MISSINGINCLUDECOMPLETIONMODEL_H
#include <language/codecompletion/codecompletionmodel.h>
#include <language/codecompletion/codecompletionworker.h>
#include <ktexteditor/codecompletionmodelcontrollerinterface.h>
#include <qwaitcondition.h>
#include <qmutex.h>
#include <language/duchain/ducontext.h>
namespace KDevelop {
class ParseJob;
}
namespace Cpp {
class MissingIncludeCompletionWorker;
class MissingIncludeCompletionModel : public KDevelop::CodeCompletionModel
{
Q_OBJECT
public:
void stop();
MissingIncludeCompletionModel(QObject* parent);
~MissingIncludeCompletionModel();
//Bridge from Cpp::CodeCompletionModel to this model
void startWithExpression(KDevelop::DUContextPointer context, const QString& prefixExpression, const QString& localExpression);
static MissingIncludeCompletionModel& self();
static void startCompletionAfterParsing(const KDevelop::IndexedString& url);
private slots:
void parseJobFinished(KDevelop::ParseJob* job);
protected:
virtual QString filterString(KTextEditor::View* view, const KTextEditor::Range& range, const KTextEditor::Cursor& position);
virtual KTextEditor::Range updateCompletionRange(KTextEditor::View* view, const KTextEditor::Range& range);
MissingIncludeCompletionWorker* worker() const;
virtual void completionInvokedInternal(KTextEditor::View* view, const KTextEditor::Range& range, KTextEditor::CodeCompletionModel::InvocationType invocationType, const KUrl& url);
virtual KDevelop::CodeCompletionWorker* createCompletionWorker ();
virtual KTextEditor::CodeCompletionModelControllerInterface3::MatchReaction matchingItem(const QModelIndex& matched);
};
class MissingIncludeCompletionWorker : public KDevelop::CodeCompletionWorker {
public:
MissingIncludeCompletionWorker(KDevelop::CodeCompletionModel* model);
~MissingIncludeCompletionWorker();
QMutex mutex;
QWaitCondition wait;
QString localExpression; //The local expression, that is represented by the completion-range, for example "map" as component of "std::map"
QString prefixExpression; //The prefix-expression, like "std::"
//This contains the current surrounding context, and is also used as marker whether this completion is enabled.
KDevelop::IndexedDUContext context;
void allowCompletion();
bool aborted() {
return aborting();
}
virtual void abortCurrentCompletion();
virtual void doSpecialProcessing(unsigned int data);
protected:
virtual void computeCompletions(KDevelop::DUContextPointer context, const KTextEditor::Cursor& position, KTextEditor::View* view, const KTextEditor::Range& contextRange, const QString& contextText);
};
}
#endif // MISSINGINCLUDECOMPLETIONMODEL_H
|