Merge remote-tracking branch 'origin/master' into 12.0

Change-Id: Iae9b2f871a3d9ae9cda4689b68cf0bc815cb1057
This commit is contained in:
Eike Ziller
2023-09-27 08:39:45 +02:00
48 changed files with 3208 additions and 2270 deletions

1
.gitignore vendored
View File

@@ -56,6 +56,7 @@ CMakeLists.txt.user*
/share/qtcreator/qmldesigner/QtProject/
/src/app/Info.plist
/src/plugins/**/*.json
!/src/plugins/**/wizard.json
/src/plugins/coreplugin/ide_version.h
/src/libs/qt-breakpad/bin
/.cmake/

View File

@@ -970,3 +970,36 @@ SQLite (https://www.sqlite.org) is in the Public Domain.
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
### RSTParser
RSTParser is an open-source C++ library for parsing reStructuredText
https://github.com/vitaut-archive/rstparser
License
-------
Copyright (c) 2013, Victor Zverovich
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@@ -938,6 +938,43 @@
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\endcode
\li \b RSTParser
RSTParser is an open-source C++ library for parsing reStructuredText
\list
\li \l https://github.com/vitaut-archive/rstparser
\endlist
\badcode
License
-------
Copyright (c) 2013, Victor Zverovich
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\endcode
\endlist
*/

View File

@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<snippets>
<snippet group="QML" trigger="TestCase" id="quicktest_case" complement="QuickTest Test Case">TestCase {
name: "$TestCaseName$"
function test_$TestFunctionName$() {
$$
}
}
</snippet>
<snippet group="C++" trigger="TEST" id="gtest_test_function" complement="GTest Function">TEST($TestSuite$, $TestName$)
{
$$
}
</snippet>
<snippet group="C++" trigger="TEST_F" id="gtest_test_function_fixture" complement="GTest Fixture">TEST_F($TestFixtureName$, $TestName$)
{
$$
}
</snippet>
<snippet group="C++" trigger="TEST_P" id="gtest_test_function_parameterized" complement="GTest Parameterized">INSTANTIATE_TEST_SUITE_P($InstantiationName$, $TestFixtureName$, $ParameterGenerator$);
TEST_P($TestFixtureName$, $TestName$)
{
$$
}
</snippet>
<snippet group="C++" trigger="BOOST_AUTO_TEST_CASE" id="boost_test_case" complement="Test Case">BOOST_AUTO_TEST_CASE($TestName$)
{
$$
}
</snippet>
<snippet group="C++" trigger="BOOST_AUTO_TEST_SUITE" id="boost_test_suite" complement="Test Suite">BOOST_AUTO_TEST_SUITE($SuiteName$)
BOOST_AUTO_TEST_CASE($TestName$)
{
$$
}
BOOST_AUTO_TEST_SUITE_END()
</snippet>
<snippet group="C++" trigger="TEST_CASE" id="catch_testcase_with_section" complement="Catch Test Case">TEST_CASE("$TestCaseName$") {
SECTION("$SectionName$") {
$$
}
}
</snippet>
<snippet group="C++" trigger="SCENARIO" id="catch_scenario" complement="Catch Scenario">SCENARIO("$ScenarioName$") {
GIVEN("$Initial$") {
$$
WHEN("$Condition$") {
$$
THEN("$Expectation$") {
$$
}
}
}
}
</snippet>
</snippets>

View File

@@ -14,4 +14,16 @@
# define EXTENSIONSYSTEM_EXPORT Q_DECL_IMPORT
#endif
#if defined(WITH_TESTS)
# if defined(EXTENSIONSYSTEM_LIBRARY)
# define EXTENSIONSYSTEM_TEST_EXPORT Q_DECL_EXPORT
# elif defined(EXTENSIONSYSTEM_STATIC_LIBRARY)
# define EXTENSIONSYSTEM_TEST_EXPORT
# else
# define EXTENSIONSYSTEM_TEST_EXPORT Q_DECL_IMPORT
# endif
#else
# define QTSUPPORT_TEST_EXPORT
#endif
Q_DECLARE_LOGGING_CATEGORY(pluginLog)

View File

@@ -38,7 +38,7 @@ namespace Internal {
class PluginSpecPrivate;
class EXTENSIONSYSTEM_EXPORT PluginManagerPrivate : public QObject
class EXTENSIONSYSTEM_TEST_EXPORT PluginManagerPrivate : public QObject
{
Q_OBJECT
public:

View File

@@ -22,7 +22,7 @@ class IPlugin;
namespace Internal {
class EXTENSIONSYSTEM_EXPORT PluginSpecPrivate : public QObject
class EXTENSIONSYSTEM_TEST_EXPORT PluginSpecPrivate : public QObject
{
Q_OBJECT

View File

@@ -3154,6 +3154,21 @@ void AspectList::removeItem(const std::shared_ptr<BaseAspect> &item)
actualRemoveItem(item);
}
void AspectList::clear()
{
if (undoStack()) {
undoStack()->beginMacro("Clear");
for (auto item : volatileItems())
undoStack()->push(new RemoveItemCommand(this, item));
undoStack()->endMacro();
} else {
for (auto item : volatileItems())
actualRemoveItem(item);
}
}
void AspectList::apply()
{
d->items = d->volatileItems;
@@ -3286,8 +3301,10 @@ QStandardItem *StringSelectionAspect::itemById(const QString &id)
void StringSelectionAspect::bufferToGui()
{
if (!m_model)
if (!m_model) {
m_undoable.setSilently(m_buffer);
return;
}
auto selected = itemById(m_buffer);
if (selected) {
@@ -3302,8 +3319,10 @@ void StringSelectionAspect::bufferToGui()
m_selectionModel->setCurrentIndex(m_model->item(0)->index(),
QItemSelectionModel::SelectionFlag::ClearAndSelect);
} else {
m_undoable.setSilently(m_buffer);
m_selectionModel->setCurrentIndex(QModelIndex(), QItemSelectionModel::SelectionFlag::Clear);
}
handleGuiChanged();
}

View File

@@ -1031,6 +1031,7 @@ public:
void removeItem(const std::shared_ptr<BaseAspect> &item);
void actualRemoveItem(const std::shared_ptr<BaseAspect> &item);
void clear();
void apply() override;

View File

@@ -225,11 +225,12 @@ QString Environment::expandedValueForKey(const QString &key) const
FilePath Environment::searchInPath(const QString &executable,
const FilePaths &additionalDirs,
const FilePathPredicate &filter) const
const FilePathPredicate &filter,
FilePath::MatchScope scope) const
{
const FilePath exec = FilePath::fromUserInput(expandVariables(executable));
const FilePaths dirs = path() + additionalDirs;
return exec.searchInDirectories(dirs, filter, FilePath::WithAnySuffix);
return exec.searchInDirectories(dirs, filter, scope);
}
FilePaths Environment::path() const

View File

@@ -61,7 +61,8 @@ public:
FilePath searchInPath(const QString &executable,
const FilePaths &additionalDirs = FilePaths(),
const FilePathPredicate &func = {}) const;
const FilePathPredicate &func = {},
FilePath::MatchScope = FilePath::WithAnySuffix) const;
FilePaths path() const;
FilePaths pathListValue(const QString &varName) const;

View File

@@ -2173,6 +2173,7 @@ FileFilter::FileFilter(const QStringList &nameFilters,
fileFilters(fileFilters),
iteratorFlags(flags)
{
QTC_CHECK(this->fileFilters != QDir::Filters());
}
QStringList FileFilter::asFindArguments(const QString &path) const

View File

@@ -44,6 +44,7 @@
#include <projectexplorer/kitaspects.h>
#include <projectexplorer/kitmanager.h>
#include <projectexplorer/project.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/projectmanager.h>
#include <projectexplorer/target.h>

View File

@@ -9,6 +9,7 @@
#include <projectexplorer/kitmanager.h>
#include <projectexplorer/toolchainmanager.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <utils/environment.h>
@@ -93,7 +94,8 @@ void AndroidToolChain::addToEnvironment(Environment &env) const
if (javaHome.exists()) {
env.set(Constants::JAVA_HOME_ENV_VAR, javaHome.toUserOutput());
const FilePath javaBin = javaHome.pathAppended("bin");
const FilePath currentJavaFilePath = env.searchInPath("java");
const FilePath currentJavaFilePath
= env.searchInPath("java", {}, {}, FilePath::WithExeSuffix);
if (!currentJavaFilePath.isChildOf(javaBin))
env.prependOrSetPath(javaBin);
}

View File

@@ -231,10 +231,10 @@ ClangModelManagerSupport::ClangModelManagerSupport()
connect(modelManager, &CppModelManager::fallbackProjectPartUpdated, this, [this] {
if (sessionModeEnabled())
return;
if (ClangdClient * const fallbackClient = clientForProject(nullptr)) {
if (ClangdClient * const fallbackClient = clientForProject(nullptr))
LanguageClientManager::shutdownClient(fallbackClient);
if (ClangdSettings::instance().useClangd())
claimNonProjectSources(new ClangdClient(nullptr, {}));
}
});
auto projectManager = ProjectManager::instance();
@@ -251,9 +251,6 @@ ClangModelManagerSupport::ClangModelManagerSupport()
connect(&ClangdSettings::instance(), &ClangdSettings::changed,
this, &ClangModelManagerSupport::onClangdSettingsChanged);
if (ClangdSettings::instance().useClangd())
new ClangdClient(nullptr, {});
new ClangdQuickFixFactory(); // memory managed by CppEditor::g_cppQuickFixFactories
}
@@ -777,8 +774,13 @@ void ClangModelManagerSupport::onEditorOpened(IEditor *editor)
project = nullptr;
else if (!project && ProjectFile::isHeader(document->filePath()))
project = fallbackProject();
if (ClangdClient * const client = clientForProject(project))
LanguageClientManager::openDocumentWithClient(textDocument, client);
ClangdClient *client = clientForProject(project);
if (!client) {
if (project)
return;
client = new ClangdClient(nullptr, {});
}
LanguageClientManager::openDocumentWithClient(textDocument, client);
}
}

View File

@@ -0,0 +1,3 @@
Files taken from the CMake repository https://github.com/vitaut-archive/rstparser.git
49e1e6626ba28357749acfe3bf07c4a19e5bc4ef

View File

@@ -0,0 +1,32 @@
RSTParser
=========
RSTParser is an open-source C++ library for parsing
`reStructuredText <http://docutils.sourceforge.net/rst.html>`__.
License
-------
Copyright (c) 2013, Victor Zverovich
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@@ -0,0 +1,169 @@
/*
reStructuredText parser tests.
Copyright (c) 2012, Victor Zverovich
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <gtest/gtest.h>
#include <stack>
#ifdef _WIN32
# include <crtdbg.h>
#endif
#include "rstparser.h"
namespace {
class TestHandler : public rst::ContentHandler {
private:
std::stack<std::string> tags_;
std::string content_;
public:
const std::string &content() const { return content_; }
void StartBlock(rst::BlockType type) {
std::string tag;
switch (type) {
case rst::PARAGRAPH:
tag = "p";
break;
case rst::LINE_BLOCK:
tag = "lineblock";
break;
case rst::BLOCK_QUOTE:
tag = "blockquote";
break;
case rst::BULLET_LIST:
tag = "ul";
break;
case rst::LIST_ITEM:
tag = "li";
break;
case rst::LITERAL_BLOCK:
tag = "code";
break;
}
content_ += "<" + tag + ">";
tags_.push(tag);
}
void EndBlock() {
content_ += "</" + tags_.top() + ">";
tags_.pop();
}
void HandleText(const char *text, std::size_t size) {
content_.append(text, size);
}
void HandleDirective(const char *type) {
content_ += std::string("<") + type + " />";
}
};
std::string Parse(const char *s) {
TestHandler handler;
rst::Parser parser(&handler);
parser.Parse(s);
return handler.content();
}
}
TEST(ParserTest, Paragraph) {
EXPECT_EQ("<p>test</p>", Parse("test"));
EXPECT_EQ("<p>test</p>", Parse("\ntest"));
EXPECT_EQ("<p>.</p>", Parse("."));
EXPECT_EQ("<p>..test</p>", Parse("..test"));
}
TEST(ParserTest, LineBlock) {
EXPECT_EQ("<lineblock>test</lineblock>", Parse("| test"));
EXPECT_EQ("<lineblock> abc\ndef</lineblock>", Parse("| abc\n| def"));
}
TEST(ParserTest, BlockQuote) {
EXPECT_EQ("<blockquote>test</blockquote>", Parse(" test"));
}
TEST(ParserTest, PreserveInnerSpace) {
EXPECT_EQ("<p>a b</p>", Parse("a b"));
}
TEST(ParserTest, ReplaceWhitespace) {
EXPECT_EQ("<p>a b</p>", Parse("a\tb"));
EXPECT_EQ("<blockquote>a b</blockquote>", Parse(" a\tb"));
EXPECT_EQ("<p>a b</p>", Parse("a\vb"));
}
TEST(ParserTest, StripTrailingSpace) {
EXPECT_EQ("<p>test</p>", Parse("test \t"));
}
TEST(ParserTest, MultiLineBlock) {
EXPECT_EQ("<p>line 1\nline 2</p>", Parse("line 1\nline 2"));
}
TEST(ParserTest, UnindentBlock) {
EXPECT_EQ("<blockquote>abc</blockquote><p>def</p>", Parse(" abc\ndef"));
}
TEST(ParserTest, BulletList) {
EXPECT_EQ("<ul><li>item</li></ul>", Parse("* item"));
EXPECT_EQ("<ul><li>abc\ndef</li></ul>", Parse("* abc\n def"));
}
TEST(ParserTest, Literal) {
EXPECT_EQ("<p>abc:</p><code>def</code>", Parse("abc::\n\n def"));
EXPECT_EQ("<code>abc\ndef</code>", Parse("::\n\n abc\n def"));
EXPECT_EQ("<p>abc\ndef</p>", Parse("::\n\nabc\ndef"));
EXPECT_EQ("<p>::\nabc\ndef</p>", Parse("::\nabc\ndef"));
}
TEST(ParserTest, Comment) {
EXPECT_EQ("", Parse(".."));
EXPECT_EQ("", Parse("..\n"));
EXPECT_EQ("", Parse(".. comment"));
EXPECT_EQ("", Parse(".. comment:"));
}
TEST(ParserTest, Directive) {
EXPECT_EQ("<test />", Parse(".. test::"));
EXPECT_EQ("<test />", Parse(".. test::"));
EXPECT_EQ("<test />", Parse("..\ttest::"));
}
int main(int argc, char **argv) {
#ifdef _WIN32
// Disable message boxes on assertion failures.
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
_CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
#endif
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

View File

@@ -0,0 +1,249 @@
/*
A reStructuredText parser written in C++.
Copyright (c) 2013, Victor Zverovich
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "rstparser.h"
#include <cctype>
#include <cstring>
namespace {
inline bool IsSpace(char c) {
switch (c) {
case ' ': case '\t': case '\v': case '\f':
return true;
}
return false;
}
// Returns true if s ends with string end.
bool EndsWith(const std::string &s, const char *end) {
std::size_t size = s.size(), end_size = std::strlen(end);
return size >= end_size ? std::strcmp(&s[size - end_size], end) == 0 : false;
}
}
rst::ContentHandler::~ContentHandler() {}
void rst::Parser::SkipSpace() {
while (IsSpace(*ptr_))
++ptr_;
}
std::string rst::Parser::ParseDirectiveType() {
const char *s = ptr_;
if (!std::isalnum(*s))
return std::string();
for (;;) {
++s;
if (std::isalnum(*s))
continue;
switch (*s) {
case '-': case '_': case '+': case ':': case '.':
if (std::isalnum(s[1])) {
++s;
continue;
}
// Fall through.
}
break;
}
std::string type;
if (s != ptr_)
type.assign(ptr_, s);
ptr_ = s;
return type;
}
void rst::Parser::EnterBlock(rst::BlockType &prev_type, rst::BlockType type) {
if (type == prev_type)
return;
if (prev_type == LIST_ITEM)
handler_->EndBlock();
if (type == LIST_ITEM)
handler_->StartBlock(BULLET_LIST);
prev_type = type;
}
void rst::Parser::ParseBlock(
rst::BlockType type, rst::BlockType &prev_type, int indent) {
std::string text;
for (bool first = true; ; first = false) {
const char *line_start = ptr_;
if (!first) {
// Check indentation.
SkipSpace();
if (ptr_ - line_start != indent)
break;
if (*ptr_ == '\n') {
++ptr_;
break; // Empty line ends the block.
}
if (!*ptr_)
break; // End of input.
}
// Strip indentation.
line_start = ptr_;
// Find the end of the line.
while (*ptr_ && *ptr_ != '\n')
++ptr_;
// Strip whitespace at the end of the line.
const char *end = ptr_;
while (end != line_start && IsSpace(end[-1]))
--end;
// Copy text converting all whitespace characters to spaces.
text.reserve(end - line_start + 1);
if (!first)
text.push_back('\n');
enum {TAB_WIDTH = 8};
for (const char *s = line_start; s != end; ++s) {
char c = *s;
if (c == '\t') {
text.append(" ",
TAB_WIDTH - ((indent + s - line_start) % TAB_WIDTH));
} else if (IsSpace(c)) {
text.push_back(' ');
} else {
text.push_back(*s);
}
}
if (*ptr_ == '\n')
++ptr_;
}
// Remove a trailing newline.
if (*text.rbegin() == '\n')
text.resize(text.size() - 1);
bool literal = type == PARAGRAPH && EndsWith(text, "::");
if (!literal || text.size() != 2) {
std::size_t size = text.size();
if (literal)
--size;
EnterBlock(prev_type, type);
handler_->StartBlock(type);
handler_->HandleText(text.c_str(), size);
handler_->EndBlock();
}
if (literal) {
// Parse a literal block.
const char *line_start = ptr_;
SkipSpace();
int new_indent = static_cast<int>(ptr_ - line_start);
if (new_indent > indent)
ParseBlock(LITERAL_BLOCK, prev_type, new_indent);
}
}
void rst::Parser::ParseLineBlock(rst::BlockType &prev_type, int indent) {
std::string text;
for (bool first = true; ; first = false) {
const char *line_start = ptr_;
if (!first) {
// Check indentation.
SkipSpace();
if (*ptr_ != '|' || !IsSpace(ptr_[1]) || ptr_ - line_start != indent)
break;
ptr_ += 2;
if (!*ptr_)
break; // End of input.
}
// Strip indentation.
line_start = ptr_;
// Find the end of the line.
while (*ptr_ && *ptr_ != '\n')
++ptr_;
if (*ptr_ == '\n')
++ptr_;
text.append(line_start, ptr_);
}
EnterBlock(prev_type, rst::LINE_BLOCK);
handler_->StartBlock(rst::LINE_BLOCK);
handler_->HandleText(text.c_str(), text.size());
handler_->EndBlock();
}
void rst::Parser::Parse(const char *s) {
BlockType prev_type = PARAGRAPH;
ptr_ = s;
while (*ptr_) {
// Skip whitespace and empty lines.
const char *line_start = ptr_;
SkipSpace();
if (*ptr_ == '\n') {
++ptr_;
continue;
}
switch (*ptr_) {
case '.':
if (ptr_[1] == '.') {
char c = ptr_[2];
if (!IsSpace(c) && c != '\n' && c)
break;
// Parse a directive or a comment.
ptr_ += 2;
SkipSpace();
std::string type = ParseDirectiveType();
if (!type.empty() && ptr_[0] == ':' && ptr_[1] == ':') {
ptr_ += 2;
handler_->HandleDirective(type.c_str());
}
// Skip everything till the end of the line.
while (*ptr_ && *ptr_ != '\n')
++ptr_;
if (*ptr_ == '\n')
++ptr_;
continue;
}
break;
case '*': case '+': case '-':
if (IsSpace(ptr_[1])) {
// Parse a bullet list item.
ptr_ += 2;
ParseBlock(LIST_ITEM, prev_type, static_cast<int>(ptr_ - line_start));
continue;
}
break;
case '|':
if (IsSpace(ptr_[1])) {
// Parse a line block.
int indent = static_cast<int>(ptr_ - line_start);
ptr_ += 2;
ParseLineBlock(prev_type, indent);
continue;
}
break;
}
ParseBlock(std::isspace(line_start[0]) ? BLOCK_QUOTE : PARAGRAPH,
prev_type, static_cast<int>(ptr_ - line_start));
}
EnterBlock(prev_type, PARAGRAPH);
}

View File

@@ -0,0 +1,97 @@
/*
A reStructuredText parser written in C++.
Copyright (c) 2013, Victor Zverovich
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef RSTPARSER_H_
#define RSTPARSER_H_
#include <memory>
#include <string>
#include <vector>
namespace rst {
enum BlockType {
PARAGRAPH,
LINE_BLOCK,
BLOCK_QUOTE,
BULLET_LIST,
LIST_ITEM,
LITERAL_BLOCK
};
// Receive notification of the logical content of a document.
class ContentHandler {
public:
virtual ~ContentHandler();
// Receives notification of the beginning of a text block.
virtual void StartBlock(BlockType type) = 0;
// Receives notification of the end of a text block.
virtual void EndBlock() = 0;
// Receives notification of text.
virtual void HandleText(const char *text, std::size_t size) = 0;
// Receives notification of a directive.
virtual void HandleDirective(const char *type) = 0;
};
// A parser for a subset of reStructuredText.
class Parser {
private:
ContentHandler *handler_;
const char *ptr_;
// Skips whitespace.
void SkipSpace();
// Parses a directive type.
std::string ParseDirectiveType();
// Parses a paragraph.
void ParseParagraph();
// Changes the current block type sending notifications if necessary.
void EnterBlock(rst::BlockType &prev_type, rst::BlockType type);
// Parses a block of text.
void ParseBlock(rst::BlockType type, rst::BlockType &prev_type, int indent);
// Parses a line block.
void ParseLineBlock(rst::BlockType &prev_type, int indent);
public:
explicit Parser(ContentHandler *h) : handler_(h), ptr_(0) {}
// Parses a string containing reStructuredText and returns a document node.
void Parse(const char *s);
};
}
#endif // RSTPARSER_H_

View File

@@ -1278,9 +1278,9 @@ void CMakeBuildSystem::setupCMakeSymbolsHash()
m_cmakeSymbolsHash.insert(QString::fromUtf8(arg.Value), link);
if (func.LowerCaseName() == "option")
m_projectKeywords.variables << QString::fromUtf8(arg.Value);
m_projectKeywords.variables[QString::fromUtf8(arg.Value)] = FilePath();
else
m_projectKeywords.functions << QString::fromUtf8(arg.Value);
m_projectKeywords.functions[QString::fromUtf8(arg.Value)] = FilePath();
}
}
}

View File

@@ -9,6 +9,7 @@
#include "cmakefilecompletionassist.h"
#include "cmakeindenter.h"
#include "cmakekitaspect.h"
#include "cmakeproject.h"
#include "cmakeprojectconstants.h"
#include "3rdparty/cmake/cmListFileCache.h"
@@ -19,11 +20,14 @@
#include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/buildsystem.h>
#include <projectexplorer/project.h>
#include <projectexplorer/projectmanager.h>
#include <projectexplorer/projecttree.h>
#include <projectexplorer/target.h>
#include <texteditor/basehoverhandler.h>
#include <texteditor/textdocument.h>
#include <texteditor/texteditoractionhandler.h>
#include <utils/textutils.h>
#include <utils/tooltip/tooltip.h>
#include <QTextDocument>
@@ -31,6 +35,7 @@
using namespace Core;
using namespace ProjectExplorer;
using namespace Utils;
using namespace TextEditor;
namespace CMakeProjectManager::Internal {
@@ -308,6 +313,83 @@ static TextDocument *createCMakeDocument()
return doc;
}
//
// CMakeHoverHandler
//
class CMakeHoverHandler : public TextEditor::BaseHoverHandler
{
mutable CMakeKeywords m_keywords;
QString m_helpToolTip;
public:
const CMakeKeywords &keywords() const;
void identifyMatch(TextEditor::TextEditorWidget *editorWidget,
int pos,
ReportPriority report) final;
void operateTooltip(TextEditorWidget *editorWidget, const QPoint &point) final;
};
const CMakeKeywords &CMakeHoverHandler::keywords() const
{
if (m_keywords.functions.isEmpty()) {
CMakeTool *tool = nullptr;
if (auto bs = ProjectTree::currentBuildSystem())
tool = CMakeKitAspect::cmakeTool(bs->target()->kit());
if (!tool)
tool = CMakeToolManager::defaultCMakeTool();
if (tool)
m_keywords = tool->keywords();
}
return m_keywords;
}
QString readFirstParagraphs(const QString &element, const FilePath &helpFile);
void CMakeHoverHandler::identifyMatch(TextEditor::TextEditorWidget *editorWidget,
int pos,
ReportPriority report)
{
const QScopeGuard cleanup([this, report] { report(priority()); });
QTextCursor cursor = editorWidget->textCursor();
cursor.setPosition(pos);
const QString word = Utils::Text::wordUnderCursor(cursor);
FilePath helpFile;
for (const auto &map : {keywords().functions,
keywords().variables,
keywords().directoryProperties,
keywords().sourceProperties,
keywords().targetProperties,
keywords().testProperties,
keywords().properties,
keywords().includeStandardModules,
keywords().findModules,
keywords().policies}) {
if (map.contains(word)) {
helpFile = map.value(word);
break;
}
}
m_helpToolTip.clear();
if (!helpFile.isEmpty())
m_helpToolTip = readFirstParagraphs(word, helpFile);
setPriority(m_helpToolTip.isEmpty() ? Priority_Tooltip : Priority_None);
}
void CMakeHoverHandler::operateTooltip(TextEditorWidget *editorWidget, const QPoint &point)
{
if (!m_helpToolTip.isEmpty())
Utils::ToolTip::show(point, m_helpToolTip, Qt::MarkdownText, editorWidget);
else
Utils::ToolTip::hide();
}
//
// CMakeEditorFactory
//
@@ -334,6 +416,8 @@ CMakeEditorFactory::CMakeEditorFactory()
| TextEditorActionHandler::FollowSymbolUnderCursor
| TextEditorActionHandler::Format);
addHoverHandler(new CMakeHoverHandler);
ActionContainer *contextMenu = ActionManager::createMenu(Constants::M_CONTEXT);
contextMenu->addAction(ActionManager::command(TextEditor::Constants::FOLLOW_SYMBOL_UNDER_CURSOR));
contextMenu->addSeparator(Context(Constants::CMAKE_EDITOR_ID));

View File

@@ -153,6 +153,40 @@ QList<AssistProposalItemInterface *> generateList(const T &words, const QIcon &i
});
}
QString readFirstParagraphs(const QString &element, const FilePath &helpFile)
{
static QMap<FilePath, QString> map;
if (map.contains(helpFile))
return map.value(helpFile);
auto content = helpFile.fileContents(1024).value_or(QByteArray());
const QString firstParagraphs
= QString("```\n%1\n```").arg(QString::fromUtf8(content.left(content.lastIndexOf("\n"))));
map[helpFile] = firstParagraphs;
return firstParagraphs;
}
QList<AssistProposalItemInterface *> generateList(const QMap<QString, FilePath> &words,
const QIcon &icon)
{
struct MarkDownAssitProposalItem : public AssistProposalItem
{
Qt::TextFormat detailFormat() const { return Qt::MarkdownText; }
};
QList<AssistProposalItemInterface *> list;
for (auto it = words.cbegin(); it != words.cend(); ++it) {
MarkDownAssitProposalItem *item = new MarkDownAssitProposalItem();
item->setText(it.key());
if (!it.value().isEmpty())
item->setDetail(readFirstParagraphs(it.key(), it.value()));
item->setIcon(icon);
list << item;
};
return list;
}
static int addFilePathItems(const AssistInterface *interface,
QList<AssistProposalItemInterface *> &items,
int symbolStartPos)

View File

@@ -89,19 +89,8 @@ public:
bool m_didRun = true;
QList<CMakeTool::Generator> m_generators;
QMap<QString, QStringList> m_functionArgs;
CMakeKeywords m_keywords;
QVector<FileApi> m_fileApis;
QStringList m_variables;
QStringList m_functions;
QStringList m_properties;
QStringList m_generatorExpressions;
QStringList m_directoryProperties;
QStringList m_sourceProperties;
QStringList m_targetProperties;
QStringList m_testProperties;
QStringList m_includeStandardModules;
QStringList m_findModules;
QStringList m_policies;
CMakeTool::Version m_version;
};
@@ -260,7 +249,7 @@ CMakeKeywords CMakeTool::keywords()
if (!isValid())
return {};
if (m_introspection->m_functions.isEmpty() && m_introspection->m_didRun) {
if (m_introspection->m_keywords.functions.isEmpty() && m_introspection->m_didRun) {
Process proc;
const FilePath findCMakeRoot = TemporaryDirectory::masterDirectoryFilePath()
@@ -279,61 +268,52 @@ CMakeKeywords CMakeTool::keywords()
const struct
{
const QString helpPath;
QStringList &targetList;
QMap<QString, FilePath> &targetMap;
} introspections[] = {
// Functions
{"Help/command", m_introspection->m_functions},
{"Help/command", m_introspection->m_keywords.functions},
// Properties
{"Help/prop_dir", m_introspection->m_directoryProperties},
{"Help/prop_sf", m_introspection->m_sourceProperties},
{"Help/prop_test", m_introspection->m_testProperties},
{"Help/prop_tgt", m_introspection->m_targetProperties},
{"Help/prop_gbl", m_introspection->m_properties},
{"Help/prop_dir", m_introspection->m_keywords.directoryProperties},
{"Help/prop_sf", m_introspection->m_keywords.sourceProperties},
{"Help/prop_test", m_introspection->m_keywords.testProperties},
{"Help/prop_tgt", m_introspection->m_keywords.targetProperties},
{"Help/prop_gbl", m_introspection->m_keywords.properties},
// Variables
{"Help/variable", m_introspection->m_variables},
{"Help/variable", m_introspection->m_keywords.variables},
// Policies
{"Help/policy", m_introspection->m_policies},
{"Help/policy", m_introspection->m_keywords.policies},
};
for (auto &i : introspections) {
const FilePaths files = cmakeRoot.pathAppended(i.helpPath)
.dirEntries({{"*.rst"}, QDir::Files}, QDir::Name);
i.targetList = transform<QStringList>(files, &FilePath::completeBaseName);
for (const auto &filePath : files)
i.targetMap[filePath.completeBaseName()] = filePath;
}
m_introspection->m_properties << m_introspection->m_directoryProperties;
m_introspection->m_properties << m_introspection->m_sourceProperties;
m_introspection->m_properties << m_introspection->m_testProperties;
m_introspection->m_properties << m_introspection->m_targetProperties;
for (const auto &map : {m_introspection->m_keywords.directoryProperties,
m_introspection->m_keywords.sourceProperties,
m_introspection->m_keywords.testProperties,
m_introspection->m_keywords.targetProperties}) {
m_introspection->m_keywords.properties.insert(map);
}
// Modules
const FilePaths files
= cmakeRoot.pathAppended("Help/module").dirEntries({{"*.rst"}, QDir::Files}, QDir::Name);
const QStringList fileNames = transform<QStringList>(files, &FilePath::completeBaseName);
for (const QString &fileName : fileNames) {
for (const FilePath &filePath : files) {
const QString fileName = filePath.completeBaseName();
if (fileName.startsWith("Find"))
m_introspection->m_findModules << fileName.mid(4);
m_introspection->m_keywords.findModules[fileName.mid(4)] = filePath;
else
m_introspection->m_includeStandardModules << fileName;
m_introspection->m_keywords.includeStandardModules[fileName] = filePath;
}
parseSyntaxHighlightingXml();
const QStringList moduleFunctions = parseSyntaxHighlightingXml();
for (const auto &function : moduleFunctions)
m_introspection->m_keywords.functions[function] = FilePath();
}
CMakeKeywords keywords;
keywords.functions = Utils::toSet(m_introspection->m_functions);
keywords.variables = Utils::toSet(m_introspection->m_variables);
keywords.functionArgs = m_introspection->m_functionArgs;
keywords.properties = Utils::toSet(m_introspection->m_properties);
keywords.generatorExpressions = Utils::toSet(m_introspection->m_generatorExpressions);
keywords.directoryProperties = Utils::toSet(m_introspection->m_directoryProperties);
keywords.sourceProperties = Utils::toSet(m_introspection->m_sourceProperties);
keywords.targetProperties = Utils::toSet(m_introspection->m_targetProperties);
keywords.testProperties = Utils::toSet(m_introspection->m_testProperties);
keywords.includeStandardModules = Utils::toSet(m_introspection->m_includeStandardModules);
keywords.findModules = Utils::toSet(m_introspection->m_findModules);
keywords.policies = Utils::toSet(m_introspection->m_policies);
return keywords;
return m_introspection->m_keywords;
}
bool CMakeTool::hasFileApi(bool ignoreCache) const
@@ -495,8 +475,6 @@ static QStringList parseDefinition(const QString &definition)
void CMakeTool::parseFunctionDetailsOutput(const QString &output)
{
const QSet<QString> functionSet = Utils::toSet(m_introspection->m_functions);
bool expectDefinition = false;
QString currentDefinition;
@@ -515,14 +493,15 @@ void CMakeTool::parseFunctionDetailsOutput(const QString &output)
QStringList words = parseDefinition(currentDefinition);
if (!words.isEmpty()) {
const QString command = words.takeFirst();
if (functionSet.contains(command)) {
if (m_introspection->m_keywords.functions.contains(command)) {
const QStringList tmp = Utils::sorted(
words + m_introspection->m_functionArgs[command]);
m_introspection->m_functionArgs[command] = Utils::filteredUnique(tmp);
words + m_introspection->m_keywords.functionArgs[command]);
m_introspection->m_keywords.functionArgs[command] = Utils::filteredUnique(
tmp);
}
}
if (!words.isEmpty() && functionSet.contains(words.at(0)))
m_introspection->m_functionArgs[words.at(0)];
if (!words.isEmpty() && m_introspection->m_keywords.functions.contains(words.at(0)))
m_introspection->m_keywords.functionArgs[words.at(0)];
currentDefinition.clear();
} else {
currentDefinition.append(line.trimmed() + ' ');
@@ -560,9 +539,9 @@ QStringList CMakeTool::parseVariableOutput(const QString &output)
return result;
}
void CMakeTool::parseSyntaxHighlightingXml()
QStringList CMakeTool::parseSyntaxHighlightingXml()
{
QSet<QString> functionSet = Utils::toSet(m_introspection->m_functions);
QStringList moduleFunctions;
const FilePath cmakeXml = Core::ICore::resourcePath("generic-highlighter/syntax/cmake.xml");
QXmlStreamReader reader(cmakeXml.fileContents().value_or(QByteArray()));
@@ -588,19 +567,19 @@ void CMakeTool::parseSyntaxHighlightingXml()
const auto functionName = name.left(name.length() - 6);
QStringList arguments = readItemList(reader);
if (m_introspection->m_functionArgs.contains(functionName))
arguments.append(m_introspection->m_functionArgs.value(functionName));
if (m_introspection->m_keywords.functionArgs.contains(functionName))
arguments.append(
m_introspection->m_keywords.functionArgs.value(functionName));
m_introspection->m_functionArgs[functionName] = arguments;
m_introspection->m_keywords.functionArgs[functionName] = arguments;
// Functions that are part of CMake modules like ExternalProject_Add
// which are not reported by cmake --help-list-commands
if (!functionSet.contains(functionName)) {
functionSet.insert(functionName);
m_introspection->m_functions.append(functionName);
if (!m_introspection->m_keywords.functions.contains(functionName)) {
moduleFunctions << functionName;
}
} else if (name == u"generator-expressions") {
m_introspection->m_generatorExpressions = readItemList(reader);
m_introspection->m_keywords.generatorExpressions = toSet(readItemList(reader));
} else {
reader.skipCurrentElement();
}
@@ -623,16 +602,19 @@ void CMakeTool::parseSyntaxHighlightingXml()
{"set_target_properties", "set_directory_properties"},
{"set_tests_properties", "set_directory_properties"}};
for (const auto &pair : std::as_const(functionPairs)) {
if (!m_introspection->m_functionArgs.contains(pair.first))
m_introspection->m_functionArgs[pair.first] = m_introspection->m_functionArgs.value(
pair.second);
if (!m_introspection->m_keywords.functionArgs.contains(pair.first))
m_introspection->m_keywords.functionArgs[pair.first]
= m_introspection->m_keywords.functionArgs.value(pair.second);
}
// Special case for cmake_print_variables, which will print the names and values for variables
// and needs to be as a known function
const QString cmakePrintVariables("cmake_print_variables");
m_introspection->m_functionArgs[cmakePrintVariables] = {};
m_introspection->m_functions.append(cmakePrintVariables);
m_introspection->m_keywords.functionArgs[cmakePrintVariables] = {};
moduleFunctions << cmakePrintVariables;
moduleFunctions.removeDuplicates();
return moduleFunctions;
}
void CMakeTool::fetchFromCapabilities(bool ignoreCache) const

View File

@@ -21,17 +21,17 @@ namespace Internal { class IntrospectionData; }
struct CMAKE_EXPORT CMakeKeywords
{
QSet<QString> variables;
QSet<QString> functions;
QSet<QString> properties;
QMap<QString, Utils::FilePath> variables;
QMap<QString, Utils::FilePath> functions;
QMap<QString, Utils::FilePath> properties;
QSet<QString> generatorExpressions;
QSet<QString> directoryProperties;
QSet<QString> sourceProperties;
QSet<QString> targetProperties;
QSet<QString> testProperties;
QSet<QString> includeStandardModules;
QSet<QString> findModules;
QSet<QString> policies;
QMap<QString, Utils::FilePath> directoryProperties;
QMap<QString, Utils::FilePath> sourceProperties;
QMap<QString, Utils::FilePath> targetProperties;
QMap<QString, Utils::FilePath> testProperties;
QMap<QString, Utils::FilePath> includeStandardModules;
QMap<QString, Utils::FilePath> findModules;
QMap<QString, Utils::FilePath> policies;
QMap<QString, QStringList> functionArgs;
};
@@ -117,7 +117,7 @@ private:
void runCMake(Utils::Process &proc, const QStringList &args, int timeoutS = 1) const;
void parseFunctionDetailsOutput(const QString &output);
QStringList parseVariableOutput(const QString &output);
void parseSyntaxHighlightingXml();
QStringList parseSyntaxHighlightingXml();
void fetchFromCapabilities(bool ignoreCache = false) const;
void parseFromCapabilities(const QString &input) const;

View File

@@ -1,5 +1,5 @@
add_qtc_plugin(CompilerExplorer
PLUGIN_DEPENDS Core TextEditor
PLUGIN_DEPENDS Core ProjectExplorer TextEditor
DEPENDS Qt::Network TerminalLib Spinner
SOURCES
api/config.h
@@ -14,6 +14,8 @@ add_qtc_plugin(CompilerExplorer
api/library.h
api/request.h
compilerexplorer.qrc
compilerexploreraspects.cpp
compilerexploreraspects.h
compilerexplorerplugin.cpp

View File

@@ -4,6 +4,7 @@ QtcPlugin {
name: "CompilerExplorer"
Depends { name: "Core" }
Depends { name: "ProjectExplorer" }
Depends { name: "Spinner" }
Depends { name: "TerminalLib" }
Depends { name: "TextEditor" }
@@ -22,6 +23,8 @@ QtcPlugin {
"api/library.h",
"api/request.h",
"compilerexplorer.qrc",
"compilerexploreraspects.cpp",
"compilerexploreraspects.h",
"compilerexplorerconstants.h",

View File

@@ -0,0 +1,8 @@
<RCC>
<qresource prefix="/compilerexplorer/wizard/">
<file>wizard/cpp/wizard.json</file>
<file>wizard/cpp/file.qtce</file>
<file>wizard/python/wizard.json</file>
<file>wizard/python/file.qtce</file>
</qresource>
</RCC>

View File

@@ -107,8 +107,11 @@ JsonSettingsDocument::JsonSettingsDocument(QUndoStack *undoStack)
{
setId(Constants::CE_EDITOR_ID);
setMimeType("application/compiler-explorer");
connect(&m_ceSettings, &CompilerExplorerSettings::changed, this, [this] { emit changed(); });
m_ceSettings.setAutoApply(true);
connect(&m_ceSettings, &CompilerExplorerSettings::changed, this, [this] {
emit changed();
emit contentsChanged();
});
m_ceSettings.setAutoApply(false);
m_ceSettings.setUndoStack(undoStack);
}
@@ -133,6 +136,8 @@ Core::IDocument::OpenResult JsonSettingsDocument::open(QString *errorString,
return OpenResult::ReadError;
}
setFilePath(filePath);
m_ceSettings.fromMap(*result);
emit settingsChanged();
return OpenResult::Success;
@@ -157,8 +162,10 @@ bool JsonSettingsDocument::saveImpl(QString *errorString, const FilePath &newFil
Utils::FilePath path = newFilePath.isEmpty() ? filePath() : newFilePath;
if (!newFilePath.isEmpty() && !autoSave)
if (!newFilePath.isEmpty() && !autoSave) {
setPreferredDisplayName({});
setFilePath(newFilePath);
}
auto result = path.writeFileContents(jsonFromStore(store));
if (!result && errorString) {
@@ -166,6 +173,7 @@ bool JsonSettingsDocument::saveImpl(QString *errorString, const FilePath &newFil
return false;
}
emit changed();
return true;
}
@@ -182,6 +190,8 @@ bool JsonSettingsDocument::setContents(const QByteArray &contents)
m_ceSettings.fromMap(*result);
emit settingsChanged();
emit changed();
emit contentsChanged();
return true;
}
@@ -313,11 +323,6 @@ CompilerWidget::CompilerWidget(const std::shared_ptr<SourceSettings> &sourceSett
m_spinner = new SpinnerSolution::Spinner(SpinnerSolution::SpinnerSize::Large, this);
}
CompilerWidget::~CompilerWidget()
{
qDebug() << "Good bye!";
}
Core::SearchableTerminal *CompilerWidget::createTerminal()
{
m_resultTerminal = new Core::SearchableTerminal();
@@ -467,172 +472,31 @@ EditorWidget::EditorWidget(const QSharedPointer<JsonSettingsDocument> &document,
QWidget *parent)
: Utils::FancyMainWindow(parent)
, m_document(document)
, m_undoStack(undoStack)
, m_actionHandler(actionHandler)
{
setAutoHideTitleBars(false);
setDockNestingEnabled(true);
setDocumentMode(true);
setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::TabPosition::South);
document->setWindowStateCallback([this] {
auto settings = saveSettings();
QVariantMap result;
document->setWindowStateCallback([this] { return windowStateCallback(); });
for (const auto &key : settings.keys()) {
// QTBUG-116339
if (key != "State") {
result.insert(key, settings.value(key));
} else {
QVariantMap m;
m["type"] = "Base64";
m["value"] = settings.value(key).toByteArray().toBase64();
result.insert(key, m);
}
}
document->settings()->m_sources.setItemAddedCallback<SourceSettings>(
[this](const std::shared_ptr<SourceSettings> &source) { addSourceEditor(source); });
return result;
document->settings()->m_sources.setItemRemovedCallback<SourceSettings>(
[this](const std::shared_ptr<SourceSettings> &source) { removeSourceEditor(source); });
connect(document.get(),
&JsonSettingsDocument::settingsChanged,
this,
&EditorWidget::recreateEditors);
connect(this, &EditorWidget::gotFocus, this, [&actionHandler] {
actionHandler.updateCurrentEditor();
});
auto addCompiler = [this,
&actionHandler](const std::shared_ptr<SourceSettings> &sourceSettings,
const std::shared_ptr<CompilerSettings> &compilerSettings,
int idx) {
auto compiler = new CompilerWidget(sourceSettings, compilerSettings);
compiler->setWindowTitle("Compiler #" + QString::number(idx));
compiler->setObjectName("compiler_" + QString::number(idx));
QDockWidget *dockWidget = addDockForWidget(compiler);
addDockWidget(Qt::RightDockWidgetArea, dockWidget);
m_compilerWidgets.append(dockWidget);
connect(compiler,
&CompilerWidget::remove,
this,
[sourceSettings = sourceSettings.get(), compilerSettings = compilerSettings.get()] {
sourceSettings->compilers.removeItem(compilerSettings->shared_from_this());
});
connect(compiler, &CompilerWidget::gotFocus, this, [&actionHandler] {
actionHandler.updateCurrentEditor();
});
};
auto addSourceEditor = [this, &actionHandler, document = document.get(), addCompiler, undoStack](
const std::shared_ptr<SourceSettings> &sourceSettings) {
auto sourceEditor = new SourceEditorWidget(sourceSettings, undoStack);
sourceEditor->setWindowTitle("Source Code #" + QString::number(m_sourceWidgets.size() + 1));
sourceEditor->setObjectName("source_code_editor_"
+ QString::number(m_sourceWidgets.size() + 1));
QDockWidget *dockWidget = addDockForWidget(sourceEditor);
connect(sourceEditor,
&SourceEditorWidget::remove,
this,
[document, sourceSettings = sourceSettings.get()] {
document->settings()->m_sources.removeItem(sourceSettings->shared_from_this());
});
connect(sourceEditor, &SourceEditorWidget::addCompiler, this, [sourceSettings] {
auto newCompiler = std::make_shared<CompilerSettings>(
sourceSettings->apiConfigFunction());
newCompiler->setLanguageId(sourceSettings->languageId());
sourceSettings->compilers.addItem(newCompiler);
});
connect(sourceEditor, &SourceEditorWidget::gotFocus, this, [&actionHandler] {
actionHandler.updateCurrentEditor();
});
addDockWidget(Qt::LeftDockWidgetArea, dockWidget);
sourceSettings->compilers.forEachItem<CompilerSettings>(
[addCompiler, sourceSettings](const std::shared_ptr<CompilerSettings> &compilerSettings,
int idx) {
addCompiler(sourceSettings, compilerSettings, idx + 1);
});
sourceSettings->compilers.setItemAddedCallback<CompilerSettings>(
[addCompiler, sourceSettings = sourceSettings.get()](
const std::shared_ptr<CompilerSettings> &compilerSettings) {
addCompiler(sourceSettings->shared_from_this(),
compilerSettings,
sourceSettings->compilers.size());
});
sourceSettings->compilers.setItemRemovedCallback<CompilerSettings>(
[this](const std::shared_ptr<CompilerSettings> &compilerSettings) {
auto it = std::find_if(m_compilerWidgets.begin(),
m_compilerWidgets.end(),
[compilerSettings](const QDockWidget *c) {
return static_cast<CompilerWidget *>(c->widget())
->m_compilerSettings
== compilerSettings;
});
QTC_ASSERT(it != m_compilerWidgets.end(), return);
delete *it;
m_compilerWidgets.erase(it);
});
/*Aggregate *agg = Aggregate::parentAggregate(sourceEditor);
if (!agg) {
agg = new Aggregate;
agg->add(sourceEditor);
}
agg->add(this);
setFocusProxy(sourceEditor);
*/
m_sourceWidgets.append(dockWidget);
};
auto removeSourceEditor = [this](const std::shared_ptr<SourceSettings> &sourceSettings) {
auto it = std::find_if(m_sourceWidgets.begin(),
m_sourceWidgets.end(),
[sourceSettings](const QDockWidget *c) {
return static_cast<SourceEditorWidget *>(c->widget())
->sourceSettings()
== sourceSettings.get();
});
QTC_ASSERT(it != m_sourceWidgets.end(), return);
delete *it;
m_sourceWidgets.erase(it);
};
auto recreateEditors = [this, addSourceEditor]() {
qDeleteAll(m_sourceWidgets);
qDeleteAll(m_compilerWidgets);
m_sourceWidgets.clear();
m_compilerWidgets.clear();
m_document->settings()->m_sources.forEachItem<SourceSettings>(addSourceEditor);
QVariantMap windowState = m_document->settings()->windowState.value();
if (!windowState.isEmpty()) {
QHash<QString, QVariant> hashMap;
for (const auto &key : windowState.keys()) {
if (key != "State")
hashMap.insert(key, windowState.value(key));
else {
QVariant v = windowState.value(key);
if (v.userType() == QMetaType::QByteArray) {
hashMap.insert(key, v);
} else if (v.userType() == QMetaType::QVariantMap) {
QVariantMap m = v.toMap();
if (m.value("type") == "Base64") {
hashMap.insert(key,
QByteArray::fromBase64(m.value("value").toByteArray()));
}
}
}
}
restoreSettings(hashMap);
}
};
document->settings()->m_sources.setItemAddedCallback<SourceSettings>(addSourceEditor);
document->settings()->m_sources.setItemRemovedCallback<SourceSettings>(removeSourceEditor);
connect(document.get(), &JsonSettingsDocument::settingsChanged, this, recreateEditors);
m_context = new Core::IContext(this);
m_context->setWidget(this);
m_context->setContext(Core::Context(Constants::CE_EDITOR_CONTEXT_ID));
@@ -645,6 +509,203 @@ EditorWidget::~EditorWidget()
m_sourceWidgets.clear();
}
void EditorWidget::focusInEvent(QFocusEvent *event)
{
emit gotFocus();
FancyMainWindow::focusInEvent(event);
}
void EditorWidget::addCompiler(const std::shared_ptr<SourceSettings> &sourceSettings,
const std::shared_ptr<CompilerSettings> &compilerSettings,
int idx,
QDockWidget *parentDockWidget)
{
auto compiler = new CompilerWidget(sourceSettings, compilerSettings);
compiler->setWindowTitle("Compiler #" + QString::number(idx));
compiler->setObjectName("compiler_" + QString::number(idx));
QDockWidget *dockWidget = addDockForWidget(compiler, parentDockWidget);
addDockWidget(Qt::RightDockWidgetArea, dockWidget);
m_compilerWidgets.append(dockWidget);
connect(compiler,
&CompilerWidget::remove,
this,
[sourceSettings = sourceSettings.get(), compilerSettings = compilerSettings.get()] {
sourceSettings->compilers.removeItem(compilerSettings->shared_from_this());
});
connect(compiler, &CompilerWidget::gotFocus, this, [this]() {
m_actionHandler.updateCurrentEditor();
});
}
QVariantMap EditorWidget::windowStateCallback()
{
auto settings = saveSettings();
QVariantMap result;
for (const auto &key : settings.keys()) {
// QTBUG-116339
if (key != "State") {
result.insert(key, settings.value(key));
} else {
QVariantMap m;
m["type"] = "Base64";
m["value"] = settings.value(key).toByteArray().toBase64();
result.insert(key, m);
}
}
return result;
}
void EditorWidget::addSourceEditor(const std::shared_ptr<SourceSettings> &sourceSettings)
{
auto sourceEditor = new SourceEditorWidget(sourceSettings, m_undoStack);
sourceEditor->setWindowTitle("Source Code #" + QString::number(m_sourceWidgets.size() + 1));
sourceEditor->setObjectName("source_code_editor_" + QString::number(m_sourceWidgets.size() + 1));
QDockWidget *dockWidget = addDockForWidget(sourceEditor);
connect(sourceEditor, &SourceEditorWidget::remove, this, [this, sourceSettings]() {
m_undoStack->beginMacro("Remove source");
sourceSettings->compilers.clear();
m_document->settings()->m_sources.removeItem(sourceSettings->shared_from_this());
m_undoStack->endMacro();
setupHelpWidget();
});
connect(sourceEditor, &SourceEditorWidget::addCompiler, this, [sourceSettings]() {
auto newCompiler = std::make_shared<CompilerSettings>(sourceSettings->apiConfigFunction());
newCompiler->setLanguageId(sourceSettings->languageId());
sourceSettings->compilers.addItem(newCompiler);
});
connect(sourceEditor, &SourceEditorWidget::gotFocus, this, [this]() {
m_actionHandler.updateCurrentEditor();
});
addDockWidget(Qt::LeftDockWidgetArea, dockWidget);
sourceSettings->compilers.forEachItem<CompilerSettings>(
[this, sourceSettings, dockWidget](const std::shared_ptr<CompilerSettings> &compilerSettings,
int idx) {
addCompiler(sourceSettings, compilerSettings, idx + 1, dockWidget);
});
sourceSettings->compilers.setItemAddedCallback<CompilerSettings>(
[this, sourceSettings, dockWidget](
const std::shared_ptr<CompilerSettings> &compilerSettings) {
addCompiler(sourceSettings->shared_from_this(),
compilerSettings,
sourceSettings->compilers.size(),
dockWidget);
});
sourceSettings->compilers.setItemRemovedCallback<CompilerSettings>(
[this, sourceSettings](const std::shared_ptr<CompilerSettings> &compilerSettings) {
auto it = std::find_if(m_compilerWidgets.begin(),
m_compilerWidgets.end(),
[compilerSettings](const QDockWidget *c) {
return static_cast<CompilerWidget *>(c->widget())
->m_compilerSettings
== compilerSettings;
});
QTC_ASSERT(it != m_compilerWidgets.end(), return);
delete *it;
m_compilerWidgets.erase(it);
});
m_sourceWidgets.append(dockWidget);
setupHelpWidget();
}
void EditorWidget::removeSourceEditor(const std::shared_ptr<SourceSettings> &sourceSettings)
{
auto it
= std::find_if(m_sourceWidgets.begin(),
m_sourceWidgets.end(),
[sourceSettings](const QDockWidget *c) {
return static_cast<SourceEditorWidget *>(c->widget())->sourceSettings()
== sourceSettings.get();
});
QTC_ASSERT(it != m_sourceWidgets.end(), return);
delete *it;
m_sourceWidgets.erase(it);
}
void EditorWidget::recreateEditors()
{
qDeleteAll(m_sourceWidgets);
qDeleteAll(m_compilerWidgets);
m_sourceWidgets.clear();
m_compilerWidgets.clear();
m_document->settings()->m_sources.forEachItem<SourceSettings>(
[this](const auto &sourceSettings) { addSourceEditor(sourceSettings); });
QVariantMap windowState = m_document->settings()->windowState.value();
if (!windowState.isEmpty()) {
QHash<QString, QVariant> hashMap;
for (const auto &key : windowState.keys()) {
if (key != "State")
hashMap.insert(key, windowState.value(key));
else {
QVariant v = windowState.value(key);
if (v.userType() == QMetaType::QByteArray) {
hashMap.insert(key, v);
} else if (v.userType() == QMetaType::QVariantMap) {
QVariantMap m = v.toMap();
if (m.value("type") == "Base64") {
hashMap.insert(key, QByteArray::fromBase64(m.value("value").toByteArray()));
}
}
}
}
restoreSettings(hashMap);
}
}
void EditorWidget::setupHelpWidget()
{
if (m_document->settings()->m_sources.size() == 0) {
setCentralWidget(createHelpWidget());
} else {
delete takeCentralWidget();
}
}
QWidget *EditorWidget::createHelpWidget() const
{
using namespace Layouting;
auto addSourceButton = new QPushButton(Tr::tr("Add source code"));
connect(addSourceButton, &QPushButton::clicked, this, [this] {
auto newSource = std::make_shared<SourceSettings>(
[settings = m_document->settings()] { return settings->apiConfig(); });
m_document->settings()->m_sources.addItem(newSource);
});
// clang-format off
return Column {
st,
Row {
st,
Column {
Tr::tr("No source code added yet. Add one using the button below."),
Row { st, addSourceButton, st }
},
st,
},
st,
}.emerge();
// clang-format on
}
TextEditor::TextEditorWidget *EditorWidget::focusedEditorWidget() const
{
for (const QDockWidget *sourceWidget : m_sourceWidgets) {

View File

@@ -140,8 +140,6 @@ public:
CompilerWidget(const std::shared_ptr<SourceSettings> &sourceSettings,
const std::shared_ptr<CompilerSettings> &compilerSettings);
~CompilerWidget();
Core::SearchableTerminal *createTerminal();
void compile(const QString &source);
@@ -188,11 +186,32 @@ public:
signals:
void sourceCodeChanged();
void gotFocus();
protected:
void focusInEvent(QFocusEvent *event) override;
void setupHelpWidget();
QWidget *createHelpWidget() const;
void addCompiler(const std::shared_ptr<SourceSettings> &sourceSettings,
const std::shared_ptr<CompilerSettings> &compilerSettings,
int idx,
QDockWidget *parentDockWidget);
void addSourceEditor(const std::shared_ptr<SourceSettings> &sourceSettings);
void removeSourceEditor(const std::shared_ptr<SourceSettings> &sourceSettings);
void recreateEditors();
QVariantMap windowStateCallback();
private:
QSplitter *m_mainSplitter;
int m_compilerCount{0};
QSharedPointer<JsonSettingsDocument> m_document;
QUndoStack *m_undoStack;
TextEditor::TextEditorActionHandler &m_actionHandler;
Core::IContext *m_context;

View File

@@ -14,10 +14,12 @@
#include <cppeditor/cppeditorconstants.h>
#include <QMenu>
#include <extensionsystem/iplugin.h>
#include <projectexplorer/jsonwizard/jsonwizardfactory.h>
#include <QMenu>
using namespace Core;
namespace CompilerExplorer::Internal {
@@ -40,6 +42,8 @@ public:
settings().defaultDocument().toUtf8());
});
ProjectExplorer::JsonWizardFactory::addWizardPath(":/compilerexplorer/wizard/");
ActionContainer *mtools = ActionManager::actionContainer(Core::Constants::M_TOOLS);
ActionContainer *mCompilerExplorer = ActionManager::createMenu("Tools.CompilerExplorer");
QMenu *menu = mCompilerExplorer->menu();

