File indexing completed on 2024-04-28 11:20:43

0001 /*
0002     SPDX-License-Identifier: GPL-2.0-or-later
0003     SPDX-FileCopyrightText: 2011 Filipe Saraiva <filipe@kde.org>
0004 */
0005 
0006 #include "scilabkeywords.h"
0007 
0008 #include <QXmlStreamReader>
0009 #include <QtAlgorithms>
0010 #include <QDebug>
0011 
0012 #include <KSyntaxHighlighting/Repository>
0013 #include <KSyntaxHighlighting/Definition>
0014 
0015 ScilabKeywords::ScilabKeywords()
0016 {
0017     KSyntaxHighlighting::Repository m_repository;
0018     KSyntaxHighlighting::Definition definition = m_repository.definitionForName(QLatin1String("scilab"));
0019 
0020     m_keywords << definition.keywordList(QLatin1String("Structure-keywords"));
0021     m_keywords << definition.keywordList(QLatin1String("Control-keywords"));
0022     m_keywords << definition.keywordList(QLatin1String("Function-keywords"));
0023     m_keywords << definition.keywordList(QLatin1String("Warning-keywords"));
0024     m_keywords << definition.keywordList(QLatin1String("Function-keywords"));
0025 
0026     //TODO: This keywords missing in scilab syntax file
0027     m_keywords << QLatin1String("case") << QLatin1String("catch") << QLatin1String("continue");
0028     m_keywords << QLatin1String("try");
0029 
0030     m_functions << definition.keywordList(QLatin1String("functions"));
0031 
0032     //TODO: Should we use this keywordList as variables?
0033     m_variables << definition.keywordList(QLatin1String("Constants-keyword"));
0034 }
0035 
0036 ScilabKeywords* ScilabKeywords::instance()
0037 {
0038     static ScilabKeywords* inst = nullptr;
0039 
0040     if(inst == nullptr){
0041         inst = new ScilabKeywords();
0042         std::sort(inst->m_variables.begin(), inst->m_variables.end());
0043         std::sort(inst->m_functions.begin(), inst->m_functions.end());
0044         std::sort(inst->m_keywords.begin(), inst->m_keywords.end());
0045     }
0046 
0047     return inst;
0048 }
0049 
0050 const QStringList& ScilabKeywords::variables() const
0051 {
0052     return m_variables;
0053 }
0054 
0055 const QStringList& ScilabKeywords::functions() const
0056 {
0057     return m_functions;
0058 }
0059 
0060 const QStringList& ScilabKeywords::keywords() const
0061 {
0062     return m_keywords;
0063 }