2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2011-08-16 09:47:54 +02:00
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2011-08-16 09:47:54 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2011-08-16 09:47:54 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
|
** use the contact form at http://qt.digia.com/contact-us.
|
2011-08-16 09:47:54 +02:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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.
|
2011-08-16 09:47:54 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2011-08-16 09:47:54 +02:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2011-08-16 09:47:54 +02:00
|
|
|
|
|
|
|
|
#ifndef QMLJSSEMANTICHIGHLIGHTER_H
|
|
|
|
|
#define QMLJSSEMANTICHIGHLIGHTER_H
|
|
|
|
|
|
|
|
|
|
#include <texteditor/semantichighlighter.h>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QFutureWatcher>
|
2013-02-07 00:10:05 +01:00
|
|
|
#include <QTextLayout>
|
|
|
|
|
#include <QVector>
|
2011-08-16 09:47:54 +02:00
|
|
|
|
|
|
|
|
namespace QmlJS {
|
|
|
|
|
class ScopeChain;
|
|
|
|
|
namespace AST {
|
|
|
|
|
class SourceLocation;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace TextEditor {
|
|
|
|
|
class FontSettings;
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-07 00:10:05 +01:00
|
|
|
namespace QmlJSTools {
|
|
|
|
|
class SemanticInfo;
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-16 09:47:54 +02:00
|
|
|
namespace QmlJSEditor {
|
|
|
|
|
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2014-01-29 14:10:43 +01:00
|
|
|
class QmlJSEditorDocument;
|
|
|
|
|
|
2011-08-16 09:47:54 +02:00
|
|
|
class SemanticHighlighter : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
enum UseType
|
|
|
|
|
{
|
|
|
|
|
UnknownType,
|
|
|
|
|
LocalIdType, // ids in the same file
|
|
|
|
|
ExternalIdType, // ids from instantiating files
|
|
|
|
|
QmlTypeType, // qml types
|
|
|
|
|
RootObjectPropertyType, // property in root object
|
|
|
|
|
ScopeObjectPropertyType, // property in scope object
|
|
|
|
|
ExternalObjectPropertyType, // property in root object of instantiating file
|
|
|
|
|
JsScopeType, // var or function in local js scope
|
|
|
|
|
JsImportType, // name of js import
|
|
|
|
|
JsGlobalType, // in global scope
|
2011-09-12 14:00:05 +02:00
|
|
|
LocalStateNameType, // name of a state in the current file
|
|
|
|
|
BindingNameType, // name on the left hand side of a binding
|
2013-02-07 00:10:05 +01:00
|
|
|
FieldType, // member of an object
|
|
|
|
|
Max // number of the last used value (to generate the warning formats)
|
2011-08-16 09:47:54 +02:00
|
|
|
};
|
|
|
|
|
|
2013-04-16 16:48:10 +02:00
|
|
|
typedef TextEditor::HighlightingResult Use;
|
2011-08-16 09:47:54 +02:00
|
|
|
|
2014-01-29 14:10:43 +01:00
|
|
|
SemanticHighlighter(QmlJSEditorDocument *document);
|
2011-08-16 09:47:54 +02:00
|
|
|
|
2013-02-07 00:10:05 +01:00
|
|
|
void rerun(const QmlJSTools::SemanticInfo &scopeChain);
|
2011-09-12 12:58:59 +02:00
|
|
|
void cancel();
|
|
|
|
|
|
|
|
|
|
int startRevision() const;
|
2011-08-16 09:47:54 +02:00
|
|
|
|
|
|
|
|
void updateFontSettings(const TextEditor::FontSettings &fontSettings);
|
2013-02-07 00:10:05 +01:00
|
|
|
void reportMessagesInfo(const QVector<QTextLayout::FormatRange> &diagnosticMessages,
|
|
|
|
|
const QHash<int,QTextCharFormat> &formats);
|
2011-08-16 09:47:54 +02:00
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
void applyResults(int from, int to);
|
|
|
|
|
void finished();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
QFutureWatcher<Use> m_watcher;
|
2014-01-29 14:10:43 +01:00
|
|
|
QmlJSEditorDocument *m_document;
|
2011-08-16 09:47:54 +02:00
|
|
|
int m_startRevision;
|
|
|
|
|
QHash<int, QTextCharFormat> m_formats;
|
2013-02-07 00:10:05 +01:00
|
|
|
QHash<int, QTextCharFormat> m_extraFormats;
|
|
|
|
|
QVector<QTextLayout::FormatRange> m_diagnosticRanges;
|
2011-08-16 09:47:54 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace QmlJSEditor
|
|
|
|
|
|
|
|
|
|
#endif // QMLJSSEMANTICHIGHLIGHTER_H
|