forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/3.6'
Conflicts: qtcreator.pri qtcreator.qbs Change-Id: Ifbe181e86c161e082cc9a69a4bc7bd399f34ff47
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -37,17 +37,12 @@
|
|||||||
|
|
||||||
namespace ClangBackEnd {
|
namespace ClangBackEnd {
|
||||||
|
|
||||||
CodeCompletionChunk::CodeCompletionChunk()
|
|
||||||
: kind_(Invalid)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
CodeCompletionChunk::CodeCompletionChunk(CodeCompletionChunk::Kind kind,
|
CodeCompletionChunk::CodeCompletionChunk(CodeCompletionChunk::Kind kind,
|
||||||
const Utf8String &text,
|
const Utf8String &text,
|
||||||
const CodeCompletionChunks &optionalChunks)
|
bool isOptional)
|
||||||
: text_(text),
|
: text_(text),
|
||||||
optionalChunks_(optionalChunks),
|
kind_(kind),
|
||||||
kind_(kind)
|
isOptional_(isOptional)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,23 +56,21 @@ const Utf8String &CodeCompletionChunk::text() const
|
|||||||
return text_;
|
return text_;
|
||||||
}
|
}
|
||||||
|
|
||||||
const CodeCompletionChunks &CodeCompletionChunk::optionalChunks() const
|
bool CodeCompletionChunk::isOptional() const
|
||||||
{
|
{
|
||||||
return optionalChunks_;
|
return isOptional_;
|
||||||
}
|
}
|
||||||
|
|
||||||
quint32 &CodeCompletionChunk::kindAsInt()
|
quint8 &CodeCompletionChunk::kindAsInt()
|
||||||
{
|
{
|
||||||
return reinterpret_cast<quint32&>(kind_);
|
return reinterpret_cast<quint8&>(kind_);
|
||||||
}
|
}
|
||||||
|
|
||||||
QDataStream &operator<<(QDataStream &out, const CodeCompletionChunk &chunk)
|
QDataStream &operator<<(QDataStream &out, const CodeCompletionChunk &chunk)
|
||||||
{
|
{
|
||||||
out << chunk.kind_;
|
out << quint8(chunk.kind_);
|
||||||
out << chunk.text_;
|
out << chunk.text_;
|
||||||
|
out << chunk.isOptional_;
|
||||||
if (chunk.kind() == CodeCompletionChunk::Optional)
|
|
||||||
out << chunk.optionalChunks_;
|
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
@@ -86,9 +79,7 @@ QDataStream &operator>>(QDataStream &in, CodeCompletionChunk &chunk)
|
|||||||
{
|
{
|
||||||
in >> chunk.kindAsInt();
|
in >> chunk.kindAsInt();
|
||||||
in >> chunk.text_;
|
in >> chunk.text_;
|
||||||
|
in >> chunk.isOptional_;
|
||||||
if (chunk.kind_ == CodeCompletionChunk::Optional)
|
|
||||||
in >> chunk.optionalChunks_;
|
|
||||||
|
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
@@ -97,7 +88,7 @@ bool operator==(const CodeCompletionChunk &first, const CodeCompletionChunk &sec
|
|||||||
{
|
{
|
||||||
return first.kind() == second.kind()
|
return first.kind() == second.kind()
|
||||||
&& first.text() == second.text()
|
&& first.text() == second.text()
|
||||||
&& first.optionalChunks() == second.optionalChunks();
|
&& first.isOptional() == second.isOptional();
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *completionChunkKindToString(CodeCompletionChunk::Kind kind)
|
static const char *completionChunkKindToString(CodeCompletionChunk::Kind kind)
|
||||||
@@ -136,8 +127,8 @@ QDebug operator<<(QDebug debug, const CodeCompletionChunk &chunk)
|
|||||||
debug.nospace() << completionChunkKindToString(chunk.kind()) << ", ";
|
debug.nospace() << completionChunkKindToString(chunk.kind()) << ", ";
|
||||||
debug.nospace() << chunk.text();
|
debug.nospace() << chunk.text();
|
||||||
|
|
||||||
if (chunk.kind() == CodeCompletionChunk::Optional)
|
if (chunk.isOptional())
|
||||||
debug.nospace() << ", " << chunk.optionalChunks();
|
debug.nospace() << ", optional";
|
||||||
|
|
||||||
debug.nospace() << ")";
|
debug.nospace() << ")";
|
||||||
|
|
||||||
@@ -150,20 +141,8 @@ void PrintTo(const CodeCompletionChunk &chunk, ::std::ostream* os)
|
|||||||
*os << completionChunkKindToString(chunk.kind()) << ", ";
|
*os << completionChunkKindToString(chunk.kind()) << ", ";
|
||||||
*os << chunk.text().constData();
|
*os << chunk.text().constData();
|
||||||
|
|
||||||
if (chunk.kind() == CodeCompletionChunk::Optional) {
|
if (chunk.isOptional())
|
||||||
const auto optionalChunks = chunk.optionalChunks();
|
*os << ", optional";
|
||||||
*os << ", {";
|
|
||||||
|
|
||||||
for (auto optionalChunkPosition = optionalChunks.cbegin();
|
|
||||||
optionalChunkPosition != optionalChunks.cend();
|
|
||||||
++optionalChunkPosition) {
|
|
||||||
PrintTo(*optionalChunkPosition, os);
|
|
||||||
if (std::next(optionalChunkPosition) != optionalChunks.cend())
|
|
||||||
*os << ", ";
|
|
||||||
}
|
|
||||||
|
|
||||||
*os << "}";
|
|
||||||
}
|
|
||||||
|
|
||||||
*os << "}";
|
*os << "}";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class CMBIPC_EXPORT CodeCompletionChunk
|
|||||||
friend CMBIPC_EXPORT bool operator==(const CodeCompletionChunk &first, const CodeCompletionChunk &second);
|
friend CMBIPC_EXPORT bool operator==(const CodeCompletionChunk &first, const CodeCompletionChunk &second);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum Kind : quint32 {
|
enum Kind : quint8 {
|
||||||
Optional,
|
Optional,
|
||||||
TypedText,
|
TypedText,
|
||||||
Text,
|
Text,
|
||||||
@@ -71,25 +71,25 @@ public:
|
|||||||
Equal,
|
Equal,
|
||||||
HorizontalSpace,
|
HorizontalSpace,
|
||||||
VerticalSpace,
|
VerticalSpace,
|
||||||
Invalid = 255};
|
Invalid = 255
|
||||||
|
};
|
||||||
|
|
||||||
CodeCompletionChunk();
|
CodeCompletionChunk() = default;
|
||||||
CodeCompletionChunk(Kind kind,
|
CodeCompletionChunk(Kind kind,
|
||||||
const Utf8String &text,
|
const Utf8String &text,
|
||||||
const CodeCompletionChunks &optionalChunks = CodeCompletionChunks());
|
bool isOptional = false);
|
||||||
|
|
||||||
Kind kind() const;
|
Kind kind() const;
|
||||||
const Utf8String &text() const;
|
const Utf8String &text() const;
|
||||||
const CodeCompletionChunks &optionalChunks() const;
|
bool isOptional() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
quint32 &kindAsInt();
|
quint8 &kindAsInt();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Utf8String text_;
|
Utf8String text_;
|
||||||
CodeCompletionChunks optionalChunks_;
|
|
||||||
Kind kind_ = Invalid;
|
Kind kind_ = Invalid;
|
||||||
|
bool isOptional_ = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const CodeCompletionChunk &chunk);
|
CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const CodeCompletionChunk &chunk);
|
||||||
|
|||||||
@@ -120,8 +120,6 @@ void TypeDescriptionReader::readDocument(UiProgram *ast)
|
|||||||
addError(import->versionToken, tr("Major version different from 1 not supported."));
|
addError(import->versionToken, tr("Major version different from 1 not supported."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (version.minorVersion() > 1)
|
|
||||||
addWarning(import->versionToken, tr("Reading only version 1.1 parts."));
|
|
||||||
|
|
||||||
if (!ast->members || !ast->members->member || ast->members->next) {
|
if (!ast->members || !ast->members->member || ast->members->next) {
|
||||||
addError(SourceLocation(), tr("Expected document to contain a single object definition."));
|
addError(SourceLocation(), tr("Expected document to contain a single object definition."));
|
||||||
@@ -153,8 +151,6 @@ void TypeDescriptionReader::readModule(UiObjectDefinition *ast)
|
|||||||
typeName = toString(component->qualifiedTypeNameId);
|
typeName = toString(component->qualifiedTypeNameId);
|
||||||
|
|
||||||
if (!component || (typeName != QLatin1String("Component") && typeName != QLatin1String("ModuleApi"))) {
|
if (!component || (typeName != QLatin1String("Component") && typeName != QLatin1String("ModuleApi"))) {
|
||||||
addWarning(member->firstSourceLocation(),
|
|
||||||
tr("Expected only Component and ModuleApi object definitions."));
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ public:
|
|||||||
bool m_iconEnabled[2];
|
bool m_iconEnabled[2];
|
||||||
|
|
||||||
bool m_isFiltering = false;
|
bool m_isFiltering = false;
|
||||||
bool m_firstChange = false;
|
bool m_firstChange = true;
|
||||||
|
|
||||||
QString m_lastFilterText;
|
QString m_lastFilterText;
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,8 @@
|
|||||||
namespace ClangCodeModel {
|
namespace ClangCodeModel {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
void CompletionChunksToTextConverter::parseChunks(const ClangBackEnd::CodeCompletionChunks &codeCompletionChunks)
|
void CompletionChunksToTextConverter::parseChunks(
|
||||||
|
const ClangBackEnd::CodeCompletionChunks &codeCompletionChunks)
|
||||||
{
|
{
|
||||||
m_text.clear();
|
m_text.clear();
|
||||||
m_placeholderPositions.clear();
|
m_placeholderPositions.clear();
|
||||||
@@ -49,7 +50,7 @@ void CompletionChunksToTextConverter::parseChunks(const ClangBackEnd::CodeComple
|
|||||||
m_codeCompletionChunks.cend(),
|
m_codeCompletionChunks.cend(),
|
||||||
[this] (const ClangBackEnd::CodeCompletionChunk &chunk)
|
[this] (const ClangBackEnd::CodeCompletionChunk &chunk)
|
||||||
{
|
{
|
||||||
parse(chunk);
|
parseDependendOnTheOptionalState(chunk);
|
||||||
m_previousCodeCompletionChunk = chunk;
|
m_previousCodeCompletionChunk = chunk;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -74,14 +75,15 @@ void CompletionChunksToTextConverter::setAddSpaces(bool addSpaces)
|
|||||||
m_addSpaces = addSpaces;
|
m_addSpaces = addSpaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompletionChunksToTextConverter::setAddExtraVerticalSpaceBetweenBraces(bool addExtraVerticalSpaceBetweenBraces)
|
void CompletionChunksToTextConverter::setAddExtraVerticalSpaceBetweenBraces(
|
||||||
|
bool addExtraVerticalSpaceBetweenBraces)
|
||||||
{
|
{
|
||||||
m_addExtraVerticalSpaceBetweenBraces = addExtraVerticalSpaceBetweenBraces;
|
m_addExtraVerticalSpaceBetweenBraces = addExtraVerticalSpaceBetweenBraces;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompletionChunksToTextConverter::setAddHtmlTags(bool addHtmlTags)
|
void CompletionChunksToTextConverter::setEmphasizeOptional(bool emphasizeOptional)
|
||||||
{
|
{
|
||||||
m_addHtmlTags = addHtmlTags;
|
m_emphasizeOptional = emphasizeOptional;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompletionChunksToTextConverter::setAddOptional(bool addOptional)
|
void CompletionChunksToTextConverter::setAddOptional(bool addOptional)
|
||||||
@@ -89,6 +91,11 @@ void CompletionChunksToTextConverter::setAddOptional(bool addOptional)
|
|||||||
m_addOptional = addOptional;
|
m_addOptional = addOptional;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CompletionChunksToTextConverter::setPlaceHolderToEmphasize(int placeHolderNumber)
|
||||||
|
{
|
||||||
|
m_placeHolderPositionToEmphasize = placeHolderNumber;
|
||||||
|
}
|
||||||
|
|
||||||
const QString &CompletionChunksToTextConverter::text() const
|
const QString &CompletionChunksToTextConverter::text() const
|
||||||
{
|
{
|
||||||
return m_text;
|
return m_text;
|
||||||
@@ -104,19 +111,27 @@ bool CompletionChunksToTextConverter::hasPlaceholderPositions() const
|
|||||||
return m_placeholderPositions.size() > 0;
|
return m_placeholderPositions.size() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CompletionChunksToTextConverter::convertToFunctionSignature(const ClangBackEnd::CodeCompletionChunks &codeCompletionChunks)
|
QString CompletionChunksToTextConverter::convertToFunctionSignature(
|
||||||
|
const ClangBackEnd::CodeCompletionChunks &codeCompletionChunks,
|
||||||
|
int parameterToEmphasize)
|
||||||
{
|
{
|
||||||
CompletionChunksToTextConverter converter;
|
CompletionChunksToTextConverter converter;
|
||||||
converter.setAddPlaceHolderText(true);
|
converter.setAddPlaceHolderText(true);
|
||||||
converter.setAddResultType(true);
|
converter.setAddResultType(true);
|
||||||
|
|
||||||
converter.setAddOptional(true);
|
converter.setAddOptional(true);
|
||||||
|
converter.setEmphasizeOptional(true);
|
||||||
|
|
||||||
|
converter.setAddPlaceHolderPositions(true);
|
||||||
|
converter.setPlaceHolderToEmphasize(parameterToEmphasize);
|
||||||
|
|
||||||
converter.parseChunks(codeCompletionChunks);
|
converter.parseChunks(codeCompletionChunks);
|
||||||
|
|
||||||
return converter.text();
|
return converter.text();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CompletionChunksToTextConverter::convertToName(const ClangBackEnd::CodeCompletionChunks &codeCompletionChunks)
|
QString CompletionChunksToTextConverter::convertToName(
|
||||||
|
const ClangBackEnd::CodeCompletionChunks &codeCompletionChunks)
|
||||||
{
|
{
|
||||||
CompletionChunksToTextConverter converter;
|
CompletionChunksToTextConverter converter;
|
||||||
|
|
||||||
@@ -125,14 +140,15 @@ QString CompletionChunksToTextConverter::convertToName(const ClangBackEnd::CodeC
|
|||||||
return converter.text();
|
return converter.text();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CompletionChunksToTextConverter::convertToToolTip(const ClangBackEnd::CodeCompletionChunks &codeCompletionChunks)
|
QString CompletionChunksToTextConverter::convertToToolTip(
|
||||||
|
const ClangBackEnd::CodeCompletionChunks &codeCompletionChunks)
|
||||||
{
|
{
|
||||||
CompletionChunksToTextConverter converter;
|
CompletionChunksToTextConverter converter;
|
||||||
converter.setAddPlaceHolderText(true);
|
converter.setAddPlaceHolderText(true);
|
||||||
converter.setAddSpaces(true);
|
converter.setAddSpaces(true);
|
||||||
converter.setAddExtraVerticalSpaceBetweenBraces(true);
|
converter.setAddExtraVerticalSpaceBetweenBraces(true);
|
||||||
converter.setAddOptional(true);
|
converter.setAddOptional(true);
|
||||||
converter.setAddHtmlTags(true);
|
converter.setEmphasizeOptional(true);
|
||||||
converter.setAddResultType(true);
|
converter.setAddResultType(true);
|
||||||
|
|
||||||
converter.parseChunks(codeCompletionChunks);
|
converter.parseChunks(codeCompletionChunks);
|
||||||
@@ -140,13 +156,13 @@ QString CompletionChunksToTextConverter::convertToToolTip(const ClangBackEnd::Co
|
|||||||
return converter.text();
|
return converter.text();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompletionChunksToTextConverter::parse(const ClangBackEnd::CodeCompletionChunk &codeCompletionChunk)
|
void CompletionChunksToTextConverter::parse(
|
||||||
|
const ClangBackEnd::CodeCompletionChunk &codeCompletionChunk)
|
||||||
{
|
{
|
||||||
using ClangBackEnd::CodeCompletionChunk;
|
using ClangBackEnd::CodeCompletionChunk;
|
||||||
|
|
||||||
switch (codeCompletionChunk.kind()) {
|
switch (codeCompletionChunk.kind()) {
|
||||||
case CodeCompletionChunk::ResultType: parseResultType(codeCompletionChunk.text()); break;
|
case CodeCompletionChunk::ResultType: parseResultType(codeCompletionChunk.text()); break;
|
||||||
case CodeCompletionChunk::Optional: parseOptional(codeCompletionChunk); break;
|
|
||||||
case CodeCompletionChunk::Placeholder: parsePlaceHolder(codeCompletionChunk); break;
|
case CodeCompletionChunk::Placeholder: parsePlaceHolder(codeCompletionChunk); break;
|
||||||
case CodeCompletionChunk::LeftParen: parseLeftParen(codeCompletionChunk); break;
|
case CodeCompletionChunk::LeftParen: parseLeftParen(codeCompletionChunk); break;
|
||||||
case CodeCompletionChunk::LeftBrace: parseLeftBrace(codeCompletionChunk); break;
|
case CodeCompletionChunk::LeftBrace: parseLeftBrace(codeCompletionChunk); break;
|
||||||
@@ -154,10 +170,19 @@ void CompletionChunksToTextConverter::parse(const ClangBackEnd::CodeCompletionCh
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CompletionChunksToTextConverter::parseDependendOnTheOptionalState(
|
||||||
|
const ClangBackEnd::CodeCompletionChunk &codeCompletionChunk)
|
||||||
|
{
|
||||||
|
wrapInCursiveTagIfOptional(codeCompletionChunk);
|
||||||
|
|
||||||
|
if (isNotOptionalOrAddOptionals(codeCompletionChunk))
|
||||||
|
parse(codeCompletionChunk);
|
||||||
|
}
|
||||||
|
|
||||||
void CompletionChunksToTextConverter::parseResultType(const Utf8String &resultTypeText)
|
void CompletionChunksToTextConverter::parseResultType(const Utf8String &resultTypeText)
|
||||||
{
|
{
|
||||||
if (m_addResultType)
|
if (m_addResultType)
|
||||||
m_text += resultTypeText.toString() + QChar(QChar::Space);
|
m_text += resultTypeText.toString().toHtmlEscaped() + QChar(QChar::Space);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompletionChunksToTextConverter::parseText(const Utf8String &text)
|
void CompletionChunksToTextConverter::parseText(const Utf8String &text)
|
||||||
@@ -167,32 +192,36 @@ void CompletionChunksToTextConverter::parseText(const Utf8String &text)
|
|||||||
m_text += QChar(QChar::Space);
|
m_text += QChar(QChar::Space);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_text += text.toString();
|
m_text += text.toString().toHtmlEscaped();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompletionChunksToTextConverter::parseOptional(const ClangBackEnd::CodeCompletionChunk &optionalCodeCompletionChunk)
|
void CompletionChunksToTextConverter::wrapInCursiveTagIfOptional(
|
||||||
|
const ClangBackEnd::CodeCompletionChunk &codeCompletionChunk)
|
||||||
{
|
{
|
||||||
if (m_addOptional) {
|
if (m_addOptional) {
|
||||||
if (m_addHtmlTags)
|
if (m_emphasizeOptional) {
|
||||||
m_text += QStringLiteral("<i>");
|
if (!m_previousCodeCompletionChunk.isOptional() && codeCompletionChunk.isOptional())
|
||||||
|
m_text += QStringLiteral("<i>");
|
||||||
m_text += convertToFunctionSignature(optionalCodeCompletionChunk.optionalChunks());
|
else if (m_previousCodeCompletionChunk.isOptional() && !codeCompletionChunk.isOptional())
|
||||||
|
m_text += QStringLiteral("</i>");
|
||||||
if (m_addHtmlTags)
|
}
|
||||||
m_text += QStringLiteral("</i>");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompletionChunksToTextConverter::parsePlaceHolder(const ClangBackEnd::CodeCompletionChunk &codeCompletionChunk)
|
void CompletionChunksToTextConverter::parsePlaceHolder(
|
||||||
|
const ClangBackEnd::CodeCompletionChunk &codeCompletionChunk)
|
||||||
{
|
{
|
||||||
if (m_addPlaceHolderText)
|
if (m_addPlaceHolderText) {
|
||||||
m_text += codeCompletionChunk.text().toString();
|
appendText(codeCompletionChunk.text().toString().toHtmlEscaped(),
|
||||||
|
emphasizeCurrentPlaceHolder());
|
||||||
|
}
|
||||||
|
|
||||||
if (m_addPlaceHolderPositions)
|
if (m_addPlaceHolderPositions)
|
||||||
m_placeholderPositions.push_back(m_text.size());
|
m_placeholderPositions.push_back(m_text.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompletionChunksToTextConverter::parseLeftParen(const ClangBackEnd::CodeCompletionChunk &codeCompletionChunk)
|
void CompletionChunksToTextConverter::parseLeftParen(
|
||||||
|
const ClangBackEnd::CodeCompletionChunk &codeCompletionChunk)
|
||||||
{
|
{
|
||||||
if (canAddSpace())
|
if (canAddSpace())
|
||||||
m_text += QChar(QChar::Space);
|
m_text += QChar(QChar::Space);
|
||||||
@@ -200,7 +229,8 @@ void CompletionChunksToTextConverter::parseLeftParen(const ClangBackEnd::CodeCom
|
|||||||
m_text += codeCompletionChunk.text().toString();
|
m_text += codeCompletionChunk.text().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompletionChunksToTextConverter::parseLeftBrace(const ClangBackEnd::CodeCompletionChunk &codeCompletionChunk)
|
void CompletionChunksToTextConverter::parseLeftBrace(
|
||||||
|
const ClangBackEnd::CodeCompletionChunk &codeCompletionChunk)
|
||||||
{
|
{
|
||||||
if (canAddSpace())
|
if (canAddSpace())
|
||||||
m_text += QChar(QChar::Space);
|
m_text += QChar(QChar::Space);
|
||||||
@@ -214,7 +244,8 @@ void CompletionChunksToTextConverter::addExtraVerticalSpaceBetweenBraces()
|
|||||||
addExtraVerticalSpaceBetweenBraces(m_codeCompletionChunks.begin());
|
addExtraVerticalSpaceBetweenBraces(m_codeCompletionChunks.begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompletionChunksToTextConverter::addExtraVerticalSpaceBetweenBraces(const ClangBackEnd::CodeCompletionChunks::iterator &begin)
|
void CompletionChunksToTextConverter::addExtraVerticalSpaceBetweenBraces(
|
||||||
|
const ClangBackEnd::CodeCompletionChunks::iterator &begin)
|
||||||
{
|
{
|
||||||
using ClangBackEnd::CodeCompletionChunk;
|
using ClangBackEnd::CodeCompletionChunk;
|
||||||
|
|
||||||
@@ -256,6 +287,24 @@ void CompletionChunksToTextConverter::addExtraVerticalSpaceBetweenBraces(const C
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CompletionChunksToTextConverter::emphasizeCurrentPlaceHolder() const
|
||||||
|
{
|
||||||
|
if (m_addPlaceHolderPositions) {
|
||||||
|
const uint currentPlaceHolderPosition = m_placeholderPositions.size() + 1;
|
||||||
|
return uint(m_placeHolderPositionToEmphasize) == currentPlaceHolderPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CompletionChunksToTextConverter::appendText(const QString &text, bool boldFormat)
|
||||||
|
{
|
||||||
|
if (boldFormat)
|
||||||
|
m_text += QStringLiteral("<b>") + text + QStringLiteral("</b>");
|
||||||
|
else
|
||||||
|
m_text += text;
|
||||||
|
}
|
||||||
|
|
||||||
bool CompletionChunksToTextConverter::canAddSpace() const
|
bool CompletionChunksToTextConverter::canAddSpace() const
|
||||||
{
|
{
|
||||||
return m_addSpaces
|
return m_addSpaces
|
||||||
@@ -263,6 +312,12 @@ bool CompletionChunksToTextConverter::canAddSpace() const
|
|||||||
&& m_previousCodeCompletionChunk.kind() != ClangBackEnd::CodeCompletionChunk::RightAngle;
|
&& m_previousCodeCompletionChunk.kind() != ClangBackEnd::CodeCompletionChunk::RightAngle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CompletionChunksToTextConverter::isNotOptionalOrAddOptionals(
|
||||||
|
const ClangBackEnd::CodeCompletionChunk &codeCompletionChunk) const
|
||||||
|
{
|
||||||
|
return !codeCompletionChunk.isOptional() || m_addOptional;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace ClangCodeModel
|
} // namespace ClangCodeModel
|
||||||
|
|
||||||
|
|||||||
@@ -52,40 +52,48 @@ public:
|
|||||||
void setAddResultType(bool addResultType);
|
void setAddResultType(bool addResultType);
|
||||||
void setAddSpaces(bool addSpaces);
|
void setAddSpaces(bool addSpaces);
|
||||||
void setAddExtraVerticalSpaceBetweenBraces(bool addExtraVerticalSpaceBetweenBraces);
|
void setAddExtraVerticalSpaceBetweenBraces(bool addExtraVerticalSpaceBetweenBraces);
|
||||||
void setAddHtmlTags(bool addHtmlTags);
|
void setEmphasizeOptional(bool emphasizeOptional);
|
||||||
void setAddOptional(bool addOptional);
|
void setAddOptional(bool addOptional);
|
||||||
|
void setPlaceHolderToEmphasize(int placeHolderNumber);
|
||||||
|
|
||||||
const QString &text() const;
|
const QString &text() const;
|
||||||
const std::vector<int> &placeholderPositions() const;
|
const std::vector<int> &placeholderPositions() const;
|
||||||
bool hasPlaceholderPositions() const;
|
bool hasPlaceholderPositions() const;
|
||||||
|
|
||||||
static QString convertToFunctionSignature(const ClangBackEnd::CodeCompletionChunks &codeCompletionChunks);
|
static QString convertToFunctionSignature(const ClangBackEnd::CodeCompletionChunks &codeCompletionChunks,
|
||||||
|
int parameterToEmphasize = -1);
|
||||||
static QString convertToName(const ClangBackEnd::CodeCompletionChunks &codeCompletionChunks);
|
static QString convertToName(const ClangBackEnd::CodeCompletionChunks &codeCompletionChunks);
|
||||||
static QString convertToToolTip(const ClangBackEnd::CodeCompletionChunks &codeCompletionChunks);
|
static QString convertToToolTip(const ClangBackEnd::CodeCompletionChunks &codeCompletionChunks);
|
||||||
private:
|
private:
|
||||||
void parse(const ClangBackEnd::CodeCompletionChunk & codeCompletionChunk);
|
void parse(const ClangBackEnd::CodeCompletionChunk &codeCompletionChunk);
|
||||||
|
void parseDependendOnTheOptionalState(const ClangBackEnd::CodeCompletionChunk &codeCompletionChunk);
|
||||||
void parseResultType(const Utf8String &text);
|
void parseResultType(const Utf8String &text);
|
||||||
void parseText(const Utf8String &text);
|
void parseText(const Utf8String &text);
|
||||||
void parseOptional(const ClangBackEnd::CodeCompletionChunk &optionalCodeCompletionChunk);
|
void wrapInCursiveTagIfOptional(const ClangBackEnd::CodeCompletionChunk &codeCompletionChunk);
|
||||||
void parsePlaceHolder(const ClangBackEnd::CodeCompletionChunk &codeCompletionChunk);
|
void parsePlaceHolder(const ClangBackEnd::CodeCompletionChunk &codeCompletionChunk);
|
||||||
void parseLeftParen(const ClangBackEnd::CodeCompletionChunk &codeCompletionChunk);
|
void parseLeftParen(const ClangBackEnd::CodeCompletionChunk &codeCompletionChunk);
|
||||||
void parseLeftBrace(const ClangBackEnd::CodeCompletionChunk &codeCompletionChunk);
|
void parseLeftBrace(const ClangBackEnd::CodeCompletionChunk &codeCompletionChunk);
|
||||||
void addExtraVerticalSpaceBetweenBraces();
|
void addExtraVerticalSpaceBetweenBraces();
|
||||||
void addExtraVerticalSpaceBetweenBraces(const ClangBackEnd::CodeCompletionChunks::iterator &);
|
void addExtraVerticalSpaceBetweenBraces(const ClangBackEnd::CodeCompletionChunks::iterator &);
|
||||||
|
|
||||||
|
void appendText(const QString &text, bool boldFormat = false);
|
||||||
bool canAddSpace() const;
|
bool canAddSpace() const;
|
||||||
|
bool isNotOptionalOrAddOptionals(const ClangBackEnd::CodeCompletionChunk &codeCompletionChunk) const;
|
||||||
|
|
||||||
|
bool emphasizeCurrentPlaceHolder() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<int> m_placeholderPositions;
|
std::vector<int> m_placeholderPositions;
|
||||||
ClangBackEnd::CodeCompletionChunks m_codeCompletionChunks;
|
ClangBackEnd::CodeCompletionChunks m_codeCompletionChunks;
|
||||||
ClangBackEnd::CodeCompletionChunk m_previousCodeCompletionChunk;
|
ClangBackEnd::CodeCompletionChunk m_previousCodeCompletionChunk;
|
||||||
QString m_text;
|
QString m_text;
|
||||||
|
int m_placeHolderPositionToEmphasize = -1;
|
||||||
bool m_addPlaceHolderText = false;
|
bool m_addPlaceHolderText = false;
|
||||||
bool m_addPlaceHolderPositions = false;
|
bool m_addPlaceHolderPositions = false;
|
||||||
bool m_addResultType = false;
|
bool m_addResultType = false;
|
||||||
bool m_addSpaces = false;
|
bool m_addSpaces = false;
|
||||||
bool m_addExtraVerticalSpaceBetweenBraces = false;
|
bool m_addExtraVerticalSpaceBetweenBraces = false;
|
||||||
bool m_addHtmlTags = false;
|
bool m_emphasizeOptional = false;
|
||||||
bool m_addOptional = false;
|
bool m_addOptional = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ using namespace CPlusPlus;
|
|||||||
|
|
||||||
ClangFunctionHintModel::ClangFunctionHintModel(const ClangBackEnd::CodeCompletions &functionSymbols)
|
ClangFunctionHintModel::ClangFunctionHintModel(const ClangBackEnd::CodeCompletions &functionSymbols)
|
||||||
: m_functionSymbols(functionSymbols)
|
: m_functionSymbols(functionSymbols)
|
||||||
, m_currentArg(-1)
|
, m_currentArgument(-1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,52 +56,61 @@ int ClangFunctionHintModel::size() const
|
|||||||
|
|
||||||
QString ClangFunctionHintModel::text(int index) const
|
QString ClangFunctionHintModel::text(int index) const
|
||||||
{
|
{
|
||||||
#if 0
|
const ClangBackEnd::CodeCompletionChunks chunks = m_functionSymbols.at(index).chunks();
|
||||||
// TODO: add the boldening to the result
|
const QString signatureWithEmphasizedCurrentParameter
|
||||||
Overview overview;
|
= CompletionChunksToTextConverter::convertToFunctionSignature(chunks, m_currentArgument + 1);
|
||||||
overview.setShowReturnTypes(true);
|
|
||||||
overview.setShowArgumentNames(true);
|
|
||||||
overview.setMarkedArgument(m_currentArg + 1);
|
|
||||||
Function *f = m_functionSymbols.at(index);
|
|
||||||
|
|
||||||
const QString prettyMethod = overview(f->type(), f->name());
|
return signatureWithEmphasizedCurrentParameter;
|
||||||
const int begin = overview.markedArgumentBegin();
|
|
||||||
const int end = overview.markedArgumentEnd();
|
|
||||||
|
|
||||||
QString hintText;
|
|
||||||
hintText += prettyMethod.left(begin).toHtmlEscaped());
|
|
||||||
hintText += "<b>";
|
|
||||||
hintText += prettyMethod.mid(begin, end - begin).toHtmlEscaped());
|
|
||||||
hintText += "</b>";
|
|
||||||
hintText += prettyMethod.mid(end).toHtmlEscaped());
|
|
||||||
return hintText;
|
|
||||||
#endif
|
|
||||||
return CompletionChunksToTextConverter::convertToFunctionSignature(m_functionSymbols.at(index).chunks());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ClangFunctionHintModel::activeArgument(const QString &prefix) const
|
int ClangFunctionHintModel::activeArgument(const QString &prefix) const
|
||||||
{
|
{
|
||||||
int argnr = 0;
|
int activeArgumentNumber = 0;
|
||||||
int parcount = 0;
|
|
||||||
|
int unbalancedParens = 0; // expressions
|
||||||
|
int unbalancedBraces = 0; // initializer lists
|
||||||
|
int unbalancedBrackets = 0; // lambda-capture
|
||||||
|
int unbalancedLessGreater = 0; // template arguments
|
||||||
|
|
||||||
SimpleLexer tokenize;
|
SimpleLexer tokenize;
|
||||||
Tokens tokens = tokenize(prefix);
|
const Tokens tokens = tokenize(prefix);
|
||||||
for (int i = 0; i < tokens.count(); ++i) {
|
for (const Token &token : tokens) {
|
||||||
const Token &tk = tokens.at(i);
|
if (token.is(T_LPAREN)) {
|
||||||
if (tk.is(T_LPAREN))
|
++unbalancedParens;
|
||||||
++parcount;
|
} else if (token.is(T_RPAREN)) {
|
||||||
else if (tk.is(T_RPAREN))
|
--unbalancedParens;
|
||||||
--parcount;
|
} else if (token.is(T_LBRACE)) {
|
||||||
else if (! parcount && tk.is(T_COMMA))
|
++unbalancedBraces;
|
||||||
++argnr;
|
} else if (token.is(T_RBRACE)) {
|
||||||
|
--unbalancedBraces;
|
||||||
|
} else if (token.is(T_LBRACKET)) {
|
||||||
|
++unbalancedBrackets;
|
||||||
|
} else if (token.is(T_RBRACKET)) {
|
||||||
|
--unbalancedBrackets;
|
||||||
|
} else if (token.is(T_LESS)) {
|
||||||
|
++unbalancedLessGreater;
|
||||||
|
} else if (token.is(T_GREATER)) {
|
||||||
|
--unbalancedLessGreater;
|
||||||
|
} else if (!unbalancedParens
|
||||||
|
&& !unbalancedBraces
|
||||||
|
&& !unbalancedBrackets
|
||||||
|
&& !unbalancedLessGreater
|
||||||
|
&& token.is(T_COMMA)) {
|
||||||
|
++activeArgumentNumber;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parcount < 0)
|
if (unbalancedParens < 0
|
||||||
|
|| unbalancedBraces < 0
|
||||||
|
|| unbalancedBrackets < 0
|
||||||
|
|| unbalancedLessGreater < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (argnr != m_currentArg)
|
if (activeArgumentNumber != m_currentArgument)
|
||||||
m_currentArg = argnr;
|
m_currentArgument = activeArgumentNumber;
|
||||||
|
|
||||||
return argnr;
|
return activeArgumentNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
ClangBackEnd::CodeCompletions m_functionSymbols;
|
ClangBackEnd::CodeCompletions m_functionSymbols;
|
||||||
mutable int m_currentArg;
|
mutable int m_currentArgument;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -914,11 +914,11 @@ void ClangCodeCompletionTest::testCompleteFunctions()
|
|||||||
|
|
||||||
QVERIFY(hasItem(t.proposal, "void f()"));
|
QVERIFY(hasItem(t.proposal, "void f()"));
|
||||||
QVERIFY(hasItem(t.proposal, "void f(int a)"));
|
QVERIFY(hasItem(t.proposal, "void f(int a)"));
|
||||||
QVERIFY(hasItem(t.proposal, "void f(const QString &s)"));
|
QVERIFY(hasItem(t.proposal, "void f(const QString &s)"));
|
||||||
QVERIFY(hasItem(t.proposal, "void f(char c, int optional)")); // TODO: No default argument?
|
QVERIFY(hasItem(t.proposal, "void f(char c<i>, int optional</i>)")); // TODO: No default argument?
|
||||||
QVERIFY(hasItem(t.proposal, "void f(char c, int optional1, int optional2)")); // TODO: No default argument?
|
QVERIFY(hasItem(t.proposal, "void f(char c<i>, int optional1, int optional2</i>)")); // TODO: No default argument?
|
||||||
QVERIFY(hasItem(t.proposal, "void f(const TType<QString> *t)"));
|
QVERIFY(hasItem(t.proposal, "void f(const TType<QString> *t)"));
|
||||||
QVERIFY(hasItem(t.proposal, "TType<QString> f(bool)"));
|
QVERIFY(hasItem(t.proposal, "TType<QString> f(bool)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClangCodeCompletionTest::testCompleteConstructorAndFallbackToGlobalCompletion()
|
void ClangCodeCompletionTest::testCompleteConstructorAndFallbackToGlobalCompletion()
|
||||||
|
|||||||
@@ -3659,7 +3659,7 @@ void GdbEngine::handleVarAssign(const DebuggerResponse &)
|
|||||||
void GdbEngine::assignValueInDebugger(WatchItem *item,
|
void GdbEngine::assignValueInDebugger(WatchItem *item,
|
||||||
const QString &expression, const QVariant &value)
|
const QString &expression, const QVariant &value)
|
||||||
{
|
{
|
||||||
DebuggerCommand cmd("assignValue");
|
DebuggerCommand cmd("assignValue", PythonCommand);
|
||||||
cmd.arg("type", item->type.toHex());
|
cmd.arg("type", item->type.toHex());
|
||||||
cmd.arg("expr", expression.toLatin1().toHex());
|
cmd.arg("expr", expression.toLatin1().toHex());
|
||||||
cmd.arg("value", value.toString().toLatin1().toHex());
|
cmd.arg("value", value.toString().toLatin1().toHex());
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ TextBrowserHelpViewer::TextBrowserHelpViewer(QWidget *parent)
|
|||||||
: HelpViewer(parent)
|
: HelpViewer(parent)
|
||||||
, m_textBrowser(new TextBrowserHelpWidget(this))
|
, m_textBrowser(new TextBrowserHelpWidget(this))
|
||||||
{
|
{
|
||||||
|
m_textBrowser->setOpenLinks(false);
|
||||||
QVBoxLayout *layout = new QVBoxLayout;
|
QVBoxLayout *layout = new QVBoxLayout;
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
@@ -68,6 +69,8 @@ TextBrowserHelpViewer::TextBrowserHelpViewer(QWidget *parent)
|
|||||||
p.setColor(QPalette::Text, Qt::black);
|
p.setColor(QPalette::Text, Qt::black);
|
||||||
setPalette(p);
|
setPalette(p);
|
||||||
|
|
||||||
|
connect(m_textBrowser, &TextBrowserHelpWidget::anchorClicked,
|
||||||
|
this, &TextBrowserHelpViewer::setSource);
|
||||||
connect(m_textBrowser, SIGNAL(sourceChanged(QUrl)), this, SIGNAL(titleChanged()));
|
connect(m_textBrowser, SIGNAL(sourceChanged(QUrl)), this, SIGNAL(titleChanged()));
|
||||||
connect(m_textBrowser, SIGNAL(forwardAvailable(bool)), this, SIGNAL(forwardAvailable(bool)));
|
connect(m_textBrowser, SIGNAL(forwardAvailable(bool)), this, SIGNAL(forwardAvailable(bool)));
|
||||||
connect(m_textBrowser, SIGNAL(backwardAvailable(bool)), this, SIGNAL(backwardAvailable(bool)));
|
connect(m_textBrowser, SIGNAL(backwardAvailable(bool)), this, SIGNAL(backwardAvailable(bool)));
|
||||||
@@ -315,7 +318,7 @@ TextBrowserHelpWidget::TextBrowserHelpWidget(TextBrowserHelpViewer *parent)
|
|||||||
|
|
||||||
QVariant TextBrowserHelpWidget::loadResource(int type, const QUrl &name)
|
QVariant TextBrowserHelpWidget::loadResource(int type, const QUrl &name)
|
||||||
{
|
{
|
||||||
if (type < 4)
|
if (type < QTextDocument::UserResource)
|
||||||
return LocalHelpManager::helpData(name).data;
|
return LocalHelpManager::helpData(name).data;
|
||||||
return QByteArray();
|
return QByteArray();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -858,6 +858,8 @@ bool QmlJSCompletionAssistProcessor::acceptsIdleEditor() const
|
|||||||
maybeAccept = true;
|
maybeAccept = true;
|
||||||
} else {
|
} else {
|
||||||
const QChar &charUnderCursor = m_interface->textDocument()->characterAt(cursorPos);
|
const QChar &charUnderCursor = m_interface->textDocument()->characterAt(cursorPos);
|
||||||
|
if (isValidIdentifierChar(charUnderCursor))
|
||||||
|
return false;
|
||||||
if (isIdentifierChar(charBeforeCursor)
|
if (isIdentifierChar(charBeforeCursor)
|
||||||
&& ((charUnderCursor.isSpace()
|
&& ((charUnderCursor.isSpace()
|
||||||
|| charUnderCursor.isNull()
|
|| charUnderCursor.isNull()
|
||||||
|
|||||||
@@ -54,6 +54,15 @@ bool isIdentifierChar(const QChar &c, bool atStart, bool acceptDollar)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isValidFirstIdentifierChar(const QChar &ch) {
|
||||||
|
return ch.isLetter() || ch == QLatin1Char('_') || ch.isHighSurrogate()
|
||||||
|
|| ch.isLowSurrogate();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isValidIdentifierChar(const QChar &ch) {
|
||||||
|
return isValidFirstIdentifierChar(ch) || ch.isNumber();
|
||||||
|
}
|
||||||
|
|
||||||
bool isDelimiterChar(const QChar &c)
|
bool isDelimiterChar(const QChar &c)
|
||||||
{
|
{
|
||||||
switch (c.unicode()) {
|
switch (c.unicode()) {
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ namespace QmlJSEditor {
|
|||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
bool isIdentifierChar(const QChar &c, bool atStart = false, bool acceptDollar = true);
|
bool isIdentifierChar(const QChar &c, bool atStart = false, bool acceptDollar = true);
|
||||||
|
bool isValidFirstIdentifierChar(const QChar &c);
|
||||||
|
bool isValidIdentifierChar(const QChar &c);
|
||||||
bool isDelimiterChar(const QChar &c);
|
bool isDelimiterChar(const QChar &c);
|
||||||
bool isActivationChar(const QChar &c);
|
bool isActivationChar(const QChar &c);
|
||||||
|
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ void QnxSettingsWidget::populateConfigsCombo()
|
|||||||
void QnxSettingsWidget::setConfigState(QnxConfiguration *config,
|
void QnxSettingsWidget::setConfigState(QnxConfiguration *config,
|
||||||
QnxSettingsWidget::State state)
|
QnxSettingsWidget::State state)
|
||||||
{
|
{
|
||||||
QnxSettingsWidget::State stateToRemove;
|
QnxSettingsWidget::State stateToRemove = QnxSettingsWidget::Activated;
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case QnxSettingsWidget::Added :
|
case QnxSettingsWidget::Added :
|
||||||
stateToRemove = QnxSettingsWidget::Removed;
|
stateToRemove = QnxSettingsWidget::Removed;
|
||||||
@@ -184,6 +184,7 @@ void QnxSettingsWidget::setConfigState(QnxConfiguration *config,
|
|||||||
break;
|
break;
|
||||||
case QnxSettingsWidget::Deactivated:
|
case QnxSettingsWidget::Deactivated:
|
||||||
stateToRemove = QnxSettingsWidget::Activated;
|
stateToRemove = QnxSettingsWidget::Activated;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (const ConfigState &configState, m_changedConfigs) {
|
foreach (const ConfigState &configState, m_changedConfigs) {
|
||||||
|
|||||||
@@ -38,7 +38,6 @@
|
|||||||
#include "qmakeparser.h"
|
#include "qmakeparser.h"
|
||||||
#include "ioutils.h"
|
#include "ioutils.h"
|
||||||
|
|
||||||
#include <qiodevice.h>
|
|
||||||
#include <qlist.h>
|
#include <qlist.h>
|
||||||
#include <qlinkedlist.h>
|
#include <qlinkedlist.h>
|
||||||
#include <qmap.h>
|
#include <qmap.h>
|
||||||
@@ -49,6 +48,8 @@
|
|||||||
#include <qshareddata.h>
|
#include <qshareddata.h>
|
||||||
#ifndef QT_BOOTSTRAPPED
|
#ifndef QT_BOOTSTRAPPED
|
||||||
# include <qprocess.h>
|
# include <qprocess.h>
|
||||||
|
#else
|
||||||
|
# include <qiodevice.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef PROEVALUATOR_THREAD_SAFE
|
#ifdef PROEVALUATOR_THREAD_SAFE
|
||||||
# include <qmutex.h>
|
# include <qmutex.h>
|
||||||
|
|||||||
@@ -42,13 +42,12 @@ void CodeCompletionChunkConverter::extractCompletionChunks(CXCompletionString co
|
|||||||
for (uint chunkIndex = 0; chunkIndex < completionChunkCount; ++chunkIndex) {
|
for (uint chunkIndex = 0; chunkIndex < completionChunkCount; ++chunkIndex) {
|
||||||
const CodeCompletionChunk::Kind kind = chunkKind(completionString, chunkIndex);
|
const CodeCompletionChunk::Kind kind = chunkKind(completionString, chunkIndex);
|
||||||
|
|
||||||
if (kind == CodeCompletionChunk::Optional)
|
if (kind == CodeCompletionChunk::Optional) {
|
||||||
chunks.append(CodeCompletionChunk(kind,
|
extractOptionalCompletionChunks(clang_getCompletionChunkCompletionString(completionString, chunkIndex));
|
||||||
chunkText(completionString, chunkIndex),
|
} else {
|
||||||
optionalChunks(completionString, chunkIndex)));
|
|
||||||
else
|
|
||||||
chunks.append(CodeCompletionChunk(kind,
|
chunks.append(CodeCompletionChunk(kind,
|
||||||
chunkText(completionString, chunkIndex)));
|
chunkText(completionString, chunkIndex)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,7 +61,7 @@ void CodeCompletionChunkConverter::extractOptionalCompletionChunks(CXCompletionS
|
|||||||
if (kind == CodeCompletionChunk::Optional)
|
if (kind == CodeCompletionChunk::Optional)
|
||||||
extractOptionalCompletionChunks(clang_getCompletionChunkCompletionString(completionString, chunkIndex));
|
extractOptionalCompletionChunks(clang_getCompletionChunkCompletionString(completionString, chunkIndex));
|
||||||
else
|
else
|
||||||
chunks.append(CodeCompletionChunk(kind, chunkText(completionString, chunkIndex)));
|
chunks.append(CodeCompletionChunk(kind, chunkText(completionString, chunkIndex), true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,14 +84,5 @@ Utf8String CodeCompletionChunkConverter::chunkText(CXCompletionString completion
|
|||||||
return ClangString(clang_getCompletionChunkText(completionString, chunkIndex));
|
return ClangString(clang_getCompletionChunkText(completionString, chunkIndex));
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeCompletionChunks CodeCompletionChunkConverter::optionalChunks(CXCompletionString completionString, uint chunkIndex)
|
|
||||||
{
|
|
||||||
CodeCompletionChunkConverter converter;
|
|
||||||
|
|
||||||
converter.extractOptionalCompletionChunks(clang_getCompletionChunkCompletionString(completionString, chunkIndex));
|
|
||||||
|
|
||||||
return converter.chunks;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace ClangBackEnd
|
} // namespace ClangBackEnd
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ public:
|
|||||||
static Utf8String chunkText(CXCompletionString completionString, uint chunkIndex);
|
static Utf8String chunkText(CXCompletionString completionString, uint chunkIndex);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CodeCompletionChunks optionalChunks(CXCompletionString completionString, uint chunkIndex);
|
|
||||||
static CodeCompletionChunk::Kind chunkKind(CXCompletionString completionString, uint chunkIndex);
|
static CodeCompletionChunk::Kind chunkKind(CXCompletionString completionString, uint chunkIndex);
|
||||||
void extractCompletionChunks(CXCompletionString completionString);
|
void extractCompletionChunks(CXCompletionString completionString);
|
||||||
void extractOptionalCompletionChunks(CXCompletionString completionString);
|
void extractOptionalCompletionChunks(CXCompletionString completionString);
|
||||||
|
|||||||
@@ -201,6 +201,7 @@ HighlightingType HighlightingInformation::identifierKind(const Cursor &cursor) c
|
|||||||
case CXCursor_TemplateTemplateParameter:
|
case CXCursor_TemplateTemplateParameter:
|
||||||
case CXCursor_UnionDecl:
|
case CXCursor_UnionDecl:
|
||||||
case CXCursor_StructDecl:
|
case CXCursor_StructDecl:
|
||||||
|
case CXCursor_OverloadedDeclRef:
|
||||||
case CXCursor_TemplateRef:
|
case CXCursor_TemplateRef:
|
||||||
case CXCursor_Namespace:
|
case CXCursor_Namespace:
|
||||||
case CXCursor_NamespaceRef:
|
case CXCursor_NamespaceRef:
|
||||||
|
|||||||
@@ -630,11 +630,10 @@ TEST_F(CodeCompletionsExtractor, CompletionChunksFunctionWithOptionalChunks)
|
|||||||
{CodeCompletionChunk::TypedText, Utf8StringLiteral("FunctionWithOptional")},
|
{CodeCompletionChunk::TypedText, Utf8StringLiteral("FunctionWithOptional")},
|
||||||
{CodeCompletionChunk::LeftParen, Utf8StringLiteral("(")},
|
{CodeCompletionChunk::LeftParen, Utf8StringLiteral("(")},
|
||||||
{CodeCompletionChunk::Placeholder, Utf8StringLiteral("int x")},
|
{CodeCompletionChunk::Placeholder, Utf8StringLiteral("int x")},
|
||||||
{CodeCompletionChunk::Optional, Utf8String(), CodeCompletionChunks({
|
{CodeCompletionChunk::Comma, Utf8StringLiteral(", "), true},
|
||||||
{CodeCompletionChunk::Comma, Utf8StringLiteral(", ")},
|
{CodeCompletionChunk::Placeholder, Utf8StringLiteral("char y"), true},
|
||||||
{CodeCompletionChunk::Placeholder, Utf8StringLiteral("char y")},
|
{CodeCompletionChunk::Comma, Utf8StringLiteral(", "), true},
|
||||||
{CodeCompletionChunk::Comma, Utf8StringLiteral(", ")},
|
{CodeCompletionChunk::Placeholder, Utf8StringLiteral("int z"), true},
|
||||||
{CodeCompletionChunk::Placeholder, Utf8StringLiteral("int z")}})},
|
|
||||||
{CodeCompletionChunk::RightParen, Utf8StringLiteral(")")}})));
|
{CodeCompletionChunk::RightParen, Utf8StringLiteral(")")}})));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ protected:
|
|||||||
protected:
|
protected:
|
||||||
Converter converter;
|
Converter converter;
|
||||||
CodeCompletionChunk integerResultType{CodeCompletionChunk::ResultType, Utf8StringLiteral("int")};
|
CodeCompletionChunk integerResultType{CodeCompletionChunk::ResultType, Utf8StringLiteral("int")};
|
||||||
|
CodeCompletionChunk templateResultType{CodeCompletionChunk::ResultType, Utf8StringLiteral("Foo<int>")};
|
||||||
CodeCompletionChunk enumerationResultType{CodeCompletionChunk::ResultType, Utf8StringLiteral("Enumeration")};
|
CodeCompletionChunk enumerationResultType{CodeCompletionChunk::ResultType, Utf8StringLiteral("Enumeration")};
|
||||||
CodeCompletionChunk functionName{CodeCompletionChunk::TypedText, Utf8StringLiteral("Function")};
|
CodeCompletionChunk functionName{CodeCompletionChunk::TypedText, Utf8StringLiteral("Function")};
|
||||||
CodeCompletionChunk variableName{CodeCompletionChunk::TypedText, Utf8StringLiteral("Variable")};
|
CodeCompletionChunk variableName{CodeCompletionChunk::TypedText, Utf8StringLiteral("Variable")};
|
||||||
@@ -63,6 +64,7 @@ protected:
|
|||||||
CodeCompletionChunk functionArgumentX{CodeCompletionChunk::Placeholder, Utf8StringLiteral("char x")};
|
CodeCompletionChunk functionArgumentX{CodeCompletionChunk::Placeholder, Utf8StringLiteral("char x")};
|
||||||
CodeCompletionChunk functionArgumentY{CodeCompletionChunk::Placeholder, Utf8StringLiteral("int y")};
|
CodeCompletionChunk functionArgumentY{CodeCompletionChunk::Placeholder, Utf8StringLiteral("int y")};
|
||||||
CodeCompletionChunk functionArgumentZ{CodeCompletionChunk::Placeholder, Utf8StringLiteral("int z")};
|
CodeCompletionChunk functionArgumentZ{CodeCompletionChunk::Placeholder, Utf8StringLiteral("int z")};
|
||||||
|
CodeCompletionChunk functionArgumentTemplate{CodeCompletionChunk::Placeholder, Utf8StringLiteral("const Foo<int> &foo")};
|
||||||
CodeCompletionChunk switchName{CodeCompletionChunk::TypedText, Utf8StringLiteral("switch")};
|
CodeCompletionChunk switchName{CodeCompletionChunk::TypedText, Utf8StringLiteral("switch")};
|
||||||
CodeCompletionChunk condition{CodeCompletionChunk::Placeholder, Utf8StringLiteral("condition")};
|
CodeCompletionChunk condition{CodeCompletionChunk::Placeholder, Utf8StringLiteral("condition")};
|
||||||
CodeCompletionChunk leftBrace{CodeCompletionChunk::LeftBrace, Utf8StringLiteral("{")};
|
CodeCompletionChunk leftBrace{CodeCompletionChunk::LeftBrace, Utf8StringLiteral("{")};
|
||||||
@@ -80,10 +82,12 @@ protected:
|
|||||||
CodeCompletionChunk elseName{CodeCompletionChunk::TypedText, Utf8StringLiteral("else")};
|
CodeCompletionChunk elseName{CodeCompletionChunk::TypedText, Utf8StringLiteral("else")};
|
||||||
CodeCompletionChunk ifName{CodeCompletionChunk::TypedText, Utf8StringLiteral("if")};
|
CodeCompletionChunk ifName{CodeCompletionChunk::TypedText, Utf8StringLiteral("if")};
|
||||||
CodeCompletionChunk horizontalSpace{CodeCompletionChunk::HorizontalSpace, Utf8StringLiteral(" ")};
|
CodeCompletionChunk horizontalSpace{CodeCompletionChunk::HorizontalSpace, Utf8StringLiteral(" ")};
|
||||||
CodeCompletionChunk optional{CodeCompletionChunk::Optional, Utf8String(), {comma, functionArgumentY, comma, functionArgumentZ}};
|
|
||||||
CodeCompletionChunk enableIfT{CodeCompletionChunk::TypedText, Utf8StringLiteral("enable_if_t")};
|
CodeCompletionChunk enableIfT{CodeCompletionChunk::TypedText, Utf8StringLiteral("enable_if_t")};
|
||||||
CodeCompletionChunk enableIfTCondition{CodeCompletionChunk::Placeholder, Utf8StringLiteral("_Cond")};
|
CodeCompletionChunk enableIfTCondition{CodeCompletionChunk::Placeholder, Utf8StringLiteral("_Cond")};
|
||||||
CodeCompletionChunk enableIfTType{CodeCompletionChunk::Placeholder, Utf8StringLiteral("_Tp")};
|
CodeCompletionChunk optionalEnableIfTType{CodeCompletionChunk::Placeholder, Utf8StringLiteral("_Tp"), true};
|
||||||
|
CodeCompletionChunk optionalComma{CodeCompletionChunk::Comma, Utf8StringLiteral(", "), true};
|
||||||
|
CodeCompletionChunk optionalFunctionArgumentY{CodeCompletionChunk::Placeholder, Utf8StringLiteral("int y"), true};
|
||||||
|
CodeCompletionChunk optionalFunctionArgumentZ{CodeCompletionChunk::Placeholder, Utf8StringLiteral("int z"), true};
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(CompletionChunksToTextConverter, ParseIsClearingText)
|
TEST_F(CompletionChunksToTextConverter, ParseIsClearingText)
|
||||||
@@ -117,9 +121,111 @@ TEST_F(CompletionChunksToTextConverter, ConvertFunctionWithParameters)
|
|||||||
ASSERT_THAT(converter.text(), QStringLiteral("int Function(char x)"));
|
ASSERT_THAT(converter.text(), QStringLiteral("int Function(char x)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(CompletionChunksToTextConverter, ConvertToFunctionSignatureWithOneArgument)
|
||||||
|
{
|
||||||
|
CodeCompletionChunks completionChunks({integerResultType,
|
||||||
|
functionName,
|
||||||
|
leftParen,
|
||||||
|
functionArgumentX,
|
||||||
|
rightParen});
|
||||||
|
|
||||||
|
using ClangCodeModel::Internal::CompletionChunksToTextConverter;
|
||||||
|
|
||||||
|
ASSERT_THAT(converter.convertToFunctionSignature(completionChunks),
|
||||||
|
QStringLiteral("int Function(char x)"));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(CompletionChunksToTextConverter, ConvertToFunctionSignatureWithOneParameterThatIsActive)
|
||||||
|
{
|
||||||
|
CodeCompletionChunks completionChunks({integerResultType,
|
||||||
|
functionName,
|
||||||
|
leftParen,
|
||||||
|
functionArgumentX,
|
||||||
|
rightParen});
|
||||||
|
|
||||||
|
ASSERT_THAT(converter.convertToFunctionSignature(completionChunks, 1),
|
||||||
|
QStringLiteral("int Function(<b>char x</b>)"));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(CompletionChunksToTextConverter, ConvertToFunctionSignatureWithOneParameterAndInInvalidActiveParameter)
|
||||||
|
{
|
||||||
|
CodeCompletionChunks completionChunks({integerResultType,
|
||||||
|
functionName,
|
||||||
|
leftParen,
|
||||||
|
functionArgumentX,
|
||||||
|
rightParen});
|
||||||
|
|
||||||
|
ASSERT_THAT(converter.convertToFunctionSignature(completionChunks, -1),
|
||||||
|
QStringLiteral("int Function(char x)"));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(CompletionChunksToTextConverter, ConvertToFunctionSignatureWithTwoParametersWhereOneIsActive)
|
||||||
|
{
|
||||||
|
CodeCompletionChunks completionChunks({integerResultType,
|
||||||
|
functionName,
|
||||||
|
leftParen,
|
||||||
|
functionArgumentX,
|
||||||
|
comma,
|
||||||
|
functionArgumentY,
|
||||||
|
rightParen});
|
||||||
|
|
||||||
|
ASSERT_THAT(converter.convertToFunctionSignature(completionChunks, 2),
|
||||||
|
QStringLiteral("int Function(char x, <b>int y</b>)"));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(CompletionChunksToTextConverter, ConvertToFunctionSignatureWithTwoParametersWhereOneIsOptionalAndActive)
|
||||||
|
{
|
||||||
|
CodeCompletionChunks completionChunks({integerResultType,
|
||||||
|
functionName,
|
||||||
|
leftParen,
|
||||||
|
functionArgumentX,
|
||||||
|
optionalComma,
|
||||||
|
optionalFunctionArgumentY,
|
||||||
|
rightParen});
|
||||||
|
|
||||||
|
ASSERT_THAT(converter.convertToFunctionSignature(completionChunks, 2),
|
||||||
|
QStringLiteral("int Function(char x<i>, <b>int y</b></i>)"));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(CompletionChunksToTextConverter, ConvertToFunctionSignatureWithTemplateReturnType)
|
||||||
|
{
|
||||||
|
CodeCompletionChunks completionChunks({templateResultType,
|
||||||
|
functionName,
|
||||||
|
leftParen,
|
||||||
|
functionArgumentX,
|
||||||
|
rightParen});
|
||||||
|
|
||||||
|
using ClangCodeModel::Internal::CompletionChunksToTextConverter;
|
||||||
|
|
||||||
|
ASSERT_THAT(CompletionChunksToTextConverter::convertToFunctionSignature(completionChunks),
|
||||||
|
QStringLiteral("Foo<int> Function(char x)"));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(CompletionChunksToTextConverter, ConvertToFunctionSignatureWithTemplateArgument)
|
||||||
|
{
|
||||||
|
CodeCompletionChunks completionChunks({integerResultType,
|
||||||
|
functionName,
|
||||||
|
leftParen,
|
||||||
|
functionArgumentTemplate,
|
||||||
|
rightParen});
|
||||||
|
|
||||||
|
using ClangCodeModel::Internal::CompletionChunksToTextConverter;
|
||||||
|
|
||||||
|
ASSERT_THAT(CompletionChunksToTextConverter::convertToFunctionSignature(completionChunks),
|
||||||
|
QStringLiteral("int Function(const Foo<int> &foo)"));
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(CompletionChunksToTextConverter, ConvertFunctionWithOptionalParameter)
|
TEST_F(CompletionChunksToTextConverter, ConvertFunctionWithOptionalParameter)
|
||||||
{
|
{
|
||||||
CodeCompletionChunks completionChunks({integerResultType, functionName, leftParen, functionArgumentX, optional,rightParen});
|
CodeCompletionChunks completionChunks({integerResultType,
|
||||||
|
functionName,
|
||||||
|
leftParen,
|
||||||
|
functionArgumentX,
|
||||||
|
optionalComma,
|
||||||
|
optionalFunctionArgumentY,
|
||||||
|
optionalComma,
|
||||||
|
optionalFunctionArgumentZ,
|
||||||
|
rightParen});
|
||||||
|
|
||||||
ASSERT_THAT(Converter::convertToToolTip(completionChunks),
|
ASSERT_THAT(Converter::convertToToolTip(completionChunks),
|
||||||
QStringLiteral("int Function (char x<i>, int y, int z</i>)"));
|
QStringLiteral("int Function (char x<i>, int y, int z</i>)"));
|
||||||
@@ -157,12 +263,12 @@ TEST_F(CompletionChunksToTextConverter, Enumeration)
|
|||||||
TEST_F(CompletionChunksToTextConverter, Switch)
|
TEST_F(CompletionChunksToTextConverter, Switch)
|
||||||
{
|
{
|
||||||
CodeCompletionChunks completionChunks({switchName,
|
CodeCompletionChunks completionChunks({switchName,
|
||||||
leftParen,
|
leftParen,
|
||||||
condition,
|
condition,
|
||||||
rightParen,
|
rightParen,
|
||||||
leftBrace,
|
leftBrace,
|
||||||
verticalSpace,
|
verticalSpace,
|
||||||
rightBrace});
|
rightBrace});
|
||||||
setupConverterForKeywords();
|
setupConverterForKeywords();
|
||||||
|
|
||||||
converter.parseChunks(completionChunks);
|
converter.parseChunks(completionChunks);
|
||||||
@@ -204,7 +310,7 @@ TEST_F(CompletionChunksToTextConverter, const_cast)
|
|||||||
|
|
||||||
converter.parseChunks(completionChunks);
|
converter.parseChunks(completionChunks);
|
||||||
|
|
||||||
ASSERT_THAT(converter.text(), QStringLiteral("const_cast<>()"));
|
ASSERT_THAT(converter.text(), QStringLiteral("const_cast<>()"));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(CompletionChunksToTextConverter, Throw)
|
TEST_F(CompletionChunksToTextConverter, Throw)
|
||||||
@@ -239,13 +345,14 @@ TEST_F(CompletionChunksToTextConverter, EnableIfT)
|
|||||||
CodeCompletionChunks completionChunks({enableIfT,
|
CodeCompletionChunks completionChunks({enableIfT,
|
||||||
leftAngle,
|
leftAngle,
|
||||||
enableIfTCondition,
|
enableIfTCondition,
|
||||||
CodeCompletionChunk(CodeCompletionChunk::Optional, Utf8String(), {comma, enableIfTType}),
|
optionalComma,
|
||||||
|
optionalEnableIfTType,
|
||||||
rightAngle});
|
rightAngle});
|
||||||
setupConverterForKeywords();
|
setupConverterForKeywords();
|
||||||
|
|
||||||
converter.parseChunks(completionChunks);
|
converter.parseChunks(completionChunks);
|
||||||
|
|
||||||
ASSERT_THAT(converter.text(), QStringLiteral("enable_if_t<>"));
|
ASSERT_THAT(converter.text(), QStringLiteral("enable_if_t<>"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompletionChunksToTextConverter::setupConverterForKeywords()
|
void CompletionChunksToTextConverter::setupConverterForKeywords()
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ struct StructInNameSpace {};
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace NameSpaceAlias = NameSpace;
|
namespace NameSpaceAlias = NameSpace;
|
||||||
|
using NameSpace::StructInNameSpace;
|
||||||
NameSpace::StructInNameSpace foo6;
|
NameSpace::StructInNameSpace foo6;
|
||||||
|
|
||||||
class BaseClass {
|
class BaseClass {
|
||||||
|
|||||||
@@ -462,6 +462,13 @@ TEST_F(HighlightingInformations, NameSpaceAlias)
|
|||||||
ASSERT_THAT(infos[1], HasType(HighlightingType::Type));
|
ASSERT_THAT(infos[1], HasType(HighlightingType::Type));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(HighlightingInformations, UsingStructInNameSpace)
|
||||||
|
{
|
||||||
|
const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(165, 36));
|
||||||
|
|
||||||
|
ASSERT_THAT(infos[3], HasType(HighlightingType::Type));
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(HighlightingInformations, NameSpaceReference)
|
TEST_F(HighlightingInformations, NameSpaceReference)
|
||||||
{
|
{
|
||||||
const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(166, 35));
|
const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(166, 35));
|
||||||
@@ -469,6 +476,13 @@ TEST_F(HighlightingInformations, NameSpaceReference)
|
|||||||
ASSERT_THAT(infos[0], HasType(HighlightingType::Type));
|
ASSERT_THAT(infos[0], HasType(HighlightingType::Type));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(HighlightingInformations, StructInNameSpaceReference)
|
||||||
|
{
|
||||||
|
const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(166, 35));
|
||||||
|
|
||||||
|
ASSERT_THAT(infos[2], HasType(HighlightingType::Type));
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(HighlightingInformations, VirtualFunction)
|
TEST_F(HighlightingInformations, VirtualFunction)
|
||||||
{
|
{
|
||||||
const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(170, 35));
|
const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(170, 35));
|
||||||
|
|||||||
Reference in New Issue
Block a user