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

Change-Id: I56399e6938a5f5096c0b1a1561a54d34a5c96330
This commit is contained in:
Eike Ziller
2016-06-27 09:50:52 +02:00
87 changed files with 1097 additions and 217 deletions

View File

@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
This color scheme is based on the Monokai color scheme, originally
created by Wimer Hazenberg:
http://www.monokai.nl/blog/2006/07/15/textmate-color-theme/
It was initially modified (hence the name) for Qt Creator,
and fine-tuned over time, by Georger Araújo.
-->
<style-scheme version="1.0" name="Modnokai Night Shift v2">
<style name="Text" foreground="#ffffff" background="#000000"/>
<style name="Link" foreground="#ffff00"/>
<style name="Selection" background="#11404c"/>
<style name="LineNumber" foreground="#888888" background="#272822"/>
<style name="SearchResult" background="#555500"/>
<style name="SearchScope" background="#222200"/>
<style name="Parentheses" foreground="#ffffff" background="#11404c"/>
<style name="CurrentLine" background="#373737"/>
<style name="CurrentLineNumber" foreground="#ffff00"/>
<style name="Occurrences" background="#aa0000"/>
<style name="Occurrences.Unused" foreground="#808000"/>
<style name="Occurrences.Rename" foreground="#ffaaaa" background="#553636"/>
<style name="Number" foreground="#ffcd22"/>
<style name="String" foreground="#e0a000"/>
<style name="Type" foreground="#ff8080"/>
<style name="Local"/>
<style name="Field"/>
<style name="Static" foreground="#55ff55" italic="true"/>
<style name="VirtualMethod" italic="true"/>
<style name="Function"/>
<style name="Keyword" foreground="#78d7ec" italic="true"/>
<style name="PrimitiveType" foreground="#ff8080"/>
<style name="Operator" foreground="#a6e22e"/>
<style name="Preprocessor" foreground="#f92672"/>
<style name="Label" foreground="#ffff55"/>
<style name="Comment" foreground="#75715e" italic="true"/>
<style name="Doxygen.Comment" foreground="#75715e" bold="true" italic="true"/>
<style name="Doxygen.Tag" foreground="#80ff80"/>
<style name="VisualWhitespace" foreground="#c0c0c0"/>
<style name="QmlLocalId" italic="true"/>
<style name="QmlExternalId" foreground="#aaaaff" italic="true"/>
<style name="QmlTypeId" foreground="#55ff55"/>
<style name="QmlRootObjectProperty" italic="true"/>
<style name="QmlScopeObjectProperty" italic="true"/>
<style name="QmlExternalObjectProperty" foreground="#aaaaff" italic="true"/>
<style name="JsScopeVar" foreground="#8888ff" italic="true"/>
<style name="JsImportVar" foreground="#8888ff" italic="true"/>
<style name="JsGlobalVar" foreground="#8888ff" italic="true"/>
<style name="QmlStateName" italic="true"/>
<style name="Binding" foreground="#ff5555"/>
<style name="DisabledCode" foreground="#777777"/>
<style name="AddedLine" foreground="#55ffff"/>
<style name="RemovedLine" foreground="#ff5555"/>
<style name="DiffFile" foreground="#55ff55"/>
<style name="DiffLocation" foreground="#ffff55"/>
<style name="DiffFileLine" foreground="#000000" background="#d7d700"/>
<style name="DiffContextLine" foreground="#000000" background="#8aaab6"/>
<style name="DiffSourceLine" background="#8c2d2d"/>
<style name="DiffSourceChar" foreground="#000000" background="#c34141"/>
<style name="DiffDestLine" background="#2d8c2d"/>
<style name="DiffDestChar" foreground="#000000" background="#41c341"/>
<style name="Declaration"/>
</style-scheme>

View File