View File

@@ -0,0 +1,10 @@
{
"Sources": [{
"LanguageId": "c++",
"Source": "int main() {\n return 0;\n}",
"Compilers": [{
"Id": "clang_trunk",
"Options": "-O3"
}]
}]
}

View File

@@ -0,0 +1,37 @@
{
"version": 1,
"supportedProjectTypes": [],
"id": "QTCE.CppSource",
"category": "U.CompilerExplorer",
"trDescription": "Creates an example CompilerExplorer setup for C++.",
"trDisplayName": "Compiler Explorer C++ Source",
"trDisplayCategory": "Compiler Explorer",
"icon": "",
"iconKind": "Plain",
"options": {
"key": "DefaultSuffix",
"value": "%{JS: Util.preferredSuffix('application/compiler-explorer')}"
},
"pages": [
{
"trDisplayName": "Location",
"trShortTitle": "Location",
"typeId": "File"
},
{
"trDisplayName": "Project Management",
"trShortTitle": "Summary",
"typeId": "Summary"
}
],
"generators": [
{
"typeId": "File",
"data": {
"source": "file.qtce",
"target": "%{JS: Util.fileName(value('TargetPath'), value('DefaultSuffix'))}",
"openInEditor": true
}
}
]
}

View File

@@ -0,0 +1,9 @@
{
"Sources": [{
"LanguageId": "python",
"Source": "def main():\\n print(\\"Hello World\\")\\n\\nif __name__ == \\"__main__\\":\\n main()",
"Compilers": [{
"Id": "python311"
}]
}]
}

