qmljscodecompletion.h 2.95 KB
Newer Older
1
2
3
4
/**************************************************************************
**
** This file is part of Qt Creator
**
hjk's avatar
hjk committed
5
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/

Roberto Raggi's avatar
Roberto Raggi committed
30
31
#ifndef QMLJSCODECOMPLETION_H
#define QMLJSCODECOMPLETION_H
32

33
#include <qmljs/qmljsdocument.h>
34
#include <texteditor/icompletioncollector.h>
35
#include <QtCore/QDateTime>
36
#include <QtCore/QPointer>
37
38
39
40
41

namespace TextEditor {
class ITextEditable;
}

42
namespace QmlJSEditor {
43

Roberto Raggi's avatar
Roberto Raggi committed
44
class ModelManagerInterface;
45

46
47
namespace Internal {

48
49
class FunctionArgumentWidget;

Roberto Raggi's avatar
Roberto Raggi committed
50
class CodeCompletion: public TextEditor::ICompletionCollector
51
52
53
54
{
    Q_OBJECT

public:
Roberto Raggi's avatar
Roberto Raggi committed
55
    CodeCompletion(ModelManagerInterface *modelManager, QObject *parent = 0);
Roberto Raggi's avatar
Roberto Raggi committed
56
    virtual ~CodeCompletion();
57

58
59
    virtual TextEditor::ITextEditable *editor() const;
    virtual int startPosition() const;
60
    virtual bool shouldRestartCompletion();
61
62
63
64
65
66
    virtual bool supportsEditor(TextEditor::ITextEditable *editor);
    virtual bool triggersCompletion(TextEditor::ITextEditable *editor);
    virtual int startCompletion(TextEditor::ITextEditable *editor);
    virtual void completions(QList<TextEditor::CompletionItem> *completions);
    virtual void complete(const TextEditor::CompletionItem &item);
    virtual bool partiallyComplete(const QList<TextEditor::CompletionItem> &completionItems);
Roberto Raggi's avatar
Roberto Raggi committed
67
68
    virtual QList<TextEditor::CompletionItem> getCompletions();

69
70
71
    virtual void cleanup();

private:
72
73
    void updateSnippets();

74
    bool maybeTriggersCompletion(TextEditor::ITextEditable *editor);
75
76
    bool isDelimiter(const QChar &ch) const;

Roberto Raggi's avatar
Roberto Raggi committed
77
    ModelManagerInterface *m_modelManager;
78
79
80
    TextEditor::ITextEditable *m_editor;
    int m_startPosition;
    QList<TextEditor::CompletionItem> m_completions;
81
82
83

    QList<TextEditor::CompletionItem> m_snippets;
    QDateTime m_snippetFileLastModified;
84
    QPointer<FunctionArgumentWidget> m_functionArgumentWidget;
85
86
87
88
};


} // end of namespace Internal
89
} // end of namespace QmlJSEditor
90

Roberto Raggi's avatar
Roberto Raggi committed
91
#endif // QMLJSCODECOMPLETION_H