├── util ├── screen.png ├── win │ ├── env.bat │ ├── prepare.bat │ └── build.bat ├── osx │ ├── build.sh │ ├── prepare.sh │ └── qt_install.qs ├── ubuntu │ ├── build.sh │ ├── prepare.sh │ └── qt_install.qs └── README.md ├── images ├── passed.ico ├── popup.ico └── README.md ├── .gitignore ├── resources.qrc ├── src ├── PluginGlobal.h ├── ParseState.cpp ├── Constants.h ├── OutputParser.h ├── AutoToolTipDelegate.h ├── TestMark.h ├── ParseState.h ├── TestMark.cpp ├── PaneWidget.ui ├── QtcGtestPlugin.h ├── PaneWidget.h ├── AutoToolTipDelegate.cpp ├── TestProject.h ├── PaneWidget.cpp ├── TestModel.h ├── OutputPane.h ├── QtcGtestPlugin.cpp ├── OutputParser.cpp ├── OutputPane.cpp ├── TestProject.cpp └── TestModel.cpp ├── QtcGtest.json.in ├── .gitattributes ├── .appveyor.yml ├── paths.pri ├── LICENSE.md ├── README.md ├── .travis.yml ├── qtc-gtest.pro ├── translation └── QtcGtest_ru.ts └── uncrustify.cfg /util/screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneMoreGres/qtc-gtest/HEAD/util/screen.png -------------------------------------------------------------------------------- /images/passed.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneMoreGres/qtc-gtest/HEAD/images/passed.ico -------------------------------------------------------------------------------- /images/popup.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneMoreGres/qtc-gtest/HEAD/images/popup.ico -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled translations 2 | *.qm 3 | 4 | # Qt creator user settings 5 | *.user 6 | 7 | # Archives 8 | *.zip 9 | *.rar 10 | *.tar.gz 11 | *.tar.bz2 -------------------------------------------------------------------------------- /resources.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | images/popup.ico 4 | images/passed.ico 5 | 6 | 7 | -------------------------------------------------------------------------------- /images/README.md: -------------------------------------------------------------------------------- 1 | #Used images: 2 | 3 | [Tango Icon Library](http://tango.freedesktop.org/Tango_Icon_Library) 4 | 5 | [Free 3d Glossy Interface Icons](http://www.aha-soft.com) 6 | -------------------------------------------------------------------------------- /src/PluginGlobal.h: -------------------------------------------------------------------------------- 1 | #ifndef QTCGTEST_GLOBAL_H 2 | #define QTCGTEST_GLOBAL_H 3 | 4 | #include 5 | 6 | #if defined(QTCGTEST_LIBRARY) 7 | # define QTCGTESTSHARED_EXPORT Q_DECL_EXPORT 8 | #else 9 | # define QTCGTESTSHARED_EXPORT Q_DECL_IMPORT 10 | #endif 11 | 12 | #endif // QTCGTEST_GLOBAL_H 13 | 14 | -------------------------------------------------------------------------------- /src/ParseState.cpp: -------------------------------------------------------------------------------- 1 | #include "ParseState.h" 2 | 3 | using namespace QtcGtest::Internal; 4 | 5 | ParseState::ParseState () { 6 | reset (); 7 | } 8 | 9 | void ParseState::reset () { 10 | isGoogleTestRun = false; 11 | currentCase = currentTest = QString (); 12 | passedCount = passedTotalCount = failedCount = failedTotalCount = totalTime = disabledCount = 0; 13 | projectFiles.clear (); 14 | } 15 | -------------------------------------------------------------------------------- /QtcGtest.json.in: -------------------------------------------------------------------------------- 1 | { 2 | \"Name\" : \"QtcGtest\", 3 | \"Version\" : \"$$QTCREATOR_VERSION$$VERSION_SUFFIX\", 4 | \"CompatVersion\" : \"$$QTCREATOR_COMPAT_VERSION\", 5 | \"Experimental\" : true, 6 | \"Category\": \"C++\", 7 | \"Vendor\" : \"Gres\", 8 | \"Copyright\" : \"(C) Gres\", 9 | \"License\" : \"MIT license\", 10 | \"Description\" : \"Integrates Google test framework into Qt Creator\", 11 | \"Url\" : \"http://gres.biz/qtc-gtest\", 12 | $$dependencyList 13 | } 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/Constants.h: -------------------------------------------------------------------------------- 1 | #ifndef QTCGTESTCONSTANTS_H 2 | #define QTCGTESTCONSTANTS_H 3 | 4 | namespace QtcGtest { 5 | namespace Constants { 6 | 7 | const char MENU_ID[] = "QtcGtest.Menu"; 8 | const char ACTION_CHECK_PROJECT_ID[] = "QtcGtest.CheckActiveProject"; 9 | const char ACTION_CHECK_CURRENT_ID[] = "QtcGtest.CheckCurrent"; 10 | const char ACTION_CHECK_CHANGED_ID[] = "QtcGtest.CheckChanged"; 11 | const char TEST_MARK_ID[] = "QtcGtest.TestMark"; 12 | 13 | } // namespace QtcGtest 14 | } // namespace Constants 15 | 16 | #endif // QTCGTESTCONSTANTS_H 17 | 18 | -------------------------------------------------------------------------------- /util/win/env.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | if "%ARCH%" == "" set ARCH=x86 4 | 5 | if /i %ARCH% == x86 goto x86 6 | if /i %ARCH% == x64 goto x64 7 | goto end 8 | 9 | :x64 10 | call "c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64 11 | set PATH=c:\Qt\5.10.1\msvc2015_64\bin\;%PATH% 12 | set QT_DIR=c:\Qt\5.10.1\msvc2015_64\ 13 | goto end 14 | 15 | :x86 16 | call "c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86 17 | set PATH=c:\Qt\5.10.1\msvc2015\bin\;%PATH% 18 | set QT_DIR=c:\Qt\5.10.1\msvc2015\ 19 | goto end 20 | 21 | :end 22 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /src/OutputParser.h: -------------------------------------------------------------------------------- 1 | #ifndef OUTPUTPARSER_H 2 | #define OUTPUTPARSER_H 3 | 4 | #include 5 | 6 | namespace QtcGtest { 7 | namespace Internal { 8 | 9 | class TestModel; 10 | class ParseState; 11 | 12 | class OutputParser : public QObject { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit OutputParser (QObject *parent = 0); 17 | 18 | bool isGoogleTestRun (const QString &line) const; 19 | 20 | void parseMessage (const QString &line, TestModel &model, ParseState &state); 21 | }; 22 | 23 | } // namespace Internal 24 | } // namespace QtcGtest 25 | 26 | #endif // OUTPUTPARSER_H 27 | -------------------------------------------------------------------------------- /src/AutoToolTipDelegate.h: -------------------------------------------------------------------------------- 1 | #ifndef AUTOTOOLTIPDELEGATE_H 2 | #define AUTOTOOLTIPDELEGATE_H 3 | 4 | #include 5 | 6 | namespace QtcGtest { 7 | namespace Internal { 8 | 9 | class AutoToolTipDelegate : public QStyledItemDelegate { 10 | Q_OBJECT 11 | 12 | public: 13 | AutoToolTipDelegate (QObject *parent); 14 | 15 | public slots: 16 | bool helpEvent (QHelpEvent *event, QAbstractItemView *view, 17 | const QStyleOptionViewItem &option, const QModelIndex &index); 18 | }; 19 | 20 | } // namespace Internal 21 | } // namespace QtcGtest 22 | 23 | 24 | #endif // AUTOTOOLTIPDELEGATE_H 25 | -------------------------------------------------------------------------------- /src/TestMark.h: -------------------------------------------------------------------------------- 1 | #ifndef TESTMARK_H 2 | #define TESTMARK_H 3 | 4 | #include 5 | 6 | #include 7 | 8 | namespace QtcGtest { 9 | namespace Internal { 10 | 11 | class OutputPane; 12 | 13 | class TestMark : public TextEditor::TextMark { 14 | public: 15 | TestMark (QPersistentModelIndex index, const QString &fileName, int lineNumber, 16 | OutputPane &pane); 17 | 18 | bool isClickable () const override; 19 | void clicked () override; 20 | 21 | private: 22 | QPersistentModelIndex index_; 23 | OutputPane &pane_; 24 | }; 25 | 26 | } 27 | } 28 | 29 | #endif // TESTMARK_H 30 | -------------------------------------------------------------------------------- /src/ParseState.h: -------------------------------------------------------------------------------- 1 | #ifndef PARSESTATE_H 2 | #define PARSESTATE_H 3 | 4 | #include 5 | 6 | namespace QtcGtest { 7 | namespace Internal { 8 | 9 | class ParseState { 10 | public: 11 | ParseState (); 12 | void reset (); 13 | 14 | bool isGoogleTestRun; 15 | Utils::FileNameList projectFiles; 16 | QString currentCase; 17 | QString currentTest; 18 | int passedCount; 19 | int failedCount; 20 | int passedTotalCount; 21 | int failedTotalCount; 22 | int totalTime; 23 | int disabledCount; 24 | }; 25 | 26 | } // namespace Internal 27 | } // namespace QtcGtest 28 | 29 | 30 | #endif // PARSESTATE_H 31 | -------------------------------------------------------------------------------- /.appveyor.yml: -------------------------------------------------------------------------------- 1 | image: Visual Studio 2015 2 | 3 | clone_depth: 10 4 | 5 | platform: 6 | - x86 7 | 8 | environment: 9 | APPVEYOR_SAVE_CACHE_ON_ERROR: true 10 | 11 | init: 12 | - if /i %APPVEYOR_REPO_TAG% == true set VERSION=%APPVEYOR_REPO_TAG_NAME% 13 | 14 | cache: 15 | - qtcreator-latest\compiled 16 | 17 | install: 18 | - call "util\win\prepare.bat" 19 | 20 | build_script: 21 | - call "util\win\build.bat" 22 | 23 | artifacts: 24 | - path: 'QtcGtest-*.zip' 25 | name: archive 26 | 27 | deploy: 28 | - provider: GitHub 29 | description: '' 30 | auth_token: 31 | secure: NnyUV44yNAx8ea1L46dVhE4kQxUGd5M1O+yVk+9ncsNHWtw/9JoCnDqNybnxTccP 32 | artifact: archive 33 | force_update: true 34 | on: 35 | appveyor_repo_tag: true 36 | -------------------------------------------------------------------------------- /paths.pri: -------------------------------------------------------------------------------- 1 | ## set the QTC_SOURCE environment variable to override the setting here 2 | QTCREATOR_SOURCES = $$(QTC_SOURCE) 3 | isEmpty(QTCREATOR_SOURCES):QTCREATOR_SOURCES=$$PWD/../qtcreator-latest/src 4 | 5 | ## set the QTC_BUILD environment variable to override the setting here 6 | IDE_BUILD_TREE = $$(QTC_BUILD) 7 | isEmpty(IDE_BUILD_TREE){ 8 | linux-g++:QMAKE_TARGET.arch = $$QMAKE_HOST.arch 9 | linux-g++-32:QMAKE_TARGET.arch = x86 10 | linux-g++-64:QMAKE_TARGET.arch = x86_64 11 | 12 | IDE_BUILD_TREE=$$PWD/../qtcreator-latest/release-x64 13 | CONFIG(debug, debug|release):IDE_BUILD_TREE=$$PWD/../qtcreator-latest/debug-x64 14 | contains(QMAKE_TARGET.arch, x86):IDE_BUILD_TREE=$$PWD/../qtcreator-latest/release-x86 15 | msvc:IDE_BUILD_TREE=$$PWD/../qtcreator-latest/release 16 | } 17 | -------------------------------------------------------------------------------- /src/TestMark.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "TestMark.h" 4 | #include "Constants.h" 5 | #include "OutputPane.h" 6 | 7 | namespace QtcGtest { 8 | namespace Internal { 9 | 10 | TestMark::TestMark (QPersistentModelIndex index, const QString &fileName, int lineNumber, 11 | OutputPane &pane) 12 | : TextEditor::TextMark (fileName, lineNumber, Core::Id (Constants::TEST_MARK_ID)), 13 | index_ (index), pane_ (pane) { 14 | setVisible (true); 15 | setIcon (Utils::Icons::CRITICAL.icon ()); 16 | setPriority (TextEditor::TextMark::LowPriority); 17 | } 18 | 19 | bool TestMark::isClickable () const { 20 | return true; 21 | } 22 | 23 | void TestMark::clicked () { 24 | pane_.popup (OutputPane::NoModeSwitch); 25 | pane_.setCurrentIndex (index_); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/PaneWidget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | PaneWidget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 20 | QAbstractItemView::NoEditTriggers 21 | 22 | 23 | true 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /util/win/prepare.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | set SELF_PATH=%~dp0 4 | call %SELF_PATH%\env.bat 5 | 6 | 7 | mkdir qtcreator-latest 8 | mklink /D qtcreator-latest\Qt %QT_DIR% 9 | if "%VERSION%"=="" set VERSION=debug 10 | echo %VERSION%>qtcreator-latest\version 11 | if %errorlevel% neq 0 exit /b %errorlevel% 12 | 13 | 14 | if exist qtcreator-latest/src goto build 15 | 16 | mkdir download 17 | if not exist download/src.zip curl -fsSLk -o download\src.zip http://download.qt.io/official_releases/qtcreator/4.6/4.6.0/qt-creator-opensource-src-4.6.0.zip 18 | unzip -qq download\src.zip -d qtcreator-latest 19 | move qtcreator-latest\qt-creator* qtcreator-latest\src 20 | if %errorlevel% neq 0 exit /b %errorlevel% 21 | 22 | 23 | :build 24 | 25 | if exist qtcreator-latest\compiled\bin\qtcreator.exe goto end 26 | 27 | mkdir qtcreator-latest\compiled 28 | cd qtcreator-latest\compiled 29 | qmake QMAKE_CXXFLAGS+=/MP ..\src 30 | nmake /S 31 | if %errorlevel% neq 0 exit /b %errorlevel% 32 | rd /Q /S src 33 | cd ..\.. 34 | 35 | :end 36 | -------------------------------------------------------------------------------- /util/win/build.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | set SELF_PATH=%~dp0 4 | call %SELF_PATH%\env.bat 5 | 6 | set QTC_SOURCE=%cd%\qtcreator-latest\src 7 | set QTC_BUILD=%cd%\qtcreator-latest\compiled 8 | 9 | rmdir /s /q build 10 | mkdir build 11 | 12 | cd build 13 | lrelease %SELF_PATH%\..\..\qtc-gtest.pro 14 | qmake %SELF_PATH%\..\.. 15 | nmake 16 | if %errorlevel% neq 0 exit /b %errorlevel% 17 | cd .. 18 | 19 | 20 | set /p VERSION= 7 | 8 | #include 9 | 10 | namespace QtcGtest { 11 | namespace Internal { 12 | 13 | class TestProject; 14 | 15 | /*! 16 | * \brief main plugin class. 17 | */ 18 | class QtcGtestPlugin : public ExtensionSystem::IPlugin { 19 | Q_OBJECT 20 | Q_PLUGIN_METADATA (IID "org.qt-project.Qt.QtCreatorPlugin" FILE "QtcGtest.json") 21 | 22 | public: 23 | QtcGtestPlugin (); 24 | ~QtcGtestPlugin (); 25 | 26 | bool initialize (const QStringList &arguments, QString *errorString); 27 | void extensionsInitialized (); 28 | ShutdownFlag aboutToShutdown (); 29 | 30 | private: 31 | void initLanguage (); 32 | void initMenus (); 33 | 34 | private: 35 | TestProject *testProject_; 36 | QAction *checkProjectAction; 37 | QAction *checkCurrentAction; 38 | QAction *checkChangedAction; 39 | }; 40 | 41 | } // namespace Internal 42 | } // namespace QtcGtest 43 | 44 | #endif // QTCGTEST_H 45 | 46 | -------------------------------------------------------------------------------- /util/osx/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | SELF_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 6 | 7 | export PATH="$PWD/qtcreator-latest/Qt/bin/:$PATH" 8 | ROOT="$SELF_PATH/../.." 9 | echo `clang --version` 10 | echo `qmake --version` 11 | 12 | 13 | export QTC_SOURCE="$PWD/qtcreator-latest/src" 14 | export QTC_BUILD="$PWD/qtcreator-latest/compiled" 15 | 16 | rm -rf build 17 | mkdir -p build 18 | 19 | cd build 20 | lrelease "$ROOT/qtc-gtest.pro" 21 | qmake "$ROOT/qtc-gtest.pro" 22 | make 23 | cd .. 24 | 25 | 26 | PLUGIN_NAME="QtcGtest" 27 | VERSION=$(cat qtcreator-latest/version) 28 | 29 | if [ ! -f "qtcreator-latest/compiled/Contents/PlugIns/lib$PLUGIN_NAME.dylib" ]; then exit 1; fi 30 | 31 | rm -rf dist 32 | mkdir -p dist/Contents/PlugIns/ 33 | mkdir -p dist/Contents/Resources/translations 34 | cp qtcreator-latest/compiled/Contents/PlugIns/lib$PLUGIN_NAME.dylib dist/Contents/PlugIns/ 35 | ls -l dist/Contents/PlugIns/lib$PLUGIN_NAME.dylib 36 | cp $ROOT/translation/*.qm dist/Contents/Resources/translations 37 | 38 | rm -f $PLUGIN_NAME-$VERSION-osx.tar.gz 39 | cd dist 40 | tar czf ../$PLUGIN_NAME-$VERSION-osx.tar.gz . 41 | cd .. 42 | 43 | ls -l $PLUGIN_NAME-$VERSION-osx.tar.gz 44 | -------------------------------------------------------------------------------- /src/PaneWidget.h: -------------------------------------------------------------------------------- 1 | #ifndef PANEWIDGET_H 2 | #define PANEWIDGET_H 3 | 4 | #include 5 | #include 6 | 7 | namespace Ui { 8 | class PaneWidget; 9 | } 10 | 11 | namespace QtcGtest { 12 | namespace Internal { 13 | class TestModel; 14 | 15 | class PaneWidget : public QWidget { 16 | Q_OBJECT 17 | 18 | public: 19 | explicit PaneWidget (const QSharedPointer &model, QWidget *parent = 0); 20 | ~PaneWidget (); 21 | 22 | public: 23 | QModelIndex currentIndex () const; 24 | void setCurrentIndex (const QModelIndex &index); 25 | QModelIndex testModelIndex (const QModelIndex &proxyIndex) const; 26 | QModelIndex proxyIndex (const QModelIndex &testModelIndex) const; 27 | 28 | public slots: 29 | void showPassed (bool show); 30 | void spanColumns (); 31 | 32 | signals: 33 | void viewClicked (const QModelIndex &index); 34 | 35 | private: 36 | Ui::PaneWidget *ui; 37 | QSharedPointer model_; 38 | QSortFilterProxyModel *proxy_; 39 | }; 40 | 41 | } // namespace Internal 42 | } // namespace QtcGtest 43 | 44 | #endif // PANEWIDGET_H 45 | -------------------------------------------------------------------------------- /util/osx/prepare.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | SELF_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 6 | 7 | mkdir -p download 8 | mkdir -p qtcreator-latest 9 | if [ -z "$VERSION" ]; then VERSION="debug"; fi 10 | echo "$VERSION" > qtcreator-latest/version 11 | 12 | if [ ! -d "qtcreator-latest/src" ]; then 13 | curl -fsSLk -o download/src.tar.gz http://download.qt.io/official_releases/qtcreator/4.6/4.6.0/qt-creator-opensource-src-4.6.0.tar.gz 14 | tar zxf download/src.tar.gz -C qtcreator-latest 15 | mv qtcreator-latest/qt-creator* qtcreator-latest/src 16 | fi 17 | 18 | if [ ! -d "qtcreator-latest/compiled" ]; then 19 | curl -fsSLk -o download/installer.dmg http://download.qt.io/official_releases/online_installers/qt-unified-mac-x64-online.dmg 20 | hdiutil attach -mountpoint installer download/installer.dmg 21 | ln -s installer/qt-*/Contents/MacOS/qt-* run 22 | ls -l run 23 | sudo QT_QPA_PLATFORM="minimal" ./run --script "$SELF_PATH/qt_install.qs" -v 24 | rm run 25 | hdiutil unmount installer 26 | sudo chmod a+w /opt/qt/Qt\ Creator.app/Contents/PlugIns 27 | ln -s /opt/qt/5.10.1/clang_64 qtcreator-latest/Qt 28 | ln -s /opt/qt/Qt\ Creator.app qtcreator-latest/compiled 29 | fi 30 | 31 | -------------------------------------------------------------------------------- /src/AutoToolTipDelegate.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "AutoToolTipDelegate.h" 6 | 7 | QtcGtest::Internal::AutoToolTipDelegate::AutoToolTipDelegate (QObject *parent) : 8 | QStyledItemDelegate (parent) { 9 | 10 | } 11 | 12 | bool QtcGtest::Internal::AutoToolTipDelegate::helpEvent ( 13 | QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, 14 | const QModelIndex &index) { 15 | if (!event || !view) { 16 | return false; 17 | } 18 | 19 | if (event->type () == QEvent::ToolTip) { 20 | QRect rect = view->visualRect (index); 21 | QSize size = sizeHint (option, index); 22 | if (rect.width () < size.width ()) { 23 | QVariant tooltip = index.data (Qt::DisplayRole); 24 | if (tooltip.canConvert()) { 25 | QToolTip::showText (event->globalPos (), QString (QLatin1String ("
%1
")) 26 | .arg (tooltip.toString ().toHtmlEscaped ()), view); 27 | return true; 28 | } 29 | } 30 | if (!QStyledItemDelegate::helpEvent (event, view, option, index)) { 31 | QToolTip::hideText (); 32 | } 33 | return true; 34 | } 35 | 36 | return QStyledItemDelegate::helpEvent (event, view, option, index); 37 | } 38 | -------------------------------------------------------------------------------- /util/ubuntu/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | SELF_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 6 | 7 | GCC_PATH=/opt/gcc-5/ 8 | export PATH="$GCC_PATH:$PWD/qtcreator-latest/Qt/bin/:$PATH" 9 | ROOT="$SELF_PATH/../.." 10 | echo `g++ --version` 11 | echo `qmake --version` 12 | 13 | export QTC_SOURCE="$PWD/qtcreator-latest/src" 14 | export QTC_BUILD="$PWD/qtcreator-latest/compiled" 15 | 16 | rm -rf build 17 | mkdir -p build 18 | 19 | cd build 20 | lrelease "$ROOT/qtc-gtest.pro" 21 | qmake "$ROOT/qtc-gtest.pro" 22 | make -j`nproc` 23 | cd .. 24 | 25 | 26 | PLUGIN_NAME="QtcGtest" 27 | VERSION=$(cat qtcreator-latest/version) 28 | 29 | if [ ! -f "qtcreator-latest/compiled/lib/qtcreator/plugins/lib$PLUGIN_NAME.so" ]; then exit 1; fi 30 | 31 | rm -rf dist 32 | mkdir -p dist/lib/qtcreator/plugins 33 | mkdir -p dist/share/qtcreator/translations 34 | cp qtcreator-latest/compiled/lib/qtcreator/plugins/lib$PLUGIN_NAME.so dist/lib/qtcreator/plugins 35 | strip dist/lib/qtcreator/plugins/lib$PLUGIN_NAME.so 36 | ls -l dist/lib/qtcreator/plugins/lib$PLUGIN_NAME.so 37 | cp $SELF_PATH/../../translation/*.qm dist/share/qtcreator/translations 38 | 39 | rm -f $PLUGIN_NAME-$VERSION-linux-x64.tar.gz 40 | cd dist 41 | tar czf ../$PLUGIN_NAME-$VERSION-linux-x64.tar.gz . 42 | cd .. 43 | 44 | ls -l $PLUGIN_NAME-$VERSION-linux-x64.tar.gz 45 | -------------------------------------------------------------------------------- /util/ubuntu/prepare.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | SELF_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 6 | 7 | 8 | sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test 9 | sudo apt-get -qq update 10 | sudo apt-get -y -qq install gcc-5 g++-5 wget libfontconfig libgl1-mesa-dev 11 | 12 | GCC_PATH=/opt/gcc-5 13 | sudo mkdir -p $GCC_PATH 14 | sudo ln -sf /usr/bin/g++-5 $GCC_PATH/g++ 15 | sudo ln -sf /usr/bin/gcc-5 $GCC_PATH/gcc 16 | 17 | mkdir -p download 18 | mkdir -p qtcreator-latest 19 | if [ -z "$VERSION" ]; then VERSION="debug"; fi 20 | echo "$VERSION" > qtcreator-latest/version 21 | 22 | if [ ! -d "qtcreator-latest/src" ]; then 23 | wget -cq http://download.qt.io/official_releases/qtcreator/4.6/4.6.0/qt-creator-opensource-src-4.6.0.tar.gz -O download/src.tar.gz 24 | tar axf download/src.tar.gz -C qtcreator-latest 25 | mv qtcreator-latest/qt-creator* qtcreator-latest/src 26 | fi 27 | 28 | if [ ! -d "qtcreator-latest/compiled" ]; then 29 | wget -cq http://download.qt.io/official_releases/online_installers/qt-unified-linux-x64-online.run -O download/installer.run 30 | chmod +x download/installer.run 31 | sudo QT_QPA_PLATFORM="minimal" download/installer.run --script "$SELF_PATH/qt_install.qs" -v 32 | sudo chmod a+w /opt/qt/Tools/QtCreator/lib/qtcreator/plugins 33 | ln -s /opt/qt/5.10.1/gcc_64 qtcreator-latest/Qt 34 | ln -s /opt/qt/Tools/QtCreator qtcreator-latest/compiled 35 | fi 36 | 37 | -------------------------------------------------------------------------------- /util/README.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## v 4.4.0 4 | - QTC version update 5 | 6 | ## v 4.3.0 7 | - Some bugfixes 8 | 9 | ## v 4.2.0 10 | - QTC version update 11 | 12 | ## v 4.1.0 13 | * Correctly clear marks. 14 | * Check buttons added to pane. 15 | * Popup pane when click on mark. 16 | 17 | 18 | ## v 4.0.0 19 | * Updated failed file finding algorithm. 20 | * Added marks. 21 | * Some Q_ASSERTs changed to QTC_ASSERTs. 22 | 23 | 24 | ## v 3.6.0 25 | - QTC version update 26 | ## v 3.5.0_1 27 | - Fixed possible freeze. 28 | ## v 3.5.0 29 | - QTC version update 30 | - Fixed wrong dynamic libraries search paths 31 | - Fixed subdirs projects parse errors 32 | - Default keybindings changed 33 | ## v 3.4.0 34 | - QTC version update 35 | - Now capture single disabled test 36 | ## v 3.3.1 37 | - Fixed wrong handling of parameterized tests failure. 38 | - Improved msvc support. 39 | - Fixed possible crash at qt creator termination. 40 | ## v 3.3.0_1 41 | - Fixed prev/next error selection in pane. 42 | - Added ability to filter out successful tests. 43 | - Added margin to label. 44 | - Added ability to disable auto popup of the pane. 45 | - Added parsing and visualization of gtest_filter run argument. 46 | - Added parsing and visualization of disabled tests. 47 | - Added support of parameterized tests. 48 | - Fixed possible crash when "cout" messages without endl. 49 | - Fixed possible crash. 50 | ## v 3.3.0 51 | - QTC version update 52 | - QBS projects support improved 53 | ## v 3.2.1 54 | QTC version update 55 | ## v 3.2.0 56 | QTC version update 57 | ## v 3.1.0_1 58 | - Run tests from current project 59 | - Run tests that depends on current file 60 | - Run tests that depends on changed files 61 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Qt Creator Google Test Integration 2 | 3 | ## Introduction 4 | Plugin integrates some [Google Test](https://code.google.com/p/googletest/ "Google T") functionality into Qt Creator IDE. 5 | 6 | ![Screen](util/screen.png?raw=true) 7 | 8 | ## Features 9 | * Parse test runner's output and show tests' results in pane 10 | * Launches tests from active project 11 | * Translation support 12 | 13 | ## Usage 14 | ### Parsing tests output 15 | 1. Write google test application. 16 | 2. Uncheck `launch in terminal` option in project's run configuration. 17 | 3. Run application. Testing results will be represented in `Google Test` pane. 18 | 19 | ### Running tests 20 | 1. Write google test application. 21 | 2. In `Tools->Google Test` menu select appropriate entry. 22 | 3. Depending on chosen menu entry, plugin will generate run arguments for active project and launch it. 23 | 24 | >Note: Tests from changed files or current file will be run only if they belong to active project. 25 | 26 | ## Downloads 27 | Built plugin can be downloaded [here](https://sourceforge.net/projects/qtc-gtest/files/bin/ "Sourceforge") 28 | or from github releases. 29 | 30 | 31 | ## Installation 32 | IMPORTANT: plugin's version must match Qt Creator's version (difference in last digit is acceptable) 33 | 34 | ### From source 35 | 1. Change paths.pri: 36 | 37 | - set `QTCREATOR_SOURCES` = path to Qt Creator source dir (with qtcreator.pro) 38 | - set `IDE_BUILD_TREE` = path to compiled Qt Creator dir (with bin,lib,libexec,...) 39 | 40 | 2. Compile plugin. 41 | 42 | ### From binaries 43 | 1. Extract/copy files from archive into Qt Creator's dir (archive already contains proper paths). 44 | 2. Enable plugin in Help->Modules menu. 45 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | 3 | dist: trusty 4 | sudo: required 5 | 6 | git: 7 | depth: 10 8 | 9 | env: 10 | - VERSION="$TRAVIS_TAG" 11 | 12 | matrix: 13 | include: 14 | - os: osx 15 | osx_image: xcode7.3 16 | - os: linux 17 | dist: trusty 18 | 19 | install: 20 | - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then chmod +x ./util/osx/prepare.sh & ./util/osx/prepare.sh; fi 21 | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then chmod +x ./util/ubuntu/prepare.sh & sudo ./util/ubuntu/prepare.sh; fi 22 | 23 | script: 24 | - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then chmod +x ./util/osx/build.sh & ./util/osx/build.sh ; fi 25 | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then chmod +x ./util/ubuntu/build.sh & ./util/ubuntu/build.sh; fi 26 | 27 | deploy: 28 | - provider: releases 29 | api_key: 30 | secure: "O/E7evsNZtq3V1HNk2u+RwoEAKk7ukSFMEyhHxQbzoRZ3skrvYrIBtQMw1N/qqPKftUgtLlo214HmAnh8DzeqTDHx3M5NlXnBmDjm/d14lLX1Vemd3pKJIFY47Ml2HKieWh9oCksDrpxnY9Zkm1GMqZN8EaOUnvgkVUiORDqCD4D0i4inwdflVicBdFlrGK81Cu552InY7fFg2Ss2/8mpuKWCb1NIE/CReJjWXQogvHRP3nGB+mrlmHyognjHpavmcalnCLiiX7cEqOcR0Hdw7EGLN9alHONGlxES9qEV5Ydk0+T8Ccvp1MgWa406+oDQ949U+X8Vc4ZCyK9GLZ98/QVElJf7rH9YTt4Kso3Y0752v2a3Un+O+wlA9cEDbpwj5OpeEUKXBgy9tDYiLc8n1nL0xdFHsEJS1qTQcD3ZLlNnye+yYftCYRLKV5SPNqwUPYgE/YYpU5fZeuzDfiXc3H/fhmjV1CpVOdc9CVWgRLxtdmWfQi1VvPbTCThWnfQ6bfbfRaVkxihiRsWGhRe0yHVqOUzzkGkd4lhYa1zsn5RpF6yEfxQvnE/yAI2wvo3JaYIoVqTAkV1Tl9dZdfsmEh+MFgB1LZmEGWqaB0wY7vBY9SeDF3eqgAaIS5Hj1ArzFHVSa6rK/Klv89d3P+HvIq7FmQYRUM3YyIesubdVZY=" 31 | file_glob: true 32 | file: "QtcGtest-*.tar.gz" 33 | skip_cleanup: true 34 | on: 35 | tags: true 36 | 37 | notifications: 38 | email: 39 | on_success: change 40 | on_failure: change 41 | -------------------------------------------------------------------------------- /qtc-gtest.pro: -------------------------------------------------------------------------------- 1 | DEFINES += QTCGTEST_LIBRARY 2 | 3 | VERSION_SUFFIX = "" 4 | 5 | include(paths.pri) 6 | 7 | # QtcGtest files 8 | 9 | SOURCES += \ 10 | src/QtcGtestPlugin.cpp \ 11 | src/PaneWidget.cpp \ 12 | src/OutputParser.cpp \ 13 | src/TestModel.cpp \ 14 | src/OutputPane.cpp \ 15 | src/ParseState.cpp \ 16 | src/TestProject.cpp \ 17 | src/AutoToolTipDelegate.cpp \ 18 | src/TestMark.cpp 19 | 20 | HEADERS += \ 21 | src/Constants.h \ 22 | src/PluginGlobal.h \ 23 | src/QtcGtestPlugin.h \ 24 | src/PaneWidget.h \ 25 | src/OutputParser.h \ 26 | src/TestModel.h \ 27 | src/OutputPane.h \ 28 | src/ParseState.h \ 29 | src/TestProject.h \ 30 | src/AutoToolTipDelegate.h \ 31 | src/TestMark.h 32 | 33 | FORMS += \ 34 | src/PaneWidget.ui 35 | 36 | RESOURCES += \ 37 | resources.qrc 38 | 39 | TRANSLATIONS += \ 40 | translation/QtcGtest_ru.ts 41 | 42 | OTHER_FILES += \ 43 | LICENSE.md \ 44 | README.md \ 45 | images/README.md \ 46 | util/README.md \ 47 | uncrustify.cfg 48 | 49 | PROVIDER = Gres 50 | 51 | ###### If the plugin can be depended upon by other plugins, this code needs to be outsourced to 52 | ###### _dependencies.pri, where is the name of the directory containing the 53 | ###### plugin's sources. 54 | 55 | QTC_PLUGIN_NAME = QtcGtest 56 | QTC_LIB_DEPENDS += \ 57 | cplusplus 58 | 59 | QTC_PLUGIN_DEPENDS += \ 60 | coreplugin\ 61 | projectexplorer\ 62 | cpptools 63 | 64 | QTC_PLUGIN_RECOMMENDS += \ 65 | # optional plugin dependencies. nothing here at this time 66 | 67 | ###### End _dependencies.pri contents ###### 68 | 69 | include($$QTCREATOR_SOURCES/src/qtcreatorplugin.pri) 70 | -------------------------------------------------------------------------------- /util/osx/qt_install.qs: -------------------------------------------------------------------------------- 1 | function Controller() { 2 | installer.autoRejectMessageBoxes(); 3 | installer.installationFinished.connect(function() { 4 | gui.clickButton(buttons.NextButton); 5 | }); 6 | } 7 | 8 | Controller.prototype.WelcomePageCallback = function() { 9 | gui.clickButton(buttons.NextButton, 2000); 10 | } 11 | 12 | Controller.prototype.CredentialsPageCallback = function() { 13 | gui.clickButton(buttons.NextButton); 14 | } 15 | 16 | Controller.prototype.IntroductionPageCallback = function() { 17 | gui.clickButton(buttons.NextButton); 18 | } 19 | 20 | Controller.prototype.TargetDirectoryPageCallback = function() { 21 | gui.currentPageWidget().TargetDirectoryLineEdit.setText('/opt/qt'); 22 | gui.clickButton(buttons.NextButton); 23 | } 24 | 25 | Controller.prototype.ComponentSelectionPageCallback = function() { 26 | var widget = gui.currentPageWidget(); 27 | widget.deselectAll(); 28 | widget.selectComponent('qt.qt5.5101.clang_64'); 29 | gui.clickButton(buttons.NextButton); 30 | } 31 | 32 | Controller.prototype.LicenseAgreementPageCallback = function() { 33 | gui.currentPageWidget().AcceptLicenseRadioButton.setChecked(true); 34 | gui.clickButton(buttons.NextButton); 35 | } 36 | 37 | Controller.prototype.StartMenuDirectoryPageCallback = function() { 38 | gui.clickButton(buttons.NextButton); 39 | } 40 | 41 | Controller.prototype.ReadyForInstallationPageCallback = function() { 42 | gui.clickButton(buttons.NextButton); 43 | } 44 | 45 | Controller.prototype.FinishedPageCallback = function() { 46 | var checkBoxForm = gui.currentPageWidget().LaunchQtCreatorCheckBoxForm; 47 | if (checkBoxForm && checkBoxForm.launchQtCreatorCheckBox) { 48 | checkBoxForm.launchQtCreatorCheckBox.checked = false; 49 | } 50 | gui.clickButton(buttons.FinishButton); 51 | } 52 | 53 | -------------------------------------------------------------------------------- /util/ubuntu/qt_install.qs: -------------------------------------------------------------------------------- 1 | function Controller() { 2 | installer.autoRejectMessageBoxes(); 3 | installer.installationFinished.connect(function() { 4 | gui.clickButton(buttons.NextButton); 5 | }); 6 | } 7 | 8 | Controller.prototype.WelcomePageCallback = function() { 9 | gui.clickButton(buttons.NextButton, 2000); 10 | } 11 | 12 | Controller.prototype.CredentialsPageCallback = function() { 13 | gui.clickButton(buttons.NextButton); 14 | } 15 | 16 | Controller.prototype.IntroductionPageCallback = function() { 17 | gui.clickButton(buttons.NextButton); 18 | } 19 | 20 | Controller.prototype.TargetDirectoryPageCallback = function() { 21 | gui.currentPageWidget().TargetDirectoryLineEdit.setText('/opt/qt'); 22 | gui.clickButton(buttons.NextButton); 23 | } 24 | 25 | Controller.prototype.ComponentSelectionPageCallback = function() { 26 | var widget = gui.currentPageWidget(); 27 | widget.deselectAll(); 28 | widget.selectComponent('qt.qt5.5101.gcc_64'); 29 | gui.clickButton(buttons.NextButton); 30 | } 31 | 32 | Controller.prototype.LicenseAgreementPageCallback = function() { 33 | gui.currentPageWidget().AcceptLicenseRadioButton.setChecked(true); 34 | gui.clickButton(buttons.NextButton); 35 | } 36 | 37 | Controller.prototype.StartMenuDirectoryPageCallback = function() { 38 | gui.clickButton(buttons.NextButton); 39 | } 40 | 41 | Controller.prototype.ReadyForInstallationPageCallback = function() { 42 | gui.clickButton(buttons.NextButton); 43 | } 44 | 45 | Controller.prototype.FinishedPageCallback = function() { 46 | var checkBoxForm = gui.currentPageWidget().LaunchQtCreatorCheckBoxForm; 47 | if (checkBoxForm && checkBoxForm.launchQtCreatorCheckBox) { 48 | checkBoxForm.launchQtCreatorCheckBox.checked = false; 49 | } 50 | gui.clickButton(buttons.FinishButton); 51 | } 52 | 53 | -------------------------------------------------------------------------------- /src/TestProject.h: -------------------------------------------------------------------------------- 1 | #ifndef TESTPROJECT_H 2 | #define TESTPROJECT_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | namespace ProjectExplorer { 11 | class Project; 12 | class RunConfiguration; 13 | class RunControl; 14 | } 15 | 16 | namespace QtcGtest { 17 | namespace Internal { 18 | 19 | using ProjectExplorer::RunConfiguration; 20 | 21 | class TestProject : public QObject { 22 | Q_OBJECT 23 | 24 | public: 25 | explicit TestProject (QObject *parent = 0); 26 | 27 | public slots: 28 | 29 | void checkProject (); 30 | void checkChanged (); 31 | void checkCurrent (); 32 | 33 | void handleDocumentsChange (const QModelIndex &topLeft, const QModelIndex &bottomRight, 34 | const QVector &roles); 35 | void handleDocumentsClose (const QModelIndex &parent, int start, int end); 36 | 37 | signals: 38 | void runControlAboutToStart (ProjectExplorer::RunControl *control); 39 | 40 | private: 41 | Utils::FileNameList getChangedFiles (int beginRow, int endRow, bool modifiedFlag) const; 42 | void runTestsForFiles (const Utils::FileNameList &files, RunConfiguration *configuration); 43 | RunConfiguration *parse (ProjectExplorer::Project *project); 44 | Utils::FileNameList gtestMainIncludes () const; 45 | void preprocessDependencyTable (); 46 | void runTests (RunConfiguration *configuration); 47 | QStringList getTestCases (const QSet &fileNames) const; 48 | Utils::FileNameList getDependentFiles (const Utils::FileNameList &files) const; 49 | 50 | private: 51 | Utils::FileNameList changedFiles_; 52 | Utils::FileNameList gtestIncludeFiles_; 53 | QHash dependencyTable_; 54 | QHash testFilterPatterns_; 55 | }; 56 | 57 | } // namespace Internal 58 | } // namespace QtcGtest 59 | 60 | #endif // TESTPROJECT_H 61 | -------------------------------------------------------------------------------- /src/PaneWidget.cpp: -------------------------------------------------------------------------------- 1 | #include "PaneWidget.h" 2 | #include "ui_PaneWidget.h" 3 | #include "TestModel.h" 4 | #include "AutoToolTipDelegate.h" 5 | 6 | using namespace QtcGtest::Internal; 7 | 8 | PaneWidget::PaneWidget (const QSharedPointer &model, QWidget *parent) : 9 | QWidget (parent), 10 | ui (new Ui::PaneWidget), 11 | model_ (model), 12 | proxy_ (new QSortFilterProxyModel (this)) { 13 | ui->setupUi (this); 14 | 15 | proxy_->setSourceModel (model.data ()); 16 | proxy_->setFilterKeyColumn (TestModel::ColumnFailed); 17 | 18 | connect (ui->caseView, SIGNAL (clicked (const QModelIndex&)), 19 | this, SIGNAL (viewClicked (const QModelIndex&))); 20 | 21 | ui->caseView->setModel (proxy_); 22 | ui->caseView->hideColumn (TestModel::ColumnType); 23 | ui->caseView->header ()->setSectionResizeMode (QHeaderView::ResizeToContents); 24 | ui->caseView->setItemDelegate (new AutoToolTipDelegate (ui->caseView)); 25 | } 26 | 27 | PaneWidget::~PaneWidget () { 28 | delete ui; 29 | } 30 | 31 | QModelIndex PaneWidget::currentIndex () const { 32 | return ui->caseView->currentIndex (); 33 | } 34 | 35 | void PaneWidget::setCurrentIndex (const QModelIndex &index) { 36 | ui->caseView->setCurrentIndex (index); 37 | } 38 | 39 | QModelIndex PaneWidget::testModelIndex (const QModelIndex &proxyIndex) const { 40 | return proxy_->mapToSource (proxyIndex); 41 | } 42 | 43 | QModelIndex PaneWidget::proxyIndex (const QModelIndex &testModelIndex) const { 44 | return proxy_->mapFromSource (testModelIndex); 45 | } 46 | 47 | void PaneWidget::showPassed (bool show) { 48 | // Filter out 0 and empty ColumnFailed 49 | QString pattern = (show) ? QString () : QString (QLatin1String ("-?[1-9]\\d*")); 50 | proxy_->setFilterRegExp (pattern); 51 | spanColumns (); 52 | } 53 | 54 | void PaneWidget::spanColumns () { 55 | for (int i = 0, end = proxy_->rowCount (); i < end; ++i) { 56 | QModelIndex typeIndex = proxy_->index (i, TestModel::ColumnType); 57 | TestModel::Type caseType = TestModel::Type (typeIndex.data ().toInt ()); 58 | if (caseType == TestModel::TypeNote) { 59 | ui->caseView->setFirstColumnSpanned (i, QModelIndex (), true); 60 | continue; 61 | } 62 | QModelIndex caseIndex = proxy_->index (i, TestModel::ColumnName); 63 | for (int ii = 0, iiEnd = proxy_->rowCount (caseIndex); ii < iiEnd; ++ii) { 64 | QModelIndex testIndex = proxy_->index (ii, TestModel::ColumnName, caseIndex); 65 | for (int iii = 0, iiiEnd = proxy_->rowCount (testIndex); iii < iiiEnd; ++iii) { 66 | ui->caseView->setFirstColumnSpanned (iii, testIndex, true); 67 | } 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/TestModel.h: -------------------------------------------------------------------------------- 1 | #ifndef TESTMODEL_H 2 | #define TESTMODEL_H 3 | 4 | #include 5 | 6 | namespace QtcGtest { 7 | namespace Internal { 8 | 9 | /*! 10 | * \brief Model representing results of tests run. 11 | */ 12 | class TestModel : public QStandardItemModel { 13 | Q_OBJECT 14 | 15 | public: 16 | enum Column { 17 | ColumnName = 0, ColumnPassed, ColumnFailed, ColumnTime, ColumnType, 18 | ColumnCount, 19 | ColumnFile = ColumnPassed, // For error. 20 | ColumnLine = ColumnFailed // For error. 21 | }; 22 | enum Type { 23 | TypeCase, TypeTest, TypeDetail, TypeDetailError, TypeNote, TypeUnknown 24 | }; 25 | 26 | public: 27 | explicit TestModel (QObject *parent = 0); 28 | 29 | QModelIndex findItem (const QString &name, const QModelIndex &parent) const; 30 | 31 | QModelIndex caseIndex (const QString &name) const; 32 | QModelIndex testIndex (const QString &name, const QString &caseName) const; 33 | 34 | QModelIndex previousError (const QModelIndex &index) const; 35 | QModelIndex nextError (const QModelIndex &index) const; 36 | 37 | Type getType (const QModelIndex &index) const; 38 | 39 | int errorCount () const; 40 | 41 | QString title () const; 42 | void setTitle (const QString &title); 43 | 44 | void clear (); 45 | 46 | public slots: 47 | void addNote (const QString &text); 48 | void addCase (const QString &name); 49 | void addTest (const QString &name, const QString &caseName); 50 | void addTestDetail (const QString &name, const QString &caseName, const QString &detail); 51 | void addTestError (const QString &name, const QString &caseName, const QString &detail, const QString &file, int line); 52 | 53 | void updateTest (const QString &name, const QString &caseName, bool isOk, int time); 54 | void updateCase (const QString &name, int passedCount, int failedCount, int time); 55 | 56 | void renameTest (const QString &oldName, const QString &newName, const QString &caseName); 57 | 58 | signals: 59 | void newError (const QModelIndex &index); 60 | 61 | private: 62 | QList createRow (const QString &name, Type type) const; 63 | void setRowColor (const QModelIndex &index, const QColor &color); 64 | Type getCurrentRows (const QModelIndex &index, int &caseRow, int &testRow, int &detailRow) const; 65 | 66 | private: 67 | QString title_; 68 | int errorCount_; 69 | QHash columnNames_; 70 | }; 71 | 72 | } // namespace Internal 73 | } // namespace QtcGtest 74 | 75 | #endif // TESTMODEL_H 76 | -------------------------------------------------------------------------------- /src/OutputPane.h: -------------------------------------------------------------------------------- 1 | #ifndef OUTPUTPANE_H 2 | #define OUTPUTPANE_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | namespace ProjectExplorer { 12 | class RunControl; 13 | } 14 | 15 | namespace QtcGtest { 16 | namespace Internal { 17 | 18 | class PaneWidget; 19 | class OutputParser; 20 | class TestModel; 21 | class ParseState; 22 | class TestMark; 23 | 24 | /*! 25 | * \brief Output pane for google test control. 26 | */ 27 | class OutputPane : public Core::IOutputPane { 28 | Q_OBJECT 29 | 30 | public: 31 | explicit OutputPane (QObject *parent = 0); 32 | ~OutputPane (); 33 | 34 | // IOutputPane interface 35 | 36 | public: 37 | QWidget *outputWidget (QWidget *parent); 38 | QList toolBarWidgets () const; 39 | QString displayName () const; 40 | int priorityInStatusBar () const; 41 | void clearContents (); 42 | void visibilityChanged (bool visible); 43 | void setFocus (); 44 | bool hasFocus () const; 45 | bool canFocus () const; 46 | bool canNavigate () const; 47 | bool canNext () const; 48 | bool canPrevious () const; 49 | void goToNext (); 50 | void goToPrev (); 51 | void setCurrentIndex (const QModelIndex &index); 52 | 53 | public: 54 | void setCheckActions (QAction *checkProject, QAction *checkCurrent, QAction *checkChanged); 55 | 56 | public slots: 57 | void handleRunStart (ProjectExplorer::RunControl *control); 58 | void handleRunFinish (ProjectExplorer::RunControl *control); 59 | 60 | private slots: 61 | void parseMessage (ProjectExplorer::RunControl *control, 62 | const QString &msg, Utils::OutputFormat format); 63 | void handleViewClicked (const QModelIndex &index); 64 | void addMark (const QModelIndex &index); 65 | 66 | private: 67 | void showError (const QModelIndex &errorIndex); 68 | 69 | private: 70 | OutputParser *parser_; 71 | QSharedPointer model_; 72 | ParseState *state_; 73 | QList marks; 74 | 75 | // output widget 76 | QPointer widget_; 77 | 78 | // toolBarWidgets 79 | QLabel *totalsLabel_; 80 | QLabel *disabledLabel_; 81 | QToolButton *togglePopupButton_; 82 | QToolButton *togglePassedButton_; 83 | QToolButton *cmdCheckProject_; 84 | QToolButton *cmdCheckCurrent_; 85 | QToolButton *cmdCheckChanged_; 86 | }; 87 | 88 | } // namespace Internal 89 | } // namespace QtcGtest 90 | 91 | #endif // OUTPUTPANE_H 92 | -------------------------------------------------------------------------------- /translation/QtcGtest_ru.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PaneWidget 6 | 7 | 8 | Form 9 | Форма 10 | 11 | 12 | 13 | QtcGtest::Internal::OutputPane 14 | 15 | 16 | Auto popup pane 17 | Авто показ панели 18 | 19 | 20 | 21 | Show passed tests 22 | Показывать успешные тесты 23 | 24 | 25 | 26 | Google Test 27 | Google Test 28 | 29 | 30 | 31 | Total: passed %1 of %2 (%3 ms). 32 | Всего: пройдено %1 из %2 (%3 мсек.). 33 | 34 | 35 | 36 | Disabled tests: %1. 37 | Отключенных тестов: %1. 38 | 39 | 40 | Total: passed %1 of %2 (%3 ms) 41 | Всего: пройдено %1 из %2 (%3 мсек.) 42 | 43 | 44 | 45 | QtcGtest::Internal::QtcGtestPlugin 46 | 47 | 48 | Check project 49 | Проверить проект 50 | 51 | 52 | 53 | Ctrl+Alt+T,A 54 | Ctrl+Alt+T,A 55 | 56 | 57 | 58 | Ctrl+Alt+T,C 59 | Ctrl+Alt+T,C 60 | 61 | 62 | 63 | Ctrl+Alt+T,T 64 | Ctrl+Alt+T,T 65 | 66 | 67 | Alt+T,Alt+A 68 | Alt+T,Alt+A 69 | 70 | 71 | 72 | Check current 73 | Проверить текущий документ 74 | 75 | 76 | Alt+T,Alt+C 77 | Alt+T,Alt+C 78 | 79 | 80 | 81 | Check changed 82 | Проверить изменившиеся файлы 83 | 84 | 85 | Alt+T,Alt+T 86 | Alt+T,Alt+T 87 | 88 | 89 | 90 | Google Test 91 | Google Test 92 | 93 | 94 | 95 | QtcGtest::Internal::TestModel 96 | 97 | 98 | 99 | Name 100 | Название 101 | 102 | 103 | 104 | 105 | Passed 106 | Пройдено 107 | 108 | 109 | 110 | 111 | Failed 112 | Провалено 113 | 114 | 115 | 116 | 117 | Time 118 | Время 119 | 120 | 121 | 122 | 123 | Type 124 | Тип 125 | 126 | 127 | 128 | -------------------------------------------------------------------------------- /src/QtcGtestPlugin.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include 15 | 16 | #include "QtcGtestPlugin.h" 17 | #include "Constants.h" 18 | #include "OutputPane.h" 19 | #include "TestProject.h" 20 | 21 | using namespace QtcGtest::Internal; 22 | 23 | using namespace Core; 24 | using namespace ProjectExplorer; 25 | 26 | QtcGtestPlugin::QtcGtestPlugin () : 27 | IPlugin (), 28 | testProject_ (new TestProject (this)) { 29 | // Create your members 30 | } 31 | 32 | QtcGtestPlugin::~QtcGtestPlugin () { 33 | // Unregister objects from the plugin manager's object pool 34 | // Delete members 35 | } 36 | 37 | bool QtcGtestPlugin::initialize (const QStringList &arguments, QString *errorString) { 38 | // Register objects in the plugin manager's object pool 39 | // Load settings 40 | // Add actions to menus 41 | // Connect to other plugins' signals 42 | // In the initialize function, a plugin can be sure that the plugins it 43 | // depends on have initialized their members. 44 | 45 | Q_UNUSED (arguments) 46 | Q_UNUSED (errorString) 47 | 48 | initLanguage (); 49 | initMenus (); 50 | 51 | OutputPane *pane = new OutputPane; 52 | pane->setCheckActions (checkProjectAction, checkCurrentAction, checkChangedAction); 53 | connect (testProject_,&TestProject::runControlAboutToStart, 54 | pane, &OutputPane::handleRunStart); 55 | addAutoReleasedObject (pane); 56 | 57 | 58 | connect (DocumentModel::model (), 59 | SIGNAL (dataChanged (const QModelIndex&,const QModelIndex&,const QVector &)), 60 | testProject_, 61 | SLOT (handleDocumentsChange (const QModelIndex&,const QModelIndex&,const QVector &))); 62 | connect (DocumentModel::model (), 63 | SIGNAL (rowsAboutToBeRemoved (const QModelIndex&,int,int)), 64 | testProject_, 65 | SLOT (handleDocumentsClose (const QModelIndex&,int,int))); 66 | 67 | return true; 68 | } 69 | 70 | void QtcGtestPlugin::initLanguage () { 71 | const QString &language = Core::ICore::userInterfaceLanguage (); 72 | if (!language.isEmpty ()) { 73 | QStringList paths; 74 | paths << ICore::resourcePath () << ICore::userResourcePath (); 75 | const QString &trFile = QLatin1String ("QtcGtest_") + language; 76 | QTranslator *translator = new QTranslator (this); 77 | foreach (const QString &path, paths) { 78 | if (translator->load (trFile, path + QLatin1String ("/translations"))) { 79 | qApp->installTranslator (translator); 80 | break; 81 | } 82 | } 83 | } 84 | } 85 | 86 | void QtcGtestPlugin::initMenus () { 87 | checkProjectAction = new QAction (tr ("Check project"), this); 88 | Core::Command *checkProjectCmd = ActionManager::registerAction ( 89 | checkProjectAction, Constants::ACTION_CHECK_PROJECT_ID, 90 | Context (Core::Constants::C_GLOBAL)); 91 | checkProjectCmd->setDefaultKeySequence (QKeySequence (tr ("Ctrl+Alt+T,A"))); 92 | connect (checkProjectAction, SIGNAL (triggered ()), testProject_, SLOT (checkProject ())); 93 | 94 | checkCurrentAction = new QAction (tr ("Check current"), this); 95 | Core::Command *checkCurrentCmd = ActionManager::registerAction ( 96 | checkCurrentAction, Constants::ACTION_CHECK_CURRENT_ID, 97 | Context (Core::Constants::C_GLOBAL)); 98 | checkCurrentCmd->setDefaultKeySequence (QKeySequence (tr ("Ctrl+Alt+T,C"))); 99 | connect (checkCurrentAction, SIGNAL (triggered ()), testProject_, SLOT (checkCurrent ())); 100 | 101 | checkChangedAction = new QAction (tr ("Check changed"), this); 102 | Core::Command *checkChangedCmd = ActionManager::registerAction ( 103 | checkChangedAction, Constants::ACTION_CHECK_CHANGED_ID, 104 | Context (Core::Constants::C_GLOBAL)); 105 | checkChangedCmd->setDefaultKeySequence (QKeySequence (tr ("Ctrl+Alt+T,T"))); 106 | connect (checkChangedAction, SIGNAL (triggered ()), testProject_, SLOT (checkChanged ())); 107 | 108 | ActionContainer *menu = ActionManager::createMenu (Constants::MENU_ID); 109 | menu->menu ()->setTitle (tr ("Google Test")); 110 | menu->addAction (checkProjectCmd); 111 | menu->addAction (checkCurrentCmd); 112 | menu->addAction (checkChangedCmd); 113 | ActionManager::actionContainer (Core::Constants::M_TOOLS)->addMenu (menu); 114 | } 115 | 116 | void QtcGtestPlugin::extensionsInitialized () { 117 | // Retrieve objects from the plugin manager's object pool 118 | // In the extensionsInitialized function, a plugin can be sure that all 119 | // plugins that depend on it are completely initialized. 120 | } 121 | 122 | ExtensionSystem::IPlugin::ShutdownFlag QtcGtestPlugin::aboutToShutdown () { 123 | // Save settings 124 | // Disconnect from signals that are not needed during shutdown 125 | // Hide UI (if you add UI that is not in the main window directly) 126 | return SynchronousShutdown; 127 | } 128 | -------------------------------------------------------------------------------- /src/OutputParser.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | 7 | #include "OutputParser.h" 8 | #include "ParseState.h" 9 | #include "TestModel.h" 10 | 11 | using namespace QtcGtest::Internal; 12 | namespace { 13 | const QRegularExpression gtestStartPattern ( 14 | QLatin1String ("^(.*)\\[==========\\] Running \\d+ tests? from \\d+ test cases?\\.\\s*$")); 15 | enum GtestStart {GtestStartUnrelated = 1}; 16 | const QRegularExpression gtestEndPattern ( 17 | QLatin1String ("^(.*)\\[==========\\] (\\d+) tests? from (\\d+) test cases? ran. \\((\\d+) ms total\\)\\s*$")); 18 | enum GtestEnd {GtestEndUnrelated = 1, GtestEndTestsRun, GtestEndCasesRun, GtestEndTimeSpent}; 19 | const QRegularExpression gtestDisabledPattern ( 20 | QLatin1String ("^\\s*YOU HAVE (\\d+) DISABLED TESTS?\\s*$")); 21 | enum GtestDisabled {GtestDisabledCount = 1}; 22 | const QRegularExpression gtestFilterPattern ( 23 | QLatin1String ("^\\s*Note: (Google Test filter = .*)\\s*$")); 24 | enum GtestFilter {GtestFilterLine = 1}; 25 | 26 | const QRegularExpression newCasePattern ( 27 | QLatin1String ("^(.*)\\[\\-{10}\\] \\d+ tests? from ([\\w/]+)(, where TypeParam = (.+))?\\s*$")); 28 | enum NewCase {NewCaseUnrelated = 1, NewCaseName, NewCaseFullParameter, NewCaseParameterType}; 29 | const QRegularExpression endCasePattern ( 30 | QLatin1String ("^(.*)\\[\\-{10}\\] \\d+ tests? from ([\\w/]+) \\((\\d+) ms total\\)\\s*$")); 31 | enum EndCase {EndCaseUnrelated = 1, EndCaseName, EndCaseTimeSpent}; 32 | 33 | const QRegularExpression beginTestPattern ( 34 | QLatin1String ("^(.*)\\[ RUN \\] ([\\w/]+)\\.([\\w/]+)\\s*$")); 35 | enum NewTest {NewTestUnrelated = 1, NewTestCaseName, NewTestName}; 36 | const QRegularExpression failTestPattern ( 37 | QLatin1String ("^(.*)\\[ FAILED \\] ([\\w/]+)\\.([\\w/]+)(, where (GetParam\\(\\)|TypeParam) = (.+))? \\((\\d+) ms\\)\\s*$")); 38 | enum FailTest {FailTestUnrelated = 1, FailTestCaseName, FailTestName, FailTestFullParameter, 39 | FailTestParameterType, FailTestParameterDetail, FailTestTimeSpent}; 40 | const QRegularExpression passTestPattern ( 41 | QLatin1String ("^(.*)\\[ OK \\] ([\\w/]+)\\.([\\w/]+) \\((\\d+) ms\\)\\s*$")); 42 | enum PassTest {PassTestUnrelated = 1, PassTestCaseName, PassTestName, PassTestTimeSpent}; 43 | const QRegularExpression failDetailPattern ( 44 | QLatin1String ("^(.+)[\\(:](\\d+)\\)?: (?:Failure|error).*$")); 45 | enum FailDetail {FailDetailFileName = 1, FailDetailLine}; 46 | } 47 | 48 | OutputParser::OutputParser (QObject *parent) : 49 | QObject (parent) { 50 | } 51 | 52 | bool OutputParser::isGoogleTestRun (const QString &line) const { 53 | QRegularExpressionMatch match = gtestStartPattern.match (line); 54 | QRegularExpressionMatch matchFilter = gtestFilterPattern.match (line); 55 | return (match.hasMatch () || matchFilter.hasMatch ()); 56 | } 57 | 58 | void OutputParser::parseMessage (const QString &line, TestModel &model, ParseState &state) { 59 | QRegularExpressionMatch match; 60 | match = newCasePattern.match (line); 61 | if (match.hasMatch ()) { 62 | state.currentCase = match.captured (NewCaseName); 63 | if (match.lastCapturedIndex () == NewCaseParameterType) { 64 | state.currentCase += QString (QLatin1String (" <%1>")).arg (match.captured (NewCaseParameterType)); 65 | } 66 | state.passedCount = state.failedCount = 0; 67 | model.addCase (state.currentCase); 68 | return; 69 | } 70 | 71 | match = endCasePattern.match (line); 72 | if (match.hasMatch ()) { 73 | int totalTime = match.captured (EndCaseTimeSpent).toInt (); 74 | model.updateCase (state.currentCase, state.passedCount, state.failedCount, totalTime); 75 | state.currentCase.clear (); 76 | state.currentTest.clear (); 77 | return; 78 | } 79 | 80 | match = beginTestPattern.match (line); 81 | if (match.hasMatch ()) { 82 | state.currentTest = match.captured (NewTestName); 83 | model.addTest (state.currentTest, state.currentCase); 84 | return; 85 | } 86 | 87 | match = passTestPattern.match (line); 88 | if (match.hasMatch ()) { 89 | QString unrelated = match.captured (PassTestUnrelated); 90 | if (!unrelated.isEmpty ()) { 91 | model.addTestDetail (state.currentTest, state.currentCase, unrelated); 92 | } 93 | ++state.passedCount; 94 | ++state.passedTotalCount; 95 | int totalTime = match.captured (PassTestTimeSpent).toInt (); 96 | model.updateTest (state.currentTest, state.currentCase, true, totalTime); 97 | state.currentTest.clear (); 98 | return; 99 | } 100 | 101 | match = failTestPattern.match (line); 102 | if (match.hasMatch ()) { 103 | QString unrelated = match.captured (PassTestUnrelated); 104 | if (!unrelated.isEmpty ()) { 105 | model.addTestDetail (state.currentTest, state.currentCase, unrelated); 106 | } 107 | ++state.failedCount; 108 | ++state.failedTotalCount; 109 | int totalTime = match.captured (FailTestTimeSpent).toInt (); 110 | model.updateTest (state.currentTest, state.currentCase, false, totalTime); 111 | QString parameterDetail = match.captured (FailTestParameterDetail); 112 | if (!parameterDetail.isEmpty ()) { 113 | QString newTestName = state.currentTest + QString (QLatin1String (" <%1>")).arg (parameterDetail); 114 | model.renameTest (state.currentTest, newTestName, state.currentCase); 115 | } 116 | state.currentTest.clear (); 117 | return; 118 | } 119 | 120 | match = failDetailPattern.match (line); 121 | if (match.hasMatch ()) { 122 | QString file = QDir::fromNativeSeparators (match.captured (FailDetailFileName)); 123 | QFileInfo info (file); 124 | if (info.exists ()) { 125 | file = info.absoluteFilePath (); 126 | } 127 | else{ 128 | const QString dirUp (QStringLiteral ("../")); 129 | QString searchName = file.contains (dirUp) ? file.mid (file.lastIndexOf (dirUp) + 2) : file; 130 | for (const auto &projectFile: state.projectFiles) { 131 | if (projectFile.endsWith (searchName)) { 132 | file = projectFile.toString (); 133 | break; 134 | } 135 | } 136 | } 137 | 138 | int lineNumber = match.captured (FailDetailLine).toInt (); 139 | model.addTestError (state.currentTest, state.currentCase, line, file, lineNumber); 140 | return; 141 | } 142 | 143 | match = gtestEndPattern.match (line); 144 | if (match.hasMatch ()) { 145 | state.totalTime = match.captured (GtestEndTimeSpent).toInt (); 146 | return; 147 | } 148 | 149 | match = gtestDisabledPattern.match (line); 150 | if (match.hasMatch ()) { 151 | state.disabledCount = match.captured (GtestDisabledCount).toInt (); 152 | return; 153 | } 154 | 155 | match = gtestFilterPattern.match (line); 156 | if (match.hasMatch ()) { 157 | model.addNote (match.captured (GtestFilterLine)); 158 | return; 159 | } 160 | 161 | if (!state.currentTest.isEmpty ()) { 162 | QTC_ASSERT (!state.currentCase.isEmpty (), return ); 163 | model.addTestDetail (state.currentTest, state.currentCase, line); 164 | } 165 | } 166 | -------------------------------------------------------------------------------- /src/OutputPane.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "OutputPane.h" 10 | #include "OutputParser.h" 11 | #include "PaneWidget.h" 12 | #include "TestModel.h" 13 | #include "ParseState.h" 14 | #include "TestMark.h" 15 | 16 | using namespace QtcGtest::Internal; 17 | 18 | OutputPane::OutputPane (QObject *parent) : 19 | IOutputPane (parent), 20 | parser_ (new OutputParser), 21 | model_ (new TestModel), 22 | state_ (new ParseState), 23 | widget_ (NULL), 24 | totalsLabel_ (new QLabel), 25 | disabledLabel_ (new QLabel), 26 | togglePopupButton_ (new QToolButton), 27 | togglePassedButton_ (new QToolButton), 28 | cmdCheckProject_ (new QToolButton), 29 | cmdCheckCurrent_ (new QToolButton), 30 | cmdCheckChanged_ (new QToolButton) { 31 | totalsLabel_->setMargin (5); 32 | 33 | togglePopupButton_->setCheckable (true); 34 | togglePopupButton_->setChecked (true); 35 | togglePopupButton_->setToolTip (tr ("Auto popup pane")); 36 | togglePopupButton_->setIcon (QIcon (QLatin1String (":/images/popup.ico"))); 37 | 38 | togglePassedButton_->setCheckable (true); 39 | togglePassedButton_->setChecked (true); 40 | togglePassedButton_->setToolTip (tr ("Show passed tests")); 41 | togglePassedButton_->setIcon (QIcon (QLatin1String (":/images/passed.ico"))); 42 | 43 | connect (model_.data (), &TestModel::newError, this, &OutputPane::addMark); 44 | } 45 | 46 | OutputPane::~OutputPane () { 47 | delete togglePassedButton_; 48 | delete togglePopupButton_; 49 | delete disabledLabel_; 50 | delete totalsLabel_; 51 | delete parser_; 52 | delete state_; 53 | } 54 | 55 | QWidget *OutputPane::outputWidget (QWidget *parent) { 56 | Q_ASSERT (model_ != NULL); 57 | widget_ = new PaneWidget (model_, parent); // Can be only 1? 58 | connect (widget_.data (), SIGNAL (viewClicked (const QModelIndex&)), 59 | this, SLOT (handleViewClicked (const QModelIndex&))); 60 | connect (togglePassedButton_, SIGNAL (clicked (bool)), 61 | widget_.data (), SLOT (showPassed (bool))); 62 | return widget_.data (); 63 | } 64 | 65 | QList OutputPane::toolBarWidgets () const { 66 | QList widgets; 67 | widgets << cmdCheckProject_ 68 | << cmdCheckCurrent_ 69 | << cmdCheckChanged_ 70 | << togglePopupButton_ 71 | << togglePassedButton_ 72 | << totalsLabel_ 73 | << disabledLabel_; 74 | return widgets; 75 | } 76 | 77 | QString OutputPane::displayName () const { 78 | return tr ("Google Test"); 79 | } 80 | 81 | int OutputPane::priorityInStatusBar () const { 82 | return 10; 83 | } 84 | 85 | void OutputPane::clearContents () { 86 | qDeleteAll (marks); 87 | marks.clear (); 88 | model_->clear (); 89 | totalsLabel_->clear (); 90 | disabledLabel_->clear (); 91 | } 92 | 93 | void OutputPane::visibilityChanged (bool /*visible*/) { 94 | } 95 | 96 | void OutputPane::setFocus () { 97 | if (!widget_.isNull ()) { 98 | widget_->setFocus (); 99 | } 100 | } 101 | 102 | bool OutputPane::hasFocus () const { 103 | if (!widget_.isNull ()) { 104 | return widget_->hasFocus (); 105 | } 106 | return false; 107 | } 108 | 109 | bool OutputPane::canFocus () const { 110 | return (!widget_.isNull ()); 111 | } 112 | 113 | bool OutputPane::canNavigate () const { 114 | return true; 115 | } 116 | 117 | bool OutputPane::canNext () const { 118 | Q_ASSERT (model_ != NULL); 119 | // Do not update value because Creator checks it BEFORE it can actually be updated. 120 | return (model_->errorCount () > 0); 121 | } 122 | 123 | bool OutputPane::canPrevious () const { 124 | Q_ASSERT (model_ != NULL); 125 | // Do not update value because Creator checks it BEFORE it can actually be updated. 126 | return (model_->errorCount () > 0); 127 | } 128 | 129 | void OutputPane::goToNext () { 130 | Q_ASSERT (!widget_.isNull ()); 131 | QModelIndex currentIndex = widget_->testModelIndex (widget_->currentIndex ()); 132 | showError (model_->nextError (currentIndex)); 133 | } 134 | 135 | void OutputPane::goToPrev () { 136 | Q_ASSERT (!widget_.isNull ()); 137 | QModelIndex currentIndex = widget_->testModelIndex (widget_->currentIndex ()); 138 | showError (model_->previousError (currentIndex)); 139 | } 140 | 141 | void OutputPane::setCurrentIndex (const QModelIndex &index) { 142 | widget_->setCurrentIndex (widget_->proxyIndex (index)); 143 | } 144 | 145 | void OutputPane::setCheckActions (QAction *checkProject, QAction *checkCurrent, QAction *checkChanged) { 146 | cmdCheckProject_->setDefaultAction (checkProject); 147 | cmdCheckCurrent_->setDefaultAction (checkCurrent); 148 | cmdCheckChanged_->setDefaultAction (checkChanged); 149 | } 150 | 151 | void OutputPane::showError (const QModelIndex &errorIndex) { 152 | if (!errorIndex.isValid ()) { 153 | return; 154 | } 155 | widget_->setCurrentIndex (widget_->proxyIndex (errorIndex)); 156 | int row = errorIndex.row (); 157 | QString file = errorIndex.sibling (row, TestModel::ColumnFile).data ().toString (); 158 | int line = errorIndex.sibling (row, TestModel::ColumnLine).data ().toInt (); 159 | Core::EditorManager::openEditorAt (file, line); 160 | } 161 | 162 | void OutputPane::handleViewClicked (const QModelIndex &index) { 163 | Q_ASSERT (index.isValid ()); 164 | QModelIndex sourceIndex = widget_->testModelIndex (index); 165 | TestModel::Type type = model_->getType (sourceIndex); 166 | if (type == TestModel::TypeDetailError) { 167 | showError (sourceIndex); 168 | } 169 | else if (type == TestModel::TypeDetail) { 170 | QModelIndex previousError = model_->previousError (sourceIndex); 171 | if (previousError.isValid () && previousError.parent ().row () == sourceIndex.parent ().row ()) { 172 | showError (model_->previousError (sourceIndex)); 173 | } 174 | } 175 | } 176 | 177 | void OutputPane::addMark (const QModelIndex &index) { 178 | auto row = index.row (); 179 | auto file = index.sibling (row, TestModel::ColumnFile).data ().toString (); 180 | auto line = index.sibling (row, TestModel::ColumnLine).data ().toInt (); 181 | marks << new TestMark (QPersistentModelIndex (index), file, line, *this); 182 | } 183 | 184 | void OutputPane::handleRunStart (ProjectExplorer::RunControl *control) { 185 | state_->reset (); 186 | model_->clear (); 187 | totalsLabel_->clear (); 188 | disabledLabel_->clear (); 189 | if (control && control->project ()) { 190 | state_->projectFiles = control->project ()->files (ProjectExplorer::Project::SourceFiles); 191 | } 192 | connect (control, &ProjectExplorer::RunControl::finished, 193 | this, [control, this] {handleRunFinish (control);}); 194 | 195 | connect (control, SIGNAL (appendMessageRequested (ProjectExplorer::RunControl *,const QString&,Utils::OutputFormat)), 196 | this, SLOT (parseMessage (ProjectExplorer::RunControl *,const QString&,Utils::OutputFormat))); 197 | 198 | } 199 | 200 | void OutputPane::handleRunFinish (ProjectExplorer::RunControl *control) { 201 | if (state_->isGoogleTestRun) { 202 | widget_->spanColumns (); 203 | totalsLabel_->setText (tr ("Total: passed %1 of %2 (%3 ms).").arg ( 204 | state_->passedTotalCount).arg ( 205 | state_->passedTotalCount + 206 | state_->failedTotalCount).arg (state_->totalTime)); 207 | disabledLabel_->setText (tr ("Disabled tests: %1.").arg (state_->disabledCount)); 208 | if (togglePopupButton_->isChecked ()) { 209 | popup (WithFocus); 210 | } 211 | } 212 | disconnect (control, SIGNAL (appendMessageRequested (ProjectExplorer::RunControl *,const QString&,Utils::OutputFormat)), 213 | this, SLOT (parseMessage (ProjectExplorer::RunControl *,const QString&,Utils::OutputFormat))); 214 | 215 | } 216 | 217 | void OutputPane::parseMessage (ProjectExplorer::RunControl *control, const QString &msg, Utils::OutputFormat format) { 218 | Q_UNUSED (control); 219 | if (!(format == Utils::StdOutFormat || format == Utils::StdOutFormatSameLine)) { 220 | return; 221 | } 222 | 223 | QStringList lines = msg.split (QLatin1Char ('\n')); 224 | foreach (const QString &line, lines) { 225 | if (line.trimmed ().isEmpty ()) { 226 | continue; 227 | } 228 | if (!state_->isGoogleTestRun) { 229 | state_->isGoogleTestRun = parser_->isGoogleTestRun (line); 230 | if (!state_->isGoogleTestRun) { 231 | continue; 232 | } 233 | clearContents (); 234 | } 235 | parser_->parseMessage (line, *model_, *state_); 236 | } 237 | } 238 | -------------------------------------------------------------------------------- /src/TestProject.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include "TestProject.h" 19 | 20 | using namespace QtcGtest::Internal; 21 | 22 | using namespace Core; 23 | using namespace ProjectExplorer; 24 | using namespace CppTools; 25 | using namespace CPlusPlus; 26 | using namespace Utils; 27 | 28 | namespace { 29 | const QString gtestInclude = QLatin1String ("gtest.h"); 30 | const QString gtestFilter = QLatin1String ("--gtest_filter=%1"); 31 | const QString gtestFilterSeparator = QLatin1String (":"); 32 | const QRegularExpression testPattern ( 33 | QLatin1String ("(TEST|TEST_F|TYPED_TEST|TYPED_TEST_P|TEST_P)\\s*\\((\\w+),\\s*\\w+\\)")); 34 | enum Test {TestType = 1, TestCase, TestName}; 35 | 36 | 37 | FileName shortenFileName (const FileName &file) { 38 | QFileInfo f (file.toString ()); 39 | FileName newName = FileName::fromString (f.absolutePath () + QLatin1Char ('/') + f.baseName ()); 40 | return newName; 41 | } 42 | 43 | template 44 | void removeDuplicates (T &list) { 45 | auto last = std::unique (list.begin (), list.end ()); 46 | list.erase (last, list.end ()); 47 | } 48 | } 49 | 50 | TestProject::TestProject (QObject *parent) : 51 | QObject (parent) { 52 | testFilterPatterns_[QLatin1String ("TYPED_TEST")] = QLatin1String ("%1/*.*"); 53 | testFilterPatterns_[QLatin1String ("TYPED_TEST_P")] = QLatin1String ("*/%1/*.*"); 54 | testFilterPatterns_[QLatin1String ("TEST_P")] = QLatin1String ("*/%1.*"); 55 | testFilterPatterns_[QLatin1String ("TEST")] = QLatin1String ("%1.*"); 56 | testFilterPatterns_[QLatin1String ("TEST_F")] = QLatin1String ("%1.*"); 57 | } 58 | 59 | void TestProject::checkProject () { 60 | Project *project = SessionManager::startupProject (); 61 | RunConfiguration *configuration = parse (project); 62 | if (configuration != NULL) { 63 | runTests (configuration); 64 | } 65 | } 66 | 67 | void TestProject::runTests (RunConfiguration *configuration) { 68 | Q_ASSERT (configuration != NULL); 69 | ProjectExplorerPlugin *plugin = ProjectExplorerPlugin::instance (); 70 | auto runControl = new ProjectExplorer::RunControl ( 71 | configuration, ProjectExplorer::Constants::NORMAL_RUN_MODE); 72 | 73 | auto producer = RunControl::producer ( 74 | configuration, ProjectExplorer::Constants::NORMAL_RUN_MODE); 75 | QTC_ASSERT (producer, return ); 76 | 77 | if (!runControl) { 78 | qDebug () << "failed to create run control"; 79 | return; 80 | } 81 | emit runControlAboutToStart (runControl); 82 | (void) producer (runControl); 83 | 84 | plugin->startRunControl (runControl); 85 | } 86 | 87 | void TestProject::checkChanged () { 88 | if (changedFiles_.isEmpty ()) { 89 | return; 90 | } 91 | Project *project = SessionManager::startupProject (); 92 | RunConfiguration *configuration = parse (project); 93 | if (configuration != NULL) { 94 | runTestsForFiles (changedFiles_, configuration); 95 | changedFiles_.clear (); 96 | } 97 | } 98 | 99 | void TestProject::checkCurrent () { 100 | Project *project = SessionManager::startupProject (); 101 | RunConfiguration *configuration = parse (project); 102 | if (configuration == NULL) { 103 | return; 104 | } 105 | 106 | IDocument *document = EditorManager::currentDocument (); 107 | if (document == NULL) { 108 | return; 109 | } 110 | FileName file = document->filePath (); 111 | Utils::FileNameList files = project->files (Project::SourceFiles); 112 | if (!files.contains (file)) { 113 | return; 114 | } 115 | 116 | runTestsForFiles (FileNameList () << file, configuration); 117 | } 118 | 119 | void TestProject::runTestsForFiles (const FileNameList &files, RunConfiguration *configuration) { 120 | Q_ASSERT (configuration != NULL); 121 | Q_ASSERT (!gtestIncludeFiles_.isEmpty ()); 122 | QSet testFiles = getDependentFiles (gtestIncludeFiles_).toSet (); 123 | QSet dependentFiles = getDependentFiles (files).toSet (); 124 | testFiles.intersect (dependentFiles); 125 | if (testFiles.isEmpty ()) { 126 | return; 127 | } 128 | 129 | QStringList testCases = getTestCases (testFiles); 130 | if (testCases.isEmpty ()) { 131 | return; 132 | } 133 | QString arguments = gtestFilter.arg (testCases.join (gtestFilterSeparator)); 134 | ArgumentsAspect *aspect = configuration->extraAspect (); 135 | if (aspect != NULL) { 136 | // hack to avoid segv inside aspect. not so terrible because this aspect is for 1 use only 137 | QWidget fakeWidget; 138 | QFormLayout fakeLayout; 139 | aspect->addToMainConfigurationWidget (&fakeWidget, &fakeLayout); 140 | aspect->setArguments (aspect->unexpandedArguments () + arguments); 141 | } 142 | runTests (configuration); 143 | } 144 | 145 | FileNameList TestProject::getDependentFiles (const FileNameList &files) const { 146 | FileNameList dependentFiles; 147 | FileNameList uncheckedFiles = files; 148 | while (!uncheckedFiles.isEmpty ()) { 149 | FileName file = uncheckedFiles.takeFirst (); 150 | if (dependentFiles.contains (file)) { 151 | continue; 152 | } 153 | dependentFiles << file; 154 | FileName newName = shortenFileName (file); 155 | FileNameList newFiles = dependencyTable_.value (newName); 156 | if (!newFiles.isEmpty ()) { 157 | dependentFiles += newFiles; 158 | uncheckedFiles += newFiles; 159 | } 160 | } 161 | removeDuplicates (dependentFiles); 162 | return dependentFiles; 163 | } 164 | 165 | QStringList TestProject::getTestCases (const QSet &fileNames) const { 166 | QStringList testCases; 167 | foreach (const FileName &file, fileNames) { 168 | QFile f (file.toString ()); 169 | if (!f.open (QFile::ReadOnly)) { 170 | continue; 171 | } 172 | //TODO Support codecs? 173 | QString source = QString::fromLocal8Bit (f.readAll ()); 174 | f.close (); 175 | QRegularExpressionMatchIterator i = testPattern.globalMatch (source); 176 | while (i.hasNext ()) { 177 | QRegularExpressionMatch match = i.next (); 178 | QString caseType = match.captured (TestType); 179 | Q_ASSERT (testFilterPatterns_.contains (caseType)); 180 | QString pattern = testFilterPatterns_[caseType].arg (match.captured (TestCase)); 181 | testCases << pattern; 182 | } 183 | } 184 | testCases.removeDuplicates (); 185 | return testCases; 186 | } 187 | 188 | void TestProject::handleDocumentsChange (const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector &roles) { 189 | Q_UNUSED (roles); 190 | changedFiles_ = getChangedFiles (topLeft.row (), bottomRight.row (), false); 191 | } 192 | 193 | void TestProject::handleDocumentsClose (const QModelIndex &parent, int start, int end) { 194 | Q_UNUSED (parent); 195 | changedFiles_ = getChangedFiles (start, end, true); // Documents were modified before remove. 196 | } 197 | 198 | FileNameList TestProject::getChangedFiles (int beginRow, int endRow, bool modifiedFlag) const { 199 | FileNameList files; 200 | for (int row = beginRow; row <= endRow; ++row) { 201 | DocumentModel::Entry *entry = DocumentModel::entryAtRow (row); 202 | if (entry == NULL) { 203 | continue; 204 | } 205 | IDocument *document = entry->document; 206 | if (document == NULL) { 207 | continue; 208 | } 209 | if (document->isModified () == modifiedFlag) { // May not belong to project 210 | files << document->filePath (); 211 | } 212 | } 213 | return files; 214 | } 215 | 216 | RunConfiguration *TestProject::parse (Project *project) { 217 | if (project == NULL) { 218 | return NULL; 219 | } 220 | 221 | //TODO build dependency table only on globalSnapshotChange signal? 222 | //TODO use snapshot instead of copying it to qhash? 223 | using namespace CppTools; 224 | Snapshot snapshot = CppModelManagerBase::instance ()->snapshot (); 225 | dependencyTable_.clear (); 226 | for (Snapshot::const_iterator i = snapshot.begin (), end = snapshot.end (); i != end; ++i) { 227 | const FileName &fileName = i.key (); 228 | dependencyTable_[fileName] = snapshot.filesDependingOn (fileName); 229 | } 230 | gtestIncludeFiles_ = gtestMainIncludes (); 231 | if (gtestIncludeFiles_.isEmpty ()) { 232 | return NULL; 233 | } 234 | preprocessDependencyTable (); 235 | 236 | Target *target = project->activeTarget (); 237 | if (target == NULL) { 238 | return NULL; 239 | } 240 | 241 | RunConfiguration *configuration = 242 | qobject_cast (target->activeRunConfiguration ()); 243 | 244 | Target *parent = qobject_cast(configuration->parent ()); 245 | if (parent) { 246 | IRunConfigurationFactory *factory = 247 | ExtensionSystem::PluginManager::getObject( 248 | [configuration, parent](IRunConfigurationFactory *factory) { 249 | return factory->canClone (parent, configuration); 250 | }); 251 | if (factory) { 252 | return factory->clone (parent, configuration); 253 | } 254 | } 255 | return NULL; 256 | } 257 | 258 | FileNameList TestProject::gtestMainIncludes () const { 259 | FileNameList gtestHeaders; // List because projects can have unique gtest.h includes. 260 | foreach (const FileName &file, dependencyTable_.keys ()) { 261 | if (file.endsWith (QLatin1Char ('/') + gtestInclude)) { // Should work fine because file contains full path 262 | gtestHeaders << file; 263 | } 264 | } 265 | removeDuplicates (gtestHeaders); 266 | return gtestHeaders; 267 | } 268 | 269 | void TestProject::preprocessDependencyTable () { 270 | QHash newTable; 271 | for (QHash::ConstIterator i = dependencyTable_.constBegin (), 272 | end = dependencyTable_.constEnd (); i != end; ++i) { 273 | FileName newName = shortenFileName (i.key ()); 274 | newTable [newName] += i.value (); 275 | } 276 | dependencyTable_ = newTable; 277 | } 278 | -------------------------------------------------------------------------------- /src/TestModel.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "TestModel.h" 4 | 5 | using namespace QtcGtest::Internal; 6 | 7 | namespace { 8 | const QColor goodColor = QColor ("#33CC66"); 9 | const QColor badColor = QColor ("#FF6666"); 10 | const QColor noteColor = QColor ("#F0E68C"); 11 | } 12 | 13 | TestModel::TestModel (QObject *parent) : 14 | QStandardItemModel (parent), errorCount_ (0) { 15 | columnNames_.insert (int (ColumnName), tr ("Name")); 16 | columnNames_.insert (int (ColumnPassed), tr ("Passed")); 17 | columnNames_.insert (int (ColumnFailed), tr ("Failed")); 18 | columnNames_.insert (int (ColumnTime), tr ("Time")); 19 | columnNames_.insert (int (ColumnType), tr ("Type")); 20 | setColumnCount (ColumnCount); 21 | setHeaderData (int (ColumnName), Qt::Horizontal, tr ("Name")); 22 | setHeaderData (int (ColumnPassed), Qt::Horizontal, tr ("Passed")); 23 | setHeaderData (int (ColumnFailed), Qt::Horizontal, tr ("Failed")); 24 | setHeaderData (int (ColumnTime), Qt::Horizontal, tr ("Time")); 25 | setHeaderData (int (ColumnType), Qt::Horizontal, tr ("Type")); 26 | } 27 | 28 | QModelIndex TestModel::findItem (const QString &name, const QModelIndex &parent) const { 29 | QTC_ASSERT (!name.isEmpty (), return QModelIndex ()); 30 | for (int i = 0, end = rowCount (parent); i < end; ++i) { 31 | QModelIndex item = index (i, ColumnName, parent); 32 | if (item.data () == name) { 33 | return item; 34 | } 35 | } 36 | return QModelIndex (); 37 | } 38 | 39 | QModelIndex TestModel::caseIndex (const QString &name) const { 40 | QTC_ASSERT (!name.isEmpty (), return QModelIndex ()); 41 | return findItem (name, QModelIndex ()); 42 | } 43 | 44 | QModelIndex TestModel::testIndex (const QString &name, 45 | const QString &caseName) const { 46 | QTC_ASSERT (!name.isEmpty (), return QModelIndex ()); 47 | QModelIndex caseIndex = this->caseIndex (caseName); 48 | QTC_ASSERT (caseIndex.isValid (), return QModelIndex ()); 49 | return findItem (name, caseIndex); 50 | } 51 | 52 | QModelIndex TestModel::previousError (const QModelIndex &index) const { 53 | int currentCase, currentTest, currentDetail; 54 | getCurrentRows (index, currentCase, currentTest, currentDetail); 55 | if (currentCase == 0 && currentTest == 0 && currentDetail == 0) { 56 | return QModelIndex (); 57 | } 58 | --currentDetail; 59 | if (currentDetail == -1) { 60 | --currentTest; 61 | } 62 | if (currentTest == -1) { 63 | --currentCase; 64 | } 65 | 66 | for (; currentCase >= 0; --currentCase) { 67 | QModelIndex caseIndex = this->index (currentCase, 0); 68 | if (currentTest == -1) { 69 | currentTest = rowCount (caseIndex) - 1; 70 | } 71 | for (; currentTest >= 0; --currentTest) { 72 | QModelIndex testIndex = this->index (currentTest, 0, caseIndex); 73 | if (currentDetail == -1) { 74 | currentDetail = rowCount (testIndex) - 1; 75 | } 76 | for (; currentDetail >= 0; --currentDetail) { 77 | QModelIndex detailIndex = this->index (currentDetail, 0, testIndex); 78 | if (getType (detailIndex) == TypeDetailError) { 79 | return detailIndex; 80 | } 81 | } 82 | } 83 | } 84 | return QModelIndex (); 85 | } 86 | 87 | QModelIndex TestModel::nextError (const QModelIndex &index) const { 88 | int currentCase, currentTest, currentDetail; 89 | Type type = getCurrentRows (index, currentCase, currentTest, currentDetail); 90 | if (type == TypeDetail || type == TypeDetailError) { 91 | ++currentDetail; 92 | } 93 | 94 | for (int iEnd = rowCount (); currentCase < iEnd; ++currentCase) { 95 | QModelIndex caseIndex = this->index (currentCase, 0); 96 | for (int iiEnd = rowCount (caseIndex); currentTest < iiEnd; ++currentTest) { 97 | QModelIndex testIndex = this->index (currentTest, 0, caseIndex); 98 | for (int iiiEnd = rowCount (testIndex); currentDetail < iiiEnd; ++currentDetail) { 99 | QModelIndex detailIndex = this->index (currentDetail, 0, testIndex); 100 | if (getType (detailIndex) == TypeDetailError) { 101 | return detailIndex; 102 | } 103 | } 104 | currentDetail = 0; 105 | } 106 | currentTest = 0; 107 | } 108 | return QModelIndex (); 109 | } 110 | 111 | TestModel::Type TestModel::getCurrentRows (const QModelIndex &index, int &caseRow, int &testRow, int &detailRow) const { 112 | caseRow = testRow = detailRow = 0; 113 | Type type = getType (index); 114 | if (type == TypeCase) { 115 | caseRow = index.row (); 116 | } 117 | else if (type == TypeTest) { 118 | testRow = index.row (); 119 | caseRow = index.parent ().row (); 120 | QTC_ASSERT (caseRow >= 0, return TypeUnknown); 121 | } 122 | else if (type == TypeDetail || type == TypeDetailError) { 123 | detailRow = index.row (); 124 | testRow = index.parent ().row (); 125 | QTC_ASSERT (testRow >= 0, return TypeUnknown); 126 | caseRow = index.parent ().parent ().row (); 127 | QTC_ASSERT (caseRow >= 0, return TypeUnknown); 128 | } 129 | return type; 130 | } 131 | 132 | TestModel::Type TestModel::getType (const QModelIndex &index) const { 133 | if (!index.isValid ()) { 134 | return TypeUnknown; 135 | } 136 | return Type (index.sibling (index.row (), ColumnType).data ().toInt ()); 137 | } 138 | 139 | int TestModel::errorCount () const { 140 | return errorCount_; 141 | } 142 | 143 | QList TestModel::createRow (const QString &name, Type type) const { 144 | QList items; 145 | for (int i = 0; i < ColumnCount; ++i) { 146 | items << new QStandardItem; 147 | } 148 | items.first ()->setData (name, Qt::EditRole); 149 | items.last ()->setData (int (type), Qt::EditRole); 150 | return items; 151 | } 152 | 153 | void TestModel::setRowColor (const QModelIndex &index, const QColor &color) { 154 | int row = index.row (); 155 | QTC_ASSERT (index.isValid (), return ); 156 | for (int i = 0; i < ColumnCount; ++i) { 157 | itemFromIndex (index.sibling (row, i))->setBackground (color); 158 | } 159 | } 160 | 161 | QString TestModel::title () const { 162 | return title_; 163 | } 164 | 165 | void TestModel::setTitle (const QString &title) { 166 | title_ = title; 167 | } 168 | 169 | void TestModel::clear () { 170 | removeRows (0, rowCount ()); 171 | errorCount_ = 0; 172 | } 173 | 174 | void TestModel::addNote (const QString &text) { 175 | QTC_ASSERT (!text.isEmpty (), return ); 176 | QList row = createRow (text, TypeNote); 177 | row.at (ColumnFailed)->setText (QLatin1String ("-1")); 178 | invisibleRootItem ()->appendRow (row); 179 | QModelIndex noteIndex = indexFromItem (row.first ()); 180 | setRowColor (noteIndex, noteColor); 181 | } 182 | 183 | void TestModel::addCase (const QString &name) { 184 | QTC_ASSERT (!name.isEmpty (), return ); 185 | invisibleRootItem ()->appendRow (createRow (name, TypeCase)); 186 | } 187 | 188 | void TestModel::addTest (const QString &name, const QString &caseName) { 189 | QTC_ASSERT (!name.isEmpty (), return ); 190 | QTC_ASSERT (!caseName.isEmpty (), return ); 191 | QModelIndex caseIndex = this->caseIndex (caseName); 192 | QTC_ASSERT (caseIndex.isValid (), return ); 193 | itemFromIndex (caseIndex)->appendRow (createRow (name, TypeTest)); 194 | } 195 | 196 | void TestModel::addTestDetail (const QString &name, const QString &caseName, 197 | const QString &detail) { 198 | QTC_ASSERT (!name.isEmpty (), return ); 199 | QTC_ASSERT (!caseName.isEmpty (), return ); 200 | QTC_ASSERT (!detail.isEmpty (), return ); 201 | QModelIndex testIndex = this->testIndex (name, caseName); 202 | QTC_ASSERT (testIndex.isValid (), return ); 203 | itemFromIndex (testIndex)->appendRow (createRow (detail, TypeDetail)); 204 | } 205 | 206 | void TestModel::addTestError (const QString &name, const QString &caseName, const QString &detail, const QString &file, int line) { 207 | QTC_ASSERT (!name.isEmpty (), return ); 208 | QTC_ASSERT (!caseName.isEmpty (), return ); 209 | QTC_ASSERT (!detail.isEmpty (), return ); 210 | QTC_ASSERT (!file.isEmpty (), return ); 211 | QModelIndex testIndex = this->testIndex (name, caseName); 212 | QTC_ASSERT (testIndex.isValid (), return ); 213 | QList row = createRow (detail, TypeDetailError); 214 | row.at (ColumnFile)->setText (file); 215 | row.at (ColumnLine)->setText (QString::number (line)); 216 | itemFromIndex (testIndex)->appendRow (row); 217 | ++errorCount_; 218 | 219 | emit newError (indexFromItem (row.first ())); 220 | } 221 | 222 | void TestModel::updateTest (const QString &name, const QString &caseName, 223 | bool isOk, int time) { 224 | QTC_ASSERT (!name.isEmpty (), return ); 225 | QTC_ASSERT (!caseName.isEmpty (), return ); 226 | QModelIndex testIndex = this->testIndex (name, caseName); 227 | QTC_ASSERT (testIndex.isValid (), return ); 228 | int row = testIndex.row (); 229 | setData (testIndex.sibling (row, ColumnPassed), isOk ? 1 : 0); 230 | setData (testIndex.sibling (row, ColumnFailed), isOk ? 0 : 1); 231 | setData (testIndex.sibling (row, ColumnTime), time); 232 | setRowColor (testIndex, isOk ? goodColor : badColor); 233 | if (!isOk) { 234 | // Set ColumnFailed = -1 for fail messages to filter it later in proxy model. 235 | for (int i = 0, end = rowCount (testIndex); i < end; ++i) { 236 | QModelIndex child = testIndex.child (i, ColumnFailed); 237 | if (child.data ().isNull ()) { 238 | setData (child, -1); 239 | } 240 | } 241 | } 242 | } 243 | 244 | void TestModel::updateCase (const QString &name, int passedCount, 245 | int failedCount, int time) { 246 | QTC_ASSERT (!name.isEmpty (), return ); 247 | QModelIndex caseIndex = this->caseIndex (name); 248 | QTC_ASSERT (caseIndex.isValid (), return ); 249 | int row = caseIndex.row (); 250 | setData (caseIndex.sibling (row, ColumnPassed), passedCount); 251 | setData (caseIndex.sibling (row, ColumnFailed), failedCount); 252 | setData (caseIndex.sibling (row, ColumnTime), time); 253 | setRowColor (caseIndex, (failedCount == 0) ? goodColor : badColor); 254 | } 255 | 256 | void TestModel::renameTest (const QString &oldName, const QString &newName, 257 | const QString &caseName) { 258 | QTC_ASSERT (!oldName.isEmpty (), return ); 259 | QTC_ASSERT (!caseName.isEmpty (), return ); 260 | QModelIndex testIndex = this->testIndex (oldName, caseName); 261 | QTC_ASSERT (testIndex.isValid (), return ); 262 | QTC_ASSERT (!newName.isEmpty (), return ); 263 | setData (testIndex, newName); 264 | } 265 | -------------------------------------------------------------------------------- /uncrustify.cfg: -------------------------------------------------------------------------------- 1 | # Uncrustify 0.60 2 | 3 | # 4 | # General options 5 | # 6 | 7 | # The type of line endings 8 | newlines = auto # auto/lf/crlf/cr 9 | 10 | # The original size of tabs in the input 11 | input_tab_size = 2 # number 12 | 13 | # The size of tabs in the output (only used if align_with_tabs=true) 14 | output_tab_size = 2 # number 15 | 16 | # The ASCII value of the string escape char, usually 92 (\) or 94 (^). (Pawn) 17 | string_escape_char = 92 # number 18 | 19 | # Alternate string escape char for Pawn. Only works right before the quote char. 20 | string_escape_char2 = 0 # number 21 | 22 | # Allow interpreting '>=' and '>>=' as part of a template in 'void f(list>=val);'. 23 | # If true (default), 'assert(x<0 && y>=3)' will be broken. 24 | # Improvements to template detection may make this option obsolete. 25 | tok_split_gte = false # false/true 26 | 27 | # Control what to do with the UTF-8 BOM (recommend 'remove') 28 | utf8_bom = ignore # ignore/add/remove/force 29 | 30 | # If the file contains bytes with values between 128 and 255, but is not UTF-8, then output as UTF-8 31 | utf8_byte = false # false/true 32 | 33 | # Force the output encoding to UTF-8 34 | utf8_force = false # false/true 35 | 36 | # 37 | # Indenting 38 | # 39 | 40 | # The number of columns to indent per level. 41 | # Usually 2, 3, 4, or 8. 42 | indent_columns = 2 # number 43 | 44 | # The continuation indent. If non-zero, this overrides the indent of '(' and '=' continuation indents. 45 | # For FreeBSD, this is set to 4. Negative value is absolute and not increased for each ( level 46 | indent_continue = 0 # number 47 | 48 | # How to use tabs when indenting code 49 | # 0=spaces only 50 | # 1=indent with tabs to brace level, align with spaces 51 | # 2=indent and align with tabs, using spaces when not on a tabstop 52 | indent_with_tabs = 0 # number 53 | 54 | # Comments that are not a brace level are indented with tabs on a tabstop. 55 | # Requires indent_with_tabs=2. If false, will use spaces. 56 | indent_cmt_with_tabs = false # false/true 57 | 58 | # Whether to indent strings broken by '\' so that they line up 59 | indent_align_string = false # false/true 60 | 61 | # The number of spaces to indent multi-line XML strings. 62 | # Requires indent_align_string=True 63 | indent_xml_string = 0 # number 64 | 65 | # Spaces to indent '{' from level 66 | indent_brace = 0 # number 67 | 68 | # Whether braces are indented to the body level 69 | indent_braces = false # false/true 70 | 71 | # Disabled indenting function braces if indent_braces is true 72 | indent_braces_no_func = false # false/true 73 | 74 | # Disabled indenting class braces if indent_braces is true 75 | indent_braces_no_class = false # false/true 76 | 77 | # Disabled indenting struct braces if indent_braces is true 78 | indent_braces_no_struct = false # false/true 79 | 80 | # Indent based on the size of the brace parent, i.e. 'if' => 3 spaces, 'for' => 4 spaces, etc. 81 | indent_brace_parent = false # false/true 82 | 83 | # Whether the 'namespace' body is indented 84 | indent_namespace = true # false/true 85 | 86 | # The number of spaces to indent a namespace block 87 | indent_namespace_level = 2 # number 88 | 89 | # If the body of the namespace is longer than this number, it won't be indented. 90 | # Requires indent_namespace=true. Default=0 (no limit) 91 | indent_namespace_limit = 0 # number 92 | 93 | # Whether the 'extern "C"' body is indented 94 | indent_extern = true # false/true 95 | 96 | # Whether the 'class' body is indented 97 | indent_class = true # false/true 98 | 99 | # Whether to indent the stuff after a leading class colon 100 | indent_class_colon = true # false/true 101 | 102 | # Virtual indent from the ':' for member initializers. Default is 2 103 | indent_ctor_init_leading = 2 # number 104 | 105 | # Additional indenting for constructor initializer list 106 | indent_ctor_init = 0 # number 107 | 108 | # False=treat 'else\nif' as 'else if' for indenting purposes 109 | # True=indent the 'if' one level 110 | indent_else_if = false # false/true 111 | 112 | # Amount to indent variable declarations after a open brace. neg=relative, pos=absolute 113 | indent_var_def_blk = 0 # number 114 | 115 | # Indent continued variable declarations instead of aligning. 116 | indent_var_def_cont = false # false/true 117 | 118 | # True: force indentation of function definition to start in column 1 119 | # False: use the default behavior 120 | indent_func_def_force_col1 = false # false/true 121 | 122 | # True: indent continued function call parameters one indent level 123 | # False: align parameters under the open paren 124 | indent_func_call_param = false # false/true 125 | 126 | # Same as indent_func_call_param, but for function defs 127 | indent_func_def_param = false # false/true 128 | 129 | # Same as indent_func_call_param, but for function protos 130 | indent_func_proto_param = false # false/true 131 | 132 | # Same as indent_func_call_param, but for class declarations 133 | indent_func_class_param = false # false/true 134 | 135 | # Same as indent_func_call_param, but for class variable constructors 136 | indent_func_ctor_var_param = false # false/true 137 | 138 | # Same as indent_func_call_param, but for templates 139 | indent_template_param = false # false/true 140 | 141 | # Double the indent for indent_func_xxx_param options 142 | indent_func_param_double = false # false/true 143 | 144 | # Indentation column for standalone 'const' function decl/proto qualifier 145 | indent_func_const = 0 # number 146 | 147 | # Indentation column for standalone 'throw' function decl/proto qualifier 148 | indent_func_throw = 0 # number 149 | 150 | # The number of spaces to indent a continued '->' or '.' 151 | # Usually set to 0, 1, or indent_columns. 152 | indent_member = 0 # number 153 | 154 | # Spaces to indent single line ('//') comments on lines before code 155 | indent_sing_line_comments = 0 # number 156 | 157 | # If set, will indent trailing single line ('//') comments relative 158 | # to the code instead of trying to keep the same absolute column 159 | indent_relative_single_line_comments = false # false/true 160 | 161 | # Spaces to indent 'case' from 'switch' 162 | # Usually 0 or indent_columns. 163 | indent_switch_case = 2 # number 164 | 165 | # Spaces to shift the 'case' line, without affecting any other lines 166 | # Usually 0. 167 | indent_case_shift = 0 # number 168 | 169 | # Spaces to indent '{' from 'case'. 170 | # By default, the brace will appear under the 'c' in case. 171 | # Usually set to 0 or indent_columns. 172 | indent_case_brace = 2 # number 173 | 174 | # Whether to indent comments found in first column 175 | indent_col1_comment = true # false/true 176 | 177 | # How to indent goto labels 178 | # >0 : absolute column where 1 is the leftmost column 179 | # <=0 : subtract from brace indent 180 | indent_label = 1 # number 181 | 182 | # Same as indent_label, but for access specifiers that are followed by a colon 183 | indent_access_spec = 1 # number 184 | 185 | # Indent the code after an access specifier by one level. 186 | # If set, this option forces 'indent_access_spec=0' 187 | indent_access_spec_body = true # false/true 188 | 189 | # If an open paren is followed by a newline, indent the next line so that it lines up after the open paren (not recommended) 190 | indent_paren_nl = false # false/true 191 | 192 | # Controls the indent of a close paren after a newline. 193 | # 0: Indent to body level 194 | # 1: Align under the open paren 195 | # 2: Indent to the brace level 196 | indent_paren_close = 0 # number 197 | 198 | # Controls the indent of a comma when inside a paren.If TRUE, aligns under the open paren 199 | indent_comma_paren = false # false/true 200 | 201 | # Controls the indent of a BOOL operator when inside a paren.If TRUE, aligns under the open paren 202 | indent_bool_paren = false # false/true 203 | 204 | # If 'indent_bool_paren' is true, controls the indent of the first expression. If TRUE, aligns the first expression to the following ones 205 | indent_first_bool_expr = false # false/true 206 | 207 | # If an open square is followed by a newline, indent the next line so that it lines up after the open square (not recommended) 208 | indent_square_nl = false # false/true 209 | 210 | # Don't change the relative indent of ESQL/C 'EXEC SQL' bodies 211 | indent_preserve_sql = false # false/true 212 | 213 | # Align continued statements at the '='. Default=True 214 | # If FALSE or the '=' is followed by a newline, the next line is indent one tab. 215 | indent_align_assign = true # false/true 216 | 217 | # Indent OC blocks at brace level instead of usual rules. 218 | indent_oc_block = false # false/true 219 | 220 | # Indent OC blocks in a message relative to the parameter name. 221 | # 0=use indent_oc_block rules, 1+=spaces to indent 222 | indent_oc_block_msg = 0 # number 223 | 224 | # Minimum indent for subsequent parameters 225 | indent_oc_msg_colon = 0 # number 226 | 227 | # 228 | # Spacing options 229 | # 230 | 231 | # Add or remove space around arithmetic operator '+', '-', '/', '*', etc 232 | sp_arith = add # ignore/add/remove/force 233 | 234 | # Add or remove space around assignment operator '=', '+=', etc 235 | sp_assign = add " # ignore/add/remove/force 236 | 237 | # Add or remove space around '=' in C++11 lambda capture specifications. Overrides sp_assign 238 | sp_cpp_lambda_assign = ignore # ignore/add/remove/force 239 | 240 | # Add or remove space after the capture specification in C++11 lambda. 241 | sp_cpp_lambda_paren = ignore # ignore/add/remove/force 242 | 243 | # Add or remove space around assignment operator '=' in a prototype 244 | sp_assign_default = add # ignore/add/remove/force 245 | 246 | # Add or remove space before assignment operator '=', '+=', etc. Overrides sp_assign. 247 | sp_before_assign = ignore # ignore/add/remove/force 248 | 249 | # Add or remove space after assignment operator '=', '+=', etc. Overrides sp_assign. 250 | sp_after_assign = ignore # ignore/add/remove/force 251 | 252 | # Add or remove space around assignment '=' in enum 253 | sp_enum_assign = ignore # ignore/add/remove/force 254 | 255 | # Add or remove space before assignment '=' in enum. Overrides sp_enum_assign. 256 | sp_enum_before_assign = ignore # ignore/add/remove/force 257 | 258 | # Add or remove space after assignment '=' in enum. Overrides sp_enum_assign. 259 | sp_enum_after_assign = ignore # ignore/add/remove/force 260 | 261 | # Add or remove space around preprocessor '##' concatenation operator. Default=Add 262 | sp_pp_concat = add # ignore/add/remove/force 263 | 264 | # Add or remove space after preprocessor '#' stringify operator. Also affects the '#@' charizing operator. 265 | sp_pp_stringify = ignore # ignore/add/remove/force 266 | 267 | # Add or remove space before preprocessor '#' stringify operator as in '#define x(y) L#y'. 268 | sp_before_pp_stringify = ignore # ignore/add/remove/force 269 | 270 | # Add or remove space around boolean operators '&&' and '||' 271 | sp_bool = ignore # ignore/add/remove/force 272 | 273 | # Add or remove space around compare operator '<', '>', '==', etc 274 | sp_compare = ignore # ignore/add/remove/force 275 | 276 | # Add or remove space inside '(' and ')' 277 | sp_inside_paren = ignore # ignore/add/remove/force 278 | 279 | # Add or remove space between nested parens 280 | sp_paren_paren = ignore # ignore/add/remove/force 281 | 282 | # Whether to balance spaces inside nested parens 283 | sp_balance_nested_parens = false # false/true 284 | 285 | # Add or remove space between ')' and '{' 286 | sp_paren_brace = add # ignore/add/remove/force 287 | 288 | # Add or remove space before pointer star '*' 289 | sp_before_ptr_star = add # ignore/add/remove/force 290 | 291 | # Add or remove space before pointer star '*' that isn't followed by a variable name 292 | # If set to 'ignore', sp_before_ptr_star is used instead. 293 | sp_before_unnamed_ptr_star = ignore # ignore/add/remove/force 294 | 295 | # Add or remove space between pointer stars '*' 296 | sp_between_ptr_star = remove # ignore/add/remove/force 297 | 298 | # Add or remove space after pointer star '*', if followed by a word. 299 | sp_after_ptr_star = remove # ignore/add/remove/force 300 | 301 | # Add or remove space after a pointer star '*', if followed by a func proto/def. 302 | sp_after_ptr_star_func = ignore # ignore/add/remove/force 303 | 304 | # Add or remove space after a pointer star '*', if followed by an open paren (function types). 305 | sp_ptr_star_paren = ignore # ignore/add/remove/force 306 | 307 | # Add or remove space before a pointer star '*', if followed by a func proto/def. 308 | sp_before_ptr_star_func = ignore # ignore/add/remove/force 309 | 310 | # Add or remove space before a reference sign '&' 311 | sp_before_byref = add # ignore/add/remove/force 312 | 313 | # Add or remove space before a reference sign '&' that isn't followed by a variable name 314 | # If set to 'ignore', sp_before_byref is used instead. 315 | sp_before_unnamed_byref = ignore # ignore/add/remove/force 316 | 317 | # Add or remove space after reference sign '&', if followed by a word. 318 | sp_after_byref = remove # ignore/add/remove/force 319 | 320 | # Add or remove space after a reference sign '&', if followed by a func proto/def. 321 | sp_after_byref_func = ignore # ignore/add/remove/force 322 | 323 | # Add or remove space before a reference sign '&', if followed by a func proto/def. 324 | sp_before_byref_func = ignore # ignore/add/remove/force 325 | 326 | # Add or remove space between type and word. Default=Force 327 | sp_after_type = force # ignore/add/remove/force 328 | 329 | # Add or remove space before the paren in the D constructs 'template Foo(' and 'class Foo('. 330 | sp_before_template_paren = ignore # ignore/add/remove/force 331 | 332 | # Add or remove space in 'template <' vs 'template<'. 333 | # If set to ignore, sp_before_angle is used. 334 | sp_template_angle = ignore # ignore/add/remove/force 335 | 336 | # Add or remove space before '<>' 337 | sp_before_angle = ignore # ignore/add/remove/force 338 | 339 | # Add or remove space inside '<' and '>' 340 | sp_inside_angle = ignore # ignore/add/remove/force 341 | 342 | # Add or remove space after '<>' 343 | sp_after_angle = ignore # ignore/add/remove/force 344 | 345 | # Add or remove space between '<>' and '(' as found in 'new List();' 346 | sp_angle_paren = ignore # ignore/add/remove/force 347 | 348 | # Add or remove space between '<>' and a word as in 'List m;' 349 | sp_angle_word = ignore # ignore/add/remove/force 350 | 351 | # Add or remove space between '>' and '>' in '>>' (template stuff C++/C# only). Default=Add 352 | sp_angle_shift = add # ignore/add/remove/force 353 | 354 | # Permit removal of the space between '>>' in 'foo >' (C++11 only). Default=False 355 | # sp_angle_shift cannot remove the space without this option. 356 | sp_permit_cpp11_shift = false # false/true 357 | 358 | # Add or remove space before '(' of 'if', 'for', 'switch', and 'while' 359 | sp_before_sparen = add # ignore/add/remove/force 360 | 361 | # Add or remove space inside if-condition '(' and ')' 362 | sp_inside_sparen = ignore # ignore/add/remove/force 363 | 364 | # Add or remove space before if-condition ')'. Overrides sp_inside_sparen. 365 | sp_inside_sparen_close = ignore # ignore/add/remove/force 366 | 367 | # Add or remove space before if-condition '('. Overrides sp_inside_sparen. 368 | sp_inside_sparen_open = ignore # ignore/add/remove/force 369 | 370 | # Add or remove space after ')' of 'if', 'for', 'switch', and 'while' 371 | sp_after_sparen = ignore # ignore/add/remove/force 372 | 373 | # Add or remove space between ')' and '{' of 'if', 'for', 'switch', and 'while' 374 | sp_sparen_brace = ignore # ignore/add/remove/force 375 | 376 | # Add or remove space between 'invariant' and '(' in the D language. 377 | sp_invariant_paren = ignore # ignore/add/remove/force 378 | 379 | # Add or remove space after the ')' in 'invariant (C) c' in the D language. 380 | sp_after_invariant_paren = ignore # ignore/add/remove/force 381 | 382 | # Add or remove space before empty statement ';' on 'if', 'for' and 'while' 383 | sp_special_semi = ignore # ignore/add/remove/force 384 | 385 | # Add or remove space before ';'. Default=Remove 386 | sp_before_semi = remove # ignore/add/remove/force 387 | 388 | # Add or remove space before ';' in non-empty 'for' statements 389 | sp_before_semi_for = ignore # ignore/add/remove/force 390 | 391 | # Add or remove space before a semicolon of an empty part of a for statement. 392 | sp_before_semi_for_empty = ignore # ignore/add/remove/force 393 | 394 | # Add or remove space after ';', except when followed by a comment. Default=Add 395 | sp_after_semi = add # ignore/add/remove/force 396 | 397 | # Add or remove space after ';' in non-empty 'for' statements. Default=Force 398 | sp_after_semi_for = force # ignore/add/remove/force 399 | 400 | # Add or remove space after the final semicolon of an empty part of a for statement: for ( ; ; ). 401 | sp_after_semi_for_empty = ignore # ignore/add/remove/force 402 | 403 | # Add or remove space before '[' (except '[]') 404 | sp_before_square = ignore # ignore/add/remove/force 405 | 406 | # Add or remove space before '[]' 407 | sp_before_squares = ignore # ignore/add/remove/force 408 | 409 | # Add or remove space inside a non-empty '[' and ']' 410 | sp_inside_square = ignore # ignore/add/remove/force 411 | 412 | # Add or remove space after ',' 413 | sp_after_comma = ignore # ignore/add/remove/force 414 | 415 | # Add or remove space before ',' 416 | sp_before_comma = remove # ignore/add/remove/force 417 | 418 | # Add or remove space between an open paren and comma: '(,' vs '( ,' 419 | sp_paren_comma = force # ignore/add/remove/force 420 | 421 | # Add or remove space before the variadic '...' when preceded by a non-punctuator 422 | sp_before_ellipsis = ignore # ignore/add/remove/force 423 | 424 | # Add or remove space after class ':' 425 | sp_after_class_colon = ignore # ignore/add/remove/force 426 | 427 | # Add or remove space before class ':' 428 | sp_before_class_colon = ignore # ignore/add/remove/force 429 | 430 | # Add or remove space before case ':'. Default=Remove 431 | sp_before_case_colon = remove # ignore/add/remove/force 432 | 433 | # Add or remove space between 'operator' and operator sign 434 | sp_after_operator = ignore # ignore/add/remove/force 435 | 436 | # Add or remove space between the operator symbol and the open paren, as in 'operator ++(' 437 | sp_after_operator_sym = ignore # ignore/add/remove/force 438 | 439 | # Add or remove space after C/D cast, i.e. 'cast(int)a' vs 'cast(int) a' or '(int)a' vs '(int) a' 440 | sp_after_cast = ignore # ignore/add/remove/force 441 | 442 | # Add or remove spaces inside cast parens 443 | sp_inside_paren_cast = ignore # ignore/add/remove/force 444 | 445 | # Add or remove space between the type and open paren in a C++ cast, i.e. 'int(exp)' vs 'int (exp)' 446 | sp_cpp_cast_paren = ignore # ignore/add/remove/force 447 | 448 | # Add or remove space between 'sizeof' and '(' 449 | sp_sizeof_paren = ignore # ignore/add/remove/force 450 | 451 | # Add or remove space after the tag keyword (Pawn) 452 | sp_after_tag = ignore # ignore/add/remove/force 453 | 454 | # Add or remove space inside enum '{' and '}' 455 | sp_inside_braces_enum = ignore # ignore/add/remove/force 456 | 457 | # Add or remove space inside struct/union '{' and '}' 458 | sp_inside_braces_struct = ignore # ignore/add/remove/force 459 | 460 | # Add or remove space inside '{' and '}' 461 | sp_inside_braces = ignore # ignore/add/remove/force 462 | 463 | # Add or remove space inside '{}' 464 | sp_inside_braces_empty = ignore # ignore/add/remove/force 465 | 466 | # Add or remove space between return type and function name 467 | # A minimum of 1 is forced except for pointer return types. 468 | sp_type_func = add # ignore/add/remove/force 469 | 470 | # Add or remove space between function name and '(' on function declaration 471 | sp_func_proto_paren = add # ignore/add/remove/force 472 | 473 | # Add or remove space between function name and '(' on function definition 474 | sp_func_def_paren = add # ignore/add/remove/force 475 | 476 | # Add or remove space inside empty function '()' 477 | sp_inside_fparens = remove # ignore/add/remove/force 478 | 479 | # Add or remove space inside function '(' and ')' 480 | sp_inside_fparen = remove # ignore/add/remove/force 481 | 482 | # Add or remove space inside the first parens in the function type: 'void (*x)(...)' 483 | sp_inside_tparen = ignore # ignore/add/remove/force 484 | 485 | # Add or remove between the parens in the function type: 'void (*x)(...)' 486 | sp_after_tparen_close = ignore # ignore/add/remove/force 487 | 488 | # Add or remove space between ']' and '(' when part of a function call. 489 | sp_square_fparen = ignore # ignore/add/remove/force 490 | 491 | # Add or remove space between ')' and '{' of function 492 | sp_fparen_brace = add # ignore/add/remove/force 493 | 494 | # Add or remove space between function name and '(' on function calls 495 | sp_func_call_paren = add # ignore/add/remove/force 496 | 497 | # Add or remove space between function name and '()' on function calls without parameters. 498 | # If set to 'ignore' (the default), sp_func_call_paren is used. 499 | sp_func_call_paren_empty = add # ignore/add/remove/force 500 | 501 | # Add or remove space between the user function name and '(' on function calls 502 | # You need to set a keyword to be a user function, like this: 'set func_call_user _' in the config file. 503 | sp_func_call_user_paren = ignore # ignore/add/remove/force 504 | 505 | # Add or remove space between a constructor/destructor and the open paren 506 | sp_func_class_paren = add # ignore/add/remove/force 507 | 508 | # Add or remove space between 'return' and '(' 509 | sp_return_paren = ignore # ignore/add/remove/force 510 | 511 | # Add or remove space between '__attribute__' and '(' 512 | sp_attribute_paren = ignore # ignore/add/remove/force 513 | 514 | # Add or remove space between 'defined' and '(' in '#if defined (FOO)' 515 | sp_defined_paren = ignore # ignore/add/remove/force 516 | 517 | # Add or remove space between 'throw' and '(' in 'throw (something)' 518 | sp_throw_paren = ignore # ignore/add/remove/force 519 | 520 | # Add or remove space between 'throw' and anything other than '(' as in '@throw [...];' 521 | sp_after_throw = ignore # ignore/add/remove/force 522 | 523 | # Add or remove space between 'catch' and '(' in 'catch (something) { }' 524 | # If set to ignore, sp_before_sparen is used. 525 | sp_catch_paren = ignore # ignore/add/remove/force 526 | 527 | # Add or remove space between 'version' and '(' in 'version (something) { }' (D language) 528 | # If set to ignore, sp_before_sparen is used. 529 | sp_version_paren = ignore # ignore/add/remove/force 530 | 531 | # Add or remove space between 'scope' and '(' in 'scope (something) { }' (D language) 532 | # If set to ignore, sp_before_sparen is used. 533 | sp_scope_paren = ignore # ignore/add/remove/force 534 | 535 | # Add or remove space between macro and value 536 | sp_macro = ignore # ignore/add/remove/force 537 | 538 | # Add or remove space between macro function ')' and value 539 | sp_macro_func = ignore # ignore/add/remove/force 540 | 541 | # Add or remove space between 'else' and '{' if on the same line 542 | sp_else_brace = ignore # ignore/add/remove/force 543 | 544 | # Add or remove space between '}' and 'else' if on the same line 545 | sp_brace_else = ignore # ignore/add/remove/force 546 | 547 | # Add or remove space between '}' and the name of a typedef on the same line 548 | sp_brace_typedef = ignore # ignore/add/remove/force 549 | 550 | # Add or remove space between 'catch' and '{' if on the same line 551 | sp_catch_brace = ignore # ignore/add/remove/force 552 | 553 | # Add or remove space between '}' and 'catch' if on the same line 554 | sp_brace_catch = ignore # ignore/add/remove/force 555 | 556 | # Add or remove space between 'finally' and '{' if on the same line 557 | sp_finally_brace = ignore # ignore/add/remove/force 558 | 559 | # Add or remove space between '}' and 'finally' if on the same line 560 | sp_brace_finally = ignore # ignore/add/remove/force 561 | 562 | # Add or remove space between 'try' and '{' if on the same line 563 | sp_try_brace = ignore # ignore/add/remove/force 564 | 565 | # Add or remove space between get/set and '{' if on the same line 566 | sp_getset_brace = ignore # ignore/add/remove/force 567 | 568 | # Add or remove space before the '::' operator 569 | sp_before_dc = ignore # ignore/add/remove/force 570 | 571 | # Add or remove space after the '::' operator 572 | sp_after_dc = ignore # ignore/add/remove/force 573 | 574 | # Add or remove around the D named array initializer ':' operator 575 | sp_d_array_colon = ignore # ignore/add/remove/force 576 | 577 | # Add or remove space after the '!' (not) operator. Default=Remove 578 | sp_not = remove # ignore/add/remove/force 579 | 580 | # Add or remove space after the '~' (invert) operator. Default=Remove 581 | sp_inv = remove # ignore/add/remove/force 582 | 583 | # Add or remove space after the '&' (address-of) operator. Default=Remove 584 | # This does not affect the spacing after a '&' that is part of a type. 585 | sp_addr = remove # ignore/add/remove/force 586 | 587 | # Add or remove space around the '.' or '->' operators. Default=Remove 588 | sp_member = remove # ignore/add/remove/force 589 | 590 | # Add or remove space after the '*' (dereference) operator. Default=Remove 591 | # This does not affect the spacing after a '*' that is part of a type. 592 | sp_deref = remove # ignore/add/remove/force 593 | 594 | # Add or remove space after '+' or '-', as in 'x = -5' or 'y = +7'. Default=Remove 595 | sp_sign = remove # ignore/add/remove/force 596 | 597 | # Add or remove space before or after '++' and '--', as in '(--x)' or 'y++;'. Default=Remove 598 | sp_incdec = remove # ignore/add/remove/force 599 | 600 | # Add or remove space before a backslash-newline at the end of a line. Default=Add 601 | sp_before_nl_cont = add # ignore/add/remove/force 602 | 603 | # Add or remove space after the scope '+' or '-', as in '-(void) foo;' or '+(int) bar;' 604 | sp_after_oc_scope = ignore # ignore/add/remove/force 605 | 606 | # Add or remove space after the colon in message specs 607 | # '-(int) f:(int) x;' vs '-(int) f: (int) x;' 608 | sp_after_oc_colon = ignore # ignore/add/remove/force 609 | 610 | # Add or remove space before the colon in message specs 611 | # '-(int) f: (int) x;' vs '-(int) f : (int) x;' 612 | sp_before_oc_colon = ignore # ignore/add/remove/force 613 | 614 | # Add or remove space after the colon in immutable dictionary expression 615 | # 'NSDictionary *test = @{@"foo" :@"bar"};' 616 | sp_after_oc_dict_colon = ignore # ignore/add/remove/force 617 | 618 | # Add or remove space before the colon in immutable dictionary expression 619 | # 'NSDictionary *test = @{@"foo" :@"bar"};' 620 | sp_before_oc_dict_colon = ignore # ignore/add/remove/force 621 | 622 | # Add or remove space after the colon in message specs 623 | # '[object setValue:1];' vs '[object setValue: 1];' 624 | sp_after_send_oc_colon = ignore # ignore/add/remove/force 625 | 626 | # Add or remove space before the colon in message specs 627 | # '[object setValue:1];' vs '[object setValue :1];' 628 | sp_before_send_oc_colon = ignore # ignore/add/remove/force 629 | 630 | # Add or remove space after the (type) in message specs 631 | # '-(int)f: (int) x;' vs '-(int)f: (int)x;' 632 | sp_after_oc_type = ignore # ignore/add/remove/force 633 | 634 | # Add or remove space after the first (type) in message specs 635 | # '-(int) f:(int)x;' vs '-(int)f:(int)x;' 636 | sp_after_oc_return_type = ignore # ignore/add/remove/force 637 | 638 | # Add or remove space between '@selector' and '(' 639 | # '@selector(msgName)' vs '@selector (msgName)' 640 | # Also applies to @protocol() constructs 641 | sp_after_oc_at_sel = ignore # ignore/add/remove/force 642 | 643 | # Add or remove space between '@selector(x)' and the following word 644 | # '@selector(foo) a:' vs '@selector(foo)a:' 645 | sp_after_oc_at_sel_parens = ignore # ignore/add/remove/force 646 | 647 | # Add or remove space inside '@selector' parens 648 | # '@selector(foo)' vs '@selector( foo )' 649 | # Also applies to @protocol() constructs 650 | sp_inside_oc_at_sel_parens = ignore # ignore/add/remove/force 651 | 652 | # Add or remove space before a block pointer caret 653 | # '^int (int arg){...}' vs. ' ^int (int arg){...}' 654 | sp_before_oc_block_caret = ignore # ignore/add/remove/force 655 | 656 | # Add or remove space after a block pointer caret 657 | # '^int (int arg){...}' vs. '^ int (int arg){...}' 658 | sp_after_oc_block_caret = ignore # ignore/add/remove/force 659 | 660 | # Add or remove space between the receiver and selector in a message. 661 | # '[receiver selector ...]' 662 | sp_after_oc_msg_receiver = ignore # ignore/add/remove/force 663 | 664 | # Add or remove space after @property. 665 | sp_after_oc_property = ignore # ignore/add/remove/force 666 | 667 | # Add or remove space around the ':' in 'b ? t : f' 668 | sp_cond_colon = ignore # ignore/add/remove/force 669 | 670 | # Add or remove space around the '?' in 'b ? t : f' 671 | sp_cond_question = ignore # ignore/add/remove/force 672 | 673 | # Fix the spacing between 'case' and the label. Only 'ignore' and 'force' make sense here. 674 | sp_case_label = ignore # ignore/add/remove/force 675 | 676 | # Control the space around the D '..' operator. 677 | sp_range = ignore # ignore/add/remove/force 678 | 679 | # Control the spacing after ':' in 'for (TYPE VAR : EXPR)' (Java) 680 | sp_after_for_colon = ignore # ignore/add/remove/force 681 | 682 | # Control the spacing before ':' in 'for (TYPE VAR : EXPR)' (Java) 683 | sp_before_for_colon = ignore # ignore/add/remove/force 684 | 685 | # Control the spacing in 'extern (C)' (D) 686 | sp_extern_paren = ignore # ignore/add/remove/force 687 | 688 | # Control the space after the opening of a C++ comment '// A' vs '//A' 689 | sp_cmt_cpp_start = ignore # ignore/add/remove/force 690 | 691 | # Controls the spaces between #else or #endif and a trailing comment 692 | sp_endif_cmt = ignore # ignore/add/remove/force 693 | 694 | # Controls the spaces after 'new', 'delete', and 'delete[]' 695 | sp_after_new = ignore # ignore/add/remove/force 696 | 697 | # Controls the spaces before a trailing or embedded comment 698 | sp_before_tr_emb_cmt = ignore # ignore/add/remove/force 699 | 700 | # Number of spaces before a trailing or embedded comment 701 | sp_num_before_tr_emb_cmt = 0 # number 702 | 703 | # Control space between a Java annotation and the open paren. 704 | sp_annotation_paren = ignore # ignore/add/remove/force 705 | 706 | # 707 | # Code alignment (not left column spaces/tabs) 708 | # 709 | 710 | # Whether to keep non-indenting tabs 711 | align_keep_tabs = false # false/true 712 | 713 | # Whether to use tabs for aligning 714 | align_with_tabs = false # false/true 715 | 716 | # Whether to bump out to the next tab when aligning 717 | align_on_tabstop = false # false/true 718 | 719 | # Whether to left-align numbers 720 | align_number_left = false # false/true 721 | 722 | # Align variable definitions in prototypes and functions 723 | align_func_params = false # false/true 724 | 725 | # Align parameters in single-line functions that have the same name. 726 | # The function names must already be aligned with each other. 727 | align_same_func_call_params = false # false/true 728 | 729 | # The span for aligning variable definitions (0=don't align) 730 | align_var_def_span = 0 # number 731 | 732 | # How to align the star in variable definitions. 733 | # 0=Part of the type 'void * foo;' 734 | # 1=Part of the variable 'void *foo;' 735 | # 2=Dangling 'void *foo;' 736 | align_var_def_star_style = 1 # number 737 | 738 | # How to align the '&' in variable definitions. 739 | # 0=Part of the type 740 | # 1=Part of the variable 741 | # 2=Dangling 742 | align_var_def_amp_style = 1 # number 743 | 744 | # The threshold for aligning variable definitions (0=no limit) 745 | align_var_def_thresh = 0 # number 746 | 747 | # The gap for aligning variable definitions 748 | align_var_def_gap = 0 # number 749 | 750 | # Whether to align the colon in struct bit fields 751 | align_var_def_colon = false # false/true 752 | 753 | # Whether to align any attribute after the variable name 754 | align_var_def_attribute = false # false/true 755 | 756 | # Whether to align inline struct/enum/union variable definitions 757 | align_var_def_inline = false # false/true 758 | 759 | # The span for aligning on '=' in assignments (0=don't align) 760 | align_assign_span = 0 # number 761 | 762 | # The threshold for aligning on '=' in assignments (0=no limit) 763 | align_assign_thresh = 10 # number 764 | 765 | # The span for aligning on '=' in enums (0=don't align) 766 | align_enum_equ_span = 0 # number 767 | 768 | # The threshold for aligning on '=' in enums (0=no limit) 769 | align_enum_equ_thresh = 0 # number 770 | 771 | # The span for aligning struct/union (0=don't align) 772 | align_var_struct_span = 0 # number 773 | 774 | # The threshold for aligning struct/union member definitions (0=no limit) 775 | align_var_struct_thresh = 0 # number 776 | 777 | # The gap for aligning struct/union member definitions 778 | align_var_struct_gap = 0 # number 779 | 780 | # The span for aligning struct initializer values (0=don't align) 781 | align_struct_init_span = 0 # number 782 | 783 | # The minimum space between the type and the synonym of a typedef 784 | align_typedef_gap = 0 # number 785 | 786 | # The span for aligning single-line typedefs (0=don't align) 787 | align_typedef_span = 0 # number 788 | 789 | # How to align typedef'd functions with other typedefs 790 | # 0: Don't mix them at all 791 | # 1: align the open paren with the types 792 | # 2: align the function type name with the other type names 793 | align_typedef_func = 0 # number 794 | 795 | # Controls the positioning of the '*' in typedefs. Just try it. 796 | # 0: Align on typedef type, ignore '*' 797 | # 1: The '*' is part of type name: typedef int *pint; 798 | # 2: The '*' is part of the type, but dangling: typedef int *pint; 799 | align_typedef_star_style = 0 # number 800 | 801 | # Controls the positioning of the '&' in typedefs. Just try it. 802 | # 0: Align on typedef type, ignore '&' 803 | # 1: The '&' is part of type name: typedef int &pint; 804 | # 2: The '&' is part of the type, but dangling: typedef int &pint; 805 | align_typedef_amp_style = 0 # number 806 | 807 | # The span for aligning comments that end lines (0=don't align) 808 | align_right_cmt_span = 0 # number 809 | 810 | # If aligning comments, mix with comments after '}' and #endif with less than 3 spaces before the comment 811 | align_right_cmt_mix = false # false/true 812 | 813 | # If a trailing comment is more than this number of columns away from the text it follows, 814 | # it will qualify for being aligned. This has to be > 0 to do anything. 815 | align_right_cmt_gap = 0 # number 816 | 817 | # Align trailing comment at or beyond column N; 'pulls in' comments as a bonus side effect (0=ignore) 818 | align_right_cmt_at_col = 0 # number 819 | 820 | # The span for aligning function prototypes (0=don't align) 821 | align_func_proto_span = 0 # number 822 | 823 | # Minimum gap between the return type and the function name. 824 | align_func_proto_gap = 0 # number 825 | 826 | # Align function protos on the 'operator' keyword instead of what follows 827 | align_on_operator = false # false/true 828 | 829 | # Whether to mix aligning prototype and variable declarations. 830 | # If true, align_var_def_XXX options are used instead of align_func_proto_XXX options. 831 | align_mix_var_proto = false # false/true 832 | 833 | # Align single-line functions with function prototypes, uses align_func_proto_span 834 | align_single_line_func = false # false/true 835 | 836 | # Aligning the open brace of single-line functions. 837 | # Requires align_single_line_func=true, uses align_func_proto_span 838 | align_single_line_brace = false # false/true 839 | 840 | # Gap for align_single_line_brace. 841 | align_single_line_brace_gap = 0 # number 842 | 843 | # The span for aligning ObjC msg spec (0=don't align) 844 | align_oc_msg_spec_span = 0 # number 845 | 846 | # Whether to align macros wrapped with a backslash and a newline. 847 | # This will not work right if the macro contains a multi-line comment. 848 | align_nl_cont = false # false/true 849 | 850 | # # Align macro functions and variables together 851 | align_pp_define_together = false # false/true 852 | 853 | # The minimum space between label and value of a preprocessor define 854 | align_pp_define_gap = 0 # number 855 | 856 | # The span for aligning on '#define' bodies (0=don't align) 857 | align_pp_define_span = 0 # number 858 | 859 | # Align lines that start with '<<' with previous '<<'. Default=true 860 | align_left_shift = true # false/true 861 | 862 | # Span for aligning parameters in an Obj-C message call on the ':' (0=don't align) 863 | align_oc_msg_colon_span = 0 # number 864 | 865 | # If true, always align with the first parameter, even if it is too short. 866 | align_oc_msg_colon_first = false # false/true 867 | 868 | # Aligning parameters in an Obj-C '+' or '-' declaration on the ':' 869 | align_oc_decl_colon = false # false/true 870 | 871 | # 872 | # Newline adding and removing options 873 | # 874 | 875 | # Whether to collapse empty blocks between '{' and '}' 876 | nl_collapse_empty_body = false # false/true 877 | 878 | # Don't split one-line braced assignments - 'foo_t f = { 1, 2 };' 879 | nl_assign_leave_one_liners = false # false/true 880 | 881 | # Don't split one-line braced statements inside a class xx { } body 882 | nl_class_leave_one_liners = false # false/true 883 | 884 | # Don't split one-line enums: 'enum foo { BAR = 15 };' 885 | nl_enum_leave_one_liners = false # false/true 886 | 887 | # Don't split one-line get or set functions 888 | nl_getset_leave_one_liners = false # false/true 889 | 890 | # Don't split one-line function definitions - 'int foo() { return 0; }' 891 | nl_func_leave_one_liners = false # false/true 892 | 893 | # Don't split one-line if/else statements - 'if(a) b++;' 894 | nl_if_leave_one_liners = false # false/true 895 | 896 | # Don't split one-line OC messages 897 | nl_oc_msg_leave_one_liner = false # false/true 898 | 899 | # Add or remove newlines at the start of the file 900 | nl_start_of_file = ignore # ignore/add/remove/force 901 | 902 | # The number of newlines at the start of the file (only used if nl_start_of_file is 'add' or 'force' 903 | nl_start_of_file_min = 0 # number 904 | 905 | # Add or remove newline at the end of the file 906 | nl_end_of_file = ignore # ignore/add/remove/force 907 | 908 | # The number of newlines at the end of the file (only used if nl_end_of_file is 'add' or 'force') 909 | nl_end_of_file_min = 0 # number 910 | 911 | # Add or remove newline between '=' and '{' 912 | nl_assign_brace = ignore # ignore/add/remove/force 913 | 914 | # Add or remove newline between '=' and '[' (D only) 915 | nl_assign_square = ignore # ignore/add/remove/force 916 | 917 | # Add or remove newline after '= [' (D only). Will also affect the newline before the ']' 918 | nl_after_square_assign = ignore # ignore/add/remove/force 919 | 920 | # The number of blank lines after a block of variable definitions at the top of a function body 921 | # 0 = No change (default) 922 | nl_func_var_def_blk = 0 # number 923 | 924 | # The number of newlines before a block of typedefs 925 | # 0 = No change (default) 926 | nl_typedef_blk_start = 0 # number 927 | 928 | # The number of newlines after a block of typedefs 929 | # 0 = No change (default) 930 | nl_typedef_blk_end = 0 # number 931 | 932 | # The maximum consecutive newlines within a block of typedefs 933 | # 0 = No change (default) 934 | nl_typedef_blk_in = 0 # number 935 | 936 | # The number of newlines before a block of variable definitions not at the top of a function body 937 | # 0 = No change (default) 938 | nl_var_def_blk_start = 0 # number 939 | 940 | # The number of newlines after a block of variable definitions not at the top of a function body 941 | # 0 = No change (default) 942 | nl_var_def_blk_end = 0 # number 943 | 944 | # The maximum consecutive newlines within a block of variable definitions 945 | # 0 = No change (default) 946 | nl_var_def_blk_in = 0 # number 947 | 948 | # Add or remove newline between a function call's ')' and '{', as in: 949 | # list_for_each(item, &list) { } 950 | nl_fcall_brace = remove # ignore/add/remove/force 951 | 952 | # Add or remove newline between 'enum' and '{' 953 | nl_enum_brace = remove # ignore/add/remove/force 954 | 955 | # Add or remove newline between 'struct and '{' 956 | nl_struct_brace = remove # ignore/add/remove/force 957 | 958 | # Add or remove newline between 'union' and '{' 959 | nl_union_brace = remove # ignore/add/remove/force 960 | 961 | # Add or remove newline between 'if' and '{' 962 | nl_if_brace = remove # ignore/add/remove/force 963 | 964 | # Add or remove newline between '}' and 'else' 965 | nl_brace_else = add # ignore/add/remove/force 966 | 967 | # Add or remove newline between 'else if' and '{' 968 | # If set to ignore, nl_if_brace is used instead 969 | nl_elseif_brace = remove # ignore/add/remove/force 970 | 971 | # Add or remove newline between 'else' and '{' 972 | nl_else_brace = remove # ignore/add/remove/force 973 | 974 | # Add or remove newline between 'else' and 'if' 975 | nl_else_if = remove # ignore/add/remove/force 976 | 977 | # Add or remove newline between '}' and 'finally' 978 | nl_brace_finally = ignore # ignore/add/remove/force 979 | 980 | # Add or remove newline between 'finally' and '{' 981 | nl_finally_brace = remove # ignore/add/remove/force 982 | 983 | # Add or remove newline between 'try' and '{' 984 | nl_try_brace = remove # ignore/add/remove/force 985 | 986 | # Add or remove newline between get/set and '{' 987 | nl_getset_brace = ignore # ignore/add/remove/force 988 | 989 | # Add or remove newline between 'for' and '{' 990 | nl_for_brace = remove # ignore/add/remove/force 991 | 992 | # Add or remove newline between 'catch' and '{' 993 | nl_catch_brace = remove # ignore/add/remove/force 994 | 995 | # Add or remove newline between '}' and 'catch' 996 | nl_brace_catch = ignore # ignore/add/remove/force 997 | 998 | # Add or remove newline between 'while' and '{' 999 | nl_while_brace = remove # ignore/add/remove/force 1000 | 1001 | # Add or remove newline between 'scope (x)' and '{' (D) 1002 | nl_scope_brace = ignore # ignore/add/remove/force 1003 | 1004 | # Add or remove newline between 'unittest' and '{' (D) 1005 | nl_unittest_brace = ignore # ignore/add/remove/force 1006 | 1007 | # Add or remove newline between 'version (x)' and '{' (D) 1008 | nl_version_brace = ignore # ignore/add/remove/force 1009 | 1010 | # Add or remove newline between 'using' and '{' 1011 | nl_using_brace = ignore # ignore/add/remove/force 1012 | 1013 | # Add or remove newline between two open or close braces. 1014 | # Due to general newline/brace handling, REMOVE may not work. 1015 | nl_brace_brace = ignore # ignore/add/remove/force 1016 | 1017 | # Add or remove newline between 'do' and '{' 1018 | nl_do_brace = remove # ignore/add/remove/force 1019 | 1020 | # Add or remove newline between '}' and 'while' of 'do' statement 1021 | nl_brace_while = add # ignore/add/remove/force 1022 | 1023 | # Add or remove newline between 'switch' and '{' 1024 | nl_switch_brace = remove # ignore/add/remove/force 1025 | 1026 | # Add a newline between ')' and '{' if the ')' is on a different line than the if/for/etc. 1027 | # Overrides nl_for_brace, nl_if_brace, nl_switch_brace, nl_while_switch, and nl_catch_brace. 1028 | nl_multi_line_cond = false # false/true 1029 | 1030 | # Force a newline in a define after the macro name for multi-line defines. 1031 | nl_multi_line_define = false # false/true 1032 | 1033 | # Whether to put a newline before 'case' statement 1034 | nl_before_case = false # false/true 1035 | 1036 | # Add or remove newline between ')' and 'throw' 1037 | nl_before_throw = ignore # ignore/add/remove/force 1038 | 1039 | # Whether to put a newline after 'case' statement 1040 | nl_after_case = false # false/true 1041 | 1042 | # Add or remove a newline between a case ':' and '{'. Overrides nl_after_case. 1043 | nl_case_colon_brace = ignore # ignore/add/remove/force 1044 | 1045 | # Newline between namespace and { 1046 | nl_namespace_brace = remove # ignore/add/remove/force 1047 | 1048 | # Add or remove newline between 'template<>' and whatever follows. 1049 | nl_template_class = ignore # ignore/add/remove/force 1050 | 1051 | # Add or remove newline between 'class' and '{' 1052 | nl_class_brace = remove # ignore/add/remove/force 1053 | 1054 | # Add or remove newline after each ',' in the constructor member initialization 1055 | nl_class_init_args = ignore # ignore/add/remove/force 1056 | 1057 | # Add or remove newline between return type and function name in a function definition 1058 | nl_func_type_name = ignore # ignore/add/remove/force 1059 | 1060 | # Add or remove newline between return type and function name inside a class {} 1061 | # Uses nl_func_type_name or nl_func_proto_type_name if set to ignore. 1062 | nl_func_type_name_class = ignore # ignore/add/remove/force 1063 | 1064 | # Add or remove newline between function scope and name in a definition 1065 | # Controls the newline after '::' in 'void A::f() { }' 1066 | nl_func_scope_name = ignore # ignore/add/remove/force 1067 | 1068 | # Add or remove newline between return type and function name in a prototype 1069 | nl_func_proto_type_name = ignore # ignore/add/remove/force 1070 | 1071 | # Add or remove newline between a function name and the opening '(' 1072 | nl_func_paren = ignore # ignore/add/remove/force 1073 | 1074 | # Add or remove newline between a function name and the opening '(' in the definition 1075 | nl_func_def_paren = ignore # ignore/add/remove/force 1076 | 1077 | # Add or remove newline after '(' in a function declaration 1078 | nl_func_decl_start = ignore # ignore/add/remove/force 1079 | 1080 | # Add or remove newline after '(' in a function definition 1081 | nl_func_def_start = ignore # ignore/add/remove/force 1082 | 1083 | # Overrides nl_func_decl_start when there is only one parameter. 1084 | nl_func_decl_start_single = ignore # ignore/add/remove/force 1085 | 1086 | # Overrides nl_func_def_start when there is only one parameter. 1087 | nl_func_def_start_single = ignore # ignore/add/remove/force 1088 | 1089 | # Add or remove newline after each ',' in a function declaration 1090 | nl_func_decl_args = ignore # ignore/add/remove/force 1091 | 1092 | # Add or remove newline after each ',' in a function definition 1093 | nl_func_def_args = ignore # ignore/add/remove/force 1094 | 1095 | # Add or remove newline before the ')' in a function declaration 1096 | nl_func_decl_end = ignore # ignore/add/remove/force 1097 | 1098 | # Add or remove newline before the ')' in a function definition 1099 | nl_func_def_end = ignore # ignore/add/remove/force 1100 | 1101 | # Overrides nl_func_decl_end when there is only one parameter. 1102 | nl_func_decl_end_single = ignore # ignore/add/remove/force 1103 | 1104 | # Overrides nl_func_def_end when there is only one parameter. 1105 | nl_func_def_end_single = ignore # ignore/add/remove/force 1106 | 1107 | # Add or remove newline between '()' in a function declaration. 1108 | nl_func_decl_empty = ignore # ignore/add/remove/force 1109 | 1110 | # Add or remove newline between '()' in a function definition. 1111 | nl_func_def_empty = ignore # ignore/add/remove/force 1112 | 1113 | # Whether to put each OC message parameter on a separate line 1114 | # See nl_oc_msg_leave_one_liner 1115 | nl_oc_msg_args = false # false/true 1116 | 1117 | # Add or remove newline between function signature and '{' 1118 | nl_fdef_brace = remove # ignore/add/remove/force 1119 | 1120 | # Add or remove a newline between the return keyword and return expression. 1121 | nl_return_expr = ignore # ignore/add/remove/force 1122 | 1123 | # Whether to put a newline after semicolons, except in 'for' statements 1124 | nl_after_semicolon = false # false/true 1125 | 1126 | # Whether to put a newline after brace open. 1127 | # This also adds a newline before the matching brace close. 1128 | nl_after_brace_open = false # false/true 1129 | 1130 | # If nl_after_brace_open and nl_after_brace_open_cmt are true, a newline is 1131 | # placed between the open brace and a trailing single-line comment. 1132 | nl_after_brace_open_cmt = false # false/true 1133 | 1134 | # Whether to put a newline after a virtual brace open with a non-empty body. 1135 | # These occur in un-braced if/while/do/for statement bodies. 1136 | nl_after_vbrace_open = false # false/true 1137 | 1138 | # Whether to put a newline after a virtual brace open with an empty body. 1139 | # These occur in un-braced if/while/do/for statement bodies. 1140 | nl_after_vbrace_open_empty = false # false/true 1141 | 1142 | # Whether to put a newline after a brace close. 1143 | # Does not apply if followed by a necessary ';'. 1144 | nl_after_brace_close = false # false/true 1145 | 1146 | # Whether to put a newline after a virtual brace close. 1147 | # Would add a newline before return in: 'if (foo) a++; return;' 1148 | nl_after_vbrace_close = false # false/true 1149 | 1150 | # Control the newline between the close brace and 'b' in: 'struct { int a; } b;' 1151 | # Affects enums, unions, and structures. If set to ignore, uses nl_after_brace_close 1152 | nl_brace_struct_var = ignore # ignore/add/remove/force 1153 | 1154 | # Whether to alter newlines in '#define' macros 1155 | nl_define_macro = false # false/true 1156 | 1157 | # Whether to not put blanks after '#ifxx', '#elxx', or before '#endif' 1158 | nl_squeeze_ifdef = false # false/true 1159 | 1160 | # Add or remove blank line before 'if' 1161 | nl_before_if = ignore # ignore/add/remove/force 1162 | 1163 | # Add or remove blank line after 'if' statement 1164 | nl_after_if = ignore # ignore/add/remove/force 1165 | 1166 | # Add or remove blank line before 'for' 1167 | nl_before_for = ignore # ignore/add/remove/force 1168 | 1169 | # Add or remove blank line after 'for' statement 1170 | nl_after_for = ignore # ignore/add/remove/force 1171 | 1172 | # Add or remove blank line before 'while' 1173 | nl_before_while = ignore # ignore/add/remove/force 1174 | 1175 | # Add or remove blank line after 'while' statement 1176 | nl_after_while = ignore # ignore/add/remove/force 1177 | 1178 | # Add or remove blank line before 'switch' 1179 | nl_before_switch = ignore # ignore/add/remove/force 1180 | 1181 | # Add or remove blank line after 'switch' statement 1182 | nl_after_switch = ignore # ignore/add/remove/force 1183 | 1184 | # Add or remove blank line before 'do' 1185 | nl_before_do = ignore # ignore/add/remove/force 1186 | 1187 | # Add or remove blank line after 'do/while' statement 1188 | nl_after_do = ignore # ignore/add/remove/force 1189 | 1190 | # Whether to double-space commented-entries in struct/enum 1191 | nl_ds_struct_enum_cmt = false # false/true 1192 | 1193 | # Whether to double-space before the close brace of a struct/union/enum 1194 | # (lower priority than 'eat_blanks_before_close_brace') 1195 | nl_ds_struct_enum_close_brace = false # false/true 1196 | 1197 | # Add or remove a newline around a class colon. 1198 | # Related to pos_class_colon, nl_class_init_args, and pos_comma. 1199 | nl_class_colon = ignore # ignore/add/remove/force 1200 | 1201 | # Change simple unbraced if statements into a one-liner 1202 | # 'if(b)\n i++;' => 'if(b) i++;' 1203 | nl_create_if_one_liner = false # false/true 1204 | 1205 | # Change simple unbraced for statements into a one-liner 1206 | # 'for (i=0;i<5;i++)\n foo(i);' => 'for (i=0;i<5;i++) foo(i);' 1207 | nl_create_for_one_liner = false # false/true 1208 | 1209 | # Change simple unbraced while statements into a one-liner 1210 | # 'while (i<5)\n foo(i++);' => 'while (i<5) foo(i++);' 1211 | nl_create_while_one_liner = false # false/true 1212 | 1213 | # 1214 | # Positioning options 1215 | # 1216 | 1217 | # The position of arithmetic operators in wrapped expressions 1218 | pos_arith = ignore # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force 1219 | 1220 | # The position of assignment in wrapped expressions. 1221 | # Do not affect '=' followed by '{' 1222 | pos_assign = ignore # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force 1223 | 1224 | # The position of boolean operators in wrapped expressions 1225 | pos_bool = ignore # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force 1226 | 1227 | # The position of comparison operators in wrapped expressions 1228 | pos_compare = ignore # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force 1229 | 1230 | # The position of conditional (b ? t : f) operators in wrapped expressions 1231 | pos_conditional = ignore # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force 1232 | 1233 | # The position of the comma in wrapped expressions 1234 | pos_comma = trail # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force 1235 | 1236 | # The position of the comma in the constructor initialization list 1237 | pos_class_comma = ignore # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force 1238 | 1239 | # The position of colons between constructor and member initialization 1240 | pos_class_colon = ignore # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force 1241 | 1242 | # 1243 | # Line Splitting options 1244 | # 1245 | 1246 | # Try to limit code width to N number of columns 1247 | code_width = 0 # number 1248 | 1249 | # Whether to fully split long 'for' statements at semi-colons 1250 | ls_for_split_full = false # false/true 1251 | 1252 | # Whether to fully split long function protos/calls at commas 1253 | ls_func_split_full = false # false/true 1254 | 1255 | # Whether to split lines as close to code_width as possible and ignore some groupings 1256 | ls_code_width = false # false/true 1257 | 1258 | # 1259 | # Blank line options 1260 | # 1261 | 1262 | # The maximum consecutive newlines 1263 | nl_max = 0 # number 1264 | 1265 | # The number of newlines after a function prototype, if followed by another function prototype 1266 | nl_after_func_proto = 0 # number 1267 | 1268 | # The number of newlines after a function prototype, if not followed by another function prototype 1269 | nl_after_func_proto_group = 0 # number 1270 | 1271 | # The number of newlines after '}' of a multi-line function body 1272 | nl_after_func_body = 0 # number 1273 | 1274 | # The number of newlines after '}' of a multi-line function body in a class declaration 1275 | nl_after_func_body_class = 0 # number 1276 | 1277 | # The number of newlines after '}' of a single line function body 1278 | nl_after_func_body_one_liner = 0 # number 1279 | 1280 | # The minimum number of newlines before a multi-line comment. 1281 | # Doesn't apply if after a brace open or another multi-line comment. 1282 | nl_before_block_comment = 0 # number 1283 | 1284 | # The minimum number of newlines before a single-line C comment. 1285 | # Doesn't apply if after a brace open or other single-line C comments. 1286 | nl_before_c_comment = 0 # number 1287 | 1288 | # The minimum number of newlines before a CPP comment. 1289 | # Doesn't apply if after a brace open or other CPP comments. 1290 | nl_before_cpp_comment = 0 # number 1291 | 1292 | # Whether to force a newline after a multi-line comment. 1293 | nl_after_multiline_comment = false # false/true 1294 | 1295 | # The number of newlines after '}' or ';' of a struct/enum/union definition 1296 | nl_after_struct = 0 # number 1297 | 1298 | # The number of newlines after '}' or ';' of a class definition 1299 | nl_after_class = 0 # number 1300 | 1301 | # The number of newlines before a 'private:', 'public:', 'protected:', 'signals:', or 'slots:' label. 1302 | # Will not change the newline count if after a brace open. 1303 | # 0 = No change. 1304 | nl_before_access_spec = 2 # number 1305 | 1306 | # The number of newlines after a 'private:', 'public:', 'protected:', 'signals:', or 'slots:' label. 1307 | # 0 = No change. 1308 | nl_after_access_spec = 0 # number 1309 | 1310 | # The number of newlines between a function def and the function comment. 1311 | # 0 = No change. 1312 | nl_comment_func_def = 0 # number 1313 | 1314 | # The number of newlines after a try-catch-finally block that isn't followed by a brace close. 1315 | # 0 = No change. 1316 | nl_after_try_catch_finally = 0 # number 1317 | 1318 | # The number of newlines before and after a property, indexer or event decl. 1319 | # 0 = No change. 1320 | nl_around_cs_property = 0 # number 1321 | 1322 | # The number of newlines between the get/set/add/remove handlers in C#. 1323 | # 0 = No change. 1324 | nl_between_get_set = 0 # number 1325 | 1326 | # Add or remove newline between C# property and the '{' 1327 | nl_property_brace = ignore # ignore/add/remove/force 1328 | 1329 | # Whether to remove blank lines after '{' 1330 | eat_blanks_after_open_brace = false # false/true 1331 | 1332 | # Whether to remove blank lines before '}' 1333 | eat_blanks_before_close_brace = false # false/true 1334 | 1335 | # How aggressively to remove extra newlines not in preproc. 1336 | # 0: No change 1337 | # 1: Remove most newlines not handled by other config 1338 | # 2: Remove all newlines and reformat completely by config 1339 | nl_remove_extra_newlines = 0 # number 1340 | 1341 | # Whether to put a blank line before 'return' statements, unless after an open brace. 1342 | nl_before_return = false # false/true 1343 | 1344 | # Whether to put a blank line after 'return' statements, unless followed by a close brace. 1345 | nl_after_return = false # false/true 1346 | 1347 | # Whether to put a newline after a Java annotation statement. 1348 | # Only affects annotations that are after a newline. 1349 | nl_after_annotation = ignore # ignore/add/remove/force 1350 | 1351 | # Controls the newline between two annotations. 1352 | nl_between_annotation = ignore # ignore/add/remove/force 1353 | 1354 | # 1355 | # Code modifying options (non-whitespace) 1356 | # 1357 | 1358 | # Add or remove braces on single-line 'do' statement 1359 | mod_full_brace_do = ignore # ignore/add/remove/force 1360 | 1361 | # Add or remove braces on single-line 'for' statement 1362 | mod_full_brace_for = add # ignore/add/remove/force 1363 | 1364 | # Add or remove braces on single-line function definitions. (Pawn) 1365 | mod_full_brace_function = add # ignore/add/remove/force 1366 | 1367 | # Add or remove braces on single-line 'if' statement. Will not remove the braces if they contain an 'else'. 1368 | mod_full_brace_if = add # ignore/add/remove/force 1369 | 1370 | # Make all if/elseif/else statements in a chain be braced or not. Overrides mod_full_brace_if. 1371 | # If any must be braced, they are all braced. If all can be unbraced, then the braces are removed. 1372 | mod_full_brace_if_chain = false # false/true 1373 | 1374 | # Don't remove braces around statements that span N newlines 1375 | mod_full_brace_nl = 0 # number 1376 | 1377 | # Add or remove braces on single-line 'while' statement 1378 | mod_full_brace_while = add # ignore/add/remove/force 1379 | 1380 | # Add or remove braces on single-line 'using ()' statement 1381 | mod_full_brace_using = ignore # ignore/add/remove/force 1382 | 1383 | # Add or remove unnecessary paren on 'return' statement 1384 | mod_paren_on_return = ignore # ignore/add/remove/force 1385 | 1386 | # Whether to change optional semicolons to real semicolons 1387 | mod_pawn_semicolon = false # false/true 1388 | 1389 | # Add parens on 'while' and 'if' statement around bools 1390 | mod_full_paren_if_bool = false # false/true 1391 | 1392 | # Whether to remove superfluous semicolons 1393 | mod_remove_extra_semicolon = false # false/true 1394 | 1395 | # If a function body exceeds the specified number of newlines and doesn't have a comment after 1396 | # the close brace, a comment will be added. 1397 | mod_add_long_function_closebrace_comment = 0 # number 1398 | 1399 | # If a switch body exceeds the specified number of newlines and doesn't have a comment after 1400 | # the close brace, a comment will be added. 1401 | mod_add_long_switch_closebrace_comment = 0 # number 1402 | 1403 | # If an #ifdef body exceeds the specified number of newlines and doesn't have a comment after 1404 | # the #endif, a comment will be added. 1405 | mod_add_long_ifdef_endif_comment = 0 # number 1406 | 1407 | # If an #ifdef or #else body exceeds the specified number of newlines and doesn't have a comment after 1408 | # the #else, a comment will be added. 1409 | mod_add_long_ifdef_else_comment = 0 # number 1410 | 1411 | # If TRUE, will sort consecutive single-line 'import' statements [Java, D] 1412 | mod_sort_import = false # false/true 1413 | 1414 | # If TRUE, will sort consecutive single-line 'using' statements [C#] 1415 | mod_sort_using = false # false/true 1416 | 1417 | # If TRUE, will sort consecutive single-line '#include' statements [C/C++] and '#import' statements [Obj-C] 1418 | # This is generally a bad idea, as it may break your code. 1419 | mod_sort_include = false # false/true 1420 | 1421 | # If TRUE, it will move a 'break' that appears after a fully braced 'case' before the close brace. 1422 | mod_move_case_break = false # false/true 1423 | 1424 | # Will add or remove the braces around a fully braced case statement. 1425 | # Will only remove the braces if there are no variable declarations in the block. 1426 | mod_case_brace = ignore # ignore/add/remove/force 1427 | 1428 | # If TRUE, it will remove a void 'return;' that appears as the last statement in a function. 1429 | mod_remove_empty_return = false # false/true 1430 | 1431 | # 1432 | # Comment modifications 1433 | # 1434 | 1435 | # Try to wrap comments at cmt_width columns 1436 | cmt_width = 0 # number 1437 | 1438 | # Set the comment reflow mode (default: 0) 1439 | # 0: no reflowing (apart from the line wrapping due to cmt_width) 1440 | # 1: no touching at all 1441 | # 2: full reflow 1442 | cmt_reflow_mode = 0 # number 1443 | 1444 | # If false, disable all multi-line comment changes, including cmt_width. keyword substitution, and leading chars. 1445 | # Default is true. 1446 | cmt_indent_multi = true # false/true 1447 | 1448 | # Whether to group c-comments that look like they are in a block 1449 | cmt_c_group = false # false/true 1450 | 1451 | # Whether to put an empty '/*' on the first line of the combined c-comment 1452 | cmt_c_nl_start = false # false/true 1453 | 1454 | # Whether to put a newline before the closing '*/' of the combined c-comment 1455 | cmt_c_nl_end = false # false/true 1456 | 1457 | # Whether to group cpp-comments that look like they are in a block 1458 | cmt_cpp_group = false # false/true 1459 | 1460 | # Whether to put an empty '/*' on the first line of the combined cpp-comment 1461 | cmt_cpp_nl_start = false # false/true 1462 | 1463 | # Whether to put a newline before the closing '*/' of the combined cpp-comment 1464 | cmt_cpp_nl_end = false # false/true 1465 | 1466 | # Whether to change cpp-comments into c-comments 1467 | cmt_cpp_to_c = false # false/true 1468 | 1469 | # Whether to put a star on subsequent comment lines 1470 | cmt_star_cont = false # false/true 1471 | 1472 | # The number of spaces to insert at the start of subsequent comment lines 1473 | cmt_sp_before_star_cont = 0 # number 1474 | 1475 | # The number of spaces to insert after the star on subsequent comment lines 1476 | cmt_sp_after_star_cont = 0 # number 1477 | 1478 | # For multi-line comments with a '*' lead, remove leading spaces if the first and last lines of 1479 | # the comment are the same length. Default=True 1480 | cmt_multi_check_last = true # false/true 1481 | 1482 | # The filename that contains text to insert at the head of a file if the file doesn't start with a C/C++ comment. 1483 | # Will substitute $(filename) with the current file's name. 1484 | cmt_insert_file_header = "" # string 1485 | 1486 | # The filename that contains text to insert at the end of a file if the file doesn't end with a C/C++ comment. 1487 | # Will substitute $(filename) with the current file's name. 1488 | cmt_insert_file_footer = "" # string 1489 | 1490 | # The filename that contains text to insert before a function implementation if the function isn't preceded with a C/C++ comment. 1491 | # Will substitute $(function) with the function name and $(javaparam) with the javadoc @param and @return stuff. 1492 | # Will also substitute $(fclass) with the class name: void CFoo::Bar() { ... } 1493 | cmt_insert_func_header = "" # string 1494 | 1495 | # The filename that contains text to insert before a class if the class isn't preceded with a C/C++ comment. 1496 | # Will substitute $(class) with the class name. 1497 | cmt_insert_class_header = "" # string 1498 | 1499 | # The filename that contains text to insert before a Obj-C message specification if the method isn't preceeded with a C/C++ comment. 1500 | # Will substitute $(message) with the function name and $(javaparam) with the javadoc @param and @return stuff. 1501 | cmt_insert_oc_msg_header = "" # string 1502 | 1503 | # If a preprocessor is encountered when stepping backwards from a function name, then 1504 | # this option decides whether the comment should be inserted. 1505 | # Affects cmt_insert_oc_msg_header, cmt_insert_func_header and cmt_insert_class_header. 1506 | cmt_insert_before_preproc = false # false/true 1507 | 1508 | # 1509 | # Preprocessor options 1510 | # 1511 | 1512 | # Control indent of preprocessors inside #if blocks at brace level 0 1513 | pp_indent = remove # ignore/add/remove/force 1514 | 1515 | # Whether to indent #if/#else/#endif at the brace level (true) or from column 1 (false) 1516 | pp_indent_at_level = false # false/true 1517 | 1518 | # If pp_indent_at_level=false, specifies the number of columns to indent per level. Default=1. 1519 | pp_indent_count = 0 # number 1520 | 1521 | # Add or remove space after # based on pp_level of #if blocks 1522 | pp_space = add # ignore/add/remove/force 1523 | 1524 | # Sets the number of spaces added with pp_space 1525 | pp_space_count = 2 # number 1526 | 1527 | # The indent for #region and #endregion in C# and '#pragma region' in C/C++ 1528 | pp_indent_region = 0 # number 1529 | 1530 | # Whether to indent the code between #region and #endregion 1531 | pp_region_indent_code = false # false/true 1532 | 1533 | # If pp_indent_at_level=true, sets the indent for #if, #else, and #endif when not at file-level 1534 | pp_indent_if = 0 # number 1535 | 1536 | # Control whether to indent the code between #if, #else and #endif when not at file-level 1537 | pp_if_indent_code = false # false/true 1538 | 1539 | # Whether to indent '#define' at the brace level (true) or from column 1 (false) 1540 | pp_define_at_level = false # false/true 1541 | 1542 | # You can force a token to be a type with the 'type' option. 1543 | # Example: 1544 | # type myfoo1 myfoo2 1545 | # 1546 | # You can create custom macro-based indentation using macro-open, 1547 | # macro-else and macro-close. 1548 | # Example: 1549 | # macro-open BEGIN_TEMPLATE_MESSAGE_MAP 1550 | # macro-open BEGIN_MESSAGE_MAP 1551 | # macro-close END_MESSAGE_MAP 1552 | # 1553 | # You can assign any keyword to any type with the set option. 1554 | # set func_call_user _ N_ 1555 | # 1556 | # The full syntax description of all custom definition config entries 1557 | # is shown below: 1558 | # 1559 | # define custom tokens as: 1560 | # - embed whitespace in token using '' escape character, or 1561 | # put token in quotes 1562 | # - these: ' " and ` are recognized as quote delimiters 1563 | # 1564 | # type token1 token2 token3 ... 1565 | # ^ optionally specify multiple tokens on a single line 1566 | # define def_token output_token 1567 | # ^ output_token is optional, then NULL is assumed 1568 | # macro-open token 1569 | # macro-close token 1570 | # macro-else token 1571 | # set id token1 token2 ... 1572 | # ^ optionally specify multiple tokens on a single line 1573 | # ^ id is one of the names in token_enum.h sans the CT_ prefix, 1574 | # e.g. PP_PRAGMA 1575 | # 1576 | # all tokens are separated by any mix of ',' commas, '=' equal signs 1577 | # and whitespace (space, tab) 1578 | # 1579 | --------------------------------------------------------------------------------