View File

@@ -0,0 +1,37 @@
{
"version": 1,
"supportedProjectTypes": [],
"id": "QTCE.PySource",
"category": "U.CompilerExplorer",
"trDescription": "Creates an example CompilerExplorer setup for Python.",
"trDisplayName": "Compiler Explorer Python Source",
"trDisplayCategory": "Compiler Explorer",
"icon": "",
"iconKind": "Plain",
"options": {
"key": "DefaultSuffix",
"value": "%{JS: Util.preferredSuffix('application/compiler-explorer')}"
},
"pages": [
{
"trDisplayName": "Location",
"trShortTitle": "Location",
"typeId": "File"
},
{
"trDisplayName": "Project Management",
"trShortTitle": "Summary",
"typeId": "Summary"
}
],
"generators": [
{
"typeId": "File",
"data": {
"source": "file.qtce",
"target": "%{JS: Util.fileName(value('TargetPath'), value('DefaultSuffix'))}",
"openInEditor": true
}
}
]
}

File diff suppressed because it is too large Load Diff

View File

@@ -6,6 +6,7 @@
#include "core_global.h"
#include "icontext.h"
#include <utils/appmainwindow.h>
#include <utils/filepath.h>
#include <utils/qtcsettings.h>
@@ -17,6 +18,7 @@
#include <functional>
QT_BEGIN_NAMESPACE
class QColor;
class QMainWindow;
class QPrinter;
class QStatusBar;
@@ -26,25 +28,25 @@ QT_END_NAMESPACE
namespace Utils { class InfoBar; }
namespace Core {
class Context;
class IDocument;
class IWizardFactory;
class NewDialog;
namespace Internal {
class MainWindow;
class MainWindowPrivate;
} // Internal
class NewDialog;
class CORE_EXPORT ICore : public QObject
{
Q_OBJECT
friend class Internal::MainWindow;
friend class Internal::MainWindowPrivate;
friend class IWizardFactory;
explicit ICore(Internal::MainWindow *mw);
ICore();
~ICore() override;
public:
@@ -154,9 +156,63 @@ public:
static void saveSettings(SaveSettingsReason reason);
static void setNewDialogFactory(const std::function<NewDialog *(QWidget *)> &newFactory);
private:
static void updateNewItemDialogState();
};
namespace Internal {
class MainWindow : public Utils::AppMainWindow
{
Q_OBJECT
public:
MainWindow();
~MainWindow() override;
void init();
void extensionsInitialized();
void aboutToShutdown();
IContext *contextObject(QWidget *widget) const;
void addContextObject(IContext *context);
void removeContextObject(IContext *context);
static IDocument *openFiles(const Utils::FilePaths &filePaths,
ICore::OpenFilesFlags flags,
const Utils::FilePath &workingDirectory = {});
QPrinter *printer() const;
IContext *currentContextObject() const;
QStatusBar *statusBar() const;
Utils::InfoBar *infoBar() const;
void updateAdditionalContexts(const Context &remove, const Context &add,
ICore::ContextPriority priority);
void setOverrideColor(const QColor &color);
QStringList additionalAboutInformation() const;
void clearAboutInformation();
void appendAboutInformation(const QString &line);
void addPreCloseListener(const std::function<bool()> &listener);
void saveSettings();
void restart();
void restartTrimmer();
public slots:
static void openFileWith();
void exit();
private:
void closeEvent(QCloseEvent *event) override;
void keyPressEvent(QKeyEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
};
} // namespace Internal
} // namespace Core

File diff suppressed because it is too large Load Diff

View File

@@ -3,81 +3,4 @@
#pragma once
#include "icontext.h"
#include "icore.h"
#include <utils/appmainwindow.h>
#include <functional>
QT_BEGIN_NAMESPACE
class QColor;
class QPrinter;
QT_END_NAMESPACE
namespace Utils { class InfoBar; }
namespace Core {
class IDocument;
namespace Internal {
class MainWindowPrivate;
class MainWindow : public Utils::AppMainWindow
{
Q_OBJECT
public:
MainWindow();
~MainWindow() override;
void init();
void extensionsInitialized();
void aboutToShutdown();
IContext *contextObject(QWidget *widget) const;
void addContextObject(IContext *context);
void removeContextObject(IContext *context);
static IDocument *openFiles(const Utils::FilePaths &filePaths,
ICore::OpenFilesFlags flags,
const Utils::FilePath &workingDirectory = {});
QPrinter *printer() const;
IContext *currentContextObject() const;
QStatusBar *statusBar() const;
Utils::InfoBar *infoBar() const;
void updateAdditionalContexts(const Context &remove, const Context &add,
ICore::ContextPriority priority);
void setOverrideColor(const QColor &color);
QStringList additionalAboutInformation() const;
void clearAboutInformation();
void appendAboutInformation(const QString &line);
void addPreCloseListener(const std::function<bool()> &listener);
void saveSettings();
void restart();
void restartTrimmer();
public slots:
static void openFileWith();
void exit();
private:
void closeEvent(QCloseEvent *event) override;
void keyPressEvent(QKeyEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
MainWindowPrivate *d = nullptr;
};
} // namespace Internal
} // namespace Core

View File

@@ -8,6 +8,7 @@
#include "devicesupport/idevice.h"
#include "gccparser.h"
#include "linuxiccparser.h"
#include "projectexplorerconstants.h"
#include "projectexplorertr.h"
#include "projectmacro.h"
#include "toolchainconfigwidget.h"
@@ -1197,65 +1198,226 @@ static Utils::FilePaths renesasRl78SearchPathsFromRegistry()
return searchPaths;
}
GccToolChainFactory::GccToolChainFactory()
static ToolChain *constructRealGccToolchain()
{
setDisplayName(Tr::tr("GCC"));
setSupportedToolChainType(Constants::GCC_TOOLCHAIN_TYPEID);
return new GccToolChain(Constants::GCC_TOOLCHAIN_TYPEID, GccToolChain::RealGcc);
}
static ToolChain *constructClangToolchain()
{
return new GccToolChain(Constants::CLANG_TOOLCHAIN_TYPEID, GccToolChain::Clang);
}
static ToolChain *constructMinGWToolchain()
{
return new GccToolChain(Constants::MINGW_TOOLCHAIN_TYPEID, GccToolChain::MinGW);
}
static ToolChain *constructLinuxIccToolchain()
{
return new GccToolChain(Constants::LINUXICC_TOOLCHAIN_TYPEID, GccToolChain::LinuxIcc);
}
GccToolChainFactory::GccToolChainFactory(GccToolChain::SubType subType)
: m_autoDetecting(subType == GccToolChain::RealGcc)
{
switch (subType) {
case GccToolChain::RealGcc:
setDisplayName(Tr::tr("GCC"));
setSupportedToolChainType(Constants::GCC_TOOLCHAIN_TYPEID);
setToolchainConstructor(&constructRealGccToolchain);
break;
case GccToolChain::Clang:
setDisplayName(Tr::tr("Clang"));
setSupportedToolChainType(Constants::CLANG_TOOLCHAIN_TYPEID);
setToolchainConstructor(&constructClangToolchain);
break;
case GccToolChain::MinGW:
setDisplayName(Tr::tr("MinGW"));
setSupportedToolChainType(Constants::MINGW_TOOLCHAIN_TYPEID);
setToolchainConstructor(&constructMinGWToolchain);
break;
case GccToolChain::LinuxIcc:
setDisplayName(Tr::tr("ICC"));
setSupportedToolChainType(Constants::LINUXICC_TOOLCHAIN_TYPEID);
setToolchainConstructor(&constructLinuxIccToolchain);
break;
}
setSupportedLanguages({Constants::C_LANGUAGE_ID, Constants::CXX_LANGUAGE_ID});
setToolchainConstructor([] { return new GccToolChain(Constants::GCC_TOOLCHAIN_TYPEID); });
setUserCreatable(true);
}
Toolchains GccToolChainFactory::autoDetect(const ToolchainDetector &detector) const
{
// GCC is almost never what you want on macOS, but it is by default found in /usr/bin
if (HostOsInfo::isMacHost() && detector.device->type() == Constants::DESKTOP_DEVICE_TYPE)
return {};
Toolchains result;
// Do all autodetection in th 'RealGcc' case, and none in the others.
if (!m_autoDetecting)
return result;
// Linux ICC
result += autoDetectToolchains("icpc",
DetectVariants::No,
Constants::CXX_LANGUAGE_ID,
Constants::LINUXICC_TOOLCHAIN_TYPEID,
detector,
&constructLinuxIccToolchain);
result += autoDetectToolchains("icc",
DetectVariants::Yes,
Constants::C_LANGUAGE_ID,
Constants::LINUXICC_TOOLCHAIN_TYPEID,
detector,
&constructLinuxIccToolchain);
// MinGW
static const auto tcChecker = [](const ToolChain *tc) {
return tc->targetAbi().osFlavor() == Abi::WindowsMSysFlavor;
};
result += autoDetectToolchains("g++",
DetectVariants::Yes,
Constants::CXX_LANGUAGE_ID,
Constants::MINGW_TOOLCHAIN_TYPEID,
detector,
&constructMinGWToolchain,
tcChecker);
result += autoDetectToolchains("gcc",
DetectVariants::Yes,
Constants::C_LANGUAGE_ID,
Constants::MINGW_TOOLCHAIN_TYPEID,
detector,
&constructMinGWToolchain,
tcChecker);
// Clang
Toolchains tcs;
static const auto tcChecker = [](const ToolChain *tc) {
return tc->targetAbi().osFlavor() != Abi::WindowsMSysFlavor
&& tc->compilerCommand().fileName() != "c89-gcc"
&& tc->compilerCommand().fileName() != "c99-gcc";
};
tcs.append(autoDetectToolchains("g++",
Toolchains known = detector.alreadyKnown;
tcs.append(autoDetectToolchains("clang++",
DetectVariants::Yes,
Constants::CXX_LANGUAGE_ID,
Constants::GCC_TOOLCHAIN_TYPEID,
Constants::CLANG_TOOLCHAIN_TYPEID,
detector,
toolchainConstructor(),
tcChecker));
tcs.append(autoDetectToolchains("gcc",
&constructClangToolchain));
tcs.append(autoDetectToolchains("clang",
DetectVariants::Yes,
Constants::C_LANGUAGE_ID,
Constants::GCC_TOOLCHAIN_TYPEID,
Constants::CLANG_TOOLCHAIN_TYPEID,
detector,
toolchainConstructor(),
tcChecker));
return tcs;
&constructClangToolchain));
known.append(tcs);
const FilePath compilerPath = Core::ICore::clangExecutable(CLANG_BINDIR);
if (!compilerPath.isEmpty()) {
const FilePath clang = compilerPath.parentDir().pathAppended("clang").withExecutableSuffix();
tcs.append(
autoDetectToolchains(clang.toString(),
DetectVariants::No,
Constants::C_LANGUAGE_ID,
Constants::CLANG_TOOLCHAIN_TYPEID,
ToolchainDetector(known, detector.device, detector.searchPaths),
&constructClangToolchain));
}
result += tcs;
// GCC
// Gcc is almost never what you want on macOS, but it is by default found in /usr/bin
if (!HostOsInfo::isMacHost() || detector.device->type() != Constants::DESKTOP_DEVICE_TYPE) {
static const auto tcChecker = [](const ToolChain *tc) {
return tc->targetAbi().osFlavor() != Abi::WindowsMSysFlavor
&& tc->compilerCommand().fileName() != "c89-gcc"
&& tc->compilerCommand().fileName() != "c99-gcc";
};
result += autoDetectToolchains("g++",
DetectVariants::Yes,
Constants::CXX_LANGUAGE_ID,
Constants::GCC_TOOLCHAIN_TYPEID,
detector,
&constructRealGccToolchain,
tcChecker);
result += autoDetectToolchains("gcc",
DetectVariants::Yes,
Constants::C_LANGUAGE_ID,
Constants::GCC_TOOLCHAIN_TYPEID,
detector,
&constructRealGccToolchain,
tcChecker);
}
return result;
}
Toolchains GccToolChainFactory::detectForImport(const ToolChainDescription &tcd) const
{
Toolchains result;
// Do all autodetection in th 'RealGcc' case, and none in the others.
if (!m_autoDetecting)
return result;
const QString fileName = tcd.compilerPath.completeBaseName();
const QString resolvedSymlinksFileName = tcd.compilerPath.resolveSymlinks().completeBaseName();
const bool isCCompiler = tcd.language == Constants::C_LANGUAGE_ID
// Linux ICC
if ((tcd.language == Constants::CXX_LANGUAGE_ID && fileName.startsWith("icpc")) ||
(tcd.language == Constants::C_LANGUAGE_ID && fileName.startsWith("icc"))) {
result += autoDetectToolChain(tcd, &constructLinuxIccToolchain);
}
// MingW
const bool cCompiler = tcd.language == Constants::C_LANGUAGE_ID
&& ((fileName.startsWith("gcc") || fileName.endsWith("gcc"))
|| fileName == "cc");
const bool cxxCompiler = tcd.language == Constants::CXX_LANGUAGE_ID
&& ((fileName.startsWith("g++") || fileName.endsWith("g++"))
|| (fileName.startsWith("c++") || fileName.endsWith("c++")));
if (cCompiler || cxxCompiler) {
result += autoDetectToolChain(tcd, &constructMinGWToolchain, [](const ToolChain *tc) {
return tc->targetAbi().osFlavor() == Abi::WindowsMSysFlavor;
});
}
// Clang
bool isCCompiler = tcd.language == Constants::C_LANGUAGE_ID
&& ((fileName.startsWith("clang") && !fileName.startsWith("clang++"))
|| (fileName == "cc" && resolvedSymlinksFileName.contains("clang")));
bool isCxxCompiler = tcd.language == Constants::CXX_LANGUAGE_ID
&& (fileName.startsWith("clang++")
|| (fileName == "c++" && resolvedSymlinksFileName.contains("clang")));
if (isCCompiler || isCxxCompiler)
result += autoDetectToolChain(tcd, &constructClangToolchain);
// GCC
isCCompiler = tcd.language == Constants::C_LANGUAGE_ID
&& (fileName.startsWith("gcc")
|| fileName.endsWith("gcc")
|| (fileName == "cc" && !resolvedSymlinksFileName.contains("clang")));
const bool isCxxCompiler = tcd.language == Constants::CXX_LANGUAGE_ID
isCxxCompiler = tcd.language == Constants::CXX_LANGUAGE_ID
&& (fileName.startsWith("g++")
|| fileName.endsWith("g++")
|| (fileName == "c++" && !resolvedSymlinksFileName.contains("clang")));
if (isCCompiler || isCxxCompiler) {
return autoDetectToolChain(tcd, toolchainConstructor(), [](const ToolChain *tc) {
result += autoDetectToolChain(tcd, &constructRealGccToolchain, [](const ToolChain *tc) {
return tc->targetAbi().osFlavor() != Abi::WindowsMSysFlavor;
});
}
return {};
return result;
}
static FilePaths findCompilerCandidates(const ToolchainDetector &detector,
@@ -1792,73 +1954,6 @@ QString GccToolChain::sysRoot() const
return {};
}
// --------------------------------------------------------------------------
// ClangToolChainFactory
// --------------------------------------------------------------------------
ClangToolChainFactory::ClangToolChainFactory()
{
setDisplayName(Tr::tr("Clang"));
setSupportedToolChainType(Constants::CLANG_TOOLCHAIN_TYPEID);
setSupportedLanguages({Constants::CXX_LANGUAGE_ID, Constants::C_LANGUAGE_ID});
setToolchainConstructor([] {
return new GccToolChain(Constants::CLANG_TOOLCHAIN_TYPEID, GccToolChain::Clang);
});
}
Toolchains ClangToolChainFactory::autoDetect(const ToolchainDetector &detector) const
{
Toolchains tcs;
Toolchains known = detector.alreadyKnown;
tcs.append(autoDetectToolchains("clang++",
DetectVariants::Yes,
Constants::CXX_LANGUAGE_ID,
Constants::CLANG_TOOLCHAIN_TYPEID,
detector,
toolchainConstructor()));
tcs.append(autoDetectToolchains("clang",
DetectVariants::Yes,
Constants::C_LANGUAGE_ID,
Constants::CLANG_TOOLCHAIN_TYPEID,
detector,
toolchainConstructor()));
known.append(tcs);
const FilePath compilerPath = Core::ICore::clangExecutable(CLANG_BINDIR);
if (!compilerPath.isEmpty()) {
const FilePath clang = compilerPath.parentDir().pathAppended("clang").withExecutableSuffix();
tcs.append(
autoDetectToolchains(clang.toString(),
DetectVariants::No,
Constants::C_LANGUAGE_ID,
Constants::CLANG_TOOLCHAIN_TYPEID,
ToolchainDetector(known, detector.device, detector.searchPaths),
toolchainConstructor()));
}
return tcs;
}
Toolchains ClangToolChainFactory::detectForImport(const ToolChainDescription &tcd) const
{
const QString fileName = tcd.compilerPath.completeBaseName();
const QString resolvedSymlinksFileName = tcd.compilerPath.resolveSymlinks().completeBaseName();
const bool isCCompiler = tcd.language == Constants::C_LANGUAGE_ID
&& ((fileName.startsWith("clang") && !fileName.startsWith("clang++"))
|| (fileName == "cc" && resolvedSymlinksFileName.contains("clang")));
const bool isCxxCompiler = tcd.language == Constants::CXX_LANGUAGE_ID
&& (fileName.startsWith("clang++")
|| (fileName == "c++" && resolvedSymlinksFileName.contains("clang")));
if (isCCompiler || isCxxCompiler) {
return autoDetectToolChain(tcd, toolchainConstructor());
}
return {};
}
void GccToolChainConfigWidget::updateParentToolChainComboBox()
{
QTC_ASSERT(m_parentToolchainCombo, return);
@@ -1886,104 +1981,6 @@ void GccToolChainConfigWidget::updateParentToolChainComboBox()
}
}
// --------------------------------------------------------------------------
// MingwToolChainFactory
// --------------------------------------------------------------------------
MingwToolChainFactory::MingwToolChainFactory()
{
setDisplayName(Tr::tr("MinGW"));
setSupportedToolChainType(Constants::MINGW_TOOLCHAIN_TYPEID);
setSupportedLanguages({Constants::CXX_LANGUAGE_ID, Constants::C_LANGUAGE_ID});
setToolchainConstructor([] {
return new GccToolChain(Constants::MINGW_TOOLCHAIN_TYPEID, GccToolChain::MinGW);
});
}
Toolchains MingwToolChainFactory::autoDetect(const ToolchainDetector &detector) const
{
static const auto tcChecker = [](const ToolChain *tc) {
return tc->targetAbi().osFlavor() == Abi::WindowsMSysFlavor;
};
Toolchains result = autoDetectToolchains("g++",
DetectVariants::Yes,
Constants::CXX_LANGUAGE_ID,
Constants::MINGW_TOOLCHAIN_TYPEID,
detector,
toolchainConstructor(),
tcChecker);
result += autoDetectToolchains("gcc",
DetectVariants::Yes,
Constants::C_LANGUAGE_ID,
Constants::MINGW_TOOLCHAIN_TYPEID,
detector,
toolchainConstructor(),
tcChecker);
return result;
}
Toolchains MingwToolChainFactory::detectForImport(const ToolChainDescription &tcd) const
{
const QString fileName = tcd.compilerPath.completeBaseName();
const bool cCompiler = tcd.language == Constants::C_LANGUAGE_ID
&& ((fileName.startsWith("gcc") || fileName.endsWith("gcc"))
|| fileName == "cc");
const bool cxxCompiler = tcd.language == Constants::CXX_LANGUAGE_ID
&& ((fileName.startsWith("g++") || fileName.endsWith("g++"))
|| (fileName.startsWith("c++") || fileName.endsWith("c++")));
if (cCompiler || cxxCompiler) {
return autoDetectToolChain(tcd, toolchainConstructor(), [](const ToolChain *tc) {
return tc->targetAbi().osFlavor() == Abi::WindowsMSysFlavor;
});
}
return {};
}
// --------------------------------------------------------------------------
// LinuxIccToolChainFactory
// --------------------------------------------------------------------------
LinuxIccToolChainFactory::LinuxIccToolChainFactory()
{
setDisplayName(Tr::tr("ICC"));
setSupportedToolChainType(Constants::LINUXICC_TOOLCHAIN_TYPEID);
setSupportedLanguages({Constants::CXX_LANGUAGE_ID, Constants::C_LANGUAGE_ID});
setToolchainConstructor([] {
return new GccToolChain(Constants::LINUXICC_TOOLCHAIN_TYPEID, GccToolChain::LinuxIcc);
});
}
Toolchains LinuxIccToolChainFactory::autoDetect(const ToolchainDetector &detector) const
{
Toolchains result = autoDetectToolchains("icpc",
DetectVariants::No,
Constants::CXX_LANGUAGE_ID,
Constants::LINUXICC_TOOLCHAIN_TYPEID,
detector,
toolchainConstructor());
result += autoDetectToolchains("icc",
DetectVariants::Yes,
Constants::C_LANGUAGE_ID,
Constants::LINUXICC_TOOLCHAIN_TYPEID,
detector,
toolchainConstructor());
return result;
}
Toolchains LinuxIccToolChainFactory::detectForImport(const ToolChainDescription &tcd) const
{
const QString fileName = tcd.compilerPath.completeBaseName();
if ((tcd.language == Constants::CXX_LANGUAGE_ID && fileName.startsWith("icpc")) ||
(tcd.language == Constants::C_LANGUAGE_ID && fileName.startsWith("icc"))) {
return autoDetectToolChain(tcd, toolchainConstructor());
}
return {};
}
GccToolChain::WarningFlagAdder::WarningFlagAdder(const QString &flag, WarningFlags &flags) :
m_flags(flags)
{

View File

@@ -5,7 +5,6 @@
#include "projectexplorer_export.h"
#include "projectexplorerconstants.h"
#include "toolchain.h"
#include "abi.h"
#include "headerpath.h"
@@ -17,11 +16,8 @@
namespace ProjectExplorer {
namespace Internal {
class ClangToolChainFactory;
class GccToolChainConfigWidget;
class GccToolChainFactory;
class MingwToolChainFactory;
class LinuxIccToolChainFactory;
const QStringList gccPredefinedMacrosOptions(Utils::Id languageId);
}
@@ -30,7 +26,6 @@ const QStringList gccPredefinedMacrosOptions(Utils::Id languageId);
// GccToolChain
// --------------------------------------------------------------------------
class PROJECTEXPLORER_EXPORT GccToolChain : public ToolChain
{
public:
@@ -174,9 +169,6 @@ private:
friend class Internal::GccToolChainConfigWidget;
friend class Internal::GccToolChainFactory;
friend class Internal::LinuxIccToolChainFactory;
friend class Internal::MingwToolChainFactory;
friend class Internal::ClangToolChainFactory;
friend class ToolChainFactory;
// "resolved" on macOS from /usr/bin/clang(++) etc to <DeveloperDir>/usr/bin/clang(++)
@@ -188,20 +180,18 @@ private:
QMetaObject::Connection m_thisToolchainRemovedConnection;
};
// --------------------------------------------------------------------------
// Factories
// --------------------------------------------------------------------------
namespace Internal {
class GccToolChainFactory : public ToolChainFactory
{
public:
GccToolChainFactory();
explicit GccToolChainFactory(GccToolChain::SubType subType);
Toolchains autoDetect(const ToolchainDetector &detector) const override;
Toolchains detectForImport(const ToolChainDescription &tcd) const override;
Toolchains autoDetect(const ToolchainDetector &detector) const final;
Toolchains detectForImport(const ToolChainDescription &tcd) const final;
protected:
private:
enum class DetectVariants { Yes, No };
using ToolchainChecker = std::function<bool(const ToolChain *)>;
static Toolchains autoDetectToolchains(const QString &compilerName,
@@ -214,33 +204,8 @@ protected:
static Toolchains autoDetectToolChain(const ToolChainDescription &tcd,
const ToolChainConstructor &constructor,
const ToolchainChecker &checker = {});
};
class ClangToolChainFactory : public GccToolChainFactory
{
public:
ClangToolChainFactory();
Toolchains autoDetect(const ToolchainDetector &detector) const final;
Toolchains detectForImport(const ToolChainDescription &tcd) const final;
};
class MingwToolChainFactory : public GccToolChainFactory
{
public:
MingwToolChainFactory();
Toolchains autoDetect(const ToolchainDetector &detector) const final;
Toolchains detectForImport(const ToolChainDescription &tcd) const final;
};
class LinuxIccToolChainFactory : public GccToolChainFactory
{
public:
LinuxIccToolChainFactory();
Toolchains autoDetect(const ToolchainDetector &detector) const final;
Toolchains detectForImport(const ToolChainDescription &tcd) const final;
const bool m_autoDetecting;
};
} // namespace Internal

View File

@@ -855,6 +855,8 @@ QSet<Id> DeviceTypeKitAspectFactory::availableFeatures(const Kit *k) const
return {};
}
const DeviceTypeKitAspectFactory theDeviceTypeKitAspectFactory;
// --------------------------------------------------------------------------
// DeviceKitAspect:
// --------------------------------------------------------------------------

View File

@@ -2057,7 +2057,7 @@ Toolchains ClangClToolChainFactory::autoDetect(const ToolchainDetector &detector
}
const Utils::Environment systemEnvironment = Utils::Environment::systemEnvironment();
const Utils::FilePath clangClPath = systemEnvironment.searchInPath("clang-cl");
const Utils::FilePath clangClPath = systemEnvironment.searchInPath("clang-cl.exe");
if (!clangClPath.isEmpty())
results.append(detectClangClToolChainInPath(clangClPath, known, ""));

View File

@@ -49,13 +49,13 @@
#include "kitfeatureprovider.h"
#include "kitaspects.h"
#include "kitmanager.h"
#include "kitoptionspage.h"
#include "miniprojecttargetselector.h"
#include "namedwidget.h"
#include "parseissuesdialog.h"
#include "processstep.h"
#include "project.h"
#include "projectcommentssettings.h"
#include "projectexplorerconstants.h"
#include "projectexplorericons.h"
#include "projectexplorersettings.h"
#include "projectexplorertr.h"
@@ -625,15 +625,16 @@ public:
MsvcToolChainFactory m_mscvToolChainFactory;
ClangClToolChainFactory m_clangClToolChainFactory;
#else
LinuxIccToolChainFactory m_linuxToolChainFactory;
GccToolChainFactory m_linuxToolChainFactory{GccToolChain::LinuxIcc};
#endif
#ifndef Q_OS_MACOS
MingwToolChainFactory m_mingwToolChainFactory; // Mingw offers cross-compiling to windows
// Mingw offers cross-compiling to windows
GccToolChainFactory m_mingwToolChainFactory{GccToolChain::MinGW};
#endif
GccToolChainFactory m_gccToolChainFactory;
ClangToolChainFactory m_clangToolChainFactory;
GccToolChainFactory m_gccToolChainFactory{GccToolChain::RealGcc};
GccToolChainFactory m_clangToolChainFactory{GccToolChain::Clang};
CustomToolChainFactory m_customToolChainFactory;
DesktopDeviceFactory m_desktopDeviceFactory;

View File

@@ -671,8 +671,7 @@ void ToolChainFactory::setSupportsAllLanguages(bool supportsAllLanguages)
m_supportsAllLanguages = supportsAllLanguages;
}
void ToolChainFactory::setToolchainConstructor
(const ToolChainConstructor &toolchainContructor)
void ToolChainFactory::setToolchainConstructor(const ToolChainConstructor &toolchainContructor)
{
m_toolchainConstructor = toolchainContructor;
}

View File

@@ -27,9 +27,9 @@
#include <utils/qtcassert.h>
#include <QDir>
#include <QFileInfo>
#include <QStringList>
#include <QLoggingCategory>
#include <QSet>
#include <QStringList>
#include <memory>
@@ -61,19 +61,18 @@ QmakeProjectImporter::QmakeProjectImporter(const FilePath &path) :
FilePaths QmakeProjectImporter::importCandidates()
{
FilePaths candidates;
const FilePath pfp = projectFilePath();
const QString prefix = pfp.baseName();
candidates << pfp.absolutePath();
FilePaths candidates{projectFilePath().absolutePath()};
QSet<FilePath> seenBaseDirs;
for (Kit *k : KitManager::kits()) {
const FilePath sbdir = QmakeBuildConfiguration::shadowBuildDirectory
(projectFilePath(), k, QString(), BuildConfiguration::Unknown);
const FilePath baseDir = sbdir.absolutePath();
if (!Utils::insert(seenBaseDirs, baseDir))
continue;
for (const FilePath &path : baseDir.dirEntries(QDir::Dirs | QDir::NoDotAndDotDot)) {
if (path.fileName().startsWith(prefix) && !candidates.contains(path))
if (!candidates.contains(path))
candidates << path;
}
}

View File

@@ -33,7 +33,7 @@ const QByteArray livePreviewId = "LivePreview";
static void handleAction(const SelectionContext &context)
{
if (context.view()->isAttached()) {
if (context.isValid()) {
if (context.toggled()) {
bool skipDeploy = false;
if (const Target *startupTarget = ProjectManager::startupTarget()) {

View File

@@ -12,6 +12,8 @@
#include <coreplugin/icore.h>
#include <coreplugin/dialogs/ioptionspage.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <utils/aspects.h>
#include <utils/environment.h>
#include <utils/infolabel.h>
@@ -19,7 +21,6 @@
#include <utils/pathchooser.h>
#include <utils/utilsicons.h>
#include <QGroupBox>
#include <QTextBrowser>
#include <QTimer>