1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
10 ** GNU Lesser General Public License Usage
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
31 **************************************************************************/
33 #ifndef HIGHLIGHTDEFINITIONHANDLER_H
34 #define HIGHLIGHTDEFINITIONHANDLER_H
36 #include <QtCore/QString>
37 #include <QtCore/QList>
38 #include <QtCore/QSharedPointer>
39 #include <QtCore/QStack>
41 #include <QtXml/QXmlDefaultHandler>
43 namespace TextEditor {
49 class HighlightDefinition;
51 class HighlightDefinitionHandler : public QXmlDefaultHandler
54 HighlightDefinitionHandler(const QSharedPointer<HighlightDefinition> &definition);
55 ~HighlightDefinitionHandler();
59 bool startElement(const QString &namespaceURI, const QString &localName,
60 const QString &qName, const QXmlAttributes &atts);
61 bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName);
62 bool characters(const QString &ch);
65 void listElementStarted(const QXmlAttributes &atts);
66 void itemElementStarted();
67 void contextElementStarted(const QXmlAttributes &atts);
68 void itemDataElementStarted(const QXmlAttributes &atts) const;
69 void commentElementStarted(const QXmlAttributes &atts) const;
70 void keywordsElementStarted(const QXmlAttributes &atts) const;
71 void foldingElementStarted(const QXmlAttributes &atts) const;
72 void ruleElementStarted(const QXmlAttributes &atts, const QSharedPointer<Rule> &rule);
75 void detectCharStarted(const QXmlAttributes &atts);
76 void detect2CharsStarted(const QXmlAttributes &atts);
77 void anyCharStarted(const QXmlAttributes &atts);
78 void stringDetectedStarted(const QXmlAttributes &atts);
79 void regExprStarted(const QXmlAttributes &atts);
80 void keywordStarted(const QXmlAttributes &atts);
81 void intStarted(const QXmlAttributes &atts);
82 void floatStarted(const QXmlAttributes &atts);
83 void hlCOctStarted(const QXmlAttributes &atts);
84 void hlCHexStarted(const QXmlAttributes &atts);
85 void hlCStringCharStarted(const QXmlAttributes &atts);
86 void hlCCharStarted(const QXmlAttributes &atts);
87 void rangeDetectStarted(const QXmlAttributes &atts);
88 void lineContinue(const QXmlAttributes &atts);
89 void includeRulesStarted(const QXmlAttributes &atts);
90 void detectSpacesStarted(const QXmlAttributes &atts);
91 void detectIdentifier(const QXmlAttributes &atts);
93 void processIncludeRules() const;
94 void processIncludeRules(const QSharedPointer<Context> &context) const;
96 QSharedPointer<HighlightDefinition> m_definition;
98 bool m_processingKeyword;
99 QString m_currentKeyword;
100 QSharedPointer<KeywordList> m_currentList;
101 QSharedPointer<Context> m_currentContext;
102 QStack<QSharedPointer<Rule> > m_currentRule;
104 bool m_initialContext;
107 } // namespace Internal
108 } // namespace TextEditor
110 #endif // HIGHLIGHTDEFINITIONHANDLER_H