OSDN Git Service

It's 2011 now.
[qt-creator-jp/qt-creator-jp.git] / src / plugins / texteditor / generichighlighter / highlightdefinition.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
8 **
9 ** No Commercial Usage
10 **
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
14 ** this package.
15 **
16 ** GNU Lesser General Public License Usage
17 **
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file.  Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights.  These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
31 **
32 **************************************************************************/
33
34 #ifndef HIGHLIGHTDEFINITION_H
35 #define HIGHLIGHTDEFINITION_H
36
37 #include <QtCore/QString>
38 #include <QtCore/QHash>
39 #include <QtCore/QSet>
40 #include <QtCore/QSharedPointer>
41
42 namespace TextEditor {
43 namespace Internal {
44
45 class KeywordList;
46 class Context;
47 class ItemData;
48
49 class HighlightDefinition
50 {
51 public:
52     HighlightDefinition();
53     ~HighlightDefinition();
54
55     QSharedPointer<KeywordList> createKeywordList(const QString &list);
56     QSharedPointer<KeywordList> keywordList(const QString &list);
57
58     QSharedPointer<Context> createContext(const QString &context, bool initial);
59     QSharedPointer<Context> initialContext() const;
60     QSharedPointer<Context> context(const QString &context) const;
61     const QHash<QString, QSharedPointer<Context> > &contexts() const;
62
63     QSharedPointer<ItemData> createItemData(const QString &itemData);
64     QSharedPointer<ItemData> itemData(const QString &itemData) const;
65
66     void setKeywordsSensitive(const QString &sensitivity);
67     Qt::CaseSensitivity keywordsSensitive() const;
68
69     void addDelimiters(const QString &characters);
70     void removeDelimiters(const QString &characters);
71     bool isDelimiter(const QChar &character) const;
72
73     void setSingleLineComment(const QString &start);
74     const QString &singleLineComment() const;
75
76     void setCommentAfterWhitespaces(const QString &after);
77     bool isCommentAfterWhiteSpaces() const;
78
79     void setMultiLineCommentStart(const QString &start);
80     const QString &multiLineCommentStart() const;
81
82     void setMultiLineCommentEnd(const QString &end);
83     const QString &multiLineCommentEnd() const;
84
85     void setMultiLineCommentRegion(const QString &region);
86     const QString &multiLineCommentRegion() const;
87
88     void setIndentationBasedFolding(const QString &indentationBasedFolding);
89     bool isIndentationBasedFolding() const;
90
91 private:
92     Q_DISABLE_COPY(HighlightDefinition)
93
94     struct GenericHelper
95     {
96         template <class Element, class Container>
97         QSharedPointer<Element> create(const QString &name, Container &container);
98
99         template <class Element, class Container>
100         QSharedPointer<Element> find(const QString &name, const Container &container) const;
101     };
102     GenericHelper m_helper;
103
104     QHash<QString, QSharedPointer<KeywordList> > m_lists;
105     QHash<QString, QSharedPointer<Context> > m_contexts;
106     QHash<QString, QSharedPointer<ItemData> > m_itemsData;
107
108     QString m_initialContext;
109
110     QString m_singleLineComment;
111     bool m_singleLineCommentAfterWhiteSpaces;
112
113     QString m_multiLineCommentStart;
114     QString m_multiLineCommentEnd;
115     QString m_multiLineCommentRegion;
116
117     Qt::CaseSensitivity m_keywordCaseSensitivity;
118
119     bool m_indentationBasedFolding;
120
121     QSet<QChar> m_delimiters;
122 };
123
124 } // namespace Internal
125 } // namespace TextEditor
126
127 #endif // HIGHLIGHTDEFINITION_H