Merge branch 'master' of github.com:royqh1979/RedPanda-CPP

This commit is contained in:
Roy Qu 2024-04-11 18:59:37 +08:00
commit 306e1b6bc4
27 changed files with 383 additions and 669 deletions

View File

@ -131,6 +131,8 @@ Red Panda C++ Version 2.27
- fix: Can't find the correct type if current symbol is member of a class that has constructors.
- fix: Alias a namespace to itself will create infinite loop.
- fix: Can't find symbols indirectly included by other files.
- enhancement: Function tip's width changes with editor width.
- fix: '<' / '>' not shown in function tips.
Red Panda C++ Version 2.26
- enhancement: Code suggestion for embedded std::vectors.

View File

@ -401,7 +401,7 @@ QStringList Compiler::getCharsetArgument(const QByteArray& encoding,FileType fil
//qDebug()<<encodingName<<execEncodingName;
if (checkSyntax) {
result << "-finput-charset=" + encodingName;
} else if (encodingName!=execEncodingName) {
} else if (QString::compare(encodingName, execEncodingName, Qt::CaseInsensitive) != 0) {
result += {
"-finput-charset=" + encodingName,
"-fexec-charset=" + execEncodingName,

View File

@ -478,7 +478,7 @@ void ProjectCompiler::writeMakeObjFilesRules(QFile &file)
if (sourceEncoding==ENCODING_SYSTEM_DEFAULT)
sourceEncoding = defaultSystemEncoding;
if (sourceEncoding!=targetEncoding) {
if (QString::compare(sourceEncoding,targetEncoding,Qt::CaseInsensitive)!=0) {
encodingStr = QString(" -finput-charset=%1 -fexec-charset=%2")
.arg(QString(sourceEncoding),
QString(targetEncoding));

View File

@ -1640,6 +1640,7 @@ void Editor::hideEvent(QHideEvent */*event*/)
void Editor::resizeEvent(QResizeEvent *event)
{
QSynedit::QSynEdit::resizeEvent(event);
pMainWindow->functionTip()->setMinWidth(width()*3/4);
pMainWindow->functionTip()->hide();
}

View File

@ -399,8 +399,8 @@ MainWindow::MainWindow(QWidget *parent)
m=ui->treeFiles->selectionModel();
ui->treeFiles->setModel(&mFileSystemModel);
delete m;
connect(&mFileSystemModel, &QFileSystemModel::layoutChanged,
this, &MainWindow::onFileSystemModelLayoutChanged, Qt::QueuedConnection);
// connect(&mFileSystemModel, &QFileSystemModel::layoutChanged,
// this, &MainWindow::onFileSystemModelLayoutChanged, Qt::QueuedConnection);
connect(&mFileSystemModel, &QFileSystemModel::fileRenamed,
this, &MainWindow::onFileSystemModelLayoutChanged, Qt::QueuedConnection);
connect(&mFileSystemModel, &QFileSystemModel::fileRenamed,

View File

@ -119,8 +119,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>2345</width>
<height>30</height>
<width>1236</width>
<height>17</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
@ -795,6 +795,11 @@
<property name="text">
<string>New Problem Set</string>
</property>
<property name="icon">
<iconset>
<normalon>:/resources/iconsets/newlook/actions/08Problem-01Problem.svg</normalon>
</iconset>
</property>
</widget>
</item>
<item>
@ -805,6 +810,11 @@
<property name="text">
<string>Add Problem</string>
</property>
<property name="icon">
<iconset>
<normalon>:/resources/iconsets/newlook/actions/00Misc-03Add.svg</normalon>
</iconset>
</property>
</widget>
</item>
<item>
@ -815,6 +825,11 @@
<property name="text">
<string>Remove Problem</string>
</property>
<property name="icon">
<iconset>
<normalon>:/resources/iconsets/newlook/actions/00Misc-04Remove.svg</normalon>
</iconset>
</property>
</widget>
</item>
<item>
@ -825,6 +840,11 @@
<property name="text">
<string>Save Problem Set</string>
</property>
<property name="icon">
<iconset>
<normalon>:/resources/iconsets/newlook/actions/01File-04SaveAs.svg</normalon>
</iconset>
</property>
</widget>
</item>
<item>
@ -835,6 +855,11 @@
<property name="text">
<string>Load Problem Set</string>
</property>
<property name="icon">
<iconset>
<normalon>:/resources/iconsets/newlook/actions/06View-03Files.svg</normalon>
</iconset>
</property>
</widget>
</item>
<item>
@ -842,6 +867,11 @@
<property name="text">
<string>Import FPS Problem Set</string>
</property>
<property name="icon">
<iconset>
<normalon>:/resources/iconsets/newlook/actions/00Misc-01Back.svg</normalon>
</iconset>
</property>
</widget>
</item>
<item>
@ -849,6 +879,11 @@
<property name="text">
<string>Export FPS Problem Set</string>
</property>
<property name="icon">
<iconset>
<normalon>:/resources/iconsets/newlook/actions/00Misc-02Forward.svg</normalon>
</iconset>
</property>
</widget>
</item>
<item>
@ -917,7 +952,7 @@
<enum>QTabWidget::South</enum>
</property>
<property name="currentIndex">
<number>6</number>
<number>2</number>
</property>
<property name="iconSize">
<size>
@ -946,7 +981,6 @@
<widget class="IssuesTable" name="tableIssues">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
@ -1098,7 +1132,7 @@
<enum>QTabWidget::North</enum>
</property>
<property name="currentIndex">
<number>0</number>
<number>3</number>
</property>
<widget class="QWidget" name="tabDebugConsole">
<attribute name="title">
@ -1628,6 +1662,10 @@
<property name="text">
<string>Add Probem Case</string>
</property>
<property name="icon">
<iconset resource="Z:/Red_Panda_CPP/RedPandaIDE/release/qmake_iconsets_files.qrc">
<normaloff>:/resources/iconsets/newlook/actions/00Misc-03Add.svg</normaloff>:/resources/iconsets/newlook/actions/00Misc-03Add.svg</iconset>
</property>
</widget>
</item>
<item>
@ -1638,6 +1676,10 @@
<property name="text">
<string>Remove Problem Case</string>
</property>
<property name="icon">
<iconset resource="Z:/Red_Panda_CPP/RedPandaIDE/release/qmake_iconsets_files.qrc">
<normaloff>:/resources/iconsets/newlook/actions/00Misc-04Remove.svg</normaloff>:/resources/iconsets/newlook/actions/00Misc-04Remove.svg</iconset>
</property>
</widget>
</item>
<item>
@ -1648,6 +1690,10 @@
<property name="text">
<string>Open Anwser Source File</string>
</property>
<property name="icon">
<iconset resource="Z:/Red_Panda_CPP/RedPandaIDE/release/qmake_iconsets_files.qrc">
<normaloff>:/resources/iconsets/newlook/actions/08Problem-04EditSource.svg</normaloff>:/resources/iconsets/newlook/actions/08Problem-04EditSource.svg</iconset>
</property>
</widget>
</item>
<item>
@ -1665,6 +1711,10 @@
<property name="text">
<string>Run All Cases</string>
</property>
<property name="icon">
<iconset resource="Z:/Red_Panda_CPP/RedPandaIDE/release/qmake_iconsets_files.qrc">
<normaloff>:/resources/iconsets/newlook/actions/08Problem-05RunCases.svg</normaloff>:/resources/iconsets/newlook/actions/08Problem-05RunCases.svg</iconset>
</property>
</widget>
</item>
<item>
@ -1672,6 +1722,10 @@
<property name="text">
<string>Problem Cases Validation Options</string>
</property>
<property name="icon">
<iconset resource="Z:/Red_Panda_CPP/RedPandaIDE/release/qmake_iconsets_files.qrc">
<normaloff>:/resources/iconsets/newlook/actions/00Misc-05Gear.svg</normaloff>:/resources/iconsets/newlook/actions/00Misc-05Gear.svg</iconset>
</property>
</widget>
</item>
<item>
@ -1789,6 +1843,10 @@
<property name="text">
<string>Choose Input File</string>
</property>
<property name="icon">
<iconset resource="Z:/Red_Panda_CPP/RedPandaIDE/release/qmake_iconsets_files.qrc">
<normaloff>:/resources/iconsets/newlook/actions/00Misc-07Folder.svg</normaloff>:/resources/iconsets/newlook/actions/00Misc-07Folder.svg</iconset>
</property>
</widget>
</item>
<item row="0" column="2">
@ -1904,6 +1962,10 @@
<property name="text">
<string>Choose Expected Output File</string>
</property>
<property name="icon">
<iconset resource="Z:/Red_Panda_CPP/RedPandaIDE/release/qmake_iconsets_files.qrc">
<normaloff>:/resources/iconsets/newlook/actions/00Misc-07Folder.svg</normaloff>:/resources/iconsets/newlook/actions/00Misc-07Folder.svg</iconset>
</property>
</widget>
</item>
</layout>
@ -1973,6 +2035,10 @@
</widget>
</widget>
<action name="actionNew">
<property name="icon">
<iconset resource="Z:/Red_Panda_CPP/RedPandaIDE/release/qmake_iconsets_files.qrc">
<normaloff>:/resources/iconsets/newlook/actions/01File-01New.svg</normaloff>:/resources/iconsets/newlook/actions/01File-01New.svg</iconset>
</property>
<property name="text">
<string>New C/C++ File</string>
</property>
@ -1984,6 +2050,10 @@
</property>
</action>
<action name="actionOpen">
<property name="icon">
<iconset resource="Z:/Red_Panda_CPP/RedPandaIDE/release/qmake_iconsets_files.qrc">
<normaloff>:/resources/iconsets/newlook/actions/01File-02Open.svg</normaloff>:/resources/iconsets/newlook/actions/01File-02Open.svg</iconset>
</property>
<property name="text">
<string>Open...</string>
</property>
@ -1992,6 +2062,10 @@
</property>
</action>
<action name="actionSave">
<property name="icon">
<iconset resource="Z:/Red_Panda_CPP/RedPandaIDE/release/qmake_iconsets_files.qrc">
<normaloff>:/resources/iconsets/newlook/actions/01File-03Save.svg</normaloff>:/resources/iconsets/newlook/actions/01File-03Save.svg</iconset>
</property>
<property name="text">
<string>Save</string>
</property>
@ -2000,6 +2074,10 @@
</property>
</action>
<action name="actionSaveAs">
<property name="icon">
<iconset resource="Z:/Red_Panda_CPP/RedPandaIDE/release/qmake_iconsets_files.qrc">
<normaloff>:/resources/iconsets/newlook/actions/01File-04SaveAs.svg</normaloff>:/resources/iconsets/newlook/actions/01File-04SaveAs.svg</iconset>
</property>
<property name="text">
<string>Save As...</string>
</property>
@ -2011,6 +2089,10 @@
</property>
</action>
<action name="actionSaveAll">
<property name="icon">
<iconset resource="Z:/Red_Panda_CPP/RedPandaIDE/release/qmake_iconsets_files.qrc">
<normaloff>:/resources/iconsets/newlook/actions/01File-05SaveAll.svg</normaloff>:/resources/iconsets/newlook/actions/01File-05SaveAll.svg</iconset>
</property>
<property name="text">
<string>Save All</string>
</property>
@ -2019,11 +2101,19 @@
</property>
</action>
<action name="actionOptions">
<property name="icon">
<iconset resource="Z:/Red_Panda_CPP/RedPandaIDE/release/qmake_iconsets_files.qrc">
<normaloff>:/resources/iconsets/newlook/actions/00Misc-05Gear.svg</normaloff>:/resources/iconsets/newlook/actions/00Misc-05Gear.svg</iconset>
</property>
<property name="text">
<string>Options</string>
</property>
</action>
<action name="actionCompile">
<property name="icon">
<iconset resource="Z:/Red_Panda_CPP/RedPandaIDE/release/qmake_iconsets_files.qrc">
<normaloff>:/resources/iconsets/newlook/actions/05Run-01Compile.svg</normaloff>:/resources/iconsets/newlook/actions/05Run-01Compile.svg</iconset>
</property>
<property name="text">
<string>Compile</string>
</property>
@ -2035,6 +2125,10 @@
</property>
</action>
<action name="actionRun">
<property name="icon">
<iconset resource="Z:/Red_Panda_CPP/RedPandaIDE/release/qmake_iconsets_files.qrc">
<normaloff>:/resources/iconsets/newlook/actions/05Run-03Run.svg</normaloff>:/resources/iconsets/newlook/actions/05Run-03Run.svg</iconset>
</property>
<property name="text">
<string>Run</string>
</property>
@ -2046,6 +2140,10 @@
</property>
</action>
<action name="actionUndo">
<property name="icon">
<iconset resource="Z:/Red_Panda_CPP/RedPandaIDE/release/qmake_iconsets_files.qrc">
<normaloff>:/resources/iconsets/newlook/actions/03Edit-01Undo.svg</normaloff>:/resources/iconsets/newlook/actions/03Edit-01Undo.svg</iconset>
</property>
<property name="text">
<string>Undo</string>
</property>
@ -2054,6 +2152,10 @@
</property>
</action>
<action name="actionRedo">
<property name="icon">
<iconset resource="Z:/Red_Panda_CPP/RedPandaIDE/release/qmake_iconsets_files.qrc">
<normaloff>:/resources/iconsets/newlook/actions/03Edit-02Redo.svg</normaloff>:/resources/iconsets/newlook/actions/03Edit-02Redo.svg</iconset>
</property>
<property name="text">
<string>Redo</string>
</property>
@ -2062,6 +2164,10 @@
</property>
</action>
<action name="actionCut">
<property name="icon">
<iconset resource="Z:/Red_Panda_CPP/RedPandaIDE/release/qmake_iconsets_files.qrc">
<normaloff>:/resources/iconsets/newlook/actions/03Edit-03Cut.svg</normaloff>:/resources/iconsets/newlook/actions/03Edit-03Cut.svg</iconset>
</property>
<property name="text">
<string>Cut</string>
</property>
@ -2070,6 +2176,10 @@
</property>
</action>
<action name="actionCopy">
<property name="icon">
<iconset resource="Z:/Red_Panda_CPP/RedPandaIDE/release/qmake_iconsets_files.qrc">
<normaloff>:/resources/iconsets/newlook/actions/03Edit-04Copy.svg</normaloff>:/resources/iconsets/newlook/actions/03Edit-04Copy.svg</iconset>
</property>
<property name="text">
<string>Copy</string>
</property>
@ -2078,6 +2188,10 @@
</property>
</action>
<action name="actionPaste">
<property name="icon">
<iconset resource="Z:/Red_Panda_CPP/RedPandaIDE/release/qmake_iconsets_files.qrc">
<normaloff>:/resources/iconsets/newlook/actions/03Edit-05Paste.svg</normaloff>:/resources/iconsets/newlook/actions/03Edit-05Paste.svg</iconset>
</property>
<property name="text">
<string>Paste</string>
</property>
@ -2094,6 +2208,10 @@
</property>
</action>
<action name="actionIndent">
<property name="icon">
<iconset resource="Z:/Red_Panda_CPP/RedPandaIDE/release/qmake_iconsets_files.qrc">
<normaloff>:/resources/iconsets/newlook/actions/03Edit-06Indent.svg</normaloff>:/resources/iconsets/newlook/actions/03Edit-06Indent.svg</iconset>
</property>
<property name="text">
<string>Indent</string>
</property>
@ -2102,6 +2220,10 @@
</property>
</action>
<action name="actionUnIndent">
<property name="icon">
<iconset resource="Z:/Red_Panda_CPP/RedPandaIDE/release/qmake_iconsets_files.qrc">
<normaloff>:/resources/iconsets/newlook/actions/03Edit-07Unindent.svg</normaloff>:/resources/iconsets/newlook/actions/03Edit-07Unindent.svg</iconset>
</property>
<property name="text">
<string>UnIndent</string>
</property>
@ -2156,6 +2278,10 @@
</property>
</action>
<action name="actionRebuild">
<property name="icon">
<iconset resource="Z:/Red_Panda_CPP/RedPandaIDE/release/qmake_iconsets_files.qrc">
<normaloff>:/resources/iconsets/newlook/actions/05Run-04Rebuild.svg</normaloff>:/resources/iconsets/newlook/actions/05Run-04Rebuild.svg</iconset>
</property>
<property name="text">
<string>Rebuild All</string>
</property>
@ -2167,6 +2293,10 @@
</property>
</action>
<action name="actionStop_Execution">
<property name="icon">
<iconset resource="Z:/Red_Panda_CPP/RedPandaIDE/release/qmake_iconsets_files.qrc">
<normaloff>:/resources/iconsets/newlook/actions/05Run-11Stop.svg</normaloff>:/resources/iconsets/newlook/actions/05Run-11Stop.svg</iconset>
</property>
<property name="text">
<string>Stop Execution</string>
</property>
@ -2175,6 +2305,10 @@
</property>
</action>
<action name="actionDebug">
<property name="icon">
<iconset resource="Z:/Red_Panda_CPP/RedPandaIDE/release/qmake_iconsets_files.qrc">
<normaloff>:/resources/iconsets/newlook/actions/05Run-06Debug.svg</normaloff>:/resources/iconsets/newlook/actions/05Run-06Debug.svg</iconset>
</property>
<property name="text">
<string>Debug</string>
</property>
@ -2186,6 +2320,10 @@
</property>
</action>
<action name="actionStep_Over">
<property name="icon">
<iconset resource="Z:/Red_Panda_CPP/RedPandaIDE/release/qmake_iconsets_files.qrc">
<normaloff>:/resources/iconsets/newlook/actions/05Run-07StepOver.svg</normaloff>:/resources/iconsets/newlook/actions/05Run-07StepOver.svg</iconset>
</property>
<property name="text">
<string>Step Over</string>
</property>
@ -2194,6 +2332,10 @@
</property>
</action>
<action name="actionStep_Into">
<property name="icon">
<iconset resource="Z:/Red_Panda_CPP/RedPandaIDE/release/qmake_iconsets_files.qrc">
<normaloff>:/resources/iconsets/newlook/actions/05Run-08StepInto.svg</normaloff>:/resources/iconsets/newlook/actions/05Run-08StepInto.svg</iconset>
</property>
<property name="text">
<string>Step Into</string>
</property>
@ -2202,6 +2344,10 @@
</property>
</action>
<action name="actionStep_Out">
<property name="icon">
<iconset resource="Z:/Red_Panda_CPP/RedPandaIDE/release/qmake_iconsets_files.qrc">
<normaloff>:/resources/iconsets/newlook/actions/05Run-08StepOut.svg</normaloff>:/resources/iconsets/newlook/actions/05Run-08StepOut.svg</iconset>
</property>
<property name="text">
<string>Step Out</string>
</property>
@ -2210,6 +2356,10 @@
</property>
</action>
<action name="actionRun_To_Cursor">
<property name="icon">
<iconset resource="Z:/Red_Panda_CPP/RedPandaIDE/release/qmake_iconsets_files.qrc">
<normaloff>:/resources/iconsets/newlook/actions/05Run-09RunToCursor.svg</normaloff>:/resources/iconsets/newlook/actions/05Run-09RunToCursor.svg</iconset>
</property>
<property name="text">
<string>Run To Cursor</string>
</property>
@ -2218,6 +2368,10 @@
</property>
</action>
<action name="actionContinue">
<property name="icon">
<iconset resource="Z:/Red_Panda_CPP/RedPandaIDE/release/qmake_iconsets_files.qrc">
<normaloff>:/resources/iconsets/newlook/actions/05Run-10Continue.svg</normaloff>:/resources/iconsets/newlook/actions/05Run-10Continue.svg</iconset>
</property>
<property name="text">
<string>Continue</string>
</property>
@ -2226,6 +2380,10 @@
</property>
</action>
<action name="actionAdd_Watch">
<property name="icon">
<iconset resource="Z:/Red_Panda_CPP/RedPandaIDE/release/qmake_iconsets_files.qrc">
<normaloff>:/resources/iconsets/newlook/actions/05Run-12AddWatch.svg</normaloff>:/resources/iconsets/newlook/actions/05Run-12AddWatch.svg</iconset>
</property>
<property name="text">
<string>Add Watch...</string>
</property>
@ -2281,6 +2439,10 @@
</property>
</action>
<action name="actionRemove_Watch">
<property name="icon">
<iconset resource="Z:/Red_Panda_CPP/RedPandaIDE/release/qmake_iconsets_files.qrc">
<normaloff>:/resources/iconsets/newlook/actions/05Run-13RemoveWatch.svg</normaloff>:/resources/iconsets/newlook/actions/05Run-13RemoveWatch.svg</iconset>
</property>
<property name="text">
<string>Remove Watch</string>
</property>
@ -2296,6 +2458,10 @@
</property>
</action>
<action name="actionReformat_Code">
<property name="icon">
<iconset resource="Z:/Red_Panda_CPP/RedPandaIDE/release/qmake_iconsets_files.qrc">
<normaloff>:/resources/iconsets/newlook/actions/04Code-05Reformat.svg</normaloff>:/resources/iconsets/newlook/actions/04Code-05Reformat.svg</iconset>
</property>
<property name="text">
<string>Reformat Code</string>
</property>
@ -2304,6 +2470,10 @@
</property>
</action>
<action name="actionBack">
<property name="icon">
<iconset resource="Z:/Red_Panda_CPP/RedPandaIDE/release/qmake_iconsets_files.qrc">
<normaloff>:/resources/iconsets/newlook/actions/04Code-01Back.svg</normaloff>:/resources/iconsets/newlook/actions/04Code-01Back.svg</iconset>
</property>
<property name="text">
<string>Go back</string>
</property>
@ -2312,6 +2482,10 @@
</property>
</action>
<action name="actionForward">
<property name="icon">
<iconset resource="Z:/Red_Panda_CPP/RedPandaIDE/release/qmake_iconsets_files.qrc">
<normaloff>:/resources/iconsets/newlook/actions/04Code-02Forward.svg</normaloff>:/resources/iconsets/newlook/actions/04Code-02Forward.svg</iconset>
</property>
<property name="text">
<string>Forward</string>
</property>
@ -2561,6 +2735,10 @@
</property>
</action>
<action name="actionRun_Parameters">
<property name="icon">
<iconset resource="Z:/Red_Panda_CPP/RedPandaIDE/release/qmake_iconsets_files.qrc">
<normaloff>:/resources/iconsets/newlook/actions/05Run-05Options.svg</normaloff>:/resources/iconsets/newlook/actions/05Run-05Options.svg</iconset>
</property>
<property name="text">
<string>Running Parameters...</string>
</property>
@ -2723,6 +2901,10 @@
</property>
</action>
<action name="actionInterrupt">
<property name="icon">
<iconset resource="Z:/Red_Panda_CPP/RedPandaIDE/release/qmake_iconsets_files.qrc">
<normaloff>:/resources/iconsets/newlook/actions/05Run-16Interrupt.svg</normaloff>:/resources/iconsets/newlook/actions/05Run-16Interrupt.svg</iconset>
</property>
<property name="text">
<string>Interrupt</string>
</property>
@ -2883,6 +3065,10 @@
</property>
</action>
<action name="actionCompiler_Options">
<property name="icon">
<iconset resource="Z:/Red_Panda_CPP/RedPandaIDE/release/qmake_iconsets_files.qrc">
<normaloff>:/resources/iconsets/newlook/actions/05Run-17CompilerOptions.svg</normaloff>:/resources/iconsets/newlook/actions/05Run-17CompilerOptions.svg</iconset>
</property>
<property name="text">
<string>Compiler Options...</string>
</property>
@ -3197,6 +3383,8 @@
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<resources>
<include location="Z:/Red_Panda_CPP/RedPandaIDE/release/qmake_iconsets_files.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -1524,11 +1524,13 @@ PStatement CppParser::addStatement(const PStatement &parent,
QChar ch=mTokenizer[i]->text[0];
if (this->isIdentChar(ch)) {
QString spaces=(i>argStart)?" ":"";
if (args.length()>0 && isWordChar(args.back()))
if (args.length()>0 && (isWordChar(args.back()) || args.back()=='>'))
args+=spaces;
word += mTokenizer[i]->text;
if (!typeGetted) {
noNameArgs+=spaces+word;
if (noNameArgs.length()>0 && isWordChar(noNameArgs.back()))
noNameArgs+=spaces;
noNameArgs+=word;
if (mCppTypeKeywords.contains(word) || !isCppKeyword(word))
typeGetted = true;
} else {
@ -1541,6 +1543,7 @@ PStatement CppParser::addStatement(const PStatement &parent,
} else if (mTokenizer[i]->text=="::") {
if (braceLevel==0) {
noNameArgs+= mTokenizer[i]->text;
typeGetted = false;
}
} else {
switch(ch.unicode()) {

View File

@ -138,11 +138,6 @@ void CppPreprocessor::getDefineParts(const QString &input, QString &name, QStrin
args.squeeze();
}
void CppPreprocessor::addHardDefineByLine(const QString &line)
{
addDefineByLine(line,true);
}
void CppPreprocessor::addDefineByLine(const QString &line, bool hardCoded)
{
// Remove define
@ -157,22 +152,13 @@ void CppPreprocessor::addDefineByLine(const QString &line, bool hardCoded)
addDefineByParts(name, args, value, hardCoded);
}
void CppPreprocessor::setScanOptions(bool parseSystem, bool parseLocal)
{
mParseSystem = parseSystem;
mParseLocal=parseLocal;
}
void CppPreprocessor::preprocess(const QString &fileName)
{
clearTempResults();
mFileName = fileName;
//mDefines = mHardDefines;
openInclude(fileName);
// StringsToFile(mBuffer,"f:\\buffer.txt");
preprocessBuffer();
// StringsToFile(mBuffer,"f:\\buffer.txt");
// StringsToFile(mResult,"f:\\log.txt");
}
void CppPreprocessor::invalidDefinesInFile(const QString &fileName)
@ -265,18 +251,6 @@ void CppPreprocessor::addProjectIncludePath(const QString &fileName)
}
}
void CppPreprocessor::clearIncludePaths()
{
mIncludePaths.clear();
mIncludePathList.clear();
}
void CppPreprocessor::clearProjectIncludePaths()
{
mProjectIncludePaths.clear();
mProjectIncludePathList.clear();
}
void CppPreprocessor::removeScannedFile(const QString &filename)
{
invalidDefinesInFile(filename);
@ -1204,71 +1178,6 @@ void CppPreprocessor::skipToPreprocessor()
}
}
bool CppPreprocessor::isWordChar(const QChar &ch)
{
if (ch=='_'
// || (ch>='a' && ch<='z') || (ch>='A' && ch<='Z')
|| ch.isLetter()
|| (ch>='0' && ch<='9')) {
return true;
}
return false;
}
bool CppPreprocessor::isIdentChar(const QChar &ch)
{
if (ch=='_' || ch == '*' || ch == '&' || ch == '~' ||
ch.isLetter()
//(ch>='a' && ch<='z') || (ch>='A' && ch<='Z')
|| (ch>='0' && ch<='9')) {
return true;
}
return false;
}
bool CppPreprocessor::isLineChar(const QChar &ch)
{
return ch=='\r' || ch == '\n';
}
bool CppPreprocessor::isSpaceChar(const QChar &ch)
{
return ch == ' ' || ch == '\t';
}
//bool CppPreprocessor::isOperatorChar(const QChar &ch)
//{
// switch(ch.unicode()) {
// case '+':
// case '-':
// case '*':
// case '/':
// case '!':
// case '=':
// case '<':
// case '>':
// case '&':
// case '|':
// case '^':
// return true;
// default:
// return false;
// }
//}
bool CppPreprocessor::isMacroIdentChar(const QChar &ch)
{
//return (ch>='A' && ch<='Z') || (ch>='a' && ch<='z')
return ch.isLetter()
|| ch == '_';
}
bool CppPreprocessor::isDigit(const QChar &ch)
{
return (ch>='0' && ch<='9');
}
bool CppPreprocessor::isNumberChar(const QChar &ch)
{
if (ch>='0' && ch<='9')
@ -1290,11 +1199,6 @@ bool CppPreprocessor::isNumberChar(const QChar &ch)
}
}
QString CppPreprocessor::lineBreak()
{
return "\n";
}
bool CppPreprocessor::evaluateIf(const QString &line)
{
QString newLine = expandDefines(line); // replace FOO by numerical value of FOO
@ -1961,22 +1865,4 @@ int CppPreprocessor::evaluateExpression(QString line)
return result;
}
void CppPreprocessor::setOnGetFileStream(const GetFileStreamCallBack &newOnGetFileStream)
{
mOnGetFileStream = newOnGetFileStream;
}
const QList<QString> &CppPreprocessor::projectIncludePathList() const
{
return mProjectIncludePathList;
}
const QList<QString> &CppPreprocessor::includePathList() const
{
return mIncludePathList;
}
const DefineMap &CppPreprocessor::hardDefines() const
{
return mHardDefines;
}

View File

@ -69,16 +69,25 @@ public:
void clearTempResults();
void getDefineParts(const QString& input, QString &name, QString &args, QString &value);
void addHardDefineByLine(const QString& line);
void setScanOptions(bool parseSystem, bool parseLocal);
void addHardDefineByLine(const QString& line) { addDefineByLine(line,true); }
void setScanOptions(bool parseSystem, bool parseLocal) {
mParseSystem = parseSystem;
mParseLocal=parseLocal;
}
void preprocess(const QString& fileName);
void dumpDefinesTo(const QString& fileName) const;
void dumpIncludesListTo(const QString& fileName) const;
void addIncludePath(const QString& fileName);
void addProjectIncludePath(const QString& fileName);
void clearIncludePaths();
void clearProjectIncludePaths();
void clearIncludePaths() {
mIncludePaths.clear();
mIncludePathList.clear();
}
void clearProjectIncludePaths() {
mProjectIncludePaths.clear();
mProjectIncludePathList.clear();
}
void removeScannedFile(const QString& filename);
PDefine getDefine(const QString& name) const{
@ -116,12 +125,12 @@ public:
return mProjectIncludePaths;
}
const DefineMap &hardDefines() const;
const DefineMap &hardDefines() const { return mHardDefines; }
const QList<QString> &includePathList() const;
const QList<QString> &includePathList() const { return mIncludePathList; }
const QList<QString> &projectIncludePathList() const;
void setOnGetFileStream(const GetFileStreamCallBack &newOnGetFileStream);
const QList<QString> &projectIncludePathList() const { return mProjectIncludePathList; }
void setOnGetFileStream(const GetFileStreamCallBack &newOnGetFileStream) { mOnGetFileStream = newOnGetFileStream; }
static QList<PDefineArgToken> tokenizeValue(const QString& value);
@ -198,40 +207,46 @@ private:
/*
* '_','a'..'z','A'..'Z','0'..'9'
*/
static bool isWordChar(const QChar& ch);
static bool isWordChar(const QChar& ch) {
return (ch=='_'
|| ch.isLetter()
|| (ch>='0' && ch<='9'));
}
/*
* 'A'..'Z', '0'..'9', 'a'..'z', '_', '*', '&', '~'
*/
static bool isIdentChar(const QChar& ch);
static bool isIdentChar(const QChar& ch) {
return (ch=='_' || ch == '*' || ch == '&' || ch == '~' ||
ch.isLetter()
|| (ch>='0' && ch<='9'));
}
/*
* '\r','\n'
*/
static bool isLineChar(const QChar& ch);
static bool isLineChar(const QChar& ch) { return ch=='\r' || ch == '\n'; }
/*
* '\t' ' '
*/
static bool isSpaceChar(const QChar& ch);
/*
* '+', '-', '*', '/', '!', '=', '<', '>', '&', '|', '^'
*/
//static bool isOperatorChar(const QChar& ch);
static bool isSpaceChar(const QChar& ch) { return ch == ' ' || ch == '\t'; }
/*
* 'A'..'Z', 'a'..'z', '_'
*/
static bool isMacroIdentChar(const QChar& ch);
static bool isMacroIdentChar(const QChar& ch) { return ch.isLetter() || ch == '_'; }
/*
* '0'..'9'
*/
static bool isDigit(const QChar& ch);
static bool isDigit(const QChar& ch) { return (ch>='0' && ch<='9'); }
/*
* '0'..'9','x',X','a'..'f','A'..'F','u','U','l','L'
*/
static bool isNumberChar(const QChar& ch);
QString lineBreak();
QString lineBreak() { return "\n"; }
bool evaluateIf(const QString& line);
QString expandDefines(QString line);

View File

@ -526,34 +526,6 @@ QString CppTokenizer::getWord()
return result;
}
bool CppTokenizer::isArguments()
{
return *mCurrent == '(';
}
//bool CppTokenizer::isForInit()
//{
// return (*mCurrent == '(') && (mLastToken == "for");
//}
bool CppTokenizer::isNumber()
{
return isDigitChar(*mCurrent);
}
bool CppTokenizer::isPreprocessor()
{
return *mCurrent=='#';
}
bool CppTokenizer::isWord()
{
bool result = isIdentChar(*mCurrent);
if (result && (*(mCurrent+1) == '"'))
result = false;
return result;
}
void CppTokenizer::simplify(QString &output)
{
//remove \n \r;

View File

@ -49,31 +49,18 @@ public:
void clear();
void tokenize(const QStringList& buffer);
void dumpTokens(const QString& fileName);
const PToken& operator[](int i) const {
return mTokenList[i];
}
int tokenCount() const {
return mTokenList.count();
}
static bool isIdentChar(const QChar& ch) {
return ch=='_' || ch.isLetter() ;
}
int lambdasCount() const {
return mLambdas.count();
}
const PToken& operator[](int i) const { return mTokenList[i]; }
int tokenCount() const { return mTokenList.count(); }
static bool isIdentChar(const QChar& ch) { return ch=='_' || ch.isLetter(); }
int lambdasCount() const { return mLambdas.count(); }
int indexOfFirstLambda() const {
return mLambdas.front();
}
void removeFirstLambda() {
mLambdas.pop_front();
}
int indexOfFirstLambda() const { return mLambdas.front(); }
void removeFirstLambda() { mLambdas.pop_front(); }
private:
void addToken(const QString& sText, int iLine, TokenType tokenType);
void advance();
void countLines();
PToken getToken(int index);
// QString getForInit();
QString getNextToken(
@ -81,11 +68,11 @@ private:
QString getNumber();
QString getPreprocessor();
QString getWord();
bool isArguments();
bool isArguments() { return *mCurrent == '('; }
// bool isForInit();
bool isNumber();
bool isPreprocessor();
bool isWord();
bool isNumber() { return isDigitChar(*mCurrent); }
bool isPreprocessor() { return *mCurrent=='#'; }
bool isWord() { return isIdentChar(*mCurrent) && (*(mCurrent+1) != '"') && (*(mCurrent+1) != '\''); }
void simplify(QString& output);
void simplifyArgs(QString& output);
// void skipAssignment();

View File

@ -529,7 +529,6 @@ bool isHFile(const QString& filename)
{
if (filename.isEmpty())
return false;
QFileInfo fileInfo(filename);
return CppHeaderExts->contains(fileInfo.suffix().toLower());
@ -576,28 +575,12 @@ void CppScopes::addScope(int line, PStatement scopeStatement)
scope->startLine = line;
scope->statement = scopeStatement;
mScopes.append(scope);
#ifdef QT_DEBUG
if (!mScopes.isEmpty() && mScopes.back()->startLine>line) {
qDebug()<<QString("Error: new scope %1 at %2 which is less that last scope %3")
.arg(scopeStatement->fullName, line,mScopes.back()->startLine>line);
}
}
PStatement CppScopes::lastScope() const
{
if (mScopes.isEmpty())
return PStatement();
return mScopes.back()->statement;
}
void CppScopes::removeLastScope()
{
if (!mScopes.isEmpty())
mScopes.pop_back();
}
void CppScopes::clear()
{
mScopes.clear();
#endif
}
MemberOperatorType getOperatorType(const QString &phrase, int index)
@ -767,17 +750,6 @@ bool isTypeKind(StatementKind kind)
}
}
ParsedFileInfo::ParsedFileInfo(const QString &fileName):
mFileName { fileName }
{
}
void ParsedFileInfo::insertBranch(int level, bool branchTrue)
{
mBranches.insert(level, branchTrue);
}
bool ParsedFileInfo::isLineVisible(int line) const
{
int lastI=-1;
@ -790,93 +762,3 @@ bool ParsedFileInfo::isLineVisible(int line) const
}
return lastI<0?true:mBranches[lastI];
}
void ParsedFileInfo::addInclude(const QString &fileName)
{
mIncludes.insert(fileName);
}
void ParsedFileInfo::addDirectInclude(const QString &fileName)
{
mDirectIncludes.append(fileName);
}
bool ParsedFileInfo::including(const QString &fileName) const
{
return mIncludes.contains(fileName);
}
const QSet<QString>& ParsedFileInfo::includes() const
{
return mIncludes;
}
const QList<std::weak_ptr<ClassInheritanceInfo> >& ParsedFileInfo::handledInheritances() const
{
return mHandledInheritances;
}
QString ParsedFileInfo::fileName() const
{
return mFileName;
}
PStatement ParsedFileInfo::findScopeAtLine(int line) const
{
return mScopes.findScopeAtLine(line);
}
void ParsedFileInfo::addStatement(const PStatement &statement)
{
mStatements.insert(statement->fullName,statement);
}
void ParsedFileInfo::clearStatements()
{
mStatements.clear();
}
void ParsedFileInfo::addScope(int line, const PStatement &scope)
{
mScopes.addScope(line,scope);
}
void ParsedFileInfo::removeLastScope()
{
mScopes.removeLastScope();
}
PStatement ParsedFileInfo::lastScope() const
{
return mScopes.lastScope();
}
void ParsedFileInfo::addUsing(const QString &usingSymbol)
{
mUsings.insert(usingSymbol);
}
void ParsedFileInfo::addHandledInheritances(std::weak_ptr<ClassInheritanceInfo> classInheritanceInfo)
{
mHandledInheritances.append(classInheritanceInfo);
}
void ParsedFileInfo::clearHandledInheritances()
{
mHandledInheritances.clear();
}
const StatementMap& ParsedFileInfo::statements() const
{
return mStatements;
}
const QSet<QString>& ParsedFileInfo::usings() const
{
return mUsings;
}
const QStringList& ParsedFileInfo::directIncludes() const
{
return mDirectIncludes;
}

View File

@ -174,8 +174,6 @@ Q_DECLARE_FLAGS(StatementProperties, StatementProperty)
Q_DECLARE_OPERATORS_FOR_FLAGS(StatementProperties)
using PStatementMathPosition = std::shared_ptr<StatementMatchPosition>;
struct Statement;
@ -184,8 +182,6 @@ using StatementList = QList<PStatement>;
using PStatementList = std::shared_ptr<StatementList>;
using StatementMap = QMultiMap<QString, PStatement>;
struct Statement {
// Statement();
// ~Statement();
std::weak_ptr<Statement> parentScope; // parent class/struct/namespace scope, use weak pointer to prevent circular reference
QString type; // type "int"
QString command; // identifier/name of statement "foo"
@ -293,13 +289,19 @@ struct CppScope {
using PCppScope = std::shared_ptr<CppScope>;
class CppScopes {
public:
PStatement findScopeAtLine(int line) const;
void addScope(int line, PStatement scopeStatement);
PStatement lastScope() const;
void removeLastScope();
void clear();
PStatement lastScope() const {
if (mScopes.isEmpty())
return PStatement();
return mScopes.back()->statement;
}
void removeLastScope() {
if (!mScopes.isEmpty())
mScopes.pop_back();
}
void clear() { mScopes.clear(); }
private:
QVector<PCppScope> mScopes;
};
@ -319,32 +321,30 @@ using PClassInheritanceInfo = std::shared_ptr<ClassInheritanceInfo>;
class ParsedFileInfo {
public:
ParsedFileInfo(const QString& fileName);
ParsedFileInfo(const QString& fileName): mFileName {fileName} { }
ParsedFileInfo(const ParsedFileInfo&)=delete;
ParsedFileInfo& operator=(const ParsedFileInfo&)=delete;
void insertBranch(int level, bool branchTrue);
void insertBranch(int level, bool branchTrue) { mBranches.insert(level, branchTrue); }
bool isLineVisible(int line) const;
void addInclude(const QString &fileName);
void addDirectInclude(const QString &fileName);
bool including(const QString &fileName) const;
PStatement findScopeAtLine(int line) const;
void addStatement(const PStatement &statement);
void clearStatements();
void addScope(int line, const PStatement &scope);
void removeLastScope();
PStatement lastScope() const;
void addUsing(const QString &usingSymbol);
void addHandledInheritances(std::weak_ptr<ClassInheritanceInfo> classInheritanceInfo);
void clearHandledInheritances();
void addInclude(const QString &fileName) { mIncludes.insert(fileName); }
void addDirectInclude(const QString &fileName) { mDirectIncludes.append(fileName); }
bool including(const QString &fileName) const { return mIncludes.contains(fileName); }
PStatement findScopeAtLine(int line) const { return mScopes.findScopeAtLine(line); }
void addStatement(const PStatement &statement) { mStatements.insert(statement->fullName,statement); }
void clearStatements() { mStatements.clear(); }
void addScope(int line, const PStatement &scope) { mScopes.addScope(line,scope); }
void removeLastScope() { mScopes.removeLastScope(); }
PStatement lastScope() const { return mScopes.lastScope(); }
void addUsing(const QString &usingSymbol) { mUsings.insert(usingSymbol); }
void addHandledInheritances(std::weak_ptr<ClassInheritanceInfo> classInheritanceInfo) { mHandledInheritances.append(classInheritanceInfo); }
void clearHandledInheritances() { mHandledInheritances.clear(); }
QString fileName() const;
const StatementMap& statements() const;
const QSet<QString>& usings() const;
const QStringList& directIncludes() const;
const QSet<QString>& includes() const;
const QList<std::weak_ptr<ClassInheritanceInfo> >& handledInheritances() const;
const QSet<QString> &includedBySet() const;
int includedByCount(const QString &fileName) const;
QString fileName() const { return mFileName; }
const StatementMap& statements() const { return mStatements; }
const QSet<QString>& usings() const { return mUsings; }
const QStringList& directIncludes() const { return mDirectIncludes; }
const QSet<QString>& includes() const { return mIncludes; }
const QList<std::weak_ptr<ClassInheritanceInfo> >& handledInheritances() const { return mHandledInheritances; }
private:
QString mFileName;

View File

@ -39,7 +39,6 @@ void StatementModel::add(const PStatement& statement)
#ifdef QT_DEBUG
mAllStatements.append(statement);
#endif
}
void StatementModel::deleteStatement(const PStatement& statement)
@ -61,29 +60,6 @@ void StatementModel::deleteStatement(const PStatement& statement)
}
const StatementMap &StatementModel::childrenStatements(const PStatement& statement) const
{
if (!statement) {
return mGlobalStatements;
} else {
return statement->children;
}
}
const StatementMap &StatementModel::childrenStatements(std::weak_ptr<Statement> statement) const
{
PStatement s = statement.lock();
return childrenStatements(s);
}
void StatementModel::clear() {
mCount=0;
mGlobalStatements.clear();
#ifdef QT_DEBUG
mAllStatements.clear();
#endif
}
#ifdef QT_DEBUG
void StatementModel::dump(const QString &logFile)
{

View File

@ -30,12 +30,22 @@ public:
StatementModel& operator=(const StatementModel&)=delete;
void add(const PStatement& statement);
// function DeleteFirst: Integer;
// function DeleteLast: Integer;
void deleteStatement(const PStatement& statement);
const StatementMap& childrenStatements(const PStatement& statement = PStatement()) const;
const StatementMap& childrenStatements(std::weak_ptr<Statement> statement) const;
void clear();
const StatementMap& childrenStatements(const PStatement& statement = PStatement()) const {
if (!statement) {
return mGlobalStatements;
} else {
return statement->children;
}
}
const StatementMap& childrenStatements(std::weak_ptr<Statement> statement) const { return childrenStatements(statement.lock()); }
void clear() {
mCount=0;
mGlobalStatements.clear();
#ifdef QT_DEBUG
mAllStatements.clear();
#endif
}
int count() const { return mCount; }
#ifdef QT_DEBUG
void dump(const QString& logFile);

View File

@ -18,9 +18,11 @@
#include <QHBoxLayout>
#include <QPushButton>
#include <QDebug>
FunctionTooltipWidget::FunctionTooltipWidget(QWidget *parent) :
QFrame(parent, Qt::ToolTip | Qt::WindowStaysOnTopHint | Qt::WindowDoesNotAcceptFocus)
QFrame{parent, Qt::ToolTip | Qt::WindowStaysOnTopHint | Qt::WindowDoesNotAcceptFocus},
mMinWidth{410}
{
setFocusPolicy(Qt::NoFocus);
mInfoLabel = new QLabel(this);
@ -120,12 +122,19 @@ void FunctionTooltipWidget::updateTip()
return;
PFunctionInfo info = mInfos[mInfoIndex];
QString text = info->returnType+ " " + info->name;
QString originText = text;
if (info->params.length()==0) {
text += "()";
originText += "()";
} else {
QStringList displayList;
QStringList originList;
for (int i=0;i<info->params.length();i++){
const QString& param = info->params[i];
QString param = info->params[i];
originList.append(param);
param.replace("<","&lt;");
param.replace(">","&gt;");
if (mParamIndex == i) {
displayList.append(QString("<b>%1</b>").arg(param));
} else {
@ -133,13 +142,14 @@ void FunctionTooltipWidget::updateTip()
}
}
text += "( "+displayList.join(", ") + ") ";
originText += "( "+originList.join(", ") + ") ";
}
if (mInfos.length()>1) {
mTotalLabel->setText(QString("%1/%2").arg(mInfoIndex+1).arg(mInfos.length()));
}
int width = mInfoLabel->fontMetrics().horizontalAdvance(text);
if (width > 400) {
mInfoLabel->setMinimumWidth(410);
int width = mInfoLabel->fontMetrics().horizontalAdvance(originText)+10;
if (width > mMinWidth) {
mInfoLabel->setMinimumWidth(mMinWidth);
} else {
mInfoLabel->setMinimumWidth(width);
}
@ -192,6 +202,16 @@ QStringList FunctionTooltipWidget::splitArgs(QString argStr)
return result;
}
int FunctionTooltipWidget::minWidth() const
{
return mMinWidth;
}
void FunctionTooltipWidget::setMinWidth(int newMinWidth)
{
mMinWidth = newMinWidth;
}
const QString &FunctionTooltipWidget::functionFullName() const
{
return mFunctioFullName;

View File

@ -54,6 +54,9 @@ public:
const QString &functionFullName() const;
void setFunctioFullName(const QString &newFunctioFullName);
int minWidth() const;
void setMinWidth(int newMinWidth);
private:
QStringList splitArgs(QString args);
private:
@ -67,6 +70,7 @@ private:
QString mFunctioFullName;
QList<PFunctionInfo> mInfos;
int mMinWidth;
// QWidget interface
protected:

View File

@ -1334,9 +1334,9 @@ int DocumentLine::glyphWidth(int i)
return calcSegmentInterval(mGlyphStartPositionList, mWidth, i);
}
int DocumentLine::width(bool forceUpdate)
int DocumentLine::width()
{
if(mWidth<0 || forceUpdate)
if(mWidth<0)
updateWidth();
return mWidth;
}

View File

@ -68,17 +68,13 @@ private:
*
* @return the glyphs count
*/
int glyphsCount() const {
return mGlyphStartCharList.length();
}
int glyphsCount() const { return mGlyphStartCharList.length(); }
/**
* @brief get list of start index of the glyphs in the line text
* @return start indice of the glyph.
*/
const QList<int>& glyphStartCharList() const {
return mGlyphStartCharList;
}
const QList<int>& glyphStartCharList() const { return mGlyphStartCharList; }
/**
* @brief get list of start position of the glyphs in the line text
@ -131,7 +127,7 @@ private:
* @brief get the width (pixel) of the line text
* @return the width (in width)
*/
int width(bool forceUpdate=false);
int width();
/**
* @brief get the state of the syntax highlighter after this line is parsed

View File

@ -81,12 +81,6 @@ bool enumTokenAttributes(PSyntaxer syntaxer, bool skipDuplicates,
tokenAttriProc, params, syntaxerList);
}
int mulDiv(int a, int b, int c)
{
//todo: handle overflow?
return a*b/c;
}
FontStyles getFontStyles(const QFont &font)
{
FontStyles styles;

View File

@ -37,7 +37,6 @@ class QColor;
namespace QSynedit {
int minMax(int x, int mi, int ma);
int mulDiv(int a, int b, int c);
BufferCoord maxBufferCoord(const BufferCoord& P1, const BufferCoord& P2);
BufferCoord minBufferCoord(const BufferCoord& P1, const BufferCoord& P2);

View File

@ -220,112 +220,12 @@ CppSyntaxer::CppSyntaxer(): Syntaxer()
resetState();
}
const PTokenAttribute &CppSyntaxer::preprocessorAttribute() const
{
return mPreprocessorAttribute;
}
const PTokenAttribute &CppSyntaxer::invalidAttribute() const
{
return mInvalidAttribute;
}
const PTokenAttribute &CppSyntaxer::numberAttribute() const
{
return mNumberAttribute;
}
const PTokenAttribute &CppSyntaxer::floatAttribute() const
{
return mFloatAttribute;
}
const PTokenAttribute &CppSyntaxer::hexAttribute() const
{
return mHexAttribute;
}
const PTokenAttribute &CppSyntaxer::octAttribute() const
{
return mOctAttribute;
}
const PTokenAttribute &CppSyntaxer::stringEscapeSequenceAttribute() const
{
return mStringEscapeSequenceAttribute;
}
const PTokenAttribute &CppSyntaxer::charAttribute() const
{
return mCharAttribute;
}
const PTokenAttribute &CppSyntaxer::variableAttribute() const
{
return mVariableAttribute;
}
const PTokenAttribute &CppSyntaxer::functionAttribute() const
{
return mFunctionAttribute;
}
const PTokenAttribute &CppSyntaxer::classAttribute() const
{
return mClassAttribute;
}
const PTokenAttribute &CppSyntaxer::globalVarAttribute() const
{
return mGlobalVarAttribute;
}
const PTokenAttribute &CppSyntaxer::localVarAttribute() const
{
return mLocalVarAttribute;
}
bool CppSyntaxer::isStringToNextLine(int state)
{
return state == RangeState::rsStringNextLine;
}
bool CppSyntaxer::isRawStringStart(int state)
{
return state == RangeState::rsRawString;
}
bool CppSyntaxer::isRawStringNoEscape(int state)
{
return state == RangeState::rsRawStringNotEscaping;
}
bool CppSyntaxer::isRawStringEnd(int state)
{
return state == RangeState::rsRawStringEnd;
}
bool CppSyntaxer::isCharNotFinished(int state)
{
return state == RangeState::rsChar || state == RangeState::rsCharEscaping;
}
bool CppSyntaxer::isCharEscaping(int state)
{
return state == RangeState::rsCharEscaping;
}
bool CppSyntaxer::isInAttribute(const SyntaxState &state)
{
return state.extraData.contains(DATA_KEY_IN_ATTRIBUTE)
&& state.extraData[DATA_KEY_IN_ATTRIBUTE].toBool();
}
CppSyntaxer::TokenId CppSyntaxer::getTokenId()
{
return mTokenId;
}
void CppSyntaxer::procAndSymbol()
{
mTokenId = TokenId::Symbol;

View File

@ -60,31 +60,31 @@ public:
CppSyntaxer(const CppSyntaxer&)=delete;
CppSyntaxer operator=(const CppSyntaxer&)=delete;
const PTokenAttribute &preprocessorAttribute() const;
const PTokenAttribute &preprocessorAttribute() const { return mPreprocessorAttribute; }
const PTokenAttribute &invalidAttribute() const;
const PTokenAttribute &invalidAttribute() const { return mInvalidAttribute; }
const PTokenAttribute &numberAttribute() const;
const PTokenAttribute &numberAttribute() const { return mNumberAttribute; }
const PTokenAttribute &floatAttribute() const;
const PTokenAttribute &floatAttribute() const { return mFloatAttribute; }
const PTokenAttribute &hexAttribute() const;
const PTokenAttribute &hexAttribute() const { return mHexAttribute; }
const PTokenAttribute &octAttribute() const;
const PTokenAttribute &octAttribute() const { return mOctAttribute; }
const PTokenAttribute &stringEscapeSequenceAttribute() const;
const PTokenAttribute &stringEscapeSequenceAttribute() const { return mStringEscapeSequenceAttribute; }
const PTokenAttribute &charAttribute() const;
const PTokenAttribute &charAttribute() const { return mCharAttribute; }
const PTokenAttribute &variableAttribute() const;
const PTokenAttribute &variableAttribute() const { return mVariableAttribute; }
const PTokenAttribute &functionAttribute() const;
const PTokenAttribute &functionAttribute() const { return mFunctionAttribute; }
const PTokenAttribute &classAttribute() const;
const PTokenAttribute &classAttribute() const { return mClassAttribute; }
const PTokenAttribute &globalVarAttribute() const;
const PTokenAttribute &globalVarAttribute() const { return mGlobalVarAttribute; }
const PTokenAttribute &localVarAttribute() const;
const PTokenAttribute &localVarAttribute() const { return mLocalVarAttribute; }
static const QSet<QString> Keywords;
@ -92,15 +92,15 @@ public:
static const QSet<QString> StandardAttributes;
bool isStringToNextLine(int state);
bool isRawStringStart(int state);
bool isRawStringNoEscape(int state);
bool isRawStringEnd(int state);
bool isCharNotFinished(int state);
bool isCharEscaping(int state);
bool isStringToNextLine(int state) { return state == RangeState::rsStringNextLine; }
bool isRawStringStart(int state) { return state == RangeState::rsRawString; }
bool isRawStringNoEscape(int state) { return state == RangeState::rsRawStringNotEscaping; }
bool isRawStringEnd(int state) { return state == RangeState::rsRawStringEnd; }
bool isCharNotFinished(int state) { return state == RangeState::rsChar || state == RangeState::rsCharEscaping; }
bool isCharEscaping(int state) { return state == RangeState::rsCharEscaping; }
bool isInAttribute(const SyntaxState &state);
TokenId getTokenId();
TokenId getTokenId() { return mTokenId; }
private:
void procAndSymbol();
void procCppStyleComment();
@ -159,7 +159,6 @@ private:
private:
SyntaxState mRange;
// SynRangeState mSpaceRange;
QString mLine;
int mLineSize;
int mRun;

View File

@ -41,46 +41,6 @@ Syntaxer::Syntaxer() :
addAttribute(mSymbolAttribute);
}
QMap<QString, PTokenAttribute> Syntaxer::attributes() const
{
return mAttributes;
}
const QSet<QChar>& Syntaxer::wordBreakChars() const
{
return mWordBreakChars;
}
const PTokenAttribute& Syntaxer::identifierAttribute() const
{
return mIdentifierAttribute;
}
const PTokenAttribute &Syntaxer::keywordAttribute() const
{
return mKeywordAttribute;
}
const PTokenAttribute &Syntaxer::commentAttribute() const
{
return mCommentAttribute;
}
const PTokenAttribute& Syntaxer::stringAttribute() const
{
return mStringAttribute;
}
const PTokenAttribute& Syntaxer::whitespaceAttribute() const
{
return mWhitespaceAttribute;
}
const PTokenAttribute& Syntaxer::symbolAttribute() const
{
return mSymbolAttribute;
}
bool Syntaxer::isKeyword(const QString &)
{
return false;
@ -153,48 +113,17 @@ bool Syntaxer::isWordBreakChar(const QChar &ch)
bool Syntaxer::isIdentChar(const QChar &ch) const
{
if (ch == '_') {
return true;
}
if ((ch>='0') && (ch <= '9')) {
return true;
}
if ((ch>='a') && (ch <= 'z')) {
return true;
}
if ((ch>='A') && (ch <= 'Z')) {
return true;
}
return false;
return (ch == '_')
|| ((ch>='0') && (ch <= '9'))
|| ((ch>='a') && (ch <= 'z'))
|| ((ch>='A') && (ch <= 'Z'));
}
bool Syntaxer::isIdentStartChar(const QChar &ch) const
{
if (ch == '_') {
return true;
}
if ((ch>='a') && (ch <= 'z')) {
return true;
}
if ((ch>='A') && (ch <= 'Z')) {
return true;
}
return false;
}
void Syntaxer::addAttribute(PTokenAttribute attribute)
{
mAttributes[attribute->name()]=attribute;
}
void Syntaxer::clearAttributes()
{
mAttributes.clear();
}
int Syntaxer::attributesCount() const
{
return mAttributes.size();
return (ch == '_')
|| ((ch>='a') && (ch <= 'z'))
|| ((ch>='A') && (ch <= 'Z'));
}
PTokenAttribute Syntaxer::getAttribute(const QString& name) const
@ -217,48 +146,6 @@ QString Syntaxer::blockCommentEndSymbol()
return QString();
}
FontStyles TokenAttribute::styles() const
{
return mStyles;
}
void TokenAttribute::setStyles(const FontStyles &styles)
{
if (mStyles!=styles) {
mStyles = styles;
}
}
const QColor& TokenAttribute::foreground() const
{
return mForeground;
}
void TokenAttribute::setForeground(const QColor &color)
{
mForeground = color;
}
const QColor &TokenAttribute::background() const
{
return mBackground;
}
void TokenAttribute::setBackground(const QColor &background)
{
mBackground = background;
}
TokenType TokenAttribute::tokenType() const
{
return mTokenType;
}
QString TokenAttribute::name() const
{
return mName;
}
TokenAttribute::TokenAttribute(const QString &name, TokenType tokenType):
mForeground(QColor()),
mBackground(QColor()),
@ -280,11 +167,9 @@ bool SyntaxState::operator==(const SyntaxState &s2)
&& (braceLevel == s2.braceLevel) // current braces embedding level (needed by rainbow color)
&& (bracketLevel == s2.bracketLevel) // current brackets embedding level (needed by rainbow color)
&& (parenthesisLevel == s2.parenthesisLevel) // current parenthesis embedding level (needed by rainbow color)
&& (indents == s2.indents)
&& (lastUnindent == s2.lastUnindent)
;
}
IndentInfo SyntaxState::getLastIndent()

View File

@ -93,18 +93,22 @@ public:
TokenAttribute(const TokenAttribute&)=delete;
TokenAttribute& operator=(const TokenAttribute&)=delete;
QString name() const;
QString name() const { return mName; }
FontStyles styles() const;
void setStyles(const FontStyles &styles);
FontStyles styles() const { return mStyles; }
void setStyles(const FontStyles &styles) {
if (mStyles!=styles) {
mStyles = styles;
}
}
const QColor &foreground() const;
void setForeground(const QColor &color);
const QColor &foreground() const { return mForeground; }
void setForeground(const QColor &color) { mForeground = color; }
const QColor &background() const;
void setBackground(const QColor &background);
const QColor &background() const { return mBackground; }
void setBackground(const QColor &background) { mBackground = background; }
TokenType tokenType() const;
TokenType tokenType() const { return mTokenType; }
private:
QColor mForeground;
@ -122,21 +126,21 @@ public:
Syntaxer(const Syntaxer&)=delete;
Syntaxer& operator=(const Syntaxer&)=delete;
virtual QMap<QString, PTokenAttribute> attributes() const;
QMap<QString, PTokenAttribute> attributes() const { return mAttributes; }
const QSet<QChar>& wordBreakChars() const;
const QSet<QChar>& wordBreakChars() const { return mWordBreakChars; }
const PTokenAttribute& identifierAttribute() const;
const PTokenAttribute& identifierAttribute() const { return mIdentifierAttribute; }
const PTokenAttribute& keywordAttribute() const;
const PTokenAttribute& keywordAttribute() const { return mKeywordAttribute; }
const PTokenAttribute& commentAttribute() const;
const PTokenAttribute& commentAttribute() const { return mCommentAttribute; }
const PTokenAttribute& stringAttribute() const;
const PTokenAttribute& stringAttribute() const { return mStringAttribute; }
const PTokenAttribute& whitespaceAttribute() const;
const PTokenAttribute& whitespaceAttribute() const { return mWhitespaceAttribute; }
const PTokenAttribute& symbolAttribute() const;
const PTokenAttribute& symbolAttribute() const { return mSymbolAttribute; }
virtual bool isIdentChar(const QChar& ch) const;
virtual bool isIdentStartChar(const QChar& ch) const;
@ -183,9 +187,9 @@ protected:
PTokenAttribute mWhitespaceAttribute;
PTokenAttribute mSymbolAttribute;
void addAttribute(PTokenAttribute attribute);
void clearAttributes();
virtual int attributesCount() const;
void addAttribute(PTokenAttribute attribute) { mAttributes[attribute->name()]=attribute; }
void clearAttributes() { mAttributes.clear(); }
virtual int attributesCount() const { return mAttributes.size(); }
private:
QMap<QString,PTokenAttribute> mAttributes;

View File

@ -48,14 +48,6 @@ void TextSyntaxer::procNull()
mState = RangeState::Unknown;
}
QMap<QString, PTokenAttribute> TextSyntaxer::attributes() const
{
QMap<QString, PTokenAttribute> result;
result.insert(SYNS_AttrText, mTextAttribute);
result.insert(SYNS_AttrSpace, whitespaceAttribute());
return result;
}
bool TextSyntaxer::eol() const
{
return mTokenID == TokenId::Null;

View File

@ -61,7 +61,6 @@ private:
void procNull();
public:
QMap<QString, PTokenAttribute> attributes() const override;
bool eol() const override;
QString languageName() override;