Merge remote-tracking branch 'origin/8.0'

Conflicts:
	src/libs/utils/terminalprocess.cpp
	tests/auto/qml/qmldesigner/coretests/CMakeLists.txt

Change-Id: Ifc5b37dadd46af752f0771a2685da1ac9a6260bd
This commit is contained in:
Eike Ziller
2022-07-07 13:28:17 +02:00
122 changed files with 983 additions and 1217 deletions

View File

@@ -751,9 +751,8 @@ ClangdClient::ClangdCompletionAssistProcessor::generateCompletionItems(
return itemGenerator(items);
const QString content = doc->toPlainText();
const bool requiresSignal = CppEditor::CppModelManager::instance()
->positionRequiresSignal(filePath().toString(),
content.toUtf8(),
pos);
->getSignalSlotType(filePath().toString(), content.toUtf8(), pos)
== CppEditor::SignalSlotType::NewStyleSignal;
if (requiresSignal)
return itemGenerator(Utils::filtered(items, criterion));
return itemGenerator(items);
@@ -846,9 +845,11 @@ static void addToCompilationDb(QJsonObject &cdb,
CppEditor::UsePrecompiledHeaders usePch,
const QJsonArray &projectPartOptions,
const Utils::FilePath &workingDir,
const CppEditor::ProjectFile &sourceFile)
const CppEditor::ProjectFile &sourceFile,
bool clStyle)
{
QJsonArray args = clangOptionsForFile(sourceFile, projectPart, projectPartOptions, usePch);
QJsonArray args = clangOptionsForFile(sourceFile, projectPart, projectPartOptions, usePch,
clStyle);
// TODO: clangd seems to apply some heuristics depending on what we put here.
// Should we make use of them or keep using our own?
@@ -890,7 +891,8 @@ ClangdClient::ClangdClient(Project *project, const Utils::FilePath &jsonDbDir)
const QJsonArray projectPartOptions = fullProjectPartOptions(
optionsBuilder, globalClangOptions());
const QJsonArray clangOptions = clangOptionsForFile({}, optionsBuilder.projectPart(),
projectPartOptions, usePch);
projectPartOptions, usePch,
optionsBuilder.isClStyle());
initOptions.insert("fallbackFlags", clangOptions);
setInitializationOptions(initOptions);
}
@@ -1019,7 +1021,7 @@ void ClangdClient::findUsages(TextDocument *document, const QTextCursor &cursor,
// Otherwise get the proper spelling of the search term from clang, so we can put it into the
// search widget.
const auto symbolInfoHandler = [this, doc = QPointer(document), adjustedCursor, replacement, categorize]
(const QString &, const QString &name, const MessageId &) {
(const QString &name, const QString &, const MessageId &) {
if (!doc)
return;
if (name.isEmpty())
@@ -1329,7 +1331,7 @@ void ClangdClient::updateParserConfig(const Utils::FilePath &filePath,
const QJsonArray projectPartOptions = fullProjectPartOptions(
optionsBuilder, globalClangOptions());
addToCompilationDb(cdbChanges, *projectPart, CppEditor::getPchUsage(), projectPartOptions,
filePath.parentDir(), file);
filePath.parentDir(), file, optionsBuilder.isClStyle());
QJsonObject settings;
addCompilationDb(settings, cdbChanges);
DidChangeConfigurationParams configChangeParams;
@@ -1609,7 +1611,7 @@ void ClangdClient::followSymbol(TextDocument *document,
d->followSymbol = new ClangdFollowSymbol(this, adjustedCursor, editorWidget, document, callback,
openInSplit);
connect(d->followSymbol, &ClangdFollowSymbol::done, this, [this] {
delete d->followSymbol;
d->followSymbol->deleteLater();
d->followSymbol = nullptr;
});
}
@@ -1626,7 +1628,7 @@ void ClangdClient::switchDeclDef(TextDocument *document, const QTextCursor &curs
delete d->switchDeclDef;
d->switchDeclDef = new ClangdSwitchDeclDef(this, document, cursor, editorWidget, callback);
connect(d->switchDeclDef, &ClangdSwitchDeclDef::done, this, [this] {
delete d->switchDeclDef;
d->switchDeclDef->deleteLater();
d->switchDeclDef = nullptr;
});
}
@@ -2237,6 +2239,10 @@ IAssistProcessor *ClangdClient::ClangdCompletionAssistProvider::createProcessor(
contextAnalyzer.positionEndOfExpression(),
contextAnalyzer.completionOperator(),
CustomAssistMode::Preprocessor);
case ClangCompletionContextAnalyzer::CompleteSignal:
case ClangCompletionContextAnalyzer::CompleteSlot:
if (!interface->isBaseObject())
return CppEditor::getCppCompletionAssistProcessor();
default:
break;
}

View File

@@ -431,9 +431,13 @@ void ClangModelManagerSupport::updateLanguageClient(
const Client * const currentClient = LanguageClientManager::clientForDocument(doc);
if (!settings.sizeIsOkay(doc->filePath()))
continue;
if (!currentClient || !currentClient->project()
|| currentClient->state() != Client::Initialized
|| project->isKnownFile(doc->filePath())) {
if (currentClient && currentClient->project()
&& currentClient->project() != project) {
continue;
}
if (const Project * const docProject
= SessionManager::projectForFile(doc->filePath());
!docProject || docProject == project) {
LanguageClientManager::openDocumentWithClient(doc, client);
hasDocuments = true;
}
@@ -546,7 +550,8 @@ void ClangModelManagerSupport::claimNonProjectSources(ClangdClient *client)
}
if (!ClangdSettings::instance().sizeIsOkay(doc->filePath()))
continue;
client->openDocument(doc);
if (!ProjectExplorer::SessionManager::projectForFile(doc->filePath()))
LanguageClientManager::openDocumentWithClient(doc, client);
}
}

View File

@@ -130,7 +130,8 @@ static QJsonObject createFileObject(const FilePath &buildDir,
const ProjectFile &projFile,
CompilationDbPurpose purpose,
const QJsonArray &projectPartOptions,
UsePrecompiledHeaders usePch)
UsePrecompiledHeaders usePch,
bool clStyle)
{
QJsonObject fileObject;
fileObject["file"] = projFile.path;
@@ -155,7 +156,7 @@ static QJsonObject createFileObject(const FilePath &buildDir,
args.append(langOptionPart);
}
} else {
args = clangOptionsForFile(projFile, projectPart, projectPartOptions, usePch);
args = clangOptionsForFile(projFile, projectPart, projectPartOptions, usePch, clStyle);
args.prepend("clang"); // TODO: clang-cl for MSVC targets? Does it matter at all what we put here?
}
@@ -200,7 +201,8 @@ GenerateCompilationDbResult generateCompilationDB(const CppEditor::ProjectInfo::
}
for (const ProjectFile &projFile : projectPart->files) {
const QJsonObject json = createFileObject(baseDir, args, *projectPart, projFile,
purpose, ppOptions, usePch);
purpose, ppOptions, usePch,
optionsBuilder.isClStyle());
if (compileCommandsFile.size() > 1)
compileCommandsFile.write(",");
compileCommandsFile.write('\n' + QJsonDocument(json).toJson().trimmed());
@@ -274,9 +276,11 @@ QString DiagnosticTextInfo::clazyCheckName(const QString &option)
QJsonArray clangOptionsForFile(const ProjectFile &file, const ProjectPart &projectPart,
const QJsonArray &generalOptions, UsePrecompiledHeaders usePch)
const QJsonArray &generalOptions, UsePrecompiledHeaders usePch,
bool clStyle)
{
CompilerOptionsBuilder optionsBuilder(projectPart);
optionsBuilder.setClStyle(clStyle);
ProjectFile::Kind fileKind = file.kind;
if (fileKind == ProjectFile::AmbiguousHeader) {
fileKind = projectPart.languageVersion <= LanguageVersion::LatestC

View File

@@ -66,7 +66,7 @@ QJsonArray fullProjectPartOptions(const QJsonArray &projectPartOptions,
QJsonArray clangOptionsForFile(const CppEditor::ProjectFile &file,
const CppEditor::ProjectPart &projectPart,
const QJsonArray &generalOptions,
CppEditor::UsePrecompiledHeaders usePch);
CppEditor::UsePrecompiledHeaders usePch, bool clStyle);
CppEditor::ProjectPart::ConstPtr projectPartForFile(const QString &filePath);