File indexing completed on 2024-05-26 11:22:04

0001 /*
0002     SPDX-License-Identifier: GPL-2.0-or-later
0003     SPDX-FileCopyrightText: 2016 Ivan Lakhtanov <ivan.lakhtanov@gmail.com>
0004 */
0005 #include "juliakeywords.h"
0006 
0007 #include <KSyntaxHighlighting/Repository>
0008 #include <KSyntaxHighlighting/Definition>
0009 
0010 JuliaKeywords::JuliaKeywords()
0011 {
0012     KSyntaxHighlighting::Repository m_repository;
0013     KSyntaxHighlighting::Definition definition = m_repository.definitionForName(QLatin1String("Julia"));
0014 
0015     m_keywords = definition.keywordList(QLatin1String("block_begin"));
0016     m_keywords << definition.keywordList(QLatin1String("block_eb"));
0017     m_keywords << definition.keywordList(QLatin1String("block_end"));
0018     m_keywords << definition.keywordList(QLatin1String("keywords"));
0019 
0020     //TODO: Upstream pull request to julia.xml from KSyntaxHighlighting?
0021     // https://bugs.kde.org/show_bug.cgi?id=403901
0022     // Add new list to julia.syntax with constans?
0023     m_variables << QLatin1String("false");
0024     m_variables << QLatin1String("Inf");
0025     m_variables << QLatin1String("NaN");
0026     m_variables << QLatin1String("nothing");
0027     m_variables << QLatin1String("true");
0028 }
0029 
0030 JuliaKeywords *JuliaKeywords::instance()
0031 {
0032     static JuliaKeywords *inst = nullptr;
0033     if (inst == nullptr) {
0034         inst = new JuliaKeywords();
0035     }
0036 
0037     return inst;
0038 }
0039 
0040 void JuliaKeywords::addVariable(const QString &variable)
0041 {
0042     if (!m_variables.contains(variable)) {
0043         m_variables << variable;
0044     }
0045 }
0046 
0047 void JuliaKeywords::clearVariables()
0048 {
0049     m_removedVariables = m_variables;
0050     m_variables.clear();
0051 }
0052 
0053 void JuliaKeywords::addFunction(const QString &function)
0054 {
0055     if (!m_functions.contains(function)) {
0056         m_functions << function;
0057     }
0058 }
0059 
0060 void JuliaKeywords::clearFunctions()
0061 {
0062     m_removedFunctions = m_functions;
0063     m_functions.clear();
0064 }