@@ -3255,6 +3255,14 @@ bool Bind::visit(FunctionDeclaratorAST *ast)
fun->setOverride(type.isOverride()); fun->setOverride(type.isOverride());
fun->setFinal(type.isFinal()); fun->setFinal(type.isFinal());
// propagate ref-qualifier
if (ast->ref_qualifier_token) {
const Kind kind = tokenAt(ast->ref_qualifier_token).kind();
CPP_CHECK(kind == T_AMPER || kind == T_AMPER_AMPER); // & or && are only allowed
fun->setRefQualifier(kind == T_AMPER ? Function::LvalueRefQualifier :
Function::RvalueRefQualifier);
}
this->exceptionSpecification(ast->exception_specification, type); this->exceptionSpecification(ast->exception_specification, type);
if (ast->as_cpp_initializer != 0) { if (ast->as_cpp_initializer != 0) {
fun->setAmbiguous(true); fun->setAmbiguous(true);

View File

@@ -630,9 +630,9 @@ void Lexer::scan_helper(Token *tok)
if (_yychar == '=') { if (_yychar == '=') {
yyinp(); yyinp();
tok->f.kind = T_GREATER_GREATER_EQUAL; tok->f.kind = T_GREATER_GREATER_EQUAL;
} else } else {
tok->f.kind = T_LESS_LESS; tok->f.kind = T_GREATER_GREATER;
tok->f.kind = T_GREATER_GREATER; }
} else if (_yychar == '=') { } else if (_yychar == '=') {
yyinp(); yyinp();
tok->f.kind = T_GREATER_EQUAL; tok->f.kind = T_GREATER_EQUAL;

View File

@@ -367,6 +367,12 @@ bool Function::isPureVirtual() const
void Function::setPureVirtual(bool isPureVirtual) void Function::setPureVirtual(bool isPureVirtual)
{ f._isPureVirtual = isPureVirtual; } { f._isPureVirtual = isPureVirtual; }
Function::RefQualifier Function::refQualifier() const
{ return static_cast<RefQualifier>(f._refQualifier); }
void Function::setRefQualifier(Function::RefQualifier refQualifier)
{ f._refQualifier = refQualifier; }
bool Function::isAmbiguous() const bool Function::isAmbiguous() const
{ return f._isAmbiguous; } { return f._isAmbiguous; }

View File

@@ -298,6 +298,12 @@ public:
InvokableMethod InvokableMethod
}; };
enum RefQualifier {
NoRefQualifier, // a function declared w/o & and && => *this may be lvalue or rvalue
LvalueRefQualifier, // a function declared with & => *this is lvalue
RvalueRefQualifier // a function declared with && => *this is rvalue
};
public: public:
Function(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name); Function(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
Function(Clone *clone, Subst *subst, Function *original); Function(Clone *clone, Subst *subst, Function *original);
@@ -344,6 +350,9 @@ public:
bool isPureVirtual() const; bool isPureVirtual() const;
void setPureVirtual(bool isPureVirtual); void setPureVirtual(bool isPureVirtual);
RefQualifier refQualifier() const;
void setRefQualifier(RefQualifier refQualifier);
bool isSignatureEqualTo(const Function *other, Matcher *matcher = 0) const; bool isSignatureEqualTo(const Function *other, Matcher *matcher = 0) const;
bool isAmbiguous() const; // internal bool isAmbiguous() const; // internal
@@ -384,6 +393,7 @@ private:
unsigned _isVolatile: 1; unsigned _isVolatile: 1;
unsigned _isAmbiguous: 1; unsigned _isAmbiguous: 1;
unsigned _methodKey: 3; unsigned _methodKey: 3;
unsigned _refQualifier: 2;
}; };
union { union {
unsigned _flags; unsigned _flags;

View File

@@ -43,7 +43,7 @@
namespace ClangBackEnd { namespace ClangBackEnd {
enum class DiagnosticSeverity // one to one mapping of the clang enum numbers enum class DiagnosticSeverity : quint32 // one to one mapping of the clang enum numbers
{ {
Ignored = 0, Ignored = 0,
Note = 1, Note = 1,
@@ -75,7 +75,7 @@ enum class HighlightingType : quint8
Declaration Declaration
}; };
enum class CompletionCorrection enum class CompletionCorrection : quint32
{ {
NoCorrection, NoCorrection,
DotToArrowCorrection DotToArrowCorrection

View File

@@ -56,15 +56,10 @@ quint64 CodeCompletedMessage::ticketNumber() const
return ticketNumber_; return ticketNumber_;
} }
quint32 &CodeCompletedMessage::neededCorrectionAsInt()
{
return reinterpret_cast<quint32&>(neededCorrection_);
}
QDataStream &operator<<(QDataStream &out, const CodeCompletedMessage &message) QDataStream &operator<<(QDataStream &out, const CodeCompletedMessage &message)
{ {
out << message.codeCompletions_; out << message.codeCompletions_;
out << quint32(message.neededCorrection_); out << static_cast<quint32>(message.neededCorrection_);
out << message.ticketNumber_; out << message.ticketNumber_;
return out; return out;
@@ -72,10 +67,14 @@ QDataStream &operator<<(QDataStream &out, const CodeCompletedMessage &message)
QDataStream &operator>>(QDataStream &in, CodeCompletedMessage &message) QDataStream &operator>>(QDataStream &in, CodeCompletedMessage &message)
{ {
quint32 neededCorrection;
in >> message.codeCompletions_; in >> message.codeCompletions_;
in >> message.neededCorrectionAsInt(); in >> neededCorrection;
in >> message.ticketNumber_; in >> message.ticketNumber_;
message.neededCorrection_ = static_cast<CompletionCorrection>(neededCorrection);
return in; return in;
} }

View File

@@ -49,9 +49,6 @@ public:
quint64 ticketNumber() const; quint64 ticketNumber() const;
private:
quint32 &neededCorrectionAsInt();
private: private:
CodeCompletions codeCompletions_; CodeCompletions codeCompletions_;
quint64 ticketNumber_ = 0; quint64 ticketNumber_ = 0;

View File

@@ -115,24 +115,14 @@ const Utf8String &CodeCompletion::briefComment() const
return briefComment_; return briefComment_;
} }
quint32 &CodeCompletion::completionKindAsInt()
{
return reinterpret_cast<quint32&>(completionKind_);
}
quint32 &CodeCompletion::availabilityAsInt()
{
return reinterpret_cast<quint32&>(availability_);
}
QDataStream &operator<<(QDataStream &out, const CodeCompletion &message) QDataStream &operator<<(QDataStream &out, const CodeCompletion &message)
{ {
out << message.text_; out << message.text_;
out << message.briefComment_; out << message.briefComment_;
out << message.chunks_; out << message.chunks_;
out << message.priority_; out << message.priority_;
out << message.completionKind_; out << static_cast<quint32>(message.completionKind_);
out << message.availability_; out << static_cast<quint32>(message.availability_);
out << message.hasParameters_; out << message.hasParameters_;
return out; return out;
@@ -140,14 +130,20 @@ QDataStream &operator<<(QDataStream &out, const CodeCompletion &message)
QDataStream &operator>>(QDataStream &in, CodeCompletion &message) QDataStream &operator>>(QDataStream &in, CodeCompletion &message)
{ {
quint32 completionKind;
quint32 availability;
in >> message.text_; in >> message.text_;
in >> message.briefComment_; in >> message.briefComment_;
in >> message.chunks_; in >> message.chunks_;
in >> message.priority_; in >> message.priority_;
in >> message.completionKindAsInt(); in >> completionKind;
in >> message.availabilityAsInt(); in >> availability;
in >> message.hasParameters_; in >> message.hasParameters_;
message.completionKind_ = static_cast<CodeCompletion::Kind>(completionKind);
message.availability_ = static_cast<CodeCompletion::Availability>(availability);
return in; return in;
} }

View File

@@ -103,10 +103,6 @@ public:
void setBriefComment(const Utf8String &briefComment); void setBriefComment(const Utf8String &briefComment);
const Utf8String &briefComment() const; const Utf8String &briefComment() const;
private:
quint32 &completionKindAsInt();
quint32 &availabilityAsInt();
private: private:
Utf8String text_; Utf8String text_;
Utf8String briefComment_; Utf8String briefComment_;

View File

@@ -56,14 +56,9 @@ bool CodeCompletionChunk::isOptional() const
return isOptional_; return isOptional_;
} }
quint8 &CodeCompletionChunk::kindAsInt()
{
return reinterpret_cast<quint8&>(kind_);
}
QDataStream &operator<<(QDataStream &out, const CodeCompletionChunk &chunk) QDataStream &operator<<(QDataStream &out, const CodeCompletionChunk &chunk)
{ {
out << quint8(chunk.kind_); out << static_cast<quint8>(chunk.kind_);
out << chunk.text_; out << chunk.text_;
out << chunk.isOptional_; out << chunk.isOptional_;
@@ -72,10 +67,14 @@ QDataStream &operator<<(QDataStream &out, const CodeCompletionChunk &chunk)
QDataStream &operator>>(QDataStream &in, CodeCompletionChunk &chunk) QDataStream &operator>>(QDataStream &in, CodeCompletionChunk &chunk)
{ {
in >> chunk.kindAsInt(); quint8 kind;
in >> kind;
in >> chunk.text_; in >> chunk.text_;
in >> chunk.isOptional_; in >> chunk.isOptional_;
chunk.kind_ = static_cast<CodeCompletionChunk::Kind>(kind);
return in; return in;
} }

View File

@@ -77,9 +77,6 @@ public:
const Utf8String &text() const; const Utf8String &text() const;
bool isOptional() const; bool isOptional() const;
private:
quint8 &kindAsInt();
private: private:
Utf8String text_; Utf8String text_;
Kind kind_ = Invalid; Kind kind_ = Invalid;

View File

@@ -97,11 +97,6 @@ const QVector<DiagnosticContainer> &DiagnosticContainer::children() const
return children_; return children_;
} }
quint32 &DiagnosticContainer::severityAsInt()
{
return reinterpret_cast<quint32&>(severity_);
}
QDataStream &operator<<(QDataStream &out, const DiagnosticContainer &container) QDataStream &operator<<(QDataStream &out, const DiagnosticContainer &container)
{ {
out << container.text_; out << container.text_;
@@ -109,7 +104,7 @@ QDataStream &operator<<(QDataStream &out, const DiagnosticContainer &container)
out << container.enableOption_; out << container.enableOption_;
out << container.disableOption_; out << container.disableOption_;
out << container.location_; out << container.location_;
out << quint32(container.severity_); out << static_cast<quint32>(container.severity_);
out << container.ranges_; out << container.ranges_;
out << container.fixIts_; out << container.fixIts_;
out << container.children_; out << container.children_;
@@ -119,16 +114,20 @@ QDataStream &operator<<(QDataStream &out, const DiagnosticContainer &container)
QDataStream &operator>>(QDataStream &in, DiagnosticContainer &container) QDataStream &operator>>(QDataStream &in, DiagnosticContainer &container)
{ {
quint32 severity;
in >> container.text_; in >> container.text_;
in >> container.category_; in >> container.category_;
in >> container.enableOption_; in >> container.enableOption_;
in >> container.disableOption_; in >> container.disableOption_;
in >> container.location_; in >> container.location_;
in >> container.severityAsInt(); in >> severity;
in >> container.ranges_; in >> container.ranges_;
in >> container.fixIts_; in >> container.fixIts_;
in >> container.children_; in >> container.children_;
container.severity_ = static_cast<DiagnosticSeverity>(severity);
return in; return in;
} }

View File

@@ -61,9 +61,6 @@ public:
const QVector<FixItContainer> &fixIts() const; const QVector<FixItContainer> &fixIts() const;
const QVector<DiagnosticContainer> &children() const; const QVector<DiagnosticContainer> &children() const;
private:
quint32 &severityAsInt();
private: private:
SourceLocationContainer location_; SourceLocationContainer location_;
QVector<SourceRangeContainer> ranges_; QVector<SourceRangeContainer> ranges_;

View File

@@ -74,14 +74,21 @@ HighlightingTypes HighlightingMarkContainer::types() const
return types_; return types_;
} }
QDataStream &operator<<(QDataStream &out, HighlightingType highlightingType)
{
out << static_cast<const quint8>(highlightingType);
return out;
}
QDataStream &operator<<(QDataStream &out, HighlightingTypes highlightingTypes) QDataStream &operator<<(QDataStream &out, HighlightingTypes highlightingTypes)
{ {
out << reinterpret_cast<const quint8&>(highlightingTypes.mainHighlightingType); out << highlightingTypes.mainHighlightingType;
out << highlightingTypes.mixinHighlightingTypes.size(); out << highlightingTypes.mixinHighlightingTypes.size();
for (HighlightingType type : highlightingTypes.mixinHighlightingTypes) for (HighlightingType type : highlightingTypes.mixinHighlightingTypes)
out << reinterpret_cast<const quint8&>(type); out << type;
return out; return out;
} }
@@ -96,16 +103,27 @@ QDataStream &operator<<(QDataStream &out, const HighlightingMarkContainer &conta
return out; return out;
} }
QDataStream &operator>>(QDataStream &in, HighlightingType &highlightingType)
{
quint8 highlightingTypeInt;
in >> highlightingTypeInt;
highlightingType = static_cast<HighlightingType>(highlightingTypeInt);
return in;
}
QDataStream &operator>>(QDataStream &in, HighlightingTypes &highlightingTypes) QDataStream &operator>>(QDataStream &in, HighlightingTypes &highlightingTypes)
{ {
in >> reinterpret_cast<quint8&>(highlightingTypes.mainHighlightingType); in >> highlightingTypes.mainHighlightingType ;
quint8 size; quint8 size;
in >> size; in >> size;
for (int counter = 0; counter < size; ++counter) { for (int counter = 0; counter < size; ++counter) {
HighlightingType type; HighlightingType type;
in >> reinterpret_cast<quint8&>(type); in >> type;
highlightingTypes.mixinHighlightingTypes.push_back(type); highlightingTypes.mixinHighlightingTypes.push_back(type);
} }

View File

@@ -79,7 +79,7 @@ public:
friend friend
QDataStream &operator<<(QDataStream &out, const MessageEnvelop &messageEnvelop) QDataStream &operator<<(QDataStream &out, const MessageEnvelop &messageEnvelop)
{ {
out << reinterpret_cast<const quint8&>(messageEnvelop.messageType_); out << static_cast<const quint8>(messageEnvelop.messageType_);
out << messageEnvelop.data; out << messageEnvelop.data;
return out; return out;
@@ -88,9 +88,13 @@ public:
friend friend
QDataStream &operator>>(QDataStream &in, MessageEnvelop &messageEnvelop) QDataStream &operator>>(QDataStream &in, MessageEnvelop &messageEnvelop)
{ {
in >> reinterpret_cast<quint8&>(messageEnvelop.messageType_); quint8 messageType;
in >> messageType;
in >> messageEnvelop.data; in >> messageEnvelop.data;
messageEnvelop.messageType_ = static_cast<MessageType>(messageType);
return in; return in;
} }

View File

@@ -92,7 +92,7 @@ void ReadMessageBlock::resetCounter()
bool ReadMessageBlock::isTheWholeMessageReadable(QDataStream &in) bool ReadMessageBlock::isTheWholeMessageReadable(QDataStream &in)
{ {
if (ioDevice->bytesAvailable() < sizeof(blockSize)) if (ioDevice->bytesAvailable() < qint64(sizeof(blockSize)))
return false; return false;
if (blockSize == 0) if (blockSize == 0)

View File

@@ -135,6 +135,7 @@ public:
funTy->copy(type); funTy->copy(type);
funTy->setConst(type->isConst()); funTy->setConst(type->isConst());
funTy->setVolatile(type->isVolatile()); funTy->setVolatile(type->isVolatile());
funTy->setRefQualifier(type->refQualifier());
funTy->setName(rewrite->rewriteName(type->name())); funTy->setName(rewrite->rewriteName(type->name()));

View File

@@ -454,6 +454,17 @@ void TypePrettyPrinter::visit(Function *type)
appendSpace(); appendSpace();
_text += QLatin1String("volatile"); _text += QLatin1String("volatile");
} }
// add ref-qualifier
if (type->refQualifier() != Function::NoRefQualifier) {
if (!_overview->starBindFlags.testFlag(Overview::BindToLeftSpecifier)
|| (!type->isConst() && !type->isVolatile())) {
appendSpace();
}
_text += type->refQualifier() == Function::LvalueRefQualifier
? QLatin1String("&")
: QLatin1String("&&");
}
} }
} }

View File

@@ -58,7 +58,6 @@ public:
Q_UNUSED(widget); Q_UNUSED(widget);
painter->save(); painter->save();
painter->setRenderHint(QPainter::Antialiasing, true);
painter->setPen(pen()); painter->setPen(pen());
painter->setBrush(brush()); painter->setBrush(brush());
painter->drawRoundedRect(rect(), 3, 3); painter->drawRoundedRect(rect(), 3, 3);

View File

@@ -40,23 +40,6 @@
namespace qmt { namespace qmt {
class ArrowItem::GraphicsPathItem : public QGraphicsPathItem
{
public:
explicit GraphicsPathItem(QGraphicsItem *parent)
: QGraphicsPathItem(parent)
{
}
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
painter->save();
painter->setRenderHint(QPainter::Antialiasing, true);
QGraphicsPathItem::paint(painter, option, widget);
painter->restore();
}
};
class ArrowItem::GraphicsHeadItem : public QGraphicsItem class ArrowItem::GraphicsHeadItem : public QGraphicsItem
{ {
public: public:
@@ -182,7 +165,7 @@ public:
if (hasArrow) { if (hasArrow) {
if (!m_arrowItem) if (!m_arrowItem)
m_arrowItem = new ArrowItem::GraphicsPathItem(this); m_arrowItem = new QGraphicsPathItem(this);
if (m_head == ArrowItem::HeadOpen || m_head == ArrowItem::HeadTriangle) { if (m_head == ArrowItem::HeadOpen || m_head == ArrowItem::HeadTriangle) {
m_arrowItem->setPen(style->linePen()); m_arrowItem->setPen(style->linePen());
@@ -210,7 +193,7 @@ public:
if (hasDiamond) { if (hasDiamond) {
if (!m_diamondItem) if (!m_diamondItem)
m_diamondItem = new ArrowItem::GraphicsPathItem(this); m_diamondItem = new QGraphicsPathItem(this);
if (m_head == ArrowItem::HeadDiamond || m_head == ArrowItem::HeadDiamondFilledTriangle) { if (m_head == ArrowItem::HeadDiamond || m_head == ArrowItem::HeadDiamondFilledTriangle) {
m_diamondItem->setPen(style->linePen()); m_diamondItem->setPen(style->linePen());
@@ -238,15 +221,15 @@ private:
ArrowItem::Head m_head = ArrowItem::HeadNone; ArrowItem::Head m_head = ArrowItem::HeadNone;
double m_arrowSize = 10.0; double m_arrowSize = 10.0;
double m_diamondSize = 15.0; double m_diamondSize = 15.0;
ArrowItem::GraphicsPathItem *m_arrowItem = 0; QGraphicsPathItem *m_arrowItem = 0;
ArrowItem::GraphicsPathItem *m_diamondItem = 0; QGraphicsPathItem *m_diamondItem = 0;
}; };
class ArrowItem::GraphicsShaftItem : public ArrowItem::GraphicsPathItem class ArrowItem::GraphicsShaftItem : public QGraphicsPathItem
{ {
public: public:
explicit GraphicsShaftItem(QGraphicsItem *parent) explicit GraphicsShaftItem(QGraphicsItem *parent)
: GraphicsPathItem(parent) : QGraphicsPathItem(parent)
{ {
} }
}; };

View File

@@ -37,7 +37,6 @@ class Style;
class ArrowItem : public QGraphicsItem class ArrowItem : public QGraphicsItem
{ {
class GraphicsPathItem;
class GraphicsHeadItem; class GraphicsHeadItem;
class GraphicsShaftItem; class GraphicsShaftItem;

View File

@@ -63,7 +63,6 @@ void RelationStarter::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
Q_UNUSED(widget); Q_UNUSED(widget);
painter->save(); painter->save();
painter->setRenderHint(QPainter::Antialiasing, true);
painter->setPen(pen()); painter->setPen(pen());
painter->setBrush(brush()); painter->setBrush(brush());
painter->drawRoundedRect(rect(), 3, 3); painter->drawRoundedRect(rect(), 3, 3);

View File

@@ -46,6 +46,7 @@ DiagramView::DiagramView(QWidget *parent)
setAlignment(Qt::AlignLeft | Qt::AlignTop); setAlignment(Qt::AlignLeft | Qt::AlignTop);
setDragMode(QGraphicsView::RubberBandDrag); setDragMode(QGraphicsView::RubberBandDrag);
setFrameShape(QFrame::NoFrame); setFrameShape(QFrame::NoFrame);
setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
} }
DiagramView::~DiagramView() DiagramView::~DiagramView()

View File

@@ -43,67 +43,47 @@ void ShapePaintVisitor::visitLine(const LineShape *shapeLine)
{ {
QPointF p1 = shapeLine->pos1().mapScaledTo(m_scaledOrigin, m_originalSize, m_baseSize, m_size); QPointF p1 = shapeLine->pos1().mapScaledTo(m_scaledOrigin, m_originalSize, m_baseSize, m_size);
QPointF p2 = shapeLine->pos2().mapScaledTo(m_scaledOrigin, m_originalSize, m_baseSize, m_size); QPointF p2 = shapeLine->pos2().mapScaledTo(m_scaledOrigin, m_originalSize, m_baseSize, m_size);
m_painter->save();
m_painter->setRenderHint(QPainter::Antialiasing, p1.x() != p2.x() && p1.y() != p2.y());
m_painter->drawLine(p1, p2); m_painter->drawLine(p1, p2);
m_painter->restore();
} }
void ShapePaintVisitor::visitRect(const RectShape *shapeRect) void ShapePaintVisitor::visitRect(const RectShape *shapeRect)
{ {
m_painter->save();
m_painter->setRenderHint(QPainter::Antialiasing, false);
m_painter->drawRect(QRectF(shapeRect->pos().mapScaledTo(m_scaledOrigin, m_originalSize, m_baseSize, m_size), m_painter->drawRect(QRectF(shapeRect->pos().mapScaledTo(m_scaledOrigin, m_originalSize, m_baseSize, m_size),
shapeRect->size().mapScaledTo(m_scaledOrigin, m_originalSize, m_baseSize, m_size))); shapeRect->size().mapScaledTo(m_scaledOrigin, m_originalSize, m_baseSize, m_size)));
m_painter->restore();
} }
void ShapePaintVisitor::visitRoundedRect(const RoundedRectShape *shapeRoundedRect) void ShapePaintVisitor::visitRoundedRect(const RoundedRectShape *shapeRoundedRect)
{ {
qreal radiusX = shapeRoundedRect->radius().mapScaledTo(0, m_originalSize.width(), m_baseSize.width(), m_size.width()); qreal radiusX = shapeRoundedRect->radius().mapScaledTo(0, m_originalSize.width(), m_baseSize.width(), m_size.width());
qreal radiusY = shapeRoundedRect->radius().mapScaledTo(0, m_originalSize.height(), m_baseSize.height(), m_size.height()); qreal radiusY = shapeRoundedRect->radius().mapScaledTo(0, m_originalSize.height(), m_baseSize.height(), m_size.height());
m_painter->save();
m_painter->setRenderHint(QPainter::Antialiasing, true);
m_painter->drawRoundedRect(QRectF(shapeRoundedRect->pos().mapScaledTo(m_scaledOrigin, m_originalSize, m_baseSize, m_size), m_painter->drawRoundedRect(QRectF(shapeRoundedRect->pos().mapScaledTo(m_scaledOrigin, m_originalSize, m_baseSize, m_size),
shapeRoundedRect->size().mapScaledTo(m_scaledOrigin, m_originalSize, m_baseSize, m_size)), shapeRoundedRect->size().mapScaledTo(m_scaledOrigin, m_originalSize, m_baseSize, m_size)),
radiusX, radiusY); radiusX, radiusY);
m_painter->restore();
} }
void ShapePaintVisitor::visitCircle(const CircleShape *shapeCircle) void ShapePaintVisitor::visitCircle(const CircleShape *shapeCircle)
{ {
m_painter->save();
m_painter->setRenderHint(QPainter::Antialiasing, true);
m_painter->drawEllipse(shapeCircle->center().mapScaledTo(m_scaledOrigin, m_originalSize, m_baseSize, m_size), m_painter->drawEllipse(shapeCircle->center().mapScaledTo(m_scaledOrigin, m_originalSize, m_baseSize, m_size),
shapeCircle->radius().mapScaledTo(m_scaledOrigin.x(), m_originalSize.width(), m_baseSize.width(), m_size.width()), shapeCircle->radius().mapScaledTo(m_scaledOrigin.x(), m_originalSize.width(), m_baseSize.width(), m_size.width()),
shapeCircle->radius().mapScaledTo(m_scaledOrigin.y(), m_originalSize.height(), m_baseSize.height(), m_size.height())); shapeCircle->radius().mapScaledTo(m_scaledOrigin.y(), m_originalSize.height(), m_baseSize.height(), m_size.height()));
m_painter->restore();
} }
void ShapePaintVisitor::visitEllipse(const EllipseShape *shapeEllipse) void ShapePaintVisitor::visitEllipse(const EllipseShape *shapeEllipse)
{ {
QSizeF radius = shapeEllipse->radius().mapScaledTo(m_scaledOrigin, m_originalSize, m_baseSize, m_size); QSizeF radius = shapeEllipse->radius().mapScaledTo(m_scaledOrigin, m_originalSize, m_baseSize, m_size);
m_painter->save();
m_painter->setRenderHint(QPainter::Antialiasing, true);
m_painter->drawEllipse(shapeEllipse->center().mapScaledTo(m_scaledOrigin, m_originalSize, m_baseSize, m_size), m_painter->drawEllipse(shapeEllipse->center().mapScaledTo(m_scaledOrigin, m_originalSize, m_baseSize, m_size),
radius.width(), radius.height()); radius.width(), radius.height());
m_painter->restore();
} }
void ShapePaintVisitor::visitArc(const ArcShape *shapeArc) void ShapePaintVisitor::visitArc(const ArcShape *shapeArc)
{ {
QSizeF radius = shapeArc->radius().mapScaledTo(m_scaledOrigin, m_originalSize, m_baseSize, m_size); QSizeF radius = shapeArc->radius().mapScaledTo(m_scaledOrigin, m_originalSize, m_baseSize, m_size);
m_painter->save();
m_painter->setRenderHint(QPainter::Antialiasing, true);
m_painter->drawArc(QRectF(shapeArc->center().mapScaledTo(m_scaledOrigin, m_originalSize, m_baseSize, m_size) - QPointF(radius.width(), radius.height()), radius * 2.0), m_painter->drawArc(QRectF(shapeArc->center().mapScaledTo(m_scaledOrigin, m_originalSize, m_baseSize, m_size) - QPointF(radius.width(), radius.height()), radius * 2.0),
shapeArc->startAngle() * 16, shapeArc->spanAngle() * 16); shapeArc->startAngle() * 16, shapeArc->spanAngle() * 16);
m_painter->restore();
} }
void ShapePaintVisitor::visitPath(const PathShape *shapePath) void ShapePaintVisitor::visitPath(const PathShape *shapePath)
{ {
m_painter->save();
m_painter->setRenderHint(QPainter::Antialiasing, true);
QPainterPath path; QPainterPath path;
foreach (const PathShape::Element &element, shapePath->elements()) { foreach (const PathShape::Element &element, shapePath->elements()) {
switch (element.m_elementType) { switch (element.m_elementType) {
@@ -138,7 +118,6 @@ void ShapePaintVisitor::visitPath(const PathShape *shapePath)
} }
} }
m_painter->drawPath(path); m_painter->drawPath(path);
m_painter->restore();
} }
ShapeSizeVisitor::ShapeSizeVisitor(const QPointF &scaledOrigin, const QSizeF &originalSize, const QSizeF &baseSize, ShapeSizeVisitor::ShapeSizeVisitor(const QPointF &scaledOrigin, const QSizeF &originalSize, const QSizeF &baseSize,

View File

@@ -250,24 +250,28 @@ QString QmlJS::modulePath(const QString &name, const QString &version,
QString candidate; QString candidate;
for (QString ver = sanitizedVersion; ; ver.remove(re)) { for (QString ver = sanitizedVersion; !ver.isEmpty(); ver.remove(re)) {
for (const QString &path: importPaths) { for (const QString &path: importPaths) {
if (ver.isEmpty()) { for (int i = parts.count() - 1; i >= 0; --i) {
candidate = QDir::cleanPath(QString::fromLatin1("%1/%2").arg(path, mkpath(parts))); candidate = QDir::cleanPath(
return QDir(candidate).exists() ? candidate : QString(); QString::fromLatin1("%1/%2.%3/%4").arg(path,
} else { mkpath(parts.mid(0, i + 1)),
for (int i = parts.count() - 1; i >= 0; --i) { ver,
candidate = QDir::cleanPath( mkpath(parts.mid(i + 1))));
QString::fromLatin1("%1/%2.%3/%4").arg(path, if (QDir(candidate).exists())
mkpath(parts.mid(0, i + 1)), return candidate;
ver,
mkpath(parts.mid(i + 1))));
if (QDir(candidate).exists())
return candidate;
}
} }
} }
} }
// Version is empty
for (const QString &path: importPaths) {
candidate = QDir::cleanPath(QString::fromLatin1("%1/%2").arg(path, mkpath(parts)));
if (QDir(candidate).exists())
return candidate;
}
return QString();
} }
bool QmlJS::isValidBuiltinPropertyType(const QString &name) bool QmlJS::isValidBuiltinPropertyType(const QString &name)

View File

@@ -267,12 +267,12 @@ public:
reverse_iterator rbegin() noexcept reverse_iterator rbegin() noexcept
{ {
return reverse_iterator(end() - 1l); return reverse_iterator(end() - static_cast<std::size_t>(1));
} }
reverse_iterator rend() noexcept reverse_iterator rend() noexcept
{ {
return reverse_iterator(begin() - 1l); return reverse_iterator(begin() - static_cast<std::size_t>(1));
} }
const_iterator begin() const noexcept const_iterator begin() const noexcept

View File

@@ -90,12 +90,12 @@ public:
const_reverse_iterator rbegin() const noexcept const_reverse_iterator rbegin() const noexcept
{ {
return const_reverse_iterator(end() - 1l); return const_reverse_iterator(end() - static_cast<std::size_t>(1));
} }
const_reverse_iterator rend() const noexcept const_reverse_iterator rend() const noexcept
{ {
return const_reverse_iterator(begin() - 1l); return const_reverse_iterator(begin() - static_cast<std::size_t>(1));
} }
constexpr static constexpr static

View File

@@ -106,12 +106,12 @@ public:
const_reverse_iterator rbegin() const noexcept const_reverse_iterator rbegin() const noexcept
{ {
return const_reverse_iterator(end() - 1l); return const_reverse_iterator(end() - static_cast<std::size_t>(1));
} }
const_reverse_iterator rend() const noexcept const_reverse_iterator rend() const noexcept
{ {
return const_reverse_iterator(begin() - 1l); return const_reverse_iterator(begin() - static_cast<std::size_t>(1));
} }
private: private:

View File

@@ -127,9 +127,21 @@ TextTip::TextTip(QWidget *parent) : QTipLabel(parent)
setWindowOpacity(style()->styleHint(QStyle::SH_ToolTipLabel_Opacity, 0, this) / 255.0); setWindowOpacity(style()->styleHint(QStyle::SH_ToolTipLabel_Opacity, 0, this) / 255.0);
} }
static bool likelyContainsLink(const QString &s)
{
return s.contains(QLatin1String("href"), Qt::CaseInsensitive);
}
void TextTip::setContent(const QVariant &content) void TextTip::setContent(const QVariant &content)
{ {
m_text = content.toString(); m_text = content.toString();
bool containsLink = likelyContainsLink(m_text);
setOpenExternalLinks(containsLink);
}
bool TextTip::isInteractive() const
{
return likelyContainsLink(m_text);
} }
void TextTip::configure(const QPoint &pos, QWidget *w) void TextTip::configure(const QPoint &pos, QWidget *w)

View File

@@ -64,6 +64,7 @@ public:
TextTip(QWidget *parent); TextTip(QWidget *parent);
virtual void setContent(const QVariant &content); virtual void setContent(const QVariant &content);
virtual bool isInteractive() const;
virtual void configure(const QPoint &pos, QWidget *w); virtual void configure(const QPoint &pos, QWidget *w);
virtual bool canHandleContentReplacement(int typeId) const; virtual bool canHandleContentReplacement(int typeId) const;
virtual int showTime() const; virtual int showTime() const;

View File

@@ -91,7 +91,8 @@ HEADERS += \
quick/quicktest_utils.h \ quick/quicktest_utils.h \
quick/quicktestvisitors.h \ quick/quicktestvisitors.h \
quick/quicktestframework.h \ quick/quicktestframework.h \
testframeworkmanager.h testframeworkmanager.h \
testrunconfiguration.h
RESOURCES += \ RESOURCES += \
autotest.qrc autotest.qrc

View File

@@ -10,6 +10,7 @@ QtcPlugin {
Depends { name: "QmlJS" } Depends { name: "QmlJS" }
Depends { name: "QmlJSTools" } Depends { name: "QmlJSTools" }
Depends { name: "Utils" } Depends { name: "Utils" }
Depends { name: "Debugger" }
pluginTestDepends: [ pluginTestDepends: [
"QbsProjectManager", "QbsProjectManager",
@@ -71,7 +72,8 @@ QtcPlugin {
"itestparser.h", "itestparser.h",
"itestframework.h", "itestframework.h",
"testframeworkmanager.cpp", "testframeworkmanager.cpp",
"testframeworkmanager.h" "testframeworkmanager.h",
"testrunconfiguration.h"
] ]
Group { Group {

View File

@@ -4,7 +4,8 @@ QTC_PLUGIN_DEPENDS += \
coreplugin \ coreplugin \
projectexplorer \ projectexplorer \
cpptools \ cpptools \
qmljstools qmljstools \
debugger
QTC_LIB_DEPENDS += \ QTC_LIB_DEPENDS += \
cplusplus \ cplusplus \

View File

@@ -162,7 +162,7 @@ void AutotestPlugin::onRunAllTriggered()
TestRunner *runner = TestRunner::instance(); TestRunner *runner = TestRunner::instance();
TestTreeModel *model = TestTreeModel::instance(); TestTreeModel *model = TestTreeModel::instance();
runner->setSelectedTests(model->getAllTestCases()); runner->setSelectedTests(model->getAllTestCases());
runner->prepareToRunTests(); runner->prepareToRunTests(TestRunner::Run);
} }
void AutotestPlugin::onRunSelectedTriggered() void AutotestPlugin::onRunSelectedTriggered()
@@ -170,7 +170,7 @@ void AutotestPlugin::onRunSelectedTriggered()
TestRunner *runner = TestRunner::instance(); TestRunner *runner = TestRunner::instance();
TestTreeModel *model = TestTreeModel::instance(); TestTreeModel *model = TestTreeModel::instance();
runner->setSelectedTests(model->getSelectedTests()); runner->setSelectedTests(model->getSelectedTests());
runner->prepareToRunTests(); runner->prepareToRunTests(TestRunner::Run);
} }
void AutotestPlugin::updateMenuItemsEnabledState() void AutotestPlugin::updateMenuItemsEnabledState()

View File

@@ -133,6 +133,11 @@ TestConfiguration *GTestTreeItem::testConfiguration() const
return config; return config;
} }
TestConfiguration *GTestTreeItem::debugConfiguration() const
{
return testConfiguration();
}
// used as key inside getAllTestCases()/getSelectedTestCases() for Google Tests // used as key inside getAllTestCases()/getSelectedTestCases() for Google Tests
class ProFileWithDisplayName class ProFileWithDisplayName
{ {

View File

@@ -53,7 +53,9 @@ public:
QVariant data(int column, int role) const override; QVariant data(int column, int role) const override;
bool canProvideTestConfiguration() const override { return type() != Root; } bool canProvideTestConfiguration() const override { return type() != Root; }
bool canProvideDebugConfiguration() const override { return type() != Root; }
TestConfiguration *testConfiguration() const override; TestConfiguration *testConfiguration() const override;
TestConfiguration *debugConfiguration() const override;
QList<TestConfiguration *> getAllTestConfigurations() const override; QList<TestConfiguration *> getAllTestConfigurations() const override;
QList<TestConfiguration *> getSelectedTestConfigurations() const override; QList<TestConfiguration *> getSelectedTestConfigurations() const override;
TestTreeItem *find(const TestParseResult *result) override; TestTreeItem *find(const TestParseResult *result) override;

View File

@@ -38,7 +38,9 @@ TestOutputReader *QtTestConfiguration::outputReader(const QFutureInterface<TestR
QStringList QtTestConfiguration::argumentsForTestRunner(const TestSettings &settings) const QStringList QtTestConfiguration::argumentsForTestRunner(const TestSettings &settings) const
{ {
QStringList arguments({"-xml"}); QStringList arguments;
if (m_runMode == Run)
arguments.append("-xml");
const QString &metricsOption = TestSettings::metricsTypeToOption(settings.metrics); const QString &metricsOption = TestSettings::metricsTypeToOption(settings.metrics);
if (!metricsOption.isEmpty()) if (!metricsOption.isEmpty())

View File

@@ -33,10 +33,20 @@ namespace Internal {
class QtTestConfiguration : public TestConfiguration class QtTestConfiguration : public TestConfiguration
{ {
public: public:
explicit QtTestConfiguration() {} enum RunMode
{
Run,
Debug
};
explicit QtTestConfiguration(RunMode mode = Run) : m_runMode(mode) {}
TestOutputReader *outputReader(const QFutureInterface<TestResultPtr> &fi, TestOutputReader *outputReader(const QFutureInterface<TestResultPtr> &fi,
QProcess *app) const override; QProcess *app) const override;
QStringList argumentsForTestRunner(const TestSettings &settings) const override; QStringList argumentsForTestRunner(const TestSettings &settings) const override;
void setRunMode(RunMode mode) { m_runMode = mode; }
private:
RunMode m_runMode;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -84,6 +84,11 @@ bool QtTestTreeItem::canProvideTestConfiguration() const
} }
} }
bool QtTestTreeItem::canProvideDebugConfiguration() const
{
return canProvideTestConfiguration();
}
TestConfiguration *QtTestTreeItem::testConfiguration() const TestConfiguration *QtTestTreeItem::testConfiguration() const
{ {
ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject(); ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject();
@@ -128,6 +133,13 @@ TestConfiguration *QtTestTreeItem::testConfiguration() const
return config; return config;
} }
TestConfiguration *QtTestTreeItem::debugConfiguration() const
{
QtTestConfiguration *config = static_cast<QtTestConfiguration *>(testConfiguration());
config->setRunMode(QtTestConfiguration::Debug);
return config;
}
QList<TestConfiguration *> QtTestTreeItem::getAllTestConfigurations() const QList<TestConfiguration *> QtTestTreeItem::getAllTestConfigurations() const
{ {
QList<TestConfiguration *> result; QList<TestConfiguration *> result;

View File

@@ -40,7 +40,9 @@ public:
QVariant data(int column, int role) const override; QVariant data(int column, int role) const override;
bool canProvideTestConfiguration() const override; bool canProvideTestConfiguration() const override;
bool canProvideDebugConfiguration() const override;
TestConfiguration *testConfiguration() const override; TestConfiguration *testConfiguration() const override;
TestConfiguration *debugConfiguration() const override;
QList<TestConfiguration *> getAllTestConfigurations() const override; QList<TestConfiguration *> getAllTestConfigurations() const override;
QList<TestConfiguration *> getSelectedTestConfigurations() const override; QList<TestConfiguration *> getSelectedTestConfigurations() const override;
TestTreeItem *find(const TestParseResult *result) override; TestTreeItem *find(const TestParseResult *result) override;

View File

@@ -25,6 +25,8 @@
#include "testconfiguration.h" #include "testconfiguration.h"
#include "testoutputreader.h" #include "testoutputreader.h"
#include "testrunconfiguration.h"
#include "testrunner.h"
#include "testsettings.h" #include "testsettings.h"
#include <cpptools/cppmodelmanager.h> #include <cpptools/cppmodelmanager.h>
@@ -84,7 +86,7 @@ static bool isLocal(RunConfiguration *runConfiguration)
return DeviceTypeKitInformation::deviceTypeId(kit) == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE; return DeviceTypeKitInformation::deviceTypeId(kit) == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE;
} }
void TestConfiguration::completeTestInformation() void TestConfiguration::completeTestInformation(int runMode)
{ {
QTC_ASSERT(!m_proFile.isEmpty(), return); QTC_ASSERT(!m_proFile.isEmpty(), return);
@@ -99,6 +101,7 @@ void TestConfiguration::completeTestInformation()
QString buildDir; QString buildDir;
Project *targetProject = 0; Project *targetProject = 0;
Utils::Environment env; Utils::Environment env;
Target *runConfigTarget = 0;
bool hasDesktopTarget = false; bool hasDesktopTarget = false;
bool guessedRunConfiguration = false; bool guessedRunConfiguration = false;
setProject(0); setProject(0);
@@ -152,6 +155,7 @@ void TestConfiguration::completeTestInformation()
workDir = Utils::FileUtils::normalizePathName(stdRunnable.workingDirectory); workDir = Utils::FileUtils::normalizePathName(stdRunnable.workingDirectory);
env = stdRunnable.environment; env = stdRunnable.environment;
hasDesktopTarget = true; hasDesktopTarget = true;
runConfigTarget = rc->target();
break; break;
} }
} }
@@ -182,6 +186,8 @@ void TestConfiguration::completeTestInformation()
setEnvironment(env); setEnvironment(env);
setProject(project); setProject(project);
setGuessedConfiguration(guessedRunConfiguration); setGuessedConfiguration(guessedRunConfiguration);
if (!guessedRunConfiguration && runMode == TestRunner::Debug)
m_runConfig = new TestRunConfiguration(runConfigTarget, this);
} }
} }

View File

@@ -44,6 +44,7 @@ namespace Internal {
class TestOutputReader; class TestOutputReader;
class TestResult; class TestResult;
class TestRunConfiguration;
struct TestSettings; struct TestSettings;
using TestResultPtr = QSharedPointer<TestResult>; using TestResultPtr = QSharedPointer<TestResult>;
@@ -55,7 +56,7 @@ public:
explicit TestConfiguration(); explicit TestConfiguration();
virtual ~TestConfiguration(); virtual ~TestConfiguration();
void completeTestInformation(); void completeTestInformation(int runMode);
void setTestCases(const QStringList &testCases); void setTestCases(const QStringList &testCases);
void setTestCaseCount(int count); void setTestCaseCount(int count);
@@ -79,6 +80,7 @@ public:
QString displayName() const { return m_displayName; } QString displayName() const { return m_displayName; }
Utils::Environment environment() const { return m_environment; } Utils::Environment environment() const { return m_environment; }
ProjectExplorer::Project *project() const { return m_project.data(); } ProjectExplorer::Project *project() const { return m_project.data(); }
TestRunConfiguration *runConfiguration() const { return m_runConfig; }
bool guessedConfiguration() const { return m_guessedConfiguration; } bool guessedConfiguration() const { return m_guessedConfiguration; }
virtual TestOutputReader *outputReader(const QFutureInterface<TestResultPtr> &fi, virtual TestOutputReader *outputReader(const QFutureInterface<TestResultPtr> &fi,
@@ -97,6 +99,7 @@ private:
Utils::Environment m_environment; Utils::Environment m_environment;
QPointer<ProjectExplorer::Project> m_project; QPointer<ProjectExplorer::Project> m_project;
bool m_guessedConfiguration = false; bool m_guessedConfiguration = false;
TestRunConfiguration *m_runConfig = 0;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -120,6 +120,7 @@ void TestNavigationWidget::contextMenuEvent(QContextMenuEvent *event)
QMenu menu; QMenu menu;
QAction *runThisTest = 0; QAction *runThisTest = 0;
QAction *debugThisTest = 0;
const QModelIndexList list = m_view->selectionModel()->selectedIndexes(); const QModelIndexList list = m_view->selectionModel()->selectedIndexes();
if (list.size() == 1) { if (list.size() == 1) {
const QModelIndex index = list.first(); const QModelIndex index = list.first();
@@ -131,7 +132,17 @@ void TestNavigationWidget::contextMenuEvent(QContextMenuEvent *event)
runThisTest = new QAction(tr("Run This Test"), &menu); runThisTest = new QAction(tr("Run This Test"), &menu);
runThisTest->setEnabled(enabled); runThisTest->setEnabled(enabled);
connect(runThisTest, &QAction::triggered, connect(runThisTest, &QAction::triggered,
this, &TestNavigationWidget::onRunThisTestTriggered); this, [this] () {
onRunThisTestTriggered(TestRunner::Run);
});
}
if (item->canProvideDebugConfiguration()) {
debugThisTest = new QAction(tr("Debug This Test"), &menu);
debugThisTest->setEnabled(enabled);
connect(debugThisTest, &QAction::triggered,
this, [this] () {
onRunThisTestTriggered(TestRunner::Debug);
});
} }
} }
} }
@@ -152,10 +163,13 @@ void TestNavigationWidget::contextMenuEvent(QContextMenuEvent *event)
deselectAll->setEnabled(enabled && hasTests); deselectAll->setEnabled(enabled && hasTests);
rescan->setEnabled(enabled); rescan->setEnabled(enabled);
if (runThisTest) { if (runThisTest)
menu.addAction(runThisTest); menu.addAction(runThisTest);
if (debugThisTest)
menu.addAction(debugThisTest);
if (runThisTest || debugThisTest)
menu.addSeparator(); menu.addSeparator();
}
menu.addAction(runAll); menu.addAction(runAll);
menu.addAction(runSelected); menu.addAction(runSelected);
menu.addSeparator(); menu.addSeparator();
@@ -260,21 +274,32 @@ void TestNavigationWidget::initializeFilterMenu()
m_filterMenu->addAction(action); m_filterMenu->addAction(action);
} }
void TestNavigationWidget::onRunThisTestTriggered() void TestNavigationWidget::onRunThisTestTriggered(TestRunner::Mode runMode)
{ {
const QModelIndexList selected = m_view->selectionModel()->selectedIndexes(); const QModelIndexList selected = m_view->selectionModel()->selectedIndexes();
// paranoia
if (selected.isEmpty()) if (selected.isEmpty())
return; return;
const QModelIndex sourceIndex = m_sortFilterModel->mapToSource(selected.first()); const QModelIndex &sourceIndex = m_sortFilterModel->mapToSource(selected.first());
if (!sourceIndex.isValid()) if (!sourceIndex.isValid())
return; return;
TestTreeItem *item = static_cast<TestTreeItem *>(sourceIndex.internalPointer()); TestTreeItem *item = static_cast<TestTreeItem *>(sourceIndex.internalPointer());
if (TestConfiguration *configuration = item->testConfiguration()) { TestConfiguration *configuration;
switch (runMode) {
case TestRunner::Run:
configuration = item->testConfiguration();
break;
case TestRunner::Debug:
configuration = item->debugConfiguration();
break;
default:
configuration = 0;
}
if (configuration) {
TestRunner *runner = TestRunner::instance(); TestRunner *runner = TestRunner::instance();
runner->setSelectedTests( {configuration} ); runner->setSelectedTests( {configuration} );
runner->prepareToRunTests(); runner->prepareToRunTests(runMode);
} }
} }

View File

@@ -25,6 +25,8 @@
#pragma once #pragma once
#include "testrunner.h"
#include <coreplugin/inavigationwidgetfactory.h> #include <coreplugin/inavigationwidgetfactory.h>
#include <utils/navigationtreeview.h> #include <utils/navigationtreeview.h>
@@ -74,7 +76,7 @@ private slots:
private: private:
void initializeFilterMenu(); void initializeFilterMenu();
void onRunThisTestTriggered(); void onRunThisTestTriggered(TestRunner::Mode runMode);
TestTreeModel *m_model; TestTreeModel *m_model;
TestTreeSortFilterModel *m_sortFilterModel; TestTreeSortFilterModel *m_sortFilterModel;

View File

@@ -397,14 +397,14 @@ void TestResultsPane::onRunAllTriggered()
{ {
TestRunner *runner = TestRunner::instance(); TestRunner *runner = TestRunner::instance();
runner->setSelectedTests(TestTreeModel::instance()->getAllTestCases()); runner->setSelectedTests(TestTreeModel::instance()->getAllTestCases());
runner->prepareToRunTests(); runner->prepareToRunTests(TestRunner::Run);
} }
void TestResultsPane::onRunSelectedTriggered() void TestResultsPane::onRunSelectedTriggered()
{ {
TestRunner *runner = TestRunner::instance(); TestRunner *runner = TestRunner::instance();
runner->setSelectedTests(TestTreeModel::instance()->getSelectedTests()); runner->setSelectedTests(TestTreeModel::instance()->getSelectedTests());
runner->prepareToRunTests(); runner->prepareToRunTests(TestRunner::Run);
} }
void TestResultsPane::initializeFilterMenu() void TestResultsPane::initializeFilterMenu()

View File

@@ -0,0 +1,79 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include "autotestplugin.h"
#include "testconfiguration.h"
#include <projectexplorer/applicationlauncher.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/devicesupport/devicemanager.h>
#include <projectexplorer/runconfiguration.h>
#include <projectexplorer/runnables.h>
#include <utils/qtcassert.h>
#include <debugger/debuggerrunconfigurationaspect.h>
namespace Autotest {
namespace Internal {
class TestRunConfiguration : public ProjectExplorer::RunConfiguration
{
public:
TestRunConfiguration(ProjectExplorer::Target *parent, TestConfiguration *config)
: ProjectExplorer::RunConfiguration(parent, "AutoTest.TestRunConfig")
{
setDefaultDisplayName(tr("AutoTest Debug"));
addExtraAspects();
// disable QmlDebugger that is enabled by default
// might change if debugging QuickTest gets enabled
if (auto debugAspect = extraAspect<Debugger::DebuggerRunConfigurationAspect>())
debugAspect->setUseQmlDebugger(false);
m_testConfig = config;
}
ProjectExplorer::Runnable runnable() const override
{
ProjectExplorer::StandardRunnable r;
QTC_ASSERT(m_testConfig, return r);
r.executable = m_testConfig->targetFile();
r.commandLineArguments = m_testConfig->argumentsForTestRunner(
*AutotestPlugin::instance()->settings()).join(' ');
r.workingDirectory = m_testConfig->workingDirectory();
r.environment = m_testConfig->environment();
r.runMode = ProjectExplorer::ApplicationLauncher::Gui;
r.device = ProjectExplorer::DeviceManager::instance()->defaultDevice(
ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE);
return r;
}
private:
QWidget *createConfigurationWidget() { return 0; }
TestConfiguration *m_testConfig = 0;
};
} // namespace Internal
} // namespace Autotest

View File

@@ -28,6 +28,7 @@
#include "autotestconstants.h" #include "autotestconstants.h"
#include "autotestplugin.h" #include "autotestplugin.h"
#include "testresultspane.h" #include "testresultspane.h"
#include "testrunconfiguration.h"
#include "testsettings.h" #include "testsettings.h"
#include "testoutputreader.h" #include "testoutputreader.h"
@@ -38,6 +39,7 @@
#include <projectexplorer/project.h> #include <projectexplorer/project.h>
#include <projectexplorer/projectexplorer.h> #include <projectexplorer/projectexplorer.h>
#include <projectexplorer/projectexplorersettings.h> #include <projectexplorer/projectexplorersettings.h>
#include <projectexplorer/target.h>
#include <utils/runextensions.h> #include <utils/runextensions.h>
@@ -45,6 +47,9 @@
#include <QFutureInterface> #include <QFutureInterface>
#include <QTime> #include <QTime>
#include <debugger/debuggerruncontrol.h>
#include <debugger/debuggerstartparameters.h>
namespace Autotest { namespace Autotest {
namespace Internal { namespace Internal {
@@ -125,7 +130,7 @@ static void performTestRun(QFutureInterface<TestResultPtr> &futureInterface,
QEventLoop eventLoop; QEventLoop eventLoop;
int testCaseCount = 0; int testCaseCount = 0;
foreach (TestConfiguration *config, selectedTests) { foreach (TestConfiguration *config, selectedTests) {
config->completeTestInformation(); config->completeTestInformation(TestRunner::Run);
if (config->project()) { if (config->project()) {
testCaseCount += config->testCaseCount(); testCaseCount += config->testCaseCount();
} else { } else {
@@ -208,8 +213,9 @@ static void performTestRun(QFutureInterface<TestResultPtr> &futureInterface,
futureInterface.setProgressValue(testCaseCount); futureInterface.setProgressValue(testCaseCount);
} }
void TestRunner::prepareToRunTests() void TestRunner::prepareToRunTests(Mode mode)
{ {
m_runMode = mode;
ProjectExplorer::Internal::ProjectExplorerSettings projectExplorerSettings = ProjectExplorer::Internal::ProjectExplorerSettings projectExplorerSettings =
ProjectExplorer::ProjectExplorerPlugin::projectExplorerSettings(); ProjectExplorer::ProjectExplorerPlugin::projectExplorerSettings();
if (projectExplorerSettings.buildBeforeDeploy && !projectExplorerSettings.saveBeforeBuild) { if (projectExplorerSettings.buildBeforeDeploy && !projectExplorerSettings.saveBeforeBuild) {
@@ -251,7 +257,7 @@ void TestRunner::prepareToRunTests()
} }
if (!projectExplorerSettings.buildBeforeDeploy) { if (!projectExplorerSettings.buildBeforeDeploy) {
runTests(); runOrDebugTests();
} else { } else {
if (project->hasActiveBuildSettings()) { if (project->hasActiveBuildSettings()) {
buildProject(project); buildProject(project);
@@ -272,6 +278,70 @@ void TestRunner::runTests()
Core::ProgressManager::addTask(future, tr("Running Tests"), Autotest::Constants::TASK_INDEX); Core::ProgressManager::addTask(future, tr("Running Tests"), Autotest::Constants::TASK_INDEX);
} }
void TestRunner::debugTests()
{
// TODO improve to support more than one test configuration
QTC_ASSERT(m_selectedTests.size() == 1, onFinished();return);
TestConfiguration *config = m_selectedTests.first();
config->completeTestInformation(Debug);
if (!config->runConfiguration()) {
emit testResultReady(TestResultPtr(new FaultyTestResult(Result::MessageFatal,
TestRunner::tr("Failed to get run configuration."))));
onFinished();
return;
}
const QString &commandFilePath = executableFilePath(config->targetFile(),
config->environment().toProcessEnvironment());
if (commandFilePath.isEmpty()) {
emit testResultReady(TestResultPtr(new FaultyTestResult(Result::MessageFatal,
TestRunner::tr("Could not find command \"%1\". (%2)")
.arg(config->targetFile())
.arg(config->displayName()))));
onFinished();
return;
}
Debugger::DebuggerStartParameters sp;
sp.inferior.executable = commandFilePath;
sp.inferior.commandLineArguments = config->argumentsForTestRunner(
*AutotestPlugin::instance()->settings()).join(' ');
sp.inferior.environment = config->environment();
sp.inferior.workingDirectory = config->workingDirectory();
sp.displayName = config->displayName();
QString errorMessage;
Debugger::DebuggerRunControl *runControl = Debugger::createDebuggerRunControl(
sp, config->runConfiguration(), &errorMessage);
if (!runControl) {
emit testResultReady(TestResultPtr(new FaultyTestResult(Result::MessageFatal,
TestRunner::tr("Failed to create run configuration.\n%1").arg(errorMessage))));
onFinished();
return;
}
connect(runControl, &Debugger::DebuggerRunControl::finished, this, &TestRunner::onFinished);
ProjectExplorer::ProjectExplorerPlugin::startRunControl(
runControl, ProjectExplorer::Constants::DEBUG_RUN_MODE);
}
void TestRunner::runOrDebugTests()
{
switch (m_runMode) {
case Run:
runTests();
break;
case Debug:
debugTests();
break;
default:
QTC_ASSERT(false, return); // unexpected run mode
}
}
void TestRunner::buildProject(ProjectExplorer::Project *project) void TestRunner::buildProject(ProjectExplorer::Project *project)
{ {
ProjectExplorer::BuildManager *buildManager = ProjectExplorer::BuildManager::instance(); ProjectExplorer::BuildManager *buildManager = ProjectExplorer::BuildManager::instance();
@@ -290,7 +360,7 @@ void TestRunner::buildFinished(bool success)
this, &TestRunner::buildFinished); this, &TestRunner::buildFinished);
if (success) { if (success) {
runTests(); runOrDebugTests();
} else { } else {
emit testResultReady(TestResultPtr(new FaultyTestResult(Result::MessageFatal, emit testResultReady(TestResultPtr(new FaultyTestResult(Result::MessageFatal,
tr("Build failed. Canceling test run.")))); tr("Build failed. Canceling test run."))));

View File

@@ -44,6 +44,12 @@ class TestRunner : public QObject
Q_OBJECT Q_OBJECT
public: public:
enum Mode
{
Run,
Debug
};
static TestRunner* instance(); static TestRunner* instance();
~TestRunner(); ~TestRunner();
@@ -57,7 +63,7 @@ signals:
void testResultReady(const TestResultPtr &result); void testResultReady(const TestResultPtr &result);
public slots: public slots:
void prepareToRunTests(); void prepareToRunTests(Mode mode);
private slots: private slots:
void buildProject(ProjectExplorer::Project *project); void buildProject(ProjectExplorer::Project *project);
@@ -66,11 +72,14 @@ private slots:
private: private:
void runTests(); void runTests();
void debugTests();
void runOrDebugTests();
explicit TestRunner(QObject *parent = 0); explicit TestRunner(QObject *parent = 0);
QFutureWatcher<TestResultPtr> m_futureWatcher; QFutureWatcher<TestResultPtr> m_futureWatcher;
QList<TestConfiguration *> m_selectedTests; QList<TestConfiguration *> m_selectedTests;
bool m_executingTests; bool m_executingTests;
Mode m_runMode = Run;
// temporarily used if building before running is necessary // temporarily used if building before running is necessary
QMetaObject::Connection m_buildConnect; QMetaObject::Connection m_buildConnect;

View File

@@ -102,7 +102,9 @@ public:
TestTreeItem *findChildByNameAndFile(const QString &name, const QString &filePath); TestTreeItem *findChildByNameAndFile(const QString &name, const QString &filePath);
virtual bool canProvideTestConfiguration() const { return false; } virtual bool canProvideTestConfiguration() const { return false; }
virtual bool canProvideDebugConfiguration() const { return false; }
virtual TestConfiguration *testConfiguration() const { return 0; } virtual TestConfiguration *testConfiguration() const { return 0; }
virtual TestConfiguration *debugConfiguration() const { return 0; }
virtual QList<TestConfiguration *> getAllTestConfigurations() const; virtual QList<TestConfiguration *> getAllTestConfigurations() const;
virtual QList<TestConfiguration *> getSelectedTestConfigurations() const; virtual QList<TestConfiguration *> getSelectedTestConfigurations() const;
virtual bool lessThan(const TestTreeItem *other, SortMode mode) const; virtual bool lessThan(const TestTreeItem *other, SortMode mode) const;

View File

@@ -69,7 +69,7 @@ ArtisticStyle::~ArtisticStyle()
bool ArtisticStyle::initialize() bool ArtisticStyle::initialize()
{ {
Core::ActionContainer *menu = Core::ActionManager::createMenu(Constants::ArtisticStyle::MENU_ID); Core::ActionContainer *menu = Core::ActionManager::createMenu(Constants::ArtisticStyle::MENU_ID);
menu->menu()->setTitle(Constants::ArtisticStyle::DISPLAY_NAME); menu->menu()->setTitle(tr(Constants::ArtisticStyle::DISPLAY_NAME));
m_formatFile = new QAction(BeautifierPlugin::msgFormatCurrentFile(), this); m_formatFile = new QAction(BeautifierPlugin::msgFormatCurrentFile(), this);
menu->addAction(Core::ActionManager::registerAction(m_formatFile, menu->addAction(Core::ActionManager::registerAction(m_formatFile,
@@ -104,7 +104,7 @@ void ArtisticStyle::formatFile()
const QString cfgFileName = configurationFile(); const QString cfgFileName = configurationFile();
if (cfgFileName.isEmpty()) { if (cfgFileName.isEmpty()) {
BeautifierPlugin::showError(BeautifierPlugin::msgCannotGetConfigurationFile( BeautifierPlugin::showError(BeautifierPlugin::msgCannotGetConfigurationFile(
Constants::ArtisticStyle::DISPLAY_NAME)); tr(Constants::ArtisticStyle::DISPLAY_NAME)));
} else { } else {
m_beautifierPlugin->formatCurrentFile(command(cfgFileName)); m_beautifierPlugin->formatCurrentFile(command(cfgFileName));
} }

View File

@@ -25,11 +25,13 @@
#pragma once #pragma once
#include <QtGlobal>
namespace Beautifier { namespace Beautifier {
namespace Constants { namespace Constants {
namespace ArtisticStyle { namespace ArtisticStyle {
const char DISPLAY_NAME[] = "Artistic Style"; const char DISPLAY_NAME[] = QT_TRANSLATE_NOOP("Beautifier::Internal::ArtisticStyle::ArtisticStyle", "Artistic Style");
const char ACTION_FORMATFILE[] = "ArtisticStyle.FormatFile"; const char ACTION_FORMATFILE[] = "ArtisticStyle.FormatFile";
const char MENU_ID[] = "ArtisticStyle.Menu"; const char MENU_ID[] = "ArtisticStyle.Menu";
const char OPTION_ID[] = "ArtisticStyle"; const char OPTION_ID[] = "ArtisticStyle";

View File

@@ -28,6 +28,7 @@
#include "artisticstyleconstants.h" #include "artisticstyleconstants.h"
#include "artisticstylesettings.h" #include "artisticstylesettings.h"
#include "artisticstyle.h"
#include "../beautifierconstants.h" #include "../beautifierconstants.h"
#include "../beautifierplugin.h" #include "../beautifierplugin.h"
@@ -49,7 +50,7 @@ ArtisticStyleOptionsPageWidget::ArtisticStyleOptionsPageWidget(ArtisticStyleSett
"HOME", QDir::toNativeSeparators(QDir::home().absolutePath()))); "HOME", QDir::toNativeSeparators(QDir::home().absolutePath())));
ui->command->setExpectedKind(Utils::PathChooser::ExistingCommand); ui->command->setExpectedKind(Utils::PathChooser::ExistingCommand);
ui->command->setPromptDialogTitle(BeautifierPlugin::msgCommandPromptDialogTitle( ui->command->setPromptDialogTitle(BeautifierPlugin::msgCommandPromptDialogTitle(
Constants::ArtisticStyle::DISPLAY_NAME)); ArtisticStyle::tr(Constants::ArtisticStyle::DISPLAY_NAME)));
connect(ui->command, &Utils::PathChooser::validChanged, ui->options, &QWidget::setEnabled); connect(ui->command, &Utils::PathChooser::validChanged, ui->options, &QWidget::setEnabled);
ui->configurations->setSettings(m_settings); ui->configurations->setSettings(m_settings);
} }

View File

@@ -101,7 +101,7 @@ FormatTask format(FormatTask task)
process.setTimeoutS(5); process.setTimeoutS(5);
Utils::SynchronousProcessResponse response = process.runBlocking(executable, options); Utils::SynchronousProcessResponse response = process.runBlocking(executable, options);
if (response.result != Utils::SynchronousProcessResponse::Finished) { if (response.result != Utils::SynchronousProcessResponse::Finished) {
task.error = QObject::tr("Failed to format: %1.").arg(response.exitMessage(executable, 5)); task.error = BeautifierPlugin::tr("Failed to format: %1.").arg(response.exitMessage(executable, 5));
return task; return task;
} }
const QString output = response.stdErr; const QString output = response.stdErr;

View File

@@ -73,7 +73,7 @@ QString ClangFormat::id() const
bool ClangFormat::initialize() bool ClangFormat::initialize()
{ {
Core::ActionContainer *menu = Core::ActionManager::createMenu(Constants::ClangFormat::MENU_ID); Core::ActionContainer *menu = Core::ActionManager::createMenu(Constants::ClangFormat::MENU_ID);
menu->menu()->setTitle(Constants::ClangFormat::DISPLAY_NAME); menu->menu()->setTitle(tr(Constants::ClangFormat::DISPLAY_NAME));
m_formatFile = new QAction(BeautifierPlugin::msgFormatCurrentFile(), this); m_formatFile = new QAction(BeautifierPlugin::msgFormatCurrentFile(), this);
Core::Command *cmd Core::Command *cmd

View File

@@ -25,11 +25,13 @@
#pragma once #pragma once
#include <QtGlobal>
namespace Beautifier { namespace Beautifier {
namespace Constants { namespace Constants {
namespace ClangFormat { namespace ClangFormat {
const char DISPLAY_NAME[] = "ClangFormat"; const char DISPLAY_NAME[] = QT_TRANSLATE_NOOP("Beautifier::Internal::ClangFormat::ClangFormat", "ClangFormat");
const char ACTION_FORMATFILE[] = "ClangFormat.FormatFile"; const char ACTION_FORMATFILE[] = "ClangFormat.FormatFile";
const char ACTION_FORMATSELECTED[] = "ClangFormat.FormatSelectedText"; const char ACTION_FORMATSELECTED[] = "ClangFormat.FormatSelectedText";
const char MENU_ID[] = "ClangFormat.Menu"; const char MENU_ID[] = "ClangFormat.Menu";

View File

@@ -69,7 +69,7 @@ Uncrustify::~Uncrustify()
bool Uncrustify::initialize() bool Uncrustify::initialize()
{ {
Core::ActionContainer *menu = Core::ActionManager::createMenu(Constants::Uncrustify::MENU_ID); Core::ActionContainer *menu = Core::ActionManager::createMenu(Constants::Uncrustify::MENU_ID);
menu->menu()->setTitle(Constants::Uncrustify::DISPLAY_NAME); menu->menu()->setTitle(tr(Constants::Uncrustify::DISPLAY_NAME));
m_formatFile = new QAction(BeautifierPlugin::msgFormatCurrentFile(), this); m_formatFile = new QAction(BeautifierPlugin::msgFormatCurrentFile(), this);
Core::Command *cmd Core::Command *cmd
@@ -114,7 +114,7 @@ void Uncrustify::formatFile()
const QString cfgFileName = configurationFile(); const QString cfgFileName = configurationFile();
if (cfgFileName.isEmpty()) { if (cfgFileName.isEmpty()) {
BeautifierPlugin::showError(BeautifierPlugin::msgCannotGetConfigurationFile( BeautifierPlugin::showError(BeautifierPlugin::msgCannotGetConfigurationFile(
Constants::Uncrustify::DISPLAY_NAME)); tr(Constants::Uncrustify::DISPLAY_NAME)));
} else { } else {
m_beautifierPlugin->formatCurrentFile(command(cfgFileName)); m_beautifierPlugin->formatCurrentFile(command(cfgFileName));
} }
@@ -125,7 +125,7 @@ void Uncrustify::formatSelectedText()
const QString cfgFileName = configurationFile(); const QString cfgFileName = configurationFile();
if (cfgFileName.isEmpty()) { if (cfgFileName.isEmpty()) {
BeautifierPlugin::showError(BeautifierPlugin::msgCannotGetConfigurationFile( BeautifierPlugin::showError(BeautifierPlugin::msgCannotGetConfigurationFile(
Constants::Uncrustify::DISPLAY_NAME)); tr(Constants::Uncrustify::DISPLAY_NAME)));
return; return;
} }

View File

@@ -25,11 +25,13 @@
#pragma once #pragma once
#include <QtGlobal>
namespace Beautifier { namespace Beautifier {
namespace Constants { namespace Constants {
namespace Uncrustify { namespace Uncrustify {
const char DISPLAY_NAME[] = "Uncrustify"; const char DISPLAY_NAME[] = QT_TRANSLATE_NOOP("Beautifier::Internal::Uncrustify::Uncrustify", "Uncrustify");
const char ACTION_FORMATFILE[] = "Uncrustify.FormatFile"; const char ACTION_FORMATFILE[] = "Uncrustify.FormatFile";
const char ACTION_FORMATSELECTED[] = "Uncrustify.FormatSelectedText"; const char ACTION_FORMATSELECTED[] = "Uncrustify.FormatSelectedText";
const char MENU_ID[] = "Uncrustify.Menu"; const char MENU_ID[] = "Uncrustify.Menu";

View File

@@ -28,6 +28,7 @@
#include "uncrustifyconstants.h" #include "uncrustifyconstants.h"
#include "uncrustifysettings.h" #include "uncrustifysettings.h"
#include "uncrustify.h"
#include "../beautifierconstants.h" #include "../beautifierconstants.h"
#include "../beautifierplugin.h" #include "../beautifierplugin.h"
@@ -51,7 +52,7 @@ UncrustifyOptionsPageWidget::UncrustifyOptionsPageWidget(UncrustifySettings *set
"HOME", QDir::toNativeSeparators(QDir::home().absolutePath()))); "HOME", QDir::toNativeSeparators(QDir::home().absolutePath())));
ui->command->setExpectedKind(Utils::PathChooser::ExistingCommand); ui->command->setExpectedKind(Utils::PathChooser::ExistingCommand);
ui->command->setPromptDialogTitle(BeautifierPlugin::msgCommandPromptDialogTitle( ui->command->setPromptDialogTitle(BeautifierPlugin::msgCommandPromptDialogTitle(
Constants::Uncrustify::DISPLAY_NAME)); Uncrustify::tr(Constants::Uncrustify::DISPLAY_NAME)));
connect(ui->command, &Utils::PathChooser::validChanged, ui->options, &QWidget::setEnabled); connect(ui->command, &Utils::PathChooser::validChanged, ui->options, &QWidget::setEnabled);
ui->configurations->setSettings(m_settings); ui->configurations->setSettings(m_settings);
} }

View File

@@ -117,6 +117,7 @@ private slots:
void test_quickfix_GenerateGetterSetter_basicGetterWithPrefixAndNamespaceToCpp(); void test_quickfix_GenerateGetterSetter_basicGetterWithPrefixAndNamespaceToCpp();
void test_quickfix_GenerateGetterSetter_onlyGetter(); void test_quickfix_GenerateGetterSetter_onlyGetter();
void test_quickfix_GenerateGetterSetter_onlyGetter_DontPreferGetterWithGet();
void test_quickfix_GenerateGetterSetter_onlySetter(); void test_quickfix_GenerateGetterSetter_onlySetter();
void test_quickfix_GenerateGetterSetter_offerGetterWhenSetterPresent(); void test_quickfix_GenerateGetterSetter_offerGetterWhenSetterPresent();
void test_quickfix_GenerateGetterSetter_offerSetterWhenGetterPresent(); void test_quickfix_GenerateGetterSetter_offerSetterWhenGetterPresent();

View File

@@ -1890,6 +1890,85 @@ void CppEditorPlugin::test_quickfix_GenerateGetterSetter_onlySetter()
QuickFixOperationTest(testDocuments, &factory, ProjectPartHeaderPaths(), 2); QuickFixOperationTest(testDocuments, &factory, ProjectPartHeaderPaths(), 2);
} }
class CppCodeStyleSettingsChanger {
public:
CppCodeStyleSettingsChanger(const CppCodeStyleSettings &settings);
~CppCodeStyleSettingsChanger(); // Restore original
static CppCodeStyleSettings currentSettings();
private:
void setSettings(const CppCodeStyleSettings &settings);
CppCodeStyleSettings m_originalSettings;
};
CppCodeStyleSettingsChanger::CppCodeStyleSettingsChanger(const CppCodeStyleSettings &settings)
{
m_originalSettings = currentSettings();
setSettings(settings);
}
CppCodeStyleSettingsChanger::~CppCodeStyleSettingsChanger()
{
setSettings(m_originalSettings);
}
void CppCodeStyleSettingsChanger::setSettings(const CppCodeStyleSettings &settings)
{
QVariant variant;
variant.setValue(settings);
CppCodeStylePreferences *preferences = CppToolsSettings::instance()->cppCodeStyle();
preferences->currentDelegate()->setValue(variant);
}
CppCodeStyleSettings CppCodeStyleSettingsChanger::currentSettings()
{
CppCodeStylePreferences *preferences = CppToolsSettings::instance()->cppCodeStyle();
return preferences->currentDelegate()->value().value<CppCodeStyleSettings>();
}
void CppEditorPlugin::test_quickfix_GenerateGetterSetter_onlyGetter_DontPreferGetterWithGet()
{
CppCodeStyleSettings modifiedSettings = CppCodeStyleSettingsChanger::currentSettings();
modifiedSettings.preferGetterNameWithoutGetPrefix = false;
CppCodeStyleSettingsChanger changer(modifiedSettings);
QList<QuickFixTestDocument::Ptr> testDocuments;
QByteArray original;
QByteArray expected;
// Header File
original =
"class Foo\n"
"{\n"
"public:\n"
" int m_bar@;\n"
"};\n";
expected =
"class Foo\n"
"{\n"
"public:\n"
" int m_bar@;\n"
" int getBar() const;\n"
"};\n";
testDocuments << QuickFixTestDocument::create("file.h", original, expected);
// Source File
original.resize(0);
expected =
"\n"
"int Foo::getBar() const\n"
"{\n"
" return m_bar;\n"
"}\n";
testDocuments << QuickFixTestDocument::create("file.cpp", original, expected);
GenerateGetterSetter factory;
QuickFixOperationTest(testDocuments, &factory, ProjectPartHeaderPaths(), 1);
}
/// Checks: Offer a "generate getter" quick fix if there is a setter /// Checks: Offer a "generate getter" quick fix if there is a setter
void CppEditorPlugin::test_quickfix_GenerateGetterSetter_offerGetterWhenSetterPresent() void CppEditorPlugin::test_quickfix_GenerateGetterSetter_offerGetterWhenSetterPresent()
{ {

View File

@@ -2832,17 +2832,7 @@ public:
} }
m_variableString = QString::fromUtf8(variableId->chars(), variableId->size()); m_variableString = QString::fromUtf8(variableId->chars(), variableId->size());
m_baseName = memberBaseName(m_variableString); determineGetterSetterNames();
if (m_baseName.isEmpty())
m_baseName = QLatin1String("value");
m_getterName = !(m_baseName == m_variableString
|| hasClassMemberWithGetPrefix(m_classSpecifier->symbol))
? m_baseName
: QString::fromLatin1("get%1%2")
.arg(m_baseName.left(1).toUpper()).arg(m_baseName.mid(1));
m_setterName = QString::fromLatin1("set%1%2")
.arg(m_baseName.left(1).toUpper()).arg(m_baseName.mid(1));
// Check if the class has already a getter and/or a setter. // Check if the class has already a getter and/or a setter.
// This is only a simple check which should suffice not triggering the // This is only a simple check which should suffice not triggering the
@@ -2909,6 +2899,8 @@ public:
updateDescriptionAndPriority(); updateDescriptionAndPriority();
} }
void determineGetterSetterNames();
// Clones "other" in order to prevent all the initial detection made in the ctor. // Clones "other" in order to prevent all the initial detection made in the ctor.
GenerateGetterSetterOperation(const CppQuickFixInterface &interface, GenerateGetterSetterOperation(const CppQuickFixInterface &interface,
GenerateGetterSetterOperation *other, OperationType type) GenerateGetterSetterOperation *other, OperationType type)
@@ -5968,5 +5960,27 @@ void ExtraRefactoringOperations::match(const CppQuickFixInterface &interface,
} }
} }
void GenerateGetterSetterOperation::determineGetterSetterNames()
{
m_baseName = memberBaseName(m_variableString);
if (m_baseName.isEmpty())
m_baseName = QLatin1String("value");
// Getter Name
const CppCodeStyleSettings settings = CppCodeStyleSettings::currentProjectCodeStyle();
const bool hasValidBaseName = m_baseName != m_variableString;
const bool getPrefixIsAlreadyUsed = hasClassMemberWithGetPrefix(m_classSpecifier->symbol);
if (settings.preferGetterNameWithoutGetPrefix && hasValidBaseName && !getPrefixIsAlreadyUsed) {
m_getterName = m_baseName;
} else {
const QString baseNameWithCapital = m_baseName.left(1).toUpper() + m_baseName.mid(1);
m_getterName = QLatin1String("get") + baseNameWithCapital;
}
// Setter Name
const QString baseNameWithCapital = m_baseName.left(1).toUpper() + m_baseName.mid(1);
m_setterName = QLatin1String("set") + baseNameWithCapital;
}
} // namespace Internal } // namespace Internal
} // namespace CppEditor } // namespace CppEditor

View File

@@ -59,6 +59,7 @@ static const char bindStarToLeftSpecifierKey[] = "BindStarToLeftSpecifier";
static const char bindStarToRightSpecifierKey[] = "BindStarToRightSpecifier"; static const char bindStarToRightSpecifierKey[] = "BindStarToRightSpecifier";
static const char extraPaddingForConditionsIfConfusingAlignKey[] = "ExtraPaddingForConditionsIfConfusingAlign"; static const char extraPaddingForConditionsIfConfusingAlignKey[] = "ExtraPaddingForConditionsIfConfusingAlign";
static const char alignAssignmentsKey[] = "AlignAssignments"; static const char alignAssignmentsKey[] = "AlignAssignments";
static const char shortGetterNameKey[] = "ShortGetterName";
using namespace CppTools; using namespace CppTools;
@@ -85,6 +86,7 @@ CppCodeStyleSettings::CppCodeStyleSettings() :
, bindStarToRightSpecifier(false) , bindStarToRightSpecifier(false)
, extraPaddingForConditionsIfConfusingAlign(true) , extraPaddingForConditionsIfConfusingAlign(true)
, alignAssignments(false) , alignAssignments(false)
, preferGetterNameWithoutGetPrefix(true)
{ {
} }
@@ -121,6 +123,7 @@ void CppCodeStyleSettings::toMap(const QString &prefix, QVariantMap *map) const
map->insert(prefix + QLatin1String(bindStarToRightSpecifierKey), bindStarToRightSpecifier); map->insert(prefix + QLatin1String(bindStarToRightSpecifierKey), bindStarToRightSpecifier);
map->insert(prefix + QLatin1String(extraPaddingForConditionsIfConfusingAlignKey), extraPaddingForConditionsIfConfusingAlign); map->insert(prefix + QLatin1String(extraPaddingForConditionsIfConfusingAlignKey), extraPaddingForConditionsIfConfusingAlign);
map->insert(prefix + QLatin1String(alignAssignmentsKey), alignAssignments); map->insert(prefix + QLatin1String(alignAssignmentsKey), alignAssignments);
map->insert(prefix + QLatin1String(shortGetterNameKey), preferGetterNameWithoutGetPrefix);
} }
void CppCodeStyleSettings::fromMap(const QString &prefix, const QVariantMap &map) void CppCodeStyleSettings::fromMap(const QString &prefix, const QVariantMap &map)
@@ -165,6 +168,8 @@ void CppCodeStyleSettings::fromMap(const QString &prefix, const QVariantMap &map
extraPaddingForConditionsIfConfusingAlign).toBool(); extraPaddingForConditionsIfConfusingAlign).toBool();
alignAssignments = map.value(prefix + QLatin1String(alignAssignmentsKey), alignAssignments = map.value(prefix + QLatin1String(alignAssignmentsKey),
alignAssignments).toBool(); alignAssignments).toBool();
preferGetterNameWithoutGetPrefix = map.value(prefix + QLatin1String(shortGetterNameKey),
preferGetterNameWithoutGetPrefix).toBool();
} }
bool CppCodeStyleSettings::equals(const CppCodeStyleSettings &rhs) const bool CppCodeStyleSettings::equals(const CppCodeStyleSettings &rhs) const
@@ -188,7 +193,37 @@ bool CppCodeStyleSettings::equals(const CppCodeStyleSettings &rhs) const
&& bindStarToLeftSpecifier == rhs.bindStarToLeftSpecifier && bindStarToLeftSpecifier == rhs.bindStarToLeftSpecifier
&& bindStarToRightSpecifier == rhs.bindStarToRightSpecifier && bindStarToRightSpecifier == rhs.bindStarToRightSpecifier
&& extraPaddingForConditionsIfConfusingAlign == rhs.extraPaddingForConditionsIfConfusingAlign && extraPaddingForConditionsIfConfusingAlign == rhs.extraPaddingForConditionsIfConfusingAlign
&& alignAssignments == rhs.alignAssignments; && alignAssignments == rhs.alignAssignments
&& preferGetterNameWithoutGetPrefix == rhs.preferGetterNameWithoutGetPrefix
;
}
CppCodeStyleSettings CppCodeStyleSettings::currentProjectCodeStyle()
{
ProjectExplorer::Project *project = ProjectExplorer::ProjectTree::currentProject();
if (!project)
return currentGlobalCodeStyle();
ProjectExplorer::EditorConfiguration *editorConfiguration = project->editorConfiguration();
QTC_ASSERT(editorConfiguration, return currentGlobalCodeStyle());
TextEditor::ICodeStylePreferences *codeStylePreferences
= editorConfiguration->codeStyle(Constants::CPP_SETTINGS_ID);
QTC_ASSERT(codeStylePreferences, return currentGlobalCodeStyle());
CppCodeStylePreferences *cppCodeStylePreferences
= dynamic_cast<CppCodeStylePreferences *>(codeStylePreferences);
QTC_ASSERT(cppCodeStylePreferences, return currentGlobalCodeStyle());
return cppCodeStylePreferences->currentCodeStyleSettings();
}
CppCodeStyleSettings CppCodeStyleSettings::currentGlobalCodeStyle()
{
CppCodeStylePreferences *cppCodeStylePreferences = CppToolsSettings::instance()->cppCodeStyle();
QTC_ASSERT(cppCodeStylePreferences, return CppCodeStyleSettings());
return cppCodeStylePreferences->currentCodeStyleSettings();
} }
static void configureOverviewWithCodeStyleSettings(CPlusPlus::Overview &overview, static void configureOverviewWithCodeStyleSettings(CPlusPlus::Overview &overview,
@@ -207,37 +242,14 @@ static void configureOverviewWithCodeStyleSettings(CPlusPlus::Overview &overview
CPlusPlus::Overview CppCodeStyleSettings::currentProjectCodeStyleOverview() CPlusPlus::Overview CppCodeStyleSettings::currentProjectCodeStyleOverview()
{ {
ProjectExplorer::Project *project = ProjectExplorer::ProjectTree::currentProject();
if (!project)
return currentGlobalCodeStyleOverview();
ProjectExplorer::EditorConfiguration *editorConfiguration = project->editorConfiguration();
QTC_ASSERT(editorConfiguration, return currentGlobalCodeStyleOverview());
TextEditor::ICodeStylePreferences *codeStylePreferences
= editorConfiguration->codeStyle(Constants::CPP_SETTINGS_ID);
QTC_ASSERT(codeStylePreferences, return currentGlobalCodeStyleOverview());
CppCodeStylePreferences *cppCodeStylePreferences
= dynamic_cast<CppCodeStylePreferences *>(codeStylePreferences);
QTC_ASSERT(cppCodeStylePreferences, return currentGlobalCodeStyleOverview());
CppCodeStyleSettings settings = cppCodeStylePreferences->currentCodeStyleSettings();
CPlusPlus::Overview overview; CPlusPlus::Overview overview;
configureOverviewWithCodeStyleSettings(overview, settings); configureOverviewWithCodeStyleSettings(overview, currentProjectCodeStyle());
return overview; return overview;
} }
CPlusPlus::Overview CppCodeStyleSettings::currentGlobalCodeStyleOverview() CPlusPlus::Overview CppCodeStyleSettings::currentGlobalCodeStyleOverview()
{ {
CPlusPlus::Overview overview; CPlusPlus::Overview overview;
configureOverviewWithCodeStyleSettings(overview, currentGlobalCodeStyle());
CppCodeStylePreferences *cppCodeStylePreferences = CppToolsSettings::instance()->cppCodeStyle();
QTC_ASSERT(cppCodeStylePreferences, return overview);
CppCodeStyleSettings settings = cppCodeStylePreferences->currentCodeStyleSettings();
configureOverviewWithCodeStyleSettings(overview, settings);
return overview; return overview;
} }

View File

@@ -80,6 +80,8 @@ public:
// b // b
bool alignAssignments; bool alignAssignments;
bool preferGetterNameWithoutGetPrefix;
void toSettings(const QString &category, QSettings *s) const; void toSettings(const QString &category, QSettings *s) const;
void fromSettings(const QString &category, const QSettings *s); void fromSettings(const QString &category, const QSettings *s);
@@ -90,6 +92,9 @@ public:
bool operator==(const CppCodeStyleSettings &s) const { return equals(s); } bool operator==(const CppCodeStyleSettings &s) const { return equals(s); }
bool operator!=(const CppCodeStyleSettings &s) const { return !equals(s); } bool operator!=(const CppCodeStyleSettings &s) const { return !equals(s); }
static CppCodeStyleSettings currentProjectCodeStyle();
static CppCodeStyleSettings currentGlobalCodeStyle();
/*! Returns an Overview configured by the current project's code style. /*! Returns an Overview configured by the current project's code style.
If no current project is available or an error occurs when getting the If no current project is available or an error occurs when getting the

View File

@@ -321,6 +321,8 @@ CppCodeStylePreferencesWidget::CppCodeStylePreferencesWidget(QWidget *parent)
this, &CppCodeStylePreferencesWidget::slotCodeStyleSettingsChanged); this, &CppCodeStylePreferencesWidget::slotCodeStyleSettingsChanged);
connect(m_ui->bindStarToRightSpecifier, &QCheckBox::toggled, connect(m_ui->bindStarToRightSpecifier, &QCheckBox::toggled,
this, &CppCodeStylePreferencesWidget::slotCodeStyleSettingsChanged); this, &CppCodeStylePreferencesWidget::slotCodeStyleSettingsChanged);
connect(m_ui->preferGetterNamesWithoutGet, &QCheckBox::toggled,
this, &CppCodeStylePreferencesWidget::slotCodeStyleSettingsChanged);
m_ui->categoryTab->setCurrentIndex(0); m_ui->categoryTab->setCurrentIndex(0);
@@ -380,6 +382,7 @@ CppCodeStyleSettings CppCodeStylePreferencesWidget::cppCodeStyleSettings() const
set.bindStarToRightSpecifier = m_ui->bindStarToRightSpecifier->isChecked(); set.bindStarToRightSpecifier = m_ui->bindStarToRightSpecifier->isChecked();
set.extraPaddingForConditionsIfConfusingAlign = m_ui->extraPaddingConditions->isChecked(); set.extraPaddingForConditionsIfConfusingAlign = m_ui->extraPaddingConditions->isChecked();
set.alignAssignments = m_ui->alignAssignments->isChecked(); set.alignAssignments = m_ui->alignAssignments->isChecked();
set.preferGetterNameWithoutGetPrefix = m_ui->preferGetterNamesWithoutGet->isChecked();
return set; return set;
} }
@@ -413,6 +416,7 @@ void CppCodeStylePreferencesWidget::setCodeStyleSettings(const CppCodeStyleSetti
m_ui->bindStarToRightSpecifier->setChecked(s.bindStarToRightSpecifier); m_ui->bindStarToRightSpecifier->setChecked(s.bindStarToRightSpecifier);
m_ui->extraPaddingConditions->setChecked(s.extraPaddingForConditionsIfConfusingAlign); m_ui->extraPaddingConditions->setChecked(s.extraPaddingForConditionsIfConfusingAlign);
m_ui->alignAssignments->setChecked(s.alignAssignments); m_ui->alignAssignments->setChecked(s.alignAssignments);
m_ui->preferGetterNamesWithoutGet->setChecked(s.preferGetterNameWithoutGetPrefix);
m_blockUpdates = wasBlocked; m_blockUpdates = wasBlocked;
if (preview) if (preview)
updatePreview(); updatePreview();

View File

@@ -484,6 +484,33 @@ if they would align to the next line</string>
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="getterSetterTab">
<attribute name="title">
<string>Getter and Setter</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QCheckBox" name="preferGetterNamesWithoutGet">
<property name="text">
<string>Prefer getter names without &quot;get&quot;</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_7">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget> </widget>
</item> </item>
</layout> </layout>

View File

@@ -54,6 +54,9 @@ public:
QAction *selectAllAction = 0; QAction *selectAllAction = 0;
QAction *openParentDiagramAction = 0; QAction *openParentDiagramAction = 0;
QAction *exportDiagramAction = 0; QAction *exportDiagramAction = 0;
QAction *zoomInAction = 0;
QAction *zoomOutAction = 0;
QAction *resetZoomAction = 0;
}; };
ActionHandler::ActionHandler(const Core::Context &context, QObject *parent) ActionHandler::ActionHandler(const Core::Context &context, QObject *parent)
@@ -118,6 +121,21 @@ QAction *ActionHandler::exportDiagramAction() const
return d->exportDiagramAction; return d->exportDiagramAction;
} }
QAction *ActionHandler::zoomInAction() const
{
return d->zoomInAction;
}
QAction *ActionHandler::zoomOutAction() const
{
return d->zoomOutAction;
}
QAction *ActionHandler::resetZoom() const
{
return d->resetZoomAction;
}
void ActionHandler::createActions() void ActionHandler::createActions()
{ {
Core::ActionContainer *medit = Core::ActionManager::actionContainer(Core::Constants::M_EDIT); Core::ActionContainer *medit = Core::ActionManager::actionContainer(Core::Constants::M_EDIT);
@@ -150,6 +168,26 @@ void ActionHandler::createActions()
menuModelEditor->addAction(exportDiagramCommand); menuModelEditor->addAction(exportDiagramCommand);
d->exportDiagramAction = exportDiagramCommand->action(); d->exportDiagramAction = exportDiagramCommand->action();
menuModelEditor->addSeparator(d->context);
Core::Command *zoomInCommand = registerCommand(
Constants::ZOOM_IN, [this]() { zoomIn(); }, d->context, true,
tr("Zoom In"), QKeySequence(QStringLiteral("Ctrl++")));
menuModelEditor->addAction(zoomInCommand);
d->zoomInAction = zoomInCommand->action();
Core::Command *zoomOutCommand = registerCommand(
Constants::ZOOM_OUT, [this]() { zoomOut(); }, d->context, true,
tr("Zoom Out"), QKeySequence(QStringLiteral("Ctrl+-")));
menuModelEditor->addAction(zoomOutCommand);
d->zoomOutAction = zoomOutCommand->action();
Core::Command *resetZoomCommand = registerCommand(
Constants::RESET_ZOOM, [this]() { resetZoom(); }, d->context, true,
tr("Reset Zoom"), QKeySequence(QStringLiteral("Ctrl+0")));
menuModelEditor->addAction(resetZoomCommand);
d->zoomOutAction = resetZoomCommand->action();
d->openParentDiagramAction = registerCommand( d->openParentDiagramAction = registerCommand(
Constants::OPEN_PARENT_DIAGRAM, [this]() { openParentDiagram(); }, Core::Context(), true, Constants::OPEN_PARENT_DIAGRAM, [this]() { openParentDiagram(); }, Core::Context(), true,
tr("Open Parent Diagram"), QKeySequence(QStringLiteral("Ctrl+Shift+P")))->action(); tr("Open Parent Diagram"), QKeySequence(QStringLiteral("Ctrl+Shift+P")))->action();
@@ -256,6 +294,27 @@ void ActionHandler::exportDiagram()
editor->exportDiagram(); editor->exportDiagram();
} }
void ActionHandler::zoomIn()
{
auto editor = qobject_cast<ModelEditor *>(Core::EditorManager::currentEditor());
if (editor)
editor->zoomIn();
}
void ActionHandler::zoomOut()
{
auto editor = qobject_cast<ModelEditor *>(Core::EditorManager::currentEditor());
if (editor)
editor->zoomOut();
}
void ActionHandler::resetZoom()
{
auto editor = qobject_cast<ModelEditor *>(Core::EditorManager::currentEditor());
if (editor)
editor->resetZoom();
}
Core::Command *ActionHandler::registerCommand(const Core::Id &id, const std::function<void()> &slot, Core::Command *ActionHandler::registerCommand(const Core::Id &id, const std::function<void()> &slot,
const Core::Context &context, bool scriptable, const QString &title, const Core::Context &context, bool scriptable, const QString &title,
const QKeySequence &keySequence) const QKeySequence &keySequence)

View File

@@ -64,6 +64,9 @@ public:
QAction *selectAllAction() const; QAction *selectAllAction() const;
QAction *openParentDiagramAction() const; QAction *openParentDiagramAction() const;
QAction *exportDiagramAction() const; QAction *exportDiagramAction() const;
QAction *zoomInAction() const;
QAction *zoomOutAction() const;
QAction *resetZoom() const;
void createActions(); void createActions();
@@ -80,6 +83,9 @@ private slots:
void onEditProperties(); void onEditProperties();
void onEditItem(); void onEditItem();
void exportDiagram(); void exportDiagram();
void zoomIn();
void zoomOut();
void resetZoom();
private: private:
Core::Command *registerCommand(const Core::Id &id, const std::function<void()> &slot, Core::Command *registerCommand(const Core::Id &id, const std::function<void()> &slot,

View File

@@ -100,6 +100,7 @@ namespace ModelEditor {
namespace Internal { namespace Internal {
static const char PROPERTYNAME_TOOLBARID[] = "ToolbarId"; static const char PROPERTYNAME_TOOLBARID[] = "ToolbarId";
static const double ZOOM_FACTOR = 1.05;
class ModelEditor::ModelEditorPrivate class ModelEditor::ModelEditorPrivate
{ {
@@ -558,6 +559,25 @@ void ModelEditor::exportDiagram()
} }
} }
void ModelEditor::zoomIn()
{
QTransform transform = d->diagramView->transform();
transform.scale(ZOOM_FACTOR, ZOOM_FACTOR);
d->diagramView->setTransform(transform);
}
void ModelEditor::zoomOut()
{
QTransform transform = d->diagramView->transform();
transform.scale(1.0 / ZOOM_FACTOR, 1.0 / ZOOM_FACTOR);
d->diagramView->setTransform(transform);
}
void ModelEditor::resetZoom()
{
d->diagramView->setTransform(QTransform());
}
qmt::MPackage *ModelEditor::guessSelectedPackage() const qmt::MPackage *ModelEditor::guessSelectedPackage() const
{ {
qmt::MPackage *package = 0; qmt::MPackage *package = 0;

View File

@@ -86,6 +86,9 @@ public:
void editProperties(); void editProperties();
void editSelectedItem(); void editSelectedItem();
void exportDiagram(); void exportDiagram();
void zoomIn();
void zoomOut();
void resetZoom();
qmt::MPackage *guessSelectedPackage() const; qmt::MPackage *guessSelectedPackage() const;

View File

@@ -36,6 +36,9 @@ const char DELETE_SELECTED_ELEMENTS[] = "ModelEditor.DeleteSelectedElements";
const char OPEN_PARENT_DIAGRAM[] = "ModelEditor.OpenParentDiagram"; const char OPEN_PARENT_DIAGRAM[] = "ModelEditor.OpenParentDiagram";
const char MENU_ID[] = "ModelEditor.Menu"; const char MENU_ID[] = "ModelEditor.Menu";
const char EXPORT_DIAGRAM[] = "ModelEditor.ExportDiagram"; const char EXPORT_DIAGRAM[] = "ModelEditor.ExportDiagram";
const char ZOOM_IN[] = "ModelEditor.ZoomIn";
const char ZOOM_OUT[] = "ModelEditor.ZoomOut";
const char RESET_ZOOM[] = "ModelEditor.ResetZoom";
const char ACTION_ADD_PACKAGE[] = "ModelEditor.Action.AddPackage"; const char ACTION_ADD_PACKAGE[] = "ModelEditor.Action.AddPackage";
const char ACTION_ADD_COMPONENT[] = "ModelEditor.Action.AddComponent"; const char ACTION_ADD_COMPONENT[] = "ModelEditor.Action.AddComponent";
const char ACTION_ADD_CLASS[] = "ModelEditor.Action.AddClass"; const char ACTION_ADD_CLASS[] = "ModelEditor.Action.AddClass";

View File

@@ -31,7 +31,7 @@
#include <utils/fileutils.h> #include <utils/fileutils.h>
// As of MSVC 2015: "foo.cpp(42) :" -> "foo.cpp(42):" // As of MSVC 2015: "foo.cpp(42) :" -> "foo.cpp(42):"
static const char FILE_POS_PATTERN[] = "(cl|LINK|.+[^ ]) ?: "; static const char FILE_POS_PATTERN[] = "(?:\\d+>)?(cl|LINK|.+[^ ]) ?: ";
static const char ERROR_PATTERN[] = "[A-Z]+\\d\\d\\d\\d ?:"; static const char ERROR_PATTERN[] = "[A-Z]+\\d\\d\\d\\d ?:";
static QPair<Utils::FileName, int> parseFileName(const QString &input) static QPair<Utils::FileName, int> parseFileName(const QString &input)
@@ -343,6 +343,16 @@ void ProjectExplorerPlugin::testMsvcOutputParsers_data()
Constants::TASK_CATEGORY_COMPILE)) Constants::TASK_CATEGORY_COMPILE))
<< QString(); << QString();
QTest::newRow("labeled error with number prefix")
<< QString::fromLatin1("1>qmlstandalone\\main.cpp(54) : error C4716: 'findUnresolvedModule' : must return a value") << OutputParserTester::STDOUT
<< QString() << QString()
<< (QList<Task>()
<< Task(Task::Error,
QLatin1String("C4716: 'findUnresolvedModule' : must return a value"),
Utils::FileName::fromUserInput(QLatin1String("qmlstandalone\\main.cpp")), 54,
Constants::TASK_CATEGORY_COMPILE))
<< QString();
QTest::newRow("labeled warning") QTest::newRow("labeled warning")
<< QString::fromLatin1("x:\\src\\plugins\\projectexplorer\\msvcparser.cpp(69) : warning C4100: 'something' : unreferenced formal parameter") << OutputParserTester::STDOUT << QString::fromLatin1("x:\\src\\plugins\\projectexplorer\\msvcparser.cpp(69) : warning C4100: 'something' : unreferenced formal parameter") << OutputParserTester::STDOUT
<< QString() << QString() << QString() << QString()
@@ -353,6 +363,17 @@ void ProjectExplorerPlugin::testMsvcOutputParsers_data()
Constants::TASK_CATEGORY_COMPILE)) Constants::TASK_CATEGORY_COMPILE))
<< QString(); << QString();
QTest::newRow("labeled warning with number prefix")
<< QString::fromLatin1("1>x:\\src\\plugins\\projectexplorer\\msvcparser.cpp(69) : warning C4100: 'something' : unreferenced formal parameter") << OutputParserTester::STDOUT
<< QString() << QString()
<< (QList<Task>()
<< Task(Task::Warning,
QLatin1String("C4100: 'something' : unreferenced formal parameter"),
Utils::FileName::fromUserInput(QLatin1String("x:\\src\\plugins\\projectexplorer\\msvcparser.cpp")), 69,
Constants::TASK_CATEGORY_COMPILE))
<< QString();
QTest::newRow("additional information") QTest::newRow("additional information")
<< QString::fromLatin1("x:\\src\\plugins\\texteditor\\icompletioncollector.h(50) : warning C4099: 'TextEditor::CompletionItem' : type name first seen using 'struct' now seen using 'class'\n" << QString::fromLatin1("x:\\src\\plugins\\texteditor\\icompletioncollector.h(50) : warning C4099: 'TextEditor::CompletionItem' : type name first seen using 'struct' now seen using 'class'\n"
" x:\\src\\plugins\\texteditor\\completionsupport.h(39) : see declaration of 'TextEditor::CompletionItem'") " x:\\src\\plugins\\texteditor\\completionsupport.h(39) : see declaration of 'TextEditor::CompletionItem'")
@@ -369,6 +390,22 @@ void ProjectExplorerPlugin::testMsvcOutputParsers_data()
Constants::TASK_CATEGORY_COMPILE)) Constants::TASK_CATEGORY_COMPILE))
<< QString(); << QString();
QTest::newRow("additional information with prefix")
<< QString::fromLatin1("2>x:\\src\\plugins\\texteditor\\icompletioncollector.h(50) : warning C4099: 'TextEditor::CompletionItem' : type name first seen using 'struct' now seen using 'class'\n"
" x:\\src\\plugins\\texteditor\\completionsupport.h(39) : see declaration of 'TextEditor::CompletionItem'")
<< OutputParserTester::STDOUT
<< QString() << QString()
<< (QList<Task>()
<< Task(Task::Warning,
QLatin1String("C4099: 'TextEditor::CompletionItem' : type name first seen using 'struct' now seen using 'class'"),
Utils::FileName::fromUserInput(QLatin1String("x:\\src\\plugins\\texteditor\\icompletioncollector.h")), 50,
Constants::TASK_CATEGORY_COMPILE)
<< Task(Task::Unknown,
QLatin1String("see declaration of 'TextEditor::CompletionItem'"),
Utils::FileName::fromUserInput(QLatin1String("x:\\src\\plugins\\texteditor\\completionsupport.h")), 39,
Constants::TASK_CATEGORY_COMPILE))
<< QString();
QTest::newRow("fatal linker error") QTest::newRow("fatal linker error")
<< QString::fromLatin1("LINK : fatal error LNK1146: no argument specified with option '/LIBPATH:'") << QString::fromLatin1("LINK : fatal error LNK1146: no argument specified with option '/LIBPATH:'")
<< OutputParserTester::STDOUT << OutputParserTester::STDOUT

View File

@@ -167,12 +167,12 @@ void MakeFileParse::parseAssignments(QList<QMakeAssignment> *assignments)
m_config.archConfig = QMakeStepConfig::NoArch; m_config.archConfig = QMakeStepConfig::NoArch;
} else if (value == QLatin1String("ppc")) { } else if (value == QLatin1String("ppc")) {
if (qa.op == QLatin1String("+=")) if (qa.op == QLatin1String("+="))
m_config.archConfig = QMakeStepConfig::PPC; m_config.archConfig = QMakeStepConfig::PowerPC;
else else
m_config.archConfig = QMakeStepConfig::NoArch; m_config.archConfig = QMakeStepConfig::NoArch;
} else if (value == QLatin1String("ppc64")) { } else if (value == QLatin1String("ppc64")) {
if (qa.op == QLatin1String("+=")) if (qa.op == QLatin1String("+="))
m_config.archConfig = QMakeStepConfig::PPC64; m_config.archConfig = QMakeStepConfig::PowerPC64;
else else
m_config.archConfig = QMakeStepConfig::NoArch; m_config.archConfig = QMakeStepConfig::NoArch;
} else if (value == QLatin1String("iphonesimulator")) { } else if (value == QLatin1String("iphonesimulator")) {

View File

@@ -888,9 +888,9 @@ QMakeStepConfig::TargetArchConfig QMakeStepConfig::targetArchFor(const Abi &targ
arch = QMakeStepConfig::X86_64; arch = QMakeStepConfig::X86_64;
} else if (targetAbi.architecture() == ProjectExplorer::Abi::PowerPCArchitecture) { } else if (targetAbi.architecture() == ProjectExplorer::Abi::PowerPCArchitecture) {
if (targetAbi.wordWidth() == 32) if (targetAbi.wordWidth() == 32)
arch = QMakeStepConfig::PPC; arch = QMakeStepConfig::PowerPC;
else if (targetAbi.wordWidth() == 64) else if (targetAbi.wordWidth() == 64)
arch = QMakeStepConfig::PPC64; arch = QMakeStepConfig::PowerPC64;
} }
} }
return arch; return arch;
@@ -920,9 +920,9 @@ QStringList QMakeStepConfig::toArguments() const
arguments << QLatin1String("CONFIG+=x86"); arguments << QLatin1String("CONFIG+=x86");
else if (archConfig == X86_64) else if (archConfig == X86_64)
arguments << QLatin1String("CONFIG+=x86_64"); arguments << QLatin1String("CONFIG+=x86_64");
else if (archConfig == PPC) else if (archConfig == PowerPC)
arguments << QLatin1String("CONFIG+=ppc"); arguments << QLatin1String("CONFIG+=ppc");
else if (archConfig == PPC64) else if (archConfig == PowerPC64)
arguments << QLatin1String("CONFIG+=ppc64"); arguments << QLatin1String("CONFIG+=ppc64");
// TODO: make that depend on the actual Qt version that is used // TODO: make that depend on the actual Qt version that is used

View File

@@ -71,7 +71,7 @@ class QMAKEPROJECTMANAGER_EXPORT QMakeStepConfig
{ {
public: public:
enum TargetArchConfig { enum TargetArchConfig {
NoArch, X86, X86_64, PPC, PPC64 NoArch, X86, X86_64, PowerPC, PowerPC64
}; };
enum OsType { enum OsType {

View File

@@ -212,6 +212,7 @@ bool AutoCompleter::autoBackspace(QTextCursor &cursor)
QTextDocument *doc = cursor.document(); QTextDocument *doc = cursor.document();
const QChar lookAhead = doc->characterAt(pos); const QChar lookAhead = doc->characterAt(pos);
const QChar lookBehind = doc->characterAt(pos - 1); const QChar lookBehind = doc->characterAt(pos - 1);
const QChar lookFurtherBehind = doc->characterAt(pos - 2);
const QChar character = lookBehind; const QChar character = lookBehind;
if (character == QLatin1Char('(') || character == QLatin1Char('[')) { if (character == QLatin1Char('(') || character == QLatin1Char('[')) {
@@ -240,7 +241,11 @@ bool AutoCompleter::autoBackspace(QTextCursor &cursor)
// ### this code needs to be generalized // ### this code needs to be generalized
if ((lookBehind == QLatin1Char('(') && lookAhead == QLatin1Char(')')) if ((lookBehind == QLatin1Char('(') && lookAhead == QLatin1Char(')'))
|| (lookBehind == QLatin1Char('[') && lookAhead == QLatin1Char(']'))) { || (lookBehind == QLatin1Char('[') && lookAhead == QLatin1Char(']'))
|| (lookBehind == QLatin1Char('"') && lookAhead == QLatin1Char('"')
&& lookFurtherBehind != QLatin1Char('\\'))
|| (lookBehind == QLatin1Char('\'') && lookAhead == QLatin1Char('\'')
&& lookFurtherBehind != QLatin1Char('\\'))) {
if (! isInComment(c)) { if (! isInComment(c)) {
cursor.beginEditBlock(); cursor.beginEditBlock();
cursor.deleteChar(); cursor.deleteChar();

View File

@@ -41,6 +41,7 @@ static const char autoSplitStringsKey[] = "AutoSplitStrings";
static const char animateAutoCompleteKey[] = "AnimateAutoComplete"; static const char animateAutoCompleteKey[] = "AnimateAutoComplete";
static const char highlightAutoCompleteKey[] = "HighlightAutoComplete"; static const char highlightAutoCompleteKey[] = "HighlightAutoComplete";
static const char skipAutoCompleteKey[] = "SkipAutoComplete"; static const char skipAutoCompleteKey[] = "SkipAutoComplete";
static const char autoRemoveKey[] = "AutoRemove";
using namespace TextEditor; using namespace TextEditor;
@@ -60,6 +61,7 @@ void CompletionSettings::toSettings(QSettings *s) const
s->setValue(animateAutoCompleteKey, m_animateAutoComplete); s->setValue(animateAutoCompleteKey, m_animateAutoComplete);
s->setValue(highlightAutoCompleteKey, m_highlightAutoComplete); s->setValue(highlightAutoCompleteKey, m_highlightAutoComplete);
s->setValue(skipAutoCompleteKey, m_skipAutoCompletedText); s->setValue(skipAutoCompleteKey, m_skipAutoCompletedText);
s->setValue(autoRemoveKey, m_autoRemove);
s->endGroup(); s->endGroup();
} }
@@ -94,6 +96,8 @@ void CompletionSettings::fromSettings(QSettings *s)
s->value(highlightAutoCompleteKey, m_highlightAutoComplete).toBool(); s->value(highlightAutoCompleteKey, m_highlightAutoComplete).toBool();
m_skipAutoCompletedText = m_skipAutoCompletedText =
s->value(skipAutoCompleteKey, m_skipAutoCompletedText).toBool(); s->value(skipAutoCompleteKey, m_skipAutoCompletedText).toBool();
m_autoRemove =
s->value(autoRemoveKey, m_autoRemove).toBool();
s->endGroup(); s->endGroup();
} }
@@ -112,5 +116,6 @@ bool CompletionSettings::equals(const CompletionSettings &cs) const
&& m_animateAutoComplete == cs.m_animateAutoComplete && m_animateAutoComplete == cs.m_animateAutoComplete
&& m_highlightAutoComplete == cs.m_highlightAutoComplete && m_highlightAutoComplete == cs.m_highlightAutoComplete
&& m_skipAutoCompletedText == cs.m_skipAutoCompletedText && m_skipAutoCompletedText == cs.m_skipAutoCompletedText
&& m_autoRemove == cs.m_autoRemove
; ;
} }

View File

@@ -69,6 +69,7 @@ public:
bool m_animateAutoComplete = true; bool m_animateAutoComplete = true;
bool m_highlightAutoComplete = true; bool m_highlightAutoComplete = true;
bool m_skipAutoCompletedText = true; bool m_skipAutoCompletedText = true;
bool m_autoRemove = true;
}; };
inline bool operator==(const CompletionSettings &t1, const CompletionSettings &t2) { return t1.equals(t2); } inline bool operator==(const CompletionSettings &t1, const CompletionSettings &t2) { return t1.equals(t2); }

View File

@@ -105,6 +105,7 @@ QWidget *CompletionSettingsPage::widget()
m_page->animateAutoComplete->setChecked(m_completionSettings.m_animateAutoComplete); m_page->animateAutoComplete->setChecked(m_completionSettings.m_animateAutoComplete);
m_page->highlightAutoComplete->setChecked(m_completionSettings.m_highlightAutoComplete); m_page->highlightAutoComplete->setChecked(m_completionSettings.m_highlightAutoComplete);
m_page->skipAutoComplete->setChecked(m_completionSettings.m_skipAutoCompletedText); m_page->skipAutoComplete->setChecked(m_completionSettings.m_skipAutoCompletedText);
m_page->removeAutoComplete->setChecked(m_completionSettings.m_autoRemove);
m_page->enableDoxygenCheckBox->setChecked(m_commentsSettings.m_enableDoxygen); m_page->enableDoxygenCheckBox->setChecked(m_commentsSettings.m_enableDoxygen);
m_page->generateBriefCheckBox->setChecked(m_commentsSettings.m_generateBrief); m_page->generateBriefCheckBox->setChecked(m_commentsSettings.m_generateBrief);
@@ -112,6 +113,7 @@ QWidget *CompletionSettingsPage::widget()
m_page->generateBriefCheckBox->setEnabled(m_page->enableDoxygenCheckBox->isChecked()); m_page->generateBriefCheckBox->setEnabled(m_page->enableDoxygenCheckBox->isChecked());
m_page->skipAutoComplete->setEnabled(m_page->highlightAutoComplete->isChecked()); m_page->skipAutoComplete->setEnabled(m_page->highlightAutoComplete->isChecked());
m_page->removeAutoComplete->setEnabled(m_page->highlightAutoComplete->isChecked());
} }
return m_widget; return m_widget;
} }
@@ -182,6 +184,7 @@ void CompletionSettingsPage::settingsFromUi(CompletionSettings &completion, Comm
completion.m_animateAutoComplete = m_page->animateAutoComplete->isChecked(); completion.m_animateAutoComplete = m_page->animateAutoComplete->isChecked();
completion.m_highlightAutoComplete = m_page->highlightAutoComplete->isChecked(); completion.m_highlightAutoComplete = m_page->highlightAutoComplete->isChecked();
completion.m_skipAutoCompletedText = m_page->skipAutoComplete->isChecked(); completion.m_skipAutoCompletedText = m_page->skipAutoComplete->isChecked();
completion.m_autoRemove = m_page->removeAutoComplete->isChecked();
comment.m_enableDoxygen = m_page->enableDoxygenCheckBox->isChecked(); comment.m_enableDoxygen = m_page->enableDoxygenCheckBox->isChecked();
comment.m_generateBrief = m_page->generateBriefCheckBox->isChecked(); comment.m_generateBrief = m_page->generateBriefCheckBox->isChecked();

View File

@@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>551</width> <width>551</width>
<height>465</height> <height>493</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
@@ -270,6 +270,39 @@ In addition, Shift+Enter inserts an escape character at the cursor position and
</item> </item>
</layout> </layout>
</item> </item>
<item row="5" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>30</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="removeAutoComplete">
<property name="toolTip">
<string>Remove the automatically inserted character if the trigger is deleted by backspace after the completion.</string>
</property>
<property name="text">
<string>Remove automatically inserted text on backspace</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
@@ -361,6 +394,7 @@ In addition, Shift+Enter inserts an escape character at the cursor position and
<tabstop>animateAutoComplete</tabstop> <tabstop>animateAutoComplete</tabstop>
<tabstop>highlightAutoComplete</tabstop> <tabstop>highlightAutoComplete</tabstop>
<tabstop>skipAutoComplete</tabstop> <tabstop>skipAutoComplete</tabstop>
<tabstop>removeAutoComplete</tabstop>
<tabstop>enableDoxygenCheckBox</tabstop> <tabstop>enableDoxygenCheckBox</tabstop>
<tabstop>generateBriefCheckBox</tabstop> <tabstop>generateBriefCheckBox</tabstop>
<tabstop>leadingAsterisksCheckBox</tabstop> <tabstop>leadingAsterisksCheckBox</tabstop>
@@ -374,12 +408,12 @@ In addition, Shift+Enter inserts an escape character at the cursor position and
<slot>setEnabled(bool)</slot> <slot>setEnabled(bool)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>195</x> <x>216</x>
<y>383</y> <y>411</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>320</x> <x>378</x>
<y>410</y> <y>438</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@@ -399,5 +433,21 @@ In addition, Shift+Enter inserts an escape character at the cursor position and
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection>
<sender>highlightAutoComplete</sender>
<signal>toggled(bool)</signal>
<receiver>removeAutoComplete</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>223</x>
<y>275</y>
</hint>
<hint type="destinationlabel">
<x>226</x>
<y>333</y>
</hint>
</hints>
</connection>
</connections> </connections>
</ui> </ui>

View File

@@ -456,6 +456,7 @@ public:
bool m_animateAutoComplete = true; bool m_animateAutoComplete = true;
bool m_highlightAutoComplete = true; bool m_highlightAutoComplete = true;
bool m_skipAutoCompletedText = true; bool m_skipAutoCompletedText = true;
bool m_removeAutoCompletedText = true;
bool m_keepAutoCompletionHighlight = false; bool m_keepAutoCompletionHighlight = false;
QTextCursor m_autoCompleteHighlightPos; QTextCursor m_autoCompleteHighlightPos;
@@ -5365,8 +5366,10 @@ void TextEditorWidgetPrivate::handleBackspaceKey()
const TabSettings &tabSettings = m_document->tabSettings(); const TabSettings &tabSettings = m_document->tabSettings();
const TypingSettings &typingSettings = m_document->typingSettings(); const TypingSettings &typingSettings = m_document->typingSettings();
if (typingSettings.m_autoIndent && m_autoCompleter->autoBackspace(cursor)) if (typingSettings.m_autoIndent && (m_autoCompleteHighlightPos == cursor)
&& m_removeAutoCompletedText && m_autoCompleter->autoBackspace(cursor)) {
return; return;
}
bool handled = false; bool handled = false;
if (typingSettings.m_smartBackspaceBehavior == TypingSettings::BackspaceNeverIndents) { if (typingSettings.m_smartBackspaceBehavior == TypingSettings::BackspaceNeverIndents) {
@@ -6571,6 +6574,7 @@ void TextEditorWidget::setCompletionSettings(const CompletionSettings &completio
d->m_animateAutoComplete = completionSettings.m_animateAutoComplete; d->m_animateAutoComplete = completionSettings.m_animateAutoComplete;
d->m_highlightAutoComplete = completionSettings.m_highlightAutoComplete; d->m_highlightAutoComplete = completionSettings.m_highlightAutoComplete;
d->m_skipAutoCompletedText = completionSettings.m_skipAutoCompletedText; d->m_skipAutoCompletedText = completionSettings.m_skipAutoCompletedText;
d->m_removeAutoCompletedText = completionSettings.m_autoRemove;
} }
void TextEditorWidget::setExtraEncodingSettings(const ExtraEncodingSettings &extraEncodingSettings) void TextEditorWidget::setExtraEncodingSettings(const ExtraEncodingSettings &extraEncodingSettings)

View File

@@ -51,6 +51,8 @@ VcsBaseOptionsPage::VcsBaseOptionsPage(QObject *parent) : Core::IOptionsPage(par
setCategoryIcon(QLatin1String(Constants::SETTINGS_CATEGORY_VCS_ICON)); setCategoryIcon(QLatin1String(Constants::SETTINGS_CATEGORY_VCS_ICON));
} }
VcsBaseOptionsPage::~VcsBaseOptionsPage() = default;
VcsClientOptionsPageWidget::VcsClientOptionsPageWidget(QWidget *parent) : QWidget(parent) VcsClientOptionsPageWidget::VcsClientOptionsPageWidget(QWidget *parent) : QWidget(parent)
{ } { }

View File

@@ -43,6 +43,7 @@ class VCSBASE_EXPORT VcsBaseOptionsPage : public Core::IOptionsPage
{ {
public: public:
explicit VcsBaseOptionsPage(QObject *parent = 0); explicit VcsBaseOptionsPage(QObject *parent = 0);
~VcsBaseOptionsPage() override;
}; };
class VcsBaseClientImpl; class VcsBaseClientImpl;

View File

@@ -38,6 +38,7 @@ typedef QByteArray _;
Q_DECLARE_METATYPE(TokenKindList) Q_DECLARE_METATYPE(TokenKindList)
Q_DECLARE_METATYPE(CPlusPlus::Tokens) Q_DECLARE_METATYPE(CPlusPlus::Tokens)
Q_DECLARE_METATYPE(CPlusPlus::Kind)
//TESTED_COMPONENT=src/libs/cplusplus //TESTED_COMPONENT=src/libs/cplusplus
using namespace CPlusPlus; using namespace CPlusPlus;
@@ -70,6 +71,8 @@ private slots:
void literals_data(); void literals_data();
void preprocessor(); void preprocessor();
void preprocessor_data(); void preprocessor_data();
void ppOpOrPunc();
void ppOpOrPunc_data();
void digraph(); void digraph();
void digraph_data(); void digraph_data();
void trigraph(); void trigraph();
@@ -395,6 +398,82 @@ void tst_SimpleLexer::preprocessor_data()
QTest::newRow("pp-number") << source << expectedTokenKindList; QTest::newRow("pp-number") << source << expectedTokenKindList;
} }
void tst_SimpleLexer::ppOpOrPunc()
{
QFETCH(Kind, expectedTokenKind);
const QByteArray source = QTest::currentDataTag();
run(source, toTokens({expectedTokenKind}), false, CompareKind, true);
}
void tst_SimpleLexer::ppOpOrPunc_data()
{
QTest::addColumn<Kind>("expectedTokenKind");
// N4296 - [2.12]
QTest::newRow("{") << T_LBRACE;
QTest::newRow("}") << T_RBRACE;
QTest::newRow("[") << T_LBRACKET;
QTest::newRow("]") << T_RBRACKET;
QTest::newRow("#") << T_POUND;
QTest::newRow("##") << T_POUND_POUND;
QTest::newRow("(") << T_LPAREN;
QTest::newRow(")") << T_RPAREN;
QTest::newRow("<:") << T_LBRACKET;
QTest::newRow(":>") << T_RBRACKET;
QTest::newRow("<%") << T_LBRACE;
QTest::newRow("%>") << T_RBRACE;
QTest::newRow("%:") << T_POUND;
QTest::newRow("%:%:") << T_POUND_POUND;
QTest::newRow(";") << T_SEMICOLON;
QTest::newRow(":") << T_COLON;
QTest::newRow("...") << T_DOT_DOT_DOT;
QTest::newRow("new") << T_NEW;
QTest::newRow("delete") << T_DELETE;
QTest::newRow("?") << T_QUESTION;
QTest::newRow("::") << T_COLON_COLON;
QTest::newRow(".") << T_DOT;
QTest::newRow(".*") << T_DOT_STAR;
QTest::newRow("+") << T_PLUS;
QTest::newRow("-") << T_MINUS;
QTest::newRow("*") << T_STAR;
QTest::newRow("/") << T_SLASH;
QTest::newRow("%") << T_PERCENT;
QTest::newRow("^") << T_CARET;
QTest::newRow("&") << T_AMPER;
QTest::newRow("|") << T_PIPE;
QTest::newRow("~") << T_TILDE;
QTest::newRow("^=") << T_CARET_EQUAL;
QTest::newRow("&=") << T_AMPER_EQUAL;
QTest::newRow("|=") << T_PIPE_EQUAL;
QTest::newRow("<<") << T_LESS_LESS;
QTest::newRow(">>") << T_GREATER_GREATER;
QTest::newRow(">>=") << T_GREATER_GREATER_EQUAL;
QTest::newRow("<<=") << T_LESS_LESS_EQUAL;
QTest::newRow("==") << T_EQUAL_EQUAL;
QTest::newRow("!=") << T_EXCLAIM_EQUAL;
QTest::newRow("<=") << T_LESS_EQUAL;
QTest::newRow(">=") << T_GREATER_EQUAL;
QTest::newRow("&&") << T_AMPER_AMPER;
QTest::newRow("||") << T_PIPE_PIPE;
QTest::newRow("++") << T_PLUS_PLUS;
QTest::newRow("--") << T_MINUS_MINUS;
QTest::newRow(",") << T_COMMA;
QTest::newRow("->*") << T_ARROW_STAR;
QTest::newRow("->") << T_ARROW;
QTest::newRow("and") << T_AND;
QTest::newRow("and_eq") << T_AND_EQ;
QTest::newRow("bitand") << T_BITAND;
QTest::newRow("bitor") << T_BITOR;
QTest::newRow("compl") << T_COMPL;
QTest::newRow("not") << T_NOT;
QTest::newRow("not_eq") << T_NOT_EQ;
QTest::newRow("or") << T_OR;
QTest::newRow("or_eq") << T_OR_EQ;
QTest::newRow("xor") << T_XOR;
QTest::newRow("xor_eq") << T_XOR_EQ;
}
void tst_SimpleLexer::bytes_and_utf16chars() void tst_SimpleLexer::bytes_and_utf16chars()
{ {
QFETCH(QByteArray, source); QFETCH(QByteArray, source);

View File

@@ -50,6 +50,9 @@
using namespace CPlusPlus; using namespace CPlusPlus;
// to use in tests directly w/o convertion to int
Q_DECLARE_METATYPE(Function::RefQualifier)
class tst_Semantic: public QObject class tst_Semantic: public QObject
{ {
Q_OBJECT Q_OBJECT
@@ -150,6 +153,8 @@ public:
private slots: private slots:
void function_declaration_1(); void function_declaration_1();
void function_declaration_2(); void function_declaration_2();
void function_declaration_ref_qualifier_data();
void function_declaration_ref_qualifier();
void function_definition_1(); void function_definition_1();
void nested_class_1(); void nested_class_1();
void alias_declaration_1(); void alias_declaration_1();
@@ -202,6 +207,7 @@ void tst_Semantic::function_declaration_1()
QVERIFY(funTy); QVERIFY(funTy);
QVERIFY(funTy->returnType()->isVoidType()); QVERIFY(funTy->returnType()->isVoidType());
QCOMPARE(funTy->argumentCount(), 0U); QCOMPARE(funTy->argumentCount(), 0U);
QCOMPARE(funTy->refQualifier(), Function::NoRefQualifier);
QVERIFY(decl->name()->isNameId()); QVERIFY(decl->name()->isNameId());
const Identifier *funId = decl->name()->asNameId()->identifier(); const Identifier *funId = decl->name()->asNameId()->identifier();
@@ -225,6 +231,7 @@ void tst_Semantic::function_declaration_2()
QVERIFY(funTy); QVERIFY(funTy);
QVERIFY(funTy->returnType()->isVoidType()); QVERIFY(funTy->returnType()->isVoidType());
QCOMPARE(funTy->argumentCount(), 1U); QCOMPARE(funTy->argumentCount(), 1U);
QCOMPARE(funTy->refQualifier(), Function::NoRefQualifier);
// check the formal argument. // check the formal argument.
Argument *arg = funTy->argumentAt(0)->asArgument(); Argument *arg = funTy->argumentAt(0)->asArgument();
@@ -261,6 +268,103 @@ void tst_Semantic::function_declaration_2()
QCOMPARE(foo, QByteArray("foo")); QCOMPARE(foo, QByteArray("foo"));
} }
void tst_Semantic::function_declaration_ref_qualifier_data()
{
QTest::addColumn<QString>("code");
QTest::addColumn<bool>("success");
QTest::addColumn<Function::RefQualifier>("refQualifier");
QTest::newRow("no")
<< "void f();" << true << Function::NoRefQualifier;
QTest::newRow("no_const")
<< "void f() const;" << true << Function::NoRefQualifier;
QTest::newRow("no_const_noexcept")
<< "void f() const noexcept;" << true << Function::NoRefQualifier;
QTest::newRow("lvalue")
<< "void f() &;" << true << Function::LvalueRefQualifier;
QTest::newRow("lvalue_const")
<< "void f() const &;" << true << Function::LvalueRefQualifier;
QTest::newRow("lvalue_const_noexcept")
<< "void f() const & noexcept;" << true << Function::LvalueRefQualifier;
QTest::newRow("rvalue")
<< "void f() &&;" << true << Function::RvalueRefQualifier;
QTest::newRow("rvalue_const")
<< "void f() const &&;" << true << Function::RvalueRefQualifier;
QTest::newRow("rvalue_const_noexcept")
<< "void f() const && noexcept;" << true << Function::RvalueRefQualifier;
QTest::newRow("lvalue_more_spaces")
<< "void f() const &;" << true << Function::LvalueRefQualifier;
QTest::newRow("rvalue_more_spaces")
<< "void f() && noexcept;" << true << Function::RvalueRefQualifier;
QTest::newRow("lvalue_more_newline")
<< "void f() const\n&;" << true << Function::LvalueRefQualifier;
QTest::newRow("rvalue_more_newline")
<< "void f() const\n&&;" << true << Function::RvalueRefQualifier;
QTest::newRow("lvalue_no_space")
<< "void f() const& noexcept;" << true << Function::LvalueRefQualifier;
QTest::newRow("rvalue_no_space")
<< "void f() const&& noexcept;" << true << Function::RvalueRefQualifier;
QTest::newRow("lvalue_before_const")
<< "void f() & const;" << false << Function::NoRefQualifier;
QTest::newRow("rvalue_before_const")
<< "void f() && const;" << false << Function::NoRefQualifier;
QTest::newRow("lvalue_after_noexcept")
<< "void f() const noexcept &;" << false << Function::NoRefQualifier;
QTest::newRow("rvalue_after_noexcept")
<< "void f() const noexcept &&;" << false << Function::NoRefQualifier;
QTest::newRow("lvalue_double")
<< "void f() const & & noexcept;" << false << Function::NoRefQualifier;
QTest::newRow("rvalue_double")
<< "void f() const && && noexcept;" << false << Function::NoRefQualifier;
}
void tst_Semantic::function_declaration_ref_qualifier()
{
QFETCH(QString, code);
QFETCH(bool, success);
QFETCH(Function::RefQualifier, refQualifier);
QSharedPointer<Document> doc = document(code.toUtf8(), false, false, true);
if (!success) {
QVERIFY(doc->errorCount > 0);
return;
}
QCOMPARE(doc->errorCount, 0U);
QCOMPARE(doc->globals->memberCount(), 1U);
Declaration *decl = doc->globals->memberAt(0)->asDeclaration();
QVERIFY(decl);
FullySpecifiedType declTy = decl->type();
Function *funTy = declTy->asFunctionType();
QVERIFY(funTy);
QVERIFY(funTy->returnType()->isVoidType());
QCOMPARE(funTy->argumentCount(), 0U);
// check the ref-qualifier
QCOMPARE(funTy->refQualifier(), refQualifier);
}
void tst_Semantic::function_definition_1() void tst_Semantic::function_definition_1()
{ {
QSharedPointer<Document> doc = document("void foo() {}"); QSharedPointer<Document> doc = document("void foo() {}");
@@ -271,6 +375,7 @@ void tst_Semantic::function_definition_1()
QVERIFY(funTy); QVERIFY(funTy);
QVERIFY(funTy->returnType()->isVoidType()); QVERIFY(funTy->returnType()->isVoidType());
QCOMPARE(funTy->argumentCount(), 0U); QCOMPARE(funTy->argumentCount(), 0U);
QCOMPARE(funTy->refQualifier(), Function::NoRefQualifier);
QVERIFY(funTy->name()->isNameId()); QVERIFY(funTy->name()->isNameId());
const Identifier *funId = funTy->name()->asNameId()->identifier(); const Identifier *funId = funTy->name()->asNameId()->identifier();

View File

@@ -93,6 +93,33 @@ static FullySpecifiedType fnTy(const QString &name, const FullySpecifiedType &re
return FullySpecifiedType(fn); return FullySpecifiedType(fn);
} }
static FullySpecifiedType refThis(const FullySpecifiedType &type)
{
FullySpecifiedType result(type);
Function *f = dynamic_cast<Function*>(result.type());
Q_ASSERT(f);
f->setRefQualifier(Function::LvalueRefQualifier);
return result;
}
static FullySpecifiedType rrefThis(const FullySpecifiedType &type)
{
FullySpecifiedType result(type);
Function *function = dynamic_cast<Function*>(result.type());
Q_ASSERT(function);
function->setRefQualifier(Function::RvalueRefQualifier);
return result;
}
static FullySpecifiedType cnstThis(const FullySpecifiedType &type)
{
FullySpecifiedType result(type);
Function *function = dynamic_cast<Function*>(result.type());
Q_ASSERT(function);
function->setConst(true);
return result;
}
static FullySpecifiedType ptr(const FullySpecifiedType &el) static FullySpecifiedType ptr(const FullySpecifiedType &el)
{ return FullySpecifiedType(new PointerType(el)); } { return FullySpecifiedType(new PointerType(el)); }
@@ -166,6 +193,14 @@ void tst_TypePrettyPrinter::basic_data()
addRow(fnTy("foo", voidTy(), intTy()), bindToNothing, "void foo(int)", "foo"); addRow(fnTy("foo", voidTy(), intTy()), bindToNothing, "void foo(int)", "foo");
addRow(fnTy("foo", voidTy(), intTy()), bindToAll, "void foo(int)", "foo"); addRow(fnTy("foo", voidTy(), intTy()), bindToAll, "void foo(int)", "foo");
addRow(refThis(fnTy("foo", voidTy())), bindToNothing, "void foo() &", "foo");
addRow(rrefThis(fnTy("foo", voidTy())), bindToNothing, "void foo() &&", "foo");
addRow(refThis(fnTy("foo", voidTy())), bindToAll, "void foo() &", "foo");
addRow(rrefThis(fnTy("foo", voidTy())), bindToAll, "void foo() &&", "foo");
addRow(cnstThis(refThis(fnTy("foo", voidTy()))), bindToNothing, "void foo() const &", "foo");
addRow(cnstThis(rrefThis(fnTy("foo", voidTy()))), bindToNothing, "void foo() const &&", "foo");
addRow(cnstThis(refThis(fnTy("foo", voidTy()))), bindToAll, "void foo() const&", "foo");
addRow(cnstThis(rrefThis(fnTy("foo", voidTy()))), bindToAll, "void foo() const&&", "foo");
// Pointers to functions and arrays are also excluded. It seems to be quite unusal to have // Pointers to functions and arrays are also excluded. It seems to be quite unusal to have
// a space there. // a space there.

View File

@@ -360,7 +360,7 @@ void tst_CodeSize::codesize_data()
QByteArray std_tie_code = QByteArray std_tie_code =
"struct QMakeStepConfig\n" "struct QMakeStepConfig\n"
"{\n" "{\n"
" enum TargetArchConfig { NoArch, X86, X86_64, PPC, PPC64 };\n" " enum TargetArchConfig { NoArch, X86, X86_64, PowerPC, PowerPC64 };\n"
" enum OsType { NoOsType, IphoneSimulator, IphoneOS };\n" " enum OsType { NoOsType, IphoneSimulator, IphoneOS };\n"
"\n" "\n"
" QMakeStepConfig()\n" " QMakeStepConfig()\n"