File indexing completed on 2025-02-16 09:45:28
0001 /* 0002 SPDX-License-Identifier: GPL-2.0-or-later 0003 SPDX-FileCopyrightText: 2016 Ivan Lakhtanov <ivan.lakhtanov@gmail.com> 0004 */ 0005 #pragma once 0006 0007 #include <QStringList> 0008 0009 /** 0010 * Keywords storage for Julia session 0011 * 0012 * Class is implemented with singleton pattern 0013 */ 0014 class JuliaKeywords 0015 { 0016 public: 0017 /** 0018 * @return singleton instance pointer 0019 */ 0020 static JuliaKeywords *instance(); 0021 0022 /** 0023 * @return list of Julia language predefined keywords 0024 */ 0025 const QStringList &keywords() const { return m_keywords; } 0026 0027 /** 0028 * @return list of known variable names 0029 */ 0030 const QStringList &variables() const { return m_variables; } 0031 0032 /** 0033 * @return list of variables removed during the last clearVariables() call 0034 */ 0035 const QStringList &removedVariables() const { return m_removedVariables; } 0036 0037 /** 0038 * Clears all known variables 0039 */ 0040 void clearVariables(); 0041 0042 /** 0043 * Add new variable to the known list 0044 * 0045 * @param variable name of the variable to add 0046 */ 0047 void addVariable(const QString &variable); 0048 0049 /** 0050 * @return list of known function names 0051 */ 0052 const QStringList &functions() const { return m_functions; } 0053 0054 /** 0055 * @return list of functions removed during the last clearFunctions() call 0056 */ 0057 const QStringList &removedFunctions() const { return m_removedFunctions; } 0058 0059 /** 0060 * Clears all known functions 0061 */ 0062 void clearFunctions(); 0063 0064 /** 0065 * Add new function to the known list 0066 * 0067 * @param function name of the function to add 0068 */ 0069 void addFunction(const QString &function); 0070 0071 private: 0072 QStringList m_keywords; //< list of predefined keywords 0073 QStringList m_variables; //< list of variables known at the moment 0074 QStringList m_removedVariables; //< list of variables removed during cleaning 0075 QStringList m_functions; //< list of known function at the moment 0076 QStringList m_removedFunctions; //< list of functions removed during cleaning 0077 0078 // We are hiding constructor and destructor for singleton 0079 JuliaKeywords(); 0080 ~JuliaKeywords() = default; 0081 };