1 /****************************************************************************
2 **
3 ** Copyright (C) 2017 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the tools applications of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21 ** included in the packaging of this file. Please review the following
22 ** information to ensure the GNU General Public License requirements will
23 ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24 **
25 ** $QT_END_LICENSE$
26 **
27 ****************************************************************************/
28 
29 /*
30   qmlcodemarker.h
31 */
32 
33 #ifndef QMLCODEMARKER_H
34 #define QMLCODEMARKER_H
35 
36 #include "cppcodemarker.h"
37 
38 #ifndef QT_NO_DECLARATIVE
39 #    include <private/qqmljsastfwd_p.h>
40 #endif
41 
42 QT_BEGIN_NAMESPACE
43 
44 #ifndef QT_NO_DECLARATIVE
45 #    include <private/qqmlapiversion_p.h>
46 #    if Q_QML_PRIVATE_API_VERSION < 8
47 namespace QQmlJS {
48     using SourceLocation = AST::SourceLocation;
49 }
50 #    endif
51 #endif
52 
53 class QmlCodeMarker : public CppCodeMarker
54 {
55     Q_DECLARE_TR_FUNCTIONS(QDoc::QmlCodeMarker)
56 
57 public:
58     QmlCodeMarker();
59     ~QmlCodeMarker() override;
60 
61     bool recognizeCode(const QString &code) override;
62     bool recognizeExtension(const QString &ext) override;
63     bool recognizeLanguage(const QString &language) override;
64     Atom::AtomType atomType() const override;
65     virtual QString markedUpCode(const QString &code, const Node *relative,
66                                  const Location &location) override;
67 
68     QString markedUpName(const Node *node) override;
69     QString markedUpFullName(const Node *node, const Node *relative) override;
70     QString markedUpIncludes(const QStringList &includes) override;
71     QString functionBeginRegExp(const QString &funcName) override;
72     QString functionEndRegExp(const QString &funcName) override;
73 
74     /* Copied from src/declarative/qml/qdeclarativescriptparser.cpp */
75 #ifndef QT_NO_DECLARATIVE
76     QVector<QQmlJS::SourceLocation> extractPragmas(QString &script);
77 #endif
78 
79 private:
80     QString addMarkUp(const QString &code, const Node *relative, const Location &location);
81 };
82 
83 QT_END_NAMESPACE
84 
85 #endif
86