2021-12-26 23:18:28 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2020-2022 Roy Qu (royqh1979@gmail.com)
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2021-08-13 11:18:42 +08:00
|
|
|
#include "parserutils.h"
|
2021-08-07 14:08:51 +08:00
|
|
|
|
2021-08-10 21:27:24 +08:00
|
|
|
#include <QDir>
|
|
|
|
#include <QFile>
|
|
|
|
#include <QFileInfo>
|
2021-08-22 05:50:26 +08:00
|
|
|
#include <QDebug>
|
2021-08-29 10:14:07 +08:00
|
|
|
#include <QGlobalStatic>
|
2024-09-06 15:32:18 +08:00
|
|
|
#include "../systemconsts.h"
|
2021-09-13 22:45:50 +08:00
|
|
|
#include "../utils.h"
|
2021-08-10 21:27:24 +08:00
|
|
|
|
2021-08-07 14:08:51 +08:00
|
|
|
QStringList CppDirectives;
|
|
|
|
QStringList JavadocTags;
|
2022-11-01 09:02:17 +08:00
|
|
|
QMap<QString,KeywordType> CppKeywords;
|
2023-08-13 15:41:17 +08:00
|
|
|
#ifdef ENABLE_SDCC
|
2023-08-13 14:46:53 +08:00
|
|
|
QMap<QString,KeywordType> SDCCKeywords;
|
|
|
|
QSet<QString> SDCCTypeKeywords;
|
2023-08-13 15:41:17 +08:00
|
|
|
#endif
|
2022-03-08 22:29:15 +08:00
|
|
|
QSet<QString> CppControlKeyWords;
|
2021-08-07 14:08:51 +08:00
|
|
|
QSet<QString> CppTypeKeywords;
|
2021-08-25 00:20:07 +08:00
|
|
|
QSet<QString> CKeywords;
|
2021-08-07 14:08:51 +08:00
|
|
|
QSet<QString> STLPointers;
|
|
|
|
QSet<QString> STLContainers;
|
2022-11-29 16:48:40 +08:00
|
|
|
QSet<QString> STLMaps;
|
2021-08-07 14:08:51 +08:00
|
|
|
QSet<QString> STLElementMethods;
|
2022-11-29 12:06:29 +08:00
|
|
|
QSet<QString> STLIterators;
|
2021-12-18 23:36:58 +08:00
|
|
|
QSet<QString> MemberOperators;
|
2022-06-01 17:02:03 +08:00
|
|
|
QSet<QString> IOManipulators;
|
2022-11-29 16:48:40 +08:00
|
|
|
QSet<QString> AutoTypes;
|
2021-08-07 14:08:51 +08:00
|
|
|
|
2021-08-29 10:14:07 +08:00
|
|
|
Q_GLOBAL_STATIC(QSet<QString>,CppHeaderExts)
|
|
|
|
Q_GLOBAL_STATIC(QSet<QString>,CppSourceExts)
|
2021-08-18 21:57:42 +08:00
|
|
|
|
2021-08-07 14:08:51 +08:00
|
|
|
void initParser()
|
|
|
|
{
|
2021-08-29 10:14:07 +08:00
|
|
|
CppHeaderExts->insert("h");
|
|
|
|
CppHeaderExts->insert("hpp");
|
|
|
|
CppHeaderExts->insert("rh");
|
|
|
|
CppHeaderExts->insert("hh");
|
|
|
|
CppHeaderExts->insert("hxx");
|
|
|
|
CppHeaderExts->insert("inl");
|
|
|
|
CppHeaderExts->insert("");
|
|
|
|
|
|
|
|
CppSourceExts->insert("c");
|
|
|
|
CppSourceExts->insert("cpp");
|
|
|
|
CppSourceExts->insert("cc");
|
|
|
|
CppSourceExts->insert("cxx");
|
|
|
|
CppSourceExts->insert("c++");
|
|
|
|
CppSourceExts->insert("cp");
|
2021-08-07 14:08:51 +08:00
|
|
|
// skip itself
|
2022-11-01 09:02:17 +08:00
|
|
|
CppKeywords.insert("and",KeywordType::SkipItself);
|
|
|
|
CppKeywords.insert("and_eq",KeywordType::SkipItself);
|
|
|
|
CppKeywords.insert("bitand",KeywordType::SkipItself);
|
|
|
|
CppKeywords.insert("bitor",KeywordType::SkipItself);
|
|
|
|
CppKeywords.insert("break",KeywordType::SkipItself);
|
|
|
|
CppKeywords.insert("compl",KeywordType::SkipItself);
|
|
|
|
CppKeywords.insert("constexpr",KeywordType::SkipItself);
|
|
|
|
CppKeywords.insert("const_cast",KeywordType::SkipItself);
|
|
|
|
CppKeywords.insert("continue",KeywordType::SkipItself);
|
|
|
|
CppKeywords.insert("dynamic_cast",KeywordType::SkipItself);
|
|
|
|
CppKeywords.insert("else",KeywordType::SkipItself);
|
|
|
|
CppKeywords.insert("explicit",KeywordType::SkipItself);
|
|
|
|
CppKeywords.insert("export",KeywordType::SkipItself);
|
|
|
|
CppKeywords.insert("false",KeywordType::SkipItself);
|
2023-05-25 18:19:18 +08:00
|
|
|
CppKeywords.insert("__extension__",KeywordType::SkipItself);
|
|
|
|
|
2021-08-07 14:08:51 +08:00
|
|
|
//CppKeywords.insert("for",SkipType::skItself);
|
2022-11-01 09:02:17 +08:00
|
|
|
CppKeywords.insert("mutable",KeywordType::SkipItself);
|
|
|
|
CppKeywords.insert("noexcept",KeywordType::SkipItself);
|
|
|
|
CppKeywords.insert("not",KeywordType::SkipItself);
|
|
|
|
CppKeywords.insert("not_eq",KeywordType::SkipItself);
|
|
|
|
CppKeywords.insert("nullptr",KeywordType::SkipItself);
|
|
|
|
CppKeywords.insert("or",KeywordType::SkipItself);
|
|
|
|
CppKeywords.insert("or_eq",KeywordType::SkipItself);
|
|
|
|
CppKeywords.insert("register",KeywordType::SkipItself);
|
|
|
|
CppKeywords.insert("reinterpret_cast",KeywordType::SkipItself);
|
|
|
|
CppKeywords.insert("static_cast",KeywordType::SkipItself);
|
|
|
|
CppKeywords.insert("template",KeywordType::SkipItself);
|
2022-01-25 13:09:36 +08:00
|
|
|
//CppKeywords.insert("this",SkipType::skItself);
|
2022-11-01 09:02:17 +08:00
|
|
|
CppKeywords.insert("thread_local",KeywordType::SkipItself);
|
|
|
|
CppKeywords.insert("true",KeywordType::SkipItself);
|
|
|
|
CppKeywords.insert("typename",KeywordType::SkipItself);
|
|
|
|
CppKeywords.insert("virtual",KeywordType::SkipItself);
|
|
|
|
CppKeywords.insert("volatile",KeywordType::SkipItself);
|
|
|
|
CppKeywords.insert("xor",KeywordType::SkipItself);
|
|
|
|
CppKeywords.insert("xor_eq",KeywordType::SkipItself);
|
2021-08-07 14:08:51 +08:00
|
|
|
|
|
|
|
|
|
|
|
//CppKeywords.insert("catch",SkipType::skItself);
|
2022-11-01 09:02:17 +08:00
|
|
|
CppKeywords.insert("do",KeywordType::SkipItself);
|
|
|
|
CppKeywords.insert("try",KeywordType::SkipItself);
|
2021-08-07 14:08:51 +08:00
|
|
|
|
|
|
|
// Skip to ;
|
2022-11-04 20:27:35 +08:00
|
|
|
CppKeywords.insert("delete",KeywordType::SkipNextSemicolon);
|
|
|
|
CppKeywords.insert("delete[]",KeywordType::SkipNextSemicolon);
|
|
|
|
CppKeywords.insert("goto",KeywordType::SkipNextSemicolon);
|
|
|
|
CppKeywords.insert("new",KeywordType::SkipNextSemicolon);
|
|
|
|
CppKeywords.insert("return",KeywordType::SkipNextSemicolon);
|
|
|
|
CppKeywords.insert("throw",KeywordType::SkipNextSemicolon);
|
2021-08-07 14:08:51 +08:00
|
|
|
// CppKeywords.insert("using",SkipType::skToSemicolon); //won't use it
|
|
|
|
|
|
|
|
// Skip to :
|
2022-11-04 20:27:35 +08:00
|
|
|
CppKeywords.insert("case",KeywordType::SkipNextColon);
|
|
|
|
CppKeywords.insert("default",KeywordType::SkipNextColon);
|
2021-08-07 14:08:51 +08:00
|
|
|
|
|
|
|
// Skip to )
|
2022-11-04 20:27:35 +08:00
|
|
|
CppKeywords.insert("__attribute__",KeywordType::SkipNextParenthesis);
|
|
|
|
CppKeywords.insert("__attribute",KeywordType::SkipNextParenthesis);
|
|
|
|
CppKeywords.insert("alignas",KeywordType::SkipNextParenthesis); // not right
|
|
|
|
CppKeywords.insert("alignof",KeywordType::SkipNextParenthesis); // not right
|
|
|
|
CppKeywords.insert("if",KeywordType::SkipNextParenthesis);
|
|
|
|
CppKeywords.insert("sizeof",KeywordType::SkipNextParenthesis);
|
|
|
|
CppKeywords.insert("switch",KeywordType::SkipNextParenthesis);
|
|
|
|
CppKeywords.insert("typeid",KeywordType::SkipNextParenthesis);
|
|
|
|
CppKeywords.insert("while",KeywordType::SkipNextParenthesis);
|
|
|
|
CppKeywords.insert("static_assert",KeywordType::SkipNextParenthesis);
|
2022-11-12 10:45:53 +08:00
|
|
|
CppKeywords.insert("_Pragma",KeywordType::SkipNextParenthesis);
|
2021-08-07 14:08:51 +08:00
|
|
|
|
|
|
|
// Skip to }
|
2023-07-05 09:01:38 +08:00
|
|
|
CppKeywords.insert("asm",KeywordType::SkipNextParenthesis);
|
|
|
|
CppKeywords.insert("__asm",KeywordType::SkipNextParenthesis);
|
2021-08-07 14:08:51 +08:00
|
|
|
// Skip to {
|
|
|
|
|
2023-10-22 13:19:03 +08:00
|
|
|
CppKeywords.insert("requires",KeywordType::Requires);
|
|
|
|
CppKeywords.insert("concept",KeywordType::Concept);
|
|
|
|
|
2021-08-07 14:08:51 +08:00
|
|
|
// wont handle
|
|
|
|
|
|
|
|
//Not supported yet
|
2022-11-01 09:02:17 +08:00
|
|
|
CppKeywords.insert("atomic_cancel",KeywordType::None);
|
|
|
|
CppKeywords.insert("atomic_commit",KeywordType::None);
|
|
|
|
CppKeywords.insert("atomic_noexcept",KeywordType::None);
|
|
|
|
CppKeywords.insert("consteval",KeywordType::None);
|
|
|
|
CppKeywords.insert("constinit",KeywordType::None);
|
2024-03-22 15:44:04 +08:00
|
|
|
CppKeywords.insert("co_await",KeywordType::None);
|
2022-11-01 09:02:17 +08:00
|
|
|
CppKeywords.insert("co_return",KeywordType::None);
|
|
|
|
CppKeywords.insert("co_yield",KeywordType::None);
|
|
|
|
CppKeywords.insert("reflexpr",KeywordType::None);
|
2021-08-07 14:08:51 +08:00
|
|
|
// its a type
|
2022-11-01 09:02:17 +08:00
|
|
|
CppKeywords.insert("auto",KeywordType::None);
|
|
|
|
CppKeywords.insert("bool",KeywordType::None);
|
|
|
|
CppKeywords.insert("char",KeywordType::None);
|
|
|
|
CppKeywords.insert("char8_t",KeywordType::None);
|
|
|
|
CppKeywords.insert("char16_t",KeywordType::None);
|
|
|
|
CppKeywords.insert("char32_t",KeywordType::None);
|
|
|
|
CppKeywords.insert("double",KeywordType::None);
|
|
|
|
CppKeywords.insert("float",KeywordType::None);
|
|
|
|
CppKeywords.insert("int",KeywordType::None);
|
|
|
|
CppKeywords.insert("long",KeywordType::None);
|
|
|
|
CppKeywords.insert("short",KeywordType::None);
|
|
|
|
CppKeywords.insert("signed",KeywordType::None);
|
|
|
|
CppKeywords.insert("unsigned",KeywordType::None);
|
|
|
|
CppKeywords.insert("void",KeywordType::None);
|
|
|
|
CppKeywords.insert("wchar_t",KeywordType::None);
|
2021-08-07 14:08:51 +08:00
|
|
|
|
2023-08-13 15:41:17 +08:00
|
|
|
#ifdef ENABLE_SDCC
|
2023-08-13 14:46:53 +08:00
|
|
|
SDCCKeywords.insert("__sfr",KeywordType::None);
|
|
|
|
SDCCKeywords.insert("__sfr16",KeywordType::None);
|
|
|
|
SDCCKeywords.insert("__sfr32",KeywordType::None);
|
|
|
|
SDCCKeywords.insert("__sbit",KeywordType::None);
|
|
|
|
SDCCKeywords.insert("__bit",KeywordType::None);
|
|
|
|
SDCCKeywords.insert("__data",KeywordType::SkipItself);
|
|
|
|
SDCCKeywords.insert("__near",KeywordType::SkipItself);
|
|
|
|
SDCCKeywords.insert("__xdata",KeywordType::SkipItself);
|
|
|
|
SDCCKeywords.insert("__far",KeywordType::SkipItself);
|
|
|
|
SDCCKeywords.insert("__idata",KeywordType::SkipItself);
|
|
|
|
SDCCKeywords.insert("__pdata",KeywordType::SkipItself);
|
|
|
|
SDCCKeywords.insert("__code",KeywordType::SkipItself);
|
|
|
|
SDCCKeywords.insert("__banked",KeywordType::SkipItself);
|
|
|
|
SDCCKeywords.insert("__at",KeywordType::SkipNextParenthesis);
|
2023-08-13 20:57:09 +08:00
|
|
|
SDCCKeywords.insert("__reentrant",KeywordType::SkipItself);
|
|
|
|
SDCCKeywords.insert("__interrupt",KeywordType::SkipItself);
|
|
|
|
SDCCKeywords.insert("__using",KeywordType::SkipItself);
|
|
|
|
SDCCKeywords.insert("__critical",KeywordType::SkipItself);
|
|
|
|
SDCCKeywords.insert("__trap",KeywordType::SkipItself);
|
|
|
|
SDCCKeywords.insert("__asm",KeywordType::SkipItself);
|
|
|
|
SDCCKeywords.insert("__endasm",KeywordType::SkipItself);
|
|
|
|
SDCCKeywords.insert("__naked",KeywordType::SkipItself);
|
2023-08-13 14:46:53 +08:00
|
|
|
|
|
|
|
SDCCTypeKeywords.insert("__sfr");
|
|
|
|
SDCCTypeKeywords.insert("__sfr16");
|
|
|
|
SDCCTypeKeywords.insert("__sfr32");
|
|
|
|
SDCCTypeKeywords.insert("__sbit");
|
|
|
|
SDCCTypeKeywords.insert("__bit");
|
2023-08-13 15:41:17 +08:00
|
|
|
#endif
|
2021-08-07 14:08:51 +08:00
|
|
|
// type keywords
|
|
|
|
CppTypeKeywords.insert("auto");
|
|
|
|
CppTypeKeywords.insert("bool");
|
|
|
|
CppTypeKeywords.insert("char");
|
|
|
|
CppTypeKeywords.insert("char8_t");
|
|
|
|
CppTypeKeywords.insert("char16_t");
|
|
|
|
CppTypeKeywords.insert("char32_t");
|
|
|
|
CppTypeKeywords.insert("double");
|
|
|
|
CppTypeKeywords.insert("float");
|
|
|
|
CppTypeKeywords.insert("int");
|
|
|
|
CppTypeKeywords.insert("long");
|
|
|
|
CppTypeKeywords.insert("short");
|
|
|
|
//CppTypeKeywords.insert("signed");
|
|
|
|
//CppTypeKeywords.insert("unsigned");
|
|
|
|
CppTypeKeywords.insert("void");
|
|
|
|
CppTypeKeywords.insert("wchar_t");
|
2021-11-18 12:51:05 +08:00
|
|
|
CppTypeKeywords.insert("signed");
|
|
|
|
CppTypeKeywords.insert("unsigned");
|
2021-08-07 14:08:51 +08:00
|
|
|
|
|
|
|
// it's part of type info
|
2022-11-01 09:02:17 +08:00
|
|
|
CppKeywords.insert("const",KeywordType::None);
|
2024-04-01 10:59:01 +08:00
|
|
|
CppKeywords.insert("extern",KeywordType::Extern);
|
2021-08-07 14:08:51 +08:00
|
|
|
|
2023-03-12 12:42:44 +08:00
|
|
|
CppKeywords.insert("operator",KeywordType::Operator);
|
|
|
|
|
2021-08-07 14:08:51 +08:00
|
|
|
// handled elsewhere
|
2022-11-01 09:02:17 +08:00
|
|
|
CppKeywords.insert("static",KeywordType::None);
|
2023-03-12 10:50:47 +08:00
|
|
|
|
|
|
|
//struct/class/union
|
|
|
|
CppKeywords.insert("class",KeywordType::Struct);
|
|
|
|
CppKeywords.insert("struct",KeywordType::Struct);
|
|
|
|
CppKeywords.insert("union",KeywordType::Struct);
|
2022-11-01 09:02:17 +08:00
|
|
|
|
2022-11-12 10:45:53 +08:00
|
|
|
|
2022-11-01 09:02:17 +08:00
|
|
|
CppKeywords.insert("for",KeywordType::For);
|
|
|
|
CppKeywords.insert("catch",KeywordType::Catch);
|
|
|
|
CppKeywords.insert("private",KeywordType::Private);
|
|
|
|
CppKeywords.insert("public",KeywordType::Public);
|
|
|
|
CppKeywords.insert("enum",KeywordType::Enum);
|
|
|
|
CppKeywords.insert("namespace",KeywordType::Namespace);
|
|
|
|
CppKeywords.insert("inline",KeywordType::Inline);
|
|
|
|
CppKeywords.insert("typedef",KeywordType::Typedef);
|
|
|
|
CppKeywords.insert("using",KeywordType::Using);
|
|
|
|
CppKeywords.insert("protected",KeywordType::Protected);
|
|
|
|
CppKeywords.insert("friend",KeywordType::Friend);
|
2022-11-04 23:44:11 +08:00
|
|
|
CppKeywords.insert("decltype",KeywordType::DeclType); // not right
|
|
|
|
|
2021-08-07 14:08:51 +08:00
|
|
|
|
|
|
|
// nullptr is value
|
2022-11-01 09:02:17 +08:00
|
|
|
CppKeywords.insert("nullptr",KeywordType::None);
|
2021-08-07 14:08:51 +08:00
|
|
|
|
2021-08-25 00:20:07 +08:00
|
|
|
//C Keywords
|
|
|
|
CKeywords.insert("auto");
|
|
|
|
CKeywords.insert("break");
|
|
|
|
CKeywords.insert("case");
|
|
|
|
CKeywords.insert("char");
|
|
|
|
CKeywords.insert("const");
|
|
|
|
CKeywords.insert("continue");
|
|
|
|
CKeywords.insert("default");
|
|
|
|
CKeywords.insert("do");
|
|
|
|
CKeywords.insert("double");
|
|
|
|
CKeywords.insert("else");
|
|
|
|
CKeywords.insert("enum");
|
|
|
|
CKeywords.insert("extern");
|
|
|
|
CKeywords.insert("float");
|
|
|
|
CKeywords.insert("for");
|
|
|
|
CKeywords.insert("goto");
|
|
|
|
CKeywords.insert("if");
|
|
|
|
CKeywords.insert("inline");
|
|
|
|
CKeywords.insert("int");
|
|
|
|
CKeywords.insert("long");
|
|
|
|
CKeywords.insert("register");
|
|
|
|
CKeywords.insert("restrict");
|
|
|
|
CKeywords.insert("return");
|
|
|
|
CKeywords.insert("short");
|
|
|
|
CKeywords.insert("signed");
|
|
|
|
CKeywords.insert("sizeof");
|
|
|
|
CKeywords.insert("static");
|
|
|
|
CKeywords.insert("struct");
|
|
|
|
CKeywords.insert("switch");
|
|
|
|
CKeywords.insert("typedef");
|
|
|
|
CKeywords.insert("union");
|
|
|
|
CKeywords.insert("unsigned");
|
|
|
|
CKeywords.insert("void");
|
|
|
|
CKeywords.insert("volatile");
|
|
|
|
CKeywords.insert("while");
|
2021-08-07 14:08:51 +08:00
|
|
|
|
2022-03-08 22:29:15 +08:00
|
|
|
CppControlKeyWords.insert("for");
|
|
|
|
CppControlKeyWords.insert("if");
|
|
|
|
CppControlKeyWords.insert("catch");
|
|
|
|
|
2021-08-07 14:08:51 +08:00
|
|
|
//STL Containers
|
|
|
|
STLContainers.insert("std::array");
|
|
|
|
STLContainers.insert("std::vector");
|
|
|
|
STLContainers.insert("std::deque");
|
|
|
|
STLContainers.insert("std::forward_list");
|
|
|
|
STLContainers.insert("std::list");
|
|
|
|
|
|
|
|
STLContainers.insert("std::set");
|
2023-03-11 19:56:40 +08:00
|
|
|
// STLContainers.insert("std::map");
|
|
|
|
// STLContainers.insert("std::multilist");
|
|
|
|
// STLContainers.insert("std::multimap");
|
2021-08-07 14:08:51 +08:00
|
|
|
|
|
|
|
STLContainers.insert("std::unordered_set");
|
2023-03-11 19:56:40 +08:00
|
|
|
// STLContainers.insert("std::unordered_map");
|
2021-08-07 14:08:51 +08:00
|
|
|
STLContainers.insert("std::unordered_multiset");
|
2023-03-11 19:56:40 +08:00
|
|
|
// STLContainers.insert("std::unordered_multimap");
|
2021-08-07 14:08:51 +08:00
|
|
|
|
|
|
|
STLContainers.insert("std::stack");
|
|
|
|
STLContainers.insert("std::queue");
|
|
|
|
STLContainers.insert("std::priority_queue");
|
|
|
|
|
|
|
|
STLContainers.insert("std::span");
|
|
|
|
|
2022-11-29 16:48:40 +08:00
|
|
|
STLMaps.insert("std::map");
|
|
|
|
STLMaps.insert("std::multilist");
|
|
|
|
STLMaps.insert("std::multimap");
|
|
|
|
STLMaps.insert("std::unordered_map");
|
|
|
|
STLMaps.insert("std::unordered_multimap");
|
|
|
|
|
2021-08-07 14:08:51 +08:00
|
|
|
//STL element access methods
|
|
|
|
STLElementMethods.insert("at");
|
|
|
|
STLElementMethods.insert("back");
|
|
|
|
STLElementMethods.insert("front");
|
|
|
|
STLElementMethods.insert("top");
|
|
|
|
|
2022-11-29 12:06:29 +08:00
|
|
|
//STL iterator
|
|
|
|
STLIterators.insert("iterator");
|
|
|
|
STLIterators.insert("const_iterator");
|
2022-11-29 15:42:08 +08:00
|
|
|
STLIterators.insert("const_local_iterator");
|
|
|
|
STLIterators.insert("local_iterator");
|
2022-11-29 12:06:29 +08:00
|
|
|
STLIterators.insert("reverse_iterator");
|
|
|
|
STLIterators.insert("const_reverse_iterator");
|
|
|
|
|
2021-08-07 14:08:51 +08:00
|
|
|
//STL pointers
|
|
|
|
STLPointers.insert("std::unique_ptr");
|
|
|
|
STLPointers.insert("std::auto_ptr");
|
|
|
|
STLPointers.insert("std::shared_ptr");
|
|
|
|
STLPointers.insert("std::weak_ptr");
|
2022-11-29 12:06:29 +08:00
|
|
|
//STLPointers.insert("__gnu_cxx::__normal_iterator");
|
2023-06-08 17:15:55 +08:00
|
|
|
// STLPointers.insert("std::reverse_iterator");
|
|
|
|
// STLPointers.insert("std::iterator");
|
|
|
|
// STLPointers.insert("std::const_iterator");
|
|
|
|
// STLPointers.insert("std::const_reverse_iterator");
|
2021-08-07 14:08:51 +08:00
|
|
|
|
2022-11-29 16:48:40 +08:00
|
|
|
AutoTypes.insert("auto");
|
|
|
|
AutoTypes.insert("auto &");
|
2024-03-21 20:04:02 +08:00
|
|
|
AutoTypes.insert("auto &&");
|
2022-11-29 16:48:40 +08:00
|
|
|
AutoTypes.insert("const auto");
|
|
|
|
AutoTypes.insert("const auto &");
|
|
|
|
|
2021-08-07 14:08:51 +08:00
|
|
|
//C/CPP preprocessor directives
|
|
|
|
CppDirectives.append("#include");
|
|
|
|
CppDirectives.append("#if");
|
|
|
|
CppDirectives.append("#ifdef");
|
|
|
|
CppDirectives.append("#ifndef");
|
|
|
|
CppDirectives.append("#else");
|
|
|
|
CppDirectives.append("#elif");
|
|
|
|
CppDirectives.append("#endif");
|
|
|
|
CppDirectives.append("#define");
|
|
|
|
CppDirectives.append("#error");
|
|
|
|
CppDirectives.append("#pragma");
|
|
|
|
CppDirectives.append("#line");
|
2022-05-11 20:34:13 +08:00
|
|
|
CppDirectives.append("#undef");
|
2021-08-07 14:08:51 +08:00
|
|
|
|
|
|
|
// javadoc tags
|
|
|
|
JavadocTags.append("@author");
|
|
|
|
JavadocTags.append("@code");
|
|
|
|
JavadocTags.append("@docRoot");
|
|
|
|
JavadocTags.append("@deprecated");
|
|
|
|
JavadocTags.append("@exception");
|
|
|
|
JavadocTags.append("@inheritDoc");
|
|
|
|
JavadocTags.append("@link");
|
|
|
|
JavadocTags.append("@linkplain");
|
|
|
|
JavadocTags.append("@literal");
|
|
|
|
JavadocTags.append("@param");
|
|
|
|
JavadocTags.append("@return");
|
|
|
|
JavadocTags.append("@see");
|
|
|
|
JavadocTags.append("@serial");
|
|
|
|
JavadocTags.append("@serialData");
|
|
|
|
JavadocTags.append("@serialField");
|
|
|
|
JavadocTags.append("@since");
|
|
|
|
JavadocTags.append("@throws");
|
|
|
|
JavadocTags.append("@value");
|
|
|
|
JavadocTags.append("@version");
|
2021-12-18 23:36:58 +08:00
|
|
|
|
|
|
|
MemberOperators.insert(".");
|
|
|
|
MemberOperators.insert("::");
|
|
|
|
MemberOperators.insert("->");
|
|
|
|
MemberOperators.insert("->*");
|
|
|
|
MemberOperators.insert(".*");
|
2022-06-01 17:02:03 +08:00
|
|
|
|
|
|
|
IOManipulators.insert("std::boolalpha");
|
|
|
|
IOManipulators.insert("std::noboolalpha");
|
|
|
|
IOManipulators.insert("std::showbase");
|
|
|
|
IOManipulators.insert("std::noshowbase");
|
|
|
|
IOManipulators.insert("std::showpoint");
|
|
|
|
IOManipulators.insert("std::noshowpoint");
|
|
|
|
IOManipulators.insert("std::showpos");
|
|
|
|
IOManipulators.insert("std::noshowpos");
|
|
|
|
IOManipulators.insert("std::skipws");
|
|
|
|
IOManipulators.insert("std::noskipws");
|
|
|
|
|
|
|
|
IOManipulators.insert("std::uppercase");
|
|
|
|
IOManipulators.insert("std::nouppercase");
|
|
|
|
IOManipulators.insert("std::unitbuf");
|
|
|
|
IOManipulators.insert("std::nounitbuf");
|
|
|
|
IOManipulators.insert("std::left");
|
|
|
|
IOManipulators.insert("std::right");
|
|
|
|
IOManipulators.insert("std::internal");
|
|
|
|
IOManipulators.insert("std::dec");
|
|
|
|
IOManipulators.insert("std::hex");
|
|
|
|
IOManipulators.insert("std::oct");
|
|
|
|
|
|
|
|
IOManipulators.insert("std::fixed");
|
|
|
|
IOManipulators.insert("std::scientific");
|
|
|
|
IOManipulators.insert("std::hexfloat");
|
|
|
|
IOManipulators.insert("std::defaultfloat");
|
|
|
|
IOManipulators.insert("std::ws");
|
|
|
|
IOManipulators.insert("std::ends");
|
|
|
|
IOManipulators.insert("std::flush");
|
|
|
|
IOManipulators.insert("std::endl");
|
|
|
|
|
2021-08-07 14:08:51 +08:00
|
|
|
}
|
2021-08-10 21:27:24 +08:00
|
|
|
|
2021-08-22 21:23:58 +08:00
|
|
|
QString getHeaderFilename(const QString &relativeTo, const QString &line,
|
2021-10-04 22:32:34 +08:00
|
|
|
const QStringList& includePaths, const QStringList& projectIncludePaths) {
|
2021-08-10 21:27:24 +08:00
|
|
|
QString result = "";
|
|
|
|
|
|
|
|
// Handle <>
|
|
|
|
int openTokenPos = line.indexOf('<');
|
|
|
|
if (openTokenPos >= 0) {
|
|
|
|
int closeTokenPos = line.indexOf('>',openTokenPos+1);
|
|
|
|
if (closeTokenPos >=0) {
|
|
|
|
QString fileName = line.mid(openTokenPos + 1, closeTokenPos - openTokenPos - 1);
|
|
|
|
//project settings is preferred
|
2021-08-22 21:23:58 +08:00
|
|
|
result = getSystemHeaderFilename(fileName, projectIncludePaths);
|
2021-08-10 21:27:24 +08:00
|
|
|
if (result.isEmpty()) {
|
2021-08-22 21:23:58 +08:00
|
|
|
result = getSystemHeaderFilename(fileName, includePaths);
|
2021-08-10 21:27:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Try ""
|
|
|
|
openTokenPos = line.indexOf('"');
|
|
|
|
if (openTokenPos >= 0) {
|
|
|
|
int closeTokenPos = line.indexOf('"', openTokenPos+1);
|
|
|
|
if (closeTokenPos >= 0) {
|
|
|
|
QString fileName = line.mid(openTokenPos + 1, closeTokenPos - openTokenPos - 1);
|
2021-08-22 21:23:58 +08:00
|
|
|
result = getLocalHeaderFilename(relativeTo, fileName);
|
2021-08-10 21:27:24 +08:00
|
|
|
//project settings is preferred
|
|
|
|
if (result.isEmpty()) {
|
2021-08-22 21:23:58 +08:00
|
|
|
result = getSystemHeaderFilename(fileName, projectIncludePaths);
|
2021-08-10 21:27:24 +08:00
|
|
|
}
|
|
|
|
if (result.isEmpty()) {
|
2021-08-22 21:23:58 +08:00
|
|
|
result = getSystemHeaderFilename(fileName, includePaths);
|
2021-08-10 21:27:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-10-23 23:06:55 +08:00
|
|
|
|
2021-08-16 23:17:48 +08:00
|
|
|
return result;
|
2021-08-10 21:27:24 +08:00
|
|
|
}
|
|
|
|
|
2021-08-22 21:23:58 +08:00
|
|
|
QString getLocalHeaderFilename(const QString &relativeTo, const QString &fileName)
|
2021-08-10 21:27:24 +08:00
|
|
|
{
|
|
|
|
QFileInfo relativeFile(relativeTo);
|
|
|
|
QDir dir = relativeFile.dir();
|
|
|
|
// Search local directory
|
|
|
|
if (dir.exists(fileName)) {
|
2022-10-24 17:23:37 +08:00
|
|
|
return cleanPath(dir.absoluteFilePath(fileName));
|
2021-08-10 21:27:24 +08:00
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2021-10-04 22:32:34 +08:00
|
|
|
QString getSystemHeaderFilename(const QString &fileName, const QStringList& includePaths)
|
2021-08-10 21:27:24 +08:00
|
|
|
{
|
|
|
|
|
|
|
|
// Search compiler include directories
|
2021-08-29 00:48:23 +08:00
|
|
|
for (const QString& path:includePaths) {
|
2021-08-10 21:27:24 +08:00
|
|
|
QDir dir(path);
|
2022-10-23 23:06:55 +08:00
|
|
|
if (dir.exists(fileName)) {
|
2022-10-24 17:23:37 +08:00
|
|
|
return cleanPath(dir.absoluteFilePath(fileName));
|
2022-10-23 23:06:55 +08:00
|
|
|
}
|
2021-08-10 21:27:24 +08:00
|
|
|
}
|
|
|
|
//not found
|
|
|
|
return "";
|
|
|
|
}
|
2021-08-13 11:18:42 +08:00
|
|
|
|
2021-08-19 23:49:23 +08:00
|
|
|
bool isSystemHeaderFile(const QString &fileName, const QSet<QString> &includePaths)
|
2021-08-13 11:18:42 +08:00
|
|
|
{
|
2021-09-28 10:01:13 +08:00
|
|
|
if (fileName.isEmpty())
|
|
|
|
return false;
|
2021-08-13 11:18:42 +08:00
|
|
|
if (includePaths.isEmpty())
|
|
|
|
return false;
|
|
|
|
bool isFullName = false;
|
2022-08-06 08:51:53 +08:00
|
|
|
|
2021-08-13 11:18:42 +08:00
|
|
|
#ifdef Q_OS_WIN
|
2024-09-06 15:27:49 +08:00
|
|
|
isFullName = fileName.startsWith("/") || (fileName.length()>2 && fileName[1]==':'
|
|
|
|
&& fileName[0].isLetter());
|
2021-08-13 11:18:42 +08:00
|
|
|
#else
|
2021-12-25 08:23:52 +08:00
|
|
|
isFullName = fileName.startsWith("/");
|
2021-08-13 11:18:42 +08:00
|
|
|
#endif
|
|
|
|
if (isFullName) {
|
|
|
|
QFileInfo info(fileName);
|
2022-08-06 08:51:53 +08:00
|
|
|
// If it's a full file name, check if its directory is an include path
|
2021-08-13 11:18:42 +08:00
|
|
|
if (info.exists()) { // full file name
|
|
|
|
QDir dir = info.dir();
|
2024-09-06 15:27:49 +08:00
|
|
|
QString absPath = dir.absolutePath();
|
2021-09-13 22:45:50 +08:00
|
|
|
foreach (const QString& incPath, includePaths) {
|
2024-09-06 15:32:18 +08:00
|
|
|
if (absPath.startsWith(incPath, PATH_SENSITIVITY))
|
2021-09-13 22:45:50 +08:00
|
|
|
return true;
|
|
|
|
}
|
2021-08-13 11:18:42 +08:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
//check if it's in the include dir
|
2021-08-29 00:48:23 +08:00
|
|
|
for (const QString& includePath: includePaths) {
|
2021-08-13 11:18:42 +08:00
|
|
|
QDir dir(includePath);
|
|
|
|
if (dir.exists(fileName))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2021-08-15 17:52:39 +08:00
|
|
|
|
2022-01-26 12:17:15 +08:00
|
|
|
bool isCppKeyword(const QString &word)
|
2021-08-15 17:52:39 +08:00
|
|
|
{
|
|
|
|
return CppKeywords.contains(word);
|
|
|
|
}
|
2021-08-18 21:57:42 +08:00
|
|
|
|
2022-02-13 20:08:18 +08:00
|
|
|
bool isHFile(const QString& filename)
|
2021-08-18 21:57:42 +08:00
|
|
|
{
|
|
|
|
if (filename.isEmpty())
|
|
|
|
return false;
|
|
|
|
QFileInfo fileInfo(filename);
|
2021-08-29 10:14:07 +08:00
|
|
|
return CppHeaderExts->contains(fileInfo.suffix().toLower());
|
2021-08-18 21:57:42 +08:00
|
|
|
|
|
|
|
}
|
2021-08-19 17:08:01 +08:00
|
|
|
|
2022-02-13 20:08:18 +08:00
|
|
|
bool isCFile(const QString& filename)
|
2021-08-19 17:08:01 +08:00
|
|
|
{
|
|
|
|
if (filename.isEmpty())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
QFileInfo fileInfo(filename);
|
2021-08-29 10:14:07 +08:00
|
|
|
return CppSourceExts->contains(fileInfo.suffix().toLower());
|
2021-08-19 17:08:01 +08:00
|
|
|
}
|
2021-08-22 05:50:26 +08:00
|
|
|
|
2024-04-09 18:10:44 +08:00
|
|
|
PStatement CppScopes::findScopeAtLine(int line) const
|
2021-08-22 05:50:26 +08:00
|
|
|
{
|
|
|
|
if (mScopes.isEmpty())
|
|
|
|
return PStatement();
|
|
|
|
int start = 0;
|
|
|
|
int end = mScopes.size()-1;
|
|
|
|
while (start<=end) {
|
|
|
|
int mid = (start+end)/2;
|
|
|
|
PCppScope midScope = mScopes[mid];
|
|
|
|
if (midScope->startLine == line) {
|
2023-01-10 19:08:49 +08:00
|
|
|
while (mid<end && (mScopes[mid+1]->startLine == line)) {
|
|
|
|
mid++;
|
2021-08-22 05:50:26 +08:00
|
|
|
}
|
|
|
|
return mScopes[mid]->statement;
|
|
|
|
} else if (midScope->startLine > line) {
|
|
|
|
end = mid-1;
|
|
|
|
} else {
|
|
|
|
start = mid+1;
|
|
|
|
}
|
|
|
|
}
|
2021-08-24 03:42:56 +08:00
|
|
|
if (end>=0)
|
|
|
|
return mScopes[end]->statement;
|
2021-08-22 05:50:26 +08:00
|
|
|
else
|
2021-08-24 03:42:56 +08:00
|
|
|
return PStatement();
|
2021-08-22 05:50:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CppScopes::addScope(int line, PStatement scopeStatement)
|
|
|
|
{
|
|
|
|
PCppScope scope = std::make_shared<CppScope>();
|
|
|
|
scope->startLine = line;
|
|
|
|
scope->statement = scopeStatement;
|
|
|
|
mScopes.append(scope);
|
2024-04-09 22:12:03 +08:00
|
|
|
#ifdef QT_DEBUG
|
2024-05-09 21:09:57 +08:00
|
|
|
if (!mScopes.isEmpty() && mScopes.back()->startLine > line) {
|
2021-08-22 05:50:26 +08:00
|
|
|
qDebug()<<QString("Error: new scope %1 at %2 which is less that last scope %3")
|
2024-05-09 21:09:57 +08:00
|
|
|
.arg(scopeStatement->fullName)
|
|
|
|
.arg(line)
|
|
|
|
.arg(mScopes.back()->startLine);
|
2021-08-22 05:50:26 +08:00
|
|
|
}
|
2024-04-09 22:12:03 +08:00
|
|
|
#endif
|
2021-08-22 05:50:26 +08:00
|
|
|
}
|
2021-08-25 00:20:07 +08:00
|
|
|
|
|
|
|
MemberOperatorType getOperatorType(const QString &phrase, int index)
|
|
|
|
{
|
|
|
|
if (index>=phrase.length())
|
2022-11-01 09:02:17 +08:00
|
|
|
return MemberOperatorType::Other;
|
2021-08-25 00:20:07 +08:00
|
|
|
if (phrase[index] == '.')
|
2022-11-01 09:02:17 +08:00
|
|
|
return MemberOperatorType::Dot;
|
2021-08-25 00:20:07 +08:00
|
|
|
if (index+1>=phrase.length())
|
2022-11-01 09:02:17 +08:00
|
|
|
return MemberOperatorType::Other;
|
2021-08-25 00:20:07 +08:00
|
|
|
if ((phrase[index] == '-') && (phrase[index+1] == '>'))
|
2022-11-01 09:02:17 +08:00
|
|
|
return MemberOperatorType::Arrow;
|
2021-08-25 00:20:07 +08:00
|
|
|
if ((phrase[index] == ':') && (phrase[index+1] == ':'))
|
2022-11-01 09:02:17 +08:00
|
|
|
return MemberOperatorType::DColon;
|
|
|
|
return MemberOperatorType::Other;
|
2021-08-25 00:20:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool isScopeTypeKind(StatementKind kind)
|
|
|
|
{
|
|
|
|
switch(kind) {
|
2024-04-03 10:37:29 +08:00
|
|
|
case StatementKind::Class:
|
|
|
|
case StatementKind::Namespace:
|
|
|
|
case StatementKind::EnumType:
|
|
|
|
case StatementKind::EnumClassType:
|
2021-08-25 00:20:07 +08:00
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2021-12-06 11:37:37 +08:00
|
|
|
|
2021-12-07 14:48:20 +08:00
|
|
|
EvalStatement::EvalStatement(
|
2021-12-07 08:23:27 +08:00
|
|
|
const QString &baseType,
|
|
|
|
EvalStatementKind kind,
|
|
|
|
const PStatement &baseStatement,
|
2022-11-29 12:06:29 +08:00
|
|
|
const PStatement& typeStatement,
|
|
|
|
const PStatement& effectiveTypeStatement,
|
|
|
|
int pointerLevel,
|
|
|
|
const QString& templateParams)
|
2021-12-06 11:37:37 +08:00
|
|
|
{
|
2021-12-07 14:48:20 +08:00
|
|
|
this->baseType = baseType;
|
|
|
|
this->kind = kind;
|
|
|
|
this->baseStatement = baseStatement;
|
2022-11-29 12:06:29 +08:00
|
|
|
this->typeStatement = typeStatement;
|
|
|
|
this->effectiveTypeStatement = effectiveTypeStatement;
|
2021-12-07 14:48:20 +08:00
|
|
|
this->pointerLevel = pointerLevel;
|
2022-11-29 12:06:29 +08:00
|
|
|
this->templateParams = templateParams;
|
2021-12-06 11:37:37 +08:00
|
|
|
}
|
2021-12-07 08:23:27 +08:00
|
|
|
|
|
|
|
void EvalStatement::assignType(const PEvalStatement &typeStatement)
|
|
|
|
{
|
|
|
|
Q_ASSERT(typeStatement && typeStatement->kind==EvalStatementKind::Type);
|
|
|
|
baseType = typeStatement->baseType;
|
|
|
|
pointerLevel = typeStatement->pointerLevel;
|
2021-12-08 19:13:47 +08:00
|
|
|
effectiveTypeStatement = typeStatement->effectiveTypeStatement;
|
2021-12-07 08:23:27 +08:00
|
|
|
}
|
2021-12-18 23:36:58 +08:00
|
|
|
|
|
|
|
QStringList getOwnerExpressionAndMember(const QStringList expression, QString &memberOperator, QStringList &memberExpression)
|
|
|
|
{
|
|
|
|
//find position of the last member operator
|
|
|
|
int lastMemberOperatorPos = -1;
|
|
|
|
int currentMatchingLevel = 0;
|
|
|
|
QString matchingSignLeft;
|
|
|
|
QString matchingSignRight;
|
|
|
|
for (int i=0;i<expression.length();i++) {
|
|
|
|
QString token = expression[i];
|
|
|
|
if (currentMatchingLevel == 0) {
|
|
|
|
if (isMemberOperator(token)) {
|
|
|
|
lastMemberOperatorPos = i;
|
|
|
|
} else if (token == "(") {
|
|
|
|
matchingSignLeft = "(";
|
|
|
|
matchingSignRight = ")";
|
|
|
|
currentMatchingLevel++;
|
|
|
|
} else if (token == "[") {
|
|
|
|
matchingSignLeft = "[";
|
|
|
|
matchingSignRight = "]";
|
|
|
|
currentMatchingLevel++;
|
|
|
|
} else if (token == "<") {
|
|
|
|
matchingSignLeft = "<";
|
|
|
|
matchingSignRight = ">";
|
|
|
|
currentMatchingLevel++;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (token == matchingSignLeft) {
|
|
|
|
currentMatchingLevel++;
|
|
|
|
} else if (token == matchingSignRight) {
|
|
|
|
currentMatchingLevel--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList ownerExpression;
|
|
|
|
if (lastMemberOperatorPos<0) {
|
|
|
|
memberOperator = "";
|
|
|
|
memberExpression = expression;
|
|
|
|
} else {
|
|
|
|
memberOperator = expression[lastMemberOperatorPos];
|
|
|
|
memberExpression = expression.mid(lastMemberOperatorPos+1);
|
|
|
|
ownerExpression = expression.mid(0,lastMemberOperatorPos);
|
|
|
|
}
|
|
|
|
if (memberExpression.length()>1) {
|
|
|
|
memberExpression = memberExpression.mid(memberExpression.length()-1,1);
|
|
|
|
}
|
|
|
|
return ownerExpression;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isMemberOperator(QString token)
|
|
|
|
{
|
|
|
|
return MemberOperators.contains(token);
|
|
|
|
}
|
2022-01-27 20:31:44 +08:00
|
|
|
|
|
|
|
|
|
|
|
StatementKind getKindOfStatement(const PStatement& statement)
|
|
|
|
{
|
|
|
|
if (!statement)
|
2024-04-03 10:37:29 +08:00
|
|
|
return StatementKind::Unknown;
|
|
|
|
if (statement->kind == StatementKind::Variable) {
|
2022-01-27 20:31:44 +08:00
|
|
|
if (!statement->parentScope.lock()) {
|
2024-04-03 10:37:29 +08:00
|
|
|
return StatementKind::GlobalVariable;
|
2022-11-01 09:02:17 +08:00
|
|
|
} else if (statement->scope == StatementScope::Local) {
|
2024-04-03 10:37:29 +08:00
|
|
|
return StatementKind::LocalVariable;
|
2022-01-27 20:31:44 +08:00
|
|
|
} else {
|
2024-04-03 10:37:29 +08:00
|
|
|
return StatementKind::Variable;
|
2022-01-27 20:31:44 +08:00
|
|
|
}
|
2024-04-03 10:37:29 +08:00
|
|
|
} else if (statement->kind == StatementKind::Parameter) {
|
|
|
|
return StatementKind::LocalVariable;
|
2022-01-27 20:31:44 +08:00
|
|
|
}
|
|
|
|
return statement->kind;
|
|
|
|
}
|
2022-02-13 20:08:18 +08:00
|
|
|
|
|
|
|
bool isCppFile(const QString &filename)
|
|
|
|
{
|
|
|
|
if (isCFile(filename) && !filename.endsWith(".c"))
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
2022-03-08 22:29:15 +08:00
|
|
|
|
|
|
|
bool isCppControlKeyword(const QString &word)
|
|
|
|
{
|
|
|
|
return CppControlKeyWords.contains(word);
|
|
|
|
}
|
2022-10-22 19:33:20 +08:00
|
|
|
|
2022-10-22 22:10:35 +08:00
|
|
|
//static int counter=0;
|
|
|
|
//Statement::Statement()
|
|
|
|
//{
|
|
|
|
// counter++;
|
|
|
|
//}
|
|
|
|
|
|
|
|
//Statement::~Statement()
|
|
|
|
//{
|
|
|
|
// counter--;
|
|
|
|
// qDebug()<<"statement deleted:"<<counter<<fullName<<kind<<extractFileName(fileName)<<line;
|
|
|
|
//}
|
2023-05-26 08:55:21 +08:00
|
|
|
|
|
|
|
bool isTypeKind(StatementKind kind)
|
|
|
|
{
|
|
|
|
switch(kind) {
|
2024-04-03 10:37:29 +08:00
|
|
|
case StatementKind::Class:
|
|
|
|
case StatementKind::Namespace:
|
|
|
|
case StatementKind::EnumType:
|
|
|
|
case StatementKind::EnumClassType:
|
|
|
|
case StatementKind::Typedef:
|
|
|
|
case StatementKind::Preprocessor:
|
2023-05-26 08:55:21 +08:00
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2023-08-17 13:24:08 +08:00
|
|
|
|
2024-04-09 18:10:44 +08:00
|
|
|
bool ParsedFileInfo::isLineVisible(int line) const
|
2023-08-17 13:24:08 +08:00
|
|
|
{
|
|
|
|
int lastI=-1;
|
2024-04-09 20:18:10 +08:00
|
|
|
for(auto it=mBranches.begin();it!=mBranches.end();++it) {
|
|
|
|
int i = it.key();
|
2023-08-17 13:24:08 +08:00
|
|
|
if (line<i)
|
|
|
|
break;
|
|
|
|
else
|
|
|
|
lastI = i;
|
|
|
|
}
|
2024-04-09 18:10:44 +08:00
|
|
|
return lastI<0?true:mBranches[lastI];
|
2023-08-17 13:24:08 +08:00
|
|
|
}
|