From 49d4adc663601c1ca352df1d6fef5ed836ad9454 Mon Sep 17 00:00:00 2001 From: Nerum Date: Fri, 4 Nov 2022 16:59:19 +0100 Subject: [PATCH 001/106] Add base graph implementation based on qt example --- tools/CMakeLists.txt | 1 + tools/fm-editor/CMakeLists.txt | 31 ++++++ tools/fm-editor/FeatureEdge.cpp | 73 +++++++++++++ tools/fm-editor/FeatureEdge.h | 29 ++++++ tools/fm-editor/FeatureModelGraph.cpp | 143 ++++++++++++++++++++++++++ tools/fm-editor/FeatureModelGraph.h | 39 +++++++ tools/fm-editor/FeatureNode.cpp | 100 ++++++++++++++++++ tools/fm-editor/FeatureNode.h | 40 +++++++ tools/fm-editor/main.cpp | 22 ++++ 9 files changed, 478 insertions(+) create mode 100644 tools/fm-editor/CMakeLists.txt create mode 100644 tools/fm-editor/FeatureEdge.cpp create mode 100644 tools/fm-editor/FeatureEdge.h create mode 100644 tools/fm-editor/FeatureModelGraph.cpp create mode 100644 tools/fm-editor/FeatureModelGraph.h create mode 100644 tools/fm-editor/FeatureNode.cpp create mode 100644 tools/fm-editor/FeatureNode.h create mode 100644 tools/fm-editor/main.cpp diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 30a0e6dd2..6fc768618 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -1 +1,2 @@ add_subdirectory(fm-viewer) +add_subdirectory(fm-editor) diff --git a/tools/fm-editor/CMakeLists.txt b/tools/fm-editor/CMakeLists.txt new file mode 100644 index 000000000..133a2e8d7 --- /dev/null +++ b/tools/fm-editor/CMakeLists.txt @@ -0,0 +1,31 @@ +set(LLVM_LINK_COMPONENTS + Support + Demangle + Core + ) + +add_vara_executable(fm-editor + main.cpp + FeatureModelGraph.h + FeatureModelGraph.cpp + FeatureNode.h + FeatureNode.cpp + FeatureEdge.h + FeatureEdge.cpp + ) + +target_link_libraries(fm-editor + LINK_PRIVATE + VaRAFeature + Qt::Core + Qt::Gui + Qt::Widgets + ${STD_FS_LIB} + ) + +add_custom_target(check-vara-fm-editor + COMMAND fm-editor xml/test.xml -viewer cat | dot | grep . -q + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../unittests/resources + ) + +find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets) \ No newline at end of file diff --git a/tools/fm-editor/FeatureEdge.cpp b/tools/fm-editor/FeatureEdge.cpp new file mode 100644 index 000000000..a0a986b48 --- /dev/null +++ b/tools/fm-editor/FeatureEdge.cpp @@ -0,0 +1,73 @@ +// +// Created by simon on 04.11.22. +// + +#include "FeatureEdge.h" +#include "FeatureNode.h" + +#include +#include + +FeatureEdge::FeatureEdge(FeatureNode *SourceNode, FeatureNode *TargetNode) + : Source(SourceNode), Target(TargetNode) { + setAcceptedMouseButtons(Qt::NoButton); + Source->addEdge(this); + Target->addEdge(this); + adjust(); +} +FeatureNode *FeatureEdge::sourceNode() const { return Source; } +FeatureNode *FeatureEdge::targetNode() const { return Target; } +void FeatureEdge::adjust() { + if (!Source || !Target) { + return; + } + + QLineF Line(mapFromItem(Source, 0, 0), mapFromItem(Target, 0, 0)); + qreal Length = Line.length(); + + prepareGeometryChange(); + + if (Length > qreal(20.)) { + QPointF EdgeOffset((Line.dx() * 10) / Length, (Line.dy() * 10) / Length); + SourcePoint = Line.p1() + EdgeOffset; + TargetPoint = Line.p2() - EdgeOffset; + } else { + SourcePoint = TargetPoint = Line.p1(); + } +} +QRectF FeatureEdge::boundingRect() const { + if (!Source || !Target) { + return {}; + } + + qreal PenWidth = 1; + qreal Extra = (PenWidth + ArrowSize) / 2.0; + + return QRectF(SourcePoint, QSizeF(TargetPoint.x() - SourcePoint.x(), + TargetPoint.y() - SourcePoint.y())) + .normalized() + .adjusted(-Extra, -Extra, Extra, Extra); +} +void FeatureEdge::paint(QPainter *Painter, + const QStyleOptionGraphicsItem *Option, + QWidget *Widget) { + if (!Source || !Target) { + return; +} + + QLineF Line(SourcePoint, TargetPoint); + if (qFuzzyCompare(Line.length(), qreal(0.))) { + return; +} + + Painter->setPen(QPen(Qt::black, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); + Painter->drawLine(Line); + double Angle = std::atan2(-Line.dy(), Line.dx()); + QPointF DestArrowP1 = TargetPoint + QPointF(sin(Angle - M_PI / 3) * ArrowSize, + cos(Angle - M_PI / 3) * ArrowSize); + QPointF DestArrowP2 = TargetPoint + QPointF(sin(Angle - M_PI + M_PI / 3) * ArrowSize, + cos(Angle - M_PI + M_PI / 3) * ArrowSize); + + Painter->setBrush(Qt::black); + Painter->drawPolygon(QPolygonF() << Line.p2() << DestArrowP1 << DestArrowP2); +} diff --git a/tools/fm-editor/FeatureEdge.h b/tools/fm-editor/FeatureEdge.h new file mode 100644 index 000000000..b4b51bf86 --- /dev/null +++ b/tools/fm-editor/FeatureEdge.h @@ -0,0 +1,29 @@ + +#ifndef VARA_FEATURE_FEATUREEDGE_H +#define VARA_FEATURE_FEATUREEDGE_H + +#include +class FeatureNode; +class FeatureEdge : public QGraphicsItem{ +public: + FeatureEdge(FeatureNode *SourceNode, FeatureNode *TargetNode); + + [[nodiscard]] FeatureNode *sourceNode() const; + [[nodiscard]] FeatureNode *targetNode() const; + void adjust(); + enum { Type = UserType + 2 }; + [[nodiscard]] int type() const override { return Type; } + +protected: + QRectF boundingRect() const override; + void paint(QPainter *Painter, const QStyleOptionGraphicsItem *Option, QWidget *Widget) override; + +private: + FeatureNode *Source, *Target; + + QPointF SourcePoint; + QPointF TargetPoint; + qreal ArrowSize = 10; +}; + +#endif // VARA_FEATURE_FEATUREEDGE_H diff --git a/tools/fm-editor/FeatureModelGraph.cpp b/tools/fm-editor/FeatureModelGraph.cpp new file mode 100644 index 000000000..b169d76a1 --- /dev/null +++ b/tools/fm-editor/FeatureModelGraph.cpp @@ -0,0 +1,143 @@ +// +// Created by simon on 04.11.22. +// + +#include "FeatureModelGraph.h" +#include "FeatureEdge.h" +#include "FeatureNode.h" +#include "vara/Feature/Feature.h" +#include "vara/Feature/FeatureModel.h" + +#include + +#include +#include +FeatureModelGraph::FeatureModelGraph(vara::feature::FeatureModel &FeatureModel, + QWidget *Parent) + : QGraphicsView(Parent) { + + auto *Scene = new QGraphicsScene(this); + Scene->setItemIndexMethod(QGraphicsScene::NoIndex); + Scene->setSceneRect(-200, -200, 400, 400); + setScene(Scene); + setCacheMode(CacheBackground); + setViewportUpdateMode(BoundingRectViewportUpdate); + setRenderHint(QPainter::Antialiasing); + setTransformationAnchor(AnchorUnderMouse); + scale(qreal(0.8), qreal(0.8)); + setMinimumSize(400, 400); + setWindowTitle(tr("Elastic Nodes")); + auto EntryNode = std::make_unique(this, FeatureModel.getRoot()); + Scene->addItem(EntryNode.get()); + buildRec(EntryNode.get()); + Nodes.insert(std::move(EntryNode)); +} + +void FeatureModelGraph::buildRec(FeatureNode *CurrentFeatureNode) { + for (auto *Feature : + CurrentFeatureNode->getFeature()->getChildren( + 1)) { + auto Node = std::make_unique(this, Feature); + auto Edge = std::make_unique(CurrentFeatureNode, Node.get()); + scene()->addItem(Edge.get()); + scene()->addItem(Node.get()); + buildRec(Node.get()); + Nodes.insert(std::move(Node)); + Edges.insert(std::move(Edge)); + } +} + +void FeatureModelGraph::itemMoved() { + if (!TimerId) { + TimerId = startTimer(1000 / 25); + } +} +void FeatureModelGraph::keyPressEvent(QKeyEvent *Event) { + switch (Event->key()) { + case Qt::Key_Plus: + zoomIn(); + break; + case Qt::Key_Minus: + zoomOut(); + break; + default: + QGraphicsView::keyPressEvent(Event); + } +} +void FeatureModelGraph::timerEvent(QTimerEvent *Event) { + Q_UNUSED(Event); + + for (const std::unique_ptr &Node : Nodes) { + Node->calculateForces(); + } + + bool ItemsMoved = false; + for (const std::unique_ptr &Node : Nodes) { + if (Node->advancePosition()) { + ItemsMoved = true; + } + } + + if (!ItemsMoved) { + killTimer(TimerId); + TimerId = 0; + } +} +#if QT_CONFIG(wheelevent) +void FeatureModelGraph::wheelEvent(QWheelEvent *Event) { + scaleView(pow(2., -Event->angleDelta().y() / 240.0)); +} +#endif + +void FeatureModelGraph::drawBackground(QPainter *Painter, const QRectF &Rect) { + Q_UNUSED(Rect); + + // Shadow + QRectF SceneRect = this->sceneRect(); + QRectF RightShadow(SceneRect.right(), SceneRect.top() + 5, 5, + SceneRect.height()); + QRectF BottomShadow(SceneRect.left() + 5, SceneRect.bottom(), + SceneRect.width(), 5); + if (RightShadow.intersects(Rect) || RightShadow.contains(Rect)) { + Painter->fillRect(RightShadow, Qt::darkGray); + } + if (BottomShadow.intersects(Rect) || BottomShadow.contains(Rect)) { + Painter->fillRect(BottomShadow, Qt::darkGray); + } + + // Fill + QLinearGradient Gradient(SceneRect.topLeft(), SceneRect.bottomRight()); + Gradient.setColorAt(0, Qt::white); + Gradient.setColorAt(1, Qt::lightGray); + Painter->fillRect(Rect.intersected(SceneRect), Gradient); + Painter->setBrush(Qt::NoBrush); + Painter->drawRect(SceneRect); + + // Text + QRectF TextRect(SceneRect.left() + 4, SceneRect.top() + 4, + SceneRect.width() - 4, SceneRect.height() - 4); + QString Message(tr("Click and drag the nodes around, and zoom with the mouse " + "wheel or the '+' and '-' keys")); + + QFont Font = Painter->font(); + Font.setBold(true); + Font.setPointSize(14); + Painter->setFont(Font); + Painter->setPen(Qt::lightGray); + Painter->drawText(TextRect.translated(2, 2), Message); + Painter->setPen(Qt::black); + Painter->drawText(TextRect, Message); +} +void FeatureModelGraph::scaleView(qreal ScaleFactor) { + qreal Factor = transform() + .scale(ScaleFactor, ScaleFactor) + .mapRect(QRectF(0, 0, 1, 1)) + .width(); + if (Factor < 0.07 || Factor > 100) { + return; + } + + scale(ScaleFactor, ScaleFactor); +} +void FeatureModelGraph::zoomIn() { scaleView(qreal(1.2)); } +void FeatureModelGraph::zoomOut() { scaleView(1 / qreal(1.2)); } diff --git a/tools/fm-editor/FeatureModelGraph.h b/tools/fm-editor/FeatureModelGraph.h new file mode 100644 index 000000000..f3c62fae8 --- /dev/null +++ b/tools/fm-editor/FeatureModelGraph.h @@ -0,0 +1,39 @@ + +#ifndef VARA_FEATURE_FEATUREMODELGRAPH_H +#define VARA_FEATURE_FEATUREMODELGRAPH_H + +#include "vara/Feature/FeatureModel.h" +#include +class FeatureNode; +class FeatureEdge; +class FeatureModelGraph : public QGraphicsView { + Q_OBJECT + +public: + FeatureModelGraph(vara::feature::FeatureModel &FeatureModel, + QWidget *Parent = nullptr); + + void itemMoved(); + +public slots: + void zoomIn(); + void zoomOut(); + +protected: + void keyPressEvent(QKeyEvent *Event) override; + void timerEvent(QTimerEvent *Event) override; +#if QT_CONFIG(wheelevent) + void wheelEvent(QWheelEvent *Event) override; +#endif + void drawBackground(QPainter *Painter, const QRectF &Rect) override; + + void scaleView(qreal ScaleFactor); + +private: + void buildRec(FeatureNode *CurrentFeatureNode); + int TimerId = 0; + std::set> Nodes{}; + std::set> Edges{}; +}; + +#endif // VARA_FEATURE_FEATUREMODELGRAPH_H diff --git a/tools/fm-editor/FeatureNode.cpp b/tools/fm-editor/FeatureNode.cpp new file mode 100644 index 000000000..505c27459 --- /dev/null +++ b/tools/fm-editor/FeatureNode.cpp @@ -0,0 +1,100 @@ +// +// Created by simon on 04.11.22. +// + +#include "FeatureNode.h" +#include "FeatureEdge.h" +#include "FeatureModelGraph.h" + +#include +#include +#include +#include + +FeatureNode::FeatureNode(FeatureModelGraph *Parent, vara::feature::Feature *Feature) : Parent(Parent),Feature(Feature) { + setFlag(ItemIsMovable); + setFlag(ItemSendsGeometryChanges); + setCacheMode(DeviceCoordinateCache); + setZValue(-1); +} + +void FeatureNode::addEdge(FeatureEdge *Edge) { + EdgeList << Edge; + Edge->adjust(); +} +QList FeatureNode::edges() const { + return EdgeList; +} +void FeatureNode::calculateForces() { + if (!scene() || scene()->mouseGrabberItem() == this) { + NewPos = pos(); + return; + } +} +bool FeatureNode::advancePosition() { + if (NewPos == pos()) { + return false; +} + + setPos(NewPos); + return true; +} +QRectF FeatureNode::boundingRect() const { + qreal Adjust = 2; + return { -10 - Adjust, -10 - Adjust, 23 + Adjust, 23 + Adjust}; +} + +QPainterPath FeatureNode::shape() const +{ + QPainterPath Path; + Path.addEllipse(-10, -10, 20, 20); + return Path; +} +void FeatureNode::paint(QPainter *Painter, + const QStyleOptionGraphicsItem *Option, + QWidget *Widget) { + Painter->setPen(Qt::NoPen); + Painter->setBrush(Qt::darkGray); + Painter->drawEllipse(-7, -7, 20, 20); + + QRadialGradient gradient(-3, -3, 10); + if (Option->state & QStyle::State_Sunken) { + gradient.setCenter(3, 3); + gradient.setFocalPoint(3, 3); + gradient.setColorAt(1, QColor(Qt::yellow).lighter(120)); + gradient.setColorAt(0, QColor(Qt::darkYellow).lighter(120)); + } else { + gradient.setColorAt(0, Qt::yellow); + gradient.setColorAt(1, Qt::darkYellow); + } + Painter->setBrush(gradient); + + Painter->setPen(QPen(Qt::black, 0)); + Painter->drawEllipse(-10, -10, 20, 20); +} +QVariant FeatureNode::itemChange(QGraphicsItem::GraphicsItemChange Change, + const QVariant &Value) { + switch (Change) { + case ItemPositionHasChanged: + for (FeatureEdge *Edge : std::as_const(EdgeList)) { + Edge->adjust(); +} + Parent->itemMoved(); + break; + default: + break; + }; + + return QGraphicsItem::itemChange(Change, Value); +} + +void FeatureNode::mousePressEvent(QGraphicsSceneMouseEvent *Event) +{ + update(); + QGraphicsItem::mousePressEvent(Event); +} + +void FeatureNode::mouseReleaseEvent(QGraphicsSceneMouseEvent *Event) { + update(); + QGraphicsItem::mouseReleaseEvent(Event); +} diff --git a/tools/fm-editor/FeatureNode.h b/tools/fm-editor/FeatureNode.h new file mode 100644 index 000000000..e7ca582dd --- /dev/null +++ b/tools/fm-editor/FeatureNode.h @@ -0,0 +1,40 @@ + +#ifndef VARA_FEATURE_FEATURENODE_H +#define VARA_FEATURE_FEATURENODE_H + +#include "vara/Feature/Feature.h" +#include +#include + +class FeatureEdge; +class FeatureModelGraph; +class FeatureNode : public QGraphicsItem { +public: + FeatureNode(FeatureModelGraph *Parent, vara::feature::Feature *Feature); + + void addEdge(FeatureEdge *Edge); + [[nodiscard]] QList edges() const; + + enum { Type = UserType + 1 }; + [[nodiscard]] int type() const override { return Type; } + void calculateForces(); + bool advancePosition(); + vara::feature::Feature* getFeature(){return Feature;}; + [[nodiscard]] QRectF boundingRect() const override; + [[nodiscard]] QPainterPath shape() const override; + void paint(QPainter *Painter, const QStyleOptionGraphicsItem *Option, QWidget *Widget) override; + +protected: + QVariant itemChange(GraphicsItemChange Change, const QVariant &Value) override; + + void mousePressEvent(QGraphicsSceneMouseEvent *Event) override; + void mouseReleaseEvent(QGraphicsSceneMouseEvent *Event) override; + +private: + QList EdgeList; + QPointF NewPos; + FeatureModelGraph *Parent; + vara::feature::Feature *Feature; +}; + +#endif // VARA_FEATURE_FEATURENODE_H diff --git a/tools/fm-editor/main.cpp b/tools/fm-editor/main.cpp new file mode 100644 index 000000000..a1039ffea --- /dev/null +++ b/tools/fm-editor/main.cpp @@ -0,0 +1,22 @@ +// +// Created by simon on 04.11.22. +// + +#include "FeatureModelGraph.h" + +#include +#include +#include + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + + GraphWidget *widget = new FeatureModelGraph(); + + QMainWindow mainWindow; + mainWindow.setCentralWidget(widget); + + mainWindow.show(); + return app.exec(); +} \ No newline at end of file From f2c949e5afec5a0d8ffc90ed6bd6bc35e2bbd3d4 Mon Sep 17 00:00:00 2001 From: Simon Friedel Date: Mon, 7 Nov 2022 15:39:54 +0100 Subject: [PATCH 002/106] add function to position the nodes in a tree like structure --- tools/fm-editor/FeatureEdge.cpp | 4 +-- tools/fm-editor/FeatureModelGraph.cpp | 39 +++++++++++++++++++++---- tools/fm-editor/FeatureModelGraph.h | 11 +++++-- tools/fm-editor/FeatureNode.cpp | 42 +++++++++++++++++---------- tools/fm-editor/FeatureNode.h | 13 +++++---- tools/fm-editor/main.cpp | 15 +++++----- 6 files changed, 85 insertions(+), 39 deletions(-) diff --git a/tools/fm-editor/FeatureEdge.cpp b/tools/fm-editor/FeatureEdge.cpp index a0a986b48..9f931bd15 100644 --- a/tools/fm-editor/FeatureEdge.cpp +++ b/tools/fm-editor/FeatureEdge.cpp @@ -11,8 +11,8 @@ FeatureEdge::FeatureEdge(FeatureNode *SourceNode, FeatureNode *TargetNode) : Source(SourceNode), Target(TargetNode) { setAcceptedMouseButtons(Qt::NoButton); - Source->addEdge(this); - Target->addEdge(this); + Source->addChildEdge(this); + TargetNode->setParentEdge(this); adjust(); } FeatureNode *FeatureEdge::sourceNode() const { return Source; } diff --git a/tools/fm-editor/FeatureModelGraph.cpp b/tools/fm-editor/FeatureModelGraph.cpp index b169d76a1..d8514c9d9 100644 --- a/tools/fm-editor/FeatureModelGraph.cpp +++ b/tools/fm-editor/FeatureModelGraph.cpp @@ -12,10 +12,11 @@ #include #include -FeatureModelGraph::FeatureModelGraph(vara::feature::FeatureModel &FeatureModel, +FeatureModelGraph::FeatureModelGraph(vara::feature::FeatureModel *FeatureModel, QWidget *Parent) : QGraphicsView(Parent) { - + Edges = std::set>{}; + Nodes = std::set>{}; auto *Scene = new QGraphicsScene(this); Scene->setItemIndexMethod(QGraphicsScene::NoIndex); Scene->setSceneRect(-200, -200, 400, 400); @@ -27,10 +28,16 @@ FeatureModelGraph::FeatureModelGraph(vara::feature::FeatureModel &FeatureModel, scale(qreal(0.8), qreal(0.8)); setMinimumSize(400, 400); setWindowTitle(tr("Elastic Nodes")); - auto EntryNode = std::make_unique(this, FeatureModel.getRoot()); - Scene->addItem(EntryNode.get()); - buildRec(EntryNode.get()); - Nodes.insert(std::move(EntryNode)); + auto EntryNodeUnique = std::make_unique(this, FeatureModel->getRoot()); + EntryNode = EntryNodeUnique.get(); + Scene->addItem(EntryNode); + buildRec(EntryNode); + Nodes.insert(std::move(EntryNodeUnique)); + auto NextChildren =std::vector(EntryNode->children().size()); + auto CurrentChildren = EntryNode->children(); + std::transform(CurrentChildren.begin(),CurrentChildren.end(),NextChildren.begin(),[](FeatureEdge* Edge){return Edge->targetNode();}); + positionRec(1,NextChildren,WIDTH,0); + EntryNode->setPos(WIDTH/2,0); } void FeatureModelGraph::buildRec(FeatureNode *CurrentFeatureNode) { @@ -47,6 +54,26 @@ void FeatureModelGraph::buildRec(FeatureNode *CurrentFeatureNode) { } } +int FeatureModelGraph::positionRec(const int CurrentDepth, const std::vector& Children, const unsigned long Width, const unsigned long Offset){ + if(Children.empty()){ + return CurrentDepth-1; + } + auto ContainerSize = Width / Children.size(); + int Container = 0; + int MaxDepth = CurrentDepth; + for(FeatureNode* Node : Children){ + auto NextOffset = Offset+Container*ContainerSize; + Container++; + auto NextChildren =std::vector(Node->children().size()); + auto CurrentChildren = Node->children(); + std::transform(CurrentChildren.begin(),CurrentChildren.end(),NextChildren.begin(),[](FeatureEdge* Edge){return Edge->targetNode();}); + int Depth = positionRec(CurrentDepth+1,NextChildren,ContainerSize,NextOffset); + Node->setPos(NextOffset+ContainerSize/2,(HEIGHT/Depth)*CurrentDepth); + MaxDepth = MaxDepth> Nodes{}; - std::set> Edges{}; + FeatureNode* EntryNode; + std::set> Nodes; + std::set> Edges; + int positionRec(int CurrentDepth, const std::vector& Children, + unsigned long Width, unsigned long Offset); + const int HEIGHT = 600; + const int WIDTH = 600; }; #endif // VARA_FEATURE_FEATUREMODELGRAPH_H diff --git a/tools/fm-editor/FeatureNode.cpp b/tools/fm-editor/FeatureNode.cpp index 505c27459..7774e6e91 100644 --- a/tools/fm-editor/FeatureNode.cpp +++ b/tools/fm-editor/FeatureNode.cpp @@ -11,20 +11,30 @@ #include #include -FeatureNode::FeatureNode(FeatureModelGraph *Parent, vara::feature::Feature *Feature) : Parent(Parent),Feature(Feature) { +FeatureNode::FeatureNode(FeatureModelGraph *Graph, vara::feature::Feature *Feature) : Graph(Graph),Feature(Feature) { setFlag(ItemIsMovable); setFlag(ItemSendsGeometryChanges); setCacheMode(DeviceCoordinateCache); setZValue(-1); } -void FeatureNode::addEdge(FeatureEdge *Edge) { - EdgeList << Edge; +void FeatureNode::addChildEdge(FeatureEdge *Edge) { + ChildEdges.push_back(Edge); Edge->adjust(); } -QList FeatureNode::edges() const { - return EdgeList; +void FeatureNode::setParentEdge(FeatureEdge *Edge) { + ParentEdge = Edge; + Edge->adjust(); +} + +std::vector FeatureNode::children() const { + return ChildEdges; } + +FeatureEdge * FeatureNode::parent() const { + return ParentEdge; +} + void FeatureNode::calculateForces() { if (!scene() || scene()->mouseGrabberItem() == this) { NewPos = pos(); @@ -57,17 +67,17 @@ void FeatureNode::paint(QPainter *Painter, Painter->setBrush(Qt::darkGray); Painter->drawEllipse(-7, -7, 20, 20); - QRadialGradient gradient(-3, -3, 10); + QRadialGradient Gradient(-3, -3, 10); if (Option->state & QStyle::State_Sunken) { - gradient.setCenter(3, 3); - gradient.setFocalPoint(3, 3); - gradient.setColorAt(1, QColor(Qt::yellow).lighter(120)); - gradient.setColorAt(0, QColor(Qt::darkYellow).lighter(120)); + Gradient.setCenter(3, 3); + Gradient.setFocalPoint(3, 3); + Gradient.setColorAt(1, QColor(Qt::yellow).lighter(120)); + Gradient.setColorAt(0, QColor(Qt::darkYellow).lighter(120)); } else { - gradient.setColorAt(0, Qt::yellow); - gradient.setColorAt(1, Qt::darkYellow); + Gradient.setColorAt(0, Qt::yellow); + Gradient.setColorAt(1, Qt::darkYellow); } - Painter->setBrush(gradient); + Painter->setBrush(Gradient); Painter->setPen(QPen(Qt::black, 0)); Painter->drawEllipse(-10, -10, 20, 20); @@ -76,14 +86,14 @@ QVariant FeatureNode::itemChange(QGraphicsItem::GraphicsItemChange Change, const QVariant &Value) { switch (Change) { case ItemPositionHasChanged: - for (FeatureEdge *Edge : std::as_const(EdgeList)) { + for (FeatureEdge *Edge : std::as_const(ChildEdges)) { Edge->adjust(); } - Parent->itemMoved(); + Graph->itemMoved(); break; default: break; - }; + } return QGraphicsItem::itemChange(Change, Value); } diff --git a/tools/fm-editor/FeatureNode.h b/tools/fm-editor/FeatureNode.h index e7ca582dd..de4f3d31f 100644 --- a/tools/fm-editor/FeatureNode.h +++ b/tools/fm-editor/FeatureNode.h @@ -10,10 +10,12 @@ class FeatureEdge; class FeatureModelGraph; class FeatureNode : public QGraphicsItem { public: - FeatureNode(FeatureModelGraph *Parent, vara::feature::Feature *Feature); + FeatureNode(FeatureModelGraph *Graph, vara::feature::Feature *Feature); - void addEdge(FeatureEdge *Edge); - [[nodiscard]] QList edges() const; + void addChildEdge(FeatureEdge *Edge); + void setParentEdge(FeatureEdge *Edge); + [[nodiscard]] std::vector children() const; + [[nodiscard]] FeatureEdge * parent() const; enum { Type = UserType + 1 }; [[nodiscard]] int type() const override { return Type; } @@ -31,9 +33,10 @@ class FeatureNode : public QGraphicsItem { void mouseReleaseEvent(QGraphicsSceneMouseEvent *Event) override; private: - QList EdgeList; + std::vector ChildEdges; + FeatureEdge * ParentEdge = nullptr; QPointF NewPos; - FeatureModelGraph *Parent; + FeatureModelGraph *Graph; vara::feature::Feature *Feature; }; diff --git a/tools/fm-editor/main.cpp b/tools/fm-editor/main.cpp index a1039ffea..50f79ec78 100644 --- a/tools/fm-editor/main.cpp +++ b/tools/fm-editor/main.cpp @@ -3,6 +3,7 @@ // #include "FeatureModelGraph.h" +#include "vara/Feature/FeatureModel.h" #include #include @@ -10,13 +11,13 @@ int main(int argc, char **argv) { - QApplication app(argc, argv); + QApplication App(argc, argv); + auto Model = vara::feature::loadFeatureModel("test_children.xml"); + auto *Widget = new FeatureModelGraph(Model.get()); - GraphWidget *widget = new FeatureModelGraph(); + QMainWindow MainWindow; + MainWindow.setCentralWidget(Widget); - QMainWindow mainWindow; - mainWindow.setCentralWidget(widget); - - mainWindow.show(); - return app.exec(); + MainWindow.show(); + return App.exec(); } \ No newline at end of file From 9a5c030a8ac7eef6d84638636c6e7e09ab8536fc Mon Sep 17 00:00:00 2001 From: Nerum Date: Mon, 7 Nov 2022 16:21:04 +0100 Subject: [PATCH 003/106] Remove usage of unique pointer because qt does not like that. --- tools/fm-editor/CMakeLists.txt | 1 + tools/fm-editor/FeatureModelGraph.cpp | 48 ++++----------------------- tools/fm-editor/FeatureModelGraph.h | 4 --- tools/fm-editor/FeatureNode.cpp | 5 ++- tools/fm-editor/main.cpp | 2 +- 5 files changed, 13 insertions(+), 47 deletions(-) diff --git a/tools/fm-editor/CMakeLists.txt b/tools/fm-editor/CMakeLists.txt index 133a2e8d7..c36d2018f 100644 --- a/tools/fm-editor/CMakeLists.txt +++ b/tools/fm-editor/CMakeLists.txt @@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS Demangle Core ) +set(CMAKE_AUTOMOC ON) add_vara_executable(fm-editor main.cpp diff --git a/tools/fm-editor/FeatureModelGraph.cpp b/tools/fm-editor/FeatureModelGraph.cpp index d8514c9d9..e96cc665c 100644 --- a/tools/fm-editor/FeatureModelGraph.cpp +++ b/tools/fm-editor/FeatureModelGraph.cpp @@ -14,9 +14,7 @@ #include FeatureModelGraph::FeatureModelGraph(vara::feature::FeatureModel *FeatureModel, QWidget *Parent) - : QGraphicsView(Parent) { - Edges = std::set>{}; - Nodes = std::set>{}; + : QGraphicsView(Parent), EntryNode(new FeatureNode(this, FeatureModel->getRoot())) { auto *Scene = new QGraphicsScene(this); Scene->setItemIndexMethod(QGraphicsScene::NoIndex); Scene->setSceneRect(-200, -200, 400, 400); @@ -27,12 +25,9 @@ FeatureModelGraph::FeatureModelGraph(vara::feature::FeatureModel *FeatureModel, setTransformationAnchor(AnchorUnderMouse); scale(qreal(0.8), qreal(0.8)); setMinimumSize(400, 400); - setWindowTitle(tr("Elastic Nodes")); - auto EntryNodeUnique = std::make_unique(this, FeatureModel->getRoot()); - EntryNode = EntryNodeUnique.get(); + Scene->addItem(EntryNode); buildRec(EntryNode); - Nodes.insert(std::move(EntryNodeUnique)); auto NextChildren =std::vector(EntryNode->children().size()); auto CurrentChildren = EntryNode->children(); std::transform(CurrentChildren.begin(),CurrentChildren.end(),NextChildren.begin(),[](FeatureEdge* Edge){return Edge->targetNode();}); @@ -44,13 +39,11 @@ void FeatureModelGraph::buildRec(FeatureNode *CurrentFeatureNode) { for (auto *Feature : CurrentFeatureNode->getFeature()->getChildren( 1)) { - auto Node = std::make_unique(this, Feature); - auto Edge = std::make_unique(CurrentFeatureNode, Node.get()); - scene()->addItem(Edge.get()); - scene()->addItem(Node.get()); - buildRec(Node.get()); - Nodes.insert(std::move(Node)); - Edges.insert(std::move(Edge)); + auto *Node = new FeatureNode(this, Feature); + auto *Edge = new FeatureEdge(CurrentFeatureNode, Node); + scene()->addItem(Edge); + scene()->addItem(Node); + buildRec(Node); } } @@ -91,25 +84,6 @@ void FeatureModelGraph::keyPressEvent(QKeyEvent *Event) { QGraphicsView::keyPressEvent(Event); } } -void FeatureModelGraph::timerEvent(QTimerEvent *Event) { - Q_UNUSED(Event); - - for (const std::unique_ptr &Node : Nodes) { - Node->calculateForces(); - } - - bool ItemsMoved = false; - for (const std::unique_ptr &Node : Nodes) { - if (Node->advancePosition()) { - ItemsMoved = true; - } - } - - if (!ItemsMoved) { - killTimer(TimerId); - TimerId = 0; - } -} #if QT_CONFIG(wheelevent) void FeatureModelGraph::wheelEvent(QWheelEvent *Event) { scaleView(pow(2., -Event->angleDelta().y() / 240.0)); @@ -140,20 +114,12 @@ void FeatureModelGraph::drawBackground(QPainter *Painter, const QRectF &Rect) { Painter->setBrush(Qt::NoBrush); Painter->drawRect(SceneRect); - // Text - QRectF TextRect(SceneRect.left() + 4, SceneRect.top() + 4, - SceneRect.width() - 4, SceneRect.height() - 4); - QString Message(tr("Click and drag the nodes around, and zoom with the mouse " - "wheel or the '+' and '-' keys")); - QFont Font = Painter->font(); Font.setBold(true); Font.setPointSize(14); Painter->setFont(Font); Painter->setPen(Qt::lightGray); - Painter->drawText(TextRect.translated(2, 2), Message); Painter->setPen(Qt::black); - Painter->drawText(TextRect, Message); } void FeatureModelGraph::scaleView(qreal ScaleFactor) { qreal Factor = transform() diff --git a/tools/fm-editor/FeatureModelGraph.h b/tools/fm-editor/FeatureModelGraph.h index 59e0e32d0..05015d928 100644 --- a/tools/fm-editor/FeatureModelGraph.h +++ b/tools/fm-editor/FeatureModelGraph.h @@ -21,20 +21,16 @@ public slots: protected: void keyPressEvent(QKeyEvent *Event) override; - void timerEvent(QTimerEvent *Event) override; #if QT_CONFIG(wheelevent) void wheelEvent(QWheelEvent *Event) override; #endif void drawBackground(QPainter *Painter, const QRectF &Rect) override; void scaleView(qreal ScaleFactor); - private: void buildRec(FeatureNode *CurrentFeatureNode); int TimerId = 0; FeatureNode* EntryNode; - std::set> Nodes; - std::set> Edges; int positionRec(int CurrentDepth, const std::vector& Children, unsigned long Width, unsigned long Offset); const int HEIGHT = 600; diff --git a/tools/fm-editor/FeatureNode.cpp b/tools/fm-editor/FeatureNode.cpp index 7774e6e91..19e32bbb0 100644 --- a/tools/fm-editor/FeatureNode.cpp +++ b/tools/fm-editor/FeatureNode.cpp @@ -88,7 +88,10 @@ QVariant FeatureNode::itemChange(QGraphicsItem::GraphicsItemChange Change, case ItemPositionHasChanged: for (FeatureEdge *Edge : std::as_const(ChildEdges)) { Edge->adjust(); -} + } + if (ParentEdge) { + ParentEdge->adjust(); + } Graph->itemMoved(); break; default: diff --git a/tools/fm-editor/main.cpp b/tools/fm-editor/main.cpp index 50f79ec78..5293b7a7b 100644 --- a/tools/fm-editor/main.cpp +++ b/tools/fm-editor/main.cpp @@ -12,7 +12,7 @@ int main(int argc, char **argv) { QApplication App(argc, argv); - auto Model = vara::feature::loadFeatureModel("test_children.xml"); + auto Model = vara::feature::loadFeatureModel("/home/simon/Workspace/vara-feature/tools/fm-editor/test_children.xml"); auto *Widget = new FeatureModelGraph(Model.get()); QMainWindow MainWindow; From e85c7af37d29cb4f2347dcf96711eb6ecb5841a8 Mon Sep 17 00:00:00 2001 From: Nerum Date: Tue, 15 Nov 2022 20:37:17 +0100 Subject: [PATCH 004/106] add ui --- tools/fm-editor/CMakeLists.txt | 4 +- tools/fm-editor/FeatureModelEditor.cpp | 20 +++++++++ tools/fm-editor/FeatureModelEditor.h | 24 ++++++++++ tools/fm-editor/FeatureModelEditor.ui | 62 ++++++++++++++++++++++++++ tools/fm-editor/FeatureModelGraph.cpp | 15 ++++--- tools/fm-editor/FeatureModelGraph.h | 6 ++- tools/fm-editor/FeatureNode.cpp | 38 ++++++++-------- tools/fm-editor/FeatureNode.h | 5 ++- tools/fm-editor/main.cpp | 12 ++--- 9 files changed, 148 insertions(+), 38 deletions(-) create mode 100644 tools/fm-editor/FeatureModelEditor.cpp create mode 100644 tools/fm-editor/FeatureModelEditor.h create mode 100644 tools/fm-editor/FeatureModelEditor.ui diff --git a/tools/fm-editor/CMakeLists.txt b/tools/fm-editor/CMakeLists.txt index c36d2018f..51405d018 100644 --- a/tools/fm-editor/CMakeLists.txt +++ b/tools/fm-editor/CMakeLists.txt @@ -4,7 +4,7 @@ set(LLVM_LINK_COMPONENTS Core ) set(CMAKE_AUTOMOC ON) - +set(CMAKE_AUTOUIC ON) add_vara_executable(fm-editor main.cpp FeatureModelGraph.h @@ -13,6 +13,8 @@ add_vara_executable(fm-editor FeatureNode.cpp FeatureEdge.h FeatureEdge.cpp + FeatureModelEditor.h FeatureModelEditor.cpp + FeatureModelEditor.ui ) target_link_libraries(fm-editor diff --git a/tools/fm-editor/FeatureModelEditor.cpp b/tools/fm-editor/FeatureModelEditor.cpp new file mode 100644 index 000000000..613d5e4d7 --- /dev/null +++ b/tools/fm-editor/FeatureModelEditor.cpp @@ -0,0 +1,20 @@ +// +// Created by simon on 07.11.22. +// + +#include "FeatureModelEditor.h" +#include "FeatureModelGraph.h" +#include "FeatureNode.h" +#include "ui_FeatureModelEditor.h" +#include "vara/Feature/FeatureModel.h" +FeatureModelEditor::FeatureModelEditor(QWidget *Parent) : QMainWindow(Parent), Ui(new Ui::FeatureModelEditor) { + auto Model = vara::feature::loadFeatureModel("/home/simon/Workspace/vara-feature/tools/fm-editor/test_children.xml"); + Ui->setupUi(this); + auto * featureModelGraph= new FeatureModelGraph(std::move(Model),Ui->centralwidget); + Ui->featureGraph = featureModelGraph; + Ui->featureGraph->setObjectName(QString::fromUtf8("featureGraph")); + Ui->gridLayout->addWidget(Ui->featureGraph, 0, 0, 2, 1); + for(auto * Node:featureModelGraph->getNodes()) { + QObject::connect(Node,&FeatureNode::clicked, this, &FeatureModelEditor::loadFeature); + } +} diff --git a/tools/fm-editor/FeatureModelEditor.h b/tools/fm-editor/FeatureModelEditor.h new file mode 100644 index 000000000..916b02e25 --- /dev/null +++ b/tools/fm-editor/FeatureModelEditor.h @@ -0,0 +1,24 @@ + +#ifndef VARA_FEATURE_FEATUREMODELEDITOR_H +#define VARA_FEATURE_FEATUREMODELEDITOR_H + +#include "vara/Feature/Feature.h" +#include +QT_BEGIN_NAMESPACE +namespace Ui { +class FeatureModelEditor; +} // namespace Ui +QT_END_NAMESPACE + +class FeatureModelEditor : public QMainWindow { + Q_OBJECT +public: + explicit FeatureModelEditor(QWidget *Parent = nullptr); + ~FeatureModelEditor() override = default; +private: + Ui::FeatureModelEditor *Ui; +private slots: + void loadFeature(vara::feature::Feature &Feature); +}; + +#endif // VARA_FEATURE_FEATUREMODELEDITOR_H diff --git a/tools/fm-editor/FeatureModelEditor.ui b/tools/fm-editor/FeatureModelEditor.ui new file mode 100644 index 000000000..91a0d3bd5 --- /dev/null +++ b/tools/fm-editor/FeatureModelEditor.ui @@ -0,0 +1,62 @@ + + + FeatureModelEditor + + + + 0 + 0 + 800 + 600 + + + + MainWindow + + + + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + load + + + + + + + + + + + + + + + + + + 0 + 0 + 800 + 30 + + + + + + + + diff --git a/tools/fm-editor/FeatureModelGraph.cpp b/tools/fm-editor/FeatureModelGraph.cpp index e96cc665c..381089967 100644 --- a/tools/fm-editor/FeatureModelGraph.cpp +++ b/tools/fm-editor/FeatureModelGraph.cpp @@ -12,12 +12,12 @@ #include #include -FeatureModelGraph::FeatureModelGraph(vara::feature::FeatureModel *FeatureModel, +FeatureModelGraph::FeatureModelGraph(std::unique_ptr FeatureModel, QWidget *Parent) - : QGraphicsView(Parent), EntryNode(new FeatureNode(this, FeatureModel->getRoot())) { + : QGraphicsView(Parent), EntryNode(new FeatureNode(this, FeatureModel->getRoot())), FeatureModel(std::move(FeatureModel)) { auto *Scene = new QGraphicsScene(this); Scene->setItemIndexMethod(QGraphicsScene::NoIndex); - Scene->setSceneRect(-200, -200, 400, 400); + Scene->setSceneRect(0, 0, 600, 600); setScene(Scene); setCacheMode(CacheBackground); setViewportUpdateMode(BoundingRectViewportUpdate); @@ -25,14 +25,14 @@ FeatureModelGraph::FeatureModelGraph(vara::feature::FeatureModel *FeatureModel, setTransformationAnchor(AnchorUnderMouse); scale(qreal(0.8), qreal(0.8)); setMinimumSize(400, 400); - + Nodes.insert(EntryNode); Scene->addItem(EntryNode); buildRec(EntryNode); auto NextChildren =std::vector(EntryNode->children().size()); auto CurrentChildren = EntryNode->children(); std::transform(CurrentChildren.begin(),CurrentChildren.end(),NextChildren.begin(),[](FeatureEdge* Edge){return Edge->targetNode();}); - positionRec(1,NextChildren,WIDTH,0); - EntryNode->setPos(WIDTH/2,0); + positionRec(1,NextChildren,WIDTH-10,0); + EntryNode->setPos(WIDTH/2,10); } void FeatureModelGraph::buildRec(FeatureNode *CurrentFeatureNode) { @@ -41,6 +41,7 @@ void FeatureModelGraph::buildRec(FeatureNode *CurrentFeatureNode) { 1)) { auto *Node = new FeatureNode(this, Feature); auto *Edge = new FeatureEdge(CurrentFeatureNode, Node); + Nodes.insert(Node); scene()->addItem(Edge); scene()->addItem(Node); buildRec(Node); @@ -61,7 +62,7 @@ int FeatureModelGraph::positionRec(const int CurrentDepth, const std::vectorchildren(); std::transform(CurrentChildren.begin(),CurrentChildren.end(),NextChildren.begin(),[](FeatureEdge* Edge){return Edge->targetNode();}); int Depth = positionRec(CurrentDepth+1,NextChildren,ContainerSize,NextOffset); - Node->setPos(NextOffset+ContainerSize/2,(HEIGHT/Depth)*CurrentDepth); + Node->setPos(NextOffset+ContainerSize/2,(HEIGHT/(Depth+1))*CurrentDepth); MaxDepth = MaxDepth FeatureModel, QWidget *Parent = nullptr); - + std::set getNodes() {return Nodes;}; void itemMoved(); public slots: @@ -35,6 +35,8 @@ public slots: unsigned long Width, unsigned long Offset); const int HEIGHT = 600; const int WIDTH = 600; + std::unique_ptr FeatureModel; + std::set Nodes; }; #endif // VARA_FEATURE_FEATUREMODELGRAPH_H diff --git a/tools/fm-editor/FeatureNode.cpp b/tools/fm-editor/FeatureNode.cpp index 19e32bbb0..b3a19865c 100644 --- a/tools/fm-editor/FeatureNode.cpp +++ b/tools/fm-editor/FeatureNode.cpp @@ -51,36 +51,32 @@ bool FeatureNode::advancePosition() { } QRectF FeatureNode::boundingRect() const { qreal Adjust = 2; - return { -10 - Adjust, -10 - Adjust, 23 + Adjust, 23 + Adjust}; + int W = width(); + return {-W / 2 - Adjust, -10 - Adjust, W + Adjust, 23 + Adjust}; } -QPainterPath FeatureNode::shape() const -{ +QPainterPath FeatureNode::shape() const { QPainterPath Path; - Path.addEllipse(-10, -10, 20, 20); + int W = width(); + Path.addRect(-W / 2, -10, W, 20); return Path; } void FeatureNode::paint(QPainter *Painter, const QStyleOptionGraphicsItem *Option, QWidget *Widget) { - Painter->setPen(Qt::NoPen); - Painter->setBrush(Qt::darkGray); - Painter->drawEllipse(-7, -7, 20, 20); - - QRadialGradient Gradient(-3, -3, 10); + const auto Name = QString::fromStdString(Feature->getName().str()); + QBrush Brush(Qt::darkYellow); if (Option->state & QStyle::State_Sunken) { - Gradient.setCenter(3, 3); - Gradient.setFocalPoint(3, 3); - Gradient.setColorAt(1, QColor(Qt::yellow).lighter(120)); - Gradient.setColorAt(0, QColor(Qt::darkYellow).lighter(120)); + Brush.setColor(QColor(Qt::yellow).lighter(120)); } else { - Gradient.setColorAt(0, Qt::yellow); - Gradient.setColorAt(1, Qt::darkYellow); } - Painter->setBrush(Gradient); + Painter->setBrush(Brush); Painter->setPen(QPen(Qt::black, 0)); - Painter->drawEllipse(-10, -10, 20, 20); + int W = width(); + Painter->drawRect(-W / 2, -10, W, 20); + Painter->setPen(QPen(Qt::black, 1)); + Painter->drawText(-W/2+5, 5, Name); } QVariant FeatureNode::itemChange(QGraphicsItem::GraphicsItemChange Change, const QVariant &Value) { @@ -101,8 +97,7 @@ QVariant FeatureNode::itemChange(QGraphicsItem::GraphicsItemChange Change, return QGraphicsItem::itemChange(Change, Value); } -void FeatureNode::mousePressEvent(QGraphicsSceneMouseEvent *Event) -{ +void FeatureNode::mousePressEvent(QGraphicsSceneMouseEvent *Event) { update(); QGraphicsItem::mousePressEvent(Event); } @@ -111,3 +106,8 @@ void FeatureNode::mouseReleaseEvent(QGraphicsSceneMouseEvent *Event) { update(); QGraphicsItem::mouseReleaseEvent(Event); } + +int FeatureNode::width() const { + auto Name = Feature->getName(); + return 15 + 5 * Name.str().length(); +} diff --git a/tools/fm-editor/FeatureNode.h b/tools/fm-editor/FeatureNode.h index de4f3d31f..df3e2c541 100644 --- a/tools/fm-editor/FeatureNode.h +++ b/tools/fm-editor/FeatureNode.h @@ -9,6 +9,7 @@ class FeatureEdge; class FeatureModelGraph; class FeatureNode : public QGraphicsItem { + Q_OBJECT public: FeatureNode(FeatureModelGraph *Graph, vara::feature::Feature *Feature); @@ -25,7 +26,8 @@ class FeatureNode : public QGraphicsItem { [[nodiscard]] QRectF boundingRect() const override; [[nodiscard]] QPainterPath shape() const override; void paint(QPainter *Painter, const QStyleOptionGraphicsItem *Option, QWidget *Widget) override; - +signals: + void clicked(vara::feature::Feature &Feature); protected: QVariant itemChange(GraphicsItemChange Change, const QVariant &Value) override; @@ -33,6 +35,7 @@ class FeatureNode : public QGraphicsItem { void mouseReleaseEvent(QGraphicsSceneMouseEvent *Event) override; private: + int width() const; std::vector ChildEdges; FeatureEdge * ParentEdge = nullptr; QPointF NewPos; diff --git a/tools/fm-editor/main.cpp b/tools/fm-editor/main.cpp index 5293b7a7b..8d5681e7a 100644 --- a/tools/fm-editor/main.cpp +++ b/tools/fm-editor/main.cpp @@ -2,22 +2,18 @@ // Created by simon on 04.11.22. // +#include "FeatureModelEditor.h" #include "FeatureModelGraph.h" #include "vara/Feature/FeatureModel.h" #include -#include #include +#include int main(int argc, char **argv) { QApplication App(argc, argv); - auto Model = vara::feature::loadFeatureModel("/home/simon/Workspace/vara-feature/tools/fm-editor/test_children.xml"); - auto *Widget = new FeatureModelGraph(Model.get()); - - QMainWindow MainWindow; - MainWindow.setCentralWidget(Widget); - - MainWindow.show(); + FeatureModelEditor W; + W.show(); return App.exec(); } \ No newline at end of file From 8a897178a6a9d4b19f417f4e375b4cfcd222695e Mon Sep 17 00:00:00 2001 From: Simon Friedel Date: Tue, 29 Nov 2022 14:33:34 +0100 Subject: [PATCH 005/106] build the main gui --- tools/fm-editor/FeatureModelEditor.cpp | 30 ++++++++--- tools/fm-editor/FeatureModelEditor.h | 5 +- tools/fm-editor/FeatureModelEditor.ui | 73 +++++++++++++++++++++----- tools/fm-editor/FeatureNode.cpp | 1 + tools/fm-editor/FeatureNode.h | 8 +-- 5 files changed, 91 insertions(+), 26 deletions(-) diff --git a/tools/fm-editor/FeatureModelEditor.cpp b/tools/fm-editor/FeatureModelEditor.cpp index 613d5e4d7..516ee64ce 100644 --- a/tools/fm-editor/FeatureModelEditor.cpp +++ b/tools/fm-editor/FeatureModelEditor.cpp @@ -7,14 +7,30 @@ #include "FeatureNode.h" #include "ui_FeatureModelEditor.h" #include "vara/Feature/FeatureModel.h" -FeatureModelEditor::FeatureModelEditor(QWidget *Parent) : QMainWindow(Parent), Ui(new Ui::FeatureModelEditor) { - auto Model = vara::feature::loadFeatureModel("/home/simon/Workspace/vara-feature/tools/fm-editor/test_children.xml"); + +FeatureModelEditor::FeatureModelEditor(QWidget *Parent) + : QMainWindow(Parent), Ui(new Ui::FeatureModelEditor) { + Ui->setupUi(this); - auto * featureModelGraph= new FeatureModelGraph(std::move(Model),Ui->centralwidget); - Ui->featureGraph = featureModelGraph; + QObject::connect(Ui->loadModel, &QPushButton::pressed, this, + &FeatureModelEditor::loadGraph); +} +void FeatureModelEditor::loadFeature(vara::feature::Feature *Feature) { + auto FeatureString = + "Name: " + Feature->getName().str() + "\nOptional: " + (Feature->isOptional() + ? "True" + : "False"); + Ui->featureInfo->setText(QString::fromStdString(FeatureString)); +} +void FeatureModelEditor::loadGraph() { + auto Path = Ui->ModelFile->text().toStdString(); + auto Model = vara::feature::loadFeatureModel(Path); + auto *Graph = new FeatureModelGraph{std::move(Model), Ui->centralwidget}; + Ui->featureGraph = Graph; Ui->featureGraph->setObjectName(QString::fromUtf8("featureGraph")); - Ui->gridLayout->addWidget(Ui->featureGraph, 0, 0, 2, 1); - for(auto * Node:featureModelGraph->getNodes()) { - QObject::connect(Node,&FeatureNode::clicked, this, &FeatureModelEditor::loadFeature); + Ui->gridLayout_3->addWidget(Ui->featureGraph, 1, 2, 1, 1); + for (auto *Node : Graph->getNodes()) { + QObject::connect(Node, &FeatureNode::clicked, this, + &FeatureModelEditor::loadFeature); } } diff --git a/tools/fm-editor/FeatureModelEditor.h b/tools/fm-editor/FeatureModelEditor.h index 916b02e25..e66bf23fb 100644 --- a/tools/fm-editor/FeatureModelEditor.h +++ b/tools/fm-editor/FeatureModelEditor.h @@ -17,8 +17,9 @@ class FeatureModelEditor : public QMainWindow { ~FeatureModelEditor() override = default; private: Ui::FeatureModelEditor *Ui; -private slots: - void loadFeature(vara::feature::Feature &Feature); +public slots: + void loadFeature(vara::feature::Feature *Feature); + void loadGraph(); }; #endif // VARA_FEATURE_FEATUREMODELEDITOR_H diff --git a/tools/fm-editor/FeatureModelEditor.ui b/tools/fm-editor/FeatureModelEditor.ui index 91a0d3bd5..467c8aaa3 100644 --- a/tools/fm-editor/FeatureModelEditor.ui +++ b/tools/fm-editor/FeatureModelEditor.ui @@ -6,8 +6,8 @@ 0 0 - 800 - 600 + 915 + 896 @@ -15,11 +15,14 @@ - - - - + + + + 16777215 + 50 + + QFrame::StyledPanel @@ -27,6 +30,9 @@ QFrame::Raised + + + @@ -34,14 +40,55 @@ - - - - - + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + 0 + 100 + + + + + 16777215 + 100 + + + + + + + + + 0 + 400 + + + + + 16777215 + 16777215 + + + + + + @@ -50,8 +97,8 @@ 0 0 - 800 - 30 + 915 + 22 diff --git a/tools/fm-editor/FeatureNode.cpp b/tools/fm-editor/FeatureNode.cpp index b3a19865c..c9839b9cb 100644 --- a/tools/fm-editor/FeatureNode.cpp +++ b/tools/fm-editor/FeatureNode.cpp @@ -100,6 +100,7 @@ QVariant FeatureNode::itemChange(QGraphicsItem::GraphicsItemChange Change, void FeatureNode::mousePressEvent(QGraphicsSceneMouseEvent *Event) { update(); QGraphicsItem::mousePressEvent(Event); + emit clicked(Feature); } void FeatureNode::mouseReleaseEvent(QGraphicsSceneMouseEvent *Event) { diff --git a/tools/fm-editor/FeatureNode.h b/tools/fm-editor/FeatureNode.h index df3e2c541..8f82e8726 100644 --- a/tools/fm-editor/FeatureNode.h +++ b/tools/fm-editor/FeatureNode.h @@ -5,10 +5,10 @@ #include "vara/Feature/Feature.h" #include #include - +#include class FeatureEdge; class FeatureModelGraph; -class FeatureNode : public QGraphicsItem { +class FeatureNode : public QObject,public QGraphicsItem{ Q_OBJECT public: FeatureNode(FeatureModelGraph *Graph, vara::feature::Feature *Feature); @@ -27,7 +27,7 @@ class FeatureNode : public QGraphicsItem { [[nodiscard]] QPainterPath shape() const override; void paint(QPainter *Painter, const QStyleOptionGraphicsItem *Option, QWidget *Widget) override; signals: - void clicked(vara::feature::Feature &Feature); + void clicked(vara::feature::Feature *Feature); protected: QVariant itemChange(GraphicsItemChange Change, const QVariant &Value) override; @@ -35,7 +35,7 @@ class FeatureNode : public QGraphicsItem { void mouseReleaseEvent(QGraphicsSceneMouseEvent *Event) override; private: - int width() const; + [[nodiscard]] int width() const; std::vector ChildEdges; FeatureEdge * ParentEdge = nullptr; QPointF NewPos; From 2cd9b06a0e9cf388159fbfe911e67d5ce1cbb9ff Mon Sep 17 00:00:00 2001 From: Nerum Date: Tue, 20 Dec 2022 09:51:39 +0100 Subject: [PATCH 006/106] add Feature Add Dialog --- tools/fm-editor/CMakeLists.txt | 13 +-- tools/fm-editor/FeatureAddDialog.cpp | 26 ++++++ tools/fm-editor/FeatureAddDialog.h | 24 ++++++ tools/fm-editor/FeatureAddDialog.ui | 84 +++++++++++++++++++ tools/fm-editor/FeatureModelEditor.cpp | 30 +++++-- tools/fm-editor/FeatureModelEditor.h | 11 +++ tools/fm-editor/FeatureModelEditor.ui | 14 +++- tools/fm-editor/{ => graph}/FeatureEdge.cpp | 16 ++-- tools/fm-editor/{ => graph}/FeatureEdge.h | 0 .../{ => graph}/FeatureModelGraph.cpp | 48 +++++++++-- .../fm-editor/{ => graph}/FeatureModelGraph.h | 12 +-- tools/fm-editor/{ => graph}/FeatureNode.cpp | 18 +--- tools/fm-editor/{ => graph}/FeatureNode.h | 7 +- tools/fm-editor/main.cpp | 2 +- unittests/Feature/FeatureModelTransaction.cpp | 12 ++- 15 files changed, 256 insertions(+), 61 deletions(-) create mode 100644 tools/fm-editor/FeatureAddDialog.cpp create mode 100644 tools/fm-editor/FeatureAddDialog.h create mode 100644 tools/fm-editor/FeatureAddDialog.ui rename tools/fm-editor/{ => graph}/FeatureEdge.cpp (70%) rename tools/fm-editor/{ => graph}/FeatureEdge.h (100%) rename tools/fm-editor/{ => graph}/FeatureModelGraph.cpp (70%) rename tools/fm-editor/{ => graph}/FeatureModelGraph.h (75%) rename tools/fm-editor/{ => graph}/FeatureNode.cpp (88%) rename tools/fm-editor/{ => graph}/FeatureNode.h (85%) diff --git a/tools/fm-editor/CMakeLists.txt b/tools/fm-editor/CMakeLists.txt index 51405d018..ef2305710 100644 --- a/tools/fm-editor/CMakeLists.txt +++ b/tools/fm-editor/CMakeLists.txt @@ -7,14 +7,15 @@ set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) add_vara_executable(fm-editor main.cpp - FeatureModelGraph.h - FeatureModelGraph.cpp - FeatureNode.h - FeatureNode.cpp - FeatureEdge.h - FeatureEdge.cpp + graph/FeatureModelGraph.h + graph/FeatureModelGraph.cpp + graph/FeatureNode.h + graph/FeatureNode.cpp + graph/FeatureEdge.h + graph/FeatureEdge.cpp FeatureModelEditor.h FeatureModelEditor.cpp FeatureModelEditor.ui + FeatureAddDialog.h FeatureAddDialog.cpp FeatureAddDialog.ui ) target_link_libraries(fm-editor diff --git a/tools/fm-editor/FeatureAddDialog.cpp b/tools/fm-editor/FeatureAddDialog.cpp new file mode 100644 index 000000000..2c1d50ffa --- /dev/null +++ b/tools/fm-editor/FeatureAddDialog.cpp @@ -0,0 +1,26 @@ +// +// Created by simon on 29.11.22. +// + +#include "FeatureAddDialog.h" +#include "graph/FeatureModelGraph.h" +#include "graph/FeatureNode.h" +using vara::feature::FeatureModel; +FeatureAddDialog::FeatureAddDialog(FeatureModelGraph *Graph, QWidget *Parent) + : QDialog(Parent), Graph(Graph){ + setupUi(this); + NodeNames = QStringList(); + for(const auto &Node: *Graph->getNodes()){ + NodeNames.push_back(Node->getQName()); + } + const auto ConstNodeNames = NodeNames; + this->Nodes->addItems(ConstNodeNames); +} + +QString FeatureAddDialog::getName() { + return name->text(); +} + +std::string FeatureAddDialog::getParent(){ + return Nodes->currentText().toStdString(); +} diff --git a/tools/fm-editor/FeatureAddDialog.h b/tools/fm-editor/FeatureAddDialog.h new file mode 100644 index 000000000..930ec3067 --- /dev/null +++ b/tools/fm-editor/FeatureAddDialog.h @@ -0,0 +1,24 @@ +// +// Created by simon on 29.11.22. +// + +#ifndef VARA_FEATURE_FEATUREADDDIALOG_H +#define VARA_FEATURE_FEATUREADDDIALOG_H +#include "graph/FeatureModelGraph.h" +#include "ui_FeatureAddDialog.h" +#include +#include + +class FeatureAddDialog : public QDialog, public Ui::Add { + Q_OBJECT +public: + FeatureAddDialog(FeatureModelGraph *Graph, QWidget *Parent); + QString getName(); + string getParent(); +private: + FeatureModelGraph *Graph; + QStringList NodeNames; + +}; + +#endif // VARA_FEATURE_FEATUREADDDIALOG_H diff --git a/tools/fm-editor/FeatureAddDialog.ui b/tools/fm-editor/FeatureAddDialog.ui new file mode 100644 index 000000000..a2b79b46a --- /dev/null +++ b/tools/fm-editor/FeatureAddDialog.ui @@ -0,0 +1,84 @@ + + + Add + + + + 0 + 0 + 400 + 300 + + + + Dialog + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + Name + + + + + + + Parent + + + + + + + + + + + + buttonBox + accepted() + Add + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + Add + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/tools/fm-editor/FeatureModelEditor.cpp b/tools/fm-editor/FeatureModelEditor.cpp index 516ee64ce..262ad3ed8 100644 --- a/tools/fm-editor/FeatureModelEditor.cpp +++ b/tools/fm-editor/FeatureModelEditor.cpp @@ -3,10 +3,16 @@ // #include "FeatureModelEditor.h" -#include "FeatureModelGraph.h" -#include "FeatureNode.h" +#include "FeatureAddDialog.h" +#include "graph/FeatureModelGraph.h" +#include "graph/FeatureNode.h" #include "ui_FeatureModelEditor.h" #include "vara/Feature/FeatureModel.h" +#include "vara/Feature/FeatureModelTransaction.h" + +using vara::feature::FeatureModel; +using Transaction = vara::feature::FeatureModelTransaction; +using vara::feature::Feature; FeatureModelEditor::FeatureModelEditor(QWidget *Parent) : QMainWindow(Parent), Ui(new Ui::FeatureModelEditor) { @@ -14,23 +20,33 @@ FeatureModelEditor::FeatureModelEditor(QWidget *Parent) Ui->setupUi(this); QObject::connect(Ui->loadModel, &QPushButton::pressed, this, &FeatureModelEditor::loadGraph); + QObject::connect(Ui->actionAddFeature,&QAction::triggered, this, + &FeatureModelEditor::featureAddDialog); + } void FeatureModelEditor::loadFeature(vara::feature::Feature *Feature) { auto FeatureString = "Name: " + Feature->getName().str() + "\nOptional: " + (Feature->isOptional() ? "True" - : "False"); + : "False") + "\nSource:"; Ui->featureInfo->setText(QString::fromStdString(FeatureString)); } void FeatureModelEditor::loadGraph() { auto Path = Ui->ModelFile->text().toStdString(); - auto Model = vara::feature::loadFeatureModel(Path); - auto *Graph = new FeatureModelGraph{std::move(Model), Ui->centralwidget}; + Model = vara::feature::loadFeatureModel(Path); + Graph = new FeatureModelGraph{Model.get(), Ui->centralwidget}; Ui->featureGraph = Graph; Ui->featureGraph->setObjectName(QString::fromUtf8("featureGraph")); Ui->gridLayout_3->addWidget(Ui->featureGraph, 1, 2, 1, 1); - for (auto *Node : Graph->getNodes()) { - QObject::connect(Node, &FeatureNode::clicked, this, + for (auto &Node : *Graph->getNodes()) { + QObject::connect(Node.get(), &FeatureNode::clicked, this, &FeatureModelEditor::loadFeature); } } +void FeatureModelEditor::featureAddDialog() { + FeatureAddDialog AddDialog(Graph,this); + if(AddDialog.exec() == QDialog::Accepted){ + Graph->addFeature(AddDialog.getName(),Graph->getNode(AddDialog.getParent())); + } +} + diff --git a/tools/fm-editor/FeatureModelEditor.h b/tools/fm-editor/FeatureModelEditor.h index e66bf23fb..1b57d7a97 100644 --- a/tools/fm-editor/FeatureModelEditor.h +++ b/tools/fm-editor/FeatureModelEditor.h @@ -2,7 +2,11 @@ #ifndef VARA_FEATURE_FEATUREMODELEDITOR_H #define VARA_FEATURE_FEATUREMODELEDITOR_H +#include "graph/FeatureModelGraph.h" #include "vara/Feature/Feature.h" +#include "vara/Feature/FeatureModel.h" +#include "vara/Feature/FeatureModelTransaction.h" +#include #include QT_BEGIN_NAMESPACE namespace Ui { @@ -15,11 +19,18 @@ class FeatureModelEditor : public QMainWindow { public: explicit FeatureModelEditor(QWidget *Parent = nullptr); ~FeatureModelEditor() override = default; + private: Ui::FeatureModelEditor *Ui; + FeatureModelGraph * Graph{}; + std::unique_ptr Model {}; + std::unique_ptr> Modification {}; public slots: void loadFeature(vara::feature::Feature *Feature); void loadGraph(); + void featureAddDialog(); + //void addFeature(const QString& Name, FeatureNode *Parent); + }; #endif // VARA_FEATURE_FEATUREMODELEDITOR_H diff --git a/tools/fm-editor/FeatureModelEditor.ui b/tools/fm-editor/FeatureModelEditor.ui index 467c8aaa3..724b3058c 100644 --- a/tools/fm-editor/FeatureModelEditor.ui +++ b/tools/fm-editor/FeatureModelEditor.ui @@ -98,11 +98,23 @@ 0 0 915 - 22 + 30 + + + Edit + + + + + + + AddFeature + + diff --git a/tools/fm-editor/FeatureEdge.cpp b/tools/fm-editor/graph/FeatureEdge.cpp similarity index 70% rename from tools/fm-editor/FeatureEdge.cpp rename to tools/fm-editor/graph/FeatureEdge.cpp index 9f931bd15..39569df1b 100644 --- a/tools/fm-editor/FeatureEdge.cpp +++ b/tools/fm-editor/graph/FeatureEdge.cpp @@ -22,15 +22,15 @@ void FeatureEdge::adjust() { return; } - QLineF Line(mapFromItem(Source, 0, 0), mapFromItem(Target, 0, 0)); + QLineF Line(mapFromItem(Source, 0, 10), mapFromItem(Target, 0, -10)); qreal Length = Line.length(); prepareGeometryChange(); if (Length > qreal(20.)) { QPointF EdgeOffset((Line.dx() * 10) / Length, (Line.dy() * 10) / Length); - SourcePoint = Line.p1() + EdgeOffset; - TargetPoint = Line.p2() - EdgeOffset; + SourcePoint = Line.p1(); + TargetPoint = Line.p2(); } else { SourcePoint = TargetPoint = Line.p1(); } @@ -62,12 +62,6 @@ void FeatureEdge::paint(QPainter *Painter, Painter->setPen(QPen(Qt::black, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); Painter->drawLine(Line); - double Angle = std::atan2(-Line.dy(), Line.dx()); - QPointF DestArrowP1 = TargetPoint + QPointF(sin(Angle - M_PI / 3) * ArrowSize, - cos(Angle - M_PI / 3) * ArrowSize); - QPointF DestArrowP2 = TargetPoint + QPointF(sin(Angle - M_PI + M_PI / 3) * ArrowSize, - cos(Angle - M_PI + M_PI / 3) * ArrowSize); - - Painter->setBrush(Qt::black); - Painter->drawPolygon(QPolygonF() << Line.p2() << DestArrowP1 << DestArrowP2); + Painter->setBrush(QBrush(Target->isOptional()?Qt::white:Qt::black)); + Painter->drawEllipse(TargetPoint,4,4); } diff --git a/tools/fm-editor/FeatureEdge.h b/tools/fm-editor/graph/FeatureEdge.h similarity index 100% rename from tools/fm-editor/FeatureEdge.h rename to tools/fm-editor/graph/FeatureEdge.h diff --git a/tools/fm-editor/FeatureModelGraph.cpp b/tools/fm-editor/graph/FeatureModelGraph.cpp similarity index 70% rename from tools/fm-editor/FeatureModelGraph.cpp rename to tools/fm-editor/graph/FeatureModelGraph.cpp index 381089967..6d9f1650e 100644 --- a/tools/fm-editor/FeatureModelGraph.cpp +++ b/tools/fm-editor/graph/FeatureModelGraph.cpp @@ -7,14 +7,14 @@ #include "FeatureNode.h" #include "vara/Feature/Feature.h" #include "vara/Feature/FeatureModel.h" - +#include "vara/Feature/FeatureModelTransaction.h" #include #include #include -FeatureModelGraph::FeatureModelGraph(std::unique_ptr FeatureModel, +FeatureModelGraph::FeatureModelGraph(vara::feature::FeatureModel * FeatureModel, QWidget *Parent) - : QGraphicsView(Parent), EntryNode(new FeatureNode(this, FeatureModel->getRoot())), FeatureModel(std::move(FeatureModel)) { + : QGraphicsView(Parent), EntryNode(new FeatureNode(this, FeatureModel->getRoot())), FeatureModel(FeatureModel) { auto *Scene = new QGraphicsScene(this); Scene->setItemIndexMethod(QGraphicsScene::NoIndex); Scene->setSceneRect(0, 0, 600, 600); @@ -25,7 +25,13 @@ FeatureModelGraph::FeatureModelGraph(std::unique_ptr(EntryNode)); + auto *Scene = this->scene(); + Scene->clear(); Scene->addItem(EntryNode); buildRec(EntryNode); auto NextChildren =std::vector(EntryNode->children().size()); @@ -39,12 +45,12 @@ void FeatureModelGraph::buildRec(FeatureNode *CurrentFeatureNode) { for (auto *Feature : CurrentFeatureNode->getFeature()->getChildren( 1)) { - auto *Node = new FeatureNode(this, Feature); - auto *Edge = new FeatureEdge(CurrentFeatureNode, Node); - Nodes.insert(Node); + auto Node = std::make_unique(this, Feature); + auto *Edge = new FeatureEdge(CurrentFeatureNode, Node.get()); scene()->addItem(Edge); - scene()->addItem(Node); - buildRec(Node); + scene()->addItem(Node.get()); + buildRec(Node.get()); + Nodes.push_back(std::move(Node)); } } @@ -135,3 +141,27 @@ void FeatureModelGraph::scaleView(qreal ScaleFactor) { } void FeatureModelGraph::zoomIn() { scaleView(qreal(1.2)); } void FeatureModelGraph::zoomOut() { scaleView(1 / qreal(1.2)); } +void FeatureModelGraph::addFeature(const QString& Name, FeatureNode* Parent) { + auto Transaction = vara::feature::FeatureModelTransaction::openTransaction(*FeatureModel); + auto NewFeature = std::make_unique(Name.toStdString()); + auto NewNode = std::make_unique(this,NewFeature.get()); + Transaction.addFeature(std::move(NewFeature),FeatureModel->getFeature(Parent->getName())); + Transaction.commit(); + auto * NewEdge = new FeatureEdge(Parent,NewNode.get()); + scene()->addItem(NewEdge); + scene()->addItem(NewNode.get()); + Nodes.push_back(std::move(NewNode)); + auto NextChildren =std::vector(EntryNode->children().size()); + auto CurrentChildren = EntryNode->children(); + std::transform(CurrentChildren.begin(),CurrentChildren.end(),NextChildren.begin(),[](FeatureEdge* Edge){return Edge->targetNode();}); + positionRec(1,NextChildren,WIDTH-10,0); + EntryNode->setPos(WIDTH/2,10); +} +FeatureNode* FeatureModelGraph::getNode(std::string Name) { + auto It = std::find_if(Nodes.begin(),Nodes.end(),[&Name](auto const &Node){return Node->getName() == Name;}); + if (It != Nodes.end()) { + return It->get(); + } + return nullptr; + +} diff --git a/tools/fm-editor/FeatureModelGraph.h b/tools/fm-editor/graph/FeatureModelGraph.h similarity index 75% rename from tools/fm-editor/FeatureModelGraph.h rename to tools/fm-editor/graph/FeatureModelGraph.h index 34cff83c2..f4f623753 100644 --- a/tools/fm-editor/FeatureModelGraph.h +++ b/tools/fm-editor/graph/FeatureModelGraph.h @@ -10,11 +10,12 @@ class FeatureModelGraph : public QGraphicsView { Q_OBJECT public: - FeatureModelGraph(std::unique_ptr FeatureModel, + FeatureModelGraph(vara::feature::FeatureModel * FeatureModel, QWidget *Parent = nullptr); - std::set getNodes() {return Nodes;}; + auto getNodes() {return &Nodes;}; void itemMoved(); - + FeatureNode* getNode(std::string Name); + void addFeature(const QString& Name,FeatureNode* Parent); public slots: void zoomIn(); void zoomOut(); @@ -28,6 +29,7 @@ public slots: void scaleView(qreal ScaleFactor); private: + void reload(); void buildRec(FeatureNode *CurrentFeatureNode); int TimerId = 0; FeatureNode* EntryNode; @@ -35,8 +37,8 @@ public slots: unsigned long Width, unsigned long Offset); const int HEIGHT = 600; const int WIDTH = 600; - std::unique_ptr FeatureModel; - std::set Nodes; + vara::feature::FeatureModel* FeatureModel; + std::vector> Nodes; }; #endif // VARA_FEATURE_FEATUREMODELGRAPH_H diff --git a/tools/fm-editor/FeatureNode.cpp b/tools/fm-editor/graph/FeatureNode.cpp similarity index 88% rename from tools/fm-editor/FeatureNode.cpp rename to tools/fm-editor/graph/FeatureNode.cpp index c9839b9cb..9471687ec 100644 --- a/tools/fm-editor/FeatureNode.cpp +++ b/tools/fm-editor/graph/FeatureNode.cpp @@ -35,20 +35,6 @@ FeatureEdge * FeatureNode::parent() const { return ParentEdge; } -void FeatureNode::calculateForces() { - if (!scene() || scene()->mouseGrabberItem() == this) { - NewPos = pos(); - return; - } -} -bool FeatureNode::advancePosition() { - if (NewPos == pos()) { - return false; -} - - setPos(NewPos); - return true; -} QRectF FeatureNode::boundingRect() const { qreal Adjust = 2; int W = width(); @@ -61,10 +47,11 @@ QPainterPath FeatureNode::shape() const { Path.addRect(-W / 2, -10, W, 20); return Path; } + void FeatureNode::paint(QPainter *Painter, const QStyleOptionGraphicsItem *Option, QWidget *Widget) { - const auto Name = QString::fromStdString(Feature->getName().str()); + const auto Name = getQName(); QBrush Brush(Qt::darkYellow); if (Option->state & QStyle::State_Sunken) { Brush.setColor(QColor(Qt::yellow).lighter(120)); @@ -78,6 +65,7 @@ void FeatureNode::paint(QPainter *Painter, Painter->setPen(QPen(Qt::black, 1)); Painter->drawText(-W/2+5, 5, Name); } + QVariant FeatureNode::itemChange(QGraphicsItem::GraphicsItemChange Change, const QVariant &Value) { switch (Change) { diff --git a/tools/fm-editor/FeatureNode.h b/tools/fm-editor/graph/FeatureNode.h similarity index 85% rename from tools/fm-editor/FeatureNode.h rename to tools/fm-editor/graph/FeatureNode.h index 8f82e8726..8796d7f6d 100644 --- a/tools/fm-editor/FeatureNode.h +++ b/tools/fm-editor/graph/FeatureNode.h @@ -20,12 +20,15 @@ class FeatureNode : public QObject,public QGraphicsItem{ enum { Type = UserType + 1 }; [[nodiscard]] int type() const override { return Type; } - void calculateForces(); - bool advancePosition(); vara::feature::Feature* getFeature(){return Feature;}; [[nodiscard]] QRectF boundingRect() const override; [[nodiscard]] QPainterPath shape() const override; void paint(QPainter *Painter, const QStyleOptionGraphicsItem *Option, QWidget *Widget) override; + bool isOptional() {return Feature->isOptional();} + [[nodiscard]] QString getQName() const { + return QString::fromStdString(Feature->getName().str()); + }; + [[nodiscard]] std::string getName() const {return Feature->getName().str();}; signals: void clicked(vara::feature::Feature *Feature); protected: diff --git a/tools/fm-editor/main.cpp b/tools/fm-editor/main.cpp index 8d5681e7a..788bb8974 100644 --- a/tools/fm-editor/main.cpp +++ b/tools/fm-editor/main.cpp @@ -3,7 +3,7 @@ // #include "FeatureModelEditor.h" -#include "FeatureModelGraph.h" +#include "graph/FeatureModelGraph.h" #include "vara/Feature/FeatureModel.h" #include diff --git a/unittests/Feature/FeatureModelTransaction.cpp b/unittests/Feature/FeatureModelTransaction.cpp index a25220175..f9490f2af 100644 --- a/unittests/Feature/FeatureModelTransaction.cpp +++ b/unittests/Feature/FeatureModelTransaction.cpp @@ -104,7 +104,8 @@ TEST_F(FeatureModelTransactionCopyTest, addFeatureToModel) { size_t FMSizeBefore = FM->size(); auto FT = FeatureModelCopyTransaction::openTransaction(*FM); - FT.addFeature(std::make_unique("ab"), FM->getFeature("a")); + FT.featureAddDialog(std::make_unique("ab"), + FM->getFeature("a")); EXPECT_EQ(FMSizeBefore, FM->size()); EXPECT_TRUE(FM->getFeature("a")); @@ -133,7 +134,8 @@ TEST_F(FeatureModelTransactionCopyTest, addFeatureToModelThenAbort) { size_t FMSizeBefore = FM->size(); auto FT = FeatureModelCopyTransaction::openTransaction(*FM); - FT.addFeature(std::make_unique("ab"), FM->getFeature("a")); + FT.featureAddDialog(std::make_unique("ab"), + FM->getFeature("a")); EXPECT_EQ(FMSizeBefore, FM->size()); EXPECT_TRUE(FM->getFeature("a")); @@ -187,7 +189,8 @@ TEST_F(FeatureModelTransactionModifyTest, addFeatureToModel) { size_t FMSizeBefore = FM->size(); auto FT = FeatureModelModifyTransaction::openTransaction(*FM); - FT.addFeature(std::make_unique("ab"), FM->getFeature("a")); + FT.featureAddDialog(std::make_unique("ab"), + FM->getFeature("a")); EXPECT_EQ(FMSizeBefore, FM->size()); EXPECT_TRUE(FM->getFeature("a")); @@ -207,7 +210,8 @@ TEST_F(FeatureModelTransactionModifyTest, addFeatureToModelThenAboard) { size_t FMSizeBefore = FM->size(); auto FT = FeatureModelModifyTransaction::openTransaction(*FM); - FT.addFeature(std::make_unique("ab"), FM->getFeature("a")); + FT.featureAddDialog(std::make_unique("ab"), + FM->getFeature("a")); EXPECT_EQ(FMSizeBefore, FM->size()); EXPECT_TRUE(FM->getFeature("a")); From 9aa6a9e8074204d16ee6e477a87b0bba0c9a194e Mon Sep 17 00:00:00 2001 From: Nerum Date: Mon, 9 Jan 2023 09:56:12 +0100 Subject: [PATCH 007/106] add syntax highlighting and feature source highlighting --- tools/fm-editor/CMakeLists.txt | 4 +- tools/fm-editor/FeatureAddDialog.ui | 27 +- tools/fm-editor/FeatureModelEditor.cpp | 79 +- tools/fm-editor/FeatureModelEditor.h | 6 +- tools/fm-editor/FeatureModelEditor.ui | 104 +- .../fileview/syntaxHighlite/languagedata.cpp | 6324 +++++++++++++++++ .../fileview/syntaxHighlite/languagedata.h | 222 + .../syntaxHighlite/qsourcehighliter.cpp | 940 +++ .../syntaxHighlite/qsourcehighliter.h | 169 + .../syntaxHighlite/qsourcehighliterthemes.cpp | 72 + .../syntaxHighlite/qsourcehighliterthemes.h | 38 + tools/fm-editor/graph/FeatureModelGraph.cpp | 8 +- tools/fm-editor/graph/FeatureModelGraph.h | 2 +- tools/fm-editor/graph/FeatureNode.cpp | 13 +- tools/fm-editor/graph/FeatureNode.h | 5 +- 15 files changed, 7959 insertions(+), 54 deletions(-) create mode 100644 tools/fm-editor/fileview/syntaxHighlite/languagedata.cpp create mode 100644 tools/fm-editor/fileview/syntaxHighlite/languagedata.h create mode 100644 tools/fm-editor/fileview/syntaxHighlite/qsourcehighliter.cpp create mode 100644 tools/fm-editor/fileview/syntaxHighlite/qsourcehighliter.h create mode 100644 tools/fm-editor/fileview/syntaxHighlite/qsourcehighliterthemes.cpp create mode 100644 tools/fm-editor/fileview/syntaxHighlite/qsourcehighliterthemes.h diff --git a/tools/fm-editor/CMakeLists.txt b/tools/fm-editor/CMakeLists.txt index ef2305710..4f664a9eb 100644 --- a/tools/fm-editor/CMakeLists.txt +++ b/tools/fm-editor/CMakeLists.txt @@ -16,8 +16,10 @@ add_vara_executable(fm-editor FeatureModelEditor.h FeatureModelEditor.cpp FeatureModelEditor.ui FeatureAddDialog.h FeatureAddDialog.cpp FeatureAddDialog.ui + fileview/syntaxHighlite/qsourcehighliter.h fileview/syntaxHighlite/qsourcehighliter.cpp + fileview/syntaxHighlite/languagedata.h fileview/syntaxHighlite/languagedata.cpp + fileview/syntaxHighlite/qsourcehighliterthemes.h fileview/syntaxHighlite/qsourcehighliterthemes.cpp ) - target_link_libraries(fm-editor LINK_PRIVATE VaRAFeature diff --git a/tools/fm-editor/FeatureAddDialog.ui b/tools/fm-editor/FeatureAddDialog.ui index a2b79b46a..8d0592096 100644 --- a/tools/fm-editor/FeatureAddDialog.ui +++ b/tools/fm-editor/FeatureAddDialog.ui @@ -17,7 +17,17 @@ - + + + + + + + Name + + + + Qt::Horizontal @@ -27,14 +37,7 @@ - - - - Name - - - - + Parent @@ -42,7 +45,11 @@ - + + + Optional + + diff --git a/tools/fm-editor/FeatureModelEditor.cpp b/tools/fm-editor/FeatureModelEditor.cpp index 262ad3ed8..2c620b12d 100644 --- a/tools/fm-editor/FeatureModelEditor.cpp +++ b/tools/fm-editor/FeatureModelEditor.cpp @@ -4,12 +4,15 @@ #include "FeatureModelEditor.h" #include "FeatureAddDialog.h" +#include "fileview/syntaxHighlite/qsourcehighliter.h" #include "graph/FeatureModelGraph.h" #include "graph/FeatureNode.h" #include "ui_FeatureModelEditor.h" #include "vara/Feature/FeatureModel.h" #include "vara/Feature/FeatureModelTransaction.h" - +#include +#include +namespace fs = std::filesystem; using vara::feature::FeatureModel; using Transaction = vara::feature::FeatureModelTransaction; using vara::feature::Feature; @@ -18,22 +21,31 @@ FeatureModelEditor::FeatureModelEditor(QWidget *Parent) : QMainWindow(Parent), Ui(new Ui::FeatureModelEditor) { Ui->setupUi(this); + auto *Highliter = new QSourceHighlite::QSourceHighliter(Ui->textEdit->document()); + Highliter->setCurrentLanguage(QSourceHighlite::QSourceHighliter::CodeCpp); QObject::connect(Ui->loadModel, &QPushButton::pressed, this, &FeatureModelEditor::loadGraph); + QObject::connect(Ui->findModel, &QPushButton::pressed, this, + &FeatureModelEditor::findModel); QObject::connect(Ui->actionAddFeature,&QAction::triggered, this, &FeatureModelEditor::featureAddDialog); } void FeatureModelEditor::loadFeature(vara::feature::Feature *Feature) { auto FeatureString = - "Name: " + Feature->getName().str() + "\nOptional: " + (Feature->isOptional() - ? "True" - : "False") + "\nSource:"; + Feature->toString(); Ui->featureInfo->setText(QString::fromStdString(FeatureString)); } void FeatureModelEditor::loadGraph() { + if(!Repository.isEmpty()){ + Repository.clear(); + } auto Path = Ui->ModelFile->text().toStdString(); Model = vara::feature::loadFeatureModel(Path); + if(!Model){ + //Return if no model at Path + return; + } Graph = new FeatureModelGraph{Model.get(), Ui->centralwidget}; Ui->featureGraph = Graph; Ui->featureGraph->setObjectName(QString::fromUtf8("featureGraph")); @@ -41,12 +53,69 @@ void FeatureModelEditor::loadGraph() { for (auto &Node : *Graph->getNodes()) { QObject::connect(Node.get(), &FeatureNode::clicked, this, &FeatureModelEditor::loadFeature); + QObject::connect(Node.get(), &FeatureNode::inspectSource, this, + &FeatureModelEditor::inspectFeature); } } void FeatureModelEditor::featureAddDialog() { FeatureAddDialog AddDialog(Graph,this); if(AddDialog.exec() == QDialog::Accepted){ - Graph->addFeature(AddDialog.getName(),Graph->getNode(AddDialog.getParent())); + auto *NewNode = Graph->addFeature(AddDialog.getName(),Graph->getNode(AddDialog.getParent())); + QObject::connect(NewNode, &FeatureNode::clicked, this, + &FeatureModelEditor::loadFeature); + QObject::connect(NewNode, &FeatureNode::inspectSource, this, + &FeatureModelEditor::inspectFeature); } } +void FeatureModelEditor::findModel() { + QString const Path = QFileDialog::getOpenFileName(this,tr("Open Model"),"/home",tr("XML files (*.xml)")); + Ui->ModelFile->setText(Path); +} +void FeatureModelEditor::inspectFeature(vara::feature::Feature *Feature) { + CurrentFeature = Feature; + if(Repository.isEmpty()){ + Repository = QFileDialog::getExistingDirectory(); + } + Ui->sources->clear(); + for(const auto& Source : Feature->getLocations()){ + Ui->sources->addItem(QString::fromStdString(Source.getPath().string())); + } + connect(Ui->sources,&QComboBox::textActivated, this,&FeatureModelEditor::loadSource); +} +void FeatureModelEditor::loadSource(const QString &RelativePath){ + auto SourcePath = Repository.append("/").append(RelativePath); + std::cout << Repository.toStdString(); + QFile File(SourcePath); + if(File.exists()){ + File.open(QFile::ReadOnly | QFile::Text); + QTextStream ReadFile(&File); + Ui->textEdit->setText(ReadFile.readAll()); + QTextCharFormat Fmt; + Fmt.setBackground(Qt::yellow); + QTextCursor Cursor(Ui->textEdit->document()); + std::cout << CurrentFeature->toString(); + std::vector Locations{}; + std::copy_if(CurrentFeature->getLocationsBegin(),CurrentFeature->getLocationsEnd(),std::back_inserter(Locations),[&RelativePath](auto const& Loc){return RelativePath.toStdString()==Loc.getPath();}); + for (auto &Location:Locations) { + Cursor.movePosition(QTextCursor::MoveOperation::Start,QTextCursor::MoveMode::MoveAnchor); + Cursor.movePosition(QTextCursor::MoveOperation::Down, + QTextCursor::MoveMode::MoveAnchor, + Location.getStart()->getLineNumber() - 1); + Cursor.movePosition(QTextCursor::MoveOperation::NextCharacter, + QTextCursor::MoveMode::MoveAnchor, + Location.getStart()->getColumnOffset()-1); + Cursor.movePosition(QTextCursor::MoveOperation::Down, + QTextCursor::MoveMode::KeepAnchor, + Location.getEnd()->getLineNumber() - + Location.getStart()->getLineNumber()); + Cursor.movePosition(QTextCursor::MoveOperation::StartOfLine, + QTextCursor::MoveMode::KeepAnchor); + Cursor.movePosition(QTextCursor::MoveOperation::NextCharacter, + QTextCursor::MoveMode::KeepAnchor, + Location.getEnd()->getColumnOffset()-1); + Cursor.setCharFormat(Fmt); + } + } + +} diff --git a/tools/fm-editor/FeatureModelEditor.h b/tools/fm-editor/FeatureModelEditor.h index 1b57d7a97..f57b88447 100644 --- a/tools/fm-editor/FeatureModelEditor.h +++ b/tools/fm-editor/FeatureModelEditor.h @@ -25,12 +25,16 @@ class FeatureModelEditor : public QMainWindow { FeatureModelGraph * Graph{}; std::unique_ptr Model {}; std::unique_ptr> Modification {}; + QString Repository {}; + vara::feature::Feature* CurrentFeature; public slots: void loadFeature(vara::feature::Feature *Feature); + void inspectFeature(vara::feature::Feature *Feature); void loadGraph(); void featureAddDialog(); //void addFeature(const QString& Name, FeatureNode *Parent); - + void loadSource(const QString &RelativePath); + void findModel(); }; #endif // VARA_FEATURE_FEATUREMODELEDITOR_H diff --git a/tools/fm-editor/FeatureModelEditor.ui b/tools/fm-editor/FeatureModelEditor.ui index 724b3058c..fbf6c09f3 100644 --- a/tools/fm-editor/FeatureModelEditor.ui +++ b/tools/fm-editor/FeatureModelEditor.ui @@ -15,38 +15,7 @@ - - - - - 16777215 - 50 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - - - - load - - - - - - - - - - + QFrame::StyledPanel @@ -69,6 +38,9 @@ 100 + + true + @@ -87,6 +59,72 @@ + + + + + 16777215 + 50 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + + + + Feature Model Path + + + true + + + + + + + Load + + + + + + + Find + + + + + + + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + @@ -98,7 +136,7 @@ 0 0 915 - 30 + 34 diff --git a/tools/fm-editor/fileview/syntaxHighlite/languagedata.cpp b/tools/fm-editor/fileview/syntaxHighlite/languagedata.cpp new file mode 100644 index 000000000..dc416f87f --- /dev/null +++ b/tools/fm-editor/fileview/syntaxHighlite/languagedata.cpp @@ -0,0 +1,6324 @@ +/* + * Copyright (c) 2019-2020 Waqar Ahmed -- + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include +#include +#include "languagedata.h" +/* ------------------------ + * TEMPLATE FOR LANG DATA + * ------------------------- + * + * loadXXXData, where XXX is the language + * keywords are the language keywords e.g, const + * types are built-in types i.e, int, char, var + * literals are words like, true false + * builtin are the library functions + * other can contain any other thing, for e.g, in cpp it contains the preprocessor + + xxx_keywords = { + }; + + xxx_types = { + }; + + xxx_literals = { + }; + + xxx_builtin = { + }; + + xxx_other = { + }; + +*/ + +namespace QSourceHighlite { + +/**********************************************************/ +/* LuaData ************************************************/ +/**********************************************************/ + +static bool luaDataInitialized = false; +static LanguageData lua_keywords; +static LanguageData lua_types; +static LanguageData lua_builtin; +static LanguageData lua_literals; +static LanguageData lua_other; +void initLuaData() { + lua_keywords = LanguageData{ + {('a'), QLatin1String("and")}, + {('b'), QLatin1String("break")}, + {('d'), QLatin1String("do")}, + {('e'), QLatin1String("else")}, + {('e'), QLatin1String("elseif")}, + {('e'), QLatin1String("end")}, + {('f'), QLatin1String("for")}, + {('f'), QLatin1String("function")}, + {('i'), QLatin1String("if")}, + {('i'), QLatin1String("in")}, + {('l'), QLatin1String("local")}, + {('n'), QLatin1String("not")}, + {('o'), QLatin1String("or")}, + {('r'), QLatin1String("repeat")}, + {('r'), QLatin1String("require")}, + {('r'), QLatin1String("return")}, + {('t'), QLatin1String("then")}, + {('u'), QLatin1String("until")}, + {('w'), QLatin1String("while")}}; + + lua_literals = LanguageData{ + {('f'), QLatin1String("false")}, + {('n'), QLatin1String("nil")}, + {('t'), QLatin1String("true")}}; + + lua_other = LanguageData{ + {('_'), QLatin1String("_G")}, + {('_'), QLatin1String("__add")}, + {('_'), QLatin1String("__call")}, + {('_'), QLatin1String("__contact")}, + {('_'), QLatin1String("__div")}, + {('_'), QLatin1String("__eq")}, + {('_'), QLatin1String("__index")}, + {('_'), QLatin1String("__le")}, + {('_'), QLatin1String("__lt")}, + {('_'), QLatin1String("__mod")}, + {('_'), QLatin1String("__mul")}, + {('_'), QLatin1String("__newindex")}, + {('_'), QLatin1String("__sub")}, + {('_'), QLatin1String("__tostring")}, + {('_'), QLatin1String("__unm")} + }; + + lua_builtin = LanguageData{ + {('d'), QLatin1String("debug")}, + {('d'), QLatin1String("dofile")}, + {('g'), QLatin1String("getfenv")}, + {('g'), QLatin1String("gethook")}, + {('g'), QLatin1String("getinfo")}, + {('g'), QLatin1String("getlocal")}, + {('g'), QLatin1String("getmetatable")}, + {('g'), QLatin1String("getregistry")}, + {('g'), QLatin1String("getupvalue")}, + {('i'), QLatin1String("ipairs")}, + {('l'), QLatin1String("load")}, + {('l'), QLatin1String("loadfile")}, + {('l'), QLatin1String("loadstring")}, + {('n'), QLatin1String("next")}, + {('p'), QLatin1String("pairs")}, + {('p'), QLatin1String("print")}, + {('r'), QLatin1String("rawequal")}, + {('r'), QLatin1String("rawget")}, + {('r'), QLatin1String("rawset")}, + {('s'), QLatin1String("select")}, + {('s'), QLatin1String("setfenv")}, + {('s'), QLatin1String("sethook")}, + {('s'), QLatin1String("setlocal")}, + {('s'), QLatin1String("setmetatable")}, + {('s'), QLatin1String("setupvalue")}, + {('t'), QLatin1String("tonumber")}, + {('t'), QLatin1String("tostring")}, + {('t'), QLatin1String("traceback")}, + {('t'), QLatin1String("type")}, + {('u'), QLatin1String("unpack")} + }; + +} + +void loadLuaData(LanguageData &typess, + LanguageData &keywordss, + LanguageData &builtins, + LanguageData &literalss, + LanguageData &others){ + if (!luaDataInitialized) { + initLuaData(); + luaDataInitialized = true; + } + typess = lua_types; + keywordss = lua_keywords; + builtins = lua_builtin; + literalss = lua_literals; + others = lua_other; +} + +/**********************************************************/ +/* C/C++ Data *********************************************/ +/**********************************************************/ + +static bool cppDataInitialized = false; +static LanguageData cpp_keywords; +static LanguageData cpp_types; +static LanguageData cpp_builtin; +static LanguageData cpp_literals; +static LanguageData cpp_other; +void initCppData() { + cpp_keywords = LanguageData{ + {('a'), QLatin1String("alignas")}, + {('a'), QLatin1String("alignof")}, + {('a'), QLatin1String("and")}, + {('a'), QLatin1String("and_eq")}, + {('a'), QLatin1String("asm")}, + {('b'), QLatin1String("bit_and")}, + {('b'), QLatin1String("bit_or")}, + {('b'), QLatin1String("break")}, + {('c'), QLatin1String("case")}, + {('c'), QLatin1String("catch")}, + {('c'), QLatin1String("compl")}, + {('c'), QLatin1String("concept")}, + {('c'), QLatin1String("const")}, + {('c'), QLatin1String("constinit")}, + {('c'), QLatin1String("constexpr")}, + {('c'), QLatin1String("consteval")}, + {('c'), QLatin1String("const_cast")}, + {('c'), QLatin1String("continue")}, + {('c'), QLatin1String("co_await")}, + {('c'), QLatin1String("co_return")}, + {('c'), QLatin1String("co_yield")}, + {('d'), QLatin1String("decltype")}, + {('d'), QLatin1String("default")}, + {('d'), QLatin1String("delete")}, + {('d'), QLatin1String("do")}, + {('d'), QLatin1String("dynamic_cast")}, + {('e'), QLatin1String("else")}, + {('e'), QLatin1String("explicit")}, + {('e'), QLatin1String("export")}, + {('e'), QLatin1String("extern")}, + {('f'), QLatin1String("for")}, + {('f'), QLatin1String("friend")}, + {('g'), QLatin1String("goto")}, + {('i'), QLatin1String("if")}, + {('i'), QLatin1String("inline")}, + {('m'), QLatin1String("mutable")}, + {('n'), QLatin1String("new")}, + {('n'), QLatin1String("not")}, + {('n'), QLatin1String("not_eq")}, + {('n'), QLatin1String("noexcept")}, + {('o'), QLatin1String("or")}, + {('o'), QLatin1String("or_eq")}, + {('o'), QLatin1String("operator")}, + {('p'), QLatin1String("private")}, + {('p'), QLatin1String("protected")}, + {('p'), QLatin1String("public")}, + {('r'), QLatin1String("register")}, + {('r'), QLatin1String("reinterpret_cast")}, + {('r'), QLatin1String("requires")}, + {('r'), QLatin1String("return")}, + {('s'), QLatin1String("signal")}, + {('s'), QLatin1String("sizeof")}, + {('s'), QLatin1String("slot")}, + {('s'), QLatin1String("static")}, + {('s'), QLatin1String("static_assert")}, + {('s'), QLatin1String("static_cast")}, + {('s'), QLatin1String("switch")}, + {('t'), QLatin1String("template")}, + {('t'), QLatin1String("this")}, + {('t'), QLatin1String("thread_local")}, + {('t'), QLatin1String("throw")}, + {('t'), QLatin1String("try")}, + {('t'), QLatin1String("typeid")}, + {('t'), QLatin1String("typedef")}, + {('t'), QLatin1String("typename")}, + {('u'), QLatin1String("using")}, + {('v'), QLatin1String("volatile")}, + {('w'), QLatin1String("while")}, + {('x'), QLatin1String("xor")}, + {('x'), QLatin1String("xor_eq")}}; + + cpp_types = { + {('a'), QLatin1String("auto")}, + {('b'), QLatin1String("bool")}, + {('c'), QLatin1String("char")}, + {('c'), QLatin1String("char8_t")}, + {('c'), QLatin1String("char16_t")}, + {('c'), QLatin1String("char32_t")}, + {('c'), QLatin1String("class")}, + {('d'), QLatin1String("double")}, + {('e'), QLatin1String("enum")}, + {('f'), QLatin1String("float")}, + {('i'), QLatin1String("int")}, + {('i'), QLatin1String("int8_t")}, + {('i'), QLatin1String("int16_t")}, + {('i'), QLatin1String("int32_t")}, + {('i'), QLatin1String("int64_t")}, + {('i'), QLatin1String("int_fast8_t")}, + {('i'), QLatin1String("int_fast16_t")}, + {('i'), QLatin1String("int_fast32_t")}, + {('i'), QLatin1String("int_fast64_t")}, + {('i'), QLatin1String("intmax_t")}, + {('i'), QLatin1String("intptr_t")}, + {('l'), QLatin1String("long")}, + {('n'), QLatin1String("namespace")}, + {('Q'), QLatin1String("QHash")}, + {('Q'), QLatin1String("QList")}, + {('Q'), QLatin1String("QMap")}, + {('Q'), QLatin1String("QString")}, + {('Q'), QLatin1String("QVector")}, + {('s'), QLatin1String("short")}, + {('s'), QLatin1String("size_t")}, + {('s'), QLatin1String("signed")}, + {('s'), QLatin1String("struct")}, + {('s'), QLatin1String("ssize_t")}, + {('u'), QLatin1String("uint8_t")}, + {('u'), QLatin1String("uint16_t")}, + {('u'), QLatin1String("uint32_t")}, + {('u'), QLatin1String("uint64_t")}, + {('u'), QLatin1String("uint_fast8_t")}, + {('u'), QLatin1String("uint_fast16_t")}, + {('u'), QLatin1String("uint_fast32_t")}, + {('u'), QLatin1String("uint_fast64_t")}, + {('u'), QLatin1String("uint_least8_t")}, + {('u'), QLatin1String("uint_least16_t")}, + {('u'), QLatin1String("uint_least32_t")}, + {('u'), QLatin1String("uint_least64_t")}, + {('u'), QLatin1String("uintmax_t")}, + {('u'), QLatin1String("uintptr_t")}, + {('u'), QLatin1String("unsigned")}, + {('u'), QLatin1String("union")}, + {('v'), QLatin1String("void")}, + {('w'), QLatin1String("wchar_t")}}; + + cpp_literals = { + {('f'), QLatin1String("false")}, + {('n'), QLatin1String("nullptr")}, + {('N'), QLatin1String("NULL")}, + {('t'), QLatin1String("true")} + }; + + cpp_builtin = { + {('s'), QLatin1String("std")}, + {('s'), QLatin1String("string")}, + {('w'), QLatin1String("wstring")}, + {('c'), QLatin1String("cin")}, + {('c'), QLatin1String("cout")}, + {('c'), QLatin1String("cerr")}, + {('c'), QLatin1String("clog")}, + {('s'), QLatin1String("stdin")}, + {('s'), QLatin1String("stdout")}, + {('s'), QLatin1String("stderr")}, + {('s'), QLatin1String("stringstream")}, + {('i'), QLatin1String("istringstream")}, + {('o'), QLatin1String("ostringstream")}, + {('a'), QLatin1String("auto_ptr")}, + {('d'), QLatin1String("deque")}, + {('l'), QLatin1String("list")}, + {('q'), QLatin1String("queue")}, + {('s'), QLatin1String("stack")}, + {('v'), QLatin1String("vector")}, + {('m'), QLatin1String("map")}, + {('s'), QLatin1String("set")}, + {('b'), QLatin1String("bitset")}, + {('m'), QLatin1String("multiset")}, + {('m'), QLatin1String("multimap")}, + {('u'), QLatin1String("unordered_set")}, + {('u'), QLatin1String("unordered_map")}, + {('u'), QLatin1String("unordered_multiset")}, + {('u'), QLatin1String("unordered_multimap")}, + {('a'), QLatin1String("array")}, + {('s'), QLatin1String("shared_ptr")}, + {('a'), QLatin1String("abort")}, + {('t'), QLatin1String("terminate")}, + {('a'), QLatin1String("abs")}, + {('a'), QLatin1String("acos")}, + {('a'), QLatin1String("asin")}, + {('a'), QLatin1String("atan2")}, + {('a'), QLatin1String("atan")}, + {('c'), QLatin1String("calloc")}, + {('c'), QLatin1String("ceil")}, + {('c'), QLatin1String("cosh")}, + {('c'), QLatin1String("cos")}, + {('e'), QLatin1String("exit")}, + {('e'), QLatin1String("exp")}, + {('f'), QLatin1String("fabs")}, + {('f'), QLatin1String("floor")}, + {('f'), QLatin1String("fmod")}, + {('f'), QLatin1String("fprintf")}, + {('f'), QLatin1String("fputs")}, + {('f'), QLatin1String("free")}, + {('f'), QLatin1String("frexp")}, + {('f'), QLatin1String("fscanf")}, + {('f'), QLatin1String("future")}, + {('i'), QLatin1String("isalnum")}, + {('i'), QLatin1String("isalpha")}, + {('i'), QLatin1String("iscntrl")}, + {('i'), QLatin1String("isdigit")}, + {('i'), QLatin1String("isgraph")}, + {('i'), QLatin1String("islower")}, + {('i'), QLatin1String("isprint")}, + {('i'), QLatin1String("ispunct")}, + {('i'), QLatin1String("isspace")}, + {('i'), QLatin1String("isupper")}, + {('i'), QLatin1String("isxdigit")}, + {('t'), QLatin1String("tolower")}, + {('t'), QLatin1String("toupper")}, + {('l'), QLatin1String("labs")}, + {('l'), QLatin1String("ldexp")}, + {('l'), QLatin1String("log10")}, + {('l'), QLatin1String("log")}, + {('m'), QLatin1String("malloc")}, + {('r'), QLatin1String("realloc")}, + {('m'), QLatin1String("main")}, + {('m'), QLatin1String("memchr")}, + {('m'), QLatin1String("memcmp")}, + {('m'), QLatin1String("memcpy")}, + {('m'), QLatin1String("memset")}, + {('m'), QLatin1String("modf")}, + {('p'), QLatin1String("pow")}, + {('p'), QLatin1String("printf")}, + {('p'), QLatin1String("putchar")}, + {('p'), QLatin1String("puts")}, + {('s'), QLatin1String("scanf")}, + {('s'), QLatin1String("sinh")}, + {('s'), QLatin1String("sin")}, + {('s'), QLatin1String("snprintf")}, + {('s'), QLatin1String("sprintf")}, + {('s'), QLatin1String("sqrt")}, + {('s'), QLatin1String("sscanf")}, + {('s'), QLatin1String("strcat")}, + {('s'), QLatin1String("strchr")}, + {('s'), QLatin1String("strcmp")}, + {('s'), QLatin1String("strcpy")}, + {('s'), QLatin1String("strcspn")}, + {('s'), QLatin1String("strlen")}, + {('s'), QLatin1String("strncat")}, + {('s'), QLatin1String("strncmp")}, + {('s'), QLatin1String("strncpy")}, + {('s'), QLatin1String("strpbrk")}, + {('s'), QLatin1String("strrchr")}, + {('s'), QLatin1String("strspn")}, + {('s'), QLatin1String("strstr")}, + {('t'), QLatin1String("tanh")}, + {('t'), QLatin1String("tan")}, + {('v'), QLatin1String("vfprintf")}, + {('v'), QLatin1String("vprintf")}, + {('v'), QLatin1String("vsprintf")}, + {('e'), QLatin1String("endl")}, + {('i'), QLatin1String("initializer_list")}, + {('u'), QLatin1String("unique_ptr")}, + {('c'), QLatin1String("complex")}, + {('i'), QLatin1String("imaginary")} + }; + + cpp_other = { + {('d'), QLatin1String("define")}, + {('e'), QLatin1String("else")}, + {('e'), QLatin1String("elif")}, + {('e'), QLatin1String("endif")}, + {('e'), QLatin1String("error")}, + {('i'), QLatin1String("if")}, + {('i'), QLatin1String("ifdef")}, + {('i'), QLatin1String("ifndef")}, + {('i'), QLatin1String("include")}, + {('l'), QLatin1String("line")}, + {('p'), QLatin1String("pragma")}, + {('P'), QLatin1String("_Pragma")}, + {('u'), QLatin1String("undef")}, + {('w'), QLatin1String("warning")} + }; +} +void loadCppData(LanguageData &typess, + LanguageData &keywordss, + LanguageData &builtins, + LanguageData &literalss, + LanguageData &others){ + if (!cppDataInitialized) { + initCppData(); + cppDataInitialized = true; + } + + typess = cpp_types; + keywordss = cpp_keywords; + builtins = cpp_builtin; + literalss = cpp_literals; + others = cpp_other; + +} + +/**********************************************************/ +/* Shell Data *********************************************/ +/**********************************************************/ + +static bool shellDataInitialized = false; +static LanguageData shell_keywords; +static LanguageData shell_types; +static LanguageData shell_literals; +static LanguageData shell_builtin; +static LanguageData shell_other; +void initShellData() { + shell_keywords = { + {('i'), QLatin1String("if")}, + {('t'), QLatin1String("then")}, + {('e'), QLatin1String("else")}, + {('e'), QLatin1String("elif")}, + {('f'), QLatin1String("fi")}, + {('f'), QLatin1String("for")}, + {('w'), QLatin1String("while")}, + {('i'), QLatin1String("in")}, + {('d'), QLatin1String("do")}, + {('d'), QLatin1String("done")}, + {('c'), QLatin1String("case")}, + {('e'), QLatin1String("esac")}, + {('f'), QLatin1String("function")} + }; + + shell_types = {}; + + shell_literals = { + {('f'), QLatin1String("false")}, + {('t'), QLatin1String("true")} + }; + + shell_builtin = { + {('b'), QLatin1String("break")}, + {('c'), QLatin1String("cd")}, + {('c'), QLatin1String("continue")}, + {('e'), QLatin1String("eval")}, + {('e'), QLatin1String("exec")}, + {('e'), QLatin1String("exit")}, + {('e'), QLatin1String("export")}, + {('g'), QLatin1String("getopts")}, + {('h'), QLatin1String("hash")}, + {('p'), QLatin1String("pwd")}, + {('r'), QLatin1String("readonly")}, + {('r'), QLatin1String("return")}, + {('s'), QLatin1String("shift")}, + {('t'), QLatin1String("test")}, + {('t'), QLatin1String("timestrap")}, + {('u'), QLatin1String("umask")}, + {('u'), QLatin1String("unset")}, + {('B'), QLatin1String("Bash")}, + {('a'), QLatin1String("alias")}, + {('b'), QLatin1String("bind")}, + {('b'), QLatin1String("builtin")}, + {('c'), QLatin1String("caller")}, + {('c'), QLatin1String("command")}, + {('d'), QLatin1String("declare")}, + {('e'), QLatin1String("echo")}, + {('e'), QLatin1String("enable")}, + {('h'), QLatin1String("help")}, + {('l'), QLatin1String("let")}, + {('l'), QLatin1String("local")}, + {('l'), QLatin1String("logout")}, + {('m'), QLatin1String("mapfile")}, + {('p'), QLatin1String("printfread")}, + {('r'), QLatin1String("readarray")}, + {('s'), QLatin1String("source")}, + {('t'), QLatin1String("type")}, + {('t'), QLatin1String("typeset")}, + {('u'), QLatin1String("ulimit")}, + {('u'), QLatin1String("unalias")}, + {('m'), QLatin1String("modifiers")}, + {('s'), QLatin1String("set")}, + {('s'), QLatin1String("shopt")}, + {('a'), QLatin1String("autoload")}, + {('b'), QLatin1String("bg")}, + {('b'), QLatin1String("bindkey")}, + {('b'), QLatin1String("bye")}, + {('c'), QLatin1String("cap")}, + {('c'), QLatin1String("chdir")}, + {('c'), QLatin1String("clone")}, + {('c'), QLatin1String("comparguments")}, + {('c'), QLatin1String("compcall")}, + {('c'), QLatin1String("compctl")}, + {('c'), QLatin1String("compdescribe")}, + {('c'), QLatin1String("compfilescompgroups")}, + {('c'), QLatin1String("compquote")}, + {('c'), QLatin1String("comptags")}, + {('c'), QLatin1String("comptry")}, + {('c'), QLatin1String("compvalues")}, + {('d'), QLatin1String("dirs")}, + {('d'), QLatin1String("disable")}, + {('d'), QLatin1String("disown")}, + {('e'), QLatin1String("echotc")}, + {('e'), QLatin1String("echoti")}, + {('e'), QLatin1String("emulatefc")}, + {('f'), QLatin1String("fg")}, + {('f'), QLatin1String("float")}, + {('f'), QLatin1String("functions")}, + {('g'), QLatin1String("getcap")}, + {('g'), QLatin1String("getln")}, + {('h'), QLatin1String("history")}, + {('i'), QLatin1String("integer")}, + {('j'), QLatin1String("jobs")}, + {('k'), QLatin1String("kill")}, + {('l'), QLatin1String("limit")}, + {('l'), QLatin1String("log")}, + {('n'), QLatin1String("noglob")}, + {('p'), QLatin1String("popd")}, + {('p'), QLatin1String("printpushd")}, + {('p'), QLatin1String("pushln")}, + {('r'), QLatin1String("rehash")}, + {('s'), QLatin1String("sched")}, + {('s'), QLatin1String("setcap")}, + {('s'), QLatin1String("setopt")}, + {('s'), QLatin1String("stat")}, + {('s'), QLatin1String("suspend")}, + {('t'), QLatin1String("ttyctl")}, + {('u'), QLatin1String("unfunction")}, + {('u'), QLatin1String("unhash")}, + {('u'), QLatin1String("unlimitunsetopt")}, + {('v'), QLatin1String("vared")}, + {('w'), QLatin1String("wait")}, + {('w'), QLatin1String("whence")}, + {('w'), QLatin1String("where")}, + {('w'), QLatin1String("which")}, + {('z'), QLatin1String("zcompile")}, + {('z'), QLatin1String("zformat")}, + {('z'), QLatin1String("zftp")}, + {('z'), QLatin1String("zle")}, + {('z'), QLatin1String("zmodload")}, + {('z'), QLatin1String("zparseopts")}, + {('z'), QLatin1String("zprof")}, + {('z'), QLatin1String("zpty")}, + {('z'), QLatin1String("zregexparse")}, + {('z'), QLatin1String("zsocket")}, + {('z'), QLatin1String("zstyle")}, + {('z'), QLatin1String("ztcp")}, + {('g'), QLatin1String("git")}, + {('r'), QLatin1String("rm")}, + {('s'), QLatin1String("sudo")}, + {('f'), QLatin1String("fdisk")}, + {('a'), QLatin1String("apt")}, + {('s'), QLatin1String("snap")}, + {('f'), QLatin1String("flatpak")}, + {('s'), QLatin1String("snapcraft")}, + {('y'), QLatin1String("yaourt")}, + {('n'), QLatin1String("nmcli")}, + {('p'), QLatin1String("pacman")}, + {('p'), QLatin1String("pamac")}, + {('f'), QLatin1String("fsck")}, + {('m'), QLatin1String("mount")}, + {('m'), QLatin1String("mkdir")}, + {('m'), QLatin1String("mkswap")}, + {('s'), QLatin1String("sleep")}, + {('l'), QLatin1String("ls")}, + {('w'), QLatin1String("wget")}, + {('k'), QLatin1String("kill")}, + {('k'), QLatin1String("killall")}, + {('g'), QLatin1String("gdb")}, + {('Q'), QLatin1String("QOwnNotes")}, + {('q'), QLatin1String("qownnotes")}, + {('d'), QLatin1String("docker")}, + {('o'), QLatin1String("openssl")}, + {('p'), QLatin1String("php")}, + {('p'), QLatin1String("python")}, + {('p'), QLatin1String("perl")}, + {('g'), QLatin1String("go")}, + {('c'), QLatin1String("curl")} + }; + + shell_other = {}; +} + +void loadShellData(LanguageData &types, + LanguageData &keywords, + LanguageData &builtin, + LanguageData &literals, + LanguageData &other) { + if (!shellDataInitialized) { + initShellData(); + shellDataInitialized = true; + } + types = shell_types; + keywords = shell_keywords; + builtin = shell_builtin; + literals = shell_literals; + other = shell_other; + +} + +/**********************************************************/ +/* JS Data *********************************************/ +/**********************************************************/ +static bool JSDataInitialized = false; +static LanguageData js_keywords; +static LanguageData js_types; +static LanguageData js_literals; +static LanguageData js_builtin; +static LanguageData js_other; +void initJSData() { + js_keywords = { + {('i'), QLatin1String("in")}, + {('o'), QLatin1String("of")}, + {('i'), QLatin1String("if")}, + {('f'), QLatin1String("for")}, + {('w'), QLatin1String("while")}, + {('f'), QLatin1String("finally")}, + {('n'), QLatin1String("new")}, + {('f'), QLatin1String("function")}, + {('d'), QLatin1String("do")}, + {('r'), QLatin1String("return")}, + {('v'), QLatin1String("void")}, + {('e'), QLatin1String("else")}, + {('b'), QLatin1String("break")}, + {('c'), QLatin1String("catch")}, + {('i'), QLatin1String("instanceof")}, + {('w'), QLatin1String("with")}, + {('t'), QLatin1String("throw")}, + {('c'), QLatin1String("case")}, + {('d'), QLatin1String("default")}, + {('t'), QLatin1String("try")}, + {('t'), QLatin1String("this")}, + {('s'), QLatin1String("switch")}, + {('c'), QLatin1String("continue")}, + {('t'), QLatin1String("typeof")}, + {('d'), QLatin1String("delete")}, + {('l'), QLatin1String("let")}, + {('y'), QLatin1String("yield")}, + {('c'), QLatin1String("const")}, + {('e'), QLatin1String("export")}, + {('s'), QLatin1String("super")}, + {('d'), QLatin1String("debugger")}, + {('a'), QLatin1String("as")}, + {('a'), QLatin1String("async")}, + {('a'), QLatin1String("await")}, + {('s'), QLatin1String("static")}, + {('i'), QLatin1String("import")}, + {('f'), QLatin1String("from")}, + {('a'), QLatin1String("as")} + }; + + js_types = { + {('v'), QLatin1String("var")}, + {('c'), QLatin1String("class")}, + {('b'), QLatin1String("byte")}, + {('e'), QLatin1String("enum")}, + {('f'), QLatin1String("float")}, + {('s'), QLatin1String("short")}, + {('l'), QLatin1String("long")}, + {('i'), QLatin1String("int")}, + {('v'), QLatin1String("void")}, + {('b'), QLatin1String("boolean")}, + {('d'), QLatin1String("double")} + }; + + js_literals = { + {('f'), QLatin1String("false")}, + {('n'), QLatin1String("null")}, + {('t'), QLatin1String("true")}, + {('u'), QLatin1String("undefined")}, + {('N'), QLatin1String("NaN")}, + {('I'), QLatin1String("Infinity")} + }; + + js_builtin = { + {('e'), QLatin1String("eval")}, + {('i'), QLatin1String("isFinite")}, + {('i'), QLatin1String("isNaN")}, + {('p'), QLatin1String("parseFloat")}, + {('p'), QLatin1String("parseInt")}, + {('d'), QLatin1String("decodeURI")}, + {('d'), QLatin1String("decodeURIComponent")}, + {('e'), QLatin1String("encodeURI")}, + {('e'), QLatin1String("encodeURIComponent")}, + {('e'), QLatin1String("escape")}, + {('u'), QLatin1String("unescape")}, + {('O'), QLatin1String("Object")}, + {('F'), QLatin1String("Function")}, + {('B'), QLatin1String("Boolean")}, + {('E'), QLatin1String("Error")}, + {('E'), QLatin1String("EvalError")}, + {('I'), QLatin1String("InternalError")}, + {('R'), QLatin1String("RangeError")}, + {('R'), QLatin1String("ReferenceError")}, + {('S'), QLatin1String("StopIteration")}, + {('S'), QLatin1String("SyntaxError")}, + {('T'), QLatin1String("TypeError")}, + {('U'), QLatin1String("URIError")}, + {('N'), QLatin1String("Number")}, + {('M'), QLatin1String("Math")}, + {('D'), QLatin1String("Date")}, + {('S'), QLatin1String("String")}, + {('R'), QLatin1String("RegExp")}, + {('A'), QLatin1String("Array")}, + {('F'), QLatin1String("Float32Array")}, + {('F'), QLatin1String("Float64Array")}, + {('I'), QLatin1String("Int16Array")}, + {('I'), QLatin1String("Int32Array")}, + {('I'), QLatin1String("Int8Array")}, + {('U'), QLatin1String("Uint16Array")}, + {('U'), QLatin1String("Uint32Array")}, + {('U'), QLatin1String("Uint8Array")}, + {('U'), QLatin1String("Uint8ClampedArray")}, + {('A'), QLatin1String("ArrayBuffer")}, + {('D'), QLatin1String("DataView")}, + {('J'), QLatin1String("JSON")}, + {('I'), QLatin1String("Intl")}, + {('a'), QLatin1String("arguments")}, + {('r'), QLatin1String("require")}, + {('m'), QLatin1String("module")}, + {('c'), QLatin1String("console")}, + {('w'), QLatin1String("window")}, + {('d'), QLatin1String("document")}, + {('S'), QLatin1String("Symbol")}, + {('S'), QLatin1String("Set")}, + {('M'), QLatin1String("Map")}, + {('W'), QLatin1String("WeakSet")}, + {('W'), QLatin1String("WeakMap")}, + {('P'), QLatin1String("Proxy")}, + {('R'), QLatin1String("Reflect")}, + {('P'), QLatin1String("Promise")} + }; + + js_other = {}; +} + +void loadJSData(LanguageData &types, + LanguageData &keywords, + LanguageData &builtin, + LanguageData &literals, + LanguageData &other) { + if (!JSDataInitialized) { + initJSData(); + JSDataInitialized = true; + } + types = js_types; + keywords = js_keywords; + builtin = js_builtin; + literals = js_literals; + other = js_other; +} + +/**********************************************************/ +/* PHP Data *********************************************/ +/**********************************************************/ +static bool PHPDataInitialized = false; +static LanguageData php_keywords; +static LanguageData php_types; +static LanguageData php_literals; +static LanguageData php_builtin; +static LanguageData php_other; +void initPHPData() { + php_keywords = { + {('a'), QLatin1String("and")}, + {('l'), QLatin1String("list")}, + {('a'), QLatin1String("abstract")}, + {('g'), QLatin1String("global")}, + {('p'), QLatin1String("private")}, + {('e'), QLatin1String("echo")}, + {('i'), QLatin1String("interface")}, + {('a'), QLatin1String("as")}, + {('s'), QLatin1String("static")}, + {('e'), QLatin1String("endswitch")}, + {('i'), QLatin1String("if")}, + {('e'), QLatin1String("endwhile")}, + {('o'), QLatin1String("or")}, + {('c'), QLatin1String("const")}, + {('f'), QLatin1String("for")}, + {('e'), QLatin1String("endforeach")}, + {('s'), QLatin1String("self")}, + {('w'), QLatin1String("while")}, + {('i'), QLatin1String("isset")}, + {('p'), QLatin1String("public")}, + {('p'), QLatin1String("protected")}, + {('e'), QLatin1String("exit")}, + {('f'), QLatin1String("foreach")}, + {('t'), QLatin1String("throw")}, + {('e'), QLatin1String("elseif")}, + {('e'), QLatin1String("empty")}, + {('d'), QLatin1String("do")}, + {('x'), QLatin1String("xor")}, + {('r'), QLatin1String("return")}, + {('p'), QLatin1String("parent")}, + {('c'), QLatin1String("clone")}, + {('u'), QLatin1String("use")}, + {('e'), QLatin1String("else")}, + {('b'), QLatin1String("break")}, + {('p'), QLatin1String("print")}, + {('e'), QLatin1String("eval")}, + {('n'), QLatin1String("new")}, + {('c'), QLatin1String("catch")}, + {('c'), QLatin1String("case")}, + {('e'), QLatin1String("exception")}, + {('d'), QLatin1String("default")}, + {('d'), QLatin1String("die")}, + {('e'), QLatin1String("enddeclare")}, + {('f'), QLatin1String("final")}, + {('t'), QLatin1String("try")}, + {('s'), QLatin1String("switch")}, + {('c'), QLatin1String("continue")}, + {('e'), QLatin1String("endfor")}, + {('e'), QLatin1String("endif")}, + {('d'), QLatin1String("declare")}, + {('u'), QLatin1String("unset")}, + {('t'), QLatin1String("trait")}, + {('g'), QLatin1String("goto")}, + {('i'), QLatin1String("instanceof")}, + {('i'), QLatin1String("insteadof")}, + {('y'), QLatin1String("yield")}, + {('f'), QLatin1String("finally")} + }; + + php_types = { + {('v'), QLatin1String("var")}, + {('c'), QLatin1String("class")}, + {('e'), QLatin1String("enum")}, + {('a'), QLatin1String("array")} + }; + + php_literals = { + {('f'), QLatin1String("false")}, + {('t'), QLatin1String("true")}, + {('n'), QLatin1String("null")} + }; + + php_builtin = { + + + }; + + php_other = { + {('i'), QLatin1String("include_once")}, + {('i'), QLatin1String("include")}, + {('_'), QLatin1String("__FILE__")}, + {('r'), QLatin1String("require")}, + {('r'), QLatin1String("require_once")}, + {('_'), QLatin1String("__CLASS__")}, + {('_'), QLatin1String("__LINE__")}, + {('_'), QLatin1String("__METHOD__")}, + {('_'), QLatin1String("__FUNCTION__")}, + {('_'), QLatin1String("__DIR__")}, + {('_'), QLatin1String("__NAMESPACE__")}, + + {('S'), QLatin1String("SERVER")}, + {('G'), QLatin1String("GET")}, + {('P'), QLatin1String("POST")}, + {('F'), QLatin1String("FILES")}, + {('R'), QLatin1String("REQUEST")}, + {('S'), QLatin1String("SESSION")}, + {('E'), QLatin1String("ENV")}, + {('C'), QLatin1String("COOKIE")}, + {('G'), QLatin1String("GLOBALS")}, + {('H'), QLatin1String("HTTP_RAW_POST_DATA")}, + {('a'), QLatin1String("argc")}, + {('a'), QLatin1String("argv")}, + {('p'), QLatin1String("php_errormsg")}, + {('h'), QLatin1String("http_response_header")} +}; +} +void loadPHPData(LanguageData &types, + LanguageData &keywords, + LanguageData &builtin, + LanguageData &literals, + LanguageData &other) { + if (!PHPDataInitialized) { + initPHPData(); + PHPDataInitialized = true; + } + types = php_types; + keywords = php_keywords; + builtin = php_builtin; + literals = php_literals; + other = php_other; +} + +/**********************************************************/ +/* QML Data *********************************************/ +/**********************************************************/ +static bool QMLDataInitialized = false; +static LanguageData qml_keywords; +static LanguageData qml_types; +static LanguageData qml_literals; +static LanguageData qml_builtin; +static LanguageData qml_other; + +void initQMLData() { + qml_keywords = { + {('d'), QLatin1String("default")}, + {('p'), QLatin1String("property")}, + {('i'), QLatin1String("int")}, + {('v'), QLatin1String("var")}, + {('s'), QLatin1String("string")}, + {('f'), QLatin1String("function")}, + {('r'), QLatin1String("readonly")}, + {('M'), QLatin1String("MouseArea")}, + {('d'), QLatin1String("delegate")}, + {('i'), QLatin1String("if")}, + {('e'), QLatin1String("else")}, + + {('e'), QLatin1String("eval")}, + {('i'), QLatin1String("isFinite")}, + {('i'), QLatin1String("isNaN")}, + {('p'), QLatin1String("parseFloat")}, + {('p'), QLatin1String("parseInt")}, + {('d'), QLatin1String("decodeURI")}, + {('d'), QLatin1String("decodeURIComponent")}, + {('e'), QLatin1String("encodeURI")}, + {('e'), QLatin1String("encodeURIComponent")}, + {('e'), QLatin1String("escape")}, + {('u'), QLatin1String("unescape")}, + {('O'), QLatin1String("Object")}, + {('E'), QLatin1String("Error")}, + {('E'), QLatin1String("EvalError")}, + {('I'), QLatin1String("InternalError")}, + {('R'), QLatin1String("RangeError")}, + {('R'), QLatin1String("ReferenceError")}, + {('S'), QLatin1String("StopIteration")}, + {('S'), QLatin1String("SyntaxError")}, + {('T'), QLatin1String("TypeError")}, + {('U'), QLatin1String("URIError")}, + {('N'), QLatin1String("Number")}, + {('M'), QLatin1String("Math")}, + {('D'), QLatin1String("Date")}, + {('S'), QLatin1String("String")}, + {('R'), QLatin1String("RegExp")}, + {('A'), QLatin1String("Array")}, + {('F'), QLatin1String("Float32Array")}, + {('F'), QLatin1String("Float64Array")}, + {('I'), QLatin1String("Int16Array")}, + {('I'), QLatin1String("Int32Array")}, + {('I'), QLatin1String("Int8Array")}, + {('U'), QLatin1String("Uint16Array")}, + {('U'), QLatin1String("Uint32Array")}, + {('U'), QLatin1String("Uint8Array")}, + {('U'), QLatin1String("Uint8ClampedArray")}, + {('A'), QLatin1String("ArrayBuffer")}, + {('D'), QLatin1String("DataView")}, + {('J'), QLatin1String("JSON")}, + {('I'), QLatin1String("Intl")}, + {('a'), QLatin1String("arguments")}, + {('m'), QLatin1String("module")}, + {('c'), QLatin1String("console")}, + {('w'), QLatin1String("window")}, + {('d'), QLatin1String("document")}, + {('S'), QLatin1String("Symbol")}, + {('S'), QLatin1String("Set")}, + {('M'), QLatin1String("Map")}, + {('W'), QLatin1String("WeakSet")}, + {('W'), QLatin1String("WeakMap")}, + {('P'), QLatin1String("Proxy")}, + {('R'), QLatin1String("Reflect")}, + {('B'), QLatin1String("Behavior")}, + {('c'), QLatin1String("color")}, + {('c'), QLatin1String("coordinate")}, + {('d'), QLatin1String("date")}, + {('e'), QLatin1String("enumeration")}, + {('f'), QLatin1String("font")}, + {('g'), QLatin1String("geocircle")}, + {('g'), QLatin1String("georectangle")}, + {('g'), QLatin1String("geoshape")}, + {('l'), QLatin1String("list")}, + {('m'), QLatin1String("matrix4x4")}, + {('p'), QLatin1String("parent")}, + {('p'), QLatin1String("point")}, + {('q'), QLatin1String("quaternion")}, + {('r'), QLatin1String("real")}, + {('s'), QLatin1String("size")}, + {('s'), QLatin1String("string")}, + {('v'), QLatin1String("variant")}, + {('v'), QLatin1String("vector2d")}, + {('v'), QLatin1String("vector3d")}, + {('v'), QLatin1String("vector4d")}, + {('P'), QLatin1String("Promise")} +}; + + qml_types = { + {('R'), QLatin1String("Rectangle")}, + {('T'), QLatin1String("Text")}, + {('c'), QLatin1String("color")}, + {('I'), QLatin1String("Item")}, + {('u'), QLatin1String("url")}, + {('C'), QLatin1String("Component")}, + {('B'), QLatin1String("Button")}, + {('T'), QLatin1String("TextInput")}, + {('L'), QLatin1String("ListView")}, + + +}; + + qml_literals = { + {('f'), QLatin1String("false")}, + {('t'), QLatin1String("true")} +}; + + qml_builtin = { + +}; + + qml_other = { + {('i'), QLatin1String("import")} +}; +} +void loadQMLData(LanguageData &types, + LanguageData &keywords, + LanguageData &builtin, + LanguageData &literals, + LanguageData &other){ + if (!QMLDataInitialized) { + initQMLData(); + QMLDataInitialized = true; + } + types = qml_types; + keywords = qml_keywords; + builtin = qml_builtin; + literals = qml_literals; + other = qml_other; +} + +/**********************************************************/ +/* Python Data *********************************************/ +/**********************************************************/ +static bool PyDataInitialized = false; +static LanguageData py_keywords; +static LanguageData py_types; +static LanguageData py_literals; +static LanguageData py_builtin; +static LanguageData py_other; + +void initPyData() { + py_keywords = { + {('a'), QLatin1String("and")}, + {('e'), QLatin1String("elif")}, + {('i'), QLatin1String("is")}, + {('g'), QLatin1String("global")}, + {('a'), QLatin1String("as")}, + {('i'), QLatin1String("in")}, + {('i'), QLatin1String("if")}, + {('f'), QLatin1String("from")}, + {('r'), QLatin1String("raise")}, + {('f'), QLatin1String("for")}, + {('e'), QLatin1String("except")}, + {('f'), QLatin1String("finally")}, + {('p'), QLatin1String("print")}, + {('p'), QLatin1String("pass")}, + {('r'), QLatin1String("return")}, + {('e'), QLatin1String("exec")}, + {('e'), QLatin1String("else")}, + {('b'), QLatin1String("break")}, + {('n'), QLatin1String("not")}, + {('w'), QLatin1String("with")}, + {('c'), QLatin1String("class")}, + {('a'), QLatin1String("assert")}, + {('y'), QLatin1String("yield")}, + {('t'), QLatin1String("try")}, + {('w'), QLatin1String("while")}, + {('c'), QLatin1String("continue")}, + {('d'), QLatin1String("del")}, + {('o'), QLatin1String("or")}, + {('d'), QLatin1String("def")}, + {('l'), QLatin1String("lambda")}, + {('a'), QLatin1String("async")}, + {('a'), QLatin1String("await")}, + {('n'), QLatin1String("nonlocal")}, + }; + + py_types = { + + }; + + py_literals = { + {('F'), QLatin1String("False")}, + {('T'), QLatin1String("True")}, + {('N'), QLatin1String("None")} + }; + + py_builtin = { + { ('_'), QLatin1String("__import__") }, + { ('a'), QLatin1String("abs") }, + { ('a'), QLatin1String("all") }, + { ('a'), QLatin1String("any") }, + { ('a'), QLatin1String("apply") }, + { ('a'), QLatin1String("ascii") }, + { ('b'), QLatin1String("basestring") }, + { ('b'), QLatin1String("bin") }, + { ('b'), QLatin1String("bool") }, + { ('b'), QLatin1String("buffer") }, + { ('b'), QLatin1String("bytearray") }, + { ('b'), QLatin1String("bytes") }, + { ('c'), QLatin1String("callable") }, + { ('c'), QLatin1String("chr") }, + { ('c'), QLatin1String("classmethod") }, + { ('c'), QLatin1String("cmp") }, + { ('c'), QLatin1String("coerce") }, + { ('c'), QLatin1String("compile") }, + { ('c'), QLatin1String("complex") }, + { ('d'), QLatin1String("delattr") }, + { ('d'), QLatin1String("dict") }, + { ('d'), QLatin1String("dir") }, + { ('d'), QLatin1String("divmod") }, + { ('e'), QLatin1String("enumerate") }, + { ('e'), QLatin1String("eval") }, + { ('e'), QLatin1String("execfile") }, + { ('f'), QLatin1String("file") }, + { ('f'), QLatin1String("filter") }, + { ('f'), QLatin1String("float") }, + { ('f'), QLatin1String("format") }, + { ('f'), QLatin1String("frozenset") }, + { ('g'), QLatin1String("getattr") }, + { ('g'), QLatin1String("globals") }, + { ('h'), QLatin1String("hasattr") }, + { ('h'), QLatin1String("hash") }, + { ('h'), QLatin1String("help") }, + { ('h'), QLatin1String("hex") }, + { ('i'), QLatin1String("id") }, + { ('i'), QLatin1String("input") }, + { ('i'), QLatin1String("int") }, + { ('i'), QLatin1String("intern") }, + { ('i'), QLatin1String("isinstance") }, + { ('i'), QLatin1String("issubclass") }, + { ('i'), QLatin1String("iter") }, + { ('l'), QLatin1String("len") }, + { ('l'), QLatin1String("list") }, + { ('l'), QLatin1String("locals") }, + { ('l'), QLatin1String("long") }, + { ('m'), QLatin1String("map") }, + { ('m'), QLatin1String("max") }, + { ('m'), QLatin1String("memoryview") }, + { ('m'), QLatin1String("min") }, + { ('n'), QLatin1String("next") }, + { ('o'), QLatin1String("object") }, + { ('o'), QLatin1String("oct") }, + { ('o'), QLatin1String("open") }, + { ('o'), QLatin1String("ord") }, + { ('p'), QLatin1String("pow") }, + { ('p'), QLatin1String("property") }, + { ('r'), QLatin1String("range") }, + { ('r'), QLatin1String("raw_input") }, + { ('r'), QLatin1String("reduce") }, + { ('r'), QLatin1String("reload") }, + { ('r'), QLatin1String("repr") }, + { ('r'), QLatin1String("reversed") }, + { ('r'), QLatin1String("round") }, + { ('s'), QLatin1String("set") }, + { ('s'), QLatin1String("setattr") }, + { ('s'), QLatin1String("slice") }, + { ('s'), QLatin1String("sorted") }, + { ('s'), QLatin1String("staticmethod") }, + { ('s'), QLatin1String("str") }, + { ('s'), QLatin1String("sum") }, + { ('s'), QLatin1String("super") }, + { ('t'), QLatin1String("tuple") }, + { ('t'), QLatin1String("type") }, + { ('u'), QLatin1String("unichr") }, + { ('u'), QLatin1String("unicode") }, + { ('v'), QLatin1String("vars") }, + { ('x'), QLatin1String("xrange") }, + { ('z'), QLatin1String("zip") } + }; + + py_other = { + {('i'), QLatin1String("import")} + }; +} +void loadPythonData(LanguageData &types, + LanguageData &keywords, + LanguageData &builtin, + LanguageData &literals, + LanguageData &other){ + if (!PyDataInitialized) { + initPyData(); + PyDataInitialized = true; + } + types = py_types; + keywords = py_keywords; + builtin = py_builtin; + literals = py_literals; + other = py_other; +} + +/********************************************************/ +/*** Rust DATA ***********************************/ +/********************************************************/ +static bool rustDataInitialized = false; +static LanguageData rust_keywords; +static LanguageData rust_types; +static LanguageData rust_literals; +static LanguageData rust_builtin; +static LanguageData rust_other; +void initRustData() { +rust_keywords = { + {('a'), QLatin1String("abstract")}, + {('a'), QLatin1String("alignof")}, + {('a'), QLatin1String("as")}, + {('a'), QLatin1String("async")}, + {('a'), QLatin1String("await")}, + {('b'), QLatin1String("be")}, + {('b'), QLatin1String("box")}, + {('b'), QLatin1String("break")}, + {('c'), QLatin1String("const")}, + {('c'), QLatin1String("continue")}, + {('c'), QLatin1String("crate")}, + {('d'), QLatin1String("do")}, + {('d'), QLatin1String("dyn")}, + {('e'), QLatin1String("else")}, + {('e'), QLatin1String("extern")}, + {('f'), QLatin1String("final")}, + {('f'), QLatin1String("fn")}, + {('f'), QLatin1String("for")}, + {('i'), QLatin1String("if")}, + {('i'), QLatin1String("impl")}, + {('i'), QLatin1String("in")}, + {('l'), QLatin1String("let")}, + {('l'), QLatin1String("loop")}, + {('m'), QLatin1String("match")}, + {('m'), QLatin1String("mod")}, + {('m'), QLatin1String("move")}, + {('m'), QLatin1String("mut")}, + {('o'), QLatin1String("offsetof")}, + {('o'), QLatin1String("once")}, + {('o'), QLatin1String("override")}, + {('p'), QLatin1String("priv")}, + {('p'), QLatin1String("pub")}, + {('p'), QLatin1String("pure")}, + {('r'), QLatin1String("ref")}, + {('r'), QLatin1String("return")}, + {('s'), QLatin1String("sizeof")}, + {('s'), QLatin1String("static")}, + {('s'), QLatin1String("self")}, + {('S'), QLatin1String("Self")}, + {('s'), QLatin1String("super")}, + {('t'), QLatin1String("trait")}, + {('t'), QLatin1String("type")}, + {('t'), QLatin1String("typeof")}, + {('u'), QLatin1String("unsafe")}, + {('u'), QLatin1String("unsized")}, + {('u'), QLatin1String("use")}, + {('v'), QLatin1String("virtual")}, + {('w'), QLatin1String("where")}, + {('w'), QLatin1String("while")}, + {('y'), QLatin1String("yield")}, +}; + +rust_types = { + {('u'), QLatin1String("union")}, + {('e'), QLatin1String("enum")}, + {('s'), QLatin1String("struct")}, + + {('i'), QLatin1String("i8")}, + {('i'), QLatin1String("i16")}, + {('i'), QLatin1String("i32")}, + {('i'), QLatin1String("i64")}, + {('i'), QLatin1String("i128")}, + {('i'), QLatin1String("isize")}, + {('u'), QLatin1String("u8")}, + {('u'), QLatin1String("u16")}, + {('u'), QLatin1String("u32")}, + {('u'), QLatin1String("u64")}, + {('u'), QLatin1String("u128")}, + {('u'), QLatin1String("usize")}, + {('f'), QLatin1String("f32")}, + {('f'), QLatin1String("f64")}, + {('s'), QLatin1String("str")}, + {('c'), QLatin1String("char")}, + {('b'), QLatin1String("bool")}, + {('B'), QLatin1String("Box")}, + {('O'), QLatin1String("Option")}, + {('R'), QLatin1String("Result")}, + {('S'), QLatin1String("String")}, + {('V'), QLatin1String("Vec")} +}; + +rust_literals = { + {('f'), QLatin1String("false")}, + {('t'), QLatin1String("true")} +}; + +rust_builtin = { + +}; + +rust_other = { + {('a'), QLatin1String("assert!")}, + {('a'), QLatin1String("assert_eq!")}, + {('b'), QLatin1String("bitflags!")}, + {('b'), QLatin1String("bytes!")}, + {('c'), QLatin1String("cfg!")}, + {('c'), QLatin1String("col!")}, + {('c'), QLatin1String("concat!")}, + {('c'), QLatin1String("concat_idents!")}, + {('d'), QLatin1String("debug_assert!")}, + {('d'), QLatin1String("debug_assert_eq!")}, + {('e'), QLatin1String("env!")}, + {('p'), QLatin1String("panic!")}, + {('f'), QLatin1String("file!")}, + {('f'), QLatin1String("format!")}, + {('f'), QLatin1String("format_args!")}, + {('i'), QLatin1String("include_bin!")}, + {('i'), QLatin1String("include_str!")}, + {('l'), QLatin1String("line!")}, + {('l'), QLatin1String("local_data_key!")}, + {('m'), QLatin1String("module_path!")}, + {('o'), QLatin1String("option_env!")}, + {('p'), QLatin1String("print!")}, + {('p'), QLatin1String("println!")}, + {('s'), QLatin1String("select!")}, + {('s'), QLatin1String("stringify!")}, + {('t'), QLatin1String("try!")}, + {('u'), QLatin1String("unimplemented!")}, + {('u'), QLatin1String("unreachable!")}, + {('v'), QLatin1String("vec!")}, + {('w'), QLatin1String("write!")}, + {('w'), QLatin1String("writeln!")}, + {('m'), QLatin1String("macro_rules!")}, + {('a'), QLatin1String("assert_ne!")}, + {('d'), QLatin1String("debug_assert_ne!")} +}; +} +void loadRustData(LanguageData &types, + LanguageData &keywords, + LanguageData &builtin, + LanguageData &literals, + LanguageData &other) { + if (!rustDataInitialized) { + initRustData(); + rustDataInitialized = true; + } + types = rust_types; + keywords = rust_keywords; + builtin = rust_builtin; + literals = rust_literals; + other = rust_other; +} + +/********************************************************/ +/*** Java DATA ***********************************/ +/********************************************************/ +static bool javaDataInitialized = false; +static LanguageData java_keywords; +static LanguageData java_types; +static LanguageData java_literals; +static LanguageData java_builtin; +static LanguageData java_other; +void initJavaData() { + java_keywords = { + {('a'), QLatin1String("abstract")}, + {('a'), QLatin1String("assert")}, + {('b'), QLatin1String("break")}, + {('c'), QLatin1String("case")}, + {('c'), QLatin1String("catch")}, + {('c'), QLatin1String("const")}, + {('c'), QLatin1String("continue")}, + {('d'), QLatin1String("default")}, + {('d'), QLatin1String("do")}, + {('e'), QLatin1String("else")}, + {('e'), QLatin1String("exports")}, + {('e'), QLatin1String("extends")}, + {('f'), QLatin1String("final")}, + {('f'), QLatin1String("finally")}, + {('f'), QLatin1String("for")}, + {('g'), QLatin1String("goto")}, + {('i'), QLatin1String("if")}, + {('i'), QLatin1String("implements")}, + {('i'), QLatin1String("import")}, + {('i'), QLatin1String("instanceof")}, + {('i'), QLatin1String("interface")}, + {('l'), QLatin1String("long")}, + {('m'), QLatin1String("module")}, + {('n'), QLatin1String("native")}, + {('n'), QLatin1String("new")}, + {('n'), QLatin1String("null")}, + {('o'), QLatin1String("open")}, + {('o'), QLatin1String("opens")}, + {('p'), QLatin1String("package")}, + {('p'), QLatin1String("private")}, + {('p'), QLatin1String("protected")}, + {('p'), QLatin1String("provides")}, + {('p'), QLatin1String("public")}, + {('r'), QLatin1String("requires")}, + {('r'), QLatin1String("return")}, + {('s'), QLatin1String("static")}, + {('s'), QLatin1String("strictfp")}, + {('s'), QLatin1String("super")}, + {('s'), QLatin1String("switch")}, + {('s'), QLatin1String("synchronized")}, + {('t'), QLatin1String("this")}, + {('t'), QLatin1String("throw")}, + {('t'), QLatin1String("throws")}, + {('t'), QLatin1String("to")}, + {('t'), QLatin1String("transient")}, + {('t'), QLatin1String("transitive")}, + {('t'), QLatin1String("try")}, + {('u'), QLatin1String("uses")}, + {('v'), QLatin1String("var")}, + {('v'), QLatin1String("volatile")}, + {('w'), QLatin1String("while")}, + {('w'), QLatin1String("with")}, + {('y'), QLatin1String("yield")} + }; + + java_types = { + {('v'), QLatin1String("void")}, + {('f'), QLatin1String("float")}, + {('b'), QLatin1String("boolean")}, + {('b'), QLatin1String("byte")}, + {('i'), QLatin1String("int")}, + {('c'), QLatin1String("char")}, + {('c'), QLatin1String("class")}, + {('d'), QLatin1String("double")}, + {('e'), QLatin1String("enum")}, + {('s'), QLatin1String("short")}, + + }; + + java_literals = { + {('f'), QLatin1String("false")}, + {('t'), QLatin1String("true")} + }; + + java_builtin = { + + }; + + java_other = { + + }; +} +void loadJavaData(LanguageData &types, + LanguageData &keywords, + LanguageData &builtin, + LanguageData &literals, + LanguageData &other) { + if (!javaDataInitialized) { + initJavaData(); + javaDataInitialized = true; + } + types = java_types; + keywords = java_keywords; + builtin = java_builtin; + literals = java_literals; + other = java_other; +} + +/********************************************************/ +/*** C# DATA *************************************/ +/********************************************************/ +static bool csharpDataInitialized = false; +static LanguageData csharp_keywords; +static LanguageData csharp_types; +static LanguageData csharp_literals; +static LanguageData csharp_builtin; +static LanguageData csharp_other; +void initCSharpData() { + csharp_keywords = { + {('a'), QLatin1String("abstract")}, + {('a'), QLatin1String("add")}, + {('a'), QLatin1String("alias")}, + {('a'), QLatin1String("as")}, + {('a'), QLatin1String("ascending")}, + {('a'), QLatin1String("async")}, + {('a'), QLatin1String("await")}, + {('b'), QLatin1String("base")}, + {('b'), QLatin1String("break")}, + {('c'), QLatin1String("case")}, + {('c'), QLatin1String("catch")}, + {('c'), QLatin1String("checked")}, + {('c'), QLatin1String("const")}, + {('c'), QLatin1String("continue")}, + {('d'), QLatin1String("decimal")}, + {('d'), QLatin1String("default")}, + {('d'), QLatin1String("delegate")}, + {('d'), QLatin1String("descending")}, + {('d'), QLatin1String("do")}, + {('d'), QLatin1String("dynamic")}, + {('e'), QLatin1String("else")}, + {('e'), QLatin1String("event")}, + {('e'), QLatin1String("explicit")}, + {('e'), QLatin1String("extern")}, + {('f'), QLatin1String("finally")}, + {('f'), QLatin1String("fixed")}, + {('f'), QLatin1String("for")}, + {('f'), QLatin1String("foreach")}, + {('f'), QLatin1String("from")}, + {('g'), QLatin1String("get")}, + {('g'), QLatin1String("global")}, + {('g'), QLatin1String("goto")}, + {('g'), QLatin1String("group")}, + {('i'), QLatin1String("if")}, + {('i'), QLatin1String("implicit")}, + {('i'), QLatin1String("in")}, + {('i'), QLatin1String("interface")}, + {('i'), QLatin1String("internal")}, + {('i'), QLatin1String("into")}, + {('i'), QLatin1String("is")}, + {('j'), QLatin1String("join")}, + {('l'), QLatin1String("let")}, + {('l'), QLatin1String("lock")}, + {('l'), QLatin1String("long")}, + {('n'), QLatin1String("namespace")}, + {('n'), QLatin1String("new")}, + {('o'), QLatin1String("object")}, + {('o'), QLatin1String("operator")}, + {('o'), QLatin1String("orderby")}, + {('o'), QLatin1String("out")}, + {('o'), QLatin1String("override")}, + {('p'), QLatin1String("params")}, + {('p'), QLatin1String("partial")}, + {('p'), QLatin1String("private")}, + {('p'), QLatin1String("protected")}, + {('p'), QLatin1String("public")}, + {('r'), QLatin1String("readonly")}, + {('r'), QLatin1String("ref")}, + {('r'), QLatin1String("remove")}, + {('r'), QLatin1String("return")}, + {('s'), QLatin1String("sealed")}, + {('s'), QLatin1String("select")}, + {('s'), QLatin1String("set")}, + {('s'), QLatin1String("sizeof")}, + {('s'), QLatin1String("stackalloc")}, + {('s'), QLatin1String("static")}, + {('s'), QLatin1String("switch")}, + {('t'), QLatin1String("this")}, + {('t'), QLatin1String("throw")}, + {('t'), QLatin1String("try")}, + {('t'), QLatin1String("typeof")}, + {('u'), QLatin1String("unchecked")}, + {('u'), QLatin1String("unsafe")}, + {('u'), QLatin1String("using")}, + {('v'), QLatin1String("value")}, + {('v'), QLatin1String("virtual")}, + {('v'), QLatin1String("volatile")}, + {('w'), QLatin1String("where")}, + {('w'), QLatin1String("while")}, + {('y'), QLatin1String("yield")} + }; + + csharp_types = { + {('b'), QLatin1String("bool")}, + {('b'), QLatin1String("byte")}, + {('c'), QLatin1String("char")}, + {('c'), QLatin1String("class")}, + {('d'), QLatin1String("double")}, + {('e'), QLatin1String("enum")}, + {('f'), QLatin1String("float")}, + {('i'), QLatin1String("int")}, + {('s'), QLatin1String("sbyte")}, + {('s'), QLatin1String("short")}, + {('s'), QLatin1String("string")}, + {('s'), QLatin1String("struct")}, + {('u'), QLatin1String("uint")}, + {('u'), QLatin1String("ulong")}, + {('u'), QLatin1String("ushort")}, + {('v'), QLatin1String("var")}, + {('v'), QLatin1String("void")}, + }; + + csharp_literals = { + {('f'), QLatin1String("false")}, + {('t'), QLatin1String("true")}, + {('n'), QLatin1String("null")} + }; + + csharp_builtin = { + + }; + + csharp_other = { + {('d'), QLatin1String("define")}, + {('e'), QLatin1String("elif")}, + {('e'), QLatin1String("else")}, + {('e'), QLatin1String("endif")}, + {('e'), QLatin1String("endregion")}, + {('e'), QLatin1String("error")}, + {('i'), QLatin1String("if")}, + {('l'), QLatin1String("line")}, + {('p'), QLatin1String("pragma")}, + {('r'), QLatin1String("region")}, + {('u'), QLatin1String("undef")}, + {('w'), QLatin1String("warning")} + }; +} +void loadCSharpData(LanguageData &types, + LanguageData &keywords, + LanguageData &builtin, + LanguageData &literals, + LanguageData &other){ + if (!csharpDataInitialized) { + initCSharpData(); + csharpDataInitialized = true; + } + types = csharp_types; + keywords = csharp_keywords; + builtin = csharp_builtin; + literals = csharp_literals; + other = csharp_other; +} + +/********************************************************/ +/*** Go DATA *************************************/ +/********************************************************/ +static bool goDataInitialized = false; +static LanguageData go_keywords; +static LanguageData go_types; +static LanguageData go_literals; +static LanguageData go_builtin; +static LanguageData go_other; +void initGoData(){ + go_keywords = { + {('b'), QLatin1String("break")}, + {('c'), QLatin1String("case")}, + {('c'), QLatin1String("chan")}, + {('c'), QLatin1String("const")}, + {('c'), QLatin1String("continue")}, + {('d'), QLatin1String("default")}, + {('d'), QLatin1String("defer")}, + {('e'), QLatin1String("else")}, + {('f'), QLatin1String("fallthrough")}, + {('f'), QLatin1String("for")}, + {('f'), QLatin1String("func")}, + {('g'), QLatin1String("go")}, + {('t'), QLatin1String("to")}, + {('i'), QLatin1String("if")}, + {('i'), QLatin1String("import")}, + {('i'), QLatin1String("interface")}, + {('p'), QLatin1String("package")}, + {('r'), QLatin1String("range")}, + {('r'), QLatin1String("return")}, + {('s'), QLatin1String("select")}, + {('s'), QLatin1String("struct")}, + {('s'), QLatin1String("switch")}, + {('t'), QLatin1String("type")}, + }; + + go_types = { + {('m'), QLatin1String("map")}, + {('s'), QLatin1String("struct")}, + {('v'), QLatin1String("var")}, + {('b'), QLatin1String("bool")}, + {('b'), QLatin1String("byte")}, + {('c'), QLatin1String("complex64")}, + {('c'), QLatin1String("complex128")}, + {('f'), QLatin1String("float32")}, + {('f'), QLatin1String("float64")}, + {('i'), QLatin1String("int8")}, + {('i'), QLatin1String("int16")}, + {('i'), QLatin1String("int32")}, + {('i'), QLatin1String("int64")}, + {('s'), QLatin1String("string")}, + {('u'), QLatin1String("uint8")}, + {('u'), QLatin1String("uint16")}, + {('u'), QLatin1String("uint32")}, + {('u'), QLatin1String("uint64")}, + {('i'), QLatin1String("int")}, + {('u'), QLatin1String("uint")}, + {('u'), QLatin1String("uintptr")}, + {('r'), QLatin1String("rune")} + }; + + go_literals = { + {('f'), QLatin1String("false")}, + {('t'), QLatin1String("true")}, + {('n'), QLatin1String("nil")}, + {('i'), QLatin1String("iota")} + }; + + go_builtin = { + {('a'), QLatin1String("append")}, + {('c'), QLatin1String("cap")}, + {('c'), QLatin1String("close")}, + {('c'), QLatin1String("complex")}, + {('c'), QLatin1String("copy")}, + {('i'), QLatin1String("imag")}, + {('l'), QLatin1String("len")}, + {('m'), QLatin1String("make")}, + {('n'), QLatin1String("new")}, + {('p'), QLatin1String("panic")}, + {('p'), QLatin1String("print")}, + {('p'), QLatin1String("println")}, + {('r'), QLatin1String("real")}, + {('r'), QLatin1String("recover")}, + {('d'), QLatin1String("delete")} + }; + + go_other = { + + }; +} +void loadGoData(LanguageData &types, + LanguageData &keywords, + LanguageData &builtin, + LanguageData &literals, + LanguageData &other) { + if (!goDataInitialized) { + initGoData(); + goDataInitialized = true; + } + types = go_types; + keywords = go_keywords; + builtin = go_builtin; + literals = go_literals; + other = go_other; +} + +/********************************************************/ +/*** V DATA **************************************/ +/********************************************************/ +static bool vDataInitialized = false; +static LanguageData v_keywords; +static LanguageData v_types; +static LanguageData v_literals; +static LanguageData v_builtin; +static LanguageData v_other; +void initVData() { + v_keywords = { + {('b'), QLatin1String("break")}, + {('c'), QLatin1String("const")}, + {('c'), QLatin1String("continue")}, + {('d'), QLatin1String("defer")}, + {('e'), QLatin1String("else")}, + {('f'), QLatin1String("for")}, + {('f'), QLatin1String("fn")}, + {('g'), QLatin1String("go")}, + {('g'), QLatin1String("goto")}, + {('i'), QLatin1String("if")}, + {('i'), QLatin1String("import")}, + {('i'), QLatin1String("interface")}, + {('r'), QLatin1String("return")}, + {('s'), QLatin1String("struct")}, + {('s'), QLatin1String("switch")}, + {('t'), QLatin1String("type")}, + {('p'), QLatin1String("pub")}, + {('o'), QLatin1String("or")}, + {('n'), QLatin1String("none")} + }; + + v_types = { + {('m'), QLatin1String("map")}, + {('s'), QLatin1String("struct")}, + {('b'), QLatin1String("bool")}, + {('b'), QLatin1String("byte")}, + {('f'), QLatin1String("f32")}, + {('f'), QLatin1String("f64")}, + {('i'), QLatin1String("i8")}, + {('i'), QLatin1String("i16")}, + {('i'), QLatin1String("int")}, + {('i'), QLatin1String("i64")}, + {('i'), QLatin1String("i128")}, + {('s'), QLatin1String("string")}, + {('u'), QLatin1String("u16")}, + {('u'), QLatin1String("u32")}, + {('u'), QLatin1String("u64")}, + {('u'), QLatin1String("u128")}, + {('u'), QLatin1String("byteptr")}, + {('u'), QLatin1String("voidptr")}, + {('r'), QLatin1String("rune")} + }; + + v_literals = { + {('f'), QLatin1String("false")}, + {('t'), QLatin1String("true")}, + }; + + v_builtin = { + }; + + v_other = { + + }; +} +void loadVData(LanguageData &types, + LanguageData &keywords, + LanguageData &builtin, + LanguageData &literals, + LanguageData &other) { + if (!vDataInitialized) { + initVData(); + vDataInitialized = true; + } + types = v_types; + keywords = v_keywords; + builtin = v_builtin; + literals = v_literals; + other = v_other; +} + +/********************************************************/ +/*** SQL DATA ************************************/ +/********************************************************/ +static bool sqlDataInitialized = false; +static LanguageData sql_keywords; +static LanguageData sql_types; +static LanguageData sql_literals; +static LanguageData sql_builtin; +static LanguageData sql_other; +void initSQLData() { + sql_keywords = { + {('A'), QLatin1String("ACTION")}, + {('A'), QLatin1String("ADD")}, + {('A'), QLatin1String("AFTER")}, + {('A'), QLatin1String("ALGORITHM")}, + {('A'), QLatin1String("ALL")}, + {('A'), QLatin1String("ALTER")}, + {('A'), QLatin1String("ANALYZE")}, + {('A'), QLatin1String("ANY")}, + {('A'), QLatin1String("APPLY")}, + {('A'), QLatin1String("AS")}, + {('A'), QLatin1String("ASC")}, + {('A'), QLatin1String("AUTHORIZATION")}, + {('A'), QLatin1String("AUTO_INCREMENT")}, + {('B'), QLatin1String("BACKUP")}, + {('B'), QLatin1String("BDB")}, + {('B'), QLatin1String("BEGIN")}, + {('B'), QLatin1String("BERKELEYDB")}, + {('B'), QLatin1String("BIGINT")}, + {('B'), QLatin1String("BINARY")}, + {('B'), QLatin1String("BIT")}, + {('B'), QLatin1String("BLOB")}, + {('B'), QLatin1String("BOOL")}, + {('B'), QLatin1String("BOOLEAN")}, + {('B'), QLatin1String("BREAK")}, + {('B'), QLatin1String("BROWSE")}, + {('B'), QLatin1String("BTREE")}, + {('B'), QLatin1String("BULK")}, + {('B'), QLatin1String("BY")}, + {('C'), QLatin1String("CALL")}, + {('C'), QLatin1String("CASCADED")}, + {('C'), QLatin1String("CASE")}, + {('C'), QLatin1String("CHAIN")}, + {('C'), QLatin1String("CHARACTER")}, + {('S'), QLatin1String("SET")}, + {('C'), QLatin1String("CHECKPOINT")}, + {('C'), QLatin1String("CLOSE")}, + {('C'), QLatin1String("CLUSTERED")}, + {('C'), QLatin1String("COALESCE")}, + {('C'), QLatin1String("COLLATE")}, + {('C'), QLatin1String("COLUMNS")}, + {('C'), QLatin1String("COMMENT")}, + {('C'), QLatin1String("COMMITTED")}, + {('C'), QLatin1String("COMPUTE")}, + {('C'), QLatin1String("CONNECT")}, + {('C'), QLatin1String("CONSISTENT")}, + {('C'), QLatin1String("CONSTRAINT")}, + {('C'), QLatin1String("CONTAINSTABLE")}, + {('C'), QLatin1String("CONTINUE")}, + {('C'), QLatin1String("CONVERT")}, + {('C'), QLatin1String("CREATE")}, + {('C'), QLatin1String("CROSS")}, + {('C'), QLatin1String("CURRENT_DATE")}, + {('_'), QLatin1String("_TIME")}, + {('_'), QLatin1String("_TIMESTAMP")}, + {('_'), QLatin1String("_USER")}, + {('C'), QLatin1String("CURSOR")}, + {('C'), QLatin1String("CYCLE")}, + {('D'), QLatin1String("DATABASES")}, + {('D'), QLatin1String("DATETIME")}, + {('D'), QLatin1String("DAY")}, + {('D'), QLatin1String("DBCC")}, + {('D'), QLatin1String("DEALLOCATE")}, + {('D'), QLatin1String("DEC")}, + {('D'), QLatin1String("DECIMAL")}, + {('D'), QLatin1String("DECLARE")}, + {('D'), QLatin1String("DEFAULT")}, + {('D'), QLatin1String("DEFINER")}, + {('D'), QLatin1String("DELAYED")}, + {('D'), QLatin1String("DELETE")}, + {('D'), QLatin1String("DELIMITERS")}, + {('D'), QLatin1String("DENY")}, + {('D'), QLatin1String("DESC")}, + {('D'), QLatin1String("DESCRIBE")}, + {('D'), QLatin1String("DETERMINISTIC")}, + {('D'), QLatin1String("DISABLE")}, + {('D'), QLatin1String("DISCARD")}, + {('D'), QLatin1String("DISK")}, + {('D'), QLatin1String("DISTINCT")}, + {('D'), QLatin1String("DISTINCTROW")}, + {('D'), QLatin1String("DISTRIBUTED")}, + {('D'), QLatin1String("DO")}, + {('D'), QLatin1String("DOUBLE")}, + {('D'), QLatin1String("DROP")}, + {('D'), QLatin1String("DUMMY")}, + {('D'), QLatin1String("DUMPFILE")}, + {('D'), QLatin1String("DUPLICATE")}, + {('E'), QLatin1String("ELSEIF")}, + {('E'), QLatin1String("ENABLE")}, + {('E'), QLatin1String("ENCLOSED")}, + {('E'), QLatin1String("END")}, + {('E'), QLatin1String("ENGINE")}, + {('E'), QLatin1String("ENUM")}, + {('E'), QLatin1String("ERRLVL")}, + {('E'), QLatin1String("ERRORS")}, + {('E'), QLatin1String("ESCAPED")}, + {('E'), QLatin1String("EXCEPT")}, + {('E'), QLatin1String("EXECUTE")}, + {('E'), QLatin1String("EXISTS")}, + {('E'), QLatin1String("EXIT")}, + {('E'), QLatin1String("EXPLAIN")}, + {('E'), QLatin1String("EXTENDED")}, + {('F'), QLatin1String("FETCH")}, + {('F'), QLatin1String("FIELDS")}, + {('F'), QLatin1String("FILE")}, + {('F'), QLatin1String("FILLFACTOR")}, + {('F'), QLatin1String("FIRST")}, + {('F'), QLatin1String("FIXED")}, + {('F'), QLatin1String("FLOAT")}, + {('F'), QLatin1String("FOLLOWING")}, + {('F'), QLatin1String("FOR")}, + {('E'), QLatin1String("EACH")}, + {('R'), QLatin1String("ROW")}, + {('F'), QLatin1String("FORCE")}, + {('F'), QLatin1String("FOREIGN")}, + {('F'), QLatin1String("FREETEXTTABLE")}, + {('F'), QLatin1String("FROM")}, + {('F'), QLatin1String("FULL")}, + {('F'), QLatin1String("FUNCTION")}, + {('G'), QLatin1String("GEOMETRYCOLLECTION")}, + {('G'), QLatin1String("GLOBAL")}, + {('G'), QLatin1String("GOTO")}, + {('G'), QLatin1String("GRANT")}, + {('G'), QLatin1String("GROUP")}, + {('H'), QLatin1String("HANDLER")}, + {('H'), QLatin1String("HASH")}, + {('H'), QLatin1String("HAVING")}, + {('H'), QLatin1String("HOLDLOCK")}, + {('H'), QLatin1String("HOUR")}, + {('I'), QLatin1String("IDENTITY_INSERT")}, + {('C'), QLatin1String("COL")}, + {('I'), QLatin1String("IF")}, + {('I'), QLatin1String("IGNORE")}, + {('I'), QLatin1String("IMPORT")}, + {('I'), QLatin1String("INDEX")}, + {('I'), QLatin1String("INFILE")}, + {('I'), QLatin1String("INNER")}, + {('I'), QLatin1String("INNODB")}, + {('I'), QLatin1String("INOUT")}, + {('I'), QLatin1String("INSERT")}, + {('I'), QLatin1String("INT")}, + {('I'), QLatin1String("INTEGER")}, + {('I'), QLatin1String("INTERSECT")}, + {('I'), QLatin1String("INTERVAL")}, + {('I'), QLatin1String("INTO")}, + {('I'), QLatin1String("INVOKER")}, + {('I'), QLatin1String("ISOLATION")}, + {('I'), QLatin1String("ITERATE")}, + {('J'), QLatin1String("JOIN")}, + {('K'), QLatin1String("KEYS")}, + {('K'), QLatin1String("KILL")}, + {('L'), QLatin1String("LANGUAGE")}, + {('L'), QLatin1String("LAST")}, + {('L'), QLatin1String("LEAVE")}, + {('L'), QLatin1String("LEFT")}, + {('L'), QLatin1String("LEVEL")}, + {('L'), QLatin1String("LIMIT")}, + {('L'), QLatin1String("LINENO")}, + {('L'), QLatin1String("LINES")}, + {('L'), QLatin1String("LINESTRING")}, + {('L'), QLatin1String("LOAD")}, + {('L'), QLatin1String("LOCAL")}, + {('L'), QLatin1String("LOCK")}, + {('L'), QLatin1String("LONGBLOB")}, + {('T'), QLatin1String("TEXT")}, + {('L'), QLatin1String("LOOP")}, + {('M'), QLatin1String("MATCHED")}, + {('M'), QLatin1String("MEDIUMBLOB")}, + {('I'), QLatin1String("INT")}, + {('T'), QLatin1String("TEXT")}, + {('M'), QLatin1String("MERGE")}, + {('M'), QLatin1String("MIDDLEINT")}, + {('M'), QLatin1String("MINUTE")}, + {('M'), QLatin1String("MODE")}, + {('M'), QLatin1String("MODIFIES")}, + {('M'), QLatin1String("MODIFY")}, + {('M'), QLatin1String("MONTH")}, + {('M'), QLatin1String("MULTILINESTRING")}, + {('P'), QLatin1String("POINT")}, + {('P'), QLatin1String("POLYGON")}, + {('N'), QLatin1String("NATIONAL")}, + {('N'), QLatin1String("NATURAL")}, + {('N'), QLatin1String("NCHAR")}, + {('N'), QLatin1String("NEXT")}, + {('N'), QLatin1String("NO")}, + {('N'), QLatin1String("NONCLUSTERED")}, + {('N'), QLatin1String("NULLIF")}, + {('N'), QLatin1String("NUMERIC")}, + {('O'), QLatin1String("OFF")}, + {('O'), QLatin1String("OFFSETS")}, + {('O'), QLatin1String("ON")}, + {('O'), QLatin1String("OPENDATASOURCE")}, + {('Q'), QLatin1String("QUERY")}, + {('R'), QLatin1String("ROWSET")}, + {('O'), QLatin1String("OPTIMIZE")}, + {('O'), QLatin1String("OPTIONALLY")}, + {('O'), QLatin1String("ORDER")}, + {('O'), QLatin1String("OUTER")}, + {('F'), QLatin1String("FILE")}, + {('O'), QLatin1String("OVER")}, + {('P'), QLatin1String("PARTIAL")}, + {('P'), QLatin1String("PARTITION")}, + {('P'), QLatin1String("PERCENT")}, + {('P'), QLatin1String("PIVOT")}, + {('P'), QLatin1String("PLAN")}, + {('P'), QLatin1String("POINT")}, + {('P'), QLatin1String("POLYGON")}, + {('P'), QLatin1String("PRECEDING")}, + {('P'), QLatin1String("PRECISION")}, + {('P'), QLatin1String("PREPARE")}, + {('P'), QLatin1String("PREV")}, + {('P'), QLatin1String("PRIMARY")}, + {('P'), QLatin1String("PRINT")}, + {('P'), QLatin1String("PRIVILEGES")}, + {('P'), QLatin1String("PROCEDURE")}, + {('P'), QLatin1String("PUBLIC")}, + {('P'), QLatin1String("PURGE")}, + {('Q'), QLatin1String("QUICK")}, + {('R'), QLatin1String("RAISERROR")}, + {('R'), QLatin1String("READS")}, + {('R'), QLatin1String("REAL")}, + {('R'), QLatin1String("RECONFIGURE")}, + {('R'), QLatin1String("REFERENCES")}, + {('R'), QLatin1String("RELEASE")}, + {('R'), QLatin1String("RENAME")}, + {('R'), QLatin1String("REPEATABLE")}, + {('R'), QLatin1String("REPLACE")}, + {('R'), QLatin1String("REPLICATION")}, + {('R'), QLatin1String("REQUIRE")}, + {('R'), QLatin1String("RESIGNAL")}, + {('R'), QLatin1String("RESTORE")}, + {('R'), QLatin1String("RESTRICT")}, + {('R'), QLatin1String("RETURNS")}, + {('R'), QLatin1String("REVOKE")}, + {('R'), QLatin1String("RIGHT")}, + {('R'), QLatin1String("ROLLBACK")}, + {('R'), QLatin1String("ROUTINE")}, + {('R'), QLatin1String("ROWCOUNT")}, + {('G'), QLatin1String("GUIDCOL")}, + {('R'), QLatin1String("RTREE")}, + {('R'), QLatin1String("RULE")}, + {('S'), QLatin1String("SAVEPOINT")}, + {('S'), QLatin1String("SCHEMA")}, + {('S'), QLatin1String("SECOND")}, + {('S'), QLatin1String("SELECT")}, + {('S'), QLatin1String("SERIALIZABLE")}, + {('S'), QLatin1String("SESSION_USER")}, + {('S'), QLatin1String("SETUSER")}, + {('S'), QLatin1String("SHARE")}, + {('S'), QLatin1String("SHOW")}, + {('S'), QLatin1String("SHUTDOWN")}, + {('S'), QLatin1String("SIMPLE")}, + {('S'), QLatin1String("SMALLINT")}, + {('S'), QLatin1String("SNAPSHOT")}, + {('S'), QLatin1String("SOME")}, + {('S'), QLatin1String("SONAME")}, + {('S'), QLatin1String("SQL")}, + {('S'), QLatin1String("STARTING")}, + {('S'), QLatin1String("STATISTICS")}, + {('S'), QLatin1String("STATUS")}, + {('S'), QLatin1String("STRIPED")}, + {('S'), QLatin1String("SYSTEM_USER")}, + {('T'), QLatin1String("TABLES")}, + {('T'), QLatin1String("TABLESPACE")}, + {('T'), QLatin1String("TEMPORARY")}, + {('T'), QLatin1String("TABLE")}, + {('T'), QLatin1String("TERMINATED")}, + {('T'), QLatin1String("TEXTSIZE")}, + {('T'), QLatin1String("THEN")}, + {('T'), QLatin1String("TIMESTAMP")}, + {('T'), QLatin1String("TINYBLOB")}, + {('I'), QLatin1String("INT")}, + {('T'), QLatin1String("TEXT")}, + {('T'), QLatin1String("TOP")}, + {('T'), QLatin1String("TRANSACTIONS")}, + {('T'), QLatin1String("TRIGGER")}, + {('T'), QLatin1String("TRUNCATE")}, + {('T'), QLatin1String("TSEQUAL")}, + {('T'), QLatin1String("TYPES")}, + {('U'), QLatin1String("UNBOUNDED")}, + {('U'), QLatin1String("UNCOMMITTED")}, + {('U'), QLatin1String("UNDEFINED")}, + {('U'), QLatin1String("UNION")}, + {('U'), QLatin1String("UNIQUE")}, + {('U'), QLatin1String("UNLOCK")}, + {('U'), QLatin1String("UNPIVOT")}, + {('U'), QLatin1String("UNSIGNED")}, + {('U'), QLatin1String("UPDATETEXT")}, + {('U'), QLatin1String("USAGE")}, + {('U'), QLatin1String("USE")}, + {('U'), QLatin1String("USER")}, + {('U'), QLatin1String("USING")}, + {('V'), QLatin1String("VALUES")}, + {('V'), QLatin1String("VARBINARY")}, + {('C'), QLatin1String("CHAR")}, + {('C'), QLatin1String("CHARACTER")}, + {('Y'), QLatin1String("YING")}, + {('V'), QLatin1String("VIEW")}, + {('W'), QLatin1String("WAITFOR")}, + {('W'), QLatin1String("WARNINGS")}, + {('W'), QLatin1String("WHEN")}, + {('W'), QLatin1String("WHERE")}, + {('W'), QLatin1String("WHILE")}, + {('W'), QLatin1String("WITH")}, + {('R'), QLatin1String("ROLLUP")}, + {('I'), QLatin1String("IN")}, + {('W'), QLatin1String("WORK")}, + {('W'), QLatin1String("WRITETEXT")}, + {('Y'), QLatin1String("YEAR")} + }; + + sql_types = { + + }; + + sql_literals = { + {('A'), QLatin1String("TRUE")}, + {('F'), QLatin1String("FALSE")}, + {('N'), QLatin1String("NULL")}, + }; + + sql_builtin = { + {('A'), QLatin1String("AVG")}, + {('C'), QLatin1String("COUNT")}, + {('F'), QLatin1String("FIRST")}, + {('F'), QLatin1String("FORMAT")}, + {('L'), QLatin1String("LAST")}, + {('L'), QLatin1String("LCASE")}, + {('L'), QLatin1String("LEN")}, + {('M'), QLatin1String("MAX")}, + {('M'), QLatin1String("MID")}, + {('M'), QLatin1String("MIN")}, + {('M'), QLatin1String("MOD")}, + {('N'), QLatin1String("NOW")}, + {('R'), QLatin1String("ROUND")}, + {('S'), QLatin1String("SUM")}, + {('U'), QLatin1String("UCASE")} + }; + + sql_other = { + + }; +} +void loadSQLData(LanguageData &types, + LanguageData &keywords, + LanguageData &builtin, + LanguageData &literals, + LanguageData &other) { + if (!sqlDataInitialized) { + initSQLData(); + sqlDataInitialized = true; + } + types = sql_types; + keywords = sql_keywords; + builtin = sql_builtin; + literals = sql_literals; + other = sql_other; +} + +/********************************************************/ +/*** JSON DATA ***********************************/ +/********************************************************/ +static bool jsonDataInitialized = false; +static LanguageData json_keywords; +static LanguageData json_types; +static LanguageData json_literals; +static LanguageData json_builtin; +static LanguageData json_other; +void initJSONData() { + json_keywords = { + }; + + json_types = { + }; + + json_literals = { + {('f'), QLatin1String("false")}, + {('t'), QLatin1String("true")}, + {('n'), QLatin1String("null")} + }; + + json_builtin = { + }; + + json_other = { +}; +} +void loadJSONData(LanguageData &types, + LanguageData &keywords, + LanguageData &builtin, + LanguageData &literals, + LanguageData &other) { + if (!jsonDataInitialized) { + initJSONData(); + jsonDataInitialized = true; + } + types = json_types; + keywords = json_keywords; + builtin = json_builtin; + literals = json_literals; + other = json_other; +} + +/********************************************************/ +/*** CSS DATA ***********************************/ +/********************************************************/ +static bool cssDataInitialized = false; +static LanguageData css_keywords; +static LanguageData css_types; +static LanguageData css_literals; +static LanguageData css_builtin; +static LanguageData css_other; +void initCSSData() { + css_keywords = { + {'i', QLatin1String("important")}, + {'p', QLatin1String("px")}, + {'e', QLatin1String("em")} + }; + + css_types = { + {'a', QLatin1String("align")}, + {'c', QLatin1String("content")}, + {'i', QLatin1String("items")}, + {'s', QLatin1String("self")}, + {'a', QLatin1String("all")}, + {'a', QLatin1String("animation")}, + {'d', QLatin1String("delay")}, + {'d', QLatin1String("direction")}, + {'d', QLatin1String("duration")}, + {'f', QLatin1String("fill")}, + {'m', QLatin1String("mode")}, + {'i', QLatin1String("iteration")}, + {'c', QLatin1String("count")}, + {'n', QLatin1String("name")}, + {'p', QLatin1String("play")}, + {'s', QLatin1String("state")}, + {'t', QLatin1String("timing")}, + {'f', QLatin1String("function")}, + {'a', QLatin1String("azimuth")}, + {'b', QLatin1String("backface")}, + {'v', QLatin1String("visibility")}, + {'a', QLatin1String("attachment")}, + {'b', QLatin1String("blend")}, + {'m', QLatin1String("mode")}, + {'c', QLatin1String("clip")}, + {'c', QLatin1String("color")}, + {'i', QLatin1String("image")}, + {'o', QLatin1String("origin")}, + {'p', QLatin1String("position")}, + {'r', QLatin1String("repeat")}, + {'s', QLatin1String("size")}, + {'b', QLatin1String("background")}, + {'b', QLatin1String("bleed")}, + {'c', QLatin1String("color")}, + {'r', QLatin1String("radius")}, + {'r', QLatin1String("radius")}, + {'s', QLatin1String("style")}, + {'w', QLatin1String("width")}, + {'b', QLatin1String("bottom")}, + {'c', QLatin1String("collapse")}, + {'c', QLatin1String("color")}, + {'i', QLatin1String("image")}, + {'o', QLatin1String("outset")}, + {'r', QLatin1String("repeat")}, + {'s', QLatin1String("source")}, + {'s', QLatin1String("slice")}, + {'w', QLatin1String("width")}, + {'c', QLatin1String("color")}, + {'s', QLatin1String("style")}, + {'w', QLatin1String("width")}, + {'l', QLatin1String("left")}, + {'r', QLatin1String("radius")}, + {'c', QLatin1String("color")}, + {'s', QLatin1String("style")}, + {'w', QLatin1String("width")}, + {'r', QLatin1String("right")}, + {'s', QLatin1String("spacing")}, + {'s', QLatin1String("style")}, + {'c', QLatin1String("color")}, + {'l', QLatin1String("left")}, + {'r', QLatin1String("radius")}, + {'r', QLatin1String("radius")}, + {'s', QLatin1String("style")}, + {'w', QLatin1String("width")}, + {'t', QLatin1String("top")}, + {'w', QLatin1String("width")}, + {'b', QLatin1String("border")}, + {'b', QLatin1String("bottom")}, + {'b', QLatin1String("break")}, + {'b', QLatin1String("box")}, + {'s', QLatin1String("shadow")}, + {'b', QLatin1String("box")}, + {'s', QLatin1String("sizing")}, + {'a', QLatin1String("after")}, + {'b', QLatin1String("before")}, + {'b', QLatin1String("break")}, + {'i', QLatin1String("inside")}, + {'c', QLatin1String("caption")}, + {'s', QLatin1String("side")}, + {'c', QLatin1String("caret")}, + {'c', QLatin1String("color")}, + {'c', QLatin1String("clear")}, + {'c', QLatin1String("clip")}, + {'c', QLatin1String("color")}, + {'c', QLatin1String("columns")}, + {'c', QLatin1String("column")}, + {'c', QLatin1String("count")}, + {'f', QLatin1String("fill")}, + {'g', QLatin1String("gap")}, + {'r', QLatin1String("rule")}, + {'c', QLatin1String("color")}, + {'s', QLatin1String("style")}, + {'w', QLatin1String("width")}, + {'s', QLatin1String("span")}, + {'w', QLatin1String("width")}, + {'c', QLatin1String("content")}, + {'i', QLatin1String("increment")}, + {'c', QLatin1String("counter")}, + {'r', QLatin1String("reset")}, + {'a', QLatin1String("after")}, + {'b', QLatin1String("before")}, + {'c', QLatin1String("cue")}, + {'c', QLatin1String("cursor")}, + {'d', QLatin1String("direction")}, + {'d', QLatin1String("display")}, + {'e', QLatin1String("elevation")}, + {'e', QLatin1String("empty")}, + {'c', QLatin1String("cells")}, + {'f', QLatin1String("filter")}, + {'f', QLatin1String("flex")}, + {'b', QLatin1String("basis")}, + {'d', QLatin1String("direction")}, + {'f', QLatin1String("feature")}, + {'s', QLatin1String("settings")}, + {'f', QLatin1String("flex")}, + {'f', QLatin1String("flow")}, + {'g', QLatin1String("grow")}, + {'s', QLatin1String("shrink")}, + {'w', QLatin1String("wrap")}, + {'f', QLatin1String("float")}, + {'f', QLatin1String("family")}, + {'k', QLatin1String("kerning")}, + {'l', QLatin1String("language")}, + {'o', QLatin1String("override")}, + {'a', QLatin1String("adjust")}, + {'s', QLatin1String("size")}, + {'s', QLatin1String("stretch")}, + {'s', QLatin1String("style")}, + {'s', QLatin1String("synthesis")}, + {'v', QLatin1String("variant")}, + {'a', QLatin1String("alternates")}, + {'c', QLatin1String("caps")}, + {'e', QLatin1String("east")}, + {'a', QLatin1String("asian")}, + {'l', QLatin1String("ligatures")}, + {'n', QLatin1String("numeric")}, + {'p', QLatin1String("position")}, + {'w', QLatin1String("weight")}, + {'f', QLatin1String("font")}, + {'a', QLatin1String("area")}, + {'a', QLatin1String("auto")}, + {'c', QLatin1String("columns")}, + {'f', QLatin1String("flow")}, + {'r', QLatin1String("rows")}, + {'e', QLatin1String("end")}, + {'g', QLatin1String("gap")}, + {'s', QLatin1String("start")}, + {'c', QLatin1String("column")}, + {'g', QLatin1String("gap")}, + {'e', QLatin1String("end")}, + {'g', QLatin1String("gap")}, + {'s', QLatin1String("start")}, + {'r', QLatin1String("row")}, + {'a', QLatin1String("areas")}, + {'c', QLatin1String("columns")}, + {'r', QLatin1String("rows")}, + {'t', QLatin1String("template")}, + {'g', QLatin1String("grid")}, + {'h', QLatin1String("hanging")}, + {'p', QLatin1String("punctuation")}, + {'h', QLatin1String("height")}, + {'h', QLatin1String("hyphens")}, + {'i', QLatin1String("isolation")}, + {'j', QLatin1String("justify")}, + {'c', QLatin1String("content")}, + {'i', QLatin1String("items")}, + {'s', QLatin1String("self")}, + {'l', QLatin1String("leftimage")}, + {'l', QLatin1String("letter")}, + {'s', QLatin1String("spacing")}, + {'b', QLatin1String("break")}, + {'l', QLatin1String("line")}, + {'s', QLatin1String("style")}, + {'i', QLatin1String("image")}, + {'s', QLatin1String("style")}, + {'p', QLatin1String("position")}, + {'t', QLatin1String("type")}, + {'l', QLatin1String("list")}, + {'s', QLatin1String("style")}, + {'b', QLatin1String("bottom")}, + {'l', QLatin1String("left")}, + {'r', QLatin1String("right")}, + {'t', QLatin1String("top")}, + {'m', QLatin1String("margin")}, + {'m', QLatin1String("marker")}, + {'o', QLatin1String("offset")}, + {'m', QLatin1String("marks")}, + {'m', QLatin1String("max")}, + {'h', QLatin1String("height")}, + {'w', QLatin1String("width")}, + {'m', QLatin1String("min")}, + {'m', QLatin1String("mix")}, + {'b', QLatin1String("blend")}, + {'m', QLatin1String("mode")}, + {'n', QLatin1String("nav")}, + {'u', QLatin1String("up")}, + {'d', QLatin1String("down")}, + {'l', QLatin1String("left")}, + {'r', QLatin1String("right")}, + {'o', QLatin1String("opacity")}, + {'o', QLatin1String("order")}, + {'o', QLatin1String("orphans")}, + {'c', QLatin1String("color")}, + {'o', QLatin1String("offset")}, + {'s', QLatin1String("style")}, + {'w', QLatin1String("width")}, + {'o', QLatin1String("outline")}, + {'w', QLatin1String("wrap")}, + {'o', QLatin1String("overflow")}, + {'b', QLatin1String("bottom")}, + {'l', QLatin1String("left")}, + {'r', QLatin1String("right")}, + {'t', QLatin1String("top")}, + {'p', QLatin1String("padding")}, + {'b', QLatin1String("break")}, + {'a', QLatin1String("after")}, + {'b', QLatin1String("before")}, + {'i', QLatin1String("inside")}, + {'p', QLatin1String("page")}, + {'a', QLatin1String("after")}, + {'b', QLatin1String("before")}, + {'p', QLatin1String("pause")}, + {'p', QLatin1String("perspective")}, + {'o', QLatin1String("origin")}, + {'r', QLatin1String("range")}, + {'p', QLatin1String("pitch")}, + {'c', QLatin1String("content")}, + {'i', QLatin1String("items")}, + {'p', QLatin1String("place")}, + {'s', QLatin1String("self")}, + {'p', QLatin1String("play")}, + {'d', QLatin1String("during")}, + {'p', QLatin1String("position")}, + {'q', QLatin1String("quotes")}, + {'r', QLatin1String("resize")}, + {'r', QLatin1String("rest")}, + {'a', QLatin1String("after")}, + {'b', QLatin1String("before")}, + {'r', QLatin1String("rest")}, + {'r', QLatin1String("richness")}, + {'r', QLatin1String("right")}, + {'s', QLatin1String("size")}, + {'h', QLatin1String("header")}, + {'n', QLatin1String("numeral")}, + {'s', QLatin1String("speak")}, + {'p', QLatin1String("punctuation")}, + {'s', QLatin1String("speak")}, + {'s', QLatin1String("speech")}, + {'r', QLatin1String("rate")}, + {'s', QLatin1String("stress")}, + {'t', QLatin1String("tab")}, + {'s', QLatin1String("size")}, + {'t', QLatin1String("table")}, + {'l', QLatin1String("layout")}, + {'t', QLatin1String("text")}, + {'a', QLatin1String("align")}, + {'l', QLatin1String("last")}, + {'d', QLatin1String("decoration")}, + {'c', QLatin1String("color")}, + {'l', QLatin1String("line")}, + {'s', QLatin1String("skip")}, + {'s', QLatin1String("style")}, + {'i', QLatin1String("indent")}, + {'o', QLatin1String("overflow")}, + {'s', QLatin1String("shadow")}, + {'t', QLatin1String("transform")}, + {'u', QLatin1String("underline")}, + {'p', QLatin1String("position")}, + {'t', QLatin1String("top")}, + {'t', QLatin1String("transform")}, + {'o', QLatin1String("origin")}, + {'s', QLatin1String("style")}, + {'t', QLatin1String("transition")}, + {'d', QLatin1String("delay")}, + {'d', QLatin1String("duration")}, + {'p', QLatin1String("property")}, + {'t', QLatin1String("timing")}, + {'f', QLatin1String("function")}, + {'u', QLatin1String("unicode")}, + {'b', QLatin1String("bidi")}, + {'v', QLatin1String("vertical")}, + {'a', QLatin1String("align")}, + {'v', QLatin1String("visibility")}, + {'b', QLatin1String("balance")}, + {'d', QLatin1String("duration")}, + {'f', QLatin1String("family")}, + {'p', QLatin1String("pitch")}, + {'r', QLatin1String("range")}, + {'r', QLatin1String("rate")}, + {'s', QLatin1String("stress")}, + {'v', QLatin1String("volume")}, + {'v', QLatin1String("voice")}, + {'v', QLatin1String("volume")}, + {'w', QLatin1String("white")}, + {'s', QLatin1String("space")}, + {'w', QLatin1String("widows")}, + {'w', QLatin1String("width")}, + {'w', QLatin1String("will")}, + {'c', QLatin1String("change")}, + {'w', QLatin1String("word")}, + {'b', QLatin1String("break")}, + {'s', QLatin1String("spacing")}, + {'w', QLatin1String("wrap")}, + {'x', QLatin1String("x")}, + {'y', QLatin1String("y")}, + {'z', QLatin1String("z")}, + {'i', QLatin1String("index")}, + {'r', QLatin1String("rgb")}, + {'s', QLatin1String("sans")}, + {'s', QLatin1String("serif")}, + {'n', QLatin1String("normal")} + }; + + css_literals = { + }; + + css_builtin = { + }; + + css_other = { + }; +} +void loadCSSData(LanguageData &types, + LanguageData &keywords, + LanguageData &builtin, + LanguageData &literals, + LanguageData &other) { + if (!cssDataInitialized) { + initCSSData(); + cssDataInitialized = true; + } + types = css_types; + keywords = css_keywords; + builtin = css_builtin; + literals = css_literals; + other = css_other; +} + +/********************************************************/ +/*** Typescript DATA *********************************/ +/********************************************************/ +static bool typescriptDataInitialized = false; +static LanguageData typescript_keywords; +static LanguageData typescript_types; +static LanguageData typescript_literals; +static LanguageData typescript_builtin; +static LanguageData typescript_other; +void initTypescriptData() { + typescript_keywords = { + {'i', QLatin1String("in")}, + {'i', QLatin1String("if")}, + {'f', QLatin1String("for")}, + {'w', QLatin1String("while")}, + {'f', QLatin1String("finally")}, + {'n', QLatin1String("new")}, + {'f', QLatin1String("function")}, + {'d', QLatin1String("do")}, + {'r', QLatin1String("return")}, + {'v', QLatin1String("void")}, + {'e', QLatin1String("else")}, + {'b', QLatin1String("break")}, + {'c', QLatin1String("catch")}, + {'i', QLatin1String("instanceof")}, + {'w', QLatin1String("with")}, + {'t', QLatin1String("throw")}, + {'c', QLatin1String("case")}, + {'d', QLatin1String("default")}, + {'t', QLatin1String("try")}, + {'t', QLatin1String("this")}, + {'s', QLatin1String("switch")}, + {'c', QLatin1String("continue")}, + {'t', QLatin1String("typeof")}, + {'d', QLatin1String("delete")}, + {'l', QLatin1String("let")}, + {'y', QLatin1String("yield")}, + {'c', QLatin1String("const")}, + {'p', QLatin1String("public")}, + {'p', QLatin1String("private")}, + {'p', QLatin1String("protected")}, + {'g', QLatin1String("get")}, + {'s', QLatin1String("set")}, + {'s', QLatin1String("super")}, + {'s', QLatin1String("static")}, + {'i', QLatin1String("implements")}, + {'e', QLatin1String("export")}, + {'i', QLatin1String("import")}, + {'d', QLatin1String("declare")}, + {'t', QLatin1String("type")}, + {'n', QLatin1String("namespace")}, + {'a', QLatin1String("abstract")}, + {'a', QLatin1String("as")}, + {'f', QLatin1String("from")}, + {'e', QLatin1String("extends")}, + {'a', QLatin1String("async")}, + {'a', QLatin1String("await")} + }; + + typescript_types = { + {'v', QLatin1String("var")}, + {'c', QLatin1String("class")}, + {'e', QLatin1String("enum")} + }; + + typescript_literals = { + {('f'), QLatin1String("false")}, + {('n'), QLatin1String("null")}, + {('t'), QLatin1String("true")}, + {('u'), QLatin1String("undefined")}, + {('N'), QLatin1String("NaN")}, + {('I'), QLatin1String("Infinity")} + }; + + typescript_builtin = { + {'e', QLatin1String("eval")}, + {'i', QLatin1String("isFinite")}, + {'i', QLatin1String("isNaN")}, + {'p', QLatin1String("parseFloat")}, + {'p', QLatin1String("parseInt")}, + {'d', QLatin1String("decodeURI")}, + {'d', QLatin1String("decodeURIComponent")}, + {'e', QLatin1String("encodeURI")}, + {'e', QLatin1String("encodeURIComponent")}, + {'e', QLatin1String("escape")}, + {'u', QLatin1String("unescape")}, + {'O', QLatin1String("Object")}, + {'F', QLatin1String("Function")}, + {'B', QLatin1String("Boolean")}, + {'E', QLatin1String("Error")}, + {'E', QLatin1String("EvalError")}, + {'I', QLatin1String("InternalError")}, + {'R', QLatin1String("RangeError")}, + {'R', QLatin1String("ReferenceError")}, + {'S', QLatin1String("StopIteration")}, + {'S', QLatin1String("SyntaxError")}, + {'T', QLatin1String("TypeError")}, + {'U', QLatin1String("URIError")}, + {'N', QLatin1String("Number")}, + {'M', QLatin1String("Math")}, + {'D', QLatin1String("Date")}, + {'S', QLatin1String("String")}, + {'R', QLatin1String("RegExp")}, + {'A', QLatin1String("Array")}, + {'F', QLatin1String("Float32Array")}, + {'F', QLatin1String("Float64Array")}, + {'I', QLatin1String("Int16Array")}, + {'I', QLatin1String("Int32Array")}, + {'I', QLatin1String("Int8Array")}, + {'U', QLatin1String("Uint16Array")}, + {'U', QLatin1String("Uint32Array")}, + {'U', QLatin1String("Uint8Array")}, + {'U', QLatin1String("Uint8ClampedArray")}, + {'A', QLatin1String("ArrayBuffer")}, + {'D', QLatin1String("DataView")}, + {'J', QLatin1String("JSON")}, + {'I', QLatin1String("Intl")}, + {'a', QLatin1String("arguments")}, + {'r', QLatin1String("require")}, + {'m', QLatin1String("module")}, + {'c', QLatin1String("console")}, + {'w', QLatin1String("window")}, + {'d', QLatin1String("document")}, + {'a', QLatin1String("any")}, + {'n', QLatin1String("number")}, + {'b', QLatin1String("boolean")}, + {'s', QLatin1String("string")}, + {'v', QLatin1String("void")}, + {'P', QLatin1String("Promise")} + }; + + typescript_other = { +}; +} +void loadTypescriptData(LanguageData &types, + LanguageData &keywords, + LanguageData &builtin, + LanguageData &literals, + LanguageData &other) { + if (!typescriptDataInitialized) { + initTypescriptData(); + typescriptDataInitialized = true; + } + types = typescript_types; + keywords = typescript_keywords; + builtin = typescript_builtin; + literals = typescript_literals; + other = typescript_other; +} + +/********************************************************/ +/*** YAML DATA ***************************************/ +/********************************************************/ +static bool YAMLDataInitialized = false; +static LanguageData YAML_keywords; +static LanguageData YAML_types; +static LanguageData YAML_literals; +static LanguageData YAML_builtin; +static LanguageData YAML_other; +void initYAMLData() { + YAML_keywords = {}; + YAML_types = {}; + YAML_literals = { + {('f'), QLatin1String("false")}, + {('t'), QLatin1String("true")}, + {('n'), QLatin1String("null")}, + }; + + YAML_builtin = {}; + YAML_other = {}; +} +void loadYAMLData(LanguageData &types, + LanguageData &keywords, + LanguageData &builtin, + LanguageData &literals, + LanguageData &other) { + if (!YAMLDataInitialized) { + initYAMLData(); + YAMLDataInitialized = true; + } + types = YAML_types; + keywords = YAML_keywords; + builtin = YAML_builtin; + literals = YAML_literals; + other = YAML_other; +} + +/********************************************************/ +/*** VEX DATA ***************************************/ +/********************************************************/ +static bool vexDataInitialized = false; +static LanguageData vex_keywords; +static LanguageData vex_types; +static LanguageData vex_literals; +static LanguageData vex_builtin; +static LanguageData vex_other; +void initVEXData() { + vex_keywords = { + {'b', QLatin1String("break")}, + {'c', QLatin1String("continue")}, + {'d', QLatin1String("do")}, + {'e', QLatin1String("else")}, + {'f', QLatin1String("for")}, + {'f', QLatin1String("foreach")}, + {'f', QLatin1String("forpoints")}, + {'f', QLatin1String("function")}, + {'g', QLatin1String("gather")}, + {'i', QLatin1String("if")}, + {'i', QLatin1String("illuminance")}, + {'r', QLatin1String("return")}, + {'w', QLatin1String("while")} + }; + vex_types = { + {'b', QLatin1String("bsdf")}, + {'c', QLatin1String("char")}, + {'c', QLatin1String("color")}, + {'f', QLatin1String("float")}, + {'i', QLatin1String("int")}, + {'i', QLatin1String("integer")}, + {'m', QLatin1String("matrix")}, + {'m', QLatin1String("matrix2")}, + {'m', QLatin1String("matrix3")}, + {'m', QLatin1String("matrix4")}, + {'n', QLatin1String("normal")}, + {'p', QLatin1String("point")}, + {'s', QLatin1String("string")}, + {'s', QLatin1String("struct")}, + {'t', QLatin1String("typedef")}, + {'u', QLatin1String("union")}, + {'v', QLatin1String("vector")}, + {'v', QLatin1String("vector2")}, + {'v', QLatin1String("vector4")}, + {'v', QLatin1String("void")}, + }; + vex_literals = { + {('f'), QLatin1String("false")}, + {('t'), QLatin1String("true")}, + {('n'), QLatin1String("null")}, + }; + + vex_builtin = { + {'D', QLatin1String("Du")}, + {'D', QLatin1String("Dv")}, + {'D', QLatin1String("Dw")}, + {'a', QLatin1String("abs")}, + {'a', QLatin1String("accessframe")}, + {'a', QLatin1String("acos")}, + {'a', QLatin1String("addattrib")}, + {'a', QLatin1String("addattribute")}, + {'a', QLatin1String("adddetailattrib")}, + {'a', QLatin1String("addgroup")}, + {'a', QLatin1String("addpoint")}, + {'a', QLatin1String("addpointattrib")}, + {'a', QLatin1String("addprim")}, + {'a', QLatin1String("addprimattrib")}, + {'a', QLatin1String("addvariablename")}, + {'a', QLatin1String("addvertex")}, + {'a', QLatin1String("addvertexattrib")}, + {'a', QLatin1String("addvisualizer")}, + {'a', QLatin1String("agentaddclip")}, + {'a', QLatin1String("agentclipcatalog")}, + {'a', QLatin1String("agentclipchannel")}, + {'a', QLatin1String("agentcliplength")}, + {'a', QLatin1String("agentclipnames")}, + {'a', QLatin1String("agentclipsample")}, + {'a', QLatin1String("agentclipsamplelocal")}, + {'a', QLatin1String("agentclipsamplerate")}, + {'a', QLatin1String("agentclipsampleworld")}, + {'a', QLatin1String("agentcliptimes")}, + {'a', QLatin1String("agentclipweights")}, + {'a', QLatin1String("agentcollisionlayer")}, + {'a', QLatin1String("agentcurrentlayer")}, + {'a', QLatin1String("agentlayerbindings")}, + {'a', QLatin1String("agentlayers")}, + {'a', QLatin1String("agentlayershapes")}, + {'a', QLatin1String("agentlocaltransform")}, + {'a', QLatin1String("agentlocaltransforms")}, + {'a', QLatin1String("agentrigchildren")}, + {'a', QLatin1String("agentrigfind")}, + {'a', QLatin1String("agentrigparent")}, + {'a', QLatin1String("agenttransformcount")}, + {'a', QLatin1String("agenttransformnames")}, + {'a', QLatin1String("agenttransformtolocal")}, + {'a', QLatin1String("agenttransformtoworld")}, + {'a', QLatin1String("agentworldtransform")}, + {'a', QLatin1String("agentworldtransforms")}, + {'a', QLatin1String("albedo")}, + {'a', QLatin1String("alphaname")}, + {'a', QLatin1String("ambient")}, + {'a', QLatin1String("anoise")}, + {'a', QLatin1String("append")}, + {'a', QLatin1String("area")}, + {'a', QLatin1String("argsort")}, + {'a', QLatin1String("array")}, + {'a', QLatin1String("ashikhmin")}, + {'a', QLatin1String("asin")}, + {'a', QLatin1String("assert_enabled")}, + {'a', QLatin1String("assign")}, + {'a', QLatin1String("atan")}, + {'a', QLatin1String("atan2")}, + {'a', QLatin1String("atof")}, + {'a', QLatin1String("atoi")}, + {'a', QLatin1String("atten")}, + {'a', QLatin1String("attrib")}, + {'a', QLatin1String("attribclass")}, + {'a', QLatin1String("attribsize")}, + {'a', QLatin1String("attribtype")}, + {'a', QLatin1String("attribtypeinfo")}, + {'a', QLatin1String("avg")}, + {'b', QLatin1String("binput")}, + {'b', QLatin1String("blackbody")}, + {'b', QLatin1String("blinn")}, + {'b', QLatin1String("blinnBRDF")}, + {'b', QLatin1String("bouncelabel")}, + {'b', QLatin1String("bouncemask")}, + {'b', QLatin1String("bumpmap")}, + {'b', QLatin1String("bumpmapA")}, + {'b', QLatin1String("bumpmapB")}, + {'b', QLatin1String("bumpmapG")}, + {'b', QLatin1String("bumpmapL")}, + {'b', QLatin1String("bumpmapR")}, + {'b', QLatin1String("bumpname")}, + {'c', QLatin1String("cbrt")}, + {'c', QLatin1String("ceil")}, + {'c', QLatin1String("ch")}, + {'c', QLatin1String("ch3")}, + {'c', QLatin1String("ch4")}, + {'c', QLatin1String("chend")}, + {'c', QLatin1String("chendf")}, + {'c', QLatin1String("chendt")}, + {'c', QLatin1String("chf")}, + {'c', QLatin1String("chi")}, + {'c', QLatin1String("chinput")}, + {'c', QLatin1String("chname")}, + {'c', QLatin1String("chnumchan")}, + {'c', QLatin1String("chp")}, + {'c', QLatin1String("chr")}, + {'c', QLatin1String("chramp")}, + {'c', QLatin1String("chrate")}, + {'c', QLatin1String("chs")}, + {'c', QLatin1String("chsraw")}, + {'c', QLatin1String("chstart")}, + {'c', QLatin1String("chstartf")}, + {'c', QLatin1String("chstartt")}, + {'c', QLatin1String("chv")}, + {'c', QLatin1String("cinput")}, + {'c', QLatin1String("ckspline")}, + {'c', QLatin1String("clamp")}, + {'c', QLatin1String("clip")}, + {'c', QLatin1String("colormap")}, + {'c', QLatin1String("colorname")}, + {'c', QLatin1String("computenormal")}, + {'c', QLatin1String("concat")}, + {'c', QLatin1String("cone")}, + {'c', QLatin1String("cos")}, + {'c', QLatin1String("cosh")}, + {'c', QLatin1String("cracktransform")}, + {'c', QLatin1String("cross")}, + {'c', QLatin1String("cspline")}, + {'c', QLatin1String("ctransform")}, + {'c', QLatin1String("curlnoise")}, + {'c', QLatin1String("curlnoise2d")}, + {'c', QLatin1String("curlxnoise")}, + {'c', QLatin1String("curlxnoise2d")}, + {'c', QLatin1String("cvex_bsdf")}, + {'d', QLatin1String("degrees")}, + {'d', QLatin1String("depthmap")}, + {'d', QLatin1String("depthname")}, + {'d', QLatin1String("detail")}, + {'d', QLatin1String("detailattrib")}, + {'d', QLatin1String("detailattribsize")}, + {'d', QLatin1String("detailattribtype")}, + {'d', QLatin1String("detailattribtypeinfo")}, + {'d', QLatin1String("detailintrinsic")}, + {'d', QLatin1String("determinant")}, + {'d', QLatin1String("diffuse")}, + {'d', QLatin1String("diffuseBRDF")}, + {'d', QLatin1String("dihedral")}, + {'d', QLatin1String("dimport")}, + {'d', QLatin1String("distance")}, + {'d', QLatin1String("distance2")}, + {'d', QLatin1String("dot")}, + {'d', QLatin1String("dsmpixel")}, + {'e', QLatin1String("eigenvalues")}, + {'e', QLatin1String("endswith")}, + {'e', QLatin1String("environment")}, + {'e', QLatin1String("erf")}, + {'e', QLatin1String("erf_inv")}, + {'e', QLatin1String("erfc")}, + {'e', QLatin1String("error")}, + {'e', QLatin1String("eulertoquaternion")}, + {'e', QLatin1String("eval_bsdf")}, + {'e', QLatin1String("exp")}, + {'e', QLatin1String("expand_udim")}, + {'e', QLatin1String("expandpointgroup")}, + {'e', QLatin1String("expandprimgroup")}, + {'f', QLatin1String("fastshadow")}, + {'f', QLatin1String("filamentsample")}, + {'f', QLatin1String("file_stat")}, + {'f', QLatin1String("filtershadow")}, + {'f', QLatin1String("filterstep")}, + {'f', QLatin1String("find")}, + {'f', QLatin1String("findattribval")}, + {'f', QLatin1String("findattribvalcount")}, + {'f', QLatin1String("finput")}, + {'f', QLatin1String("fit")}, + {'f', QLatin1String("fit01")}, + {'f', QLatin1String("fit10")}, + {'f', QLatin1String("fit11")}, + {'f', QLatin1String("floor")}, + {'f', QLatin1String("flownoise")}, + {'f', QLatin1String("flowpnoise")}, + {'f', QLatin1String("frac")}, + {'f', QLatin1String("fresnel")}, + {'f', QLatin1String("fromNDC")}, + {'f', QLatin1String("frontface")}, + {'f', QLatin1String("fuzzify")}, + {'f', QLatin1String("fuzzy_and")}, + {'f', QLatin1String("fuzzy_defuzz_centroid")}, + {'f', QLatin1String("fuzzy_nand")}, + {'f', QLatin1String("fuzzy_nor")}, + {'f', QLatin1String("fuzzy_not")}, + {'f', QLatin1String("fuzzy_nxor")}, + {'f', QLatin1String("fuzzy_or")}, + {'f', QLatin1String("fuzzy_xor")}, + {'g', QLatin1String("geoself")}, + {'g', QLatin1String("getattrib")}, + {'g', QLatin1String("getattribute")}, + {'g', QLatin1String("getbbox")}, + {'g', QLatin1String("getblurP")}, + {'g', QLatin1String("getbounces")}, + {'g', QLatin1String("getbounds")}, + {'g', QLatin1String("getcomp")}, + {'g', QLatin1String("getcomponents")}, + {'g', QLatin1String("getderiv")}, + {'g', QLatin1String("getfogname")}, + {'g', QLatin1String("getglobalraylevel")}, + {'g', QLatin1String("getlight")}, + {'g', QLatin1String("getlightid")}, + {'g', QLatin1String("getlightname")}, + {'g', QLatin1String("getlights")}, + {'g', QLatin1String("getlightscope")}, + {'g', QLatin1String("getmaterial")}, + {'g', QLatin1String("getobjectname")}, + {'g', QLatin1String("getphotonlight")}, + {'g', QLatin1String("getpointbbox")}, + {'g', QLatin1String("getprimid")}, + {'g', QLatin1String("getptextureid")}, + {'g', QLatin1String("getraylevel")}, + {'g', QLatin1String("getrayweight")}, + {'g', QLatin1String("getsamplestore")}, + {'g', QLatin1String("getscope")}, + {'g', QLatin1String("getsmoothP")}, + {'g', QLatin1String("getspace")}, + {'g', QLatin1String("getuvobjects")}, + {'g', QLatin1String("getuvtangents")}, + {'g', QLatin1String("gradient")}, + {'h', QLatin1String("hair")}, + {'h', QLatin1String("hasattrib")}, + {'h', QLatin1String("hasdetailattrib")}, + {'h', QLatin1String("haslight")}, + {'h', QLatin1String("hasplane")}, + {'h', QLatin1String("haspointattrib")}, + {'h', QLatin1String("hasprimattrib")}, + {'h', QLatin1String("hasvertexattrib")}, + {'h', QLatin1String("hedge_dstpoint")}, + {'h', QLatin1String("hedge_dstvertex")}, + {'h', QLatin1String("hedge_equivcount")}, + {'h', QLatin1String("hedge_isequiv")}, + {'h', QLatin1String("hedge_isprimary")}, + {'h', QLatin1String("hedge_isvalid")}, + {'h', QLatin1String("hedge_next")}, + {'h', QLatin1String("hedge_nextequiv")}, + {'h', QLatin1String("hedge_postdstpoint")}, + {'h', QLatin1String("hedge_postdstvertex")}, + {'h', QLatin1String("hedge_presrcpoint")}, + {'h', QLatin1String("hedge_presrcvertex")}, + {'h', QLatin1String("hedge_prev")}, + {'h', QLatin1String("hedge_prim")}, + {'h', QLatin1String("hedge_primary")}, + {'h', QLatin1String("hedge_srcpoint")}, + {'h', QLatin1String("hedge_srcvertex")}, + {'h', QLatin1String("henyeygreenstein")}, + {'h', QLatin1String("hscript_noise")}, + {'h', QLatin1String("hscript_rand")}, + {'h', QLatin1String("hscript_snoise")}, + {'h', QLatin1String("hscript_sturb")}, + {'h', QLatin1String("hscript_turb")}, + {'h', QLatin1String("hsvtorgb")}, + {'i', QLatin1String("iaspect")}, + {'i', QLatin1String("ichname")}, + {'i', QLatin1String("ident")}, + {'i', QLatin1String("idtopoint")}, + {'i', QLatin1String("idtoprim")}, + {'i', QLatin1String("iend")}, + {'i', QLatin1String("iendtime")}, + {'i', QLatin1String("ihasplane")}, + {'i', QLatin1String("import")}, + {'i', QLatin1String("ingroup")}, + {'i', QLatin1String("inpointgroup")}, + {'i', QLatin1String("inprimgroup")}, + {'i', QLatin1String("insert")}, + {'i', QLatin1String("instance")}, + {'i', QLatin1String("interpolate")}, + {'i', QLatin1String("intersect")}, + {'i', QLatin1String("intersect_all")}, + {'i', QLatin1String("intersect_lights")}, + {'i', QLatin1String("inumplanes")}, + {'i', QLatin1String("invert")}, + {'i', QLatin1String("invertexgroup")}, + {'i', QLatin1String("iplaneindex")}, + {'i', QLatin1String("iplanename")}, + {'i', QLatin1String("iplanesize")}, + {'i', QLatin1String("irate")}, + {'i', QLatin1String("irradiance")}, + {'i', QLatin1String("isalpha")}, + {'i', QLatin1String("isbound")}, + {'i', QLatin1String("isconnected")}, + {'i', QLatin1String("isdigit")}, + {'i', QLatin1String("isfinite")}, + {'i', QLatin1String("isfogray")}, + {'i', QLatin1String("isframes")}, + {'i', QLatin1String("isnan")}, + {'i', QLatin1String("isotropic")}, + {'i', QLatin1String("israytracing")}, + {'i', QLatin1String("issamples")}, + {'i', QLatin1String("isseconds")}, + {'i', QLatin1String("isshadowray")}, + {'i', QLatin1String("istart")}, + {'i', QLatin1String("istarttime")}, + {'i', QLatin1String("isuvrendering")}, + {'i', QLatin1String("isvalidindex")}, + {'i', QLatin1String("isvarying")}, + {'i', QLatin1String("itoa")}, + {'i', QLatin1String("ixres")}, + {'i', QLatin1String("iyres")}, + {'j', QLatin1String("join")}, + {'k', QLatin1String("kspline")}, + {'l', QLatin1String("len")}, + {'l', QLatin1String("length")}, + {'l', QLatin1String("length2")}, + {'l', QLatin1String("lerp")}, + {'l', QLatin1String("lightid")}, + {'l', QLatin1String("limit_sample_space")}, + {'l', QLatin1String("limport")}, + {'l', QLatin1String("lkspline")}, + {'l', QLatin1String("log")}, + {'l', QLatin1String("log10")}, + {'l', QLatin1String("lookat")}, + {'l', QLatin1String("lspline")}, + {'l', QLatin1String("lstrip")}, + {'l', QLatin1String("luminance")}, + {'l', QLatin1String("lumname")}, + {'m', QLatin1String("makebasis")}, + {'m', QLatin1String("maketransform")}, + {'m', QLatin1String("maskname")}, + {'m', QLatin1String("match")}, + {'m', QLatin1String("matchvex_blinn")}, + {'m', QLatin1String("matchvex_specular")}, + {'m', QLatin1String("mattrib")}, + {'m', QLatin1String("max")}, + {'m', QLatin1String("mdensity")}, + {'m', QLatin1String("metaimport")}, + {'m', QLatin1String("metamarch")}, + {'m', QLatin1String("metanext")}, + {'m', QLatin1String("metastart")}, + {'m', QLatin1String("metaweight")}, + {'m', QLatin1String("min")}, + {'m', QLatin1String("minpos")}, + {'m', QLatin1String("mspace")}, + {'n', QLatin1String("nametopoint")}, + {'n', QLatin1String("nametoprim")}, + {'n', QLatin1String("nbouncetypes")}, + {'n', QLatin1String("nearpoint")}, + {'n', QLatin1String("nearpoints")}, + {'n', QLatin1String("neighbour")}, + {'n', QLatin1String("neighbourcount")}, + {'n', QLatin1String("neighbours")}, + {'n', QLatin1String("newgroup")}, + {'n', QLatin1String("newsampler")}, + {'n', QLatin1String("nextsample")}, + {'n', QLatin1String("ninput")}, + {'n', QLatin1String("noise")}, + {'n', QLatin1String("noised")}, + {'n', QLatin1String("normal_bsdf")}, + {'n', QLatin1String("normalize")}, + {'n', QLatin1String("normalname")}, + {'n', QLatin1String("npoints")}, + {'n', QLatin1String("npointsgroup")}, + {'n', QLatin1String("nprimitives")}, + {'n', QLatin1String("nprimitivesgroup")}, + {'n', QLatin1String("nrandom")}, + {'n', QLatin1String("ntransform")}, + {'n', QLatin1String("nuniqueval")}, + {'n', QLatin1String("nvertices")}, + {'n', QLatin1String("nverticesgroup")}, + {'o', QLatin1String("occlusion")}, + {'o', QLatin1String("onoise")}, + {'o', QLatin1String("opdigits")}, + {'o', QLatin1String("opend")}, + {'o', QLatin1String("opfullpath")}, + {'o', QLatin1String("opstart")}, + {'o', QLatin1String("optransform")}, + {'o', QLatin1String("ord")}, + {'o', QLatin1String("osd_facecount")}, + {'o', QLatin1String("osd_firstpatch")}, + {'o', QLatin1String("osd_limitsurface")}, + {'o', QLatin1String("osd_limitsurfacevertex")}, + {'o', QLatin1String("osd_patchcount")}, + {'o', QLatin1String("osd_patches")}, + {'o', QLatin1String("outerproduct")}, + {'o', QLatin1String("ow_nspace")}, + {'o', QLatin1String("ow_space")}, + {'o', QLatin1String("ow_vspace")}, + {'p', QLatin1String("pack_inttosafefloat")}, + {'p', QLatin1String("pathtrace")}, + {'p', QLatin1String("pcclose")}, + {'p', QLatin1String("pcconvex")}, + {'p', QLatin1String("pcexport")}, + {'p', QLatin1String("pcfarthest")}, + {'p', QLatin1String("pcfilter")}, + {'p', QLatin1String("pcfind")}, + {'p', QLatin1String("pcfind_radius")}, + {'p', QLatin1String("pcgenerate")}, + {'p', QLatin1String("pcimport")}, + {'p', QLatin1String("pcimportbyidx3")}, + {'p', QLatin1String("pcimportbyidx4")}, + {'p', QLatin1String("pcimportbyidxf")}, + {'p', QLatin1String("pcimportbyidxi")}, + {'p', QLatin1String("pcimportbyidxp")}, + {'p', QLatin1String("pcimportbyidxs")}, + {'p', QLatin1String("pcimportbyidxv")}, + {'p', QLatin1String("pciterate")}, + {'p', QLatin1String("pcnumfound")}, + {'p', QLatin1String("pcopen")}, + {'p', QLatin1String("pcopenlod")}, + {'p', QLatin1String("pcsampleleaf")}, + {'p', QLatin1String("pcsize")}, + {'p', QLatin1String("pcunshaded")}, + {'p', QLatin1String("pcwrite")}, + {'p', QLatin1String("pgfind")}, + {'p', QLatin1String("phong")}, + {'p', QLatin1String("phongBRDF")}, + {'p', QLatin1String("phonglobe")}, + {'p', QLatin1String("photonmap")}, + {'p', QLatin1String("planeindex")}, + {'p', QLatin1String("planename")}, + {'p', QLatin1String("planesize")}, + {'p', QLatin1String("pluralize")}, + {'p', QLatin1String("pnoise")}, + {'p', QLatin1String("point")}, + {'p', QLatin1String("pointattrib")}, + {'p', QLatin1String("pointattribsize")}, + {'p', QLatin1String("pointattribtype")}, + {'p', QLatin1String("pointattribtypeinfo")}, + {'p', QLatin1String("pointedge")}, + {'p', QLatin1String("pointhedge")}, + {'p', QLatin1String("pointhedgenext")}, + {'p', QLatin1String("pointname")}, + {'p', QLatin1String("pointprims")}, + {'p', QLatin1String("pointvertex")}, + {'p', QLatin1String("pointvertices")}, + {'p', QLatin1String("polardecomp")}, + {'p', QLatin1String("pop")}, + {'p', QLatin1String("pow")}, + {'p', QLatin1String("prim")}, + {'p', QLatin1String("prim_attribute")}, + {'p', QLatin1String("prim_normal")}, + {'p', QLatin1String("primattrib")}, + {'p', QLatin1String("primattribsize")}, + {'p', QLatin1String("primattribtype")}, + {'p', QLatin1String("primattribtypeinfo")}, + {'p', QLatin1String("primhedge")}, + {'p', QLatin1String("primintrinsic")}, + {'p', QLatin1String("primpoint")}, + {'p', QLatin1String("primpoints")}, + {'p', QLatin1String("primuv")}, + {'p', QLatin1String("primvertex")}, + {'p', QLatin1String("primvertexcount")}, + {'p', QLatin1String("primvertices")}, + {'p', QLatin1String("print_once")}, + {'p', QLatin1String("printf")}, + {'p', QLatin1String("product")}, + {'p', QLatin1String("ptexture")}, + {'p', QLatin1String("ptlined")}, + {'p', QLatin1String("ptransform")}, + {'p', QLatin1String("push")}, + {'q', QLatin1String("qconvert")}, + {'q', QLatin1String("qdistance")}, + {'q', QLatin1String("qinvert")}, + {'q', QLatin1String("qmultiply")}, + {'q', QLatin1String("qrotate")}, + {'q', QLatin1String("quaternion")}, + {'r', QLatin1String("radians")}, + {'r', QLatin1String("rand")}, + {'r', QLatin1String("random")}, + {'r', QLatin1String("random_fhash")}, + {'r', QLatin1String("random_ihash")}, + {'r', QLatin1String("random_shash")}, + {'r', QLatin1String("random_sobol")}, + {'r', QLatin1String("rawbumpmap")}, + {'r', QLatin1String("rawbumpmapA")}, + {'r', QLatin1String("rawbumpmapB")}, + {'r', QLatin1String("rawbumpmapG")}, + {'r', QLatin1String("rawbumpmapL")}, + {'r', QLatin1String("rawbumpmapR")}, + {'r', QLatin1String("rawcolormap")}, + {'r', QLatin1String("rayhittest")}, + {'r', QLatin1String("rayimport")}, + {'r', QLatin1String("re_find")}, + {'r', QLatin1String("re_findall")}, + {'r', QLatin1String("re_match")}, + {'r', QLatin1String("re_replace")}, + {'r', QLatin1String("re_split")}, + {'r', QLatin1String("reflect")}, + {'r', QLatin1String("reflectlight")}, + {'r', QLatin1String("refract")}, + {'r', QLatin1String("refractlight")}, + {'r', QLatin1String("relativepath")}, + {'r', QLatin1String("relbbox")}, + {'r', QLatin1String("relpointbbox")}, + {'r', QLatin1String("removegroup")}, + {'r', QLatin1String("removeindex")}, + {'r', QLatin1String("removepoint")}, + {'r', QLatin1String("removeprim")}, + {'r', QLatin1String("removevalue")}, + {'r', QLatin1String("renderstate")}, + {'r', QLatin1String("reorder")}, + {'r', QLatin1String("resample_linear")}, + {'r', QLatin1String("resize")}, + {'r', QLatin1String("resolvemissedray")}, + {'r', QLatin1String("reverse")}, + {'r', QLatin1String("rgbtohsv")}, + {'r', QLatin1String("rgbtoxyz")}, + {'r', QLatin1String("rint")}, + {'r', QLatin1String("rotate")}, + {'r', QLatin1String("rotate_x_to")}, + {'r', QLatin1String("rstrip")}, + {'s', QLatin1String("sample_bsdf")}, + {'s', QLatin1String("sample_cauchy")}, + {'s', QLatin1String("sample_circle_arc")}, + {'s', QLatin1String("sample_circle_edge_uniform")}, + {'s', QLatin1String("sample_circle_slice")}, + {'s', QLatin1String("sample_circle_uniform")}, + {'s', QLatin1String("sample_direction_cone")}, + {'s', QLatin1String("sample_direction_uniform")}, + {'s', QLatin1String("sample_discrete")}, + {'s', QLatin1String("sample_exponential")}, + {'s', QLatin1String("sample_geometry")}, + {'s', QLatin1String("sample_hemisphere")}, + {'s', QLatin1String("sample_hypersphere_cone")}, + {'s', QLatin1String("sample_hypersphere_uniform")}, + {'s', QLatin1String("sample_light")}, + {'s', QLatin1String("sample_lognormal")}, + {'s', QLatin1String("sample_lognormal_by_median")}, + {'s', QLatin1String("sample_normal")}, + {'s', QLatin1String("sample_orientation_cone")}, + {'s', QLatin1String("sample_orientation_uniform")}, + {'s', QLatin1String("sample_photon")}, + {'s', QLatin1String("sample_sphere_cone")}, + {'s', QLatin1String("sample_sphere_uniform")}, + {'s', QLatin1String("sampledisk")}, + {'s', QLatin1String("scale")}, + {'s', QLatin1String("select")}, + {'s', QLatin1String("sensor_panorama_create")}, + {'s', QLatin1String("sensor_panorama_getcolor")}, + {'s', QLatin1String("sensor_panorama_getcone")}, + {'s', QLatin1String("sensor_panorama_getdepth")}, + {'s', QLatin1String("sensor_save")}, + {'s', QLatin1String("serialize")}, + {'s', QLatin1String("set")}, + {'s', QLatin1String("setagentclipnames")}, + {'s', QLatin1String("setagentcliptimes")}, + {'s', QLatin1String("setagentclipweights")}, + {'s', QLatin1String("setagentcollisionlayer")}, + {'s', QLatin1String("setagentcurrentlayer")}, + {'s', QLatin1String("setagentlocaltransform")}, + {'s', QLatin1String("setagentlocaltransforms")}, + {'s', QLatin1String("setagentworldtransform")}, + {'s', QLatin1String("setagentworldtransforms")}, + {'s', QLatin1String("setattrib")}, + {'s', QLatin1String("setattribtypeinfo")}, + {'s', QLatin1String("setcomp")}, + {'s', QLatin1String("setcurrentlight")}, + {'s', QLatin1String("setdetailattrib")}, + {'s', QLatin1String("setpointattrib")}, + {'s', QLatin1String("setpointgroup")}, + {'s', QLatin1String("setprimattrib")}, + {'s', QLatin1String("setprimgroup")}, + {'s', QLatin1String("setprimintrinsic")}, + {'s', QLatin1String("setprimvertex")}, + {'s', QLatin1String("setsamplestore")}, + {'s', QLatin1String("setvertexattrib")}, + {'s', QLatin1String("setvertexgroup")}, + {'s', QLatin1String("setvertexpoint")}, + {'s', QLatin1String("shadow")}, + {'s', QLatin1String("shadow_light")}, + {'s', QLatin1String("shadowmap")}, + {'s', QLatin1String("shimport")}, + {'s', QLatin1String("shl")}, + {'s', QLatin1String("shr")}, + {'s', QLatin1String("shrz")}, + {'s', QLatin1String("sign")}, + {'s', QLatin1String("simport")}, + {'s', QLatin1String("sin")}, + {'s', QLatin1String("sinh")}, + {'s', QLatin1String("sleep")}, + {'s', QLatin1String("slerp")}, + {'s', QLatin1String("slice")}, + {'s', QLatin1String("slideframe")}, + {'s', QLatin1String("smooth")}, + {'s', QLatin1String("smoothrotation")}, + {'s', QLatin1String("snoise")}, + {'s', QLatin1String("solvecubic")}, + {'s', QLatin1String("solvepoly")}, + {'s', QLatin1String("solvequadratic")}, + {'s', QLatin1String("sort")}, + {'s', QLatin1String("specular")}, + {'s', QLatin1String("specularBRDF")}, + {'s', QLatin1String("spline")}, + {'s', QLatin1String("split")}, + {'s', QLatin1String("splitpath")}, + {'s', QLatin1String("sprintf")}, + {'s', QLatin1String("sqrt")}, + {'s', QLatin1String("startswith")}, + {'s', QLatin1String("storelightexport")}, + {'s', QLatin1String("strip")}, + {'s', QLatin1String("strlen")}, + {'s', QLatin1String("sum")}, + {'s', QLatin1String("switch")}, + {'s', QLatin1String("swizzle")}, + {'t', QLatin1String("tan")}, + {'t', QLatin1String("tanh")}, + {'t', QLatin1String("tet_adjacent")}, + {'t', QLatin1String("tet_faceindex")}, + {'t', QLatin1String("teximport")}, + {'t', QLatin1String("texprintf")}, + {'t', QLatin1String("texture")}, + {'t', QLatin1String("texture3d")}, + {'t', QLatin1String("texture3dBox")}, + {'t', QLatin1String("titlecase")}, + {'t', QLatin1String("toNDC")}, + {'t', QLatin1String("tolower")}, + {'t', QLatin1String("toupper")}, + {'t', QLatin1String("trace")}, + {'t', QLatin1String("translate")}, + {'t', QLatin1String("translucent")}, + {'t', QLatin1String("transpose")}, + {'t', QLatin1String("trunc")}, + {'t', QLatin1String("tw_nspace")}, + {'t', QLatin1String("tw_space")}, + {'t', QLatin1String("tw_vspace")}, + {'u', QLatin1String("uniqueval")}, + {'u', QLatin1String("unpack_intfromsafefloat")}, + {'u', QLatin1String("unserialize")}, + {'u', QLatin1String("upush")}, + {'u', QLatin1String("uvunwrap")}, + {'v', QLatin1String("variance")}, + {'v', QLatin1String("velocityname")}, + {'v', QLatin1String("vertex")}, + {'v', QLatin1String("vertexattrib")}, + {'v', QLatin1String("vertexattribsize")}, + {'v', QLatin1String("vertexattribtype")}, + {'v', QLatin1String("vertexattribtypeinfo")}, + {'v', QLatin1String("vertexhedge")}, + {'v', QLatin1String("vertexindex")}, + {'v', QLatin1String("vertexnext")}, + {'v', QLatin1String("vertexpoint")}, + {'v', QLatin1String("vertexprev")}, + {'v', QLatin1String("vertexprim")}, + {'v', QLatin1String("vertexprimindex")}, + {'v', QLatin1String("vnoise")}, + {'v', QLatin1String("volume")}, + {'v', QLatin1String("volumegradient")}, + {'v', QLatin1String("volumeindex")}, + {'v', QLatin1String("volumeindexorigin")}, + {'v', QLatin1String("volumeindextopos")}, + {'v', QLatin1String("volumeindexv")}, + {'v', QLatin1String("volumepostoindex")}, + {'v', QLatin1String("volumeres")}, + {'v', QLatin1String("volumesample")}, + {'v', QLatin1String("volumesamplev")}, + {'v', QLatin1String("vtransform")}, + {'w', QLatin1String("warning")}, + {'w', QLatin1String("wireblinn")}, + {'w', QLatin1String("wirediffuse")}, + {'w', QLatin1String("wnoise")}, + {'w', QLatin1String("wo_nspace")}, + {'w', QLatin1String("wo_space")}, + {'w', QLatin1String("wo_vspace")}, + {'w', QLatin1String("writepixel")}, + {'w', QLatin1String("wt_nspace")}, + {'w', QLatin1String("wt_space")}, + {'w', QLatin1String("wt_vspace")}, + {'x', QLatin1String("xnoise")}, + {'x', QLatin1String("xnoised")}, + {'x', QLatin1String("xyzdist")}, + {'x', QLatin1String("xyztorgb")} + }; + vex_other = { + {('d'), QLatin1String("define")}, + {('e'), QLatin1String("else")}, + {('e'), QLatin1String("endif")}, + {('i'), QLatin1String("if")}, + {('i'), QLatin1String("ifdef")}, + {('i'), QLatin1String("ifndef")}, + {('i'), QLatin1String("include")}, + {('p'), QLatin1String("pragma")}, + {('u'), QLatin1String("undef")}, + }; +} +void loadVEXData(LanguageData &types, + LanguageData &keywords, + LanguageData &builtin, + LanguageData &literals, + LanguageData &other) { + if (!vexDataInitialized) { + initVEXData(); + vexDataInitialized = true; + } + types = vex_types; + keywords = vex_keywords; + builtin = vex_builtin; + literals = vex_literals; + other = vex_other; +} + +/********************************************************/ +/*** CMAKE DATA ***************************************/ +/********************************************************/ +static bool cmakeDataInitialized = false; +static QMultiHash cmake_keywords; +static QMultiHash cmake_types; +static QMultiHash cmake_literals; +static QMultiHash cmake_builtin; +static QMultiHash cmake_other; +void initCMakeData() { + cmake_keywords = { + {'b', QLatin1String("break")}, + {'c', QLatin1String("cmake_host_system_information")}, + {'c', QLatin1String("cmake_minimum_required")}, + {'c', QLatin1String("cmake_parse_arguments")}, + {'c', QLatin1String("cmake_policy")}, + {'c', QLatin1String("configure_file")}, + {'c', QLatin1String("continue")}, + {'e', QLatin1String("elseif")}, + {'e', QLatin1String("else")}, + {'e', QLatin1String("endforeach")}, + {'e', QLatin1String("endfunction")}, + {'e', QLatin1String("endif")}, + {'e', QLatin1String("endmacro")}, + {'e', QLatin1String("endwhile")}, + {'e', QLatin1String("execute_process")}, + {'f', QLatin1String("file")}, + {'f', QLatin1String("find_file")}, + {'f', QLatin1String("find_library")}, + {'f', QLatin1String("find_package")}, + {'f', QLatin1String("find_path")}, + {'f', QLatin1String("find_program")}, + {'f', QLatin1String("foreach")}, + {'f', QLatin1String("function")}, + {'g', QLatin1String("get_cmake_property")}, + {'g', QLatin1String("get_directory_property")}, + {'g', QLatin1String("get_filename_component")}, + {'g', QLatin1String("get_property")}, + {'i', QLatin1String("if")}, + {'i', QLatin1String("include")}, + {'i', QLatin1String("include_guard")}, + {'l', QLatin1String("list")}, + {'m', QLatin1String("macro")}, + {'m', QLatin1String("mark_as_advanced")}, + {'m', QLatin1String("math")}, + {'m', QLatin1String("message")}, + {'o', QLatin1String("option")}, + {'r', QLatin1String("return")}, + {'s', QLatin1String("separate_arguments")}, + {'s', QLatin1String("set_directory_properties")}, + {'s', QLatin1String("set")}, + {'s', QLatin1String("set_property")}, + {'s', QLatin1String("site_name")}, + {'s', QLatin1String("string")}, + {'u', QLatin1String("unset")}, + {'v', QLatin1String("variable_watch")}, + {'w', QLatin1String("while")}, + {'a', QLatin1String("add_compile_definitions")}, + {'a', QLatin1String("add_compile_options")}, + {'A', QLatin1String("ADD_COMPILE_OPTIONS")}, + {'a', QLatin1String("add_custom_command")}, + {'a', QLatin1String("add_custom_target")}, + {'a', QLatin1String("add_definitions")}, + {'a', QLatin1String("add_dependencies")}, + {'a', QLatin1String("add_executable")}, + {'a', QLatin1String("add_library")}, + {'a', QLatin1String("add_link_options")}, + {'a', QLatin1String("add_subdirectory")}, + {'a', QLatin1String("add_test")}, + {'a', QLatin1String("aux_source_directory")}, + {'b', QLatin1String("build_command")}, + {'c', QLatin1String("create_test_sourcelist")}, + {'d', QLatin1String("define_property")}, + {'e', QLatin1String("enable_language")}, + {'e', QLatin1String("enable_testing")}, + {'e', QLatin1String("export")}, + {'f', QLatin1String("fltk_wrap_ui")}, + {'g', QLatin1String("get_source_file_property")}, + {'g', QLatin1String("get_target_property")}, + {'g', QLatin1String("get_test_property")}, + {'i', QLatin1String("include_directories")}, + {'i', QLatin1String("include_external_msproject")}, + {'i', QLatin1String("include_regular_expression")}, + {'i', QLatin1String("install")}, + {'l', QLatin1String("link_directories")}, + {'l', QLatin1String("link_libraries")}, + {'l', QLatin1String("load_cache")}, + {'p', QLatin1String("project")}, + {'q', QLatin1String("qt_wrap_cpp")}, + {'q', QLatin1String("qt_wrap_ui")}, + {'r', QLatin1String("remove_definitions")}, + {'s', QLatin1String("set_source_files_properties")}, + {'s', QLatin1String("set_target_properties")}, + {'s', QLatin1String("set_tests_properties")}, + {'s', QLatin1String("source_group")}, + {'t', QLatin1String("target_compile_definitions")}, + {'t', QLatin1String("target_compile_features")}, + {'t', QLatin1String("target_compile_options")}, + {'t', QLatin1String("target_include_directories")}, + {'t', QLatin1String("target_link_directories")}, + {'t', QLatin1String("target_link_libraries")}, + {'t', QLatin1String("target_link_options")}, + {'t', QLatin1String("target_sources")}, + {'t', QLatin1String("try_compile")}, + {'t', QLatin1String("try_run")}, + {'c', QLatin1String("ctest_build")}, + {'c', QLatin1String("ctest_configure")}, + {'c', QLatin1String("ctest_coverage")}, + {'c', QLatin1String("ctest_empty_binary_directory")}, + {'c', QLatin1String("ctest_memcheck")}, + {'c', QLatin1String("ctest_read_custom_files")}, + {'c', QLatin1String("ctest_run_script")}, + {'c', QLatin1String("ctest_sleep")}, + {'c', QLatin1String("ctest_start")}, + {'c', QLatin1String("ctest_submit")}, + {'c', QLatin1String("ctest_test")}, + {'c', QLatin1String("ctest_update")}, + {'c', QLatin1String("ctest_upload")}, + {'b', QLatin1String("build_name")}, + {'e', QLatin1String("exec_program")}, + {'e', QLatin1String("export_library_dependencies")}, + {'i', QLatin1String("install_files")}, + {'i', QLatin1String("install_programs")}, + {'i', QLatin1String("install_targets")}, + {'l', QLatin1String("load_command")}, + {'m', QLatin1String("make_directory")}, + {'o', QLatin1String("output_required_files")}, + {'r', QLatin1String("remove")}, + {'s', QLatin1String("subdir_depends")}, + {'s', QLatin1String("subdirs")}, + {'u', QLatin1String("use_mangled_mesa")}, + {'u', QLatin1String("utility_source")}, + {'v', QLatin1String("variable_requires")}, + {'w', QLatin1String("write_file")}, + {'q', QLatin1String("qt5_use_modules")}, + {'q', QLatin1String("qt5_use_package")}, + {'q', QLatin1String("qt5_wrap_cpp")}, + {'a', QLatin1String("and")}, + {'o', QLatin1String("or")}, + {'n', QLatin1String("not")}, + {'c', QLatin1String("command")}, + {'p', QLatin1String("policy")}, + {'t', QLatin1String("target")}, + {'t', QLatin1String("test")}, + {'e', QLatin1String("exists")}, + {'i', QLatin1String("is_newer_than")}, + {'i', QLatin1String("is_directory")}, + {'i', QLatin1String("is_symlink")}, + {'i', QLatin1String("is_absolute")}, + {'m', QLatin1String("matches")}, + {'l', QLatin1String("less")}, + {'g', QLatin1String("greater")}, + {'e', QLatin1String("equal")}, + {'l', QLatin1String("less_equal")}, + {'g', QLatin1String("greater_equal")}, + {'s', QLatin1String("strless")}, + {'s', QLatin1String("strgreater")}, + {'s', QLatin1String("strequal")}, + {'s', QLatin1String("strless_equal")}, + {'s', QLatin1String("strgreater_equal")}, + {'v', QLatin1String("version_less")}, + {'v', QLatin1String("version_greater")}, + {'v', QLatin1String("version_equal")}, + {'v', QLatin1String("version_less_equal")}, + {'v', QLatin1String("version_greater_equal")}, + {'i', QLatin1String("in_list")}, + {'d', QLatin1String("defined")} + }; + cmake_types = {}; + cmake_literals = { + {'o', QLatin1String("on")}, + {'o', QLatin1String("off")}, + {'O', QLatin1String("ON")}, + {'O', QLatin1String("OFF")}, + {'t', QLatin1String("true")}, + {'f', QLatin1String("false")}, + {'T', QLatin1String("TRUE")}, + {'F', QLatin1String("FALSE")} + }; + cmake_builtin = { + {'A', QLatin1String("ALLOW_DUPLICATE_CUSTOM_TARGETS")}, + {'A', QLatin1String("AUTOGEN_TARGETS_FOLDER")}, + {'A', QLatin1String("AUTOMOC_TARGETS_FOLDER")}, + {'D', QLatin1String("DEBUG_CONFIGURATIONS")}, + {'D', QLatin1String("DISABLED_FEATURES")}, + {'E', QLatin1String("ENABLED_FEATURES")}, + {'E', QLatin1String("ENABLED_LANGUAGES")}, + {'F', QLatin1String("FIND_LIBRARY_USE_LIB64_PATHS")}, + {'F', QLatin1String("FIND_LIBRARY_USE_OPENBSD_VERSIONING")}, + {'G', QLatin1String("GLOBAL_DEPENDS_DEBUG_MODE")}, + {'G', QLatin1String("GLOBAL_DEPENDS_NO_CYCLES")}, + {'I', QLatin1String("IN_TRY_COMPILE")}, + {'P', QLatin1String("PACKAGES_FOUND")}, + {'P', QLatin1String("PACKAGES_NOT_FOUND")}, + {'J', QLatin1String("JOB_POOLS")}, + {'P', QLatin1String("PREDEFINED_TARGETS_FOLDER")}, + {'E', QLatin1String("ECLIPSE_EXTRA_NATURES")}, + {'R', QLatin1String("REPORT_UNDEFINED_PROPERTIES")}, + {'R', QLatin1String("RULE_LAUNCH_COMPILE")}, + {'R', QLatin1String("RULE_LAUNCH_CUSTOM")}, + {'R', QLatin1String("RULE_LAUNCH_LINK")}, + {'R', QLatin1String("RULE_MESSAGES")}, + {'T', QLatin1String("TARGET_ARCHIVES_MAY_BE_SHARED_LIBS")}, + {'T', QLatin1String("TARGET_SUPPORTS_SHARED_LIBS")}, + {'U', QLatin1String("USE_FOLDERS")}, + {'A', QLatin1String("ADDITIONAL_MAKE_CLEAN_FILES")}, + {'C', QLatin1String("CACHE_VARIABLES")}, + {'C', QLatin1String("CLEAN_NO_CUSTOM")}, + {'C', QLatin1String("CMAKE_CONFIGURE_DEPENDS")}, + {'C', QLatin1String("COMPILE_DEFINITIONS")}, + {'C', QLatin1String("COMPILE_OPTIONS")}, + {'D', QLatin1String("DEFINITIONS")}, + {'E', QLatin1String("EXCLUDE_FROM_ALL")}, + {'I', QLatin1String("IMPLICIT_DEPENDS_INCLUDE_TRANSFORM")}, + {'I', QLatin1String("INCLUDE_DIRECTORIES")}, + {'I', QLatin1String("INCLUDE_REGULAR_EXPRESSION")}, + {'I', QLatin1String("INTERPROCEDURAL_OPTIMIZATION")}, + {'L', QLatin1String("LINK_DIRECTORIES")}, + {'L', QLatin1String("LISTFILE_STACK")}, + {'M', QLatin1String("MACROS")}, + {'P', QLatin1String("PARENT_DIRECTORY")}, + {'R', QLatin1String("RULE_LAUNCH_COMPILE")}, + {'R', QLatin1String("RULE_LAUNCH_CUSTOM")}, + {'R', QLatin1String("RULE_LAUNCH_LINK")}, + {'T', QLatin1String("TEST_INCLUDE_FILE")}, + {'V', QLatin1String("VARIABLES")}, + {'A', QLatin1String("ALIASED_TARGET")}, + {'A', QLatin1String("ARCHIVE_OUTPUT_DIRECTORY")}, + {'A', QLatin1String("ARCHIVE_OUTPUT_NAME")}, + {'A', QLatin1String("AUTOGEN_TARGET_DEPENDS")}, + {'A', QLatin1String("AUTOMOC_MOC_OPTIONS")}, + {'A', QLatin1String("AUTOMOC")}, + {'A', QLatin1String("AUTOUIC")}, + {'A', QLatin1String("AUTOUIC_OPTIONS")}, + {'A', QLatin1String("AUTORCC")}, + {'A', QLatin1String("AUTORCC_OPTIONS")}, + {'B', QLatin1String("BUILD_WITH_INSTALL_RPATH")}, + {'B', QLatin1String("BUNDLE_EXTENSION")}, + {'B', QLatin1String("BUNDLE")}, + {'C', QLatin1String("COMPATIBLE_INTERFACE_BOOL")}, + {'C', QLatin1String("COMPATIBLE_INTERFACE_NUMBER_MAX")}, + {'C', QLatin1String("COMPATIBLE_INTERFACE_NUMBER_MIN")}, + {'C', QLatin1String("COMPATIBLE_INTERFACE_STRING")}, + {'C', QLatin1String("COMPILE_DEFINITIONS")}, + {'C', QLatin1String("COMPILE_FLAGS")}, + {'C', QLatin1String("COMPILE_OPTIONS")}, + {'D', QLatin1String("DEBUG_POSTFIX")}, + {'D', QLatin1String("DEFINE_SYMBOL")}, + {'E', QLatin1String("EchoString")}, + {'E', QLatin1String("ENABLE_EXPORTS")}, + {'E', QLatin1String("EXCLUDE_FROM_ALL")}, + {'E', QLatin1String("EXCLUDE_FROM_DEFAULT_BUILD")}, + {'E', QLatin1String("EXPORT_NAME")}, + {'F', QLatin1String("FOLDER")}, + {'F', QLatin1String("Fortran_FORMAT")}, + {'F', QLatin1String("Fortran_MODULE_DIRECTORY")}, + {'F', QLatin1String("FRAMEWORK")}, + {'G', QLatin1String("GENERATOR_FILE_NAME")}, + {'G', QLatin1String("GNUtoMS")}, + {'H', QLatin1String("HAS_CXX")}, + {'I', QLatin1String("IMPLICIT_DEPENDS_INCLUDE_TRANSFORM")}, + {'I', QLatin1String("IMPORTED_CONFIGURATIONS")}, + {'I', QLatin1String("IMPORTED_IMPLIB")}, + {'I', QLatin1String("IMPORTED_LINK_DEPENDENT_LIBRARIES")}, + {'I', QLatin1String("IMPORTED_LINK_INTERFACE_LANGUAGES")}, + {'I', QLatin1String("IMPORTED_LINK_INTERFACE_LIBRARIES")}, + {'I', QLatin1String("IMPORTED_LINK_INTERFACE_MULTIPLICITY")}, + {'I', QLatin1String("IMPORTED_LOCATION")}, + {'I', QLatin1String("IMPORTED_NO_SONAME")}, + {'I', QLatin1String("IMPORTED")}, + {'I', QLatin1String("IMPORTED_SONAME")}, + {'I', QLatin1String("IMPORT_PREFIX")}, + {'I', QLatin1String("IMPORT_SUFFIX")}, + {'I', QLatin1String("INCLUDE_DIRECTORIES")}, + {'I', QLatin1String("INSTALL_NAME_DIR")}, + {'I', QLatin1String("INSTALL_RPATH")}, + {'I', QLatin1String("INSTALL_RPATH_USE_LINK_PATH")}, + {'I', QLatin1String("INTERFACE_AUTOUIC_OPTIONS")}, + {'I', QLatin1String("INTERFACE_COMPILE_DEFINITIONS")}, + {'I', QLatin1String("INTERFACE_COMPILE_OPTIONS")}, + {'I', QLatin1String("INTERFACE_INCLUDE_DIRECTORIES")}, + {'I', QLatin1String("INTERFACE_LINK_LIBRARIES")}, + {'I', QLatin1String("INTERFACE_POSITION_INDEPENDENT_CODE")}, + {'I', QLatin1String("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES")}, + {'I', QLatin1String("INTERPROCEDURAL_OPTIMIZATION")}, + {'J', QLatin1String("JOB_POOL_COMPILE")}, + {'J', QLatin1String("JOB_POOL_LINK")}, + {'L', QLatin1String("LABELS")}, + {'L', QLatin1String("LIBRARY_OUTPUT_DIRECTORY")}, + {'L', QLatin1String("LIBRARY_OUTPUT_NAME")}, + {'L', QLatin1String("LINK_DEPENDS_NO_SHARED")}, + {'L', QLatin1String("LINK_DEPENDS")}, + {'L', QLatin1String("LINKER_LANGUAGE")}, + {'L', QLatin1String("LINK_FLAGS")}, + {'L', QLatin1String("LINK_INTERFACE_LIBRARIES")}, + {'L', QLatin1String("LINK_INTERFACE_MULTIPLICITY")}, + {'L', QLatin1String("LINK_LIBRARIES")}, + {'L', QLatin1String("LINK_SEARCH_END_STATIC")}, + {'L', QLatin1String("LINK_SEARCH_START_STATIC")}, + {'L', QLatin1String("LOCATION")}, + {'M', QLatin1String("MACOSX_BUNDLE_INFO_PLIST")}, + {'M', QLatin1String("MACOSX_BUNDLE")}, + {'M', QLatin1String("MACOSX_FRAMEWORK_INFO_PLIST")}, + {'M', QLatin1String("MACOSX_RPATH")}, +// {'N', QLatin1String("NAME")}, + {'N', QLatin1String("NO_SONAME")}, + {'N', QLatin1String("NO_SYSTEM_FROM_IMPORTED")}, + {'O', QLatin1String("OSX_ARCHITECTURES")}, + {'O', QLatin1String("OUTPUT_NAME")}, + {'P', QLatin1String("PDB_NAME")}, + {'P', QLatin1String("PDB_OUTPUT_DIRECTORY")}, + {'P', QLatin1String("POSITION_INDEPENDENT_CODE")}, + {'P', QLatin1String("POST_INSTALL_SCRIPT")}, + {'P', QLatin1String("PREFIX")}, + {'P', QLatin1String("PROPERTY")}, + {'P', QLatin1String("PRE_INSTALL_SCRIPT")}, + {'P', QLatin1String("PRIVATE_HEADER")}, + {'P', QLatin1String("PROJECT_LABEL")}, + {'P', QLatin1String("PUBLIC_HEADER")}, + {'R', QLatin1String("RESOURCE")}, + {'R', QLatin1String("RULE_LAUNCH_COMPILE")}, + {'R', QLatin1String("RULE_LAUNCH_CUSTOM")}, + {'R', QLatin1String("RULE_LAUNCH_LINK")}, + {'R', QLatin1String("RUNTIME_OUTPUT_DIRECTORY")}, + {'R', QLatin1String("RUNTIME_OUTPUT_NAME")}, + {'S', QLatin1String("SKIP_BUILD_RPATH")}, + {'S', QLatin1String("SOURCES")}, + {'S', QLatin1String("SOVERSION")}, + {'S', QLatin1String("STATIC_LIBRARY_FLAGS")}, + {'S', QLatin1String("SUFFIX")}, + {'T', QLatin1String("TARGET")}, + {'T', QLatin1String("TYPE")}, + {'V', QLatin1String("VERSION")}, + {'V', QLatin1String("VISIBILITY_INLINES_HIDDEN")}, + {'V', QLatin1String("VS_DOTNET_REFERENCES")}, + {'V', QLatin1String("VS_DOTNET_TARGET_FRAMEWORK_VERSION")}, + {'V', QLatin1String("VS_GLOBAL_KEYWORD")}, + {'V', QLatin1String("VS_GLOBAL_PROJECT_TYPES")}, + {'V', QLatin1String("VS_GLOBAL_ROOTNAMESPACE")}, + {'V', QLatin1String("VS_KEYWORD")}, + {'V', QLatin1String("VS_SCC_AUXPATH")}, + {'V', QLatin1String("VS_SCC_LOCALPATH")}, + {'V', QLatin1String("VS_SCC_PROJECTNAME")}, + {'V', QLatin1String("VS_SCC_PROVIDER")}, + {'V', QLatin1String("VS_WINRT_EXTENSIONS")}, + {'V', QLatin1String("VS_WINRT_REFERENCES")}, + {'W', QLatin1String("WIN32_EXECUTABLE")}, + {'A', QLatin1String("ATTACHED_FILES_ON_FAIL")}, + {'A', QLatin1String("ATTACHED_FILES")}, + {'C', QLatin1String("COST")}, + {'D', QLatin1String("DEPENDS")}, + {'E', QLatin1String("ENVIRONMENT")}, + {'F', QLatin1String("FAIL_REGULAR_EXPRESSION")}, + {'L', QLatin1String("LABELS")}, + {'M', QLatin1String("MEASUREMENT")}, + {'P', QLatin1String("PASS_REGULAR_EXPRESSION")}, + {'P', QLatin1String("PROCESSORS")}, + {'R', QLatin1String("REQUIRED_FILES")}, + {'R', QLatin1String("RESOURCE_LOCK")}, + {'R', QLatin1String("RUN_SERIAL")}, + {'S', QLatin1String("SKIP_RETURN_CODE")}, + {'T', QLatin1String("TIMEOUT")}, + {'W', QLatin1String("WILL_FAIL")}, + {'W', QLatin1String("WORKING_DIRECTORY")}, + {'A', QLatin1String("ABSTRACT")}, + {'A', QLatin1String("AUTOUIC_OPTIONS")}, + {'A', QLatin1String("AUTORCC_OPTIONS")}, + {'C', QLatin1String("COMPILE_DEFINITIONS")}, + {'C', QLatin1String("COMPILE_FLAGS")}, + {'E', QLatin1String("EXTERNAL_OBJECT")}, + {'F', QLatin1String("Fortran_FORMAT")}, + {'G', QLatin1String("GENERATED")}, + {'H', QLatin1String("HEADER_FILE_ONLY")}, + {'K', QLatin1String("KEEP_EXTENSION")}, + {'L', QLatin1String("LABELS")}, +// {'L', QLatin1String("LANGUAGE")}, + {'L', QLatin1String("LOCATION")}, + {'M', QLatin1String("MACOSX_PACKAGE_LOCATION")}, + {'O', QLatin1String("OBJECT_DEPENDS")}, + {'O', QLatin1String("OBJECT_OUTPUTS")}, + {'S', QLatin1String("SYMBOLIC")}, + {'W', QLatin1String("WRAP_EXCLUDE")}, + {'A', QLatin1String("ADVANCED")}, + {'H', QLatin1String("HELPSTRING")}, + {'M', QLatin1String("MODIFIED")}, + {'S', QLatin1String("STRINGS")}, + {'T', QLatin1String("TYPE")}, + {'V', QLatin1String("VALUE")} + }; + cmake_other = { + {'C', QLatin1String("CMAKE_ARGC")}, + {'C', QLatin1String("CMAKE_ARGV0")}, + {'C', QLatin1String("CMAKE_AR")}, + {'C', QLatin1String("CMAKE_BINARY_DIR")}, + {'C', QLatin1String("CMAKE_BUILD_TOOL")}, + {'C', QLatin1String("CMAKE_CACHEFILE_DIR")}, + {'C', QLatin1String("CMAKE_CACHE_MAJOR_VERSION")}, + {'C', QLatin1String("CMAKE_CACHE_MINOR_VERSION")}, + {'C', QLatin1String("CMAKE_CACHE_PATCH_VERSION")}, + {'C', QLatin1String("CMAKE_CFG_INTDIR")}, + {'C', QLatin1String("CMAKE_COMMAND")}, + {'C', QLatin1String("CMAKE_CROSSCOMPILING")}, + {'C', QLatin1String("CMAKE_CTEST_COMMAND")}, + {'C', QLatin1String("CMAKE_CURRENT_BINARY_DIR")}, + {'C', QLatin1String("CMAKE_CURRENT_LIST_DIR")}, + {'C', QLatin1String("CMAKE_CURRENT_LIST_FILE")}, + {'C', QLatin1String("CMAKE_CURRENT_LIST_LINE")}, + {'C', QLatin1String("CMAKE_CURRENT_SOURCE_DIR")}, + {'C', QLatin1String("CMAKE_DL_LIBS")}, + {'C', QLatin1String("CMAKE_EDIT_COMMAND")}, + {'C', QLatin1String("CMAKE_EXECUTABLE_SUFFIX")}, + {'C', QLatin1String("CMAKE_EXTRA_GENERATOR")}, + {'C', QLatin1String("CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES")}, + {'C', QLatin1String("CMAKE_GENERATOR")}, + {'C', QLatin1String("CMAKE_GENERATOR_TOOLSET")}, + {'C', QLatin1String("CMAKE_HOME_DIRECTORY")}, + {'C', QLatin1String("CMAKE_IMPORT_LIBRARY_PREFIX")}, + {'C', QLatin1String("CMAKE_IMPORT_LIBRARY_SUFFIX")}, + {'C', QLatin1String("CMAKE_JOB_POOL_COMPILE")}, + {'C', QLatin1String("CMAKE_JOB_POOL_LINK")}, + {'C', QLatin1String("CMAKE_LINK_LIBRARY_SUFFIX")}, + {'C', QLatin1String("CMAKE_MAJOR_VERSION")}, + {'C', QLatin1String("CMAKE_MAKE_PROGRAM")}, + {'C', QLatin1String("CMAKE_MINIMUM_REQUIRED_VERSION")}, + {'C', QLatin1String("CMAKE_MINOR_VERSION")}, + {'C', QLatin1String("CMAKE_PARENT_LIST_FILE")}, + {'C', QLatin1String("CMAKE_PATCH_VERSION")}, + {'C', QLatin1String("CMAKE_PROJECT_NAME")}, + {'C', QLatin1String("CMAKE_RANLIB")}, + {'C', QLatin1String("CMAKE_ROOT")}, + {'C', QLatin1String("CMAKE_SCRIPT_MODE_FILE")}, + {'C', QLatin1String("CMAKE_SHARED_LIBRARY_PREFIX")}, + {'C', QLatin1String("CMAKE_SHARED_LIBRARY_SUFFIX")}, + {'C', QLatin1String("CMAKE_SHARED_MODULE_PREFIX")}, + {'C', QLatin1String("CMAKE_SHARED_MODULE_SUFFIX")}, + {'C', QLatin1String("CMAKE_SIZEOF_VOID_P")}, + {'C', QLatin1String("CMAKE_SKIP_INSTALL_RULES")}, + {'C', QLatin1String("CMAKE_SKIP_RPATH")}, + {'C', QLatin1String("CMAKE_SOURCE_DIR")}, + {'C', QLatin1String("CMAKE_STANDARD_LIBRARIES")}, + {'C', QLatin1String("CMAKE_STATIC_LIBRARY_PREFIX")}, + {'C', QLatin1String("CMAKE_STATIC_LIBRARY_SUFFIX")}, + {'C', QLatin1String("CMAKE_TOOLCHAIN_FILE")}, + {'C', QLatin1String("CMAKE_TWEAK_VERSION")}, + {'C', QLatin1String("CMAKE_VERBOSE_MAKEFILE")}, + {'C', QLatin1String("CMAKE_VERSION")}, + {'C', QLatin1String("CMAKE_VS_DEVENV_COMMAND")}, + {'C', QLatin1String("CMAKE_VS_INTEL_Fortran_PROJECT_VERSION")}, + {'C', QLatin1String("CMAKE_VS_MSBUILD_COMMAND")}, + {'C', QLatin1String("CMAKE_VS_MSDEV_COMMAND")}, + {'C', QLatin1String("CMAKE_VS_PLATFORM_TOOLSET")}, + {'C', QLatin1String("CMAKE_XCODE_PLATFORM_TOOLSET")}, + {'P', QLatin1String("PROJECT_BINARY_DIR")}, +// {'P', QLatin1String("PROJECT_NAME")}, + {'P', QLatin1String("PROJECT_SOURCE_DIR")}, + {'P', QLatin1String("PROJECT_VERSION")}, + {'P', QLatin1String("PROJECT_VERSION_MAJOR")}, + {'P', QLatin1String("PROJECT_VERSION_MINOR")}, + {'P', QLatin1String("PROJECT_VERSION_PATCH")}, + {'P', QLatin1String("PROJECT_VERSION_TWEAK")}, + {'B', QLatin1String("BUILD_SHARED_LIBS")}, + {'C', QLatin1String("CMAKE_ABSOLUTE_DESTINATION_FILES")}, + {'C', QLatin1String("CMAKE_APPBUNDLE_PATH")}, + {'C', QLatin1String("CMAKE_AUTOMOC_RELAXED_MODE")}, + {'C', QLatin1String("CMAKE_BACKWARDS_COMPATIBILITY")}, + {'C', QLatin1String("CMAKE_BUILD_TYPE")}, + {'C', QLatin1String("CMAKE_COLOR_MAKEFILE")}, + {'C', QLatin1String("CMAKE_CONFIGURATION_TYPES")}, + {'C', QLatin1String("CMAKE_DEBUG_TARGET_PROPERTIES")}, + {'C', QLatin1String("CMAKE_ERROR_DEPRECATED")}, + {'C', QLatin1String("CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION")}, + {'C', QLatin1String("CMAKE_SYSROOT")}, + {'C', QLatin1String("CMAKE_FIND_LIBRARY_PREFIXES")}, + {'C', QLatin1String("CMAKE_FIND_LIBRARY_SUFFIXES")}, + {'C', QLatin1String("CMAKE_FIND_NO_INSTALL_PREFIX")}, + {'C', QLatin1String("CMAKE_FIND_PACKAGE_WARN_NO_MODULE")}, + {'C', QLatin1String("CMAKE_FIND_ROOT_PATH")}, + {'C', QLatin1String("CMAKE_FIND_ROOT_PATH_MODE_INCLUDE")}, + {'C', QLatin1String("CMAKE_FIND_ROOT_PATH_MODE_LIBRARY")}, + {'C', QLatin1String("CMAKE_FIND_ROOT_PATH_MODE_PACKAGE")}, + {'C', QLatin1String("CMAKE_FIND_ROOT_PATH_MODE_PROGRAM")}, + {'C', QLatin1String("CMAKE_FRAMEWORK_PATH")}, + {'C', QLatin1String("CMAKE_IGNORE_PATH")}, + {'C', QLatin1String("CMAKE_INCLUDE_PATH")}, + {'C', QLatin1String("CMAKE_INCLUDE_DIRECTORIES_BEFORE")}, + {'C', QLatin1String("CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE")}, + {'C', QLatin1String("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME")}, + {'C', QLatin1String("CMAKE_INSTALL_PREFIX")}, + {'C', QLatin1String("CMAKE_LIBRARY_PATH")}, + {'C', QLatin1String("CMAKE_MFC_FLAG")}, + {'C', QLatin1String("CMAKE_MODULE_PATH")}, + {'C', QLatin1String("CMAKE_NOT_USING_CONFIG_FLAGS")}, + {'C', QLatin1String("CMAKE_PREFIX_PATH")}, + {'C', QLatin1String("CMAKE_PROGRAM_PATH")}, + {'C', QLatin1String("CMAKE_SKIP_INSTALL_ALL_DEPENDENCY")}, + {'C', QLatin1String("CMAKE_STAGING_PREFIX")}, + {'C', QLatin1String("CMAKE_SYSTEM_IGNORE_PATH")}, + {'C', QLatin1String("CMAKE_SYSTEM_INCLUDE_PATH")}, + {'C', QLatin1String("CMAKE_SYSTEM_LIBRARY_PATH")}, + {'C', QLatin1String("CMAKE_SYSTEM_PREFIX_PATH")}, + {'C', QLatin1String("CMAKE_SYSTEM_PROGRAM_PATH")}, + {'C', QLatin1String("CMAKE_USER_MAKE_RULES_OVERRIDE")}, + {'C', QLatin1String("CMAKE_WARN_DEPRECATED")}, + {'C', QLatin1String("CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION")}, + {'A', QLatin1String("APPLE")}, + {'B', QLatin1String("BORLAND")}, + {'C', QLatin1String("CMAKE_CL_64")}, + {'C', QLatin1String("CMAKE_COMPILER_2005")}, + {'C', QLatin1String("CMAKE_HOST_APPLE")}, + {'C', QLatin1String("CMAKE_HOST_SYSTEM_NAME")}, + {'C', QLatin1String("CMAKE_HOST_SYSTEM_PROCESSOR")}, + {'C', QLatin1String("CMAKE_HOST_SYSTEM")}, + {'C', QLatin1String("CMAKE_HOST_SYSTEM_VERSION")}, + {'C', QLatin1String("CMAKE_HOST_UNIX")}, + {'C', QLatin1String("CMAKE_HOST_WIN32")}, + {'C', QLatin1String("CMAKE_LIBRARY_ARCHITECTURE_REGEX")}, + {'C', QLatin1String("CMAKE_LIBRARY_ARCHITECTURE")}, + {'C', QLatin1String("CMAKE_OBJECT_PATH_MAX")}, + {'C', QLatin1String("CMAKE_SYSTEM_NAME")}, + {'C', QLatin1String("CMAKE_SYSTEM_PROCESSOR")}, + {'C', QLatin1String("CMAKE_SYSTEM")}, + {'C', QLatin1String("CMAKE_SYSTEM_VERSION")}, + {'C', QLatin1String("CYGWIN")}, + {'E', QLatin1String("ENV")}, + {'M', QLatin1String("MSVC10")}, + {'M', QLatin1String("MSVC11")}, + {'M', QLatin1String("MSVC12")}, + {'M', QLatin1String("MSVC60")}, + {'M', QLatin1String("MSVC70")}, + {'M', QLatin1String("MSVC71")}, + {'M', QLatin1String("MSVC80")}, + {'M', QLatin1String("MSVC90")}, + {'M', QLatin1String("MSVC_IDE")}, + {'M', QLatin1String("MSVC")}, + {'M', QLatin1String("MSVC_VERSION")}, + {'U', QLatin1String("UNIX")}, + {'W', QLatin1String("WIN32")}, + {'X', QLatin1String("XCODE_VERSION")}, + {'C', QLatin1String("CMAKE_ARCHIVE_OUTPUT_DIRECTORY")}, + {'C', QLatin1String("CMAKE_AUTOMOC_MOC_OPTIONS")}, + {'C', QLatin1String("CMAKE_AUTOMOC")}, + {'C', QLatin1String("CMAKE_AUTORCC")}, + {'C', QLatin1String("CMAKE_AUTORCC_OPTIONS")}, + {'C', QLatin1String("CMAKE_AUTOUIC")}, + {'C', QLatin1String("CMAKE_AUTOUIC_OPTIONS")}, + {'C', QLatin1String("CMAKE_BUILD_WITH_INSTALL_RPATH")}, + {'C', QLatin1String("CMAKE_DEBUG_POSTFIX")}, + {'C', QLatin1String("CMAKE_EXE_LINKER_FLAGS")}, + {'C', QLatin1String("CMAKE_Fortran_FORMAT")}, + {'C', QLatin1String("CMAKE_Fortran_MODULE_DIRECTORY")}, + {'C', QLatin1String("CMAKE_GNUtoMS")}, + {'C', QLatin1String("CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE")}, + {'C', QLatin1String("CMAKE_INCLUDE_CURRENT_DIR")}, + {'C', QLatin1String("CMAKE_INSTALL_NAME_DIR")}, + {'C', QLatin1String("CMAKE_INSTALL_RPATH")}, + {'C', QLatin1String("CMAKE_INSTALL_RPATH_USE_LINK_PATH")}, + {'C', QLatin1String("CMAKE_LIBRARY_OUTPUT_DIRECTORY")}, + {'C', QLatin1String("CMAKE_LIBRARY_PATH_FLAG")}, + {'C', QLatin1String("CMAKE_LINK_DEF_FILE_FLAG")}, + {'C', QLatin1String("CMAKE_LINK_DEPENDS_NO_SHARED")}, + {'C', QLatin1String("CMAKE_LINK_INTERFACE_LIBRARIES")}, + {'C', QLatin1String("CMAKE_LINK_LIBRARY_FILE_FLAG")}, + {'C', QLatin1String("CMAKE_LINK_LIBRARY_FLAG")}, + {'C', QLatin1String("CMAKE_MACOSX_BUNDLE")}, + {'C', QLatin1String("CMAKE_MACOSX_RPATH")}, + {'C', QLatin1String("CMAKE_MODULE_LINKER_FLAGS")}, + {'C', QLatin1String("CMAKE_NO_BUILTIN_CHRPATH")}, + {'C', QLatin1String("CMAKE_NO_SYSTEM_FROM_IMPORTED")}, + {'C', QLatin1String("CMAKE_OSX_ARCHITECTURES")}, + {'C', QLatin1String("CMAKE_OSX_DEPLOYMENT_TARGET")}, + {'C', QLatin1String("CMAKE_OSX_SYSROOT")}, + {'C', QLatin1String("CMAKE_PDB_OUTPUT_DIRECTORY")}, + {'C', QLatin1String("CMAKE_POSITION_INDEPENDENT_CODE")}, + {'C', QLatin1String("CMAKE_RUNTIME_OUTPUT_DIRECTORY")}, + {'C', QLatin1String("CMAKE_SHARED_LINKER_FLAGS")}, + {'C', QLatin1String("CMAKE_SKIP_BUILD_RPATH")}, + {'C', QLatin1String("CMAKE_SKIP_INSTALL_RPATH")}, + {'C', QLatin1String("CMAKE_STATIC_LINKER_FLAGS")}, + {'C', QLatin1String("CMAKE_TRY_COMPILE_CONFIGURATION")}, + {'C', QLatin1String("CMAKE_USE_RELATIVE_PATHS")}, + {'C', QLatin1String("CMAKE_VISIBILITY_INLINES_HIDDEN")}, + {'C', QLatin1String("CMAKE_WIN32_EXECUTABLE")}, + {'E', QLatin1String("EXECUTABLE_OUTPUT_PATH")}, + {'L', QLatin1String("LIBRARY_OUTPUT_PATH")}, + {'C', QLatin1String("CMAKE_Fortran_MODDIR_DEFAULT")}, + {'C', QLatin1String("CMAKE_Fortran_MODDIR_FLAG")}, + {'C', QLatin1String("CMAKE_Fortran_MODOUT_FLAG")}, + {'C', QLatin1String("CMAKE_INTERNAL_PLATFORM_ABI")}, + {'C', QLatin1String("CPACK_ABSOLUTE_DESTINATION_FILES")}, + {'C', QLatin1String("CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY")}, + {'C', QLatin1String("CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION")}, + {'C', QLatin1String("CPACK_INCLUDE_TOPLEVEL_DIRECTORY")}, + {'C', QLatin1String("CPACK_INSTALL_SCRIPT")}, + {'C', QLatin1String("CPACK_PACKAGING_INSTALL_PREFIX")}, + {'C', QLatin1String("CPACK_SET_DESTDIR")}, + {'C', QLatin1String("CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION")} + }; +} + +void loadCMakeData(QMultiHash &types, QMultiHash &keywords, QMultiHash &builtin, QMultiHash &literals, QMultiHash &other) +{ + if (!cmakeDataInitialized) { + initCMakeData(); + cmakeDataInitialized = true; + } + types = cmake_types; + keywords = cmake_keywords; + builtin = cmake_builtin; + literals = cmake_literals; + other = cmake_other; +} + +/********************************************************/ +/*** MAKE DATA ***************************************/ +/********************************************************/ +static bool makeDataInitialized = false; +static QMultiHash make_keywords; +static QMultiHash make_types; +static QMultiHash make_literals; +static QMultiHash make_builtin; +static QMultiHash make_other; +void initMakeData() { + make_keywords = { + {'i', QLatin1String("include")}, + {'d', QLatin1String("define")}, + {'e', QLatin1String("else")}, + {'e', QLatin1String("endef")}, + {'e', QLatin1String("endif")}, + {'e', QLatin1String("export")}, + {'i', QLatin1String("ifn?def")}, + {'i', QLatin1String("ifn?eq")}, + {'i', QLatin1String("include")}, + {'o', QLatin1String("override")}, + {'p', QLatin1String("private")}, + {'s', QLatin1String("sinclude")}, + {'u', QLatin1String("undefine")}, + {'u', QLatin1String("unexport")}, + {'v', QLatin1String("vpath")} + }; + make_types = { + {'a', QLatin1String("addsuffix")}, + {'a', QLatin1String("abspath")}, + {'a', QLatin1String("and")}, + {'a', QLatin1String("ar")}, + {'b', QLatin1String("basename")}, + {'c', QLatin1String("call")}, + {'d', QLatin1String("dir")}, + {'e', QLatin1String("error")}, + {'e', QLatin1String("eval")}, + {'f', QLatin1String("file")}, + {'f', QLatin1String("filter")}, + {'f', QLatin1String("find")}, + {'f', QLatin1String("findstring")}, + {'f', QLatin1String("firstword")}, + {'f', QLatin1String("flavor")}, + {'f', QLatin1String("foreach")}, + {'g', QLatin1String("guile")}, + {'i', QLatin1String("if")}, + {'i', QLatin1String("info")}, + {'i', QLatin1String("install")}, + {'j', QLatin1String("join")}, + {'l', QLatin1String("lastword")}, + {'l', QLatin1String("load")}, + {'n', QLatin1String("notdir")}, + {'o', QLatin1String("or")}, + {'o', QLatin1String("origin")}, + {'p', QLatin1String("patsubst")}, + {'r', QLatin1String("ranlib")}, + {'r', QLatin1String("realpath")}, + {'r', QLatin1String("rm")}, + {'s', QLatin1String("shell")}, + {'s', QLatin1String("sort")}, + {'s', QLatin1String("strip")}, + {'s', QLatin1String("subst")}, + {'s', QLatin1String("suffix")}, + {'v', QLatin1String("value")}, + {'w', QLatin1String("warning")}, + {'w', QLatin1String("wildcard")}, + {'w', QLatin1String("word")} + }; + make_literals = { + {'t', QLatin1String("true")}, + {'f', QLatin1String("false")}, + }; + make_builtin = { + }; + make_other = { + {'C', QLatin1String("CFLAGS")}, + {'L', QLatin1String("LIBS")}, + {'P', QLatin1String("PREFIX")}, + }; +} + +void loadMakeData(QMultiHash &types, QMultiHash &keywords, QMultiHash &builtin, QMultiHash &literals, QMultiHash &other) +{ + if (!makeDataInitialized) { + initMakeData(); + makeDataInitialized = true; + } + types = make_types; + keywords = make_keywords; + builtin = make_builtin; + literals = make_literals; + other = make_other; +} + +void loadAsmData(QMultiHash& types, QMultiHash& keywords, QMultiHash& builtin, QMultiHash& literals, QMultiHash& other) +{ + Q_UNUSED(literals); + types = { + { 'i', QLatin1String("ip") }, + { 'e', QLatin1String("eip") }, + { 'r', QLatin1String("rip") }, + { 'a', QLatin1String("al") }, + { 'a', QLatin1String("ah") }, + { 'b', QLatin1String("bl") }, + { 'b', QLatin1String("bh") }, + { 'c', QLatin1String("cl") }, + { 'c', QLatin1String("ch") }, + { 'd', QLatin1String("dl") }, + { 'd', QLatin1String("dh") }, + { 's', QLatin1String("sil") }, + { 'd', QLatin1String("dil") }, + { 'b', QLatin1String("bpl") }, + { 's', QLatin1String("spl") }, + { 'r', QLatin1String("r8b") }, + { 'r', QLatin1String("r9b") }, + { 'r', QLatin1String("r10b") }, + { 'r', QLatin1String("r11b") }, + { 'r', QLatin1String("r12b") }, + { 'r', QLatin1String("r13b") }, + { 'r', QLatin1String("r14b") }, + { 'r', QLatin1String("r15b") }, + { 'b', QLatin1String("bx") }, + { 'c', QLatin1String("cx") }, + { 'd', QLatin1String("dx") }, + { 's', QLatin1String("si") }, + { 'd', QLatin1String("di") }, + { 'b', QLatin1String("bp") }, + { 's', QLatin1String("sp") }, + { 'r', QLatin1String("r8w") }, + { 'r', QLatin1String("r9w") }, + { 'r', QLatin1String("r10w") }, + { 'r', QLatin1String("r11w") }, + { 'r', QLatin1String("r12w") }, + { 'r', QLatin1String("r13w") }, + { 'r', QLatin1String("r14w") }, + { 'r', QLatin1String("r15w") }, + { 'e', QLatin1String("eax") }, + { 'e', QLatin1String("ebx") }, + { 'e', QLatin1String("ecx") }, + { 'e', QLatin1String("edx") }, + { 'e', QLatin1String("esi") }, + { 'e', QLatin1String("edi") }, + { 'e', QLatin1String("ebp") }, + { 'e', QLatin1String("esp") }, + { 'e', QLatin1String("eip") }, + { 'r', QLatin1String("r8d") }, + { 'r', QLatin1String("r9d") }, + { 'r', QLatin1String("r10d") }, + { 'r', QLatin1String("r11d") }, + { 'r', QLatin1String("r12d") }, + { 'r', QLatin1String("r13d") }, + { 'r', QLatin1String("r14d") }, + { 'r', QLatin1String("r15d") }, + { 'r', QLatin1String("rax") }, + { 'r', QLatin1String("rbx") }, + { 'r', QLatin1String("rcx") }, + { 'r', QLatin1String("rdx") }, + { 'r', QLatin1String("rsi") }, + { 'r', QLatin1String("rdi") }, + { 'r', QLatin1String("rbp") }, + { 'r', QLatin1String("rsp") }, + { 'r', QLatin1String("r8") }, + { 'r', QLatin1String("r9") }, + { 'r', QLatin1String("r10") }, + { 'r', QLatin1String("r11") }, + { 'r', QLatin1String("r12") }, + { 'r', QLatin1String("r13") }, + { 'r', QLatin1String("r14") }, + { 'r', QLatin1String("r15") }, + { 'd', QLatin1String("ds") }, + { 'e', QLatin1String("es") }, + { 'f', QLatin1String("fs") }, + { 'g', QLatin1String("gs") }, + { 's', QLatin1String("ss") }, + { 's', QLatin1String("st0") }, + { 's', QLatin1String("st1") }, + { 's', QLatin1String("st2") }, + { 's', QLatin1String("st3") }, + { 's', QLatin1String("st4") }, + { 's', QLatin1String("st5") }, + { 's', QLatin1String("st6") }, + { 's', QLatin1String("st7") }, + { 'm', QLatin1String("mm0") }, + { 'm', QLatin1String("mm1") }, + { 'm', QLatin1String("mm2") }, + { 'm', QLatin1String("mm3") }, + { 'm', QLatin1String("mm4") }, + { 'm', QLatin1String("mm5") }, + { 'm', QLatin1String("mm6") }, + { 'm', QLatin1String("mm7") }, + { 'x', QLatin1String("xmm0") }, + { 'x', QLatin1String("xmm1") }, + { 'x', QLatin1String("xmm2") }, + { 'x', QLatin1String("xmm3") }, + { 'x', QLatin1String("xmm4") }, + { 'x', QLatin1String("xmm5") }, + { 'x', QLatin1String("xmm6") }, + { 'x', QLatin1String("xmm7") }, + { 'x', QLatin1String("xmm8") }, + { 'x', QLatin1String("xmm9") }, + { 'x', QLatin1String("xmm10") }, + { 'x', QLatin1String("xmm11") }, + { 'x', QLatin1String("xmm12") }, + { 'x', QLatin1String("xmm13") }, + { 'x', QLatin1String("xmm14") }, + { 'x', QLatin1String("xmm15") }, + { 'x', QLatin1String("xmm16") }, + { 'x', QLatin1String("xmm17") }, + { 'x', QLatin1String("xmm18") }, + { 'x', QLatin1String("xmm19") }, + { 'x', QLatin1String("xmm20") }, + { 'x', QLatin1String("xmm21") }, + { 'x', QLatin1String("xmm22") }, + { 'x', QLatin1String("xmm23") }, + { 'x', QLatin1String("xmm24") }, + { 'x', QLatin1String("xmm25") }, + { 'x', QLatin1String("xmm26") }, + { 'x', QLatin1String("xmm27") }, + { 'x', QLatin1String("xmm28") }, + { 'x', QLatin1String("xmm29") }, + { 'x', QLatin1String("xmm30") }, + { 'x', QLatin1String("xmm31") }, + { 'y', QLatin1String("ymm0") }, + { 'y', QLatin1String("ymm1") }, + { 'y', QLatin1String("ymm2") }, + { 'y', QLatin1String("ymm3") }, + { 'y', QLatin1String("ymm4") }, + { 'y', QLatin1String("ymm5") }, + { 'y', QLatin1String("ymm6") }, + { 'y', QLatin1String("ymm7") }, + { 'y', QLatin1String("ymm8") }, + { 'y', QLatin1String("ymm9") }, + { 'y', QLatin1String("ymm10") }, + { 'y', QLatin1String("ymm11") }, + { 'y', QLatin1String("ymm12") }, + { 'y', QLatin1String("ymm13") }, + { 'y', QLatin1String("ymm14") }, + { 'y', QLatin1String("ymm15") }, + { 'y', QLatin1String("ymm16") }, + { 'y', QLatin1String("ymm17") }, + { 'y', QLatin1String("ymm18") }, + { 'y', QLatin1String("ymm19") }, + { 'y', QLatin1String("ymm20") }, + { 'y', QLatin1String("ymm21") }, + { 'y', QLatin1String("ymm22") }, + { 'y', QLatin1String("ymm23") }, + { 'y', QLatin1String("ymm24") }, + { 'y', QLatin1String("ymm25") }, + { 'y', QLatin1String("ymm26") }, + { 'y', QLatin1String("ymm27") }, + { 'y', QLatin1String("ymm28") }, + { 'y', QLatin1String("ymm29") }, + { 'y', QLatin1String("ymm30") }, + { 'y', QLatin1String("ymm31") }, + { 'z', QLatin1String("zmm0") }, + { 'z', QLatin1String("zmm1") }, + { 'z', QLatin1String("zmm2") }, + { 'z', QLatin1String("zmm3") }, + { 'z', QLatin1String("zmm4") }, + { 'z', QLatin1String("zmm5") }, + { 'z', QLatin1String("zmm6") }, + { 'z', QLatin1String("zmm7") }, + { 'z', QLatin1String("zmm8") }, + { 'z', QLatin1String("zmm9") }, + { 'z', QLatin1String("zmm10") }, + { 'z', QLatin1String("zmm11") }, + { 'z', QLatin1String("zmm12") }, + { 'z', QLatin1String("zmm13") }, + { 'z', QLatin1String("zmm14") }, + { 'z', QLatin1String("zmm15") }, + { 'z', QLatin1String("zmm16") }, + { 'z', QLatin1String("zmm17") }, + { 'z', QLatin1String("zmm18") }, + { 'z', QLatin1String("zmm19") }, + { 'z', QLatin1String("zmm20") }, + { 'z', QLatin1String("zmm21") }, + { 'z', QLatin1String("zmm22") }, + { 'z', QLatin1String("zmm23") }, + { 'z', QLatin1String("zmm24") }, + { 'z', QLatin1String("zmm25") }, + { 'z', QLatin1String("zmm26") }, + { 'z', QLatin1String("zmm27") }, + { 'z', QLatin1String("zmm28") }, + { 'z', QLatin1String("zmm29") }, + { 'z', QLatin1String("zmm30") }, + { 'z', QLatin1String("zmm31") }, + { 'k', QLatin1String("k0") }, + { 'k', QLatin1String("k1") }, + { 'k', QLatin1String("k2") }, + { 'k', QLatin1String("k3") }, + { 'k', QLatin1String("k4") }, + { 'k', QLatin1String("k5") }, + { 'k', QLatin1String("k6") }, + { 'k', QLatin1String("k7") }, + { 'b', QLatin1String("bnd0") }, + { 'b', QLatin1String("bnd1") }, + { 'b', QLatin1String("bnd2") }, + { 'b', QLatin1String("bnd3") }, + { 'c', QLatin1String("cr0") }, + { 'c', QLatin1String("cr1") }, + { 'c', QLatin1String("cr2") }, + { 'c', QLatin1String("cr3") }, + { 'c', QLatin1String("cr4") }, + { 'c', QLatin1String("cr8") }, + { 'd', QLatin1String("dr0") }, + { 'd', QLatin1String("dr1") }, + { 'd', QLatin1String("dr2") }, + { 'd', QLatin1String("dr3") }, + { 'd', QLatin1String("dr8") }, + { 't', QLatin1String("tr3") }, + { 't', QLatin1String("tr4") }, + { 't', QLatin1String("tr5") }, + { 't', QLatin1String("tr6") }, + { 't', QLatin1String("tr7") }, + { 'r', QLatin1String("r0") }, + { 'r', QLatin1String("r1") }, + { 'r', QLatin1String("r2") }, + { 'r', QLatin1String("r3") }, + { 'r', QLatin1String("r4") }, + { 'r', QLatin1String("r5") }, + { 'r', QLatin1String("r6") }, + { 'r', QLatin1String("r7") }, + { 'r', QLatin1String("r0b") }, + { 'r', QLatin1String("r1b") }, + { 'r', QLatin1String("r2b") }, + { 'r', QLatin1String("r3b") }, + { 'r', QLatin1String("r4b") }, + { 'r', QLatin1String("r5b") }, + { 'r', QLatin1String("r6b") }, + { 'r', QLatin1String("r7b") }, + { 'r', QLatin1String("r0w") }, + { 'r', QLatin1String("r1w") }, + { 'r', QLatin1String("r2w") }, + { 'r', QLatin1String("r3w") }, + { 'r', QLatin1String("r4w") }, + { 'r', QLatin1String("r5w") }, + { 'r', QLatin1String("r6w") }, + { 'r', QLatin1String("r7w") }, + { 'r', QLatin1String("r0d") }, + { 'r', QLatin1String("r1d") }, + { 'r', QLatin1String("r2d") }, + { 'r', QLatin1String("r3d") }, + { 'r', QLatin1String("r4d") }, + { 'r', QLatin1String("r5d") }, + { 'r', QLatin1String("r6d") }, + { 'r', QLatin1String("r7d") }, + { 'r', QLatin1String("r0h") }, + { 'r', QLatin1String("r1h") }, + { 'r', QLatin1String("r2h") }, + { 'r', QLatin1String("r3h") }, + { 'r', QLatin1String("r0l") }, + { 'r', QLatin1String("r1l") }, + { 'r', QLatin1String("r2l") }, + { 'r', QLatin1String("r3l") }, + { 'r', QLatin1String("r4l") }, + { 'r', QLatin1String("r5l") }, + { 'r', QLatin1String("r6l") }, + { 'r', QLatin1String("r7l") }, + { 'r', QLatin1String("r8l") }, + { 'r', QLatin1String("r9l") }, + { 'r', QLatin1String("r10l") }, + { 'r', QLatin1String("r11l") }, + { 'r', QLatin1String("r12l") }, + { 'r', QLatin1String("r13l") }, + { 'r', QLatin1String("r14l") }, + { 'r', QLatin1String("r15l") }, + { 'd', QLatin1String("db") }, + { 'd', QLatin1String("dw") }, + { 'd', QLatin1String("dd") }, + { 'd', QLatin1String("dq") }, + { 'd', QLatin1String("dt") }, + { 'd', QLatin1String("ddq") }, + { 'd', QLatin1String("do") }, + { 'd', QLatin1String("dy") }, + { 'd', QLatin1String("dz") }, + { 'r', QLatin1String("resb") }, + { 'r', QLatin1String("resw") }, + { 'r', QLatin1String("resd") }, + { 'r', QLatin1String("resq") }, + { 'r', QLatin1String("rest") }, + { 'r', QLatin1String("resdq") }, + { 'r', QLatin1String("reso") }, + { 'r', QLatin1String("resy") }, + { 'r', QLatin1String("resz") }, + { 'i', QLatin1String("inc") }, + { 'b', QLatin1String("bin") }, + { 'e', QLatin1String("equ") }, + { 't', QLatin1String("times") }, + { 'b', QLatin1String("byte") }, + { 'w', QLatin1String("word") }, + { 'd', QLatin1String("dword") }, + { 'q', QLatin1String("qword") }, + { 'n', QLatin1String("nosplit") }, + { 'r', QLatin1String("rel") }, + { 'a', QLatin1String("abs") }, + { 's', QLatin1String("seg") }, + { 'w', QLatin1String("wrt") }, + { 's', QLatin1String("strict") }, + { 'n', QLatin1String("near") }, + { 'f', QLatin1String("far") }, + { 'a', QLatin1String("a32") }, + { 'p', QLatin1String("ptr") } + }; + + keywords = { + { 'l', QLatin1String("lock") }, + { 'r', QLatin1String("rep") }, + { 'r', QLatin1String("repe") }, + { 'r', QLatin1String("repz") }, + { 'r', QLatin1String("repne") }, + { 'r', QLatin1String("repnz") }, + { 'x', QLatin1String("xaquire") }, + { 'x', QLatin1String("xrelease") }, + { 'b', QLatin1String("bnd") }, + { 'n', QLatin1String("nobnd") }, + { 'a', QLatin1String("aaa") }, + { 'a', QLatin1String("aad") }, + { 'a', QLatin1String("aam") }, + { 'a', QLatin1String("aas") }, + { 'a', QLatin1String("adc") }, + { 'a', QLatin1String("add") }, + { 'a', QLatin1String("addl") }, + { 'a', QLatin1String("and") }, + { 'a', QLatin1String("arpl") }, + { 'b', QLatin1String("bb0_reset") }, + { 'b', QLatin1String("bb1_reset") }, + { 'b', QLatin1String("bound") }, + { 'b', QLatin1String("bsf") }, + { 'b', QLatin1String("bsr") }, + { 'b', QLatin1String("bswap") }, + { 'b', QLatin1String("bt") }, + { 'b', QLatin1String("btc") }, + { 'b', QLatin1String("btr") }, + { 'b', QLatin1String("bts") }, + { 'c', QLatin1String("call") }, + { 'c', QLatin1String("cbw") }, + { 'c', QLatin1String("cdq") }, + { 'c', QLatin1String("cdqe") }, + { 'c', QLatin1String("clc") }, + { 'c', QLatin1String("cld") }, + { 'c', QLatin1String("cli") }, + { 'c', QLatin1String("clts") }, + { 'c', QLatin1String("cltd") }, + { 'c', QLatin1String("cmc") }, + { 'c', QLatin1String("cmp") }, + { 'c', QLatin1String("cmpl") }, + { 'c', QLatin1String("cmpsb") }, + { 'c', QLatin1String("cmpsd") }, + { 'c', QLatin1String("cmpsq") }, + { 'c', QLatin1String("cmpsw") }, + { 'c', QLatin1String("cmpxchg") }, + { 'c', QLatin1String("cmpxchg486") }, + { 'c', QLatin1String("cmpxchg8b") }, + { 'c', QLatin1String("cmpxchg16b") }, + { 'c', QLatin1String("cpuid") }, + { 'c', QLatin1String("cpu_read") }, + { 'c', QLatin1String("cpu_write") }, + { 'c', QLatin1String("cqo") }, + { 'c', QLatin1String("cwd") }, + { 'c', QLatin1String("cwde") }, + { 'd', QLatin1String("daa") }, + { 'd', QLatin1String("das") }, + { 'd', QLatin1String("dec") }, + { 'd', QLatin1String("div") }, + { 'd', QLatin1String("dmint") }, + { 'e', QLatin1String("emms") }, + { 'e', QLatin1String("enter") }, + { 'e', QLatin1String("equ") }, + { 'f', QLatin1String("f2xm1") }, + { 'f', QLatin1String("fabs") }, + { 'f', QLatin1String("fadd") }, + { 'f', QLatin1String("faddp") }, + { 'f', QLatin1String("fbld") }, + { 'f', QLatin1String("fbstp") }, + { 'f', QLatin1String("fchs") }, + { 'f', QLatin1String("fclex") }, + { 'f', QLatin1String("fcmovb") }, + { 'f', QLatin1String("fcmovbe") }, + { 'f', QLatin1String("fcmove") }, + { 'f', QLatin1String("fcmovnb") }, + { 'f', QLatin1String("fcmovnbe") }, + { 'f', QLatin1String("fcmovne") }, + { 'f', QLatin1String("fcmovnu") }, + { 'f', QLatin1String("fcmovu") }, + { 'f', QLatin1String("fcom") }, + { 'f', QLatin1String("fcomi") }, + { 'f', QLatin1String("fcomip") }, + { 'f', QLatin1String("fcomp") }, + { 'f', QLatin1String("fcompp") }, + { 'f', QLatin1String("fcos") }, + { 'f', QLatin1String("fdecstp") }, + { 'f', QLatin1String("fdisi") }, + { 'f', QLatin1String("fdiv") }, + { 'f', QLatin1String("fdivp") }, + { 'f', QLatin1String("fdivr") }, + { 'f', QLatin1String("fdivrp") }, + { 'f', QLatin1String("femms") }, + { 'f', QLatin1String("feni") }, + { 'f', QLatin1String("ffree") }, + { 'f', QLatin1String("ffreep") }, + { 'f', QLatin1String("fiadd") }, + { 'f', QLatin1String("ficom") }, + { 'f', QLatin1String("ficomp") }, + { 'f', QLatin1String("fidiv") }, + { 'f', QLatin1String("fidivr") }, + { 'f', QLatin1String("fild") }, + { 'f', QLatin1String("fimul") }, + { 'f', QLatin1String("fincstp") }, + { 'f', QLatin1String("finit") }, + { 'f', QLatin1String("fist") }, + { 'f', QLatin1String("fistp") }, + { 'f', QLatin1String("fisttp") }, + { 'f', QLatin1String("fisub") }, + { 'f', QLatin1String("fisubr") }, + { 'f', QLatin1String("fld") }, + { 'f', QLatin1String("fld1") }, + { 'f', QLatin1String("fldcw") }, + { 'f', QLatin1String("fldenv") }, + { 'f', QLatin1String("fldl2e") }, + { 'f', QLatin1String("fldl2t") }, + { 'f', QLatin1String("fldlg2") }, + { 'f', QLatin1String("fldln2") }, + { 'f', QLatin1String("fldpi") }, + { 'f', QLatin1String("fldz") }, + { 'f', QLatin1String("fmul") }, + { 'f', QLatin1String("fmulp") }, + { 'f', QLatin1String("fnclex") }, + { 'f', QLatin1String("fndisi") }, + { 'f', QLatin1String("fneni") }, + { 'f', QLatin1String("fninit") }, + { 'f', QLatin1String("fnop") }, + { 'f', QLatin1String("fnsave") }, + { 'f', QLatin1String("fnstcw") }, + { 'f', QLatin1String("fnstenv") }, + { 'f', QLatin1String("fnstsw") }, + { 'f', QLatin1String("fpatan") }, + { 'f', QLatin1String("fprem") }, + { 'f', QLatin1String("fprem1") }, + { 'f', QLatin1String("fptan") }, + { 'f', QLatin1String("frndint") }, + { 'f', QLatin1String("frstor") }, + { 'f', QLatin1String("fsave") }, + { 'f', QLatin1String("fscale") }, + { 'f', QLatin1String("fsetpm") }, + { 'f', QLatin1String("fsin") }, + { 'f', QLatin1String("fsincos") }, + { 'f', QLatin1String("fsqrt") }, + { 'f', QLatin1String("fst") }, + { 'f', QLatin1String("fstcw") }, + { 'f', QLatin1String("fstenv") }, + { 'f', QLatin1String("fstp") }, + { 'f', QLatin1String("fstsw") }, + { 'f', QLatin1String("fsub") }, + { 'f', QLatin1String("fsubp") }, + { 'f', QLatin1String("fsubr") }, + { 'f', QLatin1String("fsubrp") }, + { 'f', QLatin1String("ftst") }, + { 'f', QLatin1String("fucom") }, + { 'f', QLatin1String("fucomi") }, + { 'f', QLatin1String("fucomip") }, + { 'f', QLatin1String("fucomp") }, + { 'f', QLatin1String("fucompp") }, + { 'f', QLatin1String("fxam") }, + { 'f', QLatin1String("fxch") }, + { 'f', QLatin1String("fxtract") }, + { 'f', QLatin1String("fyl2x") }, + { 'f', QLatin1String("fyl2xp1") }, + { 'g', QLatin1String("global") }, + { 'g', QLatin1String("globl") }, + { 'h', QLatin1String("hlt") }, + { 'i', QLatin1String("ibts") }, + { 'i', QLatin1String("icebp") }, + { 'i', QLatin1String("idiv") }, + { 'i', QLatin1String("idivl") }, + { 'i', QLatin1String("idivq") }, + { 'i', QLatin1String("imul") }, + { 'i', QLatin1String("imull") }, + { 'i', QLatin1String("imulq") }, + { 'i', QLatin1String("in") }, + { 'i', QLatin1String("inc") }, + { 'i', QLatin1String("incbin") }, + { 'i', QLatin1String("insb") }, + { 'i', QLatin1String("insd") }, + { 'i', QLatin1String("insw") }, + { 'i', QLatin1String("int") }, + { 'i', QLatin1String("int01") }, + { 'i', QLatin1String("int1") }, + { 'i', QLatin1String("int03") }, + { 'i', QLatin1String("int3") }, + { 'i', QLatin1String("into") }, + { 'i', QLatin1String("invd") }, + { 'i', QLatin1String("invpcid") }, + { 'i', QLatin1String("invlpg") }, + { 'i', QLatin1String("invlpga") }, + { 'i', QLatin1String("iret") }, + { 'i', QLatin1String("iretd") }, + { 'i', QLatin1String("iretq") }, + { 'i', QLatin1String("iretw") }, + { 'j', QLatin1String("jcxz") }, + { 'j', QLatin1String("jecxz") }, + { 'j', QLatin1String("jrcxz") }, + { 'j', QLatin1String("jmp") }, + { 'j', QLatin1String("jmpe") }, + { 'l', QLatin1String("lahf") }, + { 'l', QLatin1String("lar") }, + { 'l', QLatin1String("lds") }, + { 'l', QLatin1String("lea") }, + { 'l', QLatin1String("leal") }, + { 'l', QLatin1String("leaq") }, + { 'l', QLatin1String("leave") }, + { 'l', QLatin1String("les") }, + { 'l', QLatin1String("lfence") }, + { 'l', QLatin1String("lfs") }, + { 'l', QLatin1String("lgdt") }, + { 'l', QLatin1String("lgs") }, + { 'l', QLatin1String("lidt") }, + { 'l', QLatin1String("lldt") }, + { 'l', QLatin1String("lmsw") }, + { 'l', QLatin1String("loadall") }, + { 'l', QLatin1String("loadall286") }, + { 'l', QLatin1String("lodsb") }, + { 'l', QLatin1String("lodsd") }, + { 'l', QLatin1String("lodsq") }, + { 'l', QLatin1String("lodsw") }, + { 'l', QLatin1String("loop") }, + { 'l', QLatin1String("loope") }, + { 'l', QLatin1String("loopne") }, + { 'l', QLatin1String("loopnz") }, + { 'l', QLatin1String("loopz") }, + { 'l', QLatin1String("lsl") }, + { 'l', QLatin1String("lss") }, + { 'l', QLatin1String("ltr") }, + { 'm', QLatin1String("mfence") }, + { 'm', QLatin1String("monitor") }, + { 'm', QLatin1String("mov") }, + { 'm', QLatin1String("movd") }, + { 'm', QLatin1String("movl") }, + { 'm', QLatin1String("movq") }, + { 'm', QLatin1String("movsb") }, + { 'm', QLatin1String("movsd") }, + { 'm', QLatin1String("movsq") }, + { 'm', QLatin1String("movsw") }, + { 'm', QLatin1String("movsx") }, + { 'm', QLatin1String("movsxd") }, + { 'm', QLatin1String("movzx") }, + { 'm', QLatin1String("mul") }, + { 'm', QLatin1String("mwait") }, + { 'n', QLatin1String("neg") }, + { 'n', QLatin1String("nop") }, + { 'n', QLatin1String("not") }, + { 'o', QLatin1String("or") }, + { 'o', QLatin1String("out") }, + { 'o', QLatin1String("outsb") }, + { 'o', QLatin1String("outsd") }, + { 'o', QLatin1String("outsw") }, + { 'p', QLatin1String("packssdw") }, + { 'p', QLatin1String("packsswb") }, + { 'p', QLatin1String("packuswb") }, + { 'p', QLatin1String("paddb") }, + { 'p', QLatin1String("paddd") }, + { 'p', QLatin1String("paddsb") }, + { 'p', QLatin1String("paddsiw") }, + { 'p', QLatin1String("paddsw") }, + { 'p', QLatin1String("paddusb") }, + { 'p', QLatin1String("paddusw") }, + { 'p', QLatin1String("paddw") }, + { 'p', QLatin1String("pand") }, + { 'p', QLatin1String("pandn") }, + { 'p', QLatin1String("pause") }, + { 'p', QLatin1String("paveb") }, + { 'p', QLatin1String("pavgusb") }, + { 'p', QLatin1String("pcmpeqb") }, + { 'p', QLatin1String("pcmpeqd") }, + { 'p', QLatin1String("pcmpeqw") }, + { 'p', QLatin1String("pcmpgtb") }, + { 'p', QLatin1String("pcmpgtd") }, + { 'p', QLatin1String("pcmpgtw") }, + { 'p', QLatin1String("pdistib") }, + { 'p', QLatin1String("pf2id") }, + { 'p', QLatin1String("pfacc") }, + { 'p', QLatin1String("pfadd") }, + { 'p', QLatin1String("pfcmpeq") }, + { 'p', QLatin1String("pfcmpge") }, + { 'p', QLatin1String("pfcmpgt") }, + { 'p', QLatin1String("pfmax") }, + { 'p', QLatin1String("pfmin") }, + { 'p', QLatin1String("pfmul") }, + { 'p', QLatin1String("pfrcp") }, + { 'p', QLatin1String("pfrcpit1") }, + { 'p', QLatin1String("pfrcpit2") }, + { 'p', QLatin1String("pfrsqit1") }, + { 'p', QLatin1String("pfrsqrt") }, + { 'p', QLatin1String("pfsub") }, + { 'p', QLatin1String("pfsubr") }, + { 'p', QLatin1String("pi2fd") }, + { 'p', QLatin1String("pmachriw") }, + { 'p', QLatin1String("pmaddwd") }, + { 'p', QLatin1String("pmagw") }, + { 'p', QLatin1String("pmulhriw") }, + { 'p', QLatin1String("pmulhrwa") }, + { 'p', QLatin1String("pmulhrwc") }, + { 'p', QLatin1String("pmulhw") }, + { 'p', QLatin1String("pmullw") }, + { 'p', QLatin1String("pmvgezb") }, + { 'p', QLatin1String("pmvlzb") }, + { 'p', QLatin1String("pmvnzb") }, + { 'p', QLatin1String("pmvzb") }, + { 'p', QLatin1String("pop") }, + { 'p', QLatin1String("popq") }, + { 'p', QLatin1String("popa") }, + { 'p', QLatin1String("popad") }, + { 'p', QLatin1String("popaw") }, + { 'p', QLatin1String("popf") }, + { 'p', QLatin1String("popfd") }, + { 'p', QLatin1String("popfq") }, + { 'p', QLatin1String("popfw") }, + { 'p', QLatin1String("por") }, + { 'p', QLatin1String("prefetch") }, + { 'p', QLatin1String("prefetchw") }, + { 'p', QLatin1String("pslld") }, + { 'p', QLatin1String("psllq") }, + { 'p', QLatin1String("psllw") }, + { 'p', QLatin1String("psrad") }, + { 'p', QLatin1String("psraw") }, + { 'p', QLatin1String("psrld") }, + { 'p', QLatin1String("psrlq") }, + { 'p', QLatin1String("psrlw") }, + { 'p', QLatin1String("psubb") }, + { 'p', QLatin1String("psubd") }, + { 'p', QLatin1String("psubsb") }, + { 'p', QLatin1String("psubsiw") }, + { 'p', QLatin1String("psubsw") }, + { 'p', QLatin1String("psubusb") }, + { 'p', QLatin1String("psubusw") }, + { 'p', QLatin1String("psubw") }, + { 'p', QLatin1String("punpckhbw") }, + { 'p', QLatin1String("punpckhdq") }, + { 'p', QLatin1String("punpckhwd") }, + { 'p', QLatin1String("punpcklbw") }, + { 'p', QLatin1String("punpckldq") }, + { 'p', QLatin1String("punpcklwd") }, + { 'p', QLatin1String("push") }, + { 'p', QLatin1String("pusha") }, + { 'p', QLatin1String("pushq") }, + { 'p', QLatin1String("pushad") }, + { 'p', QLatin1String("pushaw") }, + { 'p', QLatin1String("pushf") }, + { 'p', QLatin1String("pushfd") }, + { 'p', QLatin1String("pushfq") }, + { 'p', QLatin1String("pushfw") }, + { 'p', QLatin1String("pxor") }, + { 'r', QLatin1String("rcl") }, + { 'r', QLatin1String("rcr") }, + { 'r', QLatin1String("rdshr") }, + { 'r', QLatin1String("rdmsr") }, + { 'r', QLatin1String("rdpmc") }, + { 'r', QLatin1String("rdtsc") }, + { 'r', QLatin1String("rdtscp") }, + { 'r', QLatin1String("ret") }, + { 'r', QLatin1String("retf") }, + { 'r', QLatin1String("retn") }, + { 'r', QLatin1String("retq") }, + { 'r', QLatin1String("rol") }, + { 'r', QLatin1String("ror") }, + { 'r', QLatin1String("rdm") }, + { 'r', QLatin1String("rsdc") }, + { 'r', QLatin1String("rsldt") }, + { 'r', QLatin1String("rsm") }, + { 'r', QLatin1String("rsts") }, + { 's', QLatin1String("sahf") }, + { 's', QLatin1String("sal") }, + { 's', QLatin1String("sall") }, + { 's', QLatin1String("salq") }, + { 's', QLatin1String("salc") }, + { 's', QLatin1String("sar") }, + { 's', QLatin1String("sarl") }, + { 's', QLatin1String("sarq") }, + { 's', QLatin1String("sbb") }, + { 's', QLatin1String("scasb") }, + { 's', QLatin1String("scasd") }, + { 's', QLatin1String("scasq") }, + { 's', QLatin1String("scasw") }, + { 's', QLatin1String("sfence") }, + { 's', QLatin1String("sgdt") }, + { 's', QLatin1String("shl") }, + { 's', QLatin1String("shll") }, + { 's', QLatin1String("shllq") }, + { 's', QLatin1String("shld") }, + { 's', QLatin1String("shr") }, + { 's', QLatin1String("shrd") }, + { 's', QLatin1String("sidt") }, + { 's', QLatin1String("sldt") }, + { 's', QLatin1String("skinit") }, + { 's', QLatin1String("smi") }, + { 's', QLatin1String("smint") }, + { 's', QLatin1String("smintold") }, + { 's', QLatin1String("smsw") }, + { 's', QLatin1String("stc") }, + { 's', QLatin1String("std") }, + { 's', QLatin1String("sti") }, + { 's', QLatin1String("stosb") }, + { 's', QLatin1String("stosd") }, + { 's', QLatin1String("stosq") }, + { 's', QLatin1String("stosw") }, + { 's', QLatin1String("str") }, + { 's', QLatin1String("sub") }, + { 's', QLatin1String("svdc") }, + { 's', QLatin1String("svldt") }, + { 's', QLatin1String("svts") }, + { 's', QLatin1String("swapgs") }, + { 's', QLatin1String("syscall") }, + { 's', QLatin1String("sysenter") }, + { 's', QLatin1String("sysexit") }, + { 's', QLatin1String("sysret") }, + { 't', QLatin1String("test") }, + { 't', QLatin1String("testl") }, + { 't', QLatin1String("testq") }, + { 'u', QLatin1String("ud0") }, + { 'u', QLatin1String("ud1") }, + { 'u', QLatin1String("ud2b") }, + { 'u', QLatin1String("ud2") }, + { 'u', QLatin1String("ud2a") }, + { 'u', QLatin1String("umov") }, + { 'v', QLatin1String("verr") }, + { 'v', QLatin1String("verw") }, + { 'f', QLatin1String("fwait") }, + { 'w', QLatin1String("wbinvd") }, + { 'w', QLatin1String("wrshr") }, + { 'w', QLatin1String("wrmsr") }, + { 'x', QLatin1String("xadd") }, + { 'x', QLatin1String("xbts") }, + { 'x', QLatin1String("xchg") }, + { 'x', QLatin1String("xlatb") }, + { 'x', QLatin1String("xlat") }, + { 'x', QLatin1String("xor") }, + { 'c', QLatin1String("cmove") }, + { 'c', QLatin1String("cmovz") }, + { 'c', QLatin1String("cmovne") }, + { 'c', QLatin1String("cmovnz") }, + { 'c', QLatin1String("cmova") }, + { 'c', QLatin1String("cmovnbe") }, + { 'c', QLatin1String("cmovae") }, + { 'c', QLatin1String("cmovnb") }, + { 'c', QLatin1String("cmovb") }, + { 'c', QLatin1String("cmovnae") }, + { 'c', QLatin1String("cmovbe") }, + { 'c', QLatin1String("cmovna") }, + { 'c', QLatin1String("cmovg") }, + { 'c', QLatin1String("cmovnle") }, + { 'c', QLatin1String("cmovge") }, + { 'c', QLatin1String("cmovnl") }, + { 'c', QLatin1String("cmovl") }, + { 'c', QLatin1String("cmovnge") }, + { 'c', QLatin1String("cmovle") }, + { 'c', QLatin1String("cmovng") }, + { 'c', QLatin1String("cmovc") }, + { 'c', QLatin1String("cmovnc") }, + { 'c', QLatin1String("cmovo") }, + { 'c', QLatin1String("cmovno") }, + { 'c', QLatin1String("cmovs") }, + { 'c', QLatin1String("cmovns") }, + { 'c', QLatin1String("cmovp") }, + { 'c', QLatin1String("cmovpe") }, + { 'c', QLatin1String("cmovnp") }, + { 'c', QLatin1String("cmovpo") }, + { 'j', QLatin1String("je") }, + { 'j', QLatin1String("jz") }, + { 'j', QLatin1String("jne") }, + { 'j', QLatin1String("jnz") }, + { 'j', QLatin1String("ja") }, + { 'j', QLatin1String("jnbe") }, + { 'j', QLatin1String("jae") }, + { 'j', QLatin1String("jnb") }, + { 'j', QLatin1String("jb") }, + { 'j', QLatin1String("jnae") }, + { 'j', QLatin1String("jbe") }, + { 'j', QLatin1String("jna") }, + { 'j', QLatin1String("jg") }, + { 'j', QLatin1String("jnle") }, + { 'j', QLatin1String("jge") }, + { 'j', QLatin1String("jnl") }, + { 'j', QLatin1String("jl") }, + { 'j', QLatin1String("jnge") }, + { 'j', QLatin1String("jle") }, + { 'j', QLatin1String("jng") }, + { 'j', QLatin1String("jc") }, + { 'j', QLatin1String("jnc") }, + { 'j', QLatin1String("jo") }, + { 'j', QLatin1String("jno") }, + { 'j', QLatin1String("js") }, + { 'j', QLatin1String("jns") }, + { 'j', QLatin1String("jpo") }, + { 'j', QLatin1String("jnp") }, + { 'j', QLatin1String("jpe") }, + { 'j', QLatin1String("jp") }, + { 's', QLatin1String("sete") }, + { 's', QLatin1String("setz") }, + { 's', QLatin1String("setne") }, + { 's', QLatin1String("setnz") }, + { 's', QLatin1String("seta") }, + { 's', QLatin1String("setnbe") }, + { 's', QLatin1String("setae") }, + { 's', QLatin1String("setnb") }, + { 's', QLatin1String("setnc") }, + { 's', QLatin1String("setb") }, + { 's', QLatin1String("setnae") }, + { 's', QLatin1String("setcset") }, + { 's', QLatin1String("setbe") }, + { 's', QLatin1String("setna") }, + { 's', QLatin1String("setg") }, + { 's', QLatin1String("setnle") }, + { 's', QLatin1String("setge") }, + { 's', QLatin1String("setnl") }, + { 's', QLatin1String("setl") }, + { 's', QLatin1String("setnge") }, + { 's', QLatin1String("setle") }, + { 's', QLatin1String("setng") }, + { 's', QLatin1String("sets") }, + { 's', QLatin1String("setns") }, + { 's', QLatin1String("seto") }, + { 's', QLatin1String("setno") }, + { 's', QLatin1String("setpe") }, + { 's', QLatin1String("setp") }, + { 's', QLatin1String("setpo") }, + { 's', QLatin1String("setnp") }, + { 'a', QLatin1String("addps") }, + { 'a', QLatin1String("addss") }, + { 'a', QLatin1String("andnps") }, + { 'a', QLatin1String("andps") }, + { 'c', QLatin1String("cmpeqps") }, + { 'c', QLatin1String("cmpeqss") }, + { 'c', QLatin1String("cmpleps") }, + { 'c', QLatin1String("cmpless") }, + { 'c', QLatin1String("cmpltps") }, + { 'c', QLatin1String("cmpltss") }, + { 'c', QLatin1String("cmpneqps") }, + { 'c', QLatin1String("cmpneqss") }, + { 'c', QLatin1String("cmpnleps") }, + { 'c', QLatin1String("cmpnless") }, + { 'c', QLatin1String("cmpnltps") }, + { 'c', QLatin1String("cmpnltss") }, + { 'c', QLatin1String("cmpordps") }, + { 'c', QLatin1String("cmpordss") }, + { 'c', QLatin1String("cmpunordps") }, + { 'c', QLatin1String("cmpunordss") }, + { 'c', QLatin1String("cmpps") }, + { 'c', QLatin1String("cmpss") }, + { 'c', QLatin1String("comiss") }, + { 'c', QLatin1String("cvtpi2ps") }, + { 'c', QLatin1String("cvtps2pi") }, + { 'c', QLatin1String("cvtsi2ss") }, + { 'c', QLatin1String("cvtss2si") }, + { 'c', QLatin1String("cvttps2pi") }, + { 'c', QLatin1String("cvttss2si") }, + { 'd', QLatin1String("divps") }, + { 'd', QLatin1String("divss") }, + { 'l', QLatin1String("ldmxcsr") }, + { 'm', QLatin1String("maxps") }, + { 'm', QLatin1String("maxss") }, + { 'm', QLatin1String("minps") }, + { 'm', QLatin1String("minss") }, + { 'm', QLatin1String("movaps") }, + { 'm', QLatin1String("movhps") }, + { 'm', QLatin1String("movlhps") }, + { 'm', QLatin1String("movlps") }, + { 'm', QLatin1String("movhlps") }, + { 'm', QLatin1String("movmskps") }, + { 'm', QLatin1String("movntps") }, + { 'm', QLatin1String("movss") }, + { 'm', QLatin1String("movups") }, + { 'm', QLatin1String("mulps") }, + { 'm', QLatin1String("mulss") }, + { 'o', QLatin1String("orps") }, + { 'r', QLatin1String("rcpps") }, + { 'r', QLatin1String("rcpss") }, + { 'r', QLatin1String("rsqrtps") }, + { 'r', QLatin1String("rsqrtss") }, + { 's', QLatin1String("shufps") }, + { 's', QLatin1String("sqrtps") }, + { 's', QLatin1String("sqrtss") }, + { 's', QLatin1String("stmxcsr") }, + { 's', QLatin1String("subps") }, + { 's', QLatin1String("subss") }, + { 'u', QLatin1String("ucomiss") }, + { 'u', QLatin1String("unpckhps") }, + { 'u', QLatin1String("unpcklps") }, + { 'x', QLatin1String("xorps") }, + { 'f', QLatin1String("fxrstor") }, + { 'f', QLatin1String("fxrstor64") }, + { 'f', QLatin1String("fxsave") }, + { 'f', QLatin1String("fxsave64") }, + { 'x', QLatin1String("xgetbv") }, + { 'x', QLatin1String("xsetbv") }, + { 'x', QLatin1String("xsave") }, + { 'x', QLatin1String("xsave64") }, + { 'x', QLatin1String("xsaveopt") }, + { 'x', QLatin1String("xsaveopt64") }, + { 'x', QLatin1String("xrstor") }, + { 'x', QLatin1String("xrstor64") }, + { 'p', QLatin1String("prefetchnta") }, + { 'p', QLatin1String("prefetcht0") }, + { 'p', QLatin1String("prefetcht1") }, + { 'p', QLatin1String("prefetcht2") }, + { 'm', QLatin1String("maskmovq") }, + { 'm', QLatin1String("movntq") }, + { 'p', QLatin1String("pavgb") }, + { 'p', QLatin1String("pavgw") }, + { 'p', QLatin1String("pextrw") }, + { 'p', QLatin1String("pinsrw") }, + { 'p', QLatin1String("pmaxsw") }, + { 'p', QLatin1String("pmaxub") }, + { 'p', QLatin1String("pminsw") }, + { 'p', QLatin1String("pminub") }, + { 'p', QLatin1String("pmovmskb") }, + { 'p', QLatin1String("pmulhuw") }, + { 'p', QLatin1String("psadbw") }, + { 'p', QLatin1String("pshufw") }, + { 'p', QLatin1String("pf2iw") }, + { 'p', QLatin1String("pfnacc") }, + { 'p', QLatin1String("pfpnacc") }, + { 'p', QLatin1String("pi2fw") }, + { 'p', QLatin1String("pswapd") }, + { 'm', QLatin1String("maskmovdqu") }, + { 'c', QLatin1String("clflush") }, + { 'm', QLatin1String("movntdq") }, + { 'm', QLatin1String("movnti") }, + { 'm', QLatin1String("movntpd") }, + { 'm', QLatin1String("movdqa") }, + { 'm', QLatin1String("movdqu") }, + { 'm', QLatin1String("movdq2q") }, + { 'm', QLatin1String("movq2dq") }, + { 'p', QLatin1String("paddq") }, + { 'p', QLatin1String("pmuludq") }, + { 'p', QLatin1String("pshufd") }, + { 'p', QLatin1String("pshufhw") }, + { 'p', QLatin1String("pshuflw") }, + { 'p', QLatin1String("pslldq") }, + { 'p', QLatin1String("psrldq") }, + { 'p', QLatin1String("psubq") }, + { 'p', QLatin1String("punpckhqdq") }, + { 'p', QLatin1String("punpcklqdq") }, + { 'a', QLatin1String("addpd") }, + { 'a', QLatin1String("addsd") }, + { 'a', QLatin1String("andnpd") }, + { 'a', QLatin1String("andpd") }, + { 'c', QLatin1String("cmpeqpd") }, + { 'c', QLatin1String("cmpeqsd") }, + { 'c', QLatin1String("cmplepd") }, + { 'c', QLatin1String("cmplesd") }, + { 'c', QLatin1String("cmpltpd") }, + { 'c', QLatin1String("cmpltsd") }, + { 'c', QLatin1String("cmpneqpd") }, + { 'c', QLatin1String("cmpneqsd") }, + { 'c', QLatin1String("cmpnlepd") }, + { 'c', QLatin1String("cmpnlesd") }, + { 'c', QLatin1String("cmpnltpd") }, + { 'c', QLatin1String("cmpnltsd") }, + { 'c', QLatin1String("cmpordpd") }, + { 'c', QLatin1String("cmpordsd") }, + { 'c', QLatin1String("cmpunordpd") }, + { 'c', QLatin1String("cmpunordsd") }, + { 'c', QLatin1String("cmppd") }, + { 'c', QLatin1String("comisd") }, + { 'c', QLatin1String("cvtdq2pd") }, + { 'c', QLatin1String("cvtdq2ps") }, + { 'c', QLatin1String("cvtpd2dq") }, + { 'c', QLatin1String("cvtpd2pi") }, + { 'c', QLatin1String("cvtpd2ps") }, + { 'c', QLatin1String("cvtpi2pd") }, + { 'c', QLatin1String("cvtps2dq") }, + { 'c', QLatin1String("cvtps2pd") }, + { 'c', QLatin1String("cvtsd2si") }, + { 'c', QLatin1String("cvtsd2ss") }, + { 'c', QLatin1String("cvtsi2sd") }, + { 'c', QLatin1String("cvtss2sd") }, + { 'c', QLatin1String("cvttpd2pi") }, + { 'c', QLatin1String("cvttpd2dq") }, + { 'c', QLatin1String("cvttps2dq") }, + { 'c', QLatin1String("cvttsd2si") }, + { 'd', QLatin1String("divpd") }, + { 'd', QLatin1String("divsd") }, + { 'm', QLatin1String("maxpd") }, + { 'm', QLatin1String("maxsd") }, + { 'm', QLatin1String("minpd") }, + { 'm', QLatin1String("minsd") }, + { 'm', QLatin1String("movapd") }, + { 'm', QLatin1String("movhpd") }, + { 'm', QLatin1String("movlpd") }, + { 'm', QLatin1String("movmskpd") }, + { 'm', QLatin1String("movupd") }, + { 'm', QLatin1String("mulpd") }, + { 'm', QLatin1String("mulsd") }, + { 'o', QLatin1String("orpd") }, + { 's', QLatin1String("shufpd") }, + { 's', QLatin1String("sqrtpd") }, + { 's', QLatin1String("sqrtsd") }, + { 's', QLatin1String("subpd") }, + { 's', QLatin1String("subsd") }, + { 'u', QLatin1String("ucomisd") }, + { 'u', QLatin1String("unpckhpd") }, + { 'u', QLatin1String("unpcklpd") }, + { 'x', QLatin1String("xorpd") }, + { 'a', QLatin1String("addsubpd") }, + { 'a', QLatin1String("addsubps") }, + { 'h', QLatin1String("haddpd") }, + { 'h', QLatin1String("haddps") }, + { 'h', QLatin1String("hsubpd") }, + { 'h', QLatin1String("hsubps") }, + { 'l', QLatin1String("lddqu") }, + { 'm', QLatin1String("movddup") }, + { 'm', QLatin1String("movshdup") }, + { 'm', QLatin1String("movsldup") }, + { 'c', QLatin1String("clgi") }, + { 's', QLatin1String("stgi") }, + { 'v', QLatin1String("vmcall") }, + { 'v', QLatin1String("vmclear") }, + { 'v', QLatin1String("vmfunc") }, + { 'v', QLatin1String("vmlaunch") }, + { 'v', QLatin1String("vmload") }, + { 'v', QLatin1String("vmmcall") }, + { 'v', QLatin1String("vmptrld") }, + { 'v', QLatin1String("vmptrst") }, + { 'v', QLatin1String("vmread") }, + { 'v', QLatin1String("vmresume") }, + { 'v', QLatin1String("vmrun") }, + { 'v', QLatin1String("vmsave") }, + { 'v', QLatin1String("vmwrite") }, + { 'v', QLatin1String("vmxoff") }, + { 'v', QLatin1String("vmxon") }, + { 'i', QLatin1String("invept") }, + { 'i', QLatin1String("invvpid") }, + { 'p', QLatin1String("pabsb") }, + { 'p', QLatin1String("pabsw") }, + { 'p', QLatin1String("pabsd") }, + { 'p', QLatin1String("palignr") }, + { 'p', QLatin1String("phaddw") }, + { 'p', QLatin1String("phaddd") }, + { 'p', QLatin1String("phaddsw") }, + { 'p', QLatin1String("phsubw") }, + { 'p', QLatin1String("phsubd") }, + { 'p', QLatin1String("phsubsw") }, + { 'p', QLatin1String("pmaddubsw") }, + { 'p', QLatin1String("pmulhrsw") }, + { 'p', QLatin1String("pshufb") }, + { 'p', QLatin1String("psignb") }, + { 'p', QLatin1String("psignw") }, + { 'p', QLatin1String("psignd") }, + { 'e', QLatin1String("extrq") }, + { 'i', QLatin1String("insertq") }, + { 'm', QLatin1String("movntsd") }, + { 'm', QLatin1String("movntss") }, + { 'l', QLatin1String("lzcnt") }, + { 'b', QLatin1String("blendpd") }, + { 'b', QLatin1String("blendps") }, + { 'b', QLatin1String("blendvpd") }, + { 'b', QLatin1String("blendvps") }, + { 'd', QLatin1String("dppd") }, + { 'd', QLatin1String("dpps") }, + { 'e', QLatin1String("extractps") }, + { 'i', QLatin1String("insertps") }, + { 'm', QLatin1String("movntdqa") }, + { 'm', QLatin1String("mpsadbw") }, + { 'p', QLatin1String("packusdw") }, + { 'p', QLatin1String("pblendvb") }, + { 'p', QLatin1String("pblendw") }, + { 'p', QLatin1String("pcmpeqq") }, + { 'p', QLatin1String("pextrb") }, + { 'p', QLatin1String("pextrd") }, + { 'p', QLatin1String("pextrq") }, + { 'p', QLatin1String("phminposuw") }, + { 'p', QLatin1String("pinsrb") }, + { 'p', QLatin1String("pinsrd") }, + { 'p', QLatin1String("pinsrq") }, + { 'p', QLatin1String("pmaxsb") }, + { 'p', QLatin1String("pmaxsd") }, + { 'p', QLatin1String("pmaxud") }, + { 'p', QLatin1String("pmaxuw") }, + { 'p', QLatin1String("pminsb") }, + { 'p', QLatin1String("pminsd") }, + { 'p', QLatin1String("pminud") }, + { 'p', QLatin1String("pminuw") }, + { 'p', QLatin1String("pmovsxbw") }, + { 'p', QLatin1String("pmovsxbd") }, + { 'p', QLatin1String("pmovsxbq") }, + { 'p', QLatin1String("pmovsxwd") }, + { 'p', QLatin1String("pmovsxwq") }, + { 'p', QLatin1String("pmovsxdq") }, + { 'p', QLatin1String("pmovzxbw") }, + { 'p', QLatin1String("pmovzxbd") }, + { 'p', QLatin1String("pmovzxbq") }, + { 'p', QLatin1String("pmovzxwd") }, + { 'p', QLatin1String("pmovzxwq") }, + { 'p', QLatin1String("pmovzxdq") }, + { 'p', QLatin1String("pmuldq") }, + { 'p', QLatin1String("pmulld") }, + { 'p', QLatin1String("ptest") }, + { 'r', QLatin1String("roundpd") }, + { 'r', QLatin1String("roundps") }, + { 'r', QLatin1String("roundsd") }, + { 'r', QLatin1String("roundss") }, + { 'c', QLatin1String("crc32") }, + { 'p', QLatin1String("pcmpestri") }, + { 'p', QLatin1String("pcmpestrm") }, + { 'p', QLatin1String("pcmpistri") }, + { 'p', QLatin1String("pcmpistrm") }, + { 'p', QLatin1String("pcmpgtq") }, + { 'p', QLatin1String("popcnt") }, + { 'g', QLatin1String("getsec") }, + { 'p', QLatin1String("pfrcpv") }, + { 'p', QLatin1String("pfrsqrtv") }, + { 'm', QLatin1String("movbe") }, + { 'a', QLatin1String("aesenc") }, + { 'a', QLatin1String("aesenclast") }, + { 'a', QLatin1String("aesdec") }, + { 'a', QLatin1String("aesdeclast") }, + { 'a', QLatin1String("aesimc") }, + { 'a', QLatin1String("aeskeygenassist") }, + { 'v', QLatin1String("vaesenc") }, + { 'v', QLatin1String("vaesenclast") }, + { 'v', QLatin1String("vaesdec") }, + { 'v', QLatin1String("vaesdeclast") }, + { 'v', QLatin1String("vaesimc") }, + { 'v', QLatin1String("vaeskeygenassist") }, + { 'v', QLatin1String("vaddpd") }, + { 'v', QLatin1String("vaddps") }, + { 'v', QLatin1String("vaddsd") }, + { 'v', QLatin1String("vaddss") }, + { 'v', QLatin1String("vaddsubpd") }, + { 'v', QLatin1String("vaddsubps") }, + { 'v', QLatin1String("vandpd") }, + { 'v', QLatin1String("vandps") }, + { 'v', QLatin1String("vandnpd") }, + { 'v', QLatin1String("vandnps") }, + { 'v', QLatin1String("vblendpd") }, + { 'v', QLatin1String("vblendps") }, + { 'v', QLatin1String("vblendvpd") }, + { 'v', QLatin1String("vblendvps") }, + { 'v', QLatin1String("vbroadcastss") }, + { 'v', QLatin1String("vbroadcastsd") }, + { 'v', QLatin1String("vbroadcastf128") }, + { 'v', QLatin1String("vcmpeq_ospd") }, + { 'v', QLatin1String("vcmpeqpd") }, + { 'v', QLatin1String("vcmplt_ospd") }, + { 'v', QLatin1String("vcmpltpd") }, + { 'v', QLatin1String("vcmple_ospd") }, + { 'v', QLatin1String("vcmplepd") }, + { 'v', QLatin1String("vcmpunord_qpd") }, + { 'v', QLatin1String("vcmpunordpd") }, + { 'v', QLatin1String("vcmpneq_uqpd") }, + { 'v', QLatin1String("vcmpneqpd") }, + { 'v', QLatin1String("vcmpnlt_uspd") }, + { 'v', QLatin1String("vcmpnltpd") }, + { 'v', QLatin1String("vcmpnle_uspd") }, + { 'v', QLatin1String("vcmpnlepd") }, + { 'v', QLatin1String("vcmpord_qpd") }, + { 'v', QLatin1String("vcmpordpd") }, + { 'v', QLatin1String("vcmpeq_uqpd") }, + { 'v', QLatin1String("vcmpnge_uspd") }, + { 'v', QLatin1String("vcmpngepd") }, + { 'v', QLatin1String("vcmpngt_uspd") }, + { 'v', QLatin1String("vcmpngtpd") }, + { 'v', QLatin1String("vcmpfalse_oqpd") }, + { 'v', QLatin1String("vcmpfalsepd") }, + { 'v', QLatin1String("vcmpneq_oqpd") }, + { 'v', QLatin1String("vcmpge_ospd") }, + { 'v', QLatin1String("vcmpgepd") }, + { 'v', QLatin1String("vcmpgt_ospd") }, + { 'v', QLatin1String("vcmpgtpd") }, + { 'v', QLatin1String("vcmptrue_uqpd") }, + { 'v', QLatin1String("vcmptruepd") }, + { 'v', QLatin1String("vcmplt_oqpd") }, + { 'v', QLatin1String("vcmple_oqpd") }, + { 'v', QLatin1String("vcmpunord_spd") }, + { 'v', QLatin1String("vcmpneq_uspd") }, + { 'v', QLatin1String("vcmpnlt_uqpd") }, + { 'v', QLatin1String("vcmpnle_uqpd") }, + { 'v', QLatin1String("vcmpord_spd") }, + { 'v', QLatin1String("vcmpeq_uspd") }, + { 'v', QLatin1String("vcmpnge_uqpd") }, + { 'v', QLatin1String("vcmpngt_uqpd") }, + { 'v', QLatin1String("vcmpfalse_ospd") }, + { 'v', QLatin1String("vcmpneq_ospd") }, + { 'v', QLatin1String("vcmpge_oqpd") }, + { 'v', QLatin1String("vcmpgt_oqpd") }, + { 'v', QLatin1String("vcmptrue_uspd") }, + { 'v', QLatin1String("vcmppd") }, + { 'v', QLatin1String("vcmpeq_osps") }, + { 'v', QLatin1String("vcmpeqps") }, + { 'v', QLatin1String("vcmplt_osps") }, + { 'v', QLatin1String("vcmpltps") }, + { 'v', QLatin1String("vcmple_osps") }, + { 'v', QLatin1String("vcmpleps") }, + { 'v', QLatin1String("vcmpunord_qps") }, + { 'v', QLatin1String("vcmpunordps") }, + { 'v', QLatin1String("vcmpneq_uqps") }, + { 'v', QLatin1String("vcmpneqps") }, + { 'v', QLatin1String("vcmpnlt_usps") }, + { 'v', QLatin1String("vcmpnltps") }, + { 'v', QLatin1String("vcmpnle_usps") }, + { 'v', QLatin1String("vcmpnleps") }, + { 'v', QLatin1String("vcmpord_qps") }, + { 'v', QLatin1String("vcmpordps") }, + { 'v', QLatin1String("vcmpeq_uqps") }, + { 'v', QLatin1String("vcmpnge_usps") }, + { 'v', QLatin1String("vcmpngeps") }, + { 'v', QLatin1String("vcmpngt_usps") }, + { 'v', QLatin1String("vcmpngtps") }, + { 'v', QLatin1String("vcmpfalse_oqps") }, + { 'v', QLatin1String("vcmpfalseps") }, + { 'v', QLatin1String("vcmpneq_oqps") }, + { 'v', QLatin1String("vcmpge_osps") }, + { 'v', QLatin1String("vcmpgeps") }, + { 'v', QLatin1String("vcmpgt_osps") }, + { 'v', QLatin1String("vcmpgtps") }, + { 'v', QLatin1String("vcmptrue_uqps") }, + { 'v', QLatin1String("vcmptrueps") }, + { 'v', QLatin1String("vcmplt_oqps") }, + { 'v', QLatin1String("vcmple_oqps") }, + { 'v', QLatin1String("vcmpunord_sps") }, + { 'v', QLatin1String("vcmpneq_usps") }, + { 'v', QLatin1String("vcmpnlt_uqps") }, + { 'v', QLatin1String("vcmpnle_uqps") }, + { 'v', QLatin1String("vcmpord_sps") }, + { 'v', QLatin1String("vcmpeq_usps") }, + { 'v', QLatin1String("vcmpnge_uqps") }, + { 'v', QLatin1String("vcmpngt_uqps") }, + { 'v', QLatin1String("vcmpfalse_osps") }, + { 'v', QLatin1String("vcmpneq_osps") }, + { 'v', QLatin1String("vcmpge_oqps") }, + { 'v', QLatin1String("vcmpgt_oqps") }, + { 'v', QLatin1String("vcmptrue_usps") }, + { 'v', QLatin1String("vcmpps") }, + { 'v', QLatin1String("vcmpeq_ossd") }, + { 'v', QLatin1String("vcmpeqsd") }, + { 'v', QLatin1String("vcmplt_ossd") }, + { 'v', QLatin1String("vcmpltsd") }, + { 'v', QLatin1String("vcmple_ossd") }, + { 'v', QLatin1String("vcmplesd") }, + { 'v', QLatin1String("vcmpunord_qsd") }, + { 'v', QLatin1String("vcmpunordsd") }, + { 'v', QLatin1String("vcmpneq_uqsd") }, + { 'v', QLatin1String("vcmpneqsd") }, + { 'v', QLatin1String("vcmpnlt_ussd") }, + { 'v', QLatin1String("vcmpnltsd") }, + { 'v', QLatin1String("vcmpnle_ussd") }, + { 'v', QLatin1String("vcmpnlesd") }, + { 'v', QLatin1String("vcmpord_qsd") }, + { 'v', QLatin1String("vcmpordsd") }, + { 'v', QLatin1String("vcmpeq_uqsd") }, + { 'v', QLatin1String("vcmpnge_ussd") }, + { 'v', QLatin1String("vcmpngesd") }, + { 'v', QLatin1String("vcmpngt_ussd") }, + { 'v', QLatin1String("vcmpngtsd") }, + { 'v', QLatin1String("vcmpfalse_oqsd") }, + { 'v', QLatin1String("vcmpfalsesd") }, + { 'v', QLatin1String("vcmpneq_oqsd") }, + { 'v', QLatin1String("vcmpge_ossd") }, + { 'v', QLatin1String("vcmpgesd") }, + { 'v', QLatin1String("vcmpgt_ossd") }, + { 'v', QLatin1String("vcmpgtsd") }, + { 'v', QLatin1String("vcmptrue_uqsd") }, + { 'v', QLatin1String("vcmptruesd") }, + { 'v', QLatin1String("vcmplt_oqsd") }, + { 'v', QLatin1String("vcmple_oqsd") }, + { 'v', QLatin1String("vcmpunord_ssd") }, + { 'v', QLatin1String("vcmpneq_ussd") }, + { 'v', QLatin1String("vcmpnlt_uqsd") }, + { 'v', QLatin1String("vcmpnle_uqsd") }, + { 'v', QLatin1String("vcmpord_ssd") }, + { 'v', QLatin1String("vcmpeq_ussd") }, + { 'v', QLatin1String("vcmpnge_uqsd") }, + { 'v', QLatin1String("vcmpngt_uqsd") }, + { 'v', QLatin1String("vcmpfalse_ossd") }, + { 'v', QLatin1String("vcmpneq_ossd") }, + { 'v', QLatin1String("vcmpge_oqsd") }, + { 'v', QLatin1String("vcmpgt_oqsd") }, + { 'v', QLatin1String("vcmptrue_ussd") }, + { 'v', QLatin1String("vcmpsd") }, + { 'v', QLatin1String("vcmpeq_osss") }, + { 'v', QLatin1String("vcmpeqss") }, + { 'v', QLatin1String("vcmplt_osss") }, + { 'v', QLatin1String("vcmpltss") }, + { 'v', QLatin1String("vcmple_osss") }, + { 'v', QLatin1String("vcmpless") }, + { 'v', QLatin1String("vcmpunord_qss") }, + { 'v', QLatin1String("vcmpunordss") }, + { 'v', QLatin1String("vcmpneq_uqss") }, + { 'v', QLatin1String("vcmpneqss") }, + { 'v', QLatin1String("vcmpnlt_usss") }, + { 'v', QLatin1String("vcmpnltss") }, + { 'v', QLatin1String("vcmpnle_usss") }, + { 'v', QLatin1String("vcmpnless") }, + { 'v', QLatin1String("vcmpord_qss") }, + { 'v', QLatin1String("vcmpordss") }, + { 'v', QLatin1String("vcmpeq_uqss") }, + { 'v', QLatin1String("vcmpnge_usss") }, + { 'v', QLatin1String("vcmpngess") }, + { 'v', QLatin1String("vcmpngt_usss") }, + { 'v', QLatin1String("vcmpngtss") }, + { 'v', QLatin1String("vcmpfalse_oqss") }, + { 'v', QLatin1String("vcmpfalsess") }, + { 'v', QLatin1String("vcmpneq_oqss") }, + { 'v', QLatin1String("vcmpge_osss") }, + { 'v', QLatin1String("vcmpgess") }, + { 'v', QLatin1String("vcmpgt_osss") }, + { 'v', QLatin1String("vcmpgtss") }, + { 'v', QLatin1String("vcmptrue_uqss") }, + { 'v', QLatin1String("vcmptruess") }, + { 'v', QLatin1String("vcmplt_oqss") }, + { 'v', QLatin1String("vcmple_oqss") }, + { 'v', QLatin1String("vcmpunord_sss") }, + { 'v', QLatin1String("vcmpneq_usss") }, + { 'v', QLatin1String("vcmpnlt_uqss") }, + { 'v', QLatin1String("vcmpnle_uqss") }, + { 'v', QLatin1String("vcmpord_sss") }, + { 'v', QLatin1String("vcmpeq_usss") }, + { 'v', QLatin1String("vcmpnge_uqss") }, + { 'v', QLatin1String("vcmpngt_uqss") }, + { 'v', QLatin1String("vcmpfalse_osss") }, + { 'v', QLatin1String("vcmpneq_osss") }, + { 'v', QLatin1String("vcmpge_oqss") }, + { 'v', QLatin1String("vcmpgt_oqss") }, + { 'v', QLatin1String("vcmptrue_usss") }, + { 'v', QLatin1String("vcmpss") }, + { 'v', QLatin1String("vcomisd") }, + { 'v', QLatin1String("vcomiss") }, + { 'v', QLatin1String("vcvtdq2pd") }, + { 'v', QLatin1String("vcvtdq2ps") }, + { 'v', QLatin1String("vcvtpd2dq") }, + { 'v', QLatin1String("vcvtpd2ps") }, + { 'v', QLatin1String("vcvtps2dq") }, + { 'v', QLatin1String("vcvtps2pd") }, + { 'v', QLatin1String("vcvtsd2si") }, + { 'v', QLatin1String("vcvtsd2ss") }, + { 'v', QLatin1String("vcvtsi2sd") }, + { 'v', QLatin1String("vcvtsi2ss") }, + { 'v', QLatin1String("vcvtss2sd") }, + { 'v', QLatin1String("vcvtss2si") }, + { 'v', QLatin1String("vcvttpd2dq") }, + { 'v', QLatin1String("vcvttps2dq") }, + { 'v', QLatin1String("vcvttsd2si") }, + { 'v', QLatin1String("vcvttss2si") }, + { 'v', QLatin1String("vdivpd") }, + { 'v', QLatin1String("vdivps") }, + { 'v', QLatin1String("vdivsd") }, + { 'v', QLatin1String("vdivss") }, + { 'v', QLatin1String("vdppd") }, + { 'v', QLatin1String("vdpps") }, + { 'v', QLatin1String("vextractf128") }, + { 'v', QLatin1String("vextractps") }, + { 'v', QLatin1String("vhaddpd") }, + { 'v', QLatin1String("vhaddps") }, + { 'v', QLatin1String("vhsubpd") }, + { 'v', QLatin1String("vhsubps") }, + { 'v', QLatin1String("vinsertf128") }, + { 'v', QLatin1String("vinsertps") }, + { 'v', QLatin1String("vlddqu") }, + { 'v', QLatin1String("vldqqu") }, + { 'v', QLatin1String("vldmxcsr") }, + { 'v', QLatin1String("vmaskmovdqu") }, + { 'v', QLatin1String("vmaskmovps") }, + { 'v', QLatin1String("vmaskmovpd") }, + { 'v', QLatin1String("vmaxpd") }, + { 'v', QLatin1String("vmaxps") }, + { 'v', QLatin1String("vmaxsd") }, + { 'v', QLatin1String("vmaxss") }, + { 'v', QLatin1String("vminpd") }, + { 'v', QLatin1String("vminps") }, + { 'v', QLatin1String("vminsd") }, + { 'v', QLatin1String("vminss") }, + { 'v', QLatin1String("vmovapd") }, + { 'v', QLatin1String("vmovaps") }, + { 'v', QLatin1String("vmovd") }, + { 'v', QLatin1String("vmovq") }, + { 'v', QLatin1String("vmovddup") }, + { 'v', QLatin1String("vmovdqa") }, + { 'v', QLatin1String("vmovqqa") }, + { 'v', QLatin1String("vmovdqu") }, + { 'v', QLatin1String("vmovqqu") }, + { 'v', QLatin1String("vmovhlps") }, + { 'v', QLatin1String("vmovhpd") }, + { 'v', QLatin1String("vmovhps") }, + { 'v', QLatin1String("vmovlhps") }, + { 'v', QLatin1String("vmovlpd") }, + { 'v', QLatin1String("vmovlps") }, + { 'v', QLatin1String("vmovmskpd") }, + { 'v', QLatin1String("vmovmskps") }, + { 'v', QLatin1String("vmovntdq") }, + { 'v', QLatin1String("vmovntqq") }, + { 'v', QLatin1String("vmovntdqa") }, + { 'v', QLatin1String("vmovntpd") }, + { 'v', QLatin1String("vmovntps") }, + { 'v', QLatin1String("vmovsd") }, + { 'v', QLatin1String("vmovshdup") }, + { 'v', QLatin1String("vmovsldup") }, + { 'v', QLatin1String("vmovss") }, + { 'v', QLatin1String("vmovupd") }, + { 'v', QLatin1String("vmovups") }, + { 'v', QLatin1String("vmpsadbw") }, + { 'v', QLatin1String("vmulpd") }, + { 'v', QLatin1String("vmulps") }, + { 'v', QLatin1String("vmulsd") }, + { 'v', QLatin1String("vmulss") }, + { 'v', QLatin1String("vorpd") }, + { 'v', QLatin1String("vorps") }, + { 'v', QLatin1String("vpabsb") }, + { 'v', QLatin1String("vpabsw") }, + { 'v', QLatin1String("vpabsd") }, + { 'v', QLatin1String("vpacksswb") }, + { 'v', QLatin1String("vpackssdw") }, + { 'v', QLatin1String("vpackuswb") }, + { 'v', QLatin1String("vpackusdw") }, + { 'v', QLatin1String("vpaddb") }, + { 'v', QLatin1String("vpaddw") }, + { 'v', QLatin1String("vpaddd") }, + { 'v', QLatin1String("vpaddq") }, + { 'v', QLatin1String("vpaddsb") }, + { 'v', QLatin1String("vpaddsw") }, + { 'v', QLatin1String("vpaddusb") }, + { 'v', QLatin1String("vpaddusw") }, + { 'v', QLatin1String("vpalignr") }, + { 'v', QLatin1String("vpand") }, + { 'v', QLatin1String("vpandn") }, + { 'v', QLatin1String("vpavgb") }, + { 'v', QLatin1String("vpavgw") }, + { 'v', QLatin1String("vpblendvb") }, + { 'v', QLatin1String("vpblendw") }, + { 'v', QLatin1String("vpcmpestri") }, + { 'v', QLatin1String("vpcmpestrm") }, + { 'v', QLatin1String("vpcmpistri") }, + { 'v', QLatin1String("vpcmpistrm") }, + { 'v', QLatin1String("vpcmpeqb") }, + { 'v', QLatin1String("vpcmpeqw") }, + { 'v', QLatin1String("vpcmpeqd") }, + { 'v', QLatin1String("vpcmpeqq") }, + { 'v', QLatin1String("vpcmpgtb") }, + { 'v', QLatin1String("vpcmpgtw") }, + { 'v', QLatin1String("vpcmpgtd") }, + { 'v', QLatin1String("vpcmpgtq") }, + { 'v', QLatin1String("vpermilpd") }, + { 'v', QLatin1String("vpermilps") }, + { 'v', QLatin1String("vperm2f128") }, + { 'v', QLatin1String("vpextrb") }, + { 'v', QLatin1String("vpextrw") }, + { 'v', QLatin1String("vpextrd") }, + { 'v', QLatin1String("vpextrq") }, + { 'v', QLatin1String("vphaddw") }, + { 'v', QLatin1String("vphaddd") }, + { 'v', QLatin1String("vphaddsw") }, + { 'v', QLatin1String("vphminposuw") }, + { 'v', QLatin1String("vphsubw") }, + { 'v', QLatin1String("vphsubd") }, + { 'v', QLatin1String("vphsubsw") }, + { 'v', QLatin1String("vpinsrb") }, + { 'v', QLatin1String("vpinsrw") }, + { 'v', QLatin1String("vpinsrd") }, + { 'v', QLatin1String("vpinsrq") }, + { 'v', QLatin1String("vpmaddwd") }, + { 'v', QLatin1String("vpmaddubsw") }, + { 'v', QLatin1String("vpmaxsb") }, + { 'v', QLatin1String("vpmaxsw") }, + { 'v', QLatin1String("vpmaxsd") }, + { 'v', QLatin1String("vpmaxub") }, + { 'v', QLatin1String("vpmaxuw") }, + { 'v', QLatin1String("vpmaxud") }, + { 'v', QLatin1String("vpminsb") }, + { 'v', QLatin1String("vpminsw") }, + { 'v', QLatin1String("vpminsd") }, + { 'v', QLatin1String("vpminub") }, + { 'v', QLatin1String("vpminuw") }, + { 'v', QLatin1String("vpminud") }, + { 'v', QLatin1String("vpmovmskb") }, + { 'v', QLatin1String("vpmovsxbw") }, + { 'v', QLatin1String("vpmovsxbd") }, + { 'v', QLatin1String("vpmovsxbq") }, + { 'v', QLatin1String("vpmovsxwd") }, + { 'v', QLatin1String("vpmovsxwq") }, + { 'v', QLatin1String("vpmovsxdq") }, + { 'v', QLatin1String("vpmovzxbw") }, + { 'v', QLatin1String("vpmovzxbd") }, + { 'v', QLatin1String("vpmovzxbq") }, + { 'v', QLatin1String("vpmovzxwd") }, + { 'v', QLatin1String("vpmovzxwq") }, + { 'v', QLatin1String("vpmovzxdq") }, + { 'v', QLatin1String("vpmulhuw") }, + { 'v', QLatin1String("vpmulhrsw") }, + { 'v', QLatin1String("vpmulhw") }, + { 'v', QLatin1String("vpmullw") }, + { 'v', QLatin1String("vpmulld") }, + { 'v', QLatin1String("vpmuludq") }, + { 'v', QLatin1String("vpmuldq") }, + { 'v', QLatin1String("vpor") }, + { 'v', QLatin1String("vpsadbw") }, + { 'v', QLatin1String("vpshufb") }, + { 'v', QLatin1String("vpshufd") }, + { 'v', QLatin1String("vpshufhw") }, + { 'v', QLatin1String("vpshuflw") }, + { 'v', QLatin1String("vpsignb") }, + { 'v', QLatin1String("vpsignw") }, + { 'v', QLatin1String("vpsignd") }, + { 'v', QLatin1String("vpslldq") }, + { 'v', QLatin1String("vpsrldq") }, + { 'v', QLatin1String("vpsllw") }, + { 'v', QLatin1String("vpslld") }, + { 'v', QLatin1String("vpsllq") }, + { 'v', QLatin1String("vpsraw") }, + { 'v', QLatin1String("vpsrad") }, + { 'v', QLatin1String("vpsrlw") }, + { 'v', QLatin1String("vpsrld") }, + { 'v', QLatin1String("vpsrlq") }, + { 'v', QLatin1String("vptest") }, + { 'v', QLatin1String("vpsubb") }, + { 'v', QLatin1String("vpsubw") }, + { 'v', QLatin1String("vpsubd") }, + { 'v', QLatin1String("vpsubq") }, + { 'v', QLatin1String("vpsubsb") }, + { 'v', QLatin1String("vpsubsw") }, + { 'v', QLatin1String("vpsubusb") }, + { 'v', QLatin1String("vpsubusw") }, + { 'v', QLatin1String("vpunpckhbw") }, + { 'v', QLatin1String("vpunpckhwd") }, + { 'v', QLatin1String("vpunpckhdq") }, + { 'v', QLatin1String("vpunpckhqdq") }, + { 'v', QLatin1String("vpunpcklbw") }, + { 'v', QLatin1String("vpunpcklwd") }, + { 'v', QLatin1String("vpunpckldq") }, + { 'v', QLatin1String("vpunpcklqdq") }, + { 'v', QLatin1String("vpxor") }, + { 'v', QLatin1String("vrcpps") }, + { 'v', QLatin1String("vrcpss") }, + { 'v', QLatin1String("vrsqrtps") }, + { 'v', QLatin1String("vrsqrtss") }, + { 'v', QLatin1String("vroundpd") }, + { 'v', QLatin1String("vroundps") }, + { 'v', QLatin1String("vroundsd") }, + { 'v', QLatin1String("vroundss") }, + { 'v', QLatin1String("vshufpd") }, + { 'v', QLatin1String("vshufps") }, + { 'v', QLatin1String("vsqrtpd") }, + { 'v', QLatin1String("vsqrtps") }, + { 'v', QLatin1String("vsqrtsd") }, + { 'v', QLatin1String("vsqrtss") }, + { 'v', QLatin1String("vstmxcsr") }, + { 'v', QLatin1String("vsubpd") }, + { 'v', QLatin1String("vsubps") }, + { 'v', QLatin1String("vsubsd") }, + { 'v', QLatin1String("vsubss") }, + { 'v', QLatin1String("vtestps") }, + { 'v', QLatin1String("vtestpd") }, + { 'v', QLatin1String("vucomisd") }, + { 'v', QLatin1String("vucomiss") }, + { 'v', QLatin1String("vunpckhpd") }, + { 'v', QLatin1String("vunpckhps") }, + { 'v', QLatin1String("vunpcklpd") }, + { 'v', QLatin1String("vunpcklps") }, + { 'v', QLatin1String("vxorpd") }, + { 'v', QLatin1String("vxorps") }, + { 'v', QLatin1String("vzeroall") }, + { 'v', QLatin1String("vzeroupper") }, + { 'p', QLatin1String("pclmullqlqdq") }, + { 'p', QLatin1String("pclmulhqlqdq") }, + { 'p', QLatin1String("pclmullqhqdq") }, + { 'p', QLatin1String("pclmulhqhqdq") }, + { 'p', QLatin1String("pclmulqdq") }, + { 'v', QLatin1String("vpclmullqlqdq") }, + { 'v', QLatin1String("vpclmulhqlqdq") }, + { 'v', QLatin1String("vpclmullqhqdq") }, + { 'v', QLatin1String("vpclmulhqhqdq") }, + { 'v', QLatin1String("vpclmulqdq") }, + { 'v', QLatin1String("vfmadd132ps") }, + { 'v', QLatin1String("vfmadd132pd") }, + { 'v', QLatin1String("vfmadd312ps") }, + { 'v', QLatin1String("vfmadd312pd") }, + { 'v', QLatin1String("vfmadd213ps") }, + { 'v', QLatin1String("vfmadd213pd") }, + { 'v', QLatin1String("vfmadd123ps") }, + { 'v', QLatin1String("vfmadd123pd") }, + { 'v', QLatin1String("vfmadd231ps") }, + { 'v', QLatin1String("vfmadd231pd") }, + { 'v', QLatin1String("vfmadd321ps") }, + { 'v', QLatin1String("vfmadd321pd") }, + { 'v', QLatin1String("vfmaddsub132ps") }, + { 'v', QLatin1String("vfmaddsub132pd") }, + { 'v', QLatin1String("vfmaddsub312ps") }, + { 'v', QLatin1String("vfmaddsub312pd") }, + { 'v', QLatin1String("vfmaddsub213ps") }, + { 'v', QLatin1String("vfmaddsub213pd") }, + { 'v', QLatin1String("vfmaddsub123ps") }, + { 'v', QLatin1String("vfmaddsub123pd") }, + { 'v', QLatin1String("vfmaddsub231ps") }, + { 'v', QLatin1String("vfmaddsub231pd") }, + { 'v', QLatin1String("vfmaddsub321ps") }, + { 'v', QLatin1String("vfmaddsub321pd") }, + { 'v', QLatin1String("vfmsub132ps") }, + { 'v', QLatin1String("vfmsub132pd") }, + { 'v', QLatin1String("vfmsub312ps") }, + { 'v', QLatin1String("vfmsub312pd") }, + { 'v', QLatin1String("vfmsub213ps") }, + { 'v', QLatin1String("vfmsub213pd") }, + { 'v', QLatin1String("vfmsub123ps") }, + { 'v', QLatin1String("vfmsub123pd") }, + { 'v', QLatin1String("vfmsub231ps") }, + { 'v', QLatin1String("vfmsub231pd") }, + { 'v', QLatin1String("vfmsub321ps") }, + { 'v', QLatin1String("vfmsub321pd") }, + { 'v', QLatin1String("vfmsubadd132ps") }, + { 'v', QLatin1String("vfmsubadd132pd") }, + { 'v', QLatin1String("vfmsubadd312ps") }, + { 'v', QLatin1String("vfmsubadd312pd") }, + { 'v', QLatin1String("vfmsubadd213ps") }, + { 'v', QLatin1String("vfmsubadd213pd") }, + { 'v', QLatin1String("vfmsubadd123ps") }, + { 'v', QLatin1String("vfmsubadd123pd") }, + { 'v', QLatin1String("vfmsubadd231ps") }, + { 'v', QLatin1String("vfmsubadd231pd") }, + { 'v', QLatin1String("vfmsubadd321ps") }, + { 'v', QLatin1String("vfmsubadd321pd") }, + { 'v', QLatin1String("vfnmadd132ps") }, + { 'v', QLatin1String("vfnmadd132pd") }, + { 'v', QLatin1String("vfnmadd312ps") }, + { 'v', QLatin1String("vfnmadd312pd") }, + { 'v', QLatin1String("vfnmadd213ps") }, + { 'v', QLatin1String("vfnmadd213pd") }, + { 'v', QLatin1String("vfnmadd123ps") }, + { 'v', QLatin1String("vfnmadd123pd") }, + { 'v', QLatin1String("vfnmadd231ps") }, + { 'v', QLatin1String("vfnmadd231pd") }, + { 'v', QLatin1String("vfnmadd321ps") }, + { 'v', QLatin1String("vfnmadd321pd") }, + { 'v', QLatin1String("vfnmsub132ps") }, + { 'v', QLatin1String("vfnmsub132pd") }, + { 'v', QLatin1String("vfnmsub312ps") }, + { 'v', QLatin1String("vfnmsub312pd") }, + { 'v', QLatin1String("vfnmsub213ps") }, + { 'v', QLatin1String("vfnmsub213pd") }, + { 'v', QLatin1String("vfnmsub123ps") }, + { 'v', QLatin1String("vfnmsub123pd") }, + { 'v', QLatin1String("vfnmsub231ps") }, + { 'v', QLatin1String("vfnmsub231pd") }, + { 'v', QLatin1String("vfnmsub321ps") }, + { 'v', QLatin1String("vfnmsub321pd") }, + { 'v', QLatin1String("vfmadd132ss") }, + { 'v', QLatin1String("vfmadd132sd") }, + { 'v', QLatin1String("vfmadd312ss") }, + { 'v', QLatin1String("vfmadd312sd") }, + { 'v', QLatin1String("vfmadd213ss") }, + { 'v', QLatin1String("vfmadd213sd") }, + { 'v', QLatin1String("vfmadd123ss") }, + { 'v', QLatin1String("vfmadd123sd") }, + { 'v', QLatin1String("vfmadd231ss") }, + { 'v', QLatin1String("vfmadd231sd") }, + { 'v', QLatin1String("vfmadd321ss") }, + { 'v', QLatin1String("vfmadd321sd") }, + { 'v', QLatin1String("vfmsub132ss") }, + { 'v', QLatin1String("vfmsub132sd") }, + { 'v', QLatin1String("vfmsub312ss") }, + { 'v', QLatin1String("vfmsub312sd") }, + { 'v', QLatin1String("vfmsub213ss") }, + { 'v', QLatin1String("vfmsub213sd") }, + { 'v', QLatin1String("vfmsub123ss") }, + { 'v', QLatin1String("vfmsub123sd") }, + { 'v', QLatin1String("vfmsub231ss") }, + { 'v', QLatin1String("vfmsub231sd") }, + { 'v', QLatin1String("vfmsub321ss") }, + { 'v', QLatin1String("vfmsub321sd") }, + { 'v', QLatin1String("vfnmadd132ss") }, + { 'v', QLatin1String("vfnmadd132sd") }, + { 'v', QLatin1String("vfnmadd312ss") }, + { 'v', QLatin1String("vfnmadd312sd") }, + { 'v', QLatin1String("vfnmadd213ss") }, + { 'v', QLatin1String("vfnmadd213sd") }, + { 'v', QLatin1String("vfnmadd123ss") }, + { 'v', QLatin1String("vfnmadd123sd") }, + { 'v', QLatin1String("vfnmadd231ss") }, + { 'v', QLatin1String("vfnmadd231sd") }, + { 'v', QLatin1String("vfnmadd321ss") }, + { 'v', QLatin1String("vfnmadd321sd") }, + { 'v', QLatin1String("vfnmsub132ss") }, + { 'v', QLatin1String("vfnmsub132sd") }, + { 'v', QLatin1String("vfnmsub312ss") }, + { 'v', QLatin1String("vfnmsub312sd") }, + { 'v', QLatin1String("vfnmsub213ss") }, + { 'v', QLatin1String("vfnmsub213sd") }, + { 'v', QLatin1String("vfnmsub123ss") }, + { 'v', QLatin1String("vfnmsub123sd") }, + { 'v', QLatin1String("vfnmsub231ss") }, + { 'v', QLatin1String("vfnmsub231sd") }, + { 'v', QLatin1String("vfnmsub321ss") }, + { 'v', QLatin1String("vfnmsub321sd") }, + { 'r', QLatin1String("rdfsbase") }, + { 'r', QLatin1String("rdgsbase") }, + { 'r', QLatin1String("rdrand") }, + { 'w', QLatin1String("wrfsbase") }, + { 'w', QLatin1String("wrgsbase") }, + { 'v', QLatin1String("vcvtph2ps") }, + { 'v', QLatin1String("vcvtps2ph") }, + { 'a', QLatin1String("adcx") }, + { 'a', QLatin1String("adox") }, + { 'r', QLatin1String("rdseed") }, + { 'c', QLatin1String("clac") }, + { 's', QLatin1String("stac") }, + { 'x', QLatin1String("xstore") }, + { 'x', QLatin1String("xcryptecb") }, + { 'x', QLatin1String("xcryptcbc") }, + { 'x', QLatin1String("xcryptctr") }, + { 'x', QLatin1String("xcryptcfb") }, + { 'x', QLatin1String("xcryptofb") }, + { 'm', QLatin1String("montmul") }, + { 'x', QLatin1String("xsha1") }, + { 'x', QLatin1String("xsha256") }, + { 'l', QLatin1String("llwpcb") }, + { 's', QLatin1String("slwpcb") }, + { 'l', QLatin1String("lwpval") }, + { 'l', QLatin1String("lwpins") }, + { 'v', QLatin1String("vfmaddpd") }, + { 'v', QLatin1String("vfmaddps") }, + { 'v', QLatin1String("vfmaddsd") }, + { 'v', QLatin1String("vfmaddss") }, + { 'v', QLatin1String("vfmaddsubpd") }, + { 'v', QLatin1String("vfmaddsubps") }, + { 'v', QLatin1String("vfmsubaddpd") }, + { 'v', QLatin1String("vfmsubaddps") }, + { 'v', QLatin1String("vfmsubpd") }, + { 'v', QLatin1String("vfmsubps") }, + { 'v', QLatin1String("vfmsubsd") }, + { 'v', QLatin1String("vfmsubss") }, + { 'v', QLatin1String("vfnmaddpd") }, + { 'v', QLatin1String("vfnmaddps") }, + { 'v', QLatin1String("vfnmaddsd") }, + { 'v', QLatin1String("vfnmaddss") }, + { 'v', QLatin1String("vfnmsubpd") }, + { 'v', QLatin1String("vfnmsubps") }, + { 'v', QLatin1String("vfnmsubsd") }, + { 'v', QLatin1String("vfnmsubss") }, + { 'v', QLatin1String("vfrczpd") }, + { 'v', QLatin1String("vfrczps") }, + { 'v', QLatin1String("vfrczsd") }, + { 'v', QLatin1String("vfrczss") }, + { 'v', QLatin1String("vpcmov") }, + { 'v', QLatin1String("vpcomb") }, + { 'v', QLatin1String("vpcomd") }, + { 'v', QLatin1String("vpcomq") }, + { 'v', QLatin1String("vpcomub") }, + { 'v', QLatin1String("vpcomud") }, + { 'v', QLatin1String("vpcomuq") }, + { 'v', QLatin1String("vpcomuw") }, + { 'v', QLatin1String("vpcomw") }, + { 'v', QLatin1String("vphaddbd") }, + { 'v', QLatin1String("vphaddbq") }, + { 'v', QLatin1String("vphaddbw") }, + { 'v', QLatin1String("vphadddq") }, + { 'v', QLatin1String("vphaddubd") }, + { 'v', QLatin1String("vphaddubq") }, + { 'v', QLatin1String("vphaddubw") }, + { 'v', QLatin1String("vphaddudq") }, + { 'v', QLatin1String("vphadduwd") }, + { 'v', QLatin1String("vphadduwq") }, + { 'v', QLatin1String("vphaddwd") }, + { 'v', QLatin1String("vphaddwq") }, + { 'v', QLatin1String("vphsubbw") }, + { 'v', QLatin1String("vphsubdq") }, + { 'v', QLatin1String("vphsubwd") }, + { 'v', QLatin1String("vpmacsdd") }, + { 'v', QLatin1String("vpmacsdqh") }, + { 'v', QLatin1String("vpmacsdql") }, + { 'v', QLatin1String("vpmacssdd") }, + { 'v', QLatin1String("vpmacssdqh") }, + { 'v', QLatin1String("vpmacssdql") }, + { 'v', QLatin1String("vpmacsswd") }, + { 'v', QLatin1String("vpmacssww") }, + { 'v', QLatin1String("vpmacswd") }, + { 'v', QLatin1String("vpmacsww") }, + { 'v', QLatin1String("vpmadcsswd") }, + { 'v', QLatin1String("vpmadcswd") }, + { 'v', QLatin1String("vpperm") }, + { 'v', QLatin1String("vprotb") }, + { 'v', QLatin1String("vprotd") }, + { 'v', QLatin1String("vprotq") }, + { 'v', QLatin1String("vprotw") }, + { 'v', QLatin1String("vpshab") }, + { 'v', QLatin1String("vpshad") }, + { 'v', QLatin1String("vpshaq") }, + { 'v', QLatin1String("vpshaw") }, + { 'v', QLatin1String("vpshlb") }, + { 'v', QLatin1String("vpshld") }, + { 'v', QLatin1String("vpshlq") }, + { 'v', QLatin1String("vpshlw") }, + { 'v', QLatin1String("vbroadcasti128") }, + { 'v', QLatin1String("vpblendd") }, + { 'v', QLatin1String("vpbroadcastb") }, + { 'v', QLatin1String("vpbroadcastw") }, + { 'v', QLatin1String("vpbroadcastd") }, + { 'v', QLatin1String("vpbroadcastq") }, + { 'v', QLatin1String("vpermd") }, + { 'v', QLatin1String("vpermpd") }, + { 'v', QLatin1String("vpermps") }, + { 'v', QLatin1String("vpermq") }, + { 'v', QLatin1String("vperm2i128") }, + { 'v', QLatin1String("vextracti128") }, + { 'v', QLatin1String("vinserti128") }, + { 'v', QLatin1String("vpmaskmovd") }, + { 'v', QLatin1String("vpmaskmovq") }, + { 'v', QLatin1String("vpsllvd") }, + { 'v', QLatin1String("vpsllvq") }, + { 'v', QLatin1String("vpsravd") }, + { 'v', QLatin1String("vpsrlvd") }, + { 'v', QLatin1String("vpsrlvq") }, + { 'v', QLatin1String("vgatherdpd") }, + { 'v', QLatin1String("vgatherqpd") }, + { 'v', QLatin1String("vgatherdps") }, + { 'v', QLatin1String("vgatherqps") }, + { 'v', QLatin1String("vpgatherdd") }, + { 'v', QLatin1String("vpgatherqd") }, + { 'v', QLatin1String("vpgatherdq") }, + { 'v', QLatin1String("vpgatherqq") }, + { 'x', QLatin1String("xabort") }, + { 'x', QLatin1String("xbegin") }, + { 'x', QLatin1String("xend") }, + { 'x', QLatin1String("xtest") }, + { 'a', QLatin1String("andn") }, + { 'b', QLatin1String("bextr") }, + { 'b', QLatin1String("blci") }, + { 'b', QLatin1String("blcic") }, + { 'b', QLatin1String("blsi") }, + { 'b', QLatin1String("blsic") }, + { 'b', QLatin1String("blcfill") }, + { 'b', QLatin1String("blsfill") }, + { 'b', QLatin1String("blcmsk") }, + { 'b', QLatin1String("blsmsk") }, + { 'b', QLatin1String("blsr") }, + { 'b', QLatin1String("blcs") }, + { 'b', QLatin1String("bzhi") }, + { 'm', QLatin1String("mulx") }, + { 'p', QLatin1String("pdep") }, + { 'p', QLatin1String("pext") }, + { 'r', QLatin1String("rorx") }, + { 's', QLatin1String("sarx") }, + { 's', QLatin1String("shlx") }, + { 's', QLatin1String("shrx") }, + { 't', QLatin1String("tzcnt") }, + { 't', QLatin1String("tzmsk") }, + { 't', QLatin1String("t1mskc") }, + { 'v', QLatin1String("valignd") }, + { 'v', QLatin1String("valignq") }, + { 'v', QLatin1String("vblendmpd") }, + { 'v', QLatin1String("vblendmps") }, + { 'v', QLatin1String("vbroadcastf32x4") }, + { 'v', QLatin1String("vbroadcastf64x4") }, + { 'v', QLatin1String("vbroadcasti32x4") }, + { 'v', QLatin1String("vbroadcasti64x4") }, + { 'v', QLatin1String("vcompresspd") }, + { 'v', QLatin1String("vcompressps") }, + { 'v', QLatin1String("vcvtpd2udq") }, + { 'v', QLatin1String("vcvtps2udq") }, + { 'v', QLatin1String("vcvtsd2usi") }, + { 'v', QLatin1String("vcvtss2usi") }, + { 'v', QLatin1String("vcvttpd2udq") }, + { 'v', QLatin1String("vcvttps2udq") }, + { 'v', QLatin1String("vcvttsd2usi") }, + { 'v', QLatin1String("vcvttss2usi") }, + { 'v', QLatin1String("vcvtudq2pd") }, + { 'v', QLatin1String("vcvtudq2ps") }, + { 'v', QLatin1String("vcvtusi2sd") }, + { 'v', QLatin1String("vcvtusi2ss") }, + { 'v', QLatin1String("vexpandpd") }, + { 'v', QLatin1String("vexpandps") }, + { 'v', QLatin1String("vextractf32x4") }, + { 'v', QLatin1String("vextractf64x4") }, + { 'v', QLatin1String("vextracti32x4") }, + { 'v', QLatin1String("vextracti64x4") }, + { 'v', QLatin1String("vfixupimmpd") }, + { 'v', QLatin1String("vfixupimmps") }, + { 'v', QLatin1String("vfixupimmsd") }, + { 'v', QLatin1String("vfixupimmss") }, + { 'v', QLatin1String("vgetexppd") }, + { 'v', QLatin1String("vgetexpps") }, + { 'v', QLatin1String("vgetexpsd") }, + { 'v', QLatin1String("vgetexpss") }, + { 'v', QLatin1String("vgetmantpd") }, + { 'v', QLatin1String("vgetmantps") }, + { 'v', QLatin1String("vgetmantsd") }, + { 'v', QLatin1String("vgetmantss") }, + { 'v', QLatin1String("vinsertf32x4") }, + { 'v', QLatin1String("vinsertf64x4") }, + { 'v', QLatin1String("vinserti32x4") }, + { 'v', QLatin1String("vinserti64x4") }, + { 'v', QLatin1String("vmovdqa32") }, + { 'v', QLatin1String("vmovdqa64") }, + { 'v', QLatin1String("vmovdqu32") }, + { 'v', QLatin1String("vmovdqu64") }, + { 'v', QLatin1String("vpabsq") }, + { 'v', QLatin1String("vpandd") }, + { 'v', QLatin1String("vpandnd") }, + { 'v', QLatin1String("vpandnq") }, + { 'v', QLatin1String("vpandq") }, + { 'v', QLatin1String("vpblendmd") }, + { 'v', QLatin1String("vpblendmq") }, + { 'v', QLatin1String("vpcmpltd") }, + { 'v', QLatin1String("vpcmpled") }, + { 'v', QLatin1String("vpcmpneqd") }, + { 'v', QLatin1String("vpcmpnltd") }, + { 'v', QLatin1String("vpcmpnled") }, + { 'v', QLatin1String("vpcmpd") }, + { 'v', QLatin1String("vpcmpltq") }, + { 'v', QLatin1String("vpcmpleq") }, + { 'v', QLatin1String("vpcmpneqq") }, + { 'v', QLatin1String("vpcmpnltq") }, + { 'v', QLatin1String("vpcmpnleq") }, + { 'v', QLatin1String("vpcmpq") }, + { 'v', QLatin1String("vpcmpequd") }, + { 'v', QLatin1String("vpcmpltud") }, + { 'v', QLatin1String("vpcmpleud") }, + { 'v', QLatin1String("vpcmpnequd") }, + { 'v', QLatin1String("vpcmpnltud") }, + { 'v', QLatin1String("vpcmpnleud") }, + { 'v', QLatin1String("vpcmpud") }, + { 'v', QLatin1String("vpcmpequq") }, + { 'v', QLatin1String("vpcmpltuq") }, + { 'v', QLatin1String("vpcmpleuq") }, + { 'v', QLatin1String("vpcmpnequq") }, + { 'v', QLatin1String("vpcmpnltuq") }, + { 'v', QLatin1String("vpcmpnleuq") }, + { 'v', QLatin1String("vpcmpuq") }, + { 'v', QLatin1String("vpcompressd") }, + { 'v', QLatin1String("vpcompressq") }, + { 'v', QLatin1String("vpermi2d") }, + { 'v', QLatin1String("vpermi2pd") }, + { 'v', QLatin1String("vpermi2ps") }, + { 'v', QLatin1String("vpermi2q") }, + { 'v', QLatin1String("vpermt2d") }, + { 'v', QLatin1String("vpermt2pd") }, + { 'v', QLatin1String("vpermt2ps") }, + { 'v', QLatin1String("vpermt2q") }, + { 'v', QLatin1String("vpexpandd") }, + { 'v', QLatin1String("vpexpandq") }, + { 'v', QLatin1String("vpmaxsq") }, + { 'v', QLatin1String("vpmaxuq") }, + { 'v', QLatin1String("vpminsq") }, + { 'v', QLatin1String("vpminuq") }, + { 'v', QLatin1String("vpmovdb") }, + { 'v', QLatin1String("vpmovdw") }, + { 'v', QLatin1String("vpmovqb") }, + { 'v', QLatin1String("vpmovqd") }, + { 'v', QLatin1String("vpmovqw") }, + { 'v', QLatin1String("vpmovsdb") }, + { 'v', QLatin1String("vpmovsdw") }, + { 'v', QLatin1String("vpmovsqb") }, + { 'v', QLatin1String("vpmovsqd") }, + { 'v', QLatin1String("vpmovsqw") }, + { 'v', QLatin1String("vpmovusdb") }, + { 'v', QLatin1String("vpmovusdw") }, + { 'v', QLatin1String("vpmovusqb") }, + { 'v', QLatin1String("vpmovusqd") }, + { 'v', QLatin1String("vpmovusqw") }, + { 'v', QLatin1String("vpord") }, + { 'v', QLatin1String("vporq") }, + { 'v', QLatin1String("vprold") }, + { 'v', QLatin1String("vprolq") }, + { 'v', QLatin1String("vprolvd") }, + { 'v', QLatin1String("vprolvq") }, + { 'v', QLatin1String("vprord") }, + { 'v', QLatin1String("vprorq") }, + { 'v', QLatin1String("vprorvd") }, + { 'v', QLatin1String("vprorvq") }, + { 'v', QLatin1String("vpscatterdd") }, + { 'v', QLatin1String("vpscatterdq") }, + { 'v', QLatin1String("vpscatterqd") }, + { 'v', QLatin1String("vpscatterqq") }, + { 'v', QLatin1String("vpsraq") }, + { 'v', QLatin1String("vpsravq") }, + { 'v', QLatin1String("vpternlogd") }, + { 'v', QLatin1String("vpternlogq") }, + { 'v', QLatin1String("vptestmd") }, + { 'v', QLatin1String("vptestmq") }, + { 'v', QLatin1String("vptestnmd") }, + { 'v', QLatin1String("vptestnmq") }, + { 'v', QLatin1String("vpxord") }, + { 'v', QLatin1String("vpxorq") }, + { 'v', QLatin1String("vrcp14pd") }, + { 'v', QLatin1String("vrcp14ps") }, + { 'v', QLatin1String("vrcp14sd") }, + { 'v', QLatin1String("vrcp14ss") }, + { 'v', QLatin1String("vrndscalepd") }, + { 'v', QLatin1String("vrndscaleps") }, + { 'v', QLatin1String("vrndscalesd") }, + { 'v', QLatin1String("vrndscaless") }, + { 'v', QLatin1String("vrsqrt14pd") }, + { 'v', QLatin1String("vrsqrt14ps") }, + { 'v', QLatin1String("vrsqrt14sd") }, + { 'v', QLatin1String("vrsqrt14ss") }, + { 'v', QLatin1String("vscalefpd") }, + { 'v', QLatin1String("vscalefps") }, + { 'v', QLatin1String("vscalefsd") }, + { 'v', QLatin1String("vscalefss") }, + { 'v', QLatin1String("vscatterdpd") }, + { 'v', QLatin1String("vscatterdps") }, + { 'v', QLatin1String("vscatterqpd") }, + { 'v', QLatin1String("vscatterqps") }, + { 'v', QLatin1String("vshuff32x4") }, + { 'v', QLatin1String("vshuff64x2") }, + { 'v', QLatin1String("vshufi32x4") }, + { 'v', QLatin1String("vshufi64x2") }, + { 'k', QLatin1String("kandnw") }, + { 'k', QLatin1String("kandw") }, + { 'k', QLatin1String("kmovw") }, + { 'k', QLatin1String("knotw") }, + { 'k', QLatin1String("kortestw") }, + { 'k', QLatin1String("korw") }, + { 'k', QLatin1String("kshiftlw") }, + { 'k', QLatin1String("kshiftrw") }, + { 'k', QLatin1String("kunpckbw") }, + { 'k', QLatin1String("kxnorw") }, + { 'k', QLatin1String("kxorw") }, + { 'v', QLatin1String("vpbroadcastmb2q") }, + { 'v', QLatin1String("vpbroadcastmw2d") }, + { 'v', QLatin1String("vpconflictd") }, + { 'v', QLatin1String("vpconflictq") }, + { 'v', QLatin1String("vplzcntd") }, + { 'v', QLatin1String("vplzcntq") }, + { 'v', QLatin1String("vexp2pd") }, + { 'v', QLatin1String("vexp2ps") }, + { 'v', QLatin1String("vrcp28pd") }, + { 'v', QLatin1String("vrcp28ps") }, + { 'v', QLatin1String("vrcp28sd") }, + { 'v', QLatin1String("vrcp28ss") }, + { 'v', QLatin1String("vrsqrt28pd") }, + { 'v', QLatin1String("vrsqrt28ps") }, + { 'v', QLatin1String("vrsqrt28sd") }, + { 'v', QLatin1String("vrsqrt28ss") }, + { 'v', QLatin1String("vgatherpf0dpd") }, + { 'v', QLatin1String("vgatherpf0dps") }, + { 'v', QLatin1String("vgatherpf0qpd") }, + { 'v', QLatin1String("vgatherpf0qps") }, + { 'v', QLatin1String("vgatherpf1dpd") }, + { 'v', QLatin1String("vgatherpf1dps") }, + { 'v', QLatin1String("vgatherpf1qpd") }, + { 'v', QLatin1String("vgatherpf1qps") }, + { 'v', QLatin1String("vscatterpf0dpd") }, + { 'v', QLatin1String("vscatterpf0dps") }, + { 'v', QLatin1String("vscatterpf0qpd") }, + { 'v', QLatin1String("vscatterpf0qps") }, + { 'v', QLatin1String("vscatterpf1dpd") }, + { 'v', QLatin1String("vscatterpf1dps") }, + { 'v', QLatin1String("vscatterpf1qpd") }, + { 'v', QLatin1String("vscatterpf1qps") }, + { 'p', QLatin1String("prefetchwt1") }, + { 'b', QLatin1String("bndmk") }, + { 'b', QLatin1String("bndcl") }, + { 'b', QLatin1String("bndcu") }, + { 'b', QLatin1String("bndcn") }, + { 'b', QLatin1String("bndmov") }, + { 'b', QLatin1String("bndldx") }, + { 'b', QLatin1String("bndstx") }, + { 's', QLatin1String("sha1rnds4") }, + { 's', QLatin1String("sha1nexte") }, + { 's', QLatin1String("sha1msg1") }, + { 's', QLatin1String("sha1msg2") }, + { 's', QLatin1String("sha256rnds2") }, + { 's', QLatin1String("sha256msg1") }, + { 's', QLatin1String("sha256msg2") }, + { 'h', QLatin1String("hint_nop") }, + }; + + other = { + { 's', QLatin1String("section") }, + }; + builtin = { + + { 't', QLatin1String("text") }, + { 'c', QLatin1String("code") }, + { 'd', QLatin1String("data") }, + { 'b', QLatin1String("bss") } + }; +} + +} diff --git a/tools/fm-editor/fileview/syntaxHighlite/languagedata.h b/tools/fm-editor/fileview/syntaxHighlite/languagedata.h new file mode 100644 index 000000000..fe244e0a0 --- /dev/null +++ b/tools/fm-editor/fileview/syntaxHighlite/languagedata.h @@ -0,0 +1,222 @@ +/* + * Copyright (c) 2019-2020 Waqar Ahmed -- + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#ifndef QOWNLANGUAGEDATA_H +#define QOWNLANGUAGEDATA_H + +template +class QMultiHash; + +class QLatin1String; + +namespace QSourceHighlite { + +using LanguageData = QMultiHash; + +/**********************************************************/ +/* LuaData ************************************************/ +/**********************************************************/ +void loadLuaData(LanguageData &typess, + LanguageData &keywordss, + LanguageData &builtins, + LanguageData &literalss, + LanguageData &others); + +/**********************************************************/ +/* C/C++ Data *********************************************/ +/**********************************************************/ +void loadCppData(LanguageData &typess, + LanguageData &keywordss, + LanguageData &builtins, + LanguageData &literalss, + LanguageData &others); + +/**********************************************************/ +/* Shell Data *********************************************/ +/**********************************************************/ +void loadShellData(LanguageData &types, + LanguageData &keywords, + LanguageData &builtin, + LanguageData &literals, + LanguageData &other); + +/**********************************************************/ +/* JS Data *********************************************/ +/**********************************************************/ +void loadJSData(LanguageData &types, + LanguageData &keywords, + LanguageData &builtin, + LanguageData &literals, + LanguageData &other); + +/**********************************************************/ +/* PHP Data *********************************************/ +/**********************************************************/ +void loadPHPData(LanguageData &types, + LanguageData &keywords, + LanguageData &builtin, + LanguageData &literals, + LanguageData &other); + +/**********************************************************/ +/* QML Data *********************************************/ +/**********************************************************/ +void loadQMLData(LanguageData &types, + LanguageData &keywords, + LanguageData &builtin, + LanguageData &literals, + LanguageData &other); + +/**********************************************************/ +/* Python Data *********************************************/ +/**********************************************************/ +void loadPythonData(LanguageData &types, + LanguageData &keywords, + LanguageData &builtin, + LanguageData &literals, + LanguageData &other); + +/********************************************************/ +/*** Rust DATA ***********************************/ +/********************************************************/ +void loadRustData(LanguageData &types, + LanguageData &keywords, + LanguageData &builtin, + LanguageData &literals, + LanguageData &other); + +/********************************************************/ +/*** Java DATA ***********************************/ +/********************************************************/ +void loadJavaData(LanguageData &types, + LanguageData &keywords, + LanguageData &builtin, + LanguageData &literals, + LanguageData &other); + +/********************************************************/ +/*** C# DATA *************************************/ +/********************************************************/ +void loadCSharpData(LanguageData &types, + LanguageData &keywords, + LanguageData &builtin, + LanguageData &literals, + LanguageData &other); + +/********************************************************/ +/*** Go DATA *************************************/ +/********************************************************/ +void loadGoData(LanguageData &types, + LanguageData &keywords, + LanguageData &builtin, + LanguageData &literals, + LanguageData &other); + +/********************************************************/ +/*** V DATA **************************************/ +/********************************************************/ +void loadVData(LanguageData &types, + LanguageData &keywords, + LanguageData &builtin, + LanguageData &literals, + LanguageData &other); + +/********************************************************/ +/*** SQL DATA ************************************/ +/********************************************************/ +void loadSQLData(LanguageData &types, + LanguageData &keywords, + LanguageData &builtin, + LanguageData &literals, + LanguageData &other); + +/********************************************************/ +/*** JSON DATA ***********************************/ +/********************************************************/ +void loadJSONData(LanguageData &types, + LanguageData &keywords, + LanguageData &builtin, + LanguageData &literals, + LanguageData &other); + +/********************************************************/ +/*** CSS DATA ***********************************/ +/********************************************************/ +void loadCSSData(LanguageData &types, + LanguageData &keywords, + LanguageData &builtin, + LanguageData &literals, + LanguageData &other); + +/********************************************************/ +/*** Typescript DATA *********************************/ +/********************************************************/ +void loadTypescriptData(LanguageData &types, + LanguageData &keywords, + LanguageData &builtin, + LanguageData &literals, + LanguageData &other); + +/********************************************************/ +/*** YAML DATA ***************************************/ +/********************************************************/ +void loadYAMLData(LanguageData &types, + LanguageData &keywords, + LanguageData &builtin, + LanguageData &literals, + LanguageData &other); + +/********************************************************/ +/*** VEX DATA ***************************************/ +/********************************************************/ +void loadVEXData(LanguageData &types, + LanguageData &keywords, + LanguageData &builtin, + LanguageData &literals, + LanguageData &other); + +/********************************************************/ +/*** CMake DATA **************************************/ +/********************************************************/ +void loadCMakeData(QMultiHash &types, + QMultiHash &keywords, + QMultiHash &builtin, + QMultiHash &literals, + QMultiHash &other); + +/********************************************************/ +/*** Make DATA ***************************************/ +/********************************************************/ +void loadMakeData(QMultiHash& types, + QMultiHash& keywords, + QMultiHash& builtin, + QMultiHash& literals, + QMultiHash& other); + +void loadAsmData(QMultiHash& types, + QMultiHash& keywords, + QMultiHash& builtin, + QMultiHash& literals, + QMultiHash& other); +} +#endif diff --git a/tools/fm-editor/fileview/syntaxHighlite/qsourcehighliter.cpp b/tools/fm-editor/fileview/syntaxHighlite/qsourcehighliter.cpp new file mode 100644 index 000000000..ed4cf64fe --- /dev/null +++ b/tools/fm-editor/fileview/syntaxHighlite/qsourcehighliter.cpp @@ -0,0 +1,940 @@ +/* + * Copyright (c) 2019-2020 Waqar Ahmed -- + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include "qsourcehighliter.h" +#include "languagedata.h" +#include "qsourcehighliterthemes.h" + +#include +#include +#include + +namespace QSourceHighlite { + +QSourceHighliter::QSourceHighliter(QTextDocument *doc) + : QSyntaxHighlighter(doc), + _language(CodeC) +{ + initFormats(); +} + +QSourceHighliter::QSourceHighliter(QTextDocument *doc, QSourceHighliter::Themes theme) + : QSyntaxHighlighter(doc), + _language(CodeC) +{ + setTheme(theme); +} + +void QSourceHighliter::initFormats() { + /**************************************** + * Formats for syntax highlighting + ***************************************/ + + QTextCharFormat format = QTextCharFormat(); + + _formats[Token::CodeBlock] = format; + format = QTextCharFormat(); + + format.setForeground(QColor("#F92672")); + _formats[Token::CodeKeyWord] = format; + format = QTextCharFormat(); + + format.setForeground(QColor("#a39b4e")); + _formats[Token::CodeString] = format; + format = QTextCharFormat(); + + format.setForeground(QColor("#75715E")); + _formats[Token::CodeComment] = format; + format = QTextCharFormat(); + + format.setForeground(QColor("#54aebf")); + _formats[Token::CodeType] = format; + + format = QTextCharFormat(); + format.setForeground(QColor("#db8744")); + _formats[Token::CodeOther] = format; + + format = QTextCharFormat(); + format.setForeground(QColor("#AE81FF")); + _formats[Token::CodeNumLiteral] = format; + + format = QTextCharFormat(); + format.setForeground(QColor("#018a0f")); + _formats[Token::CodeBuiltIn] = format; +} + +void QSourceHighliter::setCurrentLanguage(Language language) { + if (language != _language) + _language = language; +} + +QSourceHighliter::Language QSourceHighliter::currentLanguage() { + return _language; +} + +void QSourceHighliter::setTheme(QSourceHighliter::Themes theme) +{ + _formats = QSourceHighliterTheme::theme(theme); + rehighlight(); +} + +void QSourceHighliter::highlightBlock(const QString &text) +{ + if (currentBlock() == document()->firstBlock()) { + setCurrentBlockState(_language); + } else { + previousBlockState() == _language ? + setCurrentBlockState(_language) : + setCurrentBlockState(_language + 1); + } + + highlightSyntax(text); +} + +/** + * @brief Does the code syntax highlighting + * @param text + */ +void QSourceHighliter::highlightSyntax(const QString &text) +{ + if (text.isEmpty()) return; + + const auto textLen = text.length(); + + QChar comment; + bool isCSS = false; + bool isYAML = false; + bool isMake = false; + bool isAsm = false; + bool isSQL = false; + + LanguageData keywords{}, + others{}, + types{}, + builtin{}, + literals{}; + + switch (currentBlockState()) { + case CodeLua : + case CodeLuaComment : + loadLuaData(types, keywords, builtin, literals, others); + break; + case CodeCpp : + case CodeCppComment : + loadCppData(types, keywords, builtin, literals, others); + break; + case CodeJs : + case CodeJsComment : + loadJSData(types, keywords, builtin, literals, others); + break; + case CodeC : + case CodeCComment : + loadCppData(types, keywords, builtin, literals, others); + break; + case CodeBash : + loadShellData(types, keywords, builtin, literals, others); + comment = QLatin1Char('#'); + break; + case CodePHP : + case CodePHPComment : + loadPHPData(types, keywords, builtin, literals, others); + break; + case CodeQML : + case CodeQMLComment : + loadQMLData(types, keywords, builtin, literals, others); + break; + case CodePython : + loadPythonData(types, keywords, builtin, literals, others); + comment = QLatin1Char('#'); + break; + case CodeRust : + case CodeRustComment : + loadRustData(types, keywords, builtin, literals, others); + break; + case CodeJava : + case CodeJavaComment : + loadJavaData(types, keywords, builtin, literals, others); + break; + case CodeCSharp : + case CodeCSharpComment : + loadCSharpData(types, keywords, builtin, literals, others); + break; + case CodeGo : + case CodeGoComment : + loadGoData(types, keywords, builtin, literals, others); + break; + case CodeV : + case CodeVComment : + loadVData(types, keywords, builtin, literals, others); + break; + case CodeSQL : + isSQL = true; + loadSQLData(types, keywords, builtin, literals, others); + break; + case CodeJSON : + loadJSONData(types, keywords, builtin, literals, others); + break; + case CodeXML : + xmlHighlighter(text); + return; + case CodeCSS : + case CodeCSSComment : + isCSS = true; + loadCSSData(types, keywords, builtin, literals, others); + break; + case CodeTypeScript: + case CodeTypeScriptComment: + loadTypescriptData(types, keywords, builtin, literals, others); + break; + case CodeYAML: + isYAML = true; + loadYAMLData(types, keywords, builtin, literals, others); + comment = QLatin1Char('#'); + break; + case CodeINI: + comment = QLatin1Char('#'); + break; + case CodeVex: + case CodeVexComment: + loadVEXData(types, keywords, builtin, literals, others); + break; + case CodeCMake: + loadCMakeData(types, keywords, builtin, literals, others); + comment = QLatin1Char('#'); + break; + case CodeMake: + isMake = true; + loadMakeData(types, keywords, builtin, literals, others); + comment = QLatin1Char('#'); + break; + case CodeAsm: + isAsm = true; + loadAsmData(types, keywords, builtin, literals, others); + comment = QLatin1Char('#'); + break; + default: + break; + } + + // keep the default code block format + // this statement is very slow + // TODO: do this formatting when necessary instead of + // applying it to the whole block in the beginning + setFormat(0, textLen, _formats[CodeBlock]); + + auto applyCodeFormat = + [this](int i, const LanguageData &data, + const QString &text, const QTextCharFormat &fmt) -> int { + // check if we are at the beginning OR if this is the start of a word + if (i == 0 || (!text.at(i - 1).isLetterOrNumber() && + text.at(i-1) != QLatin1Char('_'))) { + const auto wordList = data.values(text.at(i).toLatin1()); + for (const QLatin1String &word : wordList) { + // we have a word match check + // 1. if we are at the end + // 2. if we have a complete word + if (word == strMidRef(text, i, word.size()) && + (i + word.size() == text.length() || + (!text.at(i + word.size()).isLetterOrNumber() && + text.at(i + word.size()) != QLatin1Char('_')))) { + setFormat(i, word.size(), fmt); + i += word.size(); + } + } + } + return i; + }; + + const QTextCharFormat &formatType = _formats[CodeType]; + const QTextCharFormat &formatKeyword = _formats[CodeKeyWord]; + const QTextCharFormat &formatComment = _formats[CodeComment]; + const QTextCharFormat &formatNumLit = _formats[CodeNumLiteral]; + const QTextCharFormat &formatBuiltIn = _formats[CodeBuiltIn]; + const QTextCharFormat &formatOther = _formats[CodeOther]; + + for (int i = 0; i < textLen; ++i) { + + if (currentBlockState() % 2 != 0) goto Comment; + + while (i < textLen && !text[i].isLetter()) { + if (text[i].isSpace()) { + ++i; + //make sure we don't cross the bound + if (i == textLen) return; + if (text[i].isLetter()) break; + else continue; + } + //inline comment + if (comment.isNull() && text[i] == QLatin1Char('/')) { + if((i+1) < textLen){ + if(text[i+1] == QLatin1Char('/')) { + setFormat(i, textLen, formatComment); + return; + } else if(text[i+1] == QLatin1Char('*')) { + Comment: + int next = text.indexOf(QLatin1String("*/")); + if (next == -1) { + //we didn't find a comment end. + //Check if we are already in a comment block + if (currentBlockState() % 2 == 0) + setCurrentBlockState(currentBlockState() + 1); + setFormat(i, textLen, formatComment); + return; + } else { + //we found a comment end + //mark this block as code if it was previously comment + //first check if the comment ended on the same line + //if modulo 2 is not equal to zero, it means we are in a comment + //-1 will set this block's state as language + if (currentBlockState() % 2 != 0) { + setCurrentBlockState(currentBlockState() - 1); + } + next += 2; + setFormat(i, next - i, formatComment); + i = next; + if (i >= textLen) return; + } + } + } + } else if (isSQL && comment.isNull() && text[i] == QLatin1Char('-')) { + if((i+1) < textLen){ + if(text[i+1] == QLatin1Char('-')) { + setFormat(i, textLen, formatComment); + return; + } + } + } else if (text[i] == comment) { + setFormat(i, textLen, formatComment); + i = textLen; + //integer literal + } else if (text[i].isNumber()) { + i = highlightNumericLiterals(text, i); + //string literals + } else if (text[i] == QLatin1Char('\"')) { + i = highlightStringLiterals('\"', text, i); + } else if (text[i] == QLatin1Char('\'')) { + i = highlightStringLiterals('\'', text, i); + } + if (i >= textLen) { + break; + } + ++i; + } + + const int pos = i; + + if (i == textLen || !text[i].isLetter()) continue; + + /* Highlight Types */ + i = applyCodeFormat(i, types, text, formatType); + /************************************************ + next letter is usually a space, in that case + going forward is useless, so continue; + We can ++i here and go to the beginning of the next word + so that the next formatter can check for formatting but this will + cause problems in case the next word is also of 'Type' or the current + type(keyword/builtin). We can work around it and reset the value of i + in the beginning of the loop to the word's first letter but I am not + sure about its efficiency yet. + ************************************************/ + if (i == textLen || !text[i].isLetter()) continue; + + /* Highlight Keywords */ + i = applyCodeFormat(i, keywords, text, formatKeyword); + if (i == textLen || !text[i].isLetter()) continue; + + /* Highlight Literals (true/false/NULL,nullptr) */ + i = applyCodeFormat(i, literals, text, formatNumLit); + if (i == textLen || !text[i].isLetter()) continue; + + /* Highlight Builtin library stuff */ + i = applyCodeFormat(i, builtin, text, formatBuiltIn); + if (i == textLen || !text[i].isLetter()) continue; + + /* Highlight other stuff (preprocessor etc.) */ + if (( i == 0 || !text.at(i-1).isLetter()) && others.contains(text[i].toLatin1())) { + const QList wordList = others.values(text[i].toLatin1()); + for(const QLatin1String &word : wordList) { + if (word == strMidRef(text, i, word.size()) // we have a word match + && + (i + word.size() == text.length() // check if we are at the end + || + !text.at(i + word.size()).isLetter()) //OR if we have a complete word + ) { + currentBlockState() == CodeCpp ? + setFormat(i - 1, word.size() + 1, formatOther) : + setFormat(i, word.size(), formatOther); + i += word.size(); + } + } + } + + //we were unable to find any match, lets skip this word + if (pos == i) { + int count = i; + while (count < textLen) { + if (!text[count].isLetter()) break; + ++count; + } + i = count; + } + } + + if (isCSS) cssHighlighter(text); + if (isYAML) ymlHighlighter(text); + if (isMake) makeHighlighter(text); + if (isAsm) asmHighlighter(text); +} + +/** + * @brief Highlight string literals in code + * @param strType str type i.e., ' or " + * @param text the text being scanned + * @param i pos of i in loop + * @return pos of i after the string + */ +int QSourceHighliter::highlightStringLiterals(const QChar strType, const QString &text, int i) { + setFormat(i, 1, _formats[CodeString]); + ++i; + + while (i < text.length()) { + //look for string end + //make sure it's not an escape seq + if (text.at(i) == strType && text.at(i-1) != QLatin1Char('\\')) { + setFormat(i, 1, _formats[CodeString]); + ++i; + break; + } + //look for escape sequence + if (text.at(i) == QLatin1Char('\\') && (i+1) < text.length()) { + int len = 0; + switch(text.at(i+1).toLatin1()) { + case 'a': + case 'b': + case 'e': + case 'f': + case 'n': + case 'r': + case 't': + case 'v': + case '\'': + case '"': + case '\\': + case '\?': + //2 because we have to highlight \ as well as the following char + len = 2; + break; + //octal esc sequence \123 + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + { + if (i + 4 <= text.length()) { + bool isCurrentOctal = true; + if (!isOctal(text.at(i+2).toLatin1())) { + isCurrentOctal = false; + break; + } + if (!isOctal(text.at(i+3).toLatin1())) { + isCurrentOctal = false; + break; + } + len = isCurrentOctal ? 4 : 0; + } + break; + } + //hex numbers \xFA + case 'x': + { + if (i + 3 <= text.length()) { + bool isCurrentHex = true; + if (!isHex(text.at(i+2).toLatin1())) { + isCurrentHex = false; + break; + } + if (!isHex(text.at(i+3).toLatin1())) { + isCurrentHex = false; + break; + } + len = isCurrentHex ? 4 : 0; + } + break; + } + //TODO: implement unicode code point escaping + default: + break; + } + + //if len is zero, that means this wasn't an esc seq + //increment i so that we skip this backslash + if (len == 0) { + setFormat(i, 1, _formats[CodeString]); + ++i; + continue; + } + + setFormat(i, len, _formats[CodeNumLiteral]); + i += len; + continue; + } + setFormat(i, 1, _formats[CodeString]); + ++i; + } + return i; +} + +/** + * @brief Highlight number literals in code + * @param text the text being scanned + * @param i pos of i in loop + * @return pos of i after the number + */ +int QSourceHighliter::highlightNumericLiterals(const QString &text, int i) +{ + bool isPreAllowed = false; + if (i == 0) isPreAllowed = true; + else { + //these values are allowed before a number + switch(text.at(i - 1).toLatin1()) { + //css number + case ':': + if (currentBlockState() == CodeCSS) + isPreAllowed = true; + break; + case '$': + if (currentBlockState() == CodeAsm) + isPreAllowed = true; + break; + case '[': + case '(': + case '{': + case ' ': + case ',': + case '=': + case '+': + case '-': + case '*': + case '/': + case '%': + case '<': + case '>': + isPreAllowed = true; + break; + } + } + + if (!isPreAllowed) return i; + + const int start = i; + + if ((i+1) >= text.length()) { + setFormat(i, 1, _formats[CodeNumLiteral]); + return ++i; + } + + ++i; + //hex numbers highlighting (only if there's a preceding zero) + if (text.at(i) == QChar('x') && text.at(i - 1) == QChar('0')) + ++i; + + while (i < text.length()) { + if (!text.at(i).isNumber() && text.at(i) != QChar('.') && + text.at(i) != QChar('e')) //exponent + break; + ++i; + } + + bool isPostAllowed = false; + if (i == text.length()) { + //cant have e at the end + if (text.at(i - 1) != QChar('e')) + isPostAllowed = true; + } else { + //these values are allowed after a number + switch(text.at(i).toLatin1()) { + case ']': + case ')': + case '}': + case ' ': + case ',': + case '=': + case '+': + case '-': + case '*': + case '/': + case '%': + case '>': + case '<': + case ';': + isPostAllowed = true; + break; + // for 100u, 1.0F + case 'p': + if (currentBlockState() == CodeCSS) + if (i + 1 < text.length() && text.at(i+1) == QChar('x')) { + if (i + 2 == text.length() || !text.at(i+2).isLetterOrNumber()) + isPostAllowed = true; + } + break; + case 'e': + if (currentBlockState() == CodeCSS) + if (i + 1 < text.length() && text.at(i+1) == QChar('m')) { + if (i + 2 == text.length() || !text.at(i+2).isLetterOrNumber()) + isPostAllowed = true; + } + break; + case 'u': + case 'l': + case 'f': + case 'U': + case 'L': + case 'F': + if (i + 1 == text.length() || !text.at(i+1).isLetterOrNumber()) { + isPostAllowed = true; + ++i; + } + break; + } + } + if (isPostAllowed) { + int end = i; + setFormat(start, end - start, _formats[CodeNumLiteral]); + } + //decrement so that the index is at the last number, not after it + return --i; +} + +/** + * @brief The YAML highlighter + * @param text + * @details This function post processes a line after the main syntax + * highlighter has run for additional highlighting. It does these things + * + * If the current line is a comment, skip it + * + * Highlight all the words that have a colon after them as 'keyword' except: + * If the word is a string, skip it. + * If the colon is in between a path, skip it (C:\) + * + * Once the colon is found, the function will skip every character except 'h' + * + * If an h letter is found, check the next 4/5 letters for http/https and + * highlight them as a link (underlined) + */ +void QSourceHighliter::ymlHighlighter(const QString &text) { + if (text.isEmpty()) return; + const auto textLen = text.length(); + bool colonNotFound = false; + + //if this is a comment don't do anything and just return + if (text.trimmed().at(0) == QLatin1Char('#')) + return; + + for (int i = 0; i < textLen; ++i) { + if (!text.at(i).isLetter()) continue; + + if (colonNotFound && text.at(i) != QLatin1Char('h')) continue; + + //we found a string literal, skip it + if (i != 0 && (text.at(i-1) == QLatin1Char('"') || text.at(i-1) == QLatin1Char('\''))) { + const int next = text.indexOf(text.at(i-1), i); + if (next == -1) break; + i = next; + continue; + } + + const int colon = text.indexOf(QLatin1Char(':'), i); + + //if colon isn't found, we set this true + if (colon == -1) colonNotFound = true; + + if (!colonNotFound) { + //if the line ends here, format and return + if (colon+1 == textLen) { + setFormat(i, colon - i, _formats[CodeKeyWord]); + return; + } else { + //colon is found, check if it isn't some path or something else + if (!(text.at(colon+1) == QLatin1Char('\\') && text.at(colon+1) == QLatin1Char('/'))) { + setFormat(i, colon - i, _formats[CodeKeyWord]); + } + } + } + + //underlined links + if (text.at(i) == QLatin1Char('h')) { + if (strMidRef(text, i, 5) == QLatin1String("https") || + strMidRef(text, i, 4) == QLatin1String("http")) { + int space = text.indexOf(QChar(' '), i); + if (space == -1) space = textLen; + QTextCharFormat f = _formats[CodeString]; + f.setUnderlineStyle(QTextCharFormat::SingleUnderline); + setFormat(i, space - i, f); + i = space; + } + } + } +} + +void QSourceHighliter::cssHighlighter(const QString &text) +{ + if (text.isEmpty()) return; + const auto textLen = text.length(); + for (int i = 0; i= textLen) return; + if (text[i + 1].isSpace() || text[i+1].isNumber()) continue; + int space = text.indexOf(QLatin1Char(' '), i); + if (space < 0) { + space = text.indexOf('{'); + if (space < 0) { + space = textLen; + } + } + setFormat(i, space - i, _formats[CodeKeyWord]); + i = space; + } else if (text[i] == QLatin1Char('c')) { + if (strMidRef(text, i, 5) == QLatin1String("color")) { + i += 5; + int colon = text.indexOf(QLatin1Char(':'), i); + if (colon < 0) continue; + i = colon; + i++; + while(i < textLen) { + if (!text[i].isSpace()) break; + i++; + } + int semicolon = text.indexOf(QLatin1Char(';')); + if (semicolon < 0) semicolon = textLen; + const QString color = text.mid(i, semicolon-i); + QTextCharFormat f = _formats[CodeBlock]; + QColor c(color); + if (color.startsWith(QLatin1String("rgb"))) { + int t = text.indexOf(QLatin1Char('('), i); + int rPos = text.indexOf(QLatin1Char(','), t); + int gPos = text.indexOf(QLatin1Char(','), rPos+1); + int bPos = text.indexOf(QLatin1Char(')'), gPos); + if (rPos > -1 && gPos > -1 && bPos > -1) { + const auto r = strMidRef(text, t+1, rPos - (t+1)); + const auto g = strMidRef(text, rPos+1, gPos - (rPos + 1)); + const auto b = strMidRef(text, gPos+1, bPos - (gPos+1)); + c.setRgb(r.toInt(), g.toInt(), b.toInt()); + } else { + c = _formats[CodeBlock].background().color(); + } + } + + if (!c.isValid()) { + continue; + } + + int lightness{}; + QColor foreground; + //really dark + if (c.lightness() <= 20) { + foreground = Qt::white; + } else if (c.lightness() > 20 && c.lightness() <= 51){ + foreground = QColor("#ccc"); + } else if (c.lightness() > 51 && c.lightness() <= 78){ + foreground = QColor("#bbb"); + } else if (c.lightness() > 78 && c.lightness() <= 110){ + foreground = QColor("#bbb"); + } else if (c.lightness() > 127) { + lightness = c.lightness() + 100; + foreground = c.darker(lightness); + } + else { + lightness = c.lightness() + 100; + foreground = c.lighter(lightness); + } + + f.setBackground(c); + f.setForeground(foreground); + setFormat(i, semicolon - i, QTextCharFormat()); //clear prev format + setFormat(i, semicolon - i, f); + i = semicolon; + } + } + } +} + + +void QSourceHighliter::xmlHighlighter(const QString &text) { + if (text.isEmpty()) return; + const auto textLen = text.length(); + + setFormat(0, textLen, _formats[CodeBlock]); + + for (int i = 0; i < textLen; ++i) { + if (text[i] == QLatin1Char('<') && text[i+1] != QLatin1Char('!')) { + + const int found = text.indexOf(QLatin1Char('>'), i); + if (found > 0) { + ++i; + if (text[i] == QLatin1Char('/')) ++i; + setFormat(i, found - i, _formats[CodeKeyWord]); + } + } + + if (text[i] == QLatin1Char('=')) { + int lastSpace = text.lastIndexOf(QLatin1Char(' '), i); + if (lastSpace == i-1) lastSpace = text.lastIndexOf(QLatin1Char(' '), i-2); + if (lastSpace > 0) { + setFormat(lastSpace, i - lastSpace, _formats[CodeBuiltIn]); + } + } + + if (text[i] == QLatin1Char('\"')) { + const int pos = i; + int cnt = 1; + ++i; + //bound check + if ( (i+1) >= textLen) return; + while (i < textLen) { + if (text[i] == QLatin1Char('\"')) { + ++cnt; + ++i; + break; + } + ++i; ++cnt; + //bound check + if ( (i+1) >= textLen) { + ++cnt; + break; + } + } + setFormat(pos, cnt, _formats[CodeString]); + } + } +} + +void QSourceHighliter::makeHighlighter(const QString &text) +{ + int colonPos = text.indexOf(QLatin1Char(':')); + if (colonPos == -1) + return; + setFormat(0, colonPos, _formats[Token::CodeBuiltIn]); +} + +/** + * @brief highlight inline labels such as 'func()' in "call func()" + * @param text + */ +void QSourceHighliter::highlightInlineAsmLabels(const QString &text) +{ +#define Q(s) QStringLiteral(s) + static const QString jumps[27] = { + //0 - 19 + Q("jmp"), Q("je"), Q("jne"), Q("jz"), Q("jnz"), Q("ja"), Q("jb"), Q("jg"), Q("jge"), Q("jae"), Q("jl"), Q("jle"), + Q("jbe"), Q("jo"), Q("jno"), Q("js"), Q("jns"), Q("jcxz"), Q("jecxz"), Q("jrcxz"), + //20 - 24 + Q("loop"), Q("loope"), Q("loopne"), Q("loopz"), Q("loopnz"), + //25 - 26 + Q("call"), Q("callq") + }; +#undef Q + + auto format = _formats[Token::CodeBuiltIn]; + format.setFontUnderline(true); + + const QString trimmed = text.trimmed(); + int start = -1; + int end = -1; + char c{}; + if (!trimmed.isEmpty()) + c = trimmed.at(0).toLatin1(); + if (c == 'j') { + start = 0; end = 20; + } else if (c == 'c') { + start = 25; end = 27; + } else if (c == 'l') { + start = 20; end = 25; + } else { + return; + } + + auto skipSpaces = [&text](int& j){ + while (text.at(j).isSpace()) j++; + return j; + }; + + for (int i = start; i < end; ++i) { + if (trimmed.startsWith(jumps[i])) { + int j = 0; + skipSpaces(j); + j = j + jumps[i].length() + 1; + skipSpaces(j); + int len = text.length() - j; + setFormat(j, len, format); + } + } +} + +void QSourceHighliter::asmHighlighter(const QString& text) +{ + highlightInlineAsmLabels(text); + //label highlighting + //examples: + //L1: + //LFB1: # local func begin + // + //following e.gs are not a label + //mov %eax, Count::count(%rip) + //.string ": #%s" + + //look for the last occurence of a colon + int colonPos = text.lastIndexOf(QLatin1Char(':')); + if (colonPos == -1) + return; + //check if this colon is in a comment maybe? + bool isComment = text.lastIndexOf('#', colonPos) != -1; + if (isComment) { + int commentPos = text.lastIndexOf('#', colonPos); + colonPos = text.lastIndexOf(':', commentPos); + } + + auto format = _formats[Token::CodeBuiltIn]; + format.setFontUnderline(true); + + if (colonPos >= text.length() - 1) { + setFormat(0, colonPos, format); + } + + int i = 0; + bool isLabel = true; + for (i = colonPos + 1; i < text.length(); ++i) { + if (!text.at(i).isSpace()) { + isLabel = false; + break; + } + } + + if (!isLabel && i < text.length() && text.at(i) == QLatin1Char('#')) + setFormat(0, colonPos, format); +} +} diff --git a/tools/fm-editor/fileview/syntaxHighlite/qsourcehighliter.h b/tools/fm-editor/fileview/syntaxHighlite/qsourcehighliter.h new file mode 100644 index 000000000..2008720e3 --- /dev/null +++ b/tools/fm-editor/fileview/syntaxHighlite/qsourcehighliter.h @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2019-2020 Waqar Ahmed -- + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#ifndef QSOURCEHIGHLITER_H +#define QSOURCEHIGHLITER_H + +#include + +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +#include +#endif + +namespace QSourceHighlite { + +class QSourceHighliter : public QSyntaxHighlighter +{ +public: + enum Themes { + Monokai = 1 + }; + + explicit QSourceHighliter(QTextDocument *doc); + QSourceHighliter(QTextDocument *doc, Themes theme); + + //languages + /********* + * When adding a language make sure that its value is a multiple of 2 + * This is because we use the next number as comment for that language + * In case the language doesn't support multiline comments in the traditional C++ + * sense, leave the next value empty. Otherwise mark the next value as comment for + * that language. + * e.g + * CodeCpp = 200 + * CodeCppComment = 201 + */ + enum Language { + //languages + CodeCpp = 200, + CodeCppComment = 201, + CodeJs = 202, + CodeJsComment = 203, + CodeC = 204, + CodeCComment = 205, + CodeBash = 206, + CodePHP = 208, + CodePHPComment = 209, + CodeQML = 210, + CodeQMLComment = 211, + CodePython = 212, + CodeRust = 214, + CodeRustComment = 215, + CodeJava = 216, + CodeJavaComment = 217, + CodeCSharp = 218, + CodeCSharpComment = 219, + CodeGo = 220, + CodeGoComment = 221, + CodeV = 222, + CodeVComment = 223, + CodeSQL = 224, + CodeJSON = 226, + CodeXML = 228, + CodeCSS = 230, + CodeCSSComment = 231, + CodeTypeScript = 232, + CodeTypeScriptComment = 233, + CodeYAML = 234, + CodeINI = 236, + CodeVex = 238, + CodeVexComment = 239, + CodeCMake = 240, + CodeMake = 242, + CodeAsm = 244, + CodeLua = 246, + CodeLuaComment = 247 + }; + Q_ENUM(Language) + + enum Token { + CodeBlock, + CodeKeyWord, + CodeString, + CodeComment, + CodeType, + CodeOther, + CodeNumLiteral, + CodeBuiltIn, + }; + Q_ENUM(Token) + + void setCurrentLanguage(Language language); + Q_REQUIRED_RESULT Language currentLanguage(); + void setTheme(Themes theme); + +protected: + void highlightBlock(const QString &text) override; + +private: + void highlightSyntax(const QString &text); + Q_REQUIRED_RESULT int highlightNumericLiterals(const QString &text, int i); + Q_REQUIRED_RESULT int highlightStringLiterals(const QChar strType, const QString &text, int i); + + /** + * @brief returns true if c is octal + * @param c the char being checked + * @returns true if the number is octal, false otherwise + */ + Q_REQUIRED_RESULT static constexpr inline bool isOctal(const char c) { + return (c >= '0' && c <= '7'); + } + + /** + * @brief returns true if c is hex + * @param c the char being checked + * @returns true if the number is hex, false otherwise + */ + Q_REQUIRED_RESULT static constexpr inline bool isHex(const char c) { + return ( + (c >= '0' && c <= '9') || + (c >= 'a' && c <= 'f') || + (c >= 'A' && c <= 'F') + ); + } + + void cssHighlighter(const QString &text); + void ymlHighlighter(const QString &text); + void xmlHighlighter(const QString &text); + void makeHighlighter(const QString &text); + void highlightInlineAsmLabels(const QString& text); + void asmHighlighter(const QString& text); + void initFormats(); + +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + static inline QStringView strMidRef(const QString& str, qsizetype position, qsizetype n = -1) + { + return QStringView(str).mid(position, n); + } +#else + static inline QStringRef strMidRef(const QString& str, int position, int n = -1) + { + return str.midRef(position, n); + } +#endif + + QHash _formats; + Language _language; +}; +} +#endif // QSOURCEHIGHLITER_H diff --git a/tools/fm-editor/fileview/syntaxHighlite/qsourcehighliterthemes.cpp b/tools/fm-editor/fileview/syntaxHighlite/qsourcehighliterthemes.cpp new file mode 100644 index 000000000..5ba7a8b2b --- /dev/null +++ b/tools/fm-editor/fileview/syntaxHighlite/qsourcehighliterthemes.cpp @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2019-2020 Waqar Ahmed -- + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include "qsourcehighliterthemes.h" + +namespace QSourceHighlite { + +static QHash formats() +{ + QHash _formats; + + QTextCharFormat defaultFormat = QTextCharFormat(); + + _formats[QSourceHighliter::Token::CodeBlock] = defaultFormat; + _formats[QSourceHighliter::Token::CodeKeyWord] = defaultFormat; + _formats[QSourceHighliter::Token::CodeString] = defaultFormat; + _formats[QSourceHighliter::Token::CodeComment] = defaultFormat; + _formats[QSourceHighliter::Token::CodeType] = defaultFormat; + _formats[QSourceHighliter::Token::CodeOther] = defaultFormat; + _formats[QSourceHighliter::Token::CodeNumLiteral] = defaultFormat; + _formats[QSourceHighliter::Token::CodeBuiltIn] = defaultFormat; + + return _formats; +} + +static QHash monokai() +{ + QHash _formats = formats(); + + _formats[QSourceHighliter::Token::CodeBlock].setForeground(QColor(227, 226, 214)); + _formats[QSourceHighliter::Token::CodeKeyWord].setForeground(QColor(249, 38, 114)); + _formats[QSourceHighliter::Token::CodeString].setForeground(QColor(230, 219, 116)); + _formats[QSourceHighliter::Token::CodeComment].setForeground(QColor(117, 113, 94)); + _formats[QSourceHighliter::Token::CodeType].setForeground(QColor(102, 217, 239)); + _formats[QSourceHighliter::Token::CodeOther].setForeground(QColor(249, 38, 114)); + _formats[QSourceHighliter::Token::CodeNumLiteral].setForeground(QColor(174, 129, 255)); + _formats[QSourceHighliter::Token::CodeBuiltIn].setForeground(QColor(166, 226, 46)); + + return _formats; +} + +QHash + QSourceHighliterTheme::theme(QSourceHighliter::Themes theme) { + switch (theme) { + case QSourceHighliter::Themes::Monokai: + return monokai(); + default: + return {}; + } +} + +} diff --git a/tools/fm-editor/fileview/syntaxHighlite/qsourcehighliterthemes.h b/tools/fm-editor/fileview/syntaxHighlite/qsourcehighliterthemes.h new file mode 100644 index 000000000..eacabaec0 --- /dev/null +++ b/tools/fm-editor/fileview/syntaxHighlite/qsourcehighliterthemes.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2019-2020 Waqar Ahmed -- + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#ifndef QSOURCEHIGHLITERTHEMES_H +#define QSOURCEHIGHLITERTHEMES_H + +#include "qsourcehighliter.h" + +namespace QSourceHighlite { + +namespace QSourceHighliterTheme +{ + QHash theme(QSourceHighliter::Themes); + +} // namespace QSourceHighliterTheme + +} // namespace QSourceHighlite +#endif // QSOURCEHIGHLITERTHEMES_H diff --git a/tools/fm-editor/graph/FeatureModelGraph.cpp b/tools/fm-editor/graph/FeatureModelGraph.cpp index 6d9f1650e..e393e8ac6 100644 --- a/tools/fm-editor/graph/FeatureModelGraph.cpp +++ b/tools/fm-editor/graph/FeatureModelGraph.cpp @@ -141,7 +141,9 @@ void FeatureModelGraph::scaleView(qreal ScaleFactor) { } void FeatureModelGraph::zoomIn() { scaleView(qreal(1.2)); } void FeatureModelGraph::zoomOut() { scaleView(1 / qreal(1.2)); } -void FeatureModelGraph::addFeature(const QString& Name, FeatureNode* Parent) { + + +FeatureNode* FeatureModelGraph::addFeature(const QString& Name, FeatureNode* Parent) { auto Transaction = vara::feature::FeatureModelTransaction::openTransaction(*FeatureModel); auto NewFeature = std::make_unique(Name.toStdString()); auto NewNode = std::make_unique(this,NewFeature.get()); @@ -150,13 +152,17 @@ void FeatureModelGraph::addFeature(const QString& Name, FeatureNode* Parent) { auto * NewEdge = new FeatureEdge(Parent,NewNode.get()); scene()->addItem(NewEdge); scene()->addItem(NewNode.get()); + auto NewNodeRaw = NewNode.get(); Nodes.push_back(std::move(NewNode)); auto NextChildren =std::vector(EntryNode->children().size()); auto CurrentChildren = EntryNode->children(); std::transform(CurrentChildren.begin(),CurrentChildren.end(),NextChildren.begin(),[](FeatureEdge* Edge){return Edge->targetNode();}); positionRec(1,NextChildren,WIDTH-10,0); EntryNode->setPos(WIDTH/2,10); + return NewNodeRaw; } + + FeatureNode* FeatureModelGraph::getNode(std::string Name) { auto It = std::find_if(Nodes.begin(),Nodes.end(),[&Name](auto const &Node){return Node->getName() == Name;}); if (It != Nodes.end()) { diff --git a/tools/fm-editor/graph/FeatureModelGraph.h b/tools/fm-editor/graph/FeatureModelGraph.h index f4f623753..9d65a408a 100644 --- a/tools/fm-editor/graph/FeatureModelGraph.h +++ b/tools/fm-editor/graph/FeatureModelGraph.h @@ -15,7 +15,7 @@ class FeatureModelGraph : public QGraphicsView { auto getNodes() {return &Nodes;}; void itemMoved(); FeatureNode* getNode(std::string Name); - void addFeature(const QString& Name,FeatureNode* Parent); + FeatureNode* addFeature(const QString& Name,FeatureNode* Parent); public slots: void zoomIn(); void zoomOut(); diff --git a/tools/fm-editor/graph/FeatureNode.cpp b/tools/fm-editor/graph/FeatureNode.cpp index 9471687ec..7459af142 100644 --- a/tools/fm-editor/graph/FeatureNode.cpp +++ b/tools/fm-editor/graph/FeatureNode.cpp @@ -10,6 +10,7 @@ #include #include #include +#include FeatureNode::FeatureNode(FeatureModelGraph *Graph, vara::feature::Feature *Feature) : Graph(Graph),Feature(Feature) { setFlag(ItemIsMovable); @@ -90,7 +91,17 @@ void FeatureNode::mousePressEvent(QGraphicsSceneMouseEvent *Event) { QGraphicsItem::mousePressEvent(Event); emit clicked(Feature); } - +void FeatureNode::contextMenuEvent(QGraphicsSceneContextMenuEvent *Event) { + auto *Menu = new QMenu; + auto *Inspect = new QAction("Inspect Sources", this); + Menu->addAction(Inspect); + Menu->popup(Event->screenPos()); + connect(Inspect, &QAction::triggered, + this, &FeatureNode::inspect); +} +void FeatureNode::inspect() { + emit(inspectSource(Feature)); +} void FeatureNode::mouseReleaseEvent(QGraphicsSceneMouseEvent *Event) { update(); QGraphicsItem::mouseReleaseEvent(Event); diff --git a/tools/fm-editor/graph/FeatureNode.h b/tools/fm-editor/graph/FeatureNode.h index 8796d7f6d..45f0c477f 100644 --- a/tools/fm-editor/graph/FeatureNode.h +++ b/tools/fm-editor/graph/FeatureNode.h @@ -31,12 +31,13 @@ class FeatureNode : public QObject,public QGraphicsItem{ [[nodiscard]] std::string getName() const {return Feature->getName().str();}; signals: void clicked(vara::feature::Feature *Feature); + void inspectSource(vara::feature::Feature *Feature); protected: QVariant itemChange(GraphicsItemChange Change, const QVariant &Value) override; void mousePressEvent(QGraphicsSceneMouseEvent *Event) override; void mouseReleaseEvent(QGraphicsSceneMouseEvent *Event) override; - + void contextMenuEvent(QGraphicsSceneContextMenuEvent *Event) override; private: [[nodiscard]] int width() const; std::vector ChildEdges; @@ -44,6 +45,8 @@ class FeatureNode : public QObject,public QGraphicsItem{ QPointF NewPos; FeatureModelGraph *Graph; vara::feature::Feature *Feature; + + void inspect(); }; #endif // VARA_FEATURE_FEATURENODE_H From 38f59598ed79a9522a379ebffa38bdf53d99c658 Mon Sep 17 00:00:00 2001 From: Nerum Date: Tue, 17 Jan 2023 15:08:55 +0100 Subject: [PATCH 008/106] Rewrite the Code for positioning Nodes --- tools/fm-editor/CMakeLists.txt | 5 +-- tools/fm-editor/graph/FeatureModelGraph.cpp | 37 ++++++++++++++------- tools/fm-editor/graph/FeatureModelGraph.h | 5 ++- tools/fm-editor/graph/FeatureNode.cpp | 35 ++++++++++++++++--- tools/fm-editor/graph/FeatureNode.h | 9 ++--- 5 files changed, 64 insertions(+), 27 deletions(-) diff --git a/tools/fm-editor/CMakeLists.txt b/tools/fm-editor/CMakeLists.txt index 4f664a9eb..feae0db90 100644 --- a/tools/fm-editor/CMakeLists.txt +++ b/tools/fm-editor/CMakeLists.txt @@ -5,6 +5,7 @@ set(LLVM_LINK_COMPONENTS ) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) +find_package(Qt6 REQUIRED COMPONENTS Widgets) add_vara_executable(fm-editor main.cpp graph/FeatureModelGraph.h @@ -23,8 +24,6 @@ add_vara_executable(fm-editor target_link_libraries(fm-editor LINK_PRIVATE VaRAFeature - Qt::Core - Qt::Gui Qt::Widgets ${STD_FS_LIB} ) @@ -33,5 +32,3 @@ add_custom_target(check-vara-fm-editor COMMAND fm-editor xml/test.xml -viewer cat | dot | grep . -q WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../unittests/resources ) - -find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets) \ No newline at end of file diff --git a/tools/fm-editor/graph/FeatureModelGraph.cpp b/tools/fm-editor/graph/FeatureModelGraph.cpp index e393e8ac6..a9563aa9d 100644 --- a/tools/fm-editor/graph/FeatureModelGraph.cpp +++ b/tools/fm-editor/graph/FeatureModelGraph.cpp @@ -17,7 +17,7 @@ FeatureModelGraph::FeatureModelGraph(vara::feature::FeatureModel * FeatureModel, : QGraphicsView(Parent), EntryNode(new FeatureNode(this, FeatureModel->getRoot())), FeatureModel(FeatureModel) { auto *Scene = new QGraphicsScene(this); Scene->setItemIndexMethod(QGraphicsScene::NoIndex); - Scene->setSceneRect(0, 0, 600, 600); + setScene(Scene); setCacheMode(CacheBackground); setViewportUpdateMode(BoundingRectViewportUpdate); @@ -26,6 +26,7 @@ FeatureModelGraph::FeatureModelGraph(vara::feature::FeatureModel * FeatureModel, scale(qreal(0.8), qreal(0.8)); setMinimumSize(400, 400); reload(); + Scene->setSceneRect(0, 0, EntryNode->childrenWidth()+100, 100*EntryNode->childrenDepth()+100); } void FeatureModelGraph::reload(){ @@ -37,8 +38,8 @@ void FeatureModelGraph::reload(){ auto NextChildren =std::vector(EntryNode->children().size()); auto CurrentChildren = EntryNode->children(); std::transform(CurrentChildren.begin(),CurrentChildren.end(),NextChildren.begin(),[](FeatureEdge* Edge){return Edge->targetNode();}); - positionRec(1,NextChildren,WIDTH-10,0); - EntryNode->setPos(WIDTH/2,10); + positionRec(1,NextChildren,5); + EntryNode->setPos(EntryNode->childrenWidth()/2,10); } void FeatureModelGraph::buildRec(FeatureNode *CurrentFeatureNode) { @@ -52,23 +53,35 @@ void FeatureModelGraph::buildRec(FeatureNode *CurrentFeatureNode) { buildRec(Node.get()); Nodes.push_back(std::move(Node)); } + for (auto *Relation : + CurrentFeatureNode->getFeature()->getChildren( + 1)) { + for (auto *Feature :Relation->getChildren( + 1)) { + auto Node = std::make_unique(this, Feature); + auto *Edge = new FeatureEdge(CurrentFeatureNode, Node.get()); + scene()->addItem(Edge); + scene()->addItem(Node.get()); + buildRec(Node.get()); + Nodes.push_back(std::move(Node)); + } + } } -int FeatureModelGraph::positionRec(const int CurrentDepth, const std::vector& Children, const unsigned long Width, const unsigned long Offset){ +int FeatureModelGraph::positionRec(const int CurrentDepth, const std::vector& Children, const unsigned long Offset){ if(Children.empty()){ return CurrentDepth-1; } - auto ContainerSize = Width / Children.size(); - int Container = 0; int MaxDepth = CurrentDepth; + auto NextOffset = Offset; for(FeatureNode* Node : Children){ - auto NextOffset = Offset+Container*ContainerSize; - Container++; auto NextChildren =std::vector(Node->children().size()); auto CurrentChildren = Node->children(); std::transform(CurrentChildren.begin(),CurrentChildren.end(),NextChildren.begin(),[](FeatureEdge* Edge){return Edge->targetNode();}); - int Depth = positionRec(CurrentDepth+1,NextChildren,ContainerSize,NextOffset); - Node->setPos(NextOffset+ContainerSize/2,(HEIGHT/(Depth+1))*CurrentDepth); + int const Depth = positionRec(CurrentDepth+1,NextChildren,NextOffset); + int Width = Node->childrenWidth()+5; + Node->setPos(NextOffset+Width/2,100*CurrentDepth); + NextOffset+=Width; MaxDepth = MaxDepth(EntryNode->children().size()); auto CurrentChildren = EntryNode->children(); std::transform(CurrentChildren.begin(),CurrentChildren.end(),NextChildren.begin(),[](FeatureEdge* Edge){return Edge->targetNode();}); - positionRec(1,NextChildren,WIDTH-10,0); - EntryNode->setPos(WIDTH/2,10); + positionRec(1,NextChildren,5); + EntryNode->setPos(EntryNode->childrenWidth()/2,10); return NewNodeRaw; } diff --git a/tools/fm-editor/graph/FeatureModelGraph.h b/tools/fm-editor/graph/FeatureModelGraph.h index 9d65a408a..bd20d137d 100644 --- a/tools/fm-editor/graph/FeatureModelGraph.h +++ b/tools/fm-editor/graph/FeatureModelGraph.h @@ -33,10 +33,9 @@ public slots: void buildRec(FeatureNode *CurrentFeatureNode); int TimerId = 0; FeatureNode* EntryNode; - int positionRec(int CurrentDepth, const std::vector& Children, - unsigned long Width, unsigned long Offset); + int positionRec(int CurrentDepth, const std::vector& Children,unsigned long Offset); const int HEIGHT = 600; - const int WIDTH = 600; + int WIDTH = 600; vara::feature::FeatureModel* FeatureModel; std::vector> Nodes; }; diff --git a/tools/fm-editor/graph/FeatureNode.cpp b/tools/fm-editor/graph/FeatureNode.cpp index 7459af142..e519e15c2 100644 --- a/tools/fm-editor/graph/FeatureNode.cpp +++ b/tools/fm-editor/graph/FeatureNode.cpp @@ -91,6 +91,12 @@ void FeatureNode::mousePressEvent(QGraphicsSceneMouseEvent *Event) { QGraphicsItem::mousePressEvent(Event); emit clicked(Feature); } + +void FeatureNode::mouseReleaseEvent(QGraphicsSceneMouseEvent *Event) { + update(); + QGraphicsItem::mouseReleaseEvent(Event); +} + void FeatureNode::contextMenuEvent(QGraphicsSceneContextMenuEvent *Event) { auto *Menu = new QMenu; auto *Inspect = new QAction("Inspect Sources", this); @@ -102,12 +108,33 @@ void FeatureNode::contextMenuEvent(QGraphicsSceneContextMenuEvent *Event) { void FeatureNode::inspect() { emit(inspectSource(Feature)); } -void FeatureNode::mouseReleaseEvent(QGraphicsSceneMouseEvent *Event) { - update(); - QGraphicsItem::mouseReleaseEvent(Event); -} int FeatureNode::width() const { auto Name = Feature->getName(); return 15 + 5 * Name.str().length(); } + +int FeatureNode::childrenWidth() const { + if(children().empty()){ + return width(); + } + int Result = 0; + for (auto *Child : children()){ + Result +=Child->targetNode()->childrenWidth(); + } + return std::max(Result,width()); +} + +int FeatureNode::childrenDepth() const{ + if(children().empty()){ + return 1; + } + int MaxDepth = 0; + for(auto *Child: children()){ + int const ChildDepth = Child->targetNode()->childrenDepth(); + if(ChildDepth +1> MaxDepth){ + MaxDepth = ChildDepth +1; + } + } + return MaxDepth; +} diff --git a/tools/fm-editor/graph/FeatureNode.h b/tools/fm-editor/graph/FeatureNode.h index 45f0c477f..caa4bec7b 100644 --- a/tools/fm-editor/graph/FeatureNode.h +++ b/tools/fm-editor/graph/FeatureNode.h @@ -10,14 +10,17 @@ class FeatureEdge; class FeatureModelGraph; class FeatureNode : public QObject,public QGraphicsItem{ Q_OBJECT + + public: FeatureNode(FeatureModelGraph *Graph, vara::feature::Feature *Feature); - + [[nodiscard]] int width() const; void addChildEdge(FeatureEdge *Edge); void setParentEdge(FeatureEdge *Edge); [[nodiscard]] std::vector children() const; [[nodiscard]] FeatureEdge * parent() const; - + [[nodiscard]] int childrenWidth() const; + [[nodiscard]] int childrenDepth() const; enum { Type = UserType + 1 }; [[nodiscard]] int type() const override { return Type; } vara::feature::Feature* getFeature(){return Feature;}; @@ -39,10 +42,8 @@ class FeatureNode : public QObject,public QGraphicsItem{ void mouseReleaseEvent(QGraphicsSceneMouseEvent *Event) override; void contextMenuEvent(QGraphicsSceneContextMenuEvent *Event) override; private: - [[nodiscard]] int width() const; std::vector ChildEdges; FeatureEdge * ParentEdge = nullptr; - QPointF NewPos; FeatureModelGraph *Graph; vara::feature::Feature *Feature; From 1d47e77be8d9d534d2a334eb3a8be13b4331ed0f Mon Sep 17 00:00:00 2001 From: Nerum Date: Mon, 6 Feb 2023 15:49:48 +0100 Subject: [PATCH 009/106] Add tree view as alternative for view for feature model. --- tools/fm-editor/CMakeLists.txt | 4 + tools/fm-editor/FeatureModelEditor.cpp | 10 +- tools/fm-editor/FeatureModelEditor.h | 3 + tools/fm-editor/FeatureModelEditor.ui | 95 ++++++++++------ tools/fm-editor/graph/FeatureModelGraph.cpp | 1 - tools/fm-editor/graph/FeatureModelGraph.h | 2 - tools/fm-editor/tree/FeatureTreeItem.cpp | 69 ++++++++++++ tools/fm-editor/tree/FeatureTreeItem.h | 103 ++++++++++++++++++ tools/fm-editor/tree/FeatureTreeViewModel.cpp | 80 ++++++++++++++ tools/fm-editor/tree/FeatureTreeViewModel.h | 30 +++++ 10 files changed, 354 insertions(+), 43 deletions(-) create mode 100644 tools/fm-editor/tree/FeatureTreeItem.cpp create mode 100644 tools/fm-editor/tree/FeatureTreeItem.h create mode 100644 tools/fm-editor/tree/FeatureTreeViewModel.cpp create mode 100644 tools/fm-editor/tree/FeatureTreeViewModel.h diff --git a/tools/fm-editor/CMakeLists.txt b/tools/fm-editor/CMakeLists.txt index feae0db90..8287c951c 100644 --- a/tools/fm-editor/CMakeLists.txt +++ b/tools/fm-editor/CMakeLists.txt @@ -14,6 +14,10 @@ add_vara_executable(fm-editor graph/FeatureNode.cpp graph/FeatureEdge.h graph/FeatureEdge.cpp + tree/FeatureTreeViewModel.h + tree/FeatureTreeViewModel.cpp + tree/FeatureTreeItem.h + tree/FeatureTreeItem.cpp FeatureModelEditor.h FeatureModelEditor.cpp FeatureModelEditor.ui FeatureAddDialog.h FeatureAddDialog.cpp FeatureAddDialog.ui diff --git a/tools/fm-editor/FeatureModelEditor.cpp b/tools/fm-editor/FeatureModelEditor.cpp index 2c620b12d..7e9821983 100644 --- a/tools/fm-editor/FeatureModelEditor.cpp +++ b/tools/fm-editor/FeatureModelEditor.cpp @@ -46,10 +46,12 @@ void FeatureModelEditor::loadGraph() { //Return if no model at Path return; } - Graph = new FeatureModelGraph{Model.get(), Ui->centralwidget}; - Ui->featureGraph = Graph; - Ui->featureGraph->setObjectName(QString::fromUtf8("featureGraph")); - Ui->gridLayout_3->addWidget(Ui->featureGraph, 1, 2, 1, 1); + Graph = new FeatureModelGraph{Model.get()}; + + Ui->tabWidget->addTab(Graph,"GraphView"); + TreeView = new QTreeView(); + TreeView->setModel(new FeatureTreeViewModel(Model.get(),TreeView)); + Ui->tabWidget->addTab(TreeView,"TreeView"); for (auto &Node : *Graph->getNodes()) { QObject::connect(Node.get(), &FeatureNode::clicked, this, &FeatureModelEditor::loadFeature); diff --git a/tools/fm-editor/FeatureModelEditor.h b/tools/fm-editor/FeatureModelEditor.h index f57b88447..dd5ad45c0 100644 --- a/tools/fm-editor/FeatureModelEditor.h +++ b/tools/fm-editor/FeatureModelEditor.h @@ -3,11 +3,13 @@ #define VARA_FEATURE_FEATUREMODELEDITOR_H #include "graph/FeatureModelGraph.h" +#include "tree/FeatureTreeViewModel.h" #include "vara/Feature/Feature.h" #include "vara/Feature/FeatureModel.h" #include "vara/Feature/FeatureModelTransaction.h" #include #include +#include QT_BEGIN_NAMESPACE namespace Ui { class FeatureModelEditor; @@ -23,6 +25,7 @@ class FeatureModelEditor : public QMainWindow { private: Ui::FeatureModelEditor *Ui; FeatureModelGraph * Graph{}; + QTreeView* TreeView; std::unique_ptr Model {}; std::unique_ptr> Modification {}; QString Repository {}; diff --git a/tools/fm-editor/FeatureModelEditor.ui b/tools/fm-editor/FeatureModelEditor.ui index fbf6c09f3..dbcadcff4 100644 --- a/tools/fm-editor/FeatureModelEditor.ui +++ b/tools/fm-editor/FeatureModelEditor.ui @@ -6,7 +6,7 @@ 0 0 - 915 + 943 896 @@ -16,15 +16,47 @@ - - - QFrame::StyledPanel + + + Qt::Horizontal - - QFrame::Raised + + QSizePolicy::Preferred + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Preferred + + + + 40 + 20 + + + + + + + + + 200 + 0 + - + @@ -43,36 +75,21 @@ - - - - - 0 - 400 - - - - - 16777215 - 16777215 - + + + + -1 - - + + 16777215 50 - - QFrame::StyledPanel - - - QFrame::Raised - @@ -110,13 +127,19 @@ - - - - QFrame::StyledPanel + + + + + 0 + 0 + - - QFrame::Raised + + + 500 + 0 + @@ -135,8 +158,8 @@ 0 0 - 915 - 34 + 943 + 30 diff --git a/tools/fm-editor/graph/FeatureModelGraph.cpp b/tools/fm-editor/graph/FeatureModelGraph.cpp index a9563aa9d..178bf4d50 100644 --- a/tools/fm-editor/graph/FeatureModelGraph.cpp +++ b/tools/fm-editor/graph/FeatureModelGraph.cpp @@ -24,7 +24,6 @@ FeatureModelGraph::FeatureModelGraph(vara::feature::FeatureModel * FeatureModel, setRenderHint(QPainter::Antialiasing); setTransformationAnchor(AnchorUnderMouse); scale(qreal(0.8), qreal(0.8)); - setMinimumSize(400, 400); reload(); Scene->setSceneRect(0, 0, EntryNode->childrenWidth()+100, 100*EntryNode->childrenDepth()+100); } diff --git a/tools/fm-editor/graph/FeatureModelGraph.h b/tools/fm-editor/graph/FeatureModelGraph.h index bd20d137d..b47018900 100644 --- a/tools/fm-editor/graph/FeatureModelGraph.h +++ b/tools/fm-editor/graph/FeatureModelGraph.h @@ -34,8 +34,6 @@ public slots: int TimerId = 0; FeatureNode* EntryNode; int positionRec(int CurrentDepth, const std::vector& Children,unsigned long Offset); - const int HEIGHT = 600; - int WIDTH = 600; vara::feature::FeatureModel* FeatureModel; std::vector> Nodes; }; diff --git a/tools/fm-editor/tree/FeatureTreeItem.cpp b/tools/fm-editor/tree/FeatureTreeItem.cpp new file mode 100644 index 000000000..764a42ccd --- /dev/null +++ b/tools/fm-editor/tree/FeatureTreeItem.cpp @@ -0,0 +1,69 @@ +// +// Created by simon on 02.02.23. +// +#include "FeatureTreeItem.h" +QVariant numericValue(vara::feature::Feature* Item) { + if(Item->getKind()==vara::feature::Feature::FeatureKind::FK_NUMERIC){ + auto *NumItem = dynamic_cast(Item); + string Result ="["; + if(std::holds_alternative(NumItem->getValues())){ + auto range = std::get(NumItem->getValues()); + Result+= std::to_string(range.first) +", "+std::to_string(range.second) + "]"; + } else { + auto Range = std::get(NumItem->getValues()); + for(auto It = Range.begin();It!=Range.end();It++){ + if(It!=Range.begin()){ + Result+=","; + } + Result+=std::to_string(*It.base()); + } + Result+="]"; + } + return QString::fromStdString(Result); + } + return {}; +} + + +QVariant locationString(vara::feature::Feature* Item){ + auto Locs = Item->getLocations(); + std::stringstream StrS; + if (Item->hasLocations()) { + std::for_each(Locs.begin(), Locs.end(), + [&StrS](const vara::feature::FeatureSourceRange &Fsr) { + StrS << llvm::formatv("{0}", Fsr.toString()).str(); + }); + } + return QString::fromStdString(StrS.str()); +} + +QVariant crossTreeConstraintString(vara::feature::Feature* Item){ + std::stringstream StrS; + for(auto Constraint:Item->constraints()){ + StrS << Constraint->toString(); + } + return QString::fromStdString(StrS.str()); +} + +FeatureTreeItem* FeatureTreeItem::createFeatureTreeItem( + vara::feature::Relationship *Item, FeatureTreeItem *Parent) { + return new FeatureTreeItemRelation(Item,Parent); +} +FeatureTreeItem* FeatureTreeItem::createFeatureTreeItem( + vara::feature::Feature *Item, FeatureTreeItem *Parent) { + return new FeatureTreeItemFeature(Item, Parent); +} + +QVariant FeatureTreeItemFeature::data(int Column) const { + switch (Column) { + case 0: return QString::fromStdString(Item->getName().str()); + case 1: return Item->isOptional()? QVariant("✓"):QVariant("x"); + case 2: return numericValue(Item); + case 3: return locationString(Item); + case 4: return crossTreeConstraintString(Item); + case 5: return Item. + default: + return {}; + } +} + diff --git a/tools/fm-editor/tree/FeatureTreeItem.h b/tools/fm-editor/tree/FeatureTreeItem.h new file mode 100644 index 000000000..e099e5e3a --- /dev/null +++ b/tools/fm-editor/tree/FeatureTreeItem.h @@ -0,0 +1,103 @@ +// +// Created by simon on 02.02.23. +// + +#ifndef VARA_FEATURE_FEATURETREEITEM_H +#define VARA_FEATURE_FEATURETREEITEM_H +#include "vara/Feature/Feature.h" +#include "vara/Feature/Relationship.h" +#include +#include +class FeatureTreeItem { +public: + virtual ~FeatureTreeItem() { + std::destroy(Children.begin(), Children.end()); + } + + FeatureTreeItem *child(int Row) { + if(Row<0||Row>Children.size()) { + return nullptr; + } + return Children[Row]; + } + int childCount() { + return Children.size(); + } + + int row() { + if(Parent) { + auto pos =std::find(Parent->Children.begin(), Parent->Children.end(), this); + if ( pos!=Parent->Children.end()){ + return pos-Parent->Children.begin(); + } + } + return 0; + } + FeatureTreeItem* parent() { + return Parent; + } + [[nodiscard]] virtual int columnCount() const = 0; + [[nodiscard]] virtual QVariant data(int Column) const = 0; + FeatureTreeItem static *createFeatureTreeItem(vara::feature::Relationship* Item,FeatureTreeItem* Parent); + FeatureTreeItem static *createFeatureTreeItem(vara::feature::Feature* Item,FeatureTreeItem* Parent); + bool booleanColumn(int Column) {return false;} +protected: + FeatureTreeItem(vara::feature::FeatureTreeNode* Item ,FeatureTreeItem* Parent): Parent(Parent) { + for(auto *Child : Item->children()){ + if(vara::feature::Relationship::classof(Child)) { + Children.push_back(createFeatureTreeItem(dynamic_cast(Child), this)); + }else { + Children.push_back(createFeatureTreeItem(dynamic_cast(Child), this)); + } + } + } + +private: + + FeatureTreeItem* Parent; + std::vector Children = {}; +}; + + +class FeatureTreeItemFeature: public FeatureTreeItem { +public: +virtual ~FeatureTreeItemFeature() = default; + FeatureTreeItemFeature(vara::feature::Feature* Item,FeatureTreeItem* Parent): FeatureTreeItem(Item,Parent), Item(Item) {} + [[nodiscard]] QVariant data(int Column) const override; + [[nodiscard]] int columnCount() const override {return 5;} + bool booleanColumn(int Column) {return Column==1;} +private: + vara::feature::Feature* Item; +}; + + +class FeatureTreeItemRelation: public FeatureTreeItem { +public: +virtual ~FeatureTreeItemRelation() = default; +FeatureTreeItemRelation(vara::feature::Relationship* Item,FeatureTreeItem* Parent): FeatureTreeItem(Item,Parent),Item(Item) {} +[[nodiscard]] QVariant data(int Column) const override{ + if(Column==0) { + return QString::fromStdString(relationType()); +} +} +[[nodiscard]] int columnCount() const override {return 1;} +private: + vara::feature::Relationship* Item; + [[nodiscard]] std::string relationType() const { + std::string Type; + switch (Item->getKind()) { + + case vara::feature::Relationship::RelationshipKind::RK_ALTERNATIVE: + Type = "⊕ Alternative"; + break; + case vara::feature::Relationship::RelationshipKind::RK_OR: + Type = "+ Or"; + break; + } + return Type; + } +}; + + + +#endif // VARA_FEATURE_FEATURETREEITEM_H diff --git a/tools/fm-editor/tree/FeatureTreeViewModel.cpp b/tools/fm-editor/tree/FeatureTreeViewModel.cpp new file mode 100644 index 000000000..1964239cd --- /dev/null +++ b/tools/fm-editor/tree/FeatureTreeViewModel.cpp @@ -0,0 +1,80 @@ +// +// Created by simon on 02.02.23. +// + +#include "FeatureTreeViewModel.h" + +QModelIndex FeatureTreeViewModel::index(int Row, int Column, const QModelIndex &Parent) const{ + FeatureTreeItem* ParentItem; + if (!Parent.isValid()) { + ParentItem = RootItem; + } else { + ParentItem = static_cast(Parent.internalPointer()); + } + auto *ChildItem= ParentItem->child(Row); + if(ChildItem) { + return createIndex(Row,Column,ChildItem); + } + return {}; +} + +QModelIndex FeatureTreeViewModel::parent(const QModelIndex &Child) const { + if(!Child.isValid()){ + return {}; + } + auto* ChildItem = static_cast(Child.internalPointer()); + auto* ParentItem = ChildItem->parent(); + if(ParentItem) { + return createIndex(ParentItem->row(),0,ParentItem); +} + return {}; +} +int FeatureTreeViewModel::rowCount(const QModelIndex &Parent) const { + if(Parent.column() > 0) { + return 0; +} + FeatureTreeItem* ParentItem; + if (!Parent.isValid()){ + ParentItem = RootItem; + } else { + ParentItem = static_cast(Parent.internalPointer()); + } + return ParentItem->childCount(); +} +int FeatureTreeViewModel::columnCount(const QModelIndex &Parent) const { + if(Parent.isValid()) { + return static_cast(Parent.internalPointer())->columnCount(); +} + return RootItem->columnCount(); +} +QVariant FeatureTreeViewModel::data(const QModelIndex &Index, int Role) const { + if(!Index.isValid() || Role!=Qt::DisplayRole) { + return {}; +} + auto* Item = static_cast(Index.internalPointer()); + return Item->data(Index.column()); +} +Qt::ItemFlags FeatureTreeViewModel::flags(const QModelIndex &Index) const { + if(Index.isValid()){ + auto *Item = static_cast(Index.internalPointer()); + if(Item->booleanColumn(Index.column())){ + return Qt::ItemIsUserCheckable | Qt::ItemIsSelectable | Qt::ItemIsEnabled; + } + } + return QAbstractItemModel::flags(Index); +} +QVariant FeatureTreeViewModel::headerData(int Section, + Qt::Orientation Orientation, + int Role) const { + if(Orientation == Qt::Orientation::Horizontal && Role == Qt::DisplayRole) { + switch (Section) { + case 0:return QString("Feature"); + case 1:return QString("Optional"); + case 2:return QString("NumericValues"); + case 3:return QString("Locations"); + case 4:return QString("Constraints"); + default:return QString("Todo"); + } +} +return {}; +} diff --git a/tools/fm-editor/tree/FeatureTreeViewModel.h b/tools/fm-editor/tree/FeatureTreeViewModel.h new file mode 100644 index 000000000..d88bad730 --- /dev/null +++ b/tools/fm-editor/tree/FeatureTreeViewModel.h @@ -0,0 +1,30 @@ +// +// Created by simon on 02.02.23. +// + +#ifndef VARA_FEATURE_FEATURETREEVIEWMODEL_H +#define VARA_FEATURE_FEATURETREEVIEWMODEL_H +#include "FeatureTreeItem.h" +#include "vara/Feature/FeatureModel.h" +#include +class FeatureTreeViewModel : public QAbstractItemModel { +public: + FeatureTreeViewModel(vara::feature::FeatureModel* Model, QObject *Parent): QAbstractItemModel(Parent), Model(Model), RootItem(FeatureTreeItem::createFeatureTreeItem(Model->getRoot(), nullptr)) { + + } + ~FeatureTreeViewModel() override{ + delete RootItem; + } + [[nodiscard]] QVariant data(const QModelIndex &Index, int Role = Qt::DisplayRole)const override; + [[nodiscard]] int rowCount(const QModelIndex &Parent = QModelIndex()) const override; + [[nodiscard]] QModelIndex index(int Row, int Column, const QModelIndex &Parent = QModelIndex()) const override; + [[nodiscard]] QModelIndex parent(const QModelIndex &Child) const override; + [[nodiscard]] int columnCount(const QModelIndex &Parent = QModelIndex()) const override; + [[nodiscard]] Qt::ItemFlags flags(const QModelIndex &Index) const override; + [[nodiscard]] QVariant headerData(int Section, Qt::Orientation Orientation, int Role = Qt::DisplayRole) const override; +private: + vara::feature::FeatureModel* Model; + FeatureTreeItem* RootItem; +}; + +#endif // VARA_FEATURE_FEATURETREEVIEWMODEL_H From 32c454ebb91b52e0e6bbff336afabb3dfc9471fd Mon Sep 17 00:00:00 2001 From: Florian Sattler Date: Mon, 7 Nov 2022 17:54:36 +0100 Subject: [PATCH 010/106] Removes deprecated std::iterator (#97) --- include/vara/Feature/FeatureModel.h | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/include/vara/Feature/FeatureModel.h b/include/vara/Feature/FeatureModel.h index db0ecd783..e212c4589 100644 --- a/include/vara/Feature/FeatureModel.h +++ b/include/vara/Feature/FeatureModel.h @@ -60,10 +60,15 @@ class FeatureModel { //===--------------------------------------------------------------------===// // DFS feature iterator - class DFSIterator : public std::iterator { + class DFSIterator { public: + using iterator_category = std::forward_iterator_tag; + using value_type = Feature *; + using difference_type = ptrdiff_t; + using pointer = Feature **; + using reference = Feature *; + using const_pointer = const Feature *const *; using const_reference = const Feature *; @@ -167,11 +172,15 @@ class FeatureModel { //===--------------------------------------------------------------------===// // Unordered feature iterator - class FeatureMapIterator - : public std::iterator { + class FeatureMapIterator { public: + using iterator_category = std::forward_iterator_tag; + using value_type = Feature *; + using difference_type = ptrdiff_t; + using pointer = Feature *; + using reference = Feature *; + using const_pointer = const Feature *; using const_reference = const Feature *; From 7507cbb2a395d71992204effafb926f4d88c80d8 Mon Sep 17 00:00:00 2001 From: Florian Sattler Date: Tue, 8 Nov 2022 20:47:14 +0100 Subject: [PATCH 011/106] Updates python binding library (#99) --- external/pybind11 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/pybind11 b/external/pybind11 index 2d6014e41..ee2b52262 160000 --- a/external/pybind11 +++ b/external/pybind11 @@ -1 +1 @@ -Subproject commit 2d6014e417a9be926eb9a3c490570707be35cd42 +Subproject commit ee2b5226295d67b690faddd446a329bb2840a1a8 From a255aa474415afa7be52ccd4491edc23e88bbb21 Mon Sep 17 00:00:00 2001 From: Florian Sattler Date: Wed, 9 Nov 2022 10:19:13 +0100 Subject: [PATCH 012/106] Move to LLVM 14 (#98) --- .github/workflows/build.yml | 20 ++++++++------------ .github/workflows/deploydocs.yml | 9 ++++----- .github/workflows/reviewdog.yml | 6 +++--- CMakeLists.txt | 2 +- README.md | 4 ++-- include/vara/Feature/ConstraintParser.h | 2 +- scripts/ci_utils/prepare_coverage_data.py | 4 ++-- 7 files changed, 21 insertions(+), 26 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c44a9bc5b..8dc736bd9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,18 +13,14 @@ jobs: fail-fast: true matrix: build: [ Debug, Release ] - llvm-major: [ 10, 11 ] - compiler: [ clang++-11, clang++-12, g++-9 ] + llvm-major: [ 14 ] + compiler: [ clang++-14, clang++-15, g++-9 ] include: - - llvm-major: 10 - llvm-minor: 0 - - llvm-major: 11 + - llvm-major: 14 llvm-minor: 0 exclude: - - llvm-major: 10 - compiler: clang++-12 - - llvm-major: 11 - compiler: clang++-11 + - llvm-major: 14 + compiler: clang++-15 continue-on-error: false steps: @@ -46,10 +42,10 @@ jobs: shell: bash run: | sudo apt-key adv --fetch-keys https://apt.llvm.org/llvm-snapshot.gpg.key - sudo add-apt-repository -y 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal main' - sudo add-apt-repository -y 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-12 main' + sudo add-apt-repository -y 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main' + sudo add-apt-repository -y 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-15 main' sudo apt-get update - sudo apt-get -y install --no-install-recommends clang-${{ matrix.llvm-major }} llvm-${{ matrix.llvm-major }}-dev clang-tidy-12 + sudo apt-get -y install --no-install-recommends clang-${{ matrix.llvm-major }} llvm-${{ matrix.llvm-major }}-dev clang-tidy-14 - name: Build ${{ matrix.build }} with LLVM ${{ matrix.llvm-major }} env: diff --git a/.github/workflows/deploydocs.yml b/.github/workflows/deploydocs.yml index acbe1cff5..fded1d2f8 100644 --- a/.github/workflows/deploydocs.yml +++ b/.github/workflows/deploydocs.yml @@ -27,16 +27,15 @@ jobs: shell: bash run: | sudo apt-key adv --fetch-keys https://apt.llvm.org/llvm-snapshot.gpg.key - sudo add-apt-repository -y 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-10 main' - sudo add-apt-repository -y 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-11 main' + sudo add-apt-repository -y 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main' sudo apt-get update - sudo apt-get -y install --no-install-recommends clang-11 llvm-11-dev + sudo apt-get -y install --no-install-recommends clang-14 llvm-14-dev - name: Build docs env: BUILD_TYPE: Release - LLVM_VERSION: 11.1 - CXX: clang++-11 + LLVM_VERSION: 14.0 + CXX: clang++-14 shell: bash run: | mkdir build diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml index d7ddc6bf2..73008f5d7 100644 --- a/.github/workflows/reviewdog.yml +++ b/.github/workflows/reviewdog.yml @@ -15,11 +15,11 @@ jobs: - tool: clang-format install: | sudo apt-key adv --fetch-keys https://apt.llvm.org/llvm-snapshot.gpg.key - sudo add-apt-repository -y 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-11 main' + sudo add-apt-repository -y 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main' sudo apt-get update - sudo apt-get -y install --no-install-recommends clang-format-11 + sudo apt-get -y install --no-install-recommends clang-format-14 regex: \.(h|c|hpp|cpp)$ - command: clang-format-11 --style=file -i + command: clang-format-14 --style=file -i continue-on-error: false steps: diff --git a/CMakeLists.txt b/CMakeLists.txt index bbe9108fd..810b12545 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -111,7 +111,7 @@ include("vara_feature_macros") # Include external dependencies if (NOT VARA_FEATURE_IN_TREE) - set(MIN_LLVM_REQUIRED 10) + set(MIN_LLVM_REQUIRED 14) # Only search for LLVM if we build out of tree if (DEFINED LLVM_REQUESTED_VERSION) diff --git a/README.md b/README.md index 79440898d..faf41a189 100644 --- a/README.md +++ b/README.md @@ -28,9 +28,9 @@ Adhere to the output of ```bash llvm-config --version ``` -To set the version to version 10.0, for instance, you can use the following command: +To set the version to version 16.0, for instance, you can use the following command: ```bash -CC=clang CXX=clang++ cmake -DLLVM_REQUESTED_VERSION=10.0 .. +CC=clang CXX=clang++ cmake -DLLVM_REQUESTED_VERSION=16.0 .. ``` diff --git a/include/vara/Feature/ConstraintParser.h b/include/vara/Feature/ConstraintParser.h index 548d11750..450e1d794 100644 --- a/include/vara/Feature/ConstraintParser.h +++ b/include/vara/Feature/ConstraintParser.h @@ -265,7 +265,7 @@ class ConstraintLexer { /// Parse 64-bit integer in decimal or scientific notation. static int64_t parseInteger(llvm::StringRef Str, llvm::Optional Line = llvm::None) { - if (Str.contains_lower('e')) { + if (Str.contains_insensitive('e')) { // If we encounter scientific notation we try to parse the number as double. if (double Double; !Str.getAsDouble(Double)) { return parseInteger(llvm::formatv("{0:0}", Double).str()); diff --git a/scripts/ci_utils/prepare_coverage_data.py b/scripts/ci_utils/prepare_coverage_data.py index a7cd69a15..100718156 100755 --- a/scripts/ci_utils/prepare_coverage_data.py +++ b/scripts/ci_utils/prepare_coverage_data.py @@ -15,7 +15,7 @@ def get_llvm_cov_binary_name() -> str: """ possible_binary_names = ["llvm-cov"] possible_binary_names.extend( - ["llvm-cov-" + str(x) for x in range(14, 7, -1)]) + ["llvm-cov-" + str(x) for x in range(15, 7, -1)]) for binary_name in possible_binary_names: if which(binary_name) is not None: @@ -30,7 +30,7 @@ def get_llvm_profdata_binary_name() -> str: """ possible_binary_names = ["llvm-profdata"] possible_binary_names.extend( - ["llvm-profdata-" + str(x) for x in range(14, 7, -1)]) + ["llvm-profdata-" + str(x) for x in range(15, 7, -1)]) for binary_name in possible_binary_names: if which(binary_name) is not None: From fda30dc8e42417ceb7bc68aa84e4f61422be112b Mon Sep 17 00:00:00 2001 From: Lauritz Timm Date: Sun, 13 Nov 2022 18:09:00 +0000 Subject: [PATCH 013/106] Add Relationships Iterator and Sort Methods in Header (#95) --- .../vara-feature/pybind_FeatureModel.cpp | 2 +- include/vara/Feature/FeatureModel.h | 124 +++++++++++------- lib/Feature/FeatureModelParser.cpp | 3 +- unittests/Feature/FeatureModel.cpp | 28 ++-- unittests/Feature/OrderedFeatureVector.cpp | 2 +- 5 files changed, 101 insertions(+), 58 deletions(-) diff --git a/bindings/python/vara-feature/pybind_FeatureModel.cpp b/bindings/python/vara-feature/pybind_FeatureModel.cpp index 39d4c9a37..d1fa4f3a1 100644 --- a/bindings/python/vara-feature/pybind_FeatureModel.cpp +++ b/bindings/python/vara-feature/pybind_FeatureModel.cpp @@ -96,7 +96,7 @@ void init_feature_model_module(py::module &M) { .def("__len__", &vf::FeatureModel::size) .def( "__iter__", - [](vf::FeatureModel &FM) { + [](const vf::FeatureModel &FM) { return py::make_iterator(FM.begin(), FM.end()); }, py::keep_alive<0, 1>()); diff --git a/include/vara/Feature/FeatureModel.h b/include/vara/Feature/FeatureModel.h index e212c4589..7b44c63ed 100644 --- a/include/vara/Feature/FeatureModel.h +++ b/include/vara/Feature/FeatureModel.h @@ -55,8 +55,19 @@ class FeatureModel { [[nodiscard]] llvm::StringRef getCommit() const { return Commit; } + //===--------------------------------------------------------------------===// + // Features + [[nodiscard]] RootFeature *getRoot() const { return Root; } + [[nodiscard]] Feature *getFeature(llvm::StringRef F) const { + auto SearchFeature = Features.find(F); + if (SearchFeature != Features.end()) { + return SearchFeature->getValue().get(); + } + return nullptr; + } + //===--------------------------------------------------------------------===// // DFS feature iterator @@ -148,22 +159,13 @@ class FeatureModel { std::set Visited; }; - using ordered_feature_iterator = DFSIterator; using const_ordered_feature_iterator = DFSIterator; - ordered_feature_iterator begin() { return {Root}; } [[nodiscard]] const_ordered_feature_iterator begin() const { return {Root}; } - - ordered_feature_iterator end() { - return {Root ? Root->getParentFeature() : nullptr}; - } [[nodiscard]] const_ordered_feature_iterator end() const { return {Root ? Root->getParentFeature() : nullptr}; } - llvm::iterator_range features() { - return llvm::make_range(begin(), end()); - } [[nodiscard]] llvm::iterator_range features() const { return llvm::make_range(begin(), end()); @@ -221,13 +223,8 @@ class FeatureModel { FeatureMapTy::const_iterator MapIter; }; - using unordered_feature_iterator = FeatureMapIterator; using const_unordered_feature_iterator = FeatureMapIterator; - llvm::iterator_range unorderedFeatures() { - return llvm::make_range(FeatureMapIterator(Features.begin()), - FeatureMapIterator(Features.end())); - } [[nodiscard]] llvm::iterator_range unorderedFeatures() const { return llvm::make_range(FeatureMapIterator(Features.begin()), @@ -237,31 +234,30 @@ class FeatureModel { //===--------------------------------------------------------------------===// // Constraints - using constraint_iterator = typename ConstraintContainerTy::iterator; using const_constraint_iterator = typename ConstraintContainerTy::const_iterator; - [[nodiscard]] llvm::iterator_range constraints() { - return llvm::make_range(Constraints.begin(), Constraints.end()); - } [[nodiscard]] llvm::iterator_range constraints() const { return llvm::make_range(Constraints.begin(), Constraints.end()); } //===--------------------------------------------------------------------===// - // Utility + // Relationships - void view() { ViewGraph(this, "FeatureModel-" + this->getName()); } + using const_relationship_iterator = + typename RelationshipContainerTy::const_iterator; - [[nodiscard]] Feature *getFeature(llvm::StringRef F) const { - auto SearchFeature = Features.find(F); - if (SearchFeature != Features.end()) { - return SearchFeature->getValue().get(); - } - return nullptr; + [[nodiscard]] llvm::iterator_range + relationships() const { + return llvm::make_range(Relationships.begin(), Relationships.end()); } + //===--------------------------------------------------------------------===// + // Utility + + void view() { ViewGraph(this, "FeatureModel-" + this->getName()); } + /// Create deep clone of whole data structure. /// /// \return new \a FeatureModel @@ -271,6 +267,15 @@ class FeatureModel { void dump() const; private: + void setName(std::string NewName) { Name = std::move(NewName); } + + void setPath(fs::path NewPath) { Path = std::move(NewPath); } + + void setCommit(std::string NewCommit) { Commit = std::move(NewCommit); } + + //===--------------------------------------------------------------------===// + // Features + /// Insert a \a Feature into existing model. /// /// \param[in] Feature feature to be inserted @@ -278,6 +283,47 @@ class FeatureModel { /// \returns ptr to inserted \a Feature Feature *addFeature(std::unique_ptr Feature); + /// Delete a \a Feature. + void removeFeature(Feature &Feature); + + RootFeature *setRoot(RootFeature &NewRoot); + + using ordered_feature_iterator = DFSIterator; + + [[nodiscard]] ordered_feature_iterator begin() { return {Root}; } + [[nodiscard]] ordered_feature_iterator end() { + return {Root ? Root->getParentFeature() : nullptr}; + } + + [[nodiscard]] llvm::iterator_range features() { + return llvm::make_range(begin(), end()); + } + + using unordered_feature_iterator = FeatureMapIterator; + + [[nodiscard]] llvm::iterator_range + unorderedFeatures() { + return llvm::make_range(FeatureMapIterator(Features.begin()), + FeatureMapIterator(Features.end())); + } + + //===--------------------------------------------------------------------===// + // Constraints + + Constraint *addConstraint(std::unique_ptr Constraint) { + Constraints.push_back(std::move(Constraint)); + return Constraints.back().get(); + } + + using constraint_iterator = typename ConstraintContainerTy::iterator; + + [[nodiscard]] llvm::iterator_range constraints() { + return llvm::make_range(Constraints.begin(), Constraints.end()); + } + + //===--------------------------------------------------------------------===// + // Relationships + Relationship *addRelationship(std::unique_ptr Relationship) { Relationships.push_back(std::move(Relationship)); return Relationships.back().get(); @@ -291,21 +337,11 @@ class FeatureModel { })); } - Constraint *addConstraint(std::unique_ptr Constraint) { - Constraints.push_back(std::move(Constraint)); - return Constraints.back().get(); - } + using relationship_iterator = typename RelationshipContainerTy::iterator; - /// Delete a \a Feature. - void removeFeature(Feature &Feature); - - RootFeature *setRoot(RootFeature &NewRoot); - - void setName(std::string NewName) { Name = std::move(NewName); } - - void setPath(fs::path NewPath) { Path = std::move(NewPath); } - - void setCommit(std::string NewCommit) { Commit = std::move(NewCommit); } + [[nodiscard]] llvm::iterator_range relationships() { + return llvm::make_range(Relationships.begin(), Relationships.end()); + } std::string Name; RootFeature *Root; @@ -501,7 +537,7 @@ namespace vara::feature { template class FeatureModelConsistencyChecker { public: - static Result isFeatureModelValid(FeatureModel &FM) { + static Result isFeatureModelValid(const FeatureModel &FM) { if (auto E = (Rules::check(FM) && ... && true); !E) { return Error(INCONSISTENT); } @@ -510,7 +546,7 @@ class FeatureModelConsistencyChecker { }; struct EveryFeatureRequiresParent { - static bool check(FeatureModel &FM) { + static bool check(const FeatureModel &FM) { if (std::all_of(FM.unorderedFeatures().begin(), FM.unorderedFeatures().end(), [](Feature *F) { return llvm::isa(F) || F->getParentFeature(); @@ -523,7 +559,7 @@ struct EveryFeatureRequiresParent { }; struct CheckFeatureParentChildRelationShip { - static bool check(FeatureModel &FM) { + static bool check(const FeatureModel &FM) { if (std::all_of( FM.unorderedFeatures().begin(), FM.unorderedFeatures().end(), [](Feature *F) { @@ -542,7 +578,7 @@ struct CheckFeatureParentChildRelationShip { }; struct ExactlyOneRootNode { - static bool check(FeatureModel &FM) { + static bool check(const FeatureModel &FM) { if (llvm::isa_and_nonnull(FM.getRoot()) && 1 == std::accumulate(FM.unorderedFeatures().begin(), FM.unorderedFeatures().end(), 0, diff --git a/lib/Feature/FeatureModelParser.cpp b/lib/Feature/FeatureModelParser.cpp index afdaeb9c9..68e2e0898 100644 --- a/lib/Feature/FeatureModelParser.cpp +++ b/lib/Feature/FeatureModelParser.cpp @@ -289,7 +289,8 @@ bool detectExclude(const Feature *A, const Feature *B) { Result FeatureModelXmlParser::detectXMLAlternatives(FeatureModel &FM) { auto Transactions = FeatureModelModifyTransaction::openTransaction(FM); - for (auto *F : FM) { + const auto &FMConstRef = FM; + for (auto *F : FMConstRef) { auto Children = F->getChildren(); if (Children.size() > 1 && std::all_of(Children.begin(), Children.end(), [Children](auto *F) { diff --git a/unittests/Feature/FeatureModel.cpp b/unittests/Feature/FeatureModel.cpp index 9554364ca..4623162a9 100644 --- a/unittests/Feature/FeatureModel.cpp +++ b/unittests/Feature/FeatureModel.cpp @@ -20,13 +20,13 @@ TEST(FeatureModel, cloneUnique) { B.makeFeature("a"); B.makeFeature("aa")->addEdge("a", "aa"); B.makeFeature("b"); - auto FM = B.buildFeatureModel(); + std::unique_ptr FM = B.buildFeatureModel(); ASSERT_TRUE(FM); auto Clone = FM->clone(); ASSERT_TRUE(Clone); - for (const auto &Feature : FM->features()) { + for (const auto &Feature : FM->unorderedFeatures()) { EXPECT_NE(Clone->getFeature(Feature->getName()), Feature); } } @@ -107,7 +107,7 @@ class FeatureModelTest : public ::testing::Test { ASSERT_TRUE(FM); } - std::unique_ptr FM; + std::unique_ptr FM; }; TEST_F(FeatureModelTest, iter) { @@ -244,7 +244,7 @@ class FeatureModelConsistencyCheckerTest // Dummy method to fulfill the FeatureModelModification interface Result exec(FeatureModel &_) override { return {ERROR}; } - std::unique_ptr FM; + std::unique_ptr FM; }; TEST_F(FeatureModelConsistencyCheckerTest, NoChecksIsTrue) { @@ -284,25 +284,31 @@ TEST_F(FeatureModelConsistencyCheckerTest, } TEST_F(FeatureModelConsistencyCheckerTest, FMNoRoot) { - FeatureModel FM; + FeatureModelBuilder B; + FM = B.buildFeatureModel(); - FeatureModelModification::removeFeature(FM, *FM.getRoot()); + auto Mod = FM->clone(); + FeatureModelModification::removeFeature(*Mod, *Mod->getRoot()); - EXPECT_EQ(FM.size(), 0); - EXPECT_EQ(FM.begin(), FM.end()); + EXPECT_EQ(Mod->size(), 0); EXPECT_FALSE( FeatureModelConsistencyChecker::isFeatureModelValid( - FM)); + *Mod)); + + const auto &FMConstRef = *Mod; + EXPECT_EQ(FMConstRef.begin(), FMConstRef.end()); } TEST_F(FeatureModelConsistencyCheckerTest, EveryFMNeedsOneRootButMultiplePresent) { + auto Mod = FM->clone(); + ASSERT_TRUE(FeatureModelModification::addFeature( - *FM, std::make_unique("z"))); + *Mod, std::make_unique("z"))); EXPECT_FALSE( FeatureModelConsistencyChecker::isFeatureModelValid( - *FM)); + *Mod)); } } // namespace vara::feature diff --git a/unittests/Feature/OrderedFeatureVector.cpp b/unittests/Feature/OrderedFeatureVector.cpp index 1c646e3ca..d8bfcce57 100644 --- a/unittests/Feature/OrderedFeatureVector.cpp +++ b/unittests/Feature/OrderedFeatureVector.cpp @@ -19,7 +19,7 @@ class OrderedFeatureVectorTest : public ::testing::Test { ASSERT_TRUE(FM); } - std::unique_ptr FM; + std::unique_ptr FM; }; TEST_F(OrderedFeatureVectorTest, insert) { From 466bcba4f69d11ae30774cdd1ccaca3c51f971b8 Mon Sep 17 00:00:00 2001 From: Lauritz Timm Date: Wed, 16 Nov 2022 13:19:19 +0000 Subject: [PATCH 014/106] Add Output String For Features (#100) --- bindings/python/tests/feature/test_feature.py | 5 +++ .../python/vara-feature/pybind_Feature.cpp | 9 +++++ include/vara/Feature/Feature.h | 33 +++++++++++-------- lib/Feature/FeatureModelParser.cpp | 11 +++++-- lib/Feature/XmlConstants.h | 1 + unittests/Feature/Feature.cpp | 6 ++++ unittests/Feature/FeatureModelParser.cpp | 8 +++++ unittests/resources/CMakeLists.txt | 1 + .../resources/xml/test_output_string.xml | 14 ++++++++ 9 files changed, 72 insertions(+), 16 deletions(-) create mode 100644 unittests/resources/xml/test_output_string.xml diff --git a/bindings/python/tests/feature/test_feature.py b/bindings/python/tests/feature/test_feature.py index d14142f6a..bc0f0b580 100644 --- a/bindings/python/tests/feature/test_feature.py +++ b/bindings/python/tests/feature/test_feature.py @@ -18,6 +18,11 @@ def test_get_name(self): test_feature = feature.BinaryFeature("Foo", False) self.assertEqual("Foo", test_feature.name.str()) + def test_string(self): + """ Checks output string. """ + test_feature = feature.BinaryFeature("Foo", False, [], "--foo") + self.assertEqual("--foo", test_feature.output_string.str()) + def test_is_optinal(self): """ Checks if the Feature is optional. """ test_feature = feature.BinaryFeature("Foo", False) diff --git a/bindings/python/vara-feature/pybind_Feature.cpp b/bindings/python/vara-feature/pybind_Feature.cpp index 91c81eceb..a06be26c0 100644 --- a/bindings/python/vara-feature/pybind_Feature.cpp +++ b/bindings/python/vara-feature/pybind_Feature.cpp @@ -42,6 +42,9 @@ void init_feature_module_feature(py::module &M) { .def("__hash__", &vf::Feature::hash) .def_property_readonly("name", &vf::Feature::getName, R"pbdoc(The name of the feature.)pbdoc") + .def_property_readonly( + "output_string", &vf::Feature::getOutputString, + R"pbdoc(Returns the output string of a feature.)pbdoc") .def( "is_root", [](const vf::Feature &F) { return llvm::isa(F); }, @@ -90,6 +93,9 @@ void init_feature_module_binary_feature(py::module &M) { .def(py::init()) .def(py::init>()) + .def(py::init, + std::string>()) .def( "to_string", &vf::BinaryFeature::toString, R"pbdoc(Returns the string representation of a BinaryFeature.)pbdoc"); @@ -100,6 +106,9 @@ void init_feature_module_numeric_feature(py::module &M) { .def(py::init()) .def(py::init>()) + .def(py::init, + std::string>()) .def( "to_string", &vf::NumericFeature::toString, R"pbdoc(Returns the string representation of a NumericFeature.)pbdoc"); diff --git a/include/vara/Feature/Feature.h b/include/vara/Feature/Feature.h index a8f229673..dd352742a 100644 --- a/include/vara/Feature/Feature.h +++ b/include/vara/Feature/Feature.h @@ -18,8 +18,6 @@ #include #include -using std::string; - namespace vara::feature { namespace detail { @@ -56,6 +54,8 @@ class Feature : public FeatureTreeNode { [[nodiscard]] llvm::StringRef getName() const { return Name; } + [[nodiscard]] llvm::StringRef getOutputString() const { return OutputString; } + [[nodiscard]] bool isOptional() const { return Opt; } /// Search parent feature in tree structure -- this may not exist or nullptr @@ -181,11 +181,13 @@ class Feature : public FeatureTreeNode { } protected: - Feature(FeatureKind Kind, string Name, bool Opt, + Feature(FeatureKind Kind, std::string Name, bool Opt, std::vector Locations, - FeatureTreeNode *Parent = nullptr, const NodeSetType &Children = {}) + std::string OutputString = "", FeatureTreeNode *Parent = nullptr, + const NodeSetType &Children = {}) : FeatureTreeNode(NodeKind::NK_FEATURE, Parent, Children), Kind(Kind), - Name(std::move(Name)), Locations(std::move(Locations)), Opt(Opt) {} + Name(std::move(Name)), OutputString(std::move(OutputString)), + Locations(std::move(Locations)), Opt(Opt) {} private: void addConstraint(Constraint *C) { @@ -211,7 +213,8 @@ class Feature : public FeatureTreeNode { } const FeatureKind Kind; - string Name; + std::string Name; + std::string OutputString; std::vector Locations; std::vector Constraints; std::vector Excludes; @@ -224,9 +227,11 @@ class BinaryFeature : public Feature { public: BinaryFeature( - string Name, bool Opt = false, - std::vector Loc = std::vector()) - : Feature(FeatureKind::FK_BINARY, std::move(Name), Opt, std::move(Loc)) {} + std::string Name, bool Opt = false, + std::vector Loc = std::vector(), + std::string OutputString = "") + : Feature(FeatureKind::FK_BINARY, std::move(Name), Opt, std::move(Loc), + std::move(OutputString)) {} [[nodiscard]] string toString() const override; @@ -244,9 +249,11 @@ class NumericFeature : public Feature { typename std::variant; NumericFeature( - string Name, ValuesVariantType Values, bool Opt = false, - std::vector Loc = std::vector()) - : Feature(FeatureKind::FK_NUMERIC, std::move(Name), Opt, std::move(Loc)), + std::string Name, ValuesVariantType Values, bool Opt = false, + std::vector Loc = std::vector(), + std::string OutputString = "") + : Feature(FeatureKind::FK_NUMERIC, std::move(Name), Opt, std::move(Loc), + std::move(OutputString)), Values(std::move(Values)) {} [[nodiscard]] ValuesVariantType getValues() const { return Values; } @@ -267,7 +274,7 @@ class NumericFeature : public Feature { class RootFeature : public Feature { public: - explicit RootFeature(string Name) + explicit RootFeature(std::string Name) : Feature(FeatureKind::FK_ROOT, std::move(Name), false, {}) {} static bool classof(const Feature *F) { diff --git a/lib/Feature/FeatureModelParser.cpp b/lib/Feature/FeatureModelParser.cpp index 68e2e0898..db9af81df 100644 --- a/lib/Feature/FeatureModelParser.cpp +++ b/lib/Feature/FeatureModelParser.cpp @@ -25,6 +25,7 @@ Result FeatureModelXmlParser::parseConfigurationOption(xmlNode *Node, bool Num = false) { std::string Name{"root"}; + std::string OutputString; bool Opt = false; int64_t MinValue = 0; int64_t MaxValue = 0; @@ -42,6 +43,8 @@ FeatureModelXmlParser::parseConfigurationOption(xmlNode *Node, // the input beforehand. if (!xmlStrcmp(Head->name, XmlConstants::NAME)) { Name = Cnt; + } else if (!xmlStrcmp(Head->name, XmlConstants::OUTPUTSTRING)) { + OutputString = Cnt; } else if (!xmlStrcmp(Head->name, XmlConstants::OPTIONAL)) { Opt = Cnt == "True"; } else if (!xmlStrcmp(Head->name, XmlConstants::PARENT)) { @@ -127,13 +130,15 @@ FeatureModelXmlParser::parseConfigurationOption(xmlNode *Node, } else if (Num) { if (Values.empty()) { FMB.makeFeature(Name, std::make_pair(MinValue, MaxValue), - Opt, std::move(SourceRanges)); + Opt, std::move(SourceRanges), + OutputString); } else { FMB.makeFeature(Name, Values, Opt, - std::move(SourceRanges)); + std::move(SourceRanges), OutputString); } } else { - FMB.makeFeature(Name, Opt, std::move(SourceRanges)); + FMB.makeFeature(Name, Opt, std::move(SourceRanges), + OutputString); } return Ok(); } diff --git a/lib/Feature/XmlConstants.h b/lib/Feature/XmlConstants.h index 634056c4a..31f05d2de 100644 --- a/lib/Feature/XmlConstants.h +++ b/lib/Feature/XmlConstants.h @@ -16,6 +16,7 @@ class XmlConstants { static constexpr xmlChar VM[] = "vm"; static constexpr xmlChar NAME[] = "name"; + static constexpr xmlChar OUTPUTSTRING[] = "outputString"; static constexpr xmlChar COMMIT[] = "commit"; static constexpr xmlChar OPTIONAL[] = "optional"; static constexpr xmlChar PARENT[] = "parent"; diff --git a/unittests/Feature/Feature.cpp b/unittests/Feature/Feature.cpp index ac89b3ad4..8299c1f91 100644 --- a/unittests/Feature/Feature.cpp +++ b/unittests/Feature/Feature.cpp @@ -15,6 +15,12 @@ TEST(Feature, equal) { EXPECT_NE(A0, B); } +TEST(Feature, outputString) { + BinaryFeature F("Foo", false, {}, "--foo"); + + EXPECT_EQ(F.getOutputString(), "--foo"); +} + TEST(Feature, locationAccessors) { FeatureSourceRange::FeatureSourceLocation Start(3, 4); FeatureSourceRange::FeatureSourceLocation End(3, 20); diff --git a/unittests/Feature/FeatureModelParser.cpp b/unittests/Feature/FeatureModelParser.cpp index a649dc2c1..be6647139 100644 --- a/unittests/Feature/FeatureModelParser.cpp +++ b/unittests/Feature/FeatureModelParser.cpp @@ -119,6 +119,14 @@ TEST(FeatureModelParser, memberOffset) { } } +TEST(FeatureModelParser, outputString) { + auto FM = buildFeatureModel("test_output_string.xml"); + ASSERT_TRUE(FM); + + auto *F = FM->getFeature("A"); + EXPECT_EQ(F->getOutputString(), "-a"); +} + //===----------------------------------------------------------------------===// // XMLAlternatives //===----------------------------------------------------------------------===// diff --git a/unittests/resources/CMakeLists.txt b/unittests/resources/CMakeLists.txt index 55fe5b2e5..4c270e69d 100644 --- a/unittests/resources/CMakeLists.txt +++ b/unittests/resources/CMakeLists.txt @@ -26,6 +26,7 @@ set(FEATURE_LIB_TEST_FILES xml/test_only_children.xml xml/test_only_parents.xml xml/test_out_of_order.xml + xml/test_output_string.xml xml/test_with_whitespaces.xml ) diff --git a/unittests/resources/xml/test_output_string.xml b/unittests/resources/xml/test_output_string.xml new file mode 100644 index 000000000..65c6cd208 --- /dev/null +++ b/unittests/resources/xml/test_output_string.xml @@ -0,0 +1,14 @@ + + + + + + A + -a + root + True + + + + + From 6c1b073e15d4bb05818b1891a2809725bf83104e Mon Sep 17 00:00:00 2001 From: Lauritz Timm Date: Sun, 18 Dec 2022 22:44:46 +0000 Subject: [PATCH 015/106] Adds parsing of step functions (#103) resolves se-sic/VaRA#966 --- include/vara/Feature/Feature.h | 9 +- include/vara/Feature/StepFunction.h | 91 +++++ include/vara/Feature/StepFunctionParser.h | 322 ++++++++++++++++++ lib/Feature/FeatureModelParser.cpp | 9 +- unittests/Feature/CMakeLists.txt | 2 + unittests/Feature/FeatureModelParser.cpp | 14 + unittests/Feature/StepFunction.cpp | 84 +++++ unittests/Feature/StepFunctionParser.cpp | 117 +++++++ unittests/resources/CMakeLists.txt | 1 + .../resources/xml/test_step_function.xml | 16 + 10 files changed, 661 insertions(+), 4 deletions(-) create mode 100644 include/vara/Feature/StepFunction.h create mode 100644 include/vara/Feature/StepFunctionParser.h create mode 100644 unittests/Feature/StepFunction.cpp create mode 100644 unittests/Feature/StepFunctionParser.cpp create mode 100644 unittests/resources/xml/test_step_function.xml diff --git a/include/vara/Feature/Feature.h b/include/vara/Feature/Feature.h index dd352742a..e36feabdb 100644 --- a/include/vara/Feature/Feature.h +++ b/include/vara/Feature/Feature.h @@ -4,6 +4,7 @@ #include "vara/Feature/Constraint.h" #include "vara/Feature/FeatureSourceRange.h" #include "vara/Feature/FeatureTreeNode.h" +#include "vara/Feature/StepFunction.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/SetVector.h" @@ -251,13 +252,16 @@ class NumericFeature : public Feature { NumericFeature( std::string Name, ValuesVariantType Values, bool Opt = false, std::vector Loc = std::vector(), - std::string OutputString = "") + std::string OutputString = "", + std::unique_ptr Step = nullptr) : Feature(FeatureKind::FK_NUMERIC, std::move(Name), Opt, std::move(Loc), std::move(OutputString)), - Values(std::move(Values)) {} + Values(std::move(Values)), Step(std::move(Step)) {} [[nodiscard]] ValuesVariantType getValues() const { return Values; } + [[nodiscard]] StepFunction *getStepFunction() { return Step.get(); } + [[nodiscard]] string toString() const override; static bool classof(const Feature *F) { @@ -266,6 +270,7 @@ class NumericFeature : public Feature { private: ValuesVariantType Values; + std::unique_ptr Step; }; //===----------------------------------------------------------------------===// diff --git a/include/vara/Feature/StepFunction.h b/include/vara/Feature/StepFunction.h new file mode 100644 index 000000000..114759d2e --- /dev/null +++ b/include/vara/Feature/StepFunction.h @@ -0,0 +1,91 @@ +#ifndef VARA_FEATURE_STEPFUNCTION_H +#define VARA_FEATURE_STEPFUNCTION_H + +#include "llvm/Support/FormatVariadic.h" + +#include +#include +#include + +namespace vara::feature { + +//===----------------------------------------------------------------------===// +// StepFunction Class +//===----------------------------------------------------------------------===// + +class StepFunction { +public: + enum class StepOperation { ADDITION, MULTIPLICATION, EXPONENTIATION }; + + using OperandVariantType = typename std::variant; + + StepFunction(OperandVariantType LHS, StepOperation Op, OperandVariantType RHS) + : Op(Op), LHS(std::move(LHS)), RHS(std::move(RHS)) {} + + StepFunction(StepOperation Op, double RHS) : StepFunction("x", Op, RHS) {} + StepFunction(double LHS, StepOperation Op) : StepFunction(LHS, Op, "x") {} + + template + [[nodiscard]] T next(T Value) { + if (std::holds_alternative(RHS)) { + assert(std::holds_alternative(LHS)); + switch (Op) { + case StepOperation::ADDITION: + return Value + std::get(RHS); + case StepOperation::MULTIPLICATION: + return Value * std::get(RHS); + case StepOperation::EXPONENTIATION: + return std::pow(Value, std::get(RHS)); + } + } + assert(std::holds_alternative(LHS)); + switch (Op) { + case StepOperation::ADDITION: + return std::get(LHS) + Value; + case StepOperation::MULTIPLICATION: + return std::get(LHS) * Value; + case StepOperation::EXPONENTIATION: + return std::pow(std::get(LHS), Value); + } + } + + [[nodiscard]] double operator()(double Value) { return next(Value); } + + [[nodiscard]] std::string toString() const { + if (std::holds_alternative(RHS)) { + assert(std::holds_alternative(LHS)); + switch (Op) { + case StepOperation::ADDITION: + return llvm::formatv("{0} + {1}", std::get(LHS), + std::get(RHS)); + case StepOperation::MULTIPLICATION: + return llvm::formatv("{0} * {1}", std::get(LHS), + std::get(RHS)); + case StepOperation::EXPONENTIATION: + return llvm::formatv("{0} ^ {1}", std::get(LHS), + std::get(RHS)); + } + } + assert(std::holds_alternative(LHS)); + switch (Op) { + case StepOperation::ADDITION: + return llvm::formatv("{0} + {1}", std::get(LHS), + std::get(RHS)); + case StepOperation::MULTIPLICATION: + return llvm::formatv("{0} * {1}", std::get(LHS), + std::get(RHS)); + case StepOperation::EXPONENTIATION: + return llvm::formatv("{0} ^ {1}", std::get(LHS), + std::get(RHS)); + } + } + +private: + StepOperation Op; + OperandVariantType LHS; + OperandVariantType RHS; +}; + +} // namespace vara::feature + +#endif // VARA_FEATURE_STEPFUNCTION_H diff --git a/include/vara/Feature/StepFunctionParser.h b/include/vara/Feature/StepFunctionParser.h new file mode 100644 index 000000000..0203fffe6 --- /dev/null +++ b/include/vara/Feature/StepFunctionParser.h @@ -0,0 +1,322 @@ +#ifndef VARA_FEATURE_STEPFUNCTIONPARSER_H +#define VARA_FEATURE_STEPFUNCTIONPARSER_H + +#include "vara/Feature/StepFunction.h" + +#include + +#include + +namespace vara::feature { + +//===----------------------------------------------------------------------===// +// StepFunctionToken Class +//===----------------------------------------------------------------------===// + +class StepFunctionToken { +public: + enum class TokenKind { + IDENTIFIER, + NUMBER, + WHITESPACE, + PLUS, + STAR, + CARET, + END_OF_FILE, + ERROR + }; + + StepFunctionToken(TokenKind Kind) : Kind(Kind) {} + StepFunctionToken(TokenKind Kind, const std::string &Value) + : Kind(Kind), Value(Value) {} + virtual ~StepFunctionToken() = default; + + [[nodiscard]] TokenKind getKind() const { return Kind; }; + + [[nodiscard]] llvm::Optional getValue() const { + return Value; + } + +private: + const TokenKind Kind; + const llvm::Optional Value{llvm::None}; +}; + +//===----------------------------------------------------------------------===// +// StepFunctionLexer Class +//===----------------------------------------------------------------------===// + +class StepFunctionLexer { +public: + using TokenListTy = std::deque; + + explicit StepFunctionLexer(std::string Cnt) : Cnt(std::move(Cnt)) {} + + [[nodiscard]] TokenListTy tokenize() { + TokenListTy TokenList; + + for (llvm::StringRef Str = Cnt; !Str.empty();) { + auto Result = munch(Str); + TokenList.push_back(Result.first); + if (auto Kind = Result.first.getKind(); + Kind == StepFunctionToken::TokenKind::END_OF_FILE || + Kind == StepFunctionToken::TokenKind::ERROR) { + break; + } + Str = Str.drop_front(Result.second); + } + + // ensure last token is always either EOF or an error + if (auto Kind = TokenList.back().getKind(); + Kind != StepFunctionToken::TokenKind::END_OF_FILE && + Kind != StepFunctionToken::TokenKind::ERROR) { + TokenList.push_back( + StepFunctionToken(StepFunctionToken::TokenKind::END_OF_FILE)); + } + + return TokenList; + } + +private: + using ResultTy = std::pair; + + static ResultTy munch(const llvm::StringRef Str) { + if (('a' <= Str.front() && Str.front() <= 'z') || + ('A' <= Str.front() && Str.front() <= 'Z')) { + return munchIdentifier(Str); + } + if (('0' <= Str.front() && Str.front() <= '9') || Str.front() == '.') { + return munchNumber(Str); + } + + switch (Str.front()) { + case EOF: + case '\0': + return {StepFunctionToken(StepFunctionToken::TokenKind::END_OF_FILE), 1}; + case ' ': + case '\t': + case '\r': + case '\n': + return munchWhitespace(Str); + case '+': + return {StepFunctionToken(StepFunctionToken::TokenKind::PLUS), 1}; + case '*': + return {StepFunctionToken(StepFunctionToken::TokenKind::STAR), 1}; + case '^': + return {StepFunctionToken(StepFunctionToken::TokenKind::CARET), 1}; + default: + return {StepFunctionToken(StepFunctionToken::TokenKind::ERROR, + Str.take_front().str()), + 1}; + } + } + + static ResultTy munchWhitespace(const llvm::StringRef &Str) { + auto Munch = Str.take_while( + [](auto C) { return C == ' ' || C == '\t' || C == '\r' || C == '\n'; }); + return {StepFunctionToken(StepFunctionToken::TokenKind::WHITESPACE), + Munch.size()}; + } + + static ResultTy munchNumber(const llvm::StringRef &Str) { + auto Munch = + Str.take_while([](auto C) { return llvm::isDigit(C) || C == '.'; }); + return { + StepFunctionToken(StepFunctionToken::TokenKind::NUMBER, Munch.lower()), + Munch.size()}; + } + + static ResultTy munchIdentifier(const llvm::StringRef &Str) { + auto Munch = + Str.take_while([](auto C) { return llvm::isAlnum(C) || C == '_'; }); + return {StepFunctionToken(StepFunctionToken::TokenKind::IDENTIFIER, + Munch.str()), + Munch.size()}; + } + + std::string Cnt; +}; + +//===----------------------------------------------------------------------===// +// StepFunctionParser Class +//===----------------------------------------------------------------------===// + +class StepFunctionParser { +public: + explicit StepFunctionParser(std::string Cnt, + llvm::Optional Line = llvm::None) + : TokenList(StepFunctionLexer(std::move(Cnt)).tokenize()), Line(Line) {} + + [[nodiscard]] std::unique_ptr buildStepFunction() { + return parseStepFunction(); + } + +private: + [[nodiscard]] const StepFunctionToken &peek() const { + return TokenList.front(); + } + + [[nodiscard]] StepFunctionToken next() { + auto Token = TokenList.front(); + TokenList.pop_front(); + return Token; + } + + bool consume(const StepFunctionToken::TokenKind Kind) { + if (TokenList.front().getKind() == Kind) { + TokenList.pop_front(); + return true; + } + return false; + } + + llvm::Optional parseOperand() { + while (!TokenList.empty()) { + switch (peek().getKind()) { + case StepFunctionToken::TokenKind::ERROR: + assert(peek().getValue().hasValue()); + llvm::errs() << "Lexical error: Unexpected character '" + << *peek().getValue() << "'\n"; + return llvm::None; + case StepFunctionToken::TokenKind::END_OF_FILE: + llvm::errs() << "Syntax error: Unexpected end of expression.\n"; + return llvm::None; + case StepFunctionToken::TokenKind::WHITESPACE: + consume(StepFunctionToken::TokenKind::WHITESPACE); + continue; + case StepFunctionToken::TokenKind::PLUS: + llvm::errs() << "Lexical error: Unexpected operator '+'.\n"; + return llvm::None; + case StepFunctionToken::TokenKind::STAR: + llvm::errs() << "Lexical error: Unexpected operator '*'.\n"; + return llvm::None; + case StepFunctionToken::TokenKind::CARET: + llvm::errs() << "Lexical error: Unexpected operator '^'.\n"; + return llvm::None; + case StepFunctionToken::TokenKind::IDENTIFIER: + assert(peek().getValue().hasValue()); + return {*next().getValue()}; + case StepFunctionToken::TokenKind::NUMBER: + assert(peek().getValue().hasValue()); + double Number; + llvm::StringRef(*next().getValue()).getAsDouble(Number); + return {Number}; + } + } + return llvm::None; + } + + llvm::Optional parseOperator() { + while (!TokenList.empty()) { + switch (peek().getKind()) { + case StepFunctionToken::TokenKind::ERROR: + assert(peek().getValue().hasValue()); + llvm::errs() << "Lexical error: Unexpected character '" + << *peek().getValue() << "'\n"; + return llvm::None; + case StepFunctionToken::TokenKind::END_OF_FILE: + llvm::errs() << "Syntax error: Unexpected end of expression.\n"; + return llvm::None; + case StepFunctionToken::TokenKind::WHITESPACE: + consume(StepFunctionToken::TokenKind::WHITESPACE); + continue; + case StepFunctionToken::TokenKind::PLUS: + consume(StepFunctionToken::TokenKind::PLUS); + return StepFunction::StepOperation::ADDITION; + case StepFunctionToken::TokenKind::STAR: + consume(StepFunctionToken::TokenKind::STAR); + return StepFunction::StepOperation::MULTIPLICATION; + case StepFunctionToken::TokenKind::CARET: + consume(StepFunctionToken::TokenKind::CARET); + return StepFunction::StepOperation::EXPONENTIATION; + case StepFunctionToken::TokenKind::IDENTIFIER: + assert(peek().getValue().hasValue()); + llvm::errs() << "Syntax error: Unexpected identifier '" + << *peek().getValue() << "'\n"; + return llvm::None; + case StepFunctionToken::TokenKind::NUMBER: + assert(peek().getValue().hasValue()); + llvm::errs() << "Syntax error: Unexpected number '" + << *peek().getValue() << "'\n"; + return llvm::None; + } + } + return llvm::None; + } + + bool parseEOF() { + while (!TokenList.empty()) { + switch (peek().getKind()) { + case StepFunctionToken::TokenKind::ERROR: + assert(peek().getValue().hasValue()); + llvm::errs() << "Lexical error: Unexpected character '" + << *peek().getValue() << "'\n"; + return false; + case StepFunctionToken::TokenKind::END_OF_FILE: + return true; + case StepFunctionToken::TokenKind::WHITESPACE: + consume(StepFunctionToken::TokenKind::WHITESPACE); + continue; + case StepFunctionToken::TokenKind::PLUS: + llvm::errs() << "Lexical error: Unexpected operator '+'.\n"; + return false; + case StepFunctionToken::TokenKind::STAR: + llvm::errs() << "Lexical error: Unexpected operator '*'.\n"; + return false; + case StepFunctionToken::TokenKind::CARET: + llvm::errs() << "Lexical error: Unexpected operator '^'.\n"; + return false; + case StepFunctionToken::TokenKind::IDENTIFIER: + assert(peek().getValue().hasValue()); + llvm::errs() << "Syntax error: Unexpected identifier '" + << *peek().getValue() << "'\n"; + return false; + case StepFunctionToken::TokenKind::NUMBER: + assert(peek().getValue().hasValue()); + llvm::errs() << "Syntax error: Unexpected number '" + << *peek().getValue() << "'\n"; + return false; + } + } + return false; + } + + std::unique_ptr parseStepFunction() { + auto LHS = parseOperand(); + if (!LHS.hasValue()) { + return nullptr; + } + auto Op = parseOperator(); + if (!Op.hasValue()) { + return nullptr; + } + auto RHS = parseOperand(); + if (!RHS.hasValue()) { + return nullptr; + } + if (!parseEOF()) { + return nullptr; + } + + if (std::holds_alternative(LHS.getValue()) && + std::holds_alternative(RHS.getValue())) { + llvm::errs() << "Syntax error: Missing constant.\n"; + return nullptr; + } + if (std::holds_alternative(LHS.getValue()) && + std::holds_alternative(RHS.getValue())) { + llvm::errs() << "Syntax error: Missing operand.\n"; + return nullptr; + } + + return std::make_unique(LHS.getValue(), Op.getValue(), + RHS.getValue()); + } + + StepFunctionLexer::TokenListTy TokenList; + llvm::Optional Line; +}; + +} // namespace vara::feature + +#endif // VARA_FEATURE_STEPFUNCTIONPARSER_H diff --git a/lib/Feature/FeatureModelParser.cpp b/lib/Feature/FeatureModelParser.cpp index db9af81df..ddeac462c 100644 --- a/lib/Feature/FeatureModelParser.cpp +++ b/lib/Feature/FeatureModelParser.cpp @@ -2,6 +2,7 @@ #include "vara/Feature/ConstraintParser.h" #include "vara/Feature/Feature.h" #include "vara/Feature/FeatureSourceRange.h" +#include "vara/Feature/StepFunctionParser.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Support/FormatVariadic.h" @@ -31,6 +32,7 @@ FeatureModelXmlParser::parseConfigurationOption(xmlNode *Node, int64_t MaxValue = 0; std::vector Values; std::vector SourceRanges; + std::unique_ptr Step; for (xmlNode *Head = Node->children; Head; Head = Head->next) { if (Head->type == XML_ELEMENT_NODE) { std::string Cnt{trim(reinterpret_cast( @@ -119,6 +121,8 @@ FeatureModelXmlParser::parseConfigurationOption(xmlNode *Node, Suffix = Matches.suffix()) { Values.emplace_back(parseInteger(Matches.str(), Head->line)); } + } else if (!xmlStrcmp(Head->name, XmlConstants::STEPFUNCTION)) { + Step = StepFunctionParser(Cnt, Head->line).buildStepFunction(); } } } @@ -131,10 +135,11 @@ FeatureModelXmlParser::parseConfigurationOption(xmlNode *Node, if (Values.empty()) { FMB.makeFeature(Name, std::make_pair(MinValue, MaxValue), Opt, std::move(SourceRanges), - OutputString); + OutputString, std::move(Step)); } else { FMB.makeFeature(Name, Values, Opt, - std::move(SourceRanges), OutputString); + std::move(SourceRanges), OutputString, + std::move(Step)); } } else { FMB.makeFeature(Name, Opt, std::move(SourceRanges), diff --git a/unittests/Feature/CMakeLists.txt b/unittests/Feature/CMakeLists.txt index 71327a2f8..aae810366 100644 --- a/unittests/Feature/CMakeLists.txt +++ b/unittests/Feature/CMakeLists.txt @@ -14,4 +14,6 @@ add_vara_unittest(VaRAFeatureUnitTests VaRAFeatureTests OrderedFeatureVector.cpp Relationship.cpp RootFeature.cpp + StepFunction.cpp + StepFunctionParser.cpp ) diff --git a/unittests/Feature/FeatureModelParser.cpp b/unittests/Feature/FeatureModelParser.cpp index be6647139..3a85129e1 100644 --- a/unittests/Feature/FeatureModelParser.cpp +++ b/unittests/Feature/FeatureModelParser.cpp @@ -127,6 +127,20 @@ TEST(FeatureModelParser, outputString) { EXPECT_EQ(F->getOutputString(), "-a"); } +TEST(FeatureModelParser, stepFunction) { + auto FM = buildFeatureModel("test_step_function.xml"); + ASSERT_TRUE(FM); + + if (auto *F = llvm::dyn_cast_or_null(FM->getFeature("A")); + F) { + auto *S = F->getStepFunction(); + ASSERT_TRUE(S); + EXPECT_DOUBLE_EQ((*S)(12.42), 54.42); + } else { + FAIL(); + } +} + //===----------------------------------------------------------------------===// // XMLAlternatives //===----------------------------------------------------------------------===// diff --git a/unittests/Feature/StepFunction.cpp b/unittests/Feature/StepFunction.cpp new file mode 100644 index 000000000..81cd5f84d --- /dev/null +++ b/unittests/Feature/StepFunction.cpp @@ -0,0 +1,84 @@ +#include "vara/Feature/StepFunction.h" + +#include "gtest/gtest.h" + +namespace vara::feature { + +template +class StepFunctionTest : public ::testing::Test { +protected: + static void checkEqual(T V1, T V2) { EXPECT_EQ(V1, V2); } + + static void checkStepFunction(T Start, StepFunction *S, + const std::function &F) { + T Next = Start; + T Expected = Start; + for (int Step = 0; Step < STEPS; ++Step) { + Next = S->next(Next); + Expected = F(Expected); + checkEqual(Next, Expected); + } + } + +private: + static const int STEPS = 10; +}; +template <> +void StepFunctionTest::checkEqual(float V1, float V2) { + EXPECT_FLOAT_EQ(V1, V2); +} +template <> +void StepFunctionTest::checkEqual(double V1, double V2) { + EXPECT_DOUBLE_EQ(V1, V2); +} + +using types = ::testing::Types; +TYPED_TEST_SUITE(StepFunctionTest, types, ); + +TYPED_TEST(StepFunctionTest, addition) { + auto S = StepFunction(StepFunction::StepOperation::ADDITION, 13.37); + TestFixture::checkStepFunction(-100, &S, + [](TypeParam X) { return X + 13.37; }); +} + +TYPED_TEST(StepFunctionTest, multiplication) { + auto S = StepFunction(StepFunction::StepOperation::MULTIPLICATION, -13.37); + TestFixture::checkStepFunction(1, &S, [](TypeParam X) { return X * -13.37; }); +} + +TYPED_TEST(StepFunctionTest, exponentiationL) { + auto S = StepFunction(StepFunction::StepOperation::EXPONENTIATION, 2); + TestFixture::checkStepFunction(1, &S, + [](TypeParam X) { return std::pow(X, 2); }); +} + +TYPED_TEST(StepFunctionTest, exponentiationR) { + auto S = StepFunction(2, StepFunction::StepOperation::EXPONENTIATION); + TestFixture::checkStepFunction(1, &S, + [](TypeParam X) { return std::pow(2, X); }); +} + +TEST(StepFunction, commutative) { + auto L = StepFunction(StepFunction::StepOperation::MULTIPLICATION, 13.37); + auto R = StepFunction(13.37, StepFunction::StepOperation::MULTIPLICATION); + + EXPECT_DOUBLE_EQ(L(42), R(42)); +} + +TEST(StepFunction, next) { + auto S = StepFunction(StepFunction::StepOperation::MULTIPLICATION, 13.37); + + EXPECT_DOUBLE_EQ(S.next(42), 561.54); + EXPECT_DOUBLE_EQ(S.next(42.), 561.54); + EXPECT_EQ(S.next(42.), 561); + EXPECT_EQ(S.next(42), 561); +} + +TEST(StepFunction, call) { + auto S = StepFunction(StepFunction::StepOperation::MULTIPLICATION, 13.37); + + EXPECT_DOUBLE_EQ(S(42.), 561.54); + EXPECT_DOUBLE_EQ(S(42), 561.54); +} + +} // namespace vara::feature diff --git a/unittests/Feature/StepFunctionParser.cpp b/unittests/Feature/StepFunctionParser.cpp new file mode 100644 index 000000000..37258071b --- /dev/null +++ b/unittests/Feature/StepFunctionParser.cpp @@ -0,0 +1,117 @@ +#include "vara/Feature/StepFunctionParser.h" + +#include "gtest/gtest.h" + +namespace vara::feature { + +TEST(StepFunctionLexer, error) { + StepFunctionLexer L("x# 42"); + + auto TokenList = L.tokenize(); + ASSERT_EQ(TokenList.size(), 2); + + EXPECT_EQ(TokenList[0].getKind(), StepFunctionToken::TokenKind::IDENTIFIER); + EXPECT_EQ(*TokenList[0].getValue(), "x"); + EXPECT_EQ(TokenList[1].getKind(), StepFunctionToken::TokenKind::ERROR); + EXPECT_EQ(*TokenList[1].getValue(), "#"); +} + +TEST(StepFunctionLexer, end) { + StepFunctionLexer L("x\0 42"); // NOLINT + + auto TokenList = L.tokenize(); + ASSERT_EQ(TokenList.size(), 2); + + EXPECT_EQ(TokenList[0].getKind(), StepFunctionToken::TokenKind::IDENTIFIER); + EXPECT_EQ(*TokenList[0].getValue(), "x"); + EXPECT_EQ(TokenList[1].getKind(), StepFunctionToken::TokenKind::END_OF_FILE); +} + +class StepFunctionLexerTest : public ::testing::Test { +protected: + static void checkPrimary(StepFunctionToken::TokenKind Kind, + const std::string &Repr) { + auto TokenList = StepFunctionLexer(Repr).tokenize(); + ASSERT_EQ(TokenList.size(), 2); + + EXPECT_EQ(TokenList[0].getKind(), Kind); + EXPECT_EQ(TokenList[1].getKind(), + StepFunctionToken::TokenKind::END_OF_FILE); + } + + static void checkBinary(StepFunctionToken::TokenKind Kind, + const std::string &Repr) { + auto TokenList = StepFunctionLexer("x" + Repr + "42").tokenize(); + ASSERT_EQ(TokenList.size(), 4); + + EXPECT_EQ(TokenList[0].getKind(), StepFunctionToken::TokenKind::IDENTIFIER); + EXPECT_EQ(*TokenList[0].getValue(), "x"); + EXPECT_EQ(TokenList[1].getKind(), Kind); + EXPECT_EQ(TokenList[2].getKind(), StepFunctionToken::TokenKind::NUMBER); + EXPECT_EQ(*TokenList[2].getValue(), "42"); + EXPECT_EQ(TokenList[3].getKind(), + StepFunctionToken::TokenKind::END_OF_FILE); + } +}; + +TEST_F(StepFunctionLexerTest, tokenize) { + checkPrimary(StepFunctionToken::TokenKind::IDENTIFIER, "x"); + checkPrimary(StepFunctionToken::TokenKind::NUMBER, "42"); + checkPrimary(StepFunctionToken::TokenKind::NUMBER, "0.5"); + checkPrimary(StepFunctionToken::TokenKind::NUMBER, ".5"); + checkPrimary(StepFunctionToken::TokenKind::WHITESPACE, " "); + checkPrimary(StepFunctionToken::TokenKind::WHITESPACE, "\n"); + checkPrimary(StepFunctionToken::TokenKind::WHITESPACE, "\r"); + checkPrimary(StepFunctionToken::TokenKind::WHITESPACE, "\t"); + checkBinary(StepFunctionToken::TokenKind::PLUS, "+"); + checkBinary(StepFunctionToken::TokenKind::STAR, "*"); + checkBinary(StepFunctionToken::TokenKind::CARET, "^"); +} + +TEST(StepFunctionParser, error) { + EXPECT_FALSE(StepFunctionParser("x 42").buildStepFunction()); + EXPECT_FALSE(StepFunctionParser("x#42").buildStepFunction()); + EXPECT_FALSE(StepFunctionParser("x +").buildStepFunction()); + EXPECT_FALSE(StepFunctionParser("+ x").buildStepFunction()); + EXPECT_FALSE(StepFunctionParser("x").buildStepFunction()); + EXPECT_FALSE(StepFunctionParser("1 2").buildStepFunction()); + EXPECT_FALSE(StepFunctionParser("x + 1 + 2").buildStepFunction()); + EXPECT_FALSE(StepFunctionParser("x + 1 * 2").buildStepFunction()); + EXPECT_FALSE(StepFunctionParser("x + 1 ^ 2").buildStepFunction()); + EXPECT_FALSE(StepFunctionParser("x + y").buildStepFunction()); + EXPECT_FALSE(StepFunctionParser("1 + 2").buildStepFunction()); + EXPECT_FALSE(StepFunctionParser("1 2 +").buildStepFunction()); +} + +class StepFunctionParserTest : public ::testing::Test { +protected: + static void checkStepFunction(double Current, double Next, + const std::string &Repr) { + auto L = StepFunctionParser(Repr).buildStepFunction(); + ASSERT_TRUE(L); + + EXPECT_DOUBLE_EQ((*L)(Current), Next); + } + + static void checkStepFunction(double Current, double Next, + const std::string &Left, + const std::string &Right) { + checkStepFunction(Current, Next, Left); + checkStepFunction(Current, Next, Right); + } +}; + +TEST_F(StepFunctionParserTest, expressions) { + checkStepFunction(0, 0, "x+0", "0+x"); + checkStepFunction(-3, 2, "x+5", "5+x"); + checkStepFunction(42, 0, "x*0", "0*x"); + checkStepFunction(1.5, 3, "x*2", "2*x"); + checkStepFunction(3, 1.5, "x*.5", ".5*x"); + checkStepFunction(0, 1, "x^0", "0^x"); + checkStepFunction(3, 9, "x^2"); + checkStepFunction(3, 8, "2^x"); + checkStepFunction(9, 3, "x^.5"); + checkStepFunction(2, .25, ".5^x"); +} + +} // namespace vara::feature diff --git a/unittests/resources/CMakeLists.txt b/unittests/resources/CMakeLists.txt index 4c270e69d..7d82d36d9 100644 --- a/unittests/resources/CMakeLists.txt +++ b/unittests/resources/CMakeLists.txt @@ -27,6 +27,7 @@ set(FEATURE_LIB_TEST_FILES xml/test_only_parents.xml xml/test_out_of_order.xml xml/test_output_string.xml + xml/test_step_function.xml xml/test_with_whitespaces.xml ) diff --git a/unittests/resources/xml/test_step_function.xml b/unittests/resources/xml/test_step_function.xml new file mode 100644 index 000000000..144cb79be --- /dev/null +++ b/unittests/resources/xml/test_step_function.xml @@ -0,0 +1,16 @@ + + + + + + + + A + root + True + 0 + 100 + x + 42 + + + From 0e48b9cf66bbd2b906b71d398abb1824be9a664f Mon Sep 17 00:00:00 2001 From: Lauritz Timm Date: Mon, 19 Dec 2022 10:43:31 +0000 Subject: [PATCH 016/106] Adds Revision Range (#101) resolves se-sic/VaRA#965 --- include/vara/Feature/FeatureModelParser.h | 4 +- include/vara/Feature/FeatureSourceRange.h | 43 +++++++++++++++--- lib/Feature/FeatureModelParser.cpp | 34 +++++++++++--- lib/Feature/XmlConstants.h | 9 +++- unittests/Feature/CMakeLists.txt | 1 + unittests/Feature/FeatureModelParser.cpp | 19 ++++++++ unittests/Feature/FeatureRevisionRange.cpp | 25 +++++++++++ unittests/Feature/FeatureSourceRange.cpp | 12 ++++- unittests/resources/CMakeLists.txt | 1 + .../resources/xml/test_revision_range.xml | 44 +++++++++++++++++++ unittests/resources/xml/vm.dtd | 5 ++- 11 files changed, 183 insertions(+), 14 deletions(-) create mode 100644 unittests/Feature/FeatureRevisionRange.cpp create mode 100644 unittests/resources/xml/test_revision_range.xml diff --git a/include/vara/Feature/FeatureModelParser.h b/include/vara/Feature/FeatureModelParser.h index 030536787..2b4ec9dac 100644 --- a/include/vara/Feature/FeatureModelParser.h +++ b/include/vara/Feature/FeatureModelParser.h @@ -70,7 +70,9 @@ class FeatureModelXmlParser : public FeatureModelParser { static FeatureSourceRange::FeatureSourceLocation createFeatureSourceLocation(xmlNode *Node); - static FeatureSourceRange createFeatureSourceRange(xmlNode *Head); + static FeatureSourceRange::FeatureRevisionRange + createFeatureRevisionRange(xmlNode *Node); + static FeatureSourceRange createFeatureSourceRange(xmlNode *Node); static long parseNumber(llvm::StringRef Str); UniqueXmlDoc parseDoc(); diff --git a/include/vara/Feature/FeatureSourceRange.h b/include/vara/Feature/FeatureSourceRange.h index 04c6cddaf..4682f0d18 100644 --- a/include/vara/Feature/FeatureSourceRange.h +++ b/include/vara/Feature/FeatureSourceRange.h @@ -22,13 +22,35 @@ namespace fs = std::experimental::filesystem; namespace vara::feature { //===----------------------------------------------------------------------===// -// FeatureSourceRange Class +// FeatureSourceRange Class //===----------------------------------------------------------------------===// class FeatureSourceRange { public: enum class Category { necessary, inessential }; + class FeatureRevisionRange { + public: + FeatureRevisionRange(std::string Introduced, std::string Removed) + : Introduced(std::move(Introduced)), Removed(std::move(Removed)) {} + FeatureRevisionRange(std::string Introduced) + : Introduced(std::move(Introduced)) {} + + [[nodiscard]] llvm::StringRef introducingCommit() const { + return Introduced; + } + + [[nodiscard]] bool hasRemovingCommit() const { return Removed.hasValue(); } + [[nodiscard]] llvm::StringRef removingCommit() const { + return Removed.hasValue() ? llvm::StringRef(Removed.getValue()) + : llvm::StringRef(); + } + + private: + std::string Introduced; + llvm::Optional Removed; + }; + class FeatureSourceLocation { public: @@ -148,17 +170,20 @@ class FeatureSourceRange { fs::path Path, llvm::Optional Start = llvm::None, llvm::Optional End = llvm::None, Category CategoryKind = Category::necessary, - llvm::Optional MemberOffset = llvm::None) + llvm::Optional MemberOffset = llvm::None, + llvm::Optional RevisionRange = llvm::None) : Path(std::move(Path)), Start(std::move(Start)), End(std::move(End)), - CategoryKind(CategoryKind), MemberOffset(std::move(MemberOffset)) {} + CategoryKind(CategoryKind), MemberOffset(std::move(MemberOffset)), + RevisionRange(std::move(RevisionRange)) {} FeatureSourceRange( fs::path Path, FeatureSourceLocation Start, FeatureSourceLocation End, Category CategoryKind = Category::necessary, - llvm::Optional MemberOffset = llvm::None) + llvm::Optional MemberOffset = llvm::None, + llvm::Optional RevisionRange = llvm::None) : FeatureSourceRange(std::move(Path), llvm::Optional(std::move(Start)), llvm::Optional(std::move(End)), CategoryKind, - std::move(MemberOffset)) {} + std::move(MemberOffset), std::move(RevisionRange)) {} FeatureSourceRange(const FeatureSourceRange &L) = default; FeatureSourceRange &operator=(const FeatureSourceRange &) = default; @@ -190,6 +215,13 @@ class FeatureSourceRange { return MemberOffset.hasValue() ? MemberOffset.getPointer() : nullptr; } + [[nodiscard]] bool hasRevisionRange() const { + return RevisionRange.hasValue(); + } + [[nodiscard]] FeatureRevisionRange *revisionRange() { + return RevisionRange.hasValue() ? RevisionRange.getPointer() : nullptr; + } + [[nodiscard]] std::string toString() const { std::stringstream StrS; StrS << Path.string(); @@ -221,6 +253,7 @@ class FeatureSourceRange { llvm::Optional End; Category CategoryKind; llvm::Optional MemberOffset; + llvm::Optional RevisionRange; }; } // namespace vara::feature diff --git a/lib/Feature/FeatureModelParser.cpp b/lib/Feature/FeatureModelParser.cpp index ddeac462c..d70bb2989 100644 --- a/lib/Feature/FeatureModelParser.cpp +++ b/lib/Feature/FeatureModelParser.cpp @@ -149,15 +149,16 @@ FeatureModelXmlParser::parseConfigurationOption(xmlNode *Node, } FeatureSourceRange -FeatureModelXmlParser::createFeatureSourceRange(xmlNode *Head) { +FeatureModelXmlParser::createFeatureSourceRange(xmlNode *Node) { fs::path Path; llvm::Optional Start; llvm::Optional End; enum FeatureSourceRange::Category Category; llvm::Optional MemberOffset; + llvm::Optional RevisionRange; std::unique_ptr Tmp( - xmlGetProp(Head, XmlConstants::CATEGORY), xmlFree); + xmlGetProp(Node, XmlConstants::CATEGORY), xmlFree); if (Tmp) { if (xmlStrcmp(Tmp.get(), XmlConstants::NECESSARY) == 0) { Category = FeatureSourceRange::Category::necessary; @@ -170,9 +171,11 @@ FeatureModelXmlParser::createFeatureSourceRange(xmlNode *Head) { } else { Category = FeatureSourceRange::Category::necessary; } - for (xmlNode *Child = Head->children; Child; Child = Child->next) { + for (xmlNode *Child = Node->children; Child; Child = Child->next) { if (Child->type == XML_ELEMENT_NODE) { - if (!xmlStrcmp(Child->name, XmlConstants::PATH)) { + if (!xmlStrcmp(Child->name, XmlConstants::REVISIONRANGE)) { + RevisionRange = createFeatureRevisionRange(Child); + } else if (!xmlStrcmp(Child->name, XmlConstants::PATH)) { Path = fs::path(trim(reinterpret_cast( UniqueXmlChar(xmlNodeGetContent(Child), xmlFree).get()))); } else if (!xmlStrcmp(Child->name, XmlConstants::START)) { @@ -187,7 +190,7 @@ FeatureModelXmlParser::createFeatureSourceRange(xmlNode *Head) { } } } - return {Path, Start, End, Category, MemberOffset}; + return {Path, Start, End, Category, MemberOffset, RevisionRange}; } Result FeatureModelXmlParser::parseOptions(xmlNode *Node, @@ -259,6 +262,27 @@ Result FeatureModelXmlParser::parseVm(xmlNode *Node) { return Ok(); } +FeatureSourceRange::FeatureRevisionRange +FeatureModelXmlParser::createFeatureRevisionRange(xmlNode *Node) { + std::string Introduced; + std::string Removed; + for (xmlNode *Head = Node->children; Head; Head = Head->next) { + if (Head->type == XML_ELEMENT_NODE) { + std::string Cnt{trim(reinterpret_cast( + UniqueXmlChar(xmlNodeGetContent(Head), xmlFree).get()))}; + if (!xmlStrcmp(Head->name, XmlConstants::INTRODUCED)) { + Introduced = Cnt; + } else if (!xmlStrcmp(Head->name, XmlConstants::REMOVED)) { + Removed = Cnt; + } + } + } + if (Removed.empty()) { + return {Introduced}; + } + return {Introduced, Removed}; +} + FeatureSourceRange::FeatureSourceLocation FeatureModelXmlParser::createFeatureSourceLocation(xmlNode *Node) { unsigned Line = 0; diff --git a/lib/Feature/XmlConstants.h b/lib/Feature/XmlConstants.h index 31f05d2de..ccd0b35ab 100644 --- a/lib/Feature/XmlConstants.h +++ b/lib/Feature/XmlConstants.h @@ -26,6 +26,9 @@ class XmlConstants { static constexpr xmlChar OPTIONS[] = "options"; static constexpr xmlChar LOCATIONS[] = "locations"; static constexpr xmlChar SOURCERANGE[] = "sourceRange"; + static constexpr xmlChar REVISIONRANGE[] = "revisionRange"; + static constexpr xmlChar INTRODUCED[] = "introduced"; + static constexpr xmlChar REMOVED[] = "removed"; static constexpr xmlChar MEMBEROFFSET[] = "memberOffset"; static constexpr xmlChar PATH[] = "path"; static constexpr xmlChar START[] = "start"; @@ -82,8 +85,12 @@ class XmlConstants { "\n" "\n" "\n" - "\n" + "\n" "\n" + "\n" + "\n" + "\n" "\n" "\n" "\n" diff --git a/unittests/Feature/CMakeLists.txt b/unittests/Feature/CMakeLists.txt index aae810366..626dbedd5 100644 --- a/unittests/Feature/CMakeLists.txt +++ b/unittests/Feature/CMakeLists.txt @@ -8,6 +8,7 @@ add_vara_unittest(VaRAFeatureUnitTests VaRAFeatureTests FeatureModelParser.cpp FeatureModelSxfm.cpp FeatureModelWriter.cpp + FeatureRevisionRange.cpp FeatureSourceRange.cpp FeatureTreeNode.cpp NumericFeature.cpp diff --git a/unittests/Feature/FeatureModelParser.cpp b/unittests/Feature/FeatureModelParser.cpp index 3a85129e1..b1ae7f75a 100644 --- a/unittests/Feature/FeatureModelParser.cpp +++ b/unittests/Feature/FeatureModelParser.cpp @@ -119,6 +119,25 @@ TEST(FeatureModelParser, memberOffset) { } } +TEST(FeatureModelParser, revisionRange) { + auto FM = buildFeatureModel("test_revision_range.xml"); + ASSERT_TRUE(FM); + + auto *Feature = FM->getFeature("A"); + for (auto &Loc : Feature->getLocations()) { + ASSERT_TRUE(Loc.hasRevisionRange()); + if (Loc.revisionRange()->hasRemovingCommit()) { + EXPECT_EQ(Loc.revisionRange()->introducingCommit(), + "94fe792df46e64f438720295742b3b72c407cab6"); + EXPECT_EQ(Loc.revisionRange()->removingCommit(), + "1ed40f72e772adaa3adfcc94b9f038e4f3382339"); + } else { + EXPECT_EQ(Loc.revisionRange()->introducingCommit(), + "a7fb445f986adb2c2972df337ea46930cfc3dbf2"); + } + } +} + TEST(FeatureModelParser, outputString) { auto FM = buildFeatureModel("test_output_string.xml"); ASSERT_TRUE(FM); diff --git a/unittests/Feature/FeatureRevisionRange.cpp b/unittests/Feature/FeatureRevisionRange.cpp new file mode 100644 index 000000000..93795639f --- /dev/null +++ b/unittests/Feature/FeatureRevisionRange.cpp @@ -0,0 +1,25 @@ +#include "vara/Feature/FeatureSourceRange.h" + +#include "gtest/gtest.h" + +namespace vara::feature { + +TEST(FeatureRevisionRange, full) { + auto R = FeatureSourceRange::FeatureRevisionRange( + "94fe792df46e64f438720295742b3b72c407cab6", + "1ed40f72e772adaa3adfcc94b9f038e4f3382339"); + + EXPECT_EQ(R.introducingCommit(), "94fe792df46e64f438720295742b3b72c407cab6"); + ASSERT_TRUE(R.hasRemovingCommit()); + EXPECT_EQ(R.removingCommit(), "1ed40f72e772adaa3adfcc94b9f038e4f3382339"); +} + +TEST(FeatureRevisionRange, introduced) { + auto R = FeatureSourceRange::FeatureRevisionRange( + "94fe792df46e64f438720295742b3b72c407cab6"); + + EXPECT_EQ(R.introducingCommit(), "94fe792df46e64f438720295742b3b72c407cab6"); + EXPECT_FALSE(R.hasRemovingCommit()); +} + +} // namespace vara::feature diff --git a/unittests/Feature/FeatureSourceRange.cpp b/unittests/Feature/FeatureSourceRange.cpp index a9653f703..396965257 100644 --- a/unittests/Feature/FeatureSourceRange.cpp +++ b/unittests/Feature/FeatureSourceRange.cpp @@ -18,7 +18,10 @@ TEST(FeatureSourceRange, full) { FeatureSourceRange::Category::inessential, FeatureSourceRange::FeatureMemberOffset::createFeatureMemberOffset( "class::memberOffset") - .getValue()); + .getValue(), + FeatureSourceRange::FeatureRevisionRange( + "94fe792df46e64f438720295742b3b72c407cab6", + "1ed40f72e772adaa3adfcc94b9f038e4f3382339")); EXPECT_EQ(L.getPath(), fs::current_path()); EXPECT_EQ(L.getStart()->getLineNumber(), 1); @@ -26,7 +29,14 @@ TEST(FeatureSourceRange, full) { EXPECT_EQ(L.getEnd()->getLineNumber(), 3); EXPECT_EQ(L.getEnd()->getColumnOffset(), 5); EXPECT_EQ(L.getCategory(), FeatureSourceRange::Category::inessential); + ASSERT_TRUE(L.hasMemberOffset()); EXPECT_EQ(L.getMemberOffset()->toString(), "class::memberOffset"); + ASSERT_TRUE(L.hasRevisionRange()); + EXPECT_EQ(L.revisionRange()->introducingCommit(), + "94fe792df46e64f438720295742b3b72c407cab6"); + ASSERT_TRUE(L.revisionRange()->hasRemovingCommit()); + EXPECT_EQ(L.revisionRange()->removingCommit(), + "1ed40f72e772adaa3adfcc94b9f038e4f3382339"); } TEST(FeatureSourceRange, noMemberOffset) { diff --git a/unittests/resources/CMakeLists.txt b/unittests/resources/CMakeLists.txt index 7d82d36d9..377a71678 100644 --- a/unittests/resources/CMakeLists.txt +++ b/unittests/resources/CMakeLists.txt @@ -27,6 +27,7 @@ set(FEATURE_LIB_TEST_FILES xml/test_only_parents.xml xml/test_out_of_order.xml xml/test_output_string.xml + xml/test_revision_range.xml xml/test_step_function.xml xml/test_with_whitespaces.xml ) diff --git a/unittests/resources/xml/test_revision_range.xml b/unittests/resources/xml/test_revision_range.xml new file mode 100644 index 000000000..d8c5717cb --- /dev/null +++ b/unittests/resources/xml/test_revision_range.xml @@ -0,0 +1,44 @@ + + + + + + A + root + True + + + + 94fe792df46e64f438720295742b3b72c407cab6 + 1ed40f72e772adaa3adfcc94b9f038e4f3382339 + + main.c + + 6 + 3 + + + 6 + 26 + + + + + a7fb445f986adb2c2972df337ea46930cfc3dbf2 + + main.c + + 6 + 3 + + + 6 + 26 + + + + + + + + diff --git a/unittests/resources/xml/vm.dtd b/unittests/resources/xml/vm.dtd index 0a308c47e..6e40350cd 100644 --- a/unittests/resources/xml/vm.dtd +++ b/unittests/resources/xml/vm.dtd @@ -26,8 +26,11 @@ - + + + + From 72cc0b9983609693a2ee0d07346731ff6c4ec36c Mon Sep 17 00:00:00 2001 From: Florian Sattler Date: Mon, 19 Dec 2022 21:45:30 +0100 Subject: [PATCH 017/106] Bugfix in `FeatureModelBuilder::makeRoot` (#104) resolves se-sic/VaRA#973 Co-authored-by: Lauritz Timm --- include/vara/Feature/FeatureModelBuilder.h | 2 +- .../vara/Feature/FeatureModelTransaction.h | 32 ++++++++++++------- unittests/Feature/FeatureModelBuilder.cpp | 27 ++++++++++++++++ 3 files changed, 48 insertions(+), 13 deletions(-) diff --git a/include/vara/Feature/FeatureModelBuilder.h b/include/vara/Feature/FeatureModelBuilder.h index d44efe331..e966eab62 100644 --- a/include/vara/Feature/FeatureModelBuilder.h +++ b/include/vara/Feature/FeatureModelBuilder.h @@ -92,7 +92,7 @@ class FeatureModelBuilder { } FeatureModelBuilder *makeRoot(const std::string &Name) { - ModelBuilder.setRoot(std::make_unique(Name)); + FeatureBuilder.setRoot(std::make_unique(Name)); return this; } diff --git a/include/vara/Feature/FeatureModelTransaction.h b/include/vara/Feature/FeatureModelTransaction.h index a1fd0f8e4..57f8b64ed 100644 --- a/include/vara/Feature/FeatureModelTransaction.h +++ b/include/vara/Feature/FeatureModelTransaction.h @@ -704,26 +704,34 @@ class SetRoot : public FeatureModelModification { if (FM.getRoot() && FM.getRoot()->getName() == Root->getName()) { for (auto *C : Root->children()) { setParent(*C, *FM.getRoot()); - removeEdge(*Root, *C); addEdge(*FM.getRoot(), *C); } + for (auto *C : FM.getRoot()->children()) { + if (Root->hasEdgeTo(*C)) { + removeEdge(*Root, *C); + } + } return FM.getRoot(); } - if (auto *NewRoot = llvm::dyn_cast_or_null( - addFeature(FM, std::move(Root))); - NewRoot) { - if (FM.getRoot()) { - for (auto *C : FM.getRoot()->children()) { - setParent(*C, *NewRoot); + auto *InsertedRoot = + llvm::dyn_cast_or_null(addFeature(FM, std::move(Root))); + if (!InsertedRoot) { + return ALREADY_PRESENT; + } + if (FM.getRoot()) { + for (auto *C : FM.getRoot()->children()) { + setParent(*C, *InsertedRoot); + addEdge(*InsertedRoot, *C); + } + for (auto *C : InsertedRoot->children()) { + if (FM.getRoot()->hasEdgeTo(*C)) { removeEdge(*FM.getRoot(), *C); - addEdge(*NewRoot, *C); } - removeFeature(FM, *FM.getRoot()); } - setRoot(FM, *NewRoot); - return FM.getRoot(); + removeFeature(FM, *FM.getRoot()); } - return ALREADY_PRESENT; + setRoot(FM, *InsertedRoot); + return FM.getRoot(); } private: diff --git a/unittests/Feature/FeatureModelBuilder.cpp b/unittests/Feature/FeatureModelBuilder.cpp index 44a46594d..7c7a648a9 100644 --- a/unittests/Feature/FeatureModelBuilder.cpp +++ b/unittests/Feature/FeatureModelBuilder.cpp @@ -114,6 +114,33 @@ TEST(FeatureModelBuilder, addBinaryFeatureRef) { EXPECT_TRUE(FM->getFeature("a")->hasEdgeTo(*FM->getFeature("aa"))); } +TEST(FeatureModelBuilder, addMultipleFeaturesWithEdges) { + FeatureModelBuilder B; + + B.makeRoot("newRoot"); + B.makeFeature("a", true); + B.makeFeature("b", true); + B.makeFeature("c", true); + + B.addEdge("newRoot", "a"); + B.addEdge("newRoot", "b"); + B.addEdge("newRoot", "c"); + + auto FM = B.buildFeatureModel(); + ASSERT_TRUE(FM); + + EXPECT_TRUE(FM->getFeature("a") != nullptr); + EXPECT_TRUE(FM->getFeature("b") != nullptr); + EXPECT_TRUE(FM->getFeature("c") != nullptr); + + EXPECT_TRUE(FM->getRoot() != nullptr); + EXPECT_EQ(FM->getRoot(), FM->getFeature("newRoot")); + + EXPECT_TRUE(FM->getRoot()->hasEdgeTo(*FM->getFeature("a"))); + EXPECT_TRUE(FM->getRoot()->hasEdgeTo(*FM->getFeature("b"))); + EXPECT_TRUE(FM->getRoot()->hasEdgeTo(*FM->getFeature("c"))); +} + TEST(FeatureModelBuilder, addNumericFeatureRef) { FeatureModelBuilder B; From 5568161b7345003a47c26c1c8e0fe32cb1c64ee8 Mon Sep 17 00:00:00 2001 From: Simon Friedel Date: Tue, 7 Feb 2023 12:22:34 +0100 Subject: [PATCH 018/106] Display outputstring of feature in treeview --- tools/fm-editor/tree/FeatureTreeItem.cpp | 2 +- tools/fm-editor/tree/FeatureTreeItem.h | 3 ++- tools/fm-editor/tree/FeatureTreeViewModel.cpp | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/fm-editor/tree/FeatureTreeItem.cpp b/tools/fm-editor/tree/FeatureTreeItem.cpp index 764a42ccd..956db4c19 100644 --- a/tools/fm-editor/tree/FeatureTreeItem.cpp +++ b/tools/fm-editor/tree/FeatureTreeItem.cpp @@ -61,7 +61,7 @@ QVariant FeatureTreeItemFeature::data(int Column) const { case 2: return numericValue(Item); case 3: return locationString(Item); case 4: return crossTreeConstraintString(Item); - case 5: return Item. + case 5: return QString::fromStdString(Item->getOutputString().str()); default: return {}; } diff --git a/tools/fm-editor/tree/FeatureTreeItem.h b/tools/fm-editor/tree/FeatureTreeItem.h index e099e5e3a..adcdb9003 100644 --- a/tools/fm-editor/tree/FeatureTreeItem.h +++ b/tools/fm-editor/tree/FeatureTreeItem.h @@ -64,7 +64,7 @@ class FeatureTreeItemFeature: public FeatureTreeItem { virtual ~FeatureTreeItemFeature() = default; FeatureTreeItemFeature(vara::feature::Feature* Item,FeatureTreeItem* Parent): FeatureTreeItem(Item,Parent), Item(Item) {} [[nodiscard]] QVariant data(int Column) const override; - [[nodiscard]] int columnCount() const override {return 5;} + [[nodiscard]] int columnCount() const override {return 6;} bool booleanColumn(int Column) {return Column==1;} private: vara::feature::Feature* Item; @@ -79,6 +79,7 @@ FeatureTreeItemRelation(vara::feature::Relationship* Item,FeatureTreeItem* Paren if(Column==0) { return QString::fromStdString(relationType()); } +return {}; } [[nodiscard]] int columnCount() const override {return 1;} private: diff --git a/tools/fm-editor/tree/FeatureTreeViewModel.cpp b/tools/fm-editor/tree/FeatureTreeViewModel.cpp index 1964239cd..1d946e192 100644 --- a/tools/fm-editor/tree/FeatureTreeViewModel.cpp +++ b/tools/fm-editor/tree/FeatureTreeViewModel.cpp @@ -73,6 +73,7 @@ QVariant FeatureTreeViewModel::headerData(int Section, case 2:return QString("NumericValues"); case 3:return QString("Locations"); case 4:return QString("Constraints"); + case 5:return QString("ConfigurationOption"); default:return QString("Todo"); } } From f89ad52c3c0d5b7f146573f2f4556f19d3fb2979 Mon Sep 17 00:00:00 2001 From: Nerum Date: Tue, 7 Feb 2023 07:43:44 +0100 Subject: [PATCH 019/106] Extend Feature AddDialog to provide choice of feature type --- tools/fm-editor/FeatureAddDialog.cpp | 14 +++++- tools/fm-editor/FeatureAddDialog.h | 4 +- tools/fm-editor/FeatureAddDialog.ui | 65 ++++++++++++++++++++++------ 3 files changed, 68 insertions(+), 15 deletions(-) diff --git a/tools/fm-editor/FeatureAddDialog.cpp b/tools/fm-editor/FeatureAddDialog.cpp index 2c1d50ffa..9eb356638 100644 --- a/tools/fm-editor/FeatureAddDialog.cpp +++ b/tools/fm-editor/FeatureAddDialog.cpp @@ -7,7 +7,7 @@ #include "graph/FeatureNode.h" using vara::feature::FeatureModel; FeatureAddDialog::FeatureAddDialog(FeatureModelGraph *Graph, QWidget *Parent) - : QDialog(Parent), Graph(Graph){ + : QDialog(Parent){ setupUi(this); NodeNames = QStringList(); for(const auto &Node: *Graph->getNodes()){ @@ -15,6 +15,10 @@ FeatureAddDialog::FeatureAddDialog(FeatureModelGraph *Graph, QWidget *Parent) } const auto ConstNodeNames = NodeNames; this->Nodes->addItems(ConstNodeNames); + this->FeatureKind->addItems(QStringList{"Binary","Numeric","Root","Unknown"}); + NumericFeature->setVisible(false); + connect(FeatureKind,&QComboBox::activated, this, + &FeatureAddDialog::featureType); } QString FeatureAddDialog::getName() { @@ -24,3 +28,11 @@ QString FeatureAddDialog::getName() { std::string FeatureAddDialog::getParent(){ return Nodes->currentText().toStdString(); } + +void FeatureAddDialog::featureType(int index) { + if(index ==1) { + NumericFeature->setVisible(true); + }else{ + NumericFeature->setVisible(false); + } +} diff --git a/tools/fm-editor/FeatureAddDialog.h b/tools/fm-editor/FeatureAddDialog.h index 930ec3067..ac6350cd8 100644 --- a/tools/fm-editor/FeatureAddDialog.h +++ b/tools/fm-editor/FeatureAddDialog.h @@ -15,8 +15,10 @@ class FeatureAddDialog : public QDialog, public Ui::Add { FeatureAddDialog(FeatureModelGraph *Graph, QWidget *Parent); QString getName(); string getParent(); +public slots: + void featureType(int index); private: - FeatureModelGraph *Graph; + QStringList NodeNames; }; diff --git a/tools/fm-editor/FeatureAddDialog.ui b/tools/fm-editor/FeatureAddDialog.ui index 8d0592096..c5f1af5fc 100644 --- a/tools/fm-editor/FeatureAddDialog.ui +++ b/tools/fm-editor/FeatureAddDialog.ui @@ -7,27 +7,31 @@ 0 0 400 - 300 + 319 Dialog - - - - - - - + Name - + + + + Optional + + + + + + + Qt::Horizontal @@ -37,18 +41,53 @@ - + Parent - - + + - Optional + FeatureType + + + + + + + + + + + + + true + + + + + Min + + + + + + + + + + Max + + + + + + + From 59b30389807ba8cab5a9033ef8bb8c8d0ad3b49f Mon Sep 17 00:00:00 2001 From: Nerum Date: Tue, 7 Feb 2023 07:44:39 +0100 Subject: [PATCH 020/106] Add contextMenu to FeatureTreeItems --- tools/fm-editor/FeatureModelEditor.cpp | 33 +++++++++++++++++++----- tools/fm-editor/FeatureModelEditor.h | 1 + tools/fm-editor/tree/FeatureTreeItem.cpp | 12 +++++++++ tools/fm-editor/tree/FeatureTreeItem.h | 15 +++++++++-- 4 files changed, 53 insertions(+), 8 deletions(-) diff --git a/tools/fm-editor/FeatureModelEditor.cpp b/tools/fm-editor/FeatureModelEditor.cpp index 7e9821983..dbe7725f9 100644 --- a/tools/fm-editor/FeatureModelEditor.cpp +++ b/tools/fm-editor/FeatureModelEditor.cpp @@ -46,18 +46,22 @@ void FeatureModelEditor::loadGraph() { //Return if no model at Path return; } + //create Graph view Graph = new FeatureModelGraph{Model.get()}; - Ui->tabWidget->addTab(Graph,"GraphView"); - TreeView = new QTreeView(); - TreeView->setModel(new FeatureTreeViewModel(Model.get(),TreeView)); - Ui->tabWidget->addTab(TreeView,"TreeView"); for (auto &Node : *Graph->getNodes()) { QObject::connect(Node.get(), &FeatureNode::clicked, this, &FeatureModelEditor::loadFeature); QObject::connect(Node.get(), &FeatureNode::inspectSource, this, &FeatureModelEditor::inspectFeature); } + //create Tree View + TreeView = new QTreeView(); + TreeView->setModel(new FeatureTreeViewModel(Model.get(),TreeView)); + TreeView->setContextMenuPolicy(Qt::CustomContextMenu); + connect(TreeView, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onCustomContextMenu(const QPoint &))); + Ui->tabWidget->addTab(TreeView,"TreeView"); + } void FeatureModelEditor::featureAddDialog() { FeatureAddDialog AddDialog(Graph,this); @@ -80,13 +84,20 @@ void FeatureModelEditor::inspectFeature(vara::feature::Feature *Feature) { Repository = QFileDialog::getExistingDirectory(); } Ui->sources->clear(); + for(const auto& Source : Feature->getLocations()){ Ui->sources->addItem(QString::fromStdString(Source.getPath().string())); } - connect(Ui->sources,&QComboBox::textActivated, this,&FeatureModelEditor::loadSource); + connect(Ui->sources,&QComboBox::currentTextChanged, this,&FeatureModelEditor::loadSource); + if(Ui->sources->count() == 1){ + loadSource(Ui->sources->itemText(0)); + } else { + Ui->sources->setPlaceholderText("Select File"); + } } void FeatureModelEditor::loadSource(const QString &RelativePath){ - auto SourcePath = Repository.append("/").append(RelativePath); + Ui->textEdit->clear(); + auto SourcePath = Repository + "/" + RelativePath; std::cout << Repository.toStdString(); QFile File(SourcePath); if(File.exists()){ @@ -121,3 +132,13 @@ void FeatureModelEditor::loadSource(const QString &RelativePath){ } } +void FeatureModelEditor::onCustomContextMenu(const QPoint &Pos) { + auto Index = TreeView->indexAt(Pos); + if(Index.isValid()){ + FeatureTreeItem* Item = static_cast(Index.internalPointer()); + connect(Item, &FeatureTreeItem::inspectSource, this,&FeatureModelEditor::inspectFeature); + Item->contextMenu(TreeView->mapToGlobal(Pos)); + + } + +} diff --git a/tools/fm-editor/FeatureModelEditor.h b/tools/fm-editor/FeatureModelEditor.h index dd5ad45c0..c7b76fd22 100644 --- a/tools/fm-editor/FeatureModelEditor.h +++ b/tools/fm-editor/FeatureModelEditor.h @@ -38,6 +38,7 @@ public slots: //void addFeature(const QString& Name, FeatureNode *Parent); void loadSource(const QString &RelativePath); void findModel(); + void onCustomContextMenu(const QPoint &Pos); }; #endif // VARA_FEATURE_FEATUREMODELEDITOR_H diff --git a/tools/fm-editor/tree/FeatureTreeItem.cpp b/tools/fm-editor/tree/FeatureTreeItem.cpp index 956db4c19..4176ff225 100644 --- a/tools/fm-editor/tree/FeatureTreeItem.cpp +++ b/tools/fm-editor/tree/FeatureTreeItem.cpp @@ -2,6 +2,7 @@ // Created by simon on 02.02.23. // #include "FeatureTreeItem.h" +#include QVariant numericValue(vara::feature::Feature* Item) { if(Item->getKind()==vara::feature::Feature::FeatureKind::FK_NUMERIC){ auto *NumItem = dynamic_cast(Item); @@ -67,3 +68,14 @@ QVariant FeatureTreeItemFeature::data(int Column) const { } } +void FeatureTreeItemFeature::inspect() { + emit(inspectSource(Item)); +} +void FeatureTreeItemFeature::contextMenu(QPoint Pos) { + auto *Menu = new QMenu; + auto *Inspect = new QAction("Inspect Sources", this); + Menu->addAction(Inspect); + Menu->popup(Pos); + connect(Inspect, &QAction::triggered, + this, &FeatureTreeItemFeature::inspect); +} diff --git a/tools/fm-editor/tree/FeatureTreeItem.h b/tools/fm-editor/tree/FeatureTreeItem.h index adcdb9003..b17f720e0 100644 --- a/tools/fm-editor/tree/FeatureTreeItem.h +++ b/tools/fm-editor/tree/FeatureTreeItem.h @@ -6,9 +6,11 @@ #define VARA_FEATURE_FEATURETREEITEM_H #include "vara/Feature/Feature.h" #include "vara/Feature/Relationship.h" +#include #include #include -class FeatureTreeItem { +class FeatureTreeItem: public QObject { + Q_OBJECT public: virtual ~FeatureTreeItem() { std::destroy(Children.begin(), Children.end()); @@ -41,6 +43,9 @@ class FeatureTreeItem { FeatureTreeItem static *createFeatureTreeItem(vara::feature::Relationship* Item,FeatureTreeItem* Parent); FeatureTreeItem static *createFeatureTreeItem(vara::feature::Feature* Item,FeatureTreeItem* Parent); bool booleanColumn(int Column) {return false;} + virtual void contextMenu(QPoint Pos) = 0; +signals: + void inspectSource(vara::feature::Feature *Feature); protected: FeatureTreeItem(vara::feature::FeatureTreeNode* Item ,FeatureTreeItem* Parent): Parent(Parent) { for(auto *Child : Item->children()){ @@ -59,15 +64,20 @@ class FeatureTreeItem { }; -class FeatureTreeItemFeature: public FeatureTreeItem { +class FeatureTreeItemFeature: public FeatureTreeItem{ + Q_OBJECT public: virtual ~FeatureTreeItemFeature() = default; FeatureTreeItemFeature(vara::feature::Feature* Item,FeatureTreeItem* Parent): FeatureTreeItem(Item,Parent), Item(Item) {} [[nodiscard]] QVariant data(int Column) const override; [[nodiscard]] int columnCount() const override {return 6;} bool booleanColumn(int Column) {return Column==1;} + void contextMenu(QPoint Pos) override; +public slots: + void inspect() ; private: vara::feature::Feature* Item; + }; @@ -82,6 +92,7 @@ FeatureTreeItemRelation(vara::feature::Relationship* Item,FeatureTreeItem* Paren return {}; } [[nodiscard]] int columnCount() const override {return 1;} +void contextMenu(QPoint Pos) override{} private: vara::feature::Relationship* Item; [[nodiscard]] std::string relationType() const { From b69fba06eeff497092bffad4924840d88e82dc98 Mon Sep 17 00:00:00 2001 From: Nerum Date: Tue, 14 Feb 2023 17:45:57 +0100 Subject: [PATCH 021/106] Add Function to get type of added feature --- tools/fm-editor/FeatureAddDialog.cpp | 3 +++ tools/fm-editor/FeatureAddDialog.h | 1 + 2 files changed, 4 insertions(+) diff --git a/tools/fm-editor/FeatureAddDialog.cpp b/tools/fm-editor/FeatureAddDialog.cpp index 9eb356638..056b9c45b 100644 --- a/tools/fm-editor/FeatureAddDialog.cpp +++ b/tools/fm-editor/FeatureAddDialog.cpp @@ -36,3 +36,6 @@ void FeatureAddDialog::featureType(int index) { NumericFeature->setVisible(false); } } +vara::feature::Feature::FeatureKind FeatureAddDialog::getFeatureKind() { + return vara::feature::Feature::FeatureKind(FeatureKind->currentIndex()); +} diff --git a/tools/fm-editor/FeatureAddDialog.h b/tools/fm-editor/FeatureAddDialog.h index ac6350cd8..70974f1b0 100644 --- a/tools/fm-editor/FeatureAddDialog.h +++ b/tools/fm-editor/FeatureAddDialog.h @@ -15,6 +15,7 @@ class FeatureAddDialog : public QDialog, public Ui::Add { FeatureAddDialog(FeatureModelGraph *Graph, QWidget *Parent); QString getName(); string getParent(); + vara::feature::Feature::FeatureKind getFeatureKind(); public slots: void featureType(int index); private: From d350add4434949c9fc7f2a6db5c3357eff8af56f Mon Sep 17 00:00:00 2001 From: Nerum Date: Tue, 14 Feb 2023 17:46:32 +0100 Subject: [PATCH 022/106] Add the ability to add sources to features --- tools/fm-editor/FeatureModelEditor.cpp | 53 +++++++-- tools/fm-editor/FeatureModelEditor.h | 4 + tools/fm-editor/FeatureModelEditor.ui | 108 ++++++++++-------- tools/fm-editor/tree/FeatureTreeItem.cpp | 12 ++ tools/fm-editor/tree/FeatureTreeItem.h | 9 +- tools/fm-editor/tree/FeatureTreeViewModel.cpp | 3 + tools/fm-editor/tree/FeatureTreeViewModel.h | 5 +- 7 files changed, 132 insertions(+), 62 deletions(-) diff --git a/tools/fm-editor/FeatureModelEditor.cpp b/tools/fm-editor/FeatureModelEditor.cpp index dbe7725f9..a63c7eaff 100644 --- a/tools/fm-editor/FeatureModelEditor.cpp +++ b/tools/fm-editor/FeatureModelEditor.cpp @@ -21,6 +21,7 @@ FeatureModelEditor::FeatureModelEditor(QWidget *Parent) : QMainWindow(Parent), Ui(new Ui::FeatureModelEditor) { Ui->setupUi(this); + Ui->textEdit->setReadOnly(true); auto *Highliter = new QSourceHighlite::QSourceHighliter(Ui->textEdit->document()); Highliter->setCurrentLanguage(QSourceHighlite::QSourceHighliter::CodeCpp); QObject::connect(Ui->loadModel, &QPushButton::pressed, this, @@ -30,6 +31,8 @@ FeatureModelEditor::FeatureModelEditor(QWidget *Parent) QObject::connect(Ui->actionAddFeature,&QAction::triggered, this, &FeatureModelEditor::featureAddDialog); + connect(Ui->addSource,&QPushButton::pressed, this,&FeatureModelEditor::addSource); + connect(Ui->addSourceFile,&QPushButton::pressed, this,&FeatureModelEditor::addSourceFile); } void FeatureModelEditor::loadFeature(vara::feature::Feature *Feature) { auto FeatureString = @@ -57,11 +60,16 @@ void FeatureModelEditor::loadGraph() { } //create Tree View TreeView = new QTreeView(); - TreeView->setModel(new FeatureTreeViewModel(Model.get(),TreeView)); + TreeModel = new FeatureTreeViewModel(Model.get(),TreeView); + for(auto Item:TreeModel->getItems()){ + QObject::connect(Item, &FeatureTreeItem::inspectSource, this, + &FeatureModelEditor::inspectFeature); + } + TreeView->setModel(TreeModel); TreeView->setContextMenuPolicy(Qt::CustomContextMenu); connect(TreeView, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onCustomContextMenu(const QPoint &))); Ui->tabWidget->addTab(TreeView,"TreeView"); - + connect(Ui->sources,&QComboBox::currentTextChanged, this,&FeatureModelEditor::loadSource); } void FeatureModelEditor::featureAddDialog() { FeatureAddDialog AddDialog(Graph,this); @@ -84,28 +92,28 @@ void FeatureModelEditor::inspectFeature(vara::feature::Feature *Feature) { Repository = QFileDialog::getExistingDirectory(); } Ui->sources->clear(); - for(const auto& Source : Feature->getLocations()){ Ui->sources->addItem(QString::fromStdString(Source.getPath().string())); } - connect(Ui->sources,&QComboBox::currentTextChanged, this,&FeatureModelEditor::loadSource); if(Ui->sources->count() == 1){ loadSource(Ui->sources->itemText(0)); } else { Ui->sources->setPlaceholderText("Select File"); } } + + + void FeatureModelEditor::loadSource(const QString &RelativePath){ Ui->textEdit->clear(); auto SourcePath = Repository + "/" + RelativePath; - std::cout << Repository.toStdString(); QFile File(SourcePath); if(File.exists()){ File.open(QFile::ReadOnly | QFile::Text); QTextStream ReadFile(&File); Ui->textEdit->setText(ReadFile.readAll()); QTextCharFormat Fmt; - Fmt.setBackground(Qt::yellow); + Fmt.setBackground(Qt::darkYellow); QTextCursor Cursor(Ui->textEdit->document()); std::cout << CurrentFeature->toString(); std::vector Locations{}; @@ -126,7 +134,7 @@ void FeatureModelEditor::loadSource(const QString &RelativePath){ QTextCursor::MoveMode::KeepAnchor); Cursor.movePosition(QTextCursor::MoveOperation::NextCharacter, QTextCursor::MoveMode::KeepAnchor, - Location.getEnd()->getColumnOffset()-1); + Location.getEnd()->getColumnOffset()); Cursor.setCharFormat(Fmt); } } @@ -136,9 +144,38 @@ void FeatureModelEditor::onCustomContextMenu(const QPoint &Pos) { auto Index = TreeView->indexAt(Pos); if(Index.isValid()){ FeatureTreeItem* Item = static_cast(Index.internalPointer()); - connect(Item, &FeatureTreeItem::inspectSource, this,&FeatureModelEditor::inspectFeature); Item->contextMenu(TreeView->mapToGlobal(Pos)); + } +} +void FeatureModelEditor::addSourceFile(){ + if(!Repository.isEmpty()) { + QString const Path = QFileDialog::getOpenFileName( + this, tr("Select Source File"), Repository, + tr("C Files (*.c *c++ *.h)")); + Ui->sources->addItem(Path.sliced(Repository.length())); } +} +void FeatureModelEditor::addSource() { + auto TextEdit = Ui->textEdit; + auto Cursor = TextEdit->textCursor(); + int start = Cursor.selectionStart(); + int end = Cursor.selectionEnd(); + Cursor.movePosition(QTextCursor::MoveOperation::StartOfLine); + int lineStart = Cursor.position(); + int lines = 1; + auto Block = Cursor.block(); + while (Cursor.position() > Block.position()) { + Cursor.movePosition(QTextCursor::MoveOperation::Up); + lines++; + } + Block = Block.previous(); + while(Block.isValid()){ + lines+=Block.lineCount(); + Block = Block.previous(); + } + auto Range = vara::feature::FeatureSourceRange(Ui->sources->currentText().toStdString(),vara::feature::FeatureSourceRange::FeatureSourceLocation(lines,start-lineStart+1),vara::feature::FeatureSourceRange::FeatureSourceLocation(lines,end-lineStart)); + CurrentFeature->addLocation(Range); + loadSource(Ui->sources->currentText()); } diff --git a/tools/fm-editor/FeatureModelEditor.h b/tools/fm-editor/FeatureModelEditor.h index c7b76fd22..5a74eb69e 100644 --- a/tools/fm-editor/FeatureModelEditor.h +++ b/tools/fm-editor/FeatureModelEditor.h @@ -26,11 +26,13 @@ class FeatureModelEditor : public QMainWindow { Ui::FeatureModelEditor *Ui; FeatureModelGraph * Graph{}; QTreeView* TreeView; + FeatureTreeViewModel *TreeModel; std::unique_ptr Model {}; std::unique_ptr> Modification {}; QString Repository {}; vara::feature::Feature* CurrentFeature; public slots: + void addSource(); void loadFeature(vara::feature::Feature *Feature); void inspectFeature(vara::feature::Feature *Feature); void loadGraph(); @@ -39,6 +41,8 @@ public slots: void loadSource(const QString &RelativePath); void findModel(); void onCustomContextMenu(const QPoint &Pos); + void addSourceFile(); +private: }; #endif // VARA_FEATURE_FEATUREMODELEDITOR_H diff --git a/tools/fm-editor/FeatureModelEditor.ui b/tools/fm-editor/FeatureModelEditor.ui index dbcadcff4..83098150b 100644 --- a/tools/fm-editor/FeatureModelEditor.ui +++ b/tools/fm-editor/FeatureModelEditor.ui @@ -15,37 +15,43 @@ - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Preferred + + + + + 0 + 0 + - + - 40 - 20 + 500 + 0 - + + + + + AddSource + + + + + + + AddSourceFile + + + + + + + + + + + @@ -127,29 +133,37 @@ - - - - - 0 - 0 - + + + + Qt::Horizontal - + + QSizePolicy::Preferred + + - 500 - 0 + 40 + 20 - - - - - - - - - + + + + + + Qt::Horizontal + + + QSizePolicy::Preferred + + + + 40 + 20 + + + @@ -159,7 +173,7 @@ 0 0 943 - 30 + 34 diff --git a/tools/fm-editor/tree/FeatureTreeItem.cpp b/tools/fm-editor/tree/FeatureTreeItem.cpp index 4176ff225..83fda54f0 100644 --- a/tools/fm-editor/tree/FeatureTreeItem.cpp +++ b/tools/fm-editor/tree/FeatureTreeItem.cpp @@ -3,6 +3,7 @@ // #include "FeatureTreeItem.h" #include +#include QVariant numericValue(vara::feature::Feature* Item) { if(Item->getKind()==vara::feature::Feature::FeatureKind::FK_NUMERIC){ auto *NumItem = dynamic_cast(Item); @@ -54,6 +55,17 @@ FeatureTreeItem* FeatureTreeItem::createFeatureTreeItem( vara::feature::Feature *Item, FeatureTreeItem *Parent) { return new FeatureTreeItemFeature(Item, Parent); } +void FeatureTreeItem::addChild(FeatureTreeItem* Child) { + Children.push_back(Child); +} +std::vector FeatureTreeItem::getChildrenRecursive() { + auto Nodes = std::vector{Children}; + for(auto Child: Children){ + auto ChildNodes = Child->getChildrenRecursive(); + Nodes.insert(Nodes.end(),ChildNodes.begin(), ChildNodes.end()); + } + return Nodes; +} QVariant FeatureTreeItemFeature::data(int Column) const { switch (Column) { diff --git a/tools/fm-editor/tree/FeatureTreeItem.h b/tools/fm-editor/tree/FeatureTreeItem.h index b17f720e0..84f1d91ec 100644 --- a/tools/fm-editor/tree/FeatureTreeItem.h +++ b/tools/fm-editor/tree/FeatureTreeItem.h @@ -12,10 +12,6 @@ class FeatureTreeItem: public QObject { Q_OBJECT public: - virtual ~FeatureTreeItem() { - std::destroy(Children.begin(), Children.end()); - } - FeatureTreeItem *child(int Row) { if(Row<0||Row>Children.size()) { return nullptr; @@ -25,7 +21,7 @@ class FeatureTreeItem: public QObject { int childCount() { return Children.size(); } - + std::vector getChildrenRecursive(); int row() { if(Parent) { auto pos =std::find(Parent->Children.begin(), Parent->Children.end(), this); @@ -38,6 +34,7 @@ class FeatureTreeItem: public QObject { FeatureTreeItem* parent() { return Parent; } + void addChild(FeatureTreeItem* Child); [[nodiscard]] virtual int columnCount() const = 0; [[nodiscard]] virtual QVariant data(int Column) const = 0; FeatureTreeItem static *createFeatureTreeItem(vara::feature::Relationship* Item,FeatureTreeItem* Parent); @@ -74,7 +71,7 @@ virtual ~FeatureTreeItemFeature() = default; bool booleanColumn(int Column) {return Column==1;} void contextMenu(QPoint Pos) override; public slots: - void inspect() ; + void inspect(); private: vara::feature::Feature* Item; diff --git a/tools/fm-editor/tree/FeatureTreeViewModel.cpp b/tools/fm-editor/tree/FeatureTreeViewModel.cpp index 1d946e192..94e2f5404 100644 --- a/tools/fm-editor/tree/FeatureTreeViewModel.cpp +++ b/tools/fm-editor/tree/FeatureTreeViewModel.cpp @@ -79,3 +79,6 @@ QVariant FeatureTreeViewModel::headerData(int Section, } return {}; } +std::vector FeatureTreeViewModel::getItems() { +return Items; +} diff --git a/tools/fm-editor/tree/FeatureTreeViewModel.h b/tools/fm-editor/tree/FeatureTreeViewModel.h index d88bad730..46477afd2 100644 --- a/tools/fm-editor/tree/FeatureTreeViewModel.h +++ b/tools/fm-editor/tree/FeatureTreeViewModel.h @@ -10,11 +10,12 @@ class FeatureTreeViewModel : public QAbstractItemModel { public: FeatureTreeViewModel(vara::feature::FeatureModel* Model, QObject *Parent): QAbstractItemModel(Parent), Model(Model), RootItem(FeatureTreeItem::createFeatureTreeItem(Model->getRoot(), nullptr)) { - + Items = RootItem->getChildrenRecursive(); } ~FeatureTreeViewModel() override{ delete RootItem; } + std::vector getItems(); [[nodiscard]] QVariant data(const QModelIndex &Index, int Role = Qt::DisplayRole)const override; [[nodiscard]] int rowCount(const QModelIndex &Parent = QModelIndex()) const override; [[nodiscard]] QModelIndex index(int Row, int Column, const QModelIndex &Parent = QModelIndex()) const override; @@ -22,9 +23,11 @@ class FeatureTreeViewModel : public QAbstractItemModel { [[nodiscard]] int columnCount(const QModelIndex &Parent = QModelIndex()) const override; [[nodiscard]] Qt::ItemFlags flags(const QModelIndex &Index) const override; [[nodiscard]] QVariant headerData(int Section, Qt::Orientation Orientation, int Role = Qt::DisplayRole) const override; + private: vara::feature::FeatureModel* Model; FeatureTreeItem* RootItem; + std::vector Items; }; #endif // VARA_FEATURE_FEATURETREEVIEWMODEL_H From b893910fd27b11675dd0451d5f51c3ba8c5c039d Mon Sep 17 00:00:00 2001 From: Nerum Date: Tue, 14 Feb 2023 18:12:35 +0100 Subject: [PATCH 023/106] Load feature information when selecting feature in treeview --- tools/fm-editor/FeatureModelEditor.cpp | 12 +++++++++++- tools/fm-editor/FeatureModelEditor.h | 4 +++- tools/fm-editor/graph/FeatureNode.h | 2 +- tools/fm-editor/tree/FeatureTreeItem.cpp | 8 +++----- tools/fm-editor/tree/FeatureTreeItem.h | 14 +++++++++----- tools/fm-editor/tree/FeatureTreeViewModel.cpp | 3 +-- 6 files changed, 28 insertions(+), 15 deletions(-) diff --git a/tools/fm-editor/FeatureModelEditor.cpp b/tools/fm-editor/FeatureModelEditor.cpp index a63c7eaff..d839d1723 100644 --- a/tools/fm-editor/FeatureModelEditor.cpp +++ b/tools/fm-editor/FeatureModelEditor.cpp @@ -34,11 +34,20 @@ FeatureModelEditor::FeatureModelEditor(QWidget *Parent) connect(Ui->addSource,&QPushButton::pressed, this,&FeatureModelEditor::addSource); connect(Ui->addSourceFile,&QPushButton::pressed, this,&FeatureModelEditor::addSourceFile); } -void FeatureModelEditor::loadFeature(vara::feature::Feature *Feature) { +void FeatureModelEditor::loadFeature(const vara::feature::Feature *Feature) { auto FeatureString = Feature->toString(); Ui->featureInfo->setText(QString::fromStdString(FeatureString)); } +void FeatureModelEditor::loadFeaturefromIndex(const QModelIndex &Index) { + if(Index.isValid()){ + auto Item = + static_cast(Index.internalPointer()); + if(Item->getKind() == vara::feature::FeatureTreeNode::NodeKind::NK_FEATURE){ + loadFeature(static_cast(Item)->getItem()); + } + } +} void FeatureModelEditor::loadGraph() { if(!Repository.isEmpty()){ Repository.clear(); @@ -65,6 +74,7 @@ void FeatureModelEditor::loadGraph() { QObject::connect(Item, &FeatureTreeItem::inspectSource, this, &FeatureModelEditor::inspectFeature); } + connect(TreeView,&QTreeView::pressed,this,&FeatureModelEditor::loadFeaturefromIndex); TreeView->setModel(TreeModel); TreeView->setContextMenuPolicy(Qt::CustomContextMenu); connect(TreeView, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onCustomContextMenu(const QPoint &))); diff --git a/tools/fm-editor/FeatureModelEditor.h b/tools/fm-editor/FeatureModelEditor.h index 5a74eb69e..c7c6bed94 100644 --- a/tools/fm-editor/FeatureModelEditor.h +++ b/tools/fm-editor/FeatureModelEditor.h @@ -33,7 +33,7 @@ class FeatureModelEditor : public QMainWindow { vara::feature::Feature* CurrentFeature; public slots: void addSource(); - void loadFeature(vara::feature::Feature *Feature); + void loadFeature(const vara::feature::Feature *Feature); void inspectFeature(vara::feature::Feature *Feature); void loadGraph(); void featureAddDialog(); @@ -42,7 +42,9 @@ public slots: void findModel(); void onCustomContextMenu(const QPoint &Pos); void addSourceFile(); + void loadFeaturefromIndex(const QModelIndex &Index); private: + }; #endif // VARA_FEATURE_FEATUREMODELEDITOR_H diff --git a/tools/fm-editor/graph/FeatureNode.h b/tools/fm-editor/graph/FeatureNode.h index caa4bec7b..dd707fee6 100644 --- a/tools/fm-editor/graph/FeatureNode.h +++ b/tools/fm-editor/graph/FeatureNode.h @@ -33,7 +33,7 @@ class FeatureNode : public QObject,public QGraphicsItem{ }; [[nodiscard]] std::string getName() const {return Feature->getName().str();}; signals: - void clicked(vara::feature::Feature *Feature); + void clicked(const vara::feature::Feature *Feature); void inspectSource(vara::feature::Feature *Feature); protected: QVariant itemChange(GraphicsItemChange Change, const QVariant &Value) override; diff --git a/tools/fm-editor/tree/FeatureTreeItem.cpp b/tools/fm-editor/tree/FeatureTreeItem.cpp index 83fda54f0..0bc29da0a 100644 --- a/tools/fm-editor/tree/FeatureTreeItem.cpp +++ b/tools/fm-editor/tree/FeatureTreeItem.cpp @@ -73,8 +73,7 @@ QVariant FeatureTreeItemFeature::data(int Column) const { case 1: return Item->isOptional()? QVariant("✓"):QVariant("x"); case 2: return numericValue(Item); case 3: return locationString(Item); - case 4: return crossTreeConstraintString(Item); - case 5: return QString::fromStdString(Item->getOutputString().str()); + case 4: return QString::fromStdString(Item->getOutputString().str()); default: return {}; } @@ -88,6 +87,5 @@ void FeatureTreeItemFeature::contextMenu(QPoint Pos) { auto *Inspect = new QAction("Inspect Sources", this); Menu->addAction(Inspect); Menu->popup(Pos); - connect(Inspect, &QAction::triggered, - this, &FeatureTreeItemFeature::inspect); -} + connect(Inspect, &QAction::triggered, this, &FeatureTreeItemFeature::inspect); +} \ No newline at end of file diff --git a/tools/fm-editor/tree/FeatureTreeItem.h b/tools/fm-editor/tree/FeatureTreeItem.h index 84f1d91ec..938f6d825 100644 --- a/tools/fm-editor/tree/FeatureTreeItem.h +++ b/tools/fm-editor/tree/FeatureTreeItem.h @@ -41,10 +41,11 @@ class FeatureTreeItem: public QObject { FeatureTreeItem static *createFeatureTreeItem(vara::feature::Feature* Item,FeatureTreeItem* Parent); bool booleanColumn(int Column) {return false;} virtual void contextMenu(QPoint Pos) = 0; + vara::feature::FeatureTreeNode::NodeKind getKind() {return Kind;} signals: void inspectSource(vara::feature::Feature *Feature); protected: - FeatureTreeItem(vara::feature::FeatureTreeNode* Item ,FeatureTreeItem* Parent): Parent(Parent) { + FeatureTreeItem(vara::feature::FeatureTreeNode* Item ,FeatureTreeItem* Parent,vara::feature::FeatureTreeNode::NodeKind Kind): Parent(Parent), Kind(Kind) { for(auto *Child : Item->children()){ if(vara::feature::Relationship::classof(Child)) { Children.push_back(createFeatureTreeItem(dynamic_cast(Child), this)); @@ -55,7 +56,7 @@ class FeatureTreeItem: public QObject { } private: - + const vara::feature::FeatureTreeNode::NodeKind Kind; FeatureTreeItem* Parent; std::vector Children = {}; }; @@ -65,11 +66,13 @@ class FeatureTreeItemFeature: public FeatureTreeItem{ Q_OBJECT public: virtual ~FeatureTreeItemFeature() = default; - FeatureTreeItemFeature(vara::feature::Feature* Item,FeatureTreeItem* Parent): FeatureTreeItem(Item,Parent), Item(Item) {} + FeatureTreeItemFeature(vara::feature::Feature* Item,FeatureTreeItem* Parent): FeatureTreeItem(Item,Parent,vara::feature::FeatureTreeNode::NodeKind::NK_FEATURE), Item(Item) {} [[nodiscard]] QVariant data(int Column) const override; - [[nodiscard]] int columnCount() const override {return 6;} + [[nodiscard]] int columnCount() const override {return 5;} bool booleanColumn(int Column) {return Column==1;} void contextMenu(QPoint Pos) override; + const vara::feature::Feature* getItem() const {return Item;} + public slots: void inspect(); private: @@ -81,7 +84,7 @@ public slots: class FeatureTreeItemRelation: public FeatureTreeItem { public: virtual ~FeatureTreeItemRelation() = default; -FeatureTreeItemRelation(vara::feature::Relationship* Item,FeatureTreeItem* Parent): FeatureTreeItem(Item,Parent),Item(Item) {} +FeatureTreeItemRelation(vara::feature::Relationship* Item,FeatureTreeItem* Parent): FeatureTreeItem(Item,Parent,vara::feature::FeatureTreeNode::NodeKind::NK_RELATIONSHIP),Item(Item) {} [[nodiscard]] QVariant data(int Column) const override{ if(Column==0) { return QString::fromStdString(relationType()); @@ -92,6 +95,7 @@ return {}; void contextMenu(QPoint Pos) override{} private: vara::feature::Relationship* Item; + static const vara::feature::FeatureTreeNode::NodeKind Kind = vara::feature::FeatureTreeNode::NodeKind::NK_RELATIONSHIP; [[nodiscard]] std::string relationType() const { std::string Type; switch (Item->getKind()) { diff --git a/tools/fm-editor/tree/FeatureTreeViewModel.cpp b/tools/fm-editor/tree/FeatureTreeViewModel.cpp index 94e2f5404..d5cc85fad 100644 --- a/tools/fm-editor/tree/FeatureTreeViewModel.cpp +++ b/tools/fm-editor/tree/FeatureTreeViewModel.cpp @@ -72,8 +72,7 @@ QVariant FeatureTreeViewModel::headerData(int Section, case 1:return QString("Optional"); case 2:return QString("NumericValues"); case 3:return QString("Locations"); - case 4:return QString("Constraints"); - case 5:return QString("ConfigurationOption"); + case 4:return QString("ConfigurationOption"); default:return QString("Todo"); } } From 81b1d364cf417c04c7e2b9260a2faab9bdfc9da1 Mon Sep 17 00:00:00 2001 From: Nerum Date: Wed, 15 Feb 2023 16:02:32 +0100 Subject: [PATCH 024/106] Refactor and add full functionality to feature adding. --- tools/fm-editor/FeatureAddDialog.cpp | 72 +++++-- tools/fm-editor/FeatureAddDialog.h | 7 +- tools/fm-editor/FeatureAddDialog.ui | 194 ++++++++++++++---- tools/fm-editor/FeatureModelEditor.cpp | 169 ++++++++++----- tools/fm-editor/FeatureModelEditor.h | 23 ++- tools/fm-editor/FeatureModelEditor.ui | 38 +++- tools/fm-editor/graph/FeatureModelGraph.cpp | 24 +-- tools/fm-editor/graph/FeatureModelGraph.h | 6 +- tools/fm-editor/graph/FeatureNode.cpp | 3 +- tools/fm-editor/graph/FeatureNode.h | 5 +- tools/fm-editor/tree/FeatureTreeItem.h | 8 +- tools/fm-editor/tree/FeatureTreeViewModel.cpp | 10 + tools/fm-editor/tree/FeatureTreeViewModel.h | 5 +- 13 files changed, 409 insertions(+), 155 deletions(-) diff --git a/tools/fm-editor/FeatureAddDialog.cpp b/tools/fm-editor/FeatureAddDialog.cpp index 056b9c45b..128351d5e 100644 --- a/tools/fm-editor/FeatureAddDialog.cpp +++ b/tools/fm-editor/FeatureAddDialog.cpp @@ -5,37 +5,81 @@ #include "FeatureAddDialog.h" #include "graph/FeatureModelGraph.h" #include "graph/FeatureNode.h" +using vara::feature::Feature; using vara::feature::FeatureModel; FeatureAddDialog::FeatureAddDialog(FeatureModelGraph *Graph, QWidget *Parent) - : QDialog(Parent){ + : QDialog(Parent) { setupUi(this); NodeNames = QStringList(); - for(const auto &Node: *Graph->getNodes()){ + for (const auto &Node : *Graph->getNodes()) { NodeNames.push_back(Node->getQName()); } - const auto ConstNodeNames = NodeNames; - this->Nodes->addItems(ConstNodeNames); - this->FeatureKind->addItems(QStringList{"Binary","Numeric","Root","Unknown"}); + this->Nodes->addItems(NodeNames); + this->FeatureKind->addItems(QStringList{"Binary", "Numeric"}); + stepOperator->addItems(QStringList{"Add +", "Multiply *", "Exp ^"}); NumericFeature->setVisible(false); - connect(FeatureKind,&QComboBox::activated, this, + connect(FeatureKind, &QComboBox::activated, this, &FeatureAddDialog::featureType); } -QString FeatureAddDialog::getName() { - return name->text(); -} +QString FeatureAddDialog::getName() { return name->text(); } -std::string FeatureAddDialog::getParent(){ - return Nodes->currentText().toStdString(); -} +QString FeatureAddDialog::getParent() { return Nodes->currentText(); } void FeatureAddDialog::featureType(int index) { - if(index ==1) { + if (index == 1) { NumericFeature->setVisible(true); - }else{ + } else { NumericFeature->setVisible(false); } } vara::feature::Feature::FeatureKind FeatureAddDialog::getFeatureKind() { return vara::feature::Feature::FeatureKind(FeatureKind->currentIndex()); } +bool FeatureAddDialog::isOptional() { return optinalCheck->isChecked(); } +QString FeatureAddDialog::getOutpuString() { return outpuString->text(); } + +std::vector stringToIntVector(string &Input) { + std::stringstream InStream(Input); + std::vector Out{}; + + for (std::string Substring; std::getline(InStream, Substring, ',');) { + Out.push_back(std::stoi(Substring)); + } + return Out; +} + +std::unique_ptr FeatureAddDialog::getFeature() { + const std::string Name = getName().toStdString(); + const bool Optional = isOptional(); + const std::string OutputString = getOutpuString().toStdString(); + vara::feature::NumericFeature::ValuesVariantType ValueRange; + switch (getFeatureKind()) { + + case Feature::FeatureKind::FK_BINARY: + return std::make_unique( + Name, Optional, std::vector(), + OutputString); + case Feature::FeatureKind::FK_NUMERIC: { + std::unique_ptr SF{}; + if (range->isChecked()) { + ValueRange = vara::feature::NumericFeature::ValueRangeType(min->value(), + max->value()); + if (lhs->isChecked()) { + SF = std::make_unique( + stepOperant->value(), vara::feature::StepFunction::StepOperation( + stepOperator->currentIndex())); + } + } else { + auto ValueString = values->text().toStdString(); + ValueRange = stringToIntVector(ValueString); + } + return std::make_unique( + Name, ValueRange, Optional, + std::vector(), OutputString, + std::move(SF)); + } + default: + return std::make_unique(Name); + } +} diff --git a/tools/fm-editor/FeatureAddDialog.h b/tools/fm-editor/FeatureAddDialog.h index 70974f1b0..365972153 100644 --- a/tools/fm-editor/FeatureAddDialog.h +++ b/tools/fm-editor/FeatureAddDialog.h @@ -14,14 +14,19 @@ class FeatureAddDialog : public QDialog, public Ui::Add { public: FeatureAddDialog(FeatureModelGraph *Graph, QWidget *Parent); QString getName(); - string getParent(); + QString getParent(); + QString getOutpuString(); + std::unique_ptr getFeature(); vara::feature::Feature::FeatureKind getFeatureKind(); + bool isOptional(); public slots: void featureType(int index); private: QStringList NodeNames; + + vara::feature::StepFunction::StepOperation getStepOperation(); }; #endif // VARA_FEATURE_FEATUREADDDIALOG_H diff --git a/tools/fm-editor/FeatureAddDialog.ui b/tools/fm-editor/FeatureAddDialog.ui index c5f1af5fc..3cb0f48d1 100644 --- a/tools/fm-editor/FeatureAddDialog.ui +++ b/tools/fm-editor/FeatureAddDialog.ui @@ -6,32 +6,21 @@ 0 0 - 400 - 319 + 410 + 392 + + + 0 + 0 + + Dialog - - - - Name - - - - - - - Optional - - - - - - - + Qt::Horizontal @@ -41,52 +30,153 @@ - + Parent - + + + + + + + Optional + + + + FeatureType - - - - + - - - - true + + + + Output String - - - + + + + + + + + + + + + Name + + + + + + + + - Min + Range - - - - - - - Max + + + + true + + 1 + + + + + + + Values + + + + + + + 1,2,10 + + + + + + + + + + + 100000000 + + + 0 + + + + + + + Min + + + + + + + 10000000.000000000000000 + + + 1.000000000000000 + + + + + + + 1000000000 + + + + + + + StepFunction + + + + + + + + + + Max + + + + + + + Value is Left Operant + + + + + - - - @@ -126,5 +216,21 @@ + + range + stateChanged(int) + NumericValues + setCurrentIndex(int) + + + 51 + 232 + + + 239 + 232 + + + diff --git a/tools/fm-editor/FeatureModelEditor.cpp b/tools/fm-editor/FeatureModelEditor.cpp index d839d1723..1eb61bbc4 100644 --- a/tools/fm-editor/FeatureModelEditor.cpp +++ b/tools/fm-editor/FeatureModelEditor.cpp @@ -10,6 +10,7 @@ #include "ui_FeatureModelEditor.h" #include "vara/Feature/FeatureModel.h" #include "vara/Feature/FeatureModelTransaction.h" +#include "vara/Feature/FeatureModelWriter.h" #include #include namespace fs = std::filesystem; @@ -17,6 +18,8 @@ using vara::feature::FeatureModel; using Transaction = vara::feature::FeatureModelTransaction; using vara::feature::Feature; + + FeatureModelEditor::FeatureModelEditor(QWidget *Parent) : QMainWindow(Parent), Ui(new Ui::FeatureModelEditor) { @@ -30,15 +33,19 @@ FeatureModelEditor::FeatureModelEditor(QWidget *Parent) &FeatureModelEditor::findModel); QObject::connect(Ui->actionAddFeature,&QAction::triggered, this, &FeatureModelEditor::featureAddDialog); - + connect(Ui->actionSave,&QAction::triggered,this,&FeatureModelEditor::save); connect(Ui->addSource,&QPushButton::pressed, this,&FeatureModelEditor::addSource); connect(Ui->addSourceFile,&QPushButton::pressed, this,&FeatureModelEditor::addSourceFile); } + +///Display the information of a Feature void FeatureModelEditor::loadFeature(const vara::feature::Feature *Feature) { auto FeatureString = Feature->toString(); Ui->featureInfo->setText(QString::fromStdString(FeatureString)); } + +///Get a Feature from an Index of the TreeView and display its information. void FeatureModelEditor::loadFeaturefromIndex(const QModelIndex &Index) { if(Index.isValid()){ auto Item = @@ -48,55 +55,104 @@ void FeatureModelEditor::loadFeaturefromIndex(const QModelIndex &Index) { } } } +///Clear all Fields that should be emptied when loading a new Model +void FeatureModelEditor::clean() { + SavePath.clear(); + Repository.clear(); + Ui->tabWidget->clear(); + Ui->sources->clear(); + Ui->textEdit->clear(); + Ui->sourcesLable->setText("Sources for: "); + Ui->featureInfo->clear(); +} + +///Load the Feature Model at the Path in ModelFile field and build the Views void FeatureModelEditor::loadGraph() { - if(!Repository.isEmpty()){ - Repository.clear(); - } - auto Path = Ui->ModelFile->text().toStdString(); - Model = vara::feature::loadFeatureModel(Path); - if(!Model){ + clean(); + ModelPath = Ui->ModelFile->text(); + FeatureModel = vara::feature::loadFeatureModel(ModelPath.toStdString()); + if(!FeatureModel){ //Return if no model at Path return; } //create Graph view - Graph = new FeatureModelGraph{Model.get()}; - Ui->tabWidget->addTab(Graph,"GraphView"); + buildGraph(); + // create Tree View + buildTree(); + Ui->tabWidget->addTab(Graph.get(),"GraphView"); + Ui->tabWidget->addTab(TreeView,"TreeView"); + connect(Ui->sources,&QComboBox::currentTextChanged, this,&FeatureModelEditor::loadSource); + Ui->actionSave->setEnabled(true); + Ui->actionAddFeature->setEnabled(true); +} + +///Build the Treeview +void FeatureModelEditor::buildTree() { + TreeView = new QTreeView(); + TreeModel =std::make_unique(FeatureModel.get(), TreeView); + for(auto Item: TreeModel->getItems()){ + connect(Item, &FeatureTreeItem::inspectSource, this, + &FeatureModelEditor::inspectFeatureSources); + } + connect(TreeView,&QTreeView::pressed,this,&FeatureModelEditor::loadFeaturefromIndex); + TreeView->setModel(TreeModel.get()); + TreeView->setContextMenuPolicy(Qt::CustomContextMenu); + connect(TreeView, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(createTreeContextMenu(const QPoint &))); +} + +///Build the graph view +void FeatureModelEditor::buildGraph() { + Graph = std::make_unique(FeatureModel.get()); for (auto &Node : *Graph->getNodes()) { QObject::connect(Node.get(), &FeatureNode::clicked, this, &FeatureModelEditor::loadFeature); QObject::connect(Node.get(), &FeatureNode::inspectSource, this, - &FeatureModelEditor::inspectFeature); - } - //create Tree View - TreeView = new QTreeView(); - TreeModel = new FeatureTreeViewModel(Model.get(),TreeView); - for(auto Item:TreeModel->getItems()){ - QObject::connect(Item, &FeatureTreeItem::inspectSource, this, - &FeatureModelEditor::inspectFeature); + &FeatureModelEditor::inspectFeatureSources); } - connect(TreeView,&QTreeView::pressed,this,&FeatureModelEditor::loadFeaturefromIndex); - TreeView->setModel(TreeModel); - TreeView->setContextMenuPolicy(Qt::CustomContextMenu); - connect(TreeView, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onCustomContextMenu(const QPoint &))); - Ui->tabWidget->addTab(TreeView,"TreeView"); - connect(Ui->sources,&QComboBox::currentTextChanged, this,&FeatureModelEditor::loadSource); } + +///Spawn a Dialog to select data to add a Feature void FeatureModelEditor::featureAddDialog() { - FeatureAddDialog AddDialog(Graph,this); + FeatureAddDialog AddDialog(Graph.get(),this); if(AddDialog.exec() == QDialog::Accepted){ - auto *NewNode = Graph->addFeature(AddDialog.getName(),Graph->getNode(AddDialog.getParent())); - QObject::connect(NewNode, &FeatureNode::clicked, this, + Feature* Parent = FeatureModel->getFeature(AddDialog.getParent().toStdString()); + auto NewFeature = AddDialog.getFeature(); + + auto *NewNode = Graph->addNode(NewFeature.get(), + Graph->getNode(Parent->getName().str())); + auto *NewTreeItem = TreeModel->addFeature(NewFeature.get(),Parent->getName().str()); + connect(NewTreeItem,&FeatureTreeItem::inspectSource, this,&FeatureModelEditor::inspectFeatureSources); + connect(NewNode, &FeatureNode::clicked, this, &FeatureModelEditor::loadFeature); - QObject::connect(NewNode, &FeatureNode::inspectSource, this, - &FeatureModelEditor::inspectFeature); + connect(NewNode, &FeatureNode::inspectSource, this, + &FeatureModelEditor::inspectFeatureSources); + + auto Transaction = vara::feature::FeatureModelTransaction::openTransaction(*FeatureModel); + Transaction.addFeature(std::move(NewFeature),Parent); + Transaction.commit(); } } + + +///Save the current State of the Feature Model +void FeatureModelEditor::save() { + SavePath = QFileDialog::getSaveFileName(this,tr("Save File"),ModelPath,tr("XML files (*.xml)")); + vara::feature::FeatureModelXmlWriter FMWrite{*FeatureModel}; + FMWrite.writeFeatureModel(SavePath.toStdString()); +} + + + +///Spawn File Selection popup to get a Feature Model void FeatureModelEditor::findModel() { QString const Path = QFileDialog::getOpenFileName(this,tr("Open Model"),"/home",tr("XML files (*.xml)")); Ui->ModelFile->setText(Path); } -void FeatureModelEditor::inspectFeature(vara::feature::Feature *Feature) { + +/// Loead the source files of the Feature to be selectable by the user and set the Feature as CurrentFeature. +/// \param Feature +void FeatureModelEditor::inspectFeatureSources(vara::feature::Feature *Feature) { CurrentFeature = Feature; if(Repository.isEmpty()){ Repository = QFileDialog::getExistingDirectory(); @@ -105,6 +161,7 @@ void FeatureModelEditor::inspectFeature(vara::feature::Feature *Feature) { for(const auto& Source : Feature->getLocations()){ Ui->sources->addItem(QString::fromStdString(Source.getPath().string())); } + Ui->sourcesLable->setText( QString::fromStdString("Sources for: "+Feature->getName().str())); if(Ui->sources->count() == 1){ loadSource(Ui->sources->itemText(0)); } else { @@ -113,7 +170,7 @@ void FeatureModelEditor::inspectFeature(vara::feature::Feature *Feature) { } - +/// Load the selected file into the textedit and mark the sources of the selected feature void FeatureModelEditor::loadSource(const QString &RelativePath){ Ui->textEdit->clear(); auto SourcePath = Repository + "/" + RelativePath; @@ -129,28 +186,36 @@ void FeatureModelEditor::loadSource(const QString &RelativePath){ std::vector Locations{}; std::copy_if(CurrentFeature->getLocationsBegin(),CurrentFeature->getLocationsEnd(),std::back_inserter(Locations),[&RelativePath](auto const& Loc){return RelativePath.toStdString()==Loc.getPath();}); for (auto &Location:Locations) { - Cursor.movePosition(QTextCursor::MoveOperation::Start,QTextCursor::MoveMode::MoveAnchor); - Cursor.movePosition(QTextCursor::MoveOperation::Down, - QTextCursor::MoveMode::MoveAnchor, - Location.getStart()->getLineNumber() - 1); - Cursor.movePosition(QTextCursor::MoveOperation::NextCharacter, - QTextCursor::MoveMode::MoveAnchor, - Location.getStart()->getColumnOffset()-1); - Cursor.movePosition(QTextCursor::MoveOperation::Down, - QTextCursor::MoveMode::KeepAnchor, - Location.getEnd()->getLineNumber() - - Location.getStart()->getLineNumber()); - Cursor.movePosition(QTextCursor::MoveOperation::StartOfLine, - QTextCursor::MoveMode::KeepAnchor); - Cursor.movePosition(QTextCursor::MoveOperation::NextCharacter, - QTextCursor::MoveMode::KeepAnchor, - Location.getEnd()->getColumnOffset()); - Cursor.setCharFormat(Fmt); + markLocation(Fmt, Cursor, Location); } } } -void FeatureModelEditor::onCustomContextMenu(const QPoint &Pos) { +/// Mark the given SourceRange with the given Format +/// \param Fmt Format to mark with +/// \param Cursor Cursor +/// \param Location Location to mark +void FeatureModelEditor::markLocation( + const QTextCharFormat &Fmt, QTextCursor &Cursor, + vara::feature::FeatureSourceRange &Location) + const { + Cursor.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor); + Cursor.movePosition(QTextCursor::Down, QTextCursor::MoveAnchor, + Location.getStart()->getLineNumber() - 1); + Cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::MoveAnchor, + Location.getStart()->getColumnOffset()-1); + Cursor.movePosition(QTextCursor::Down, QTextCursor::KeepAnchor, + Location.getEnd()->getLineNumber() - + Location.getStart()->getLineNumber()); + Cursor.movePosition(QTextCursor::StartOfLine, QTextCursor::KeepAnchor); + Cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, + Location.getEnd()->getColumnOffset()); + Cursor.setCharFormat(Fmt); +} + +/// Create the Context menu for inspecting sources in the tree view +/// \param Pos Position of the cursor used to find the clicked item +void FeatureModelEditor::createTreeContextMenu(const QPoint &Pos) { auto Index = TreeView->indexAt(Pos); if(Index.isValid()){ FeatureTreeItem* Item = static_cast(Index.internalPointer()); @@ -158,6 +223,8 @@ void FeatureModelEditor::onCustomContextMenu(const QPoint &Pos) { } } + +///Load a sourcefile to then add a location from it void FeatureModelEditor::addSourceFile(){ if(!Repository.isEmpty()) { QString const Path = QFileDialog::getOpenFileName( @@ -166,7 +233,7 @@ void FeatureModelEditor::addSourceFile(){ Ui->sources->addItem(Path.sliced(Repository.length())); } } - +/// Add the user selected Part of the textedit as a source for the active Feature void FeatureModelEditor::addSource() { auto TextEdit = Ui->textEdit; auto Cursor = TextEdit->textCursor(); @@ -186,6 +253,8 @@ void FeatureModelEditor::addSource() { Block = Block.previous(); } auto Range = vara::feature::FeatureSourceRange(Ui->sources->currentText().toStdString(),vara::feature::FeatureSourceRange::FeatureSourceLocation(lines,start-lineStart+1),vara::feature::FeatureSourceRange::FeatureSourceLocation(lines,end-lineStart)); - CurrentFeature->addLocation(Range); + auto LocationTransAction = Transaction::openTransaction(*FeatureModel); + LocationTransAction.addLocation(CurrentFeature,Range); + LocationTransAction.commit(); loadSource(Ui->sources->currentText()); } diff --git a/tools/fm-editor/FeatureModelEditor.h b/tools/fm-editor/FeatureModelEditor.h index c7c6bed94..ef85468c2 100644 --- a/tools/fm-editor/FeatureModelEditor.h +++ b/tools/fm-editor/FeatureModelEditor.h @@ -9,6 +9,7 @@ #include "vara/Feature/FeatureModelTransaction.h" #include #include +#include #include QT_BEGIN_NAMESPACE namespace Ui { @@ -24,27 +25,33 @@ class FeatureModelEditor : public QMainWindow { private: Ui::FeatureModelEditor *Ui; - FeatureModelGraph * Graph{}; + std::unique_ptr Graph{}; QTreeView* TreeView; - FeatureTreeViewModel *TreeModel; - std::unique_ptr Model {}; - std::unique_ptr> Modification {}; + std::unique_ptr TreeModel{}; + std::unique_ptr FeatureModel{}; QString Repository {}; vara::feature::Feature* CurrentFeature; + QString SavePath {}; + QString ModelPath {}; public slots: void addSource(); void loadFeature(const vara::feature::Feature *Feature); - void inspectFeature(vara::feature::Feature *Feature); + void inspectFeatureSources(vara::feature::Feature *Feature); void loadGraph(); void featureAddDialog(); - //void addFeature(const QString& Name, FeatureNode *Parent); + //void addNode(const QString& Name, FeatureNode *Parent); void loadSource(const QString &RelativePath); void findModel(); - void onCustomContextMenu(const QPoint &Pos); + void createTreeContextMenu(const QPoint &Pos); void addSourceFile(); void loadFeaturefromIndex(const QModelIndex &Index); + void save(); private: - + void clean(); + void buildGraph(); + void buildTree(); + void markLocation(const QTextCharFormat &Fmt, QTextCursor &Cursor, + vara::feature::FeatureSourceRange &Location) const; }; #endif // VARA_FEATURE_FEATUREMODELEDITOR_H diff --git a/tools/fm-editor/FeatureModelEditor.ui b/tools/fm-editor/FeatureModelEditor.ui index 83098150b..e8861e768 100644 --- a/tools/fm-editor/FeatureModelEditor.ui +++ b/tools/fm-editor/FeatureModelEditor.ui @@ -30,25 +30,32 @@ - + + + + AddSource - + + + + AddSourceFile - - - - - + + + + Sources for: + + @@ -173,7 +180,7 @@ 0 0 943 - 34 + 30 @@ -181,15 +188,30 @@ Edit + + + false + AddFeature + + + false + + + Save + + + Ctrl+S + + diff --git a/tools/fm-editor/graph/FeatureModelGraph.cpp b/tools/fm-editor/graph/FeatureModelGraph.cpp index 178bf4d50..c5e870012 100644 --- a/tools/fm-editor/graph/FeatureModelGraph.cpp +++ b/tools/fm-editor/graph/FeatureModelGraph.cpp @@ -3,18 +3,16 @@ // #include "FeatureModelGraph.h" -#include "FeatureEdge.h" -#include "FeatureNode.h" #include "vara/Feature/Feature.h" #include "vara/Feature/FeatureModel.h" #include "vara/Feature/FeatureModelTransaction.h" #include - #include #include +using vara::feature::Feature; FeatureModelGraph::FeatureModelGraph(vara::feature::FeatureModel * FeatureModel, QWidget *Parent) - : QGraphicsView(Parent), EntryNode(new FeatureNode(this, FeatureModel->getRoot())), FeatureModel(FeatureModel) { + : QGraphicsView(Parent), EntryNode(new FeatureNode(FeatureModel->getRoot())), FeatureModel(FeatureModel) { auto *Scene = new QGraphicsScene(this); Scene->setItemIndexMethod(QGraphicsScene::NoIndex); @@ -45,7 +43,7 @@ void FeatureModelGraph::buildRec(FeatureNode *CurrentFeatureNode) { for (auto *Feature : CurrentFeatureNode->getFeature()->getChildren( 1)) { - auto Node = std::make_unique(this, Feature); + auto Node = std::make_unique(Feature); auto *Edge = new FeatureEdge(CurrentFeatureNode, Node.get()); scene()->addItem(Edge); scene()->addItem(Node.get()); @@ -57,7 +55,7 @@ void FeatureModelGraph::buildRec(FeatureNode *CurrentFeatureNode) { 1)) { for (auto *Feature :Relation->getChildren( 1)) { - auto Node = std::make_unique(this, Feature); + auto Node = std::make_unique(Feature); auto *Edge = new FeatureEdge(CurrentFeatureNode, Node.get()); scene()->addItem(Edge); scene()->addItem(Node.get()); @@ -85,12 +83,6 @@ int FeatureModelGraph::positionRec(const int CurrentDepth, const std::vectorkey()) { case Qt::Key_Plus: @@ -155,12 +147,8 @@ void FeatureModelGraph::zoomIn() { scaleView(qreal(1.2)); } void FeatureModelGraph::zoomOut() { scaleView(1 / qreal(1.2)); } -FeatureNode* FeatureModelGraph::addFeature(const QString& Name, FeatureNode* Parent) { - auto Transaction = vara::feature::FeatureModelTransaction::openTransaction(*FeatureModel); - auto NewFeature = std::make_unique(Name.toStdString()); - auto NewNode = std::make_unique(this,NewFeature.get()); - Transaction.addFeature(std::move(NewFeature),FeatureModel->getFeature(Parent->getName())); - Transaction.commit(); +FeatureNode* FeatureModelGraph::addNode(Feature* Feature, FeatureNode* Parent) { + auto NewNode = std::make_unique(Feature); auto * NewEdge = new FeatureEdge(Parent,NewNode.get()); scene()->addItem(NewEdge); scene()->addItem(NewNode.get()); diff --git a/tools/fm-editor/graph/FeatureModelGraph.h b/tools/fm-editor/graph/FeatureModelGraph.h index b47018900..52d764b45 100644 --- a/tools/fm-editor/graph/FeatureModelGraph.h +++ b/tools/fm-editor/graph/FeatureModelGraph.h @@ -3,9 +3,9 @@ #define VARA_FEATURE_FEATUREMODELGRAPH_H #include "vara/Feature/FeatureModel.h" +#include "FeatureNode.h" #include -class FeatureNode; -class FeatureEdge; +#include "FeatureEdge.h" class FeatureModelGraph : public QGraphicsView { Q_OBJECT @@ -15,7 +15,7 @@ class FeatureModelGraph : public QGraphicsView { auto getNodes() {return &Nodes;}; void itemMoved(); FeatureNode* getNode(std::string Name); - FeatureNode* addFeature(const QString& Name,FeatureNode* Parent); + FeatureNode*addNode(vara::feature::Feature *Feature,FeatureNode* Parent); public slots: void zoomIn(); void zoomOut(); diff --git a/tools/fm-editor/graph/FeatureNode.cpp b/tools/fm-editor/graph/FeatureNode.cpp index e519e15c2..7111e3da6 100644 --- a/tools/fm-editor/graph/FeatureNode.cpp +++ b/tools/fm-editor/graph/FeatureNode.cpp @@ -12,7 +12,7 @@ #include #include -FeatureNode::FeatureNode(FeatureModelGraph *Graph, vara::feature::Feature *Feature) : Graph(Graph),Feature(Feature) { +FeatureNode::FeatureNode(vara::feature::Feature *Feature) : Feature(Feature) { setFlag(ItemIsMovable); setFlag(ItemSendsGeometryChanges); setCacheMode(DeviceCoordinateCache); @@ -77,7 +77,6 @@ QVariant FeatureNode::itemChange(QGraphicsItem::GraphicsItemChange Change, if (ParentEdge) { ParentEdge->adjust(); } - Graph->itemMoved(); break; default: break; diff --git a/tools/fm-editor/graph/FeatureNode.h b/tools/fm-editor/graph/FeatureNode.h index dd707fee6..d4b1e8752 100644 --- a/tools/fm-editor/graph/FeatureNode.h +++ b/tools/fm-editor/graph/FeatureNode.h @@ -3,6 +3,7 @@ #define VARA_FEATURE_FEATURENODE_H #include "vara/Feature/Feature.h" +#include "FeatureNode.h" #include #include #include @@ -13,7 +14,7 @@ class FeatureNode : public QObject,public QGraphicsItem{ public: - FeatureNode(FeatureModelGraph *Graph, vara::feature::Feature *Feature); + FeatureNode( vara::feature::Feature *Feature); [[nodiscard]] int width() const; void addChildEdge(FeatureEdge *Edge); void setParentEdge(FeatureEdge *Edge); @@ -32,6 +33,7 @@ class FeatureNode : public QObject,public QGraphicsItem{ return QString::fromStdString(Feature->getName().str()); }; [[nodiscard]] std::string getName() const {return Feature->getName().str();}; + ~FeatureNode() {std::destroy(ChildEdges.begin(), ChildEdges.end());} signals: void clicked(const vara::feature::Feature *Feature); void inspectSource(vara::feature::Feature *Feature); @@ -44,7 +46,6 @@ class FeatureNode : public QObject,public QGraphicsItem{ private: std::vector ChildEdges; FeatureEdge * ParentEdge = nullptr; - FeatureModelGraph *Graph; vara::feature::Feature *Feature; void inspect(); diff --git a/tools/fm-editor/tree/FeatureTreeItem.h b/tools/fm-editor/tree/FeatureTreeItem.h index 938f6d825..eca738e20 100644 --- a/tools/fm-editor/tree/FeatureTreeItem.h +++ b/tools/fm-editor/tree/FeatureTreeItem.h @@ -8,6 +8,7 @@ #include "vara/Feature/Relationship.h" #include #include +#include #include class FeatureTreeItem: public QObject { Q_OBJECT @@ -42,10 +43,11 @@ class FeatureTreeItem: public QObject { bool booleanColumn(int Column) {return false;} virtual void contextMenu(QPoint Pos) = 0; vara::feature::FeatureTreeNode::NodeKind getKind() {return Kind;} + virtual string getName() {return "";}; signals: void inspectSource(vara::feature::Feature *Feature); protected: - FeatureTreeItem(vara::feature::FeatureTreeNode* Item ,FeatureTreeItem* Parent,vara::feature::FeatureTreeNode::NodeKind Kind): Parent(Parent), Kind(Kind) { + FeatureTreeItem(vara::feature::FeatureTreeNode* Item ,FeatureTreeItem* Parent,vara::feature::FeatureTreeNode::NodeKind Kind): Kind(Kind),Parent(Parent) { for(auto *Child : Item->children()){ if(vara::feature::Relationship::classof(Child)) { Children.push_back(createFeatureTreeItem(dynamic_cast(Child), this)); @@ -71,8 +73,8 @@ virtual ~FeatureTreeItemFeature() = default; [[nodiscard]] int columnCount() const override {return 5;} bool booleanColumn(int Column) {return Column==1;} void contextMenu(QPoint Pos) override; - const vara::feature::Feature* getItem() const {return Item;} - + const vara::feature::Feature* getItem() const {return Item;} + string getName() {return Item->getName().str();} public slots: void inspect(); private: diff --git a/tools/fm-editor/tree/FeatureTreeViewModel.cpp b/tools/fm-editor/tree/FeatureTreeViewModel.cpp index d5cc85fad..547dceb38 100644 --- a/tools/fm-editor/tree/FeatureTreeViewModel.cpp +++ b/tools/fm-editor/tree/FeatureTreeViewModel.cpp @@ -81,3 +81,13 @@ return {}; std::vector FeatureTreeViewModel::getItems() { return Items; } +FeatureTreeItem* FeatureTreeViewModel::addFeature(vara::feature::Feature *Feature, std::string Parent) { +auto Item = std::find_if(Items.begin(), Items.end(),[&Parent](auto I){return I->getName()==Parent;}); +if(Item != Items.end()){ + auto NewItem = FeatureTreeItem::createFeatureTreeItem(Feature,*Item); + (*Item)->addChild(NewItem); + Items.push_back(NewItem); + return NewItem; +} +return nullptr; +} diff --git a/tools/fm-editor/tree/FeatureTreeViewModel.h b/tools/fm-editor/tree/FeatureTreeViewModel.h index 46477afd2..72f6cadef 100644 --- a/tools/fm-editor/tree/FeatureTreeViewModel.h +++ b/tools/fm-editor/tree/FeatureTreeViewModel.h @@ -11,9 +11,10 @@ class FeatureTreeViewModel : public QAbstractItemModel { public: FeatureTreeViewModel(vara::feature::FeatureModel* Model, QObject *Parent): QAbstractItemModel(Parent), Model(Model), RootItem(FeatureTreeItem::createFeatureTreeItem(Model->getRoot(), nullptr)) { Items = RootItem->getChildrenRecursive(); + Items.push_back(RootItem); } ~FeatureTreeViewModel() override{ - delete RootItem; + std::destroy(Items.begin(), Items.end()); } std::vector getItems(); [[nodiscard]] QVariant data(const QModelIndex &Index, int Role = Qt::DisplayRole)const override; @@ -23,7 +24,7 @@ class FeatureTreeViewModel : public QAbstractItemModel { [[nodiscard]] int columnCount(const QModelIndex &Parent = QModelIndex()) const override; [[nodiscard]] Qt::ItemFlags flags(const QModelIndex &Index) const override; [[nodiscard]] QVariant headerData(int Section, Qt::Orientation Orientation, int Role = Qt::DisplayRole) const override; - + FeatureTreeItem* addFeature(vara::feature::Feature* Item,string Parent); private: vara::feature::FeatureModel* Model; FeatureTreeItem* RootItem; From 626fa7896227db3f3db90867dca335ffac4cdd4a Mon Sep 17 00:00:00 2001 From: Simon Friedel Date: Thu, 16 Feb 2023 14:19:56 +0100 Subject: [PATCH 025/106] Allow FeatureAddDialog to take a predefined parent --- tools/fm-editor/FeatureAddDialog.cpp | 11 ++++++++--- tools/fm-editor/FeatureAddDialog.h | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/tools/fm-editor/FeatureAddDialog.cpp b/tools/fm-editor/FeatureAddDialog.cpp index 128351d5e..669fd72a3 100644 --- a/tools/fm-editor/FeatureAddDialog.cpp +++ b/tools/fm-editor/FeatureAddDialog.cpp @@ -7,12 +7,17 @@ #include "graph/FeatureNode.h" using vara::feature::Feature; using vara::feature::FeatureModel; -FeatureAddDialog::FeatureAddDialog(FeatureModelGraph *Graph, QWidget *Parent) +FeatureAddDialog::FeatureAddDialog(FeatureModelGraph *Graph, QWidget *Parent, Feature* ParentFeature) : QDialog(Parent) { setupUi(this); NodeNames = QStringList(); - for (const auto &Node : *Graph->getNodes()) { - NodeNames.push_back(Node->getQName()); + if (!ParentFeature) { + for (const auto &Node : *Graph->getNodes()) { + NodeNames.push_back(Node->getQName()); + } + } else { + NodeNames.push_back(QString::fromStdString(ParentFeature->getName().str())); + Nodes->setEnabled(false); } this->Nodes->addItems(NodeNames); this->FeatureKind->addItems(QStringList{"Binary", "Numeric"}); diff --git a/tools/fm-editor/FeatureAddDialog.h b/tools/fm-editor/FeatureAddDialog.h index 365972153..09abdd238 100644 --- a/tools/fm-editor/FeatureAddDialog.h +++ b/tools/fm-editor/FeatureAddDialog.h @@ -12,7 +12,7 @@ class FeatureAddDialog : public QDialog, public Ui::Add { Q_OBJECT public: - FeatureAddDialog(FeatureModelGraph *Graph, QWidget *Parent); + FeatureAddDialog(FeatureModelGraph *Graph, QWidget *Parent, vara::feature::Feature* ParentFeature = nullptr); QString getName(); QString getParent(); QString getOutpuString(); From e476851cd424289d0bfbbf4e7f02e606f427fb71 Mon Sep 17 00:00:00 2001 From: Simon Friedel Date: Thu, 16 Feb 2023 14:20:13 +0100 Subject: [PATCH 026/106] Fix states for numeric value selection --- tools/fm-editor/FeatureAddDialog.ui | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/fm-editor/FeatureAddDialog.ui b/tools/fm-editor/FeatureAddDialog.ui index 3cb0f48d1..1be4e6af6 100644 --- a/tools/fm-editor/FeatureAddDialog.ui +++ b/tools/fm-editor/FeatureAddDialog.ui @@ -93,7 +93,7 @@ true - 1 + 0 @@ -113,6 +113,8 @@ + + From a1c59fc71213bc5f4a56916a5d15879c2e4fb61c Mon Sep 17 00:00:00 2001 From: Simon Friedel Date: Thu, 16 Feb 2023 14:21:25 +0100 Subject: [PATCH 027/106] Add new features to relations if present, and add context menu option to add child to a feature when in tree view --- .../vara/Feature/FeatureModelTransaction.h | 30 +++++++++++++++--- tools/fm-editor/FeatureModelEditor.cpp | 31 +++++++++++-------- tools/fm-editor/FeatureModelEditor.h | 6 ++-- tools/fm-editor/tree/FeatureTreeItem.cpp | 29 +++++++++++------ tools/fm-editor/tree/FeatureTreeItem.h | 24 ++++++++------ tools/fm-editor/tree/FeatureTreeViewModel.cpp | 2 +- tools/fm-editor/tree/FeatureTreeViewModel.h | 2 +- unittests/Feature/FeatureModelTransaction.cpp | 16 +++++----- 8 files changed, 90 insertions(+), 50 deletions(-) diff --git a/include/vara/Feature/FeatureModelTransaction.h b/include/vara/Feature/FeatureModelTransaction.h index 57f8b64ed..aafbc8496 100644 --- a/include/vara/Feature/FeatureModelTransaction.h +++ b/include/vara/Feature/FeatureModelTransaction.h @@ -91,7 +91,7 @@ class FeatureModelTransaction /// \returns a pointer to the inserted Feature in CopyMode, otherwise, /// nothing. decltype(auto) addFeature(std::unique_ptr NewFeature, - Feature *Parent = nullptr) { + FeatureTreeNode *Parent = nullptr) { if constexpr (IsCopyMode) { return this->addFeatureImpl(std::move(NewFeature), Parent); } else { @@ -319,11 +319,11 @@ class AddFeatureToModel : public FeatureModelModification { private: AddFeatureToModel(std::unique_ptr NewFeature, - Feature *Parent = nullptr) + FeatureTreeNode *Parent = nullptr) : NewFeature(std::move(NewFeature)), Parent(Parent) {} std::unique_ptr NewFeature; - Feature *Parent; + FeatureTreeNode *Parent; }; //===----------------------------------------------------------------------===// @@ -826,7 +826,7 @@ class FeatureModelCopyTransactionBase { // Modifications Result - addFeatureImpl(std::unique_ptr NewFeature, Feature *Parent) { + addFeatureImpl(std::unique_ptr NewFeature, FeatureTreeNode *Parent) { if (!FM) { return ERROR; } @@ -964,6 +964,26 @@ class FeatureModelCopyTransactionBase { return FM->getFeature(F.getName()); } + [[nodiscard]] FeatureTreeNode *translateFeature(FeatureTreeNode &F) { + if(F.getKind()==FeatureTreeNode::NodeKind::NK_RELATIONSHIP) { + int i = 0; + FeatureTreeNode* Parent = F.getParent(); + while(Parent->getKind()!=FeatureTreeNode::NodeKind::NK_FEATURE){ + Parent = Parent->getParent(); + i++; + } + auto ParentFeature = dynamic_cast(Parent); + ParentFeature = FM->getFeature(ParentFeature->getName()); + Relationship* Base = *ParentFeature->getChildren(0).begin(); + for(i=i-1;i<0;i--){ + Base = *Base->getChildren(0).begin(); + } + return Base; + } + + return FM->getFeature(dynamic_cast(F).getName()); + } + std::unique_ptr FM; }; @@ -1004,7 +1024,7 @@ class FeatureModelModifyTransactionBase { //===--------------------------------------------------------------------===// // Modifications - void addFeatureImpl(std::unique_ptr NewFeature, Feature *Parent) { + void addFeatureImpl(std::unique_ptr NewFeature, FeatureTreeNode *Parent) { assert(FM && "FeatureModel is null."); Modifications.push_back( diff --git a/tools/fm-editor/FeatureModelEditor.cpp b/tools/fm-editor/FeatureModelEditor.cpp index 1eb61bbc4..f9485fcf7 100644 --- a/tools/fm-editor/FeatureModelEditor.cpp +++ b/tools/fm-editor/FeatureModelEditor.cpp @@ -93,6 +93,8 @@ void FeatureModelEditor::buildTree() { for(auto Item: TreeModel->getItems()){ connect(Item, &FeatureTreeItem::inspectSource, this, &FeatureModelEditor::inspectFeatureSources); + connect(Item, &FeatureTreeItem::addCild, this, + &FeatureModelEditor::featureAddDialogChild); } connect(TreeView,&QTreeView::pressed,this,&FeatureModelEditor::loadFeaturefromIndex); TreeView->setModel(TreeModel.get()); @@ -110,10 +112,11 @@ void FeatureModelEditor::buildGraph() { &FeatureModelEditor::inspectFeatureSources); } } - +void FeatureModelEditor::featureAddDialog(){ featureAddDialogChild(nullptr); +} ///Spawn a Dialog to select data to add a Feature -void FeatureModelEditor::featureAddDialog() { - FeatureAddDialog AddDialog(Graph.get(),this); +void FeatureModelEditor::featureAddDialogChild(Feature* ParentFeature) { + FeatureAddDialog AddDialog(Graph.get(),this, ParentFeature); if(AddDialog.exec() == QDialog::Accepted){ Feature* Parent = FeatureModel->getFeature(AddDialog.getParent().toStdString()); auto NewFeature = AddDialog.getFeature(); @@ -126,9 +129,13 @@ void FeatureModelEditor::featureAddDialog() { &FeatureModelEditor::loadFeature); connect(NewNode, &FeatureNode::inspectSource, this, &FeatureModelEditor::inspectFeatureSources); - auto Transaction = vara::feature::FeatureModelTransaction::openTransaction(*FeatureModel); - Transaction.addFeature(std::move(NewFeature),Parent); + auto PotentialRelations = Parent->getChildren(1); + if(!PotentialRelations.empty()){ + Transaction.addFeature(std::move(NewFeature),*PotentialRelations.begin()); + } else { + Transaction.addFeature(std::move(NewFeature),Parent); + } Transaction.commit(); } } @@ -179,14 +186,11 @@ void FeatureModelEditor::loadSource(const QString &RelativePath){ File.open(QFile::ReadOnly | QFile::Text); QTextStream ReadFile(&File); Ui->textEdit->setText(ReadFile.readAll()); - QTextCharFormat Fmt; - Fmt.setBackground(Qt::darkYellow); - QTextCursor Cursor(Ui->textEdit->document()); std::cout << CurrentFeature->toString(); std::vector Locations{}; std::copy_if(CurrentFeature->getLocationsBegin(),CurrentFeature->getLocationsEnd(),std::back_inserter(Locations),[&RelativePath](auto const& Loc){return RelativePath.toStdString()==Loc.getPath();}); for (auto &Location:Locations) { - markLocation(Fmt, Cursor, Location); + markLocation(Location); } } @@ -196,9 +200,10 @@ void FeatureModelEditor::loadSource(const QString &RelativePath){ /// \param Cursor Cursor /// \param Location Location to mark void FeatureModelEditor::markLocation( - const QTextCharFormat &Fmt, QTextCursor &Cursor, - vara::feature::FeatureSourceRange &Location) - const { + vara::feature::FeatureSourceRange &Location) const { + QTextCharFormat Fmt; + Fmt.setBackground(Qt::darkYellow); + QTextCursor Cursor(Ui->textEdit->document()); Cursor.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor); Cursor.movePosition(QTextCursor::Down, QTextCursor::MoveAnchor, Location.getStart()->getLineNumber() - 1); @@ -256,5 +261,5 @@ void FeatureModelEditor::addSource() { auto LocationTransAction = Transaction::openTransaction(*FeatureModel); LocationTransAction.addLocation(CurrentFeature,Range); LocationTransAction.commit(); - loadSource(Ui->sources->currentText()); + markLocation(Range); } diff --git a/tools/fm-editor/FeatureModelEditor.h b/tools/fm-editor/FeatureModelEditor.h index ef85468c2..8da967dfc 100644 --- a/tools/fm-editor/FeatureModelEditor.h +++ b/tools/fm-editor/FeatureModelEditor.h @@ -38,7 +38,7 @@ public slots: void loadFeature(const vara::feature::Feature *Feature); void inspectFeatureSources(vara::feature::Feature *Feature); void loadGraph(); - void featureAddDialog(); + void featureAddDialogChild(vara::feature::Feature* = nullptr); //void addNode(const QString& Name, FeatureNode *Parent); void loadSource(const QString &RelativePath); void findModel(); @@ -46,12 +46,12 @@ public slots: void addSourceFile(); void loadFeaturefromIndex(const QModelIndex &Index); void save(); + void featureAddDialog(); private: void clean(); void buildGraph(); void buildTree(); - void markLocation(const QTextCharFormat &Fmt, QTextCursor &Cursor, - vara::feature::FeatureSourceRange &Location) const; + void markLocation(vara::feature::FeatureSourceRange &Location) const; }; #endif // VARA_FEATURE_FEATUREMODELEDITOR_H diff --git a/tools/fm-editor/tree/FeatureTreeItem.cpp b/tools/fm-editor/tree/FeatureTreeItem.cpp index 0bc29da0a..cc84dfba7 100644 --- a/tools/fm-editor/tree/FeatureTreeItem.cpp +++ b/tools/fm-editor/tree/FeatureTreeItem.cpp @@ -46,17 +46,20 @@ QVariant crossTreeConstraintString(vara::feature::Feature* Item){ } return QString::fromStdString(StrS.str()); } - -FeatureTreeItem* FeatureTreeItem::createFeatureTreeItem( - vara::feature::Relationship *Item, FeatureTreeItem *Parent) { - return new FeatureTreeItemRelation(Item,Parent); -} -FeatureTreeItem* FeatureTreeItem::createFeatureTreeItem( - vara::feature::Feature *Item, FeatureTreeItem *Parent) { - return new FeatureTreeItemFeature(Item, Parent); +FeatureTreeItem* FeatureTreeItem::createFeatureTreeItem( + vara::feature::FeatureTreeNode *Item) { + if(Item->getKind() == vara::feature::FeatureTreeNode::NodeKind::NK_RELATIONSHIP){ + return new FeatureTreeItemRelation(dynamic_cast(Item)); + } + return new FeatureTreeItemFeature(dynamic_cast(Item)); } void FeatureTreeItem::addChild(FeatureTreeItem* Child) { - Children.push_back(Child); + if(!Children.empty() && Children[0]->getKind()==vara::feature::FeatureTreeNode::NodeKind::NK_RELATIONSHIP){ + Children[0]->addChild(Child); + } else { + Children.push_back(Child); + Child->setParent(this); + } } std::vector FeatureTreeItem::getChildrenRecursive() { auto Nodes = std::vector{Children}; @@ -85,7 +88,13 @@ void FeatureTreeItemFeature::inspect() { void FeatureTreeItemFeature::contextMenu(QPoint Pos) { auto *Menu = new QMenu; auto *Inspect = new QAction("Inspect Sources", this); + auto *AddChild = new QAction("Add Child", this); Menu->addAction(Inspect); + Menu->addAction(AddChild); Menu->popup(Pos); connect(Inspect, &QAction::triggered, this, &FeatureTreeItemFeature::inspect); -} \ No newline at end of file + connect(AddChild, &QAction::triggered, this, &FeatureTreeItemFeature::addChild); +} +void FeatureTreeItemFeature::addChild() { + emit(addCild(Item)); +} diff --git a/tools/fm-editor/tree/FeatureTreeItem.h b/tools/fm-editor/tree/FeatureTreeItem.h index eca738e20..8bed13e04 100644 --- a/tools/fm-editor/tree/FeatureTreeItem.h +++ b/tools/fm-editor/tree/FeatureTreeItem.h @@ -38,28 +38,33 @@ class FeatureTreeItem: public QObject { void addChild(FeatureTreeItem* Child); [[nodiscard]] virtual int columnCount() const = 0; [[nodiscard]] virtual QVariant data(int Column) const = 0; - FeatureTreeItem static *createFeatureTreeItem(vara::feature::Relationship* Item,FeatureTreeItem* Parent); - FeatureTreeItem static *createFeatureTreeItem(vara::feature::Feature* Item,FeatureTreeItem* Parent); + FeatureTreeItem static *createFeatureTreeItem(vara::feature::FeatureTreeNode* Item); bool booleanColumn(int Column) {return false;} virtual void contextMenu(QPoint Pos) = 0; vara::feature::FeatureTreeNode::NodeKind getKind() {return Kind;} virtual string getName() {return "";}; + void setParent(FeatureTreeItem*ParentItem) {this->Parent = ParentItem;} signals: void inspectSource(vara::feature::Feature *Feature); + void addCild(vara::feature::Feature *Feature); protected: - FeatureTreeItem(vara::feature::FeatureTreeNode* Item ,FeatureTreeItem* Parent,vara::feature::FeatureTreeNode::NodeKind Kind): Kind(Kind),Parent(Parent) { + FeatureTreeItem(vara::feature::FeatureTreeNode* Item ,vara::feature::FeatureTreeNode::NodeKind Kind): Kind(Kind) { for(auto *Child : Item->children()){ if(vara::feature::Relationship::classof(Child)) { - Children.push_back(createFeatureTreeItem(dynamic_cast(Child), this)); + auto child = createFeatureTreeItem(dynamic_cast(Child)); + Children.push_back(child); + child->setParent(this); }else { - Children.push_back(createFeatureTreeItem(dynamic_cast(Child), this)); + auto child = createFeatureTreeItem(dynamic_cast(Child)); + Children.push_back(child); + child->setParent(this); } } } private: const vara::feature::FeatureTreeNode::NodeKind Kind; - FeatureTreeItem* Parent; + FeatureTreeItem* Parent = nullptr; std::vector Children = {}; }; @@ -68,15 +73,16 @@ class FeatureTreeItemFeature: public FeatureTreeItem{ Q_OBJECT public: virtual ~FeatureTreeItemFeature() = default; - FeatureTreeItemFeature(vara::feature::Feature* Item,FeatureTreeItem* Parent): FeatureTreeItem(Item,Parent,vara::feature::FeatureTreeNode::NodeKind::NK_FEATURE), Item(Item) {} + FeatureTreeItemFeature(vara::feature::Feature* Item): FeatureTreeItem(Item,vara::feature::FeatureTreeNode::NodeKind::NK_FEATURE), Item(Item) {} [[nodiscard]] QVariant data(int Column) const override; [[nodiscard]] int columnCount() const override {return 5;} bool booleanColumn(int Column) {return Column==1;} void contextMenu(QPoint Pos) override; const vara::feature::Feature* getItem() const {return Item;} - string getName() {return Item->getName().str();} + string getName() override {return Item->getName().str();} public slots: void inspect(); + void addChild(); private: vara::feature::Feature* Item; @@ -86,7 +92,7 @@ public slots: class FeatureTreeItemRelation: public FeatureTreeItem { public: virtual ~FeatureTreeItemRelation() = default; -FeatureTreeItemRelation(vara::feature::Relationship* Item,FeatureTreeItem* Parent): FeatureTreeItem(Item,Parent,vara::feature::FeatureTreeNode::NodeKind::NK_RELATIONSHIP),Item(Item) {} +FeatureTreeItemRelation(vara::feature::Relationship* Item): FeatureTreeItem(Item,vara::feature::FeatureTreeNode::NodeKind::NK_RELATIONSHIP),Item(Item) {} [[nodiscard]] QVariant data(int Column) const override{ if(Column==0) { return QString::fromStdString(relationType()); diff --git a/tools/fm-editor/tree/FeatureTreeViewModel.cpp b/tools/fm-editor/tree/FeatureTreeViewModel.cpp index 547dceb38..5e1694b4b 100644 --- a/tools/fm-editor/tree/FeatureTreeViewModel.cpp +++ b/tools/fm-editor/tree/FeatureTreeViewModel.cpp @@ -84,7 +84,7 @@ return Items; FeatureTreeItem* FeatureTreeViewModel::addFeature(vara::feature::Feature *Feature, std::string Parent) { auto Item = std::find_if(Items.begin(), Items.end(),[&Parent](auto I){return I->getName()==Parent;}); if(Item != Items.end()){ - auto NewItem = FeatureTreeItem::createFeatureTreeItem(Feature,*Item); + auto NewItem = FeatureTreeItem::createFeatureTreeItem(Feature); (*Item)->addChild(NewItem); Items.push_back(NewItem); return NewItem; diff --git a/tools/fm-editor/tree/FeatureTreeViewModel.h b/tools/fm-editor/tree/FeatureTreeViewModel.h index 72f6cadef..519d6f2f1 100644 --- a/tools/fm-editor/tree/FeatureTreeViewModel.h +++ b/tools/fm-editor/tree/FeatureTreeViewModel.h @@ -9,7 +9,7 @@ #include class FeatureTreeViewModel : public QAbstractItemModel { public: - FeatureTreeViewModel(vara::feature::FeatureModel* Model, QObject *Parent): QAbstractItemModel(Parent), Model(Model), RootItem(FeatureTreeItem::createFeatureTreeItem(Model->getRoot(), nullptr)) { + FeatureTreeViewModel(vara::feature::FeatureModel* Model, QObject *Parent): QAbstractItemModel(Parent), Model(Model), RootItem(FeatureTreeItem::createFeatureTreeItem(Model->getRoot())) { Items = RootItem->getChildrenRecursive(); Items.push_back(RootItem); } diff --git a/unittests/Feature/FeatureModelTransaction.cpp b/unittests/Feature/FeatureModelTransaction.cpp index f9490f2af..7e5422bde 100644 --- a/unittests/Feature/FeatureModelTransaction.cpp +++ b/unittests/Feature/FeatureModelTransaction.cpp @@ -104,8 +104,8 @@ TEST_F(FeatureModelTransactionCopyTest, addFeatureToModel) { size_t FMSizeBefore = FM->size(); auto FT = FeatureModelCopyTransaction::openTransaction(*FM); - FT.featureAddDialog(std::make_unique("ab"), - FM->getFeature("a")); + FT.featureAddDialogChild(std::make_unique("ab"), + FM->getFeature("a")); EXPECT_EQ(FMSizeBefore, FM->size()); EXPECT_TRUE(FM->getFeature("a")); @@ -134,8 +134,8 @@ TEST_F(FeatureModelTransactionCopyTest, addFeatureToModelThenAbort) { size_t FMSizeBefore = FM->size(); auto FT = FeatureModelCopyTransaction::openTransaction(*FM); - FT.featureAddDialog(std::make_unique("ab"), - FM->getFeature("a")); + FT.featureAddDialogChild(std::make_unique("ab"), + FM->getFeature("a")); EXPECT_EQ(FMSizeBefore, FM->size()); EXPECT_TRUE(FM->getFeature("a")); @@ -189,8 +189,8 @@ TEST_F(FeatureModelTransactionModifyTest, addFeatureToModel) { size_t FMSizeBefore = FM->size(); auto FT = FeatureModelModifyTransaction::openTransaction(*FM); - FT.featureAddDialog(std::make_unique("ab"), - FM->getFeature("a")); + FT.featureAddDialogChild(std::make_unique("ab"), + FM->getFeature("a")); EXPECT_EQ(FMSizeBefore, FM->size()); EXPECT_TRUE(FM->getFeature("a")); @@ -210,8 +210,8 @@ TEST_F(FeatureModelTransactionModifyTest, addFeatureToModelThenAboard) { size_t FMSizeBefore = FM->size(); auto FT = FeatureModelModifyTransaction::openTransaction(*FM); - FT.featureAddDialog(std::make_unique("ab"), - FM->getFeature("a")); + FT.featureAddDialogChild(std::make_unique("ab"), + FM->getFeature("a")); EXPECT_EQ(FMSizeBefore, FM->size()); EXPECT_TRUE(FM->getFeature("a")); From 50be685d43d1855d4aa8097fa6255f66eec32341 Mon Sep 17 00:00:00 2001 From: Nerum Date: Wed, 22 Feb 2023 13:49:19 +0100 Subject: [PATCH 028/106] Add the ability to remove features from the model --- tools/fm-editor/FeatureModelEditor.cpp | 54 +++---- tools/fm-editor/FeatureModelEditor.h | 5 +- tools/fm-editor/FeatureModelEditor.ui | 7 - tools/fm-editor/Utils.h | 35 +++++ tools/fm-editor/graph/FeatureEdge.cpp | 4 + tools/fm-editor/graph/FeatureEdge.h | 1 + tools/fm-editor/graph/FeatureModelGraph.cpp | 25 ++++ tools/fm-editor/graph/FeatureModelGraph.h | 2 + tools/fm-editor/graph/FeatureNode.cpp | 19 ++- tools/fm-editor/graph/FeatureNode.h | 5 +- tools/fm-editor/tree/FeatureTreeItem.cpp | 33 ++--- tools/fm-editor/tree/FeatureTreeItem.h | 17 ++- tools/fm-editor/tree/FeatureTreeViewModel.cpp | 133 ++++++++++++------ tools/fm-editor/tree/FeatureTreeViewModel.h | 11 ++ 14 files changed, 244 insertions(+), 107 deletions(-) create mode 100644 tools/fm-editor/Utils.h diff --git a/tools/fm-editor/FeatureModelEditor.cpp b/tools/fm-editor/FeatureModelEditor.cpp index f9485fcf7..6c93ad1fc 100644 --- a/tools/fm-editor/FeatureModelEditor.cpp +++ b/tools/fm-editor/FeatureModelEditor.cpp @@ -29,8 +29,6 @@ FeatureModelEditor::FeatureModelEditor(QWidget *Parent) Highliter->setCurrentLanguage(QSourceHighlite::QSourceHighliter::CodeCpp); QObject::connect(Ui->loadModel, &QPushButton::pressed, this, &FeatureModelEditor::loadGraph); - QObject::connect(Ui->findModel, &QPushButton::pressed, this, - &FeatureModelEditor::findModel); QObject::connect(Ui->actionAddFeature,&QAction::triggered, this, &FeatureModelEditor::featureAddDialog); connect(Ui->actionSave,&QAction::triggered,this,&FeatureModelEditor::save); @@ -46,10 +44,10 @@ void FeatureModelEditor::loadFeature(const vara::feature::Feature *Feature) { } ///Get a Feature from an Index of the TreeView and display its information. -void FeatureModelEditor::loadFeaturefromIndex(const QModelIndex &Index) { +void FeatureModelEditor::loadFeatureFromIndex(const QModelIndex &Index) { if(Index.isValid()){ auto Item = - static_cast(Index.internalPointer()); + static_cast(Index.internalPointer())->child(Index.row()); if(Item->getKind() == vara::feature::FeatureTreeNode::NodeKind::NK_FEATURE){ loadFeature(static_cast(Item)->getItem()); } @@ -72,8 +70,12 @@ void FeatureModelEditor::loadGraph() { ModelPath = Ui->ModelFile->text(); FeatureModel = vara::feature::loadFeatureModel(ModelPath.toStdString()); if(!FeatureModel){ - //Return if no model at Path - return; + QString const Path = QFileDialog::getOpenFileName(this,tr("Open Model"),"/home",tr("XML files (*.xml)")); + if(Path.isEmpty()){ + return ; + } + Ui->ModelFile->setText(Path); + FeatureModel = vara::feature::loadFeatureModel(Path.toStdString()); } //create Graph view buildGraph(); @@ -93,10 +95,12 @@ void FeatureModelEditor::buildTree() { for(auto Item: TreeModel->getItems()){ connect(Item, &FeatureTreeItem::inspectSource, this, &FeatureModelEditor::inspectFeatureSources); - connect(Item, &FeatureTreeItem::addCild, this, + connect(Item, &FeatureTreeItem::addChildFeature, this, &FeatureModelEditor::featureAddDialogChild); + connect(Item, &FeatureTreeItem::removeFeature, this, &FeatureModelEditor::removeFeature); } - connect(TreeView,&QTreeView::pressed,this,&FeatureModelEditor::loadFeaturefromIndex); + connect(TreeView,&QTreeView::pressed,this, + &FeatureModelEditor::loadFeatureFromIndex); TreeView->setModel(TreeModel.get()); TreeView->setContextMenuPolicy(Qt::CustomContextMenu); connect(TreeView, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(createTreeContextMenu(const QPoint &))); @@ -140,6 +144,13 @@ void FeatureModelEditor::featureAddDialogChild(Feature* ParentFeature) { } } +void FeatureModelEditor::removeFeature(bool Recursive,Feature* Feature) { + TreeModel->deleteFeatureItem(Recursive,Feature); + Graph->deleteNode(Recursive,Feature); + Ui->featureInfo->clear(); + vara::feature::removeFeature(*FeatureModel,Feature,Recursive); +} + ///Save the current State of the Feature Model void FeatureModelEditor::save() { @@ -150,13 +161,6 @@ void FeatureModelEditor::save() { -///Spawn File Selection popup to get a Feature Model -void FeatureModelEditor::findModel() { - QString const Path = QFileDialog::getOpenFileName(this,tr("Open Model"),"/home",tr("XML files (*.xml)")); - Ui->ModelFile->setText(Path); -} - - /// Loead the source files of the Feature to be selectable by the user and set the Feature as CurrentFeature. /// \param Feature void FeatureModelEditor::inspectFeatureSources(vara::feature::Feature *Feature) { @@ -175,7 +179,16 @@ void FeatureModelEditor::inspectFeatureSources(vara::feature::Feature *Feature) Ui->sources->setPlaceholderText("Select File"); } } +/// Create the Context menu for inspecting sources in the tree view +/// \param Pos Position of the cursor used to find the clicked item +void FeatureModelEditor::createTreeContextMenu(const QPoint &Pos) { + auto Index = TreeView->indexAt(Pos); + if(Index.isValid()){ + FeatureTreeItem* Item = static_cast(Index.internalPointer())->child(Index.row()); + Item->contextMenu(TreeView->mapToGlobal(Pos)); + } +} /// Load the selected file into the textedit and mark the sources of the selected feature void FeatureModelEditor::loadSource(const QString &RelativePath){ @@ -218,17 +231,6 @@ void FeatureModelEditor::markLocation( Cursor.setCharFormat(Fmt); } -/// Create the Context menu for inspecting sources in the tree view -/// \param Pos Position of the cursor used to find the clicked item -void FeatureModelEditor::createTreeContextMenu(const QPoint &Pos) { - auto Index = TreeView->indexAt(Pos); - if(Index.isValid()){ - FeatureTreeItem* Item = static_cast(Index.internalPointer()); - Item->contextMenu(TreeView->mapToGlobal(Pos)); - } - -} - ///Load a sourcefile to then add a location from it void FeatureModelEditor::addSourceFile(){ if(!Repository.isEmpty()) { diff --git a/tools/fm-editor/FeatureModelEditor.h b/tools/fm-editor/FeatureModelEditor.h index 8da967dfc..6b89268aa 100644 --- a/tools/fm-editor/FeatureModelEditor.h +++ b/tools/fm-editor/FeatureModelEditor.h @@ -41,17 +41,18 @@ public slots: void featureAddDialogChild(vara::feature::Feature* = nullptr); //void addNode(const QString& Name, FeatureNode *Parent); void loadSource(const QString &RelativePath); - void findModel(); void createTreeContextMenu(const QPoint &Pos); void addSourceFile(); - void loadFeaturefromIndex(const QModelIndex &Index); + void loadFeatureFromIndex(const QModelIndex &Index); void save(); void featureAddDialog(); + void removeFeature(bool Recursive, vara::feature::Feature* Feature); private: void clean(); void buildGraph(); void buildTree(); void markLocation(vara::feature::FeatureSourceRange &Location) const; + }; #endif // VARA_FEATURE_FEATUREMODELEDITOR_H diff --git a/tools/fm-editor/FeatureModelEditor.ui b/tools/fm-editor/FeatureModelEditor.ui index e8861e768..61efa65f5 100644 --- a/tools/fm-editor/FeatureModelEditor.ui +++ b/tools/fm-editor/FeatureModelEditor.ui @@ -127,13 +127,6 @@ - - - - Find - - - diff --git a/tools/fm-editor/Utils.h b/tools/fm-editor/Utils.h new file mode 100644 index 000000000..f727f1b15 --- /dev/null +++ b/tools/fm-editor/Utils.h @@ -0,0 +1,35 @@ +// +// Created by simon on 20.02.23. +// + +#ifndef VARA_FEATURE_UTILS_H +#define VARA_FEATURE_UTILS_H + +#include +template +struct ActionBuilder{ + ActionBuilder(QMenu* Menu,T* Receiver) : Menu(Menu), Receiver(Receiver) {} + template + void addActions(std::pair Action,std::pair... Actions) { + auto *A = new QAction(Action.first,Receiver); + QObject::connect(A,&QAction::triggered,Receiver,Action.second); + Menu->addAction(A); + addActions(Actions...); + } + void addActions() {} +private: + QMenu* Menu; + T* Receiver; +}; + + +template +QMenu* buildMenu(T* Receiver,std::pair... Actions ) { + auto Menu = new QMenu; + ActionBuilder Builder(Menu,Receiver); + Builder.addActions(Actions...); + return Menu; +} + + +#endif // VARA_FEATURE_UTILS_H diff --git a/tools/fm-editor/graph/FeatureEdge.cpp b/tools/fm-editor/graph/FeatureEdge.cpp index 39569df1b..07bf7da6f 100644 --- a/tools/fm-editor/graph/FeatureEdge.cpp +++ b/tools/fm-editor/graph/FeatureEdge.cpp @@ -65,3 +65,7 @@ void FeatureEdge::paint(QPainter *Painter, Painter->setBrush(QBrush(Target->isOptional()?Qt::white:Qt::black)); Painter->drawEllipse(TargetPoint,4,4); } +void FeatureEdge::setSourceNode(FeatureNode *Node) { + Source = Node; + Node->addChildEdge(this); +} diff --git a/tools/fm-editor/graph/FeatureEdge.h b/tools/fm-editor/graph/FeatureEdge.h index b4b51bf86..acc2555ba 100644 --- a/tools/fm-editor/graph/FeatureEdge.h +++ b/tools/fm-editor/graph/FeatureEdge.h @@ -10,6 +10,7 @@ class FeatureEdge : public QGraphicsItem{ [[nodiscard]] FeatureNode *sourceNode() const; [[nodiscard]] FeatureNode *targetNode() const; + void setSourceNode(FeatureNode* Node); void adjust(); enum { Type = UserType + 2 }; [[nodiscard]] int type() const override { return Type; } diff --git a/tools/fm-editor/graph/FeatureModelGraph.cpp b/tools/fm-editor/graph/FeatureModelGraph.cpp index c5e870012..410b40cf5 100644 --- a/tools/fm-editor/graph/FeatureModelGraph.cpp +++ b/tools/fm-editor/graph/FeatureModelGraph.cpp @@ -171,3 +171,28 @@ FeatureNode* FeatureModelGraph::getNode(std::string Name) { return nullptr; } +void FeatureModelGraph::deleteNode(bool Recursive, FeatureNode* Node) { + auto *Parent = Node->parent()->sourceNode(); + if(!Recursive){ + for(auto *Child: Node->children()){ + Child->setSourceNode(Parent); + } + + Node->children().clear(); + }else { + for(auto *Child: Node->children()){ + deleteNode(true,Child->targetNode()); + } + } + Parent->removeChild(Node); + scene()->removeItem(Node); + scene()->removeItem(Node->parent()); + + Nodes.erase(std::find_if(Nodes.begin(), Nodes.end(),[Node](auto &N){return N.get() == Node;})); + +} +void FeatureModelGraph::deleteNode(bool Recursive, + vara::feature::Feature *Feature) { + auto * Node = getNode(Feature->getName().str()); + deleteNode(Recursive,Node); +} diff --git a/tools/fm-editor/graph/FeatureModelGraph.h b/tools/fm-editor/graph/FeatureModelGraph.h index 52d764b45..30525c9d3 100644 --- a/tools/fm-editor/graph/FeatureModelGraph.h +++ b/tools/fm-editor/graph/FeatureModelGraph.h @@ -16,6 +16,8 @@ class FeatureModelGraph : public QGraphicsView { void itemMoved(); FeatureNode* getNode(std::string Name); FeatureNode*addNode(vara::feature::Feature *Feature,FeatureNode* Parent); + void deleteNode(bool Recursive, vara::feature::Feature* Feature); + void deleteNode(bool Recursive, FeatureNode* Node); public slots: void zoomIn(); void zoomOut(); diff --git a/tools/fm-editor/graph/FeatureNode.cpp b/tools/fm-editor/graph/FeatureNode.cpp index 7111e3da6..447c87d9c 100644 --- a/tools/fm-editor/graph/FeatureNode.cpp +++ b/tools/fm-editor/graph/FeatureNode.cpp @@ -28,11 +28,11 @@ void FeatureNode::setParentEdge(FeatureEdge *Edge) { Edge->adjust(); } -std::vector FeatureNode::children() const { +std::vector FeatureNode::children() { return ChildEdges; } -FeatureEdge * FeatureNode::parent() const { +FeatureEdge * FeatureNode::parent() { return ParentEdge; } @@ -85,6 +85,13 @@ QVariant FeatureNode::itemChange(QGraphicsItem::GraphicsItemChange Change, return QGraphicsItem::itemChange(Change, Value); } +void FeatureNode::removeChild(FeatureNode* Child){ + auto EdgePos = std::find_if(ChildEdges.begin(), ChildEdges.end(), [Child](auto *Edge){return Edge->targetNode()==Child;}); + if(EdgePos!=ChildEdges.end()){ + ChildEdges.erase(EdgePos); + } +} + void FeatureNode::mousePressEvent(QGraphicsSceneMouseEvent *Event) { update(); QGraphicsItem::mousePressEvent(Event); @@ -114,22 +121,22 @@ int FeatureNode::width() const { } int FeatureNode::childrenWidth() const { - if(children().empty()){ + if(ChildEdges.empty()){ return width(); } int Result = 0; - for (auto *Child : children()){ + for (auto *Child : ChildEdges){ Result +=Child->targetNode()->childrenWidth(); } return std::max(Result,width()); } int FeatureNode::childrenDepth() const{ - if(children().empty()){ + if(ChildEdges.empty()){ return 1; } int MaxDepth = 0; - for(auto *Child: children()){ + for(auto *Child: ChildEdges){ int const ChildDepth = Child->targetNode()->childrenDepth(); if(ChildDepth +1> MaxDepth){ MaxDepth = ChildDepth +1; diff --git a/tools/fm-editor/graph/FeatureNode.h b/tools/fm-editor/graph/FeatureNode.h index d4b1e8752..2afb5d13b 100644 --- a/tools/fm-editor/graph/FeatureNode.h +++ b/tools/fm-editor/graph/FeatureNode.h @@ -14,12 +14,13 @@ class FeatureNode : public QObject,public QGraphicsItem{ public: + void removeChild(FeatureNode *Child); FeatureNode( vara::feature::Feature *Feature); [[nodiscard]] int width() const; void addChildEdge(FeatureEdge *Edge); void setParentEdge(FeatureEdge *Edge); - [[nodiscard]] std::vector children() const; - [[nodiscard]] FeatureEdge * parent() const; + [[nodiscard]] std::vector children(); + [[nodiscard]] FeatureEdge * parent(); [[nodiscard]] int childrenWidth() const; [[nodiscard]] int childrenDepth() const; enum { Type = UserType + 1 }; diff --git a/tools/fm-editor/tree/FeatureTreeItem.cpp b/tools/fm-editor/tree/FeatureTreeItem.cpp index cc84dfba7..af4e1a8bc 100644 --- a/tools/fm-editor/tree/FeatureTreeItem.cpp +++ b/tools/fm-editor/tree/FeatureTreeItem.cpp @@ -4,6 +4,7 @@ #include "FeatureTreeItem.h" #include #include +#include "../Utils.h" QVariant numericValue(vara::feature::Feature* Item) { if(Item->getKind()==vara::feature::Feature::FeatureKind::FK_NUMERIC){ auto *NumItem = dynamic_cast(Item); @@ -38,14 +39,6 @@ QVariant locationString(vara::feature::Feature* Item){ } return QString::fromStdString(StrS.str()); } - -QVariant crossTreeConstraintString(vara::feature::Feature* Item){ - std::stringstream StrS; - for(auto Constraint:Item->constraints()){ - StrS << Constraint->toString(); - } - return QString::fromStdString(StrS.str()); -} FeatureTreeItem* FeatureTreeItem::createFeatureTreeItem( vara::feature::FeatureTreeNode *Item) { if(Item->getKind() == vara::feature::FeatureTreeNode::NodeKind::NK_RELATIONSHIP){ @@ -86,15 +79,23 @@ void FeatureTreeItemFeature::inspect() { emit(inspectSource(Item)); } void FeatureTreeItemFeature::contextMenu(QPoint Pos) { - auto *Menu = new QMenu; - auto *Inspect = new QAction("Inspect Sources", this); - auto *AddChild = new QAction("Add Child", this); - Menu->addAction(Inspect); - Menu->addAction(AddChild); + auto* Menu =buildMenu(this, + std::pair(QString("Inspect Sources"),&FeatureTreeItemFeature::inspect), + std::pair(QString("Add Child"),&FeatureTreeItemFeature::addChild), + std::pair(QString("Remove"),&FeatureTreeItemFeature::remove)); + //TODO Make recursive Removal work Menu->popup(Pos); - connect(Inspect, &QAction::triggered, this, &FeatureTreeItemFeature::inspect); - connect(AddChild, &QAction::triggered, this, &FeatureTreeItemFeature::addChild); } + + +void FeatureTreeItemFeature::remove() { + emit(removeFeature(false,Item)); +} + +void FeatureTreeItemFeature::removeRecursive() { + emit(removeFeature(true, Item)); +} + void FeatureTreeItemFeature::addChild() { - emit(addCild(Item)); + emit(addChildFeature(Item)); } diff --git a/tools/fm-editor/tree/FeatureTreeItem.h b/tools/fm-editor/tree/FeatureTreeItem.h index 8bed13e04..f30a41f7e 100644 --- a/tools/fm-editor/tree/FeatureTreeItem.h +++ b/tools/fm-editor/tree/FeatureTreeItem.h @@ -36,17 +36,19 @@ class FeatureTreeItem: public QObject { return Parent; } void addChild(FeatureTreeItem* Child); + std::vector& getChildren() {return Children;} [[nodiscard]] virtual int columnCount() const = 0; [[nodiscard]] virtual QVariant data(int Column) const = 0; FeatureTreeItem static *createFeatureTreeItem(vara::feature::FeatureTreeNode* Item); - bool booleanColumn(int Column) {return false;} + static bool booleanColumn(int Column) {return false;} virtual void contextMenu(QPoint Pos) = 0; vara::feature::FeatureTreeNode::NodeKind getKind() {return Kind;} virtual string getName() {return "";}; void setParent(FeatureTreeItem*ParentItem) {this->Parent = ParentItem;} signals: void inspectSource(vara::feature::Feature *Feature); - void addCild(vara::feature::Feature *Feature); + void addChildFeature(vara::feature::Feature *Feature); + void removeFeature(bool Recursive,vara::feature::Feature *Feature); protected: FeatureTreeItem(vara::feature::FeatureTreeNode* Item ,vara::feature::FeatureTreeNode::NodeKind Kind): Kind(Kind) { for(auto *Child : Item->children()){ @@ -62,10 +64,12 @@ class FeatureTreeItem: public QObject { } } -private: - const vara::feature::FeatureTreeNode::NodeKind Kind; FeatureTreeItem* Parent = nullptr; + std::vector Children = {}; + +private: + const vara::feature::FeatureTreeNode::NodeKind Kind; }; @@ -76,16 +80,19 @@ virtual ~FeatureTreeItemFeature() = default; FeatureTreeItemFeature(vara::feature::Feature* Item): FeatureTreeItem(Item,vara::feature::FeatureTreeNode::NodeKind::NK_FEATURE), Item(Item) {} [[nodiscard]] QVariant data(int Column) const override; [[nodiscard]] int columnCount() const override {return 5;} - bool booleanColumn(int Column) {return Column==1;} + static bool booleanColumn(int Column) {return Column==1;} void contextMenu(QPoint Pos) override; const vara::feature::Feature* getItem() const {return Item;} string getName() override {return Item->getName().str();} public slots: void inspect(); void addChild(); + void removeRecursive(); + void remove(); private: vara::feature::Feature* Item; + }; diff --git a/tools/fm-editor/tree/FeatureTreeViewModel.cpp b/tools/fm-editor/tree/FeatureTreeViewModel.cpp index 5e1694b4b..ab996c21d 100644 --- a/tools/fm-editor/tree/FeatureTreeViewModel.cpp +++ b/tools/fm-editor/tree/FeatureTreeViewModel.cpp @@ -4,60 +4,65 @@ #include "FeatureTreeViewModel.h" -QModelIndex FeatureTreeViewModel::index(int Row, int Column, const QModelIndex &Parent) const{ - FeatureTreeItem* ParentItem; +QModelIndex FeatureTreeViewModel::index(int Row, int Column, + const QModelIndex &Parent) const { + FeatureTreeItem *ParentItem; + if (!Parent.isValid()) { ParentItem = RootItem; } else { - ParentItem = static_cast(Parent.internalPointer()); + ParentItem = static_cast(Parent.internalPointer())->child(Parent.row()); + } + if(ParentItem->childCount() <=0){ + return {}; } - auto *ChildItem= ParentItem->child(Row); - if(ChildItem) { - return createIndex(Row,Column,ChildItem); + auto *ChildItem = ParentItem->child(Row); + if (ChildItem) { + return createIndex(Row, Column, ParentItem); } return {}; } QModelIndex FeatureTreeViewModel::parent(const QModelIndex &Child) const { - if(!Child.isValid()){ + if (!Child.isValid()) { return {}; } - auto* ChildItem = static_cast(Child.internalPointer()); - auto* ParentItem = ChildItem->parent(); - if(ParentItem) { - return createIndex(ParentItem->row(),0,ParentItem); -} + auto *ParentItem = static_cast(Child.internalPointer()); + if (ParentItem && ParentItem != RootItem) { + return createIndex(ParentItem->row(), 0, ParentItem->parent()); + } return {}; } int FeatureTreeViewModel::rowCount(const QModelIndex &Parent) const { - if(Parent.column() > 0) { + if (Parent.column() > 0) { return 0; -} - FeatureTreeItem* ParentItem; - if (!Parent.isValid()){ + } + FeatureTreeItem *ParentItem; + if (!Parent.isValid()) { ParentItem = RootItem; } else { - ParentItem = static_cast(Parent.internalPointer()); + ParentItem = static_cast(Parent.internalPointer())->child(Parent.row()); } return ParentItem->childCount(); } int FeatureTreeViewModel::columnCount(const QModelIndex &Parent) const { - if(Parent.isValid()) { - return static_cast(Parent.internalPointer())->columnCount(); -} + if (Parent.isValid()) { + auto Item = static_cast(Parent.internalPointer())->child(Parent.row()); + return Item->columnCount(); + } return RootItem->columnCount(); } QVariant FeatureTreeViewModel::data(const QModelIndex &Index, int Role) const { - if(!Index.isValid() || Role!=Qt::DisplayRole) { - return {}; -} - auto* Item = static_cast(Index.internalPointer()); + if (!Index.isValid() || Role != Qt::DisplayRole) { + return {}; + } + auto *Item = static_cast(Index.internalPointer())->child(Index.row()); return Item->data(Index.column()); } Qt::ItemFlags FeatureTreeViewModel::flags(const QModelIndex &Index) const { - if(Index.isValid()){ - auto *Item = static_cast(Index.internalPointer()); - if(Item->booleanColumn(Index.column())){ + if (Index.isValid()) { + auto *Item = static_cast(Index.internalPointer())->child(Index.row()); + if (Item->booleanColumn(Index.column())) { return Qt::ItemIsUserCheckable | Qt::ItemIsSelectable | Qt::ItemIsEnabled; } } @@ -66,28 +71,70 @@ Qt::ItemFlags FeatureTreeViewModel::flags(const QModelIndex &Index) const { QVariant FeatureTreeViewModel::headerData(int Section, Qt::Orientation Orientation, int Role) const { - if(Orientation == Qt::Orientation::Horizontal && Role == Qt::DisplayRole) { - switch (Section) { - case 0:return QString("Feature"); - case 1:return QString("Optional"); - case 2:return QString("NumericValues"); - case 3:return QString("Locations"); - case 4:return QString("ConfigurationOption"); - default:return QString("Todo"); + if (Orientation == Qt::Orientation::Horizontal && Role == Qt::DisplayRole) { + switch (Section) { + case 0: + return QString("Feature"); + case 1: + return QString("Optional"); + case 2: + return QString("NumericValues"); + case 3: + return QString("Locations"); + case 4: + return QString("ConfigurationOption"); + default: + return QString("Todo"); } -} -return {}; + } + return {}; } std::vector FeatureTreeViewModel::getItems() { -return Items; + return Items; } -FeatureTreeItem* FeatureTreeViewModel::addFeature(vara::feature::Feature *Feature, std::string Parent) { -auto Item = std::find_if(Items.begin(), Items.end(),[&Parent](auto I){return I->getName()==Parent;}); -if(Item != Items.end()){ +FeatureTreeItem * +FeatureTreeViewModel::addFeature(vara::feature::Feature *Feature, + std::string Parent) { + auto Item = getItem(Parent); + if (Item) { auto NewItem = FeatureTreeItem::createFeatureTreeItem(Feature); - (*Item)->addChild(NewItem); + Item->addChild(NewItem); Items.push_back(NewItem); return NewItem; + } + return nullptr; +} + +void FeatureTreeViewModel::deleteFeatureItem(bool Recursive, + vara::feature::Feature *Feature) { + emit(layoutAboutToBeChanged()); + auto Item = getItem(Feature->getName().str()); + if (Item) { + deleteItem(Recursive,Item); + } + emit(layoutChanged()); } -return nullptr; + +void FeatureTreeViewModel::deleteItem(bool Recursive, FeatureTreeItem *Item) { + + if (!Recursive) { + auto *Parent = Item->parent(); + if (Parent) { + for (auto *Child : Item->getChildren()) { + Parent->addChild(Child); + } + auto ItemPos = std::find(Parent->getChildren().begin(), + Parent->getChildren().end(), Item); + Parent->getChildren().erase(ItemPos); + } + } + if(Recursive) { + for (auto *Child : Item->getChildren()) { + deleteItem(Recursive,Child); + } + } + Items.erase(std::find(Items.begin(), Items.end(), Item)); + emit(layoutAboutToBeChanged()); + delete Item; + emit(layoutChanged()); } diff --git a/tools/fm-editor/tree/FeatureTreeViewModel.h b/tools/fm-editor/tree/FeatureTreeViewModel.h index 519d6f2f1..74c193adc 100644 --- a/tools/fm-editor/tree/FeatureTreeViewModel.h +++ b/tools/fm-editor/tree/FeatureTreeViewModel.h @@ -25,10 +25,21 @@ class FeatureTreeViewModel : public QAbstractItemModel { [[nodiscard]] Qt::ItemFlags flags(const QModelIndex &Index) const override; [[nodiscard]] QVariant headerData(int Section, Qt::Orientation Orientation, int Role = Qt::DisplayRole) const override; FeatureTreeItem* addFeature(vara::feature::Feature* Item,string Parent); + void deleteFeatureItem(bool Recursive,vara::feature::Feature* Feature); + void deleteItem(bool Recursive, FeatureTreeItem* Item); + FeatureTreeItem* getItem(string Name) { + auto Item = std::find_if(Items.begin(), Items.end(),[&Name](auto I){return I->getName()== Name;}); + if(Item != Items.end()) { + return *Item; + } + return nullptr; + } +// bool removeRows(int row, int count, const QModelIndex &parent) override; private: vara::feature::FeatureModel* Model; FeatureTreeItem* RootItem; std::vector Items; + }; #endif // VARA_FEATURE_FEATURETREEVIEWMODEL_H From 8e4b0e3e09939bf3fbb890e1c89ae2ba8bf93a40 Mon Sep 17 00:00:00 2001 From: Nerum Date: Wed, 22 Feb 2023 14:07:20 +0100 Subject: [PATCH 029/106] remove Changes accidentally made by merging --- include/vara/Feature/FeatureModel.h | 2 +- include/vara/Feature/FeatureSourceRange.h | 7 ------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/include/vara/Feature/FeatureModel.h b/include/vara/Feature/FeatureModel.h index 27f1b3cbf..7c528fc56 100644 --- a/include/vara/Feature/FeatureModel.h +++ b/include/vara/Feature/FeatureModel.h @@ -186,7 +186,7 @@ class FeatureModel { FeatureMapIterator(FeatureMapTy::const_iterator MapIter) : MapIter(MapIter) {} - Feat>>>>>>> vara-devureMapIterator(const FeatureMapIterator &) = default; + FeatureMapIterator(const FeatureMapIterator &) = default; FeatureMapIterator &operator=(const FeatureMapIterator &) = delete; FeatureMapIterator(FeatureMapIterator &&) = default; FeatureMapIterator &operator=(FeatureMapIterator &&) = delete; diff --git a/include/vara/Feature/FeatureSourceRange.h b/include/vara/Feature/FeatureSourceRange.h index 9a0ed00ab..56dfdc178 100644 --- a/include/vara/Feature/FeatureSourceRange.h +++ b/include/vara/Feature/FeatureSourceRange.h @@ -225,13 +225,6 @@ class FeatureSourceRange { return RevisionRange.has_value() ? &RevisionRange.value() : nullptr; } - [[nodiscard]] bool hasRevisionRange() const { - return RevisionRange.hasValue(); - } - [[nodiscard]] FeatureRevisionRange *revisionRange() { - return RevisionRange.hasValue() ? RevisionRange.getPointer() : nullptr; - } - [[nodiscard]] std::string toString() const { std::stringstream StrS; StrS << Path.string(); From 248e9287bca9ed9f97260aa760232fb360348512 Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 22 Feb 2023 14:16:29 +0100 Subject: [PATCH 030/106] Apply suggestions from flangformater Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- include/vara/Feature/FeatureModel.h | 1 - .../vara/Feature/FeatureModelTransaction.h | 9 +- tools/fm-editor/FeatureAddDialog.cpp | 3 +- tools/fm-editor/FeatureAddDialog.h | 6 +- tools/fm-editor/FeatureModelEditor.cpp | 253 ++++++++++-------- tools/fm-editor/FeatureModelEditor.h | 18 +- 6 files changed, 157 insertions(+), 133 deletions(-) diff --git a/include/vara/Feature/FeatureModel.h b/include/vara/Feature/FeatureModel.h index 7c528fc56..a23b8ef16 100644 --- a/include/vara/Feature/FeatureModel.h +++ b/include/vara/Feature/FeatureModel.h @@ -232,7 +232,6 @@ class FeatureModel { //===--------------------------------------------------------------------===// // Constraints - private: /// \brief Base for different constraint kinds (boolean, non-boolean, etc.). class FeatureModelConstraint { diff --git a/include/vara/Feature/FeatureModelTransaction.h b/include/vara/Feature/FeatureModelTransaction.h index 31fe11a4e..ec126ffba 100644 --- a/include/vara/Feature/FeatureModelTransaction.h +++ b/include/vara/Feature/FeatureModelTransaction.h @@ -978,14 +978,14 @@ class FeatureModelCopyTransactionBase { } auto ParentFeature = dynamic_cast(Parent); ParentFeature = FM->getFeature(ParentFeature->getName()); - Relationship* Base = *ParentFeature->getChildren(0).begin(); - for(i=i-1;i<0;i--){ + Relationship *Base = *ParentFeature->getChildren(0).begin(); + for (i = i - 1; i < 0; i--) { Base = *Base->getChildren(0).begin(); } return Base; } - return FM->getFeature(dynamic_cast(F).getName()); + return FM->getFeature(dynamic_cast(F).getName()); } std::unique_ptr FM; @@ -1028,7 +1028,8 @@ class FeatureModelModifyTransactionBase { //===--------------------------------------------------------------------===// // Modifications - void addFeatureImpl(std::unique_ptr NewFeature, FeatureTreeNode *Parent) { + void addFeatureImpl(std::unique_ptr NewFeature, + FeatureTreeNode *Parent) { assert(FM && "FeatureModel is null."); Modifications.push_back( diff --git a/tools/fm-editor/FeatureAddDialog.cpp b/tools/fm-editor/FeatureAddDialog.cpp index 669fd72a3..b4a5b1beb 100644 --- a/tools/fm-editor/FeatureAddDialog.cpp +++ b/tools/fm-editor/FeatureAddDialog.cpp @@ -7,7 +7,8 @@ #include "graph/FeatureNode.h" using vara::feature::Feature; using vara::feature::FeatureModel; -FeatureAddDialog::FeatureAddDialog(FeatureModelGraph *Graph, QWidget *Parent, Feature* ParentFeature) +FeatureAddDialog::FeatureAddDialog(FeatureModelGraph *Graph, QWidget *Parent, + Feature *ParentFeature) : QDialog(Parent) { setupUi(this); NodeNames = QStringList(); diff --git a/tools/fm-editor/FeatureAddDialog.h b/tools/fm-editor/FeatureAddDialog.h index 09abdd238..e6054edee 100644 --- a/tools/fm-editor/FeatureAddDialog.h +++ b/tools/fm-editor/FeatureAddDialog.h @@ -12,7 +12,8 @@ class FeatureAddDialog : public QDialog, public Ui::Add { Q_OBJECT public: - FeatureAddDialog(FeatureModelGraph *Graph, QWidget *Parent, vara::feature::Feature* ParentFeature = nullptr); + FeatureAddDialog(FeatureModelGraph *Graph, QWidget *Parent, + vara::feature::Feature *ParentFeature = nullptr); QString getName(); QString getParent(); QString getOutpuString(); @@ -21,11 +22,10 @@ class FeatureAddDialog : public QDialog, public Ui::Add { bool isOptional(); public slots: void featureType(int index); -private: +private: QStringList NodeNames; - vara::feature::StepFunction::StepOperation getStepOperation(); }; diff --git a/tools/fm-editor/FeatureModelEditor.cpp b/tools/fm-editor/FeatureModelEditor.cpp index 6c93ad1fc..f390d1625 100644 --- a/tools/fm-editor/FeatureModelEditor.cpp +++ b/tools/fm-editor/FeatureModelEditor.cpp @@ -15,45 +15,47 @@ #include namespace fs = std::filesystem; using vara::feature::FeatureModel; -using Transaction = vara::feature::FeatureModelTransaction; +using Transaction = vara::feature::FeatureModelTransaction< + vara::feature::detail::ModifyTransactionMode>; using vara::feature::Feature; - - FeatureModelEditor::FeatureModelEditor(QWidget *Parent) : QMainWindow(Parent), Ui(new Ui::FeatureModelEditor) { Ui->setupUi(this); Ui->textEdit->setReadOnly(true); - auto *Highliter = new QSourceHighlite::QSourceHighliter(Ui->textEdit->document()); + auto *Highliter = + new QSourceHighlite::QSourceHighliter(Ui->textEdit->document()); Highliter->setCurrentLanguage(QSourceHighlite::QSourceHighliter::CodeCpp); QObject::connect(Ui->loadModel, &QPushButton::pressed, this, &FeatureModelEditor::loadGraph); - QObject::connect(Ui->actionAddFeature,&QAction::triggered, this, + QObject::connect(Ui->actionAddFeature, &QAction::triggered, this, &FeatureModelEditor::featureAddDialog); - connect(Ui->actionSave,&QAction::triggered,this,&FeatureModelEditor::save); - connect(Ui->addSource,&QPushButton::pressed, this,&FeatureModelEditor::addSource); - connect(Ui->addSourceFile,&QPushButton::pressed, this,&FeatureModelEditor::addSourceFile); + connect(Ui->actionSave, &QAction::triggered, this, &FeatureModelEditor::save); + connect(Ui->addSource, &QPushButton::pressed, this, + &FeatureModelEditor::addSource); + connect(Ui->addSourceFile, &QPushButton::pressed, this, + &FeatureModelEditor::addSourceFile); } -///Display the information of a Feature +/// Display the information of a Feature void FeatureModelEditor::loadFeature(const vara::feature::Feature *Feature) { - auto FeatureString = - Feature->toString(); + auto FeatureString = Feature->toString(); Ui->featureInfo->setText(QString::fromStdString(FeatureString)); } -///Get a Feature from an Index of the TreeView and display its information. +/// Get a Feature from an Index of the TreeView and display its information. void FeatureModelEditor::loadFeatureFromIndex(const QModelIndex &Index) { - if(Index.isValid()){ - auto Item = - static_cast(Index.internalPointer())->child(Index.row()); - if(Item->getKind() == vara::feature::FeatureTreeNode::NodeKind::NK_FEATURE){ - loadFeature(static_cast(Item)->getItem()); - } + if (Index.isValid()) { + auto Item = static_cast(Index.internalPointer()) + ->child(Index.row()); + if (Item->getKind() == + vara::feature::FeatureTreeNode::NodeKind::NK_FEATURE) { + loadFeature(static_cast(Item)->getItem()); + } } } -///Clear all Fields that should be emptied when loading a new Model +/// Clear all Fields that should be emptied when loading a new Model void FeatureModelEditor::clean() { SavePath.clear(); Repository.clear(); @@ -64,20 +66,21 @@ void FeatureModelEditor::clean() { Ui->featureInfo->clear(); } -///Load the Feature Model at the Path in ModelFile field and build the Views +/// Load the Feature Model at the Path in ModelFile field and build the Views void FeatureModelEditor::loadGraph() { clean(); ModelPath = Ui->ModelFile->text(); FeatureModel = vara::feature::loadFeatureModel(ModelPath.toStdString()); - if(!FeatureModel){ - QString const Path = QFileDialog::getOpenFileName(this,tr("Open Model"),"/home",tr("XML files (*.xml)")); - if(Path.isEmpty()){ - return ; - } - Ui->ModelFile->setText(Path); - FeatureModel = vara::feature::loadFeatureModel(Path.toStdString()); + if (!FeatureModel) { + QString const Path = QFileDialog::getOpenFileName( + this, tr("Open Model"), "/home", tr("XML files (*.xml)")); + if (Path.isEmpty()) { + return; + } + Ui->ModelFile->setText(Path); + FeatureModel = vara::feature::loadFeatureModel(Path.toStdString()); } - //create Graph view + // create Graph view buildGraph(); // create Tree View buildTree(); @@ -88,25 +91,28 @@ void FeatureModelEditor::loadGraph() { Ui->actionAddFeature->setEnabled(true); } -///Build the Treeview +/// Build the Treeview void FeatureModelEditor::buildTree() { TreeView = new QTreeView(); - TreeModel =std::make_unique(FeatureModel.get(), TreeView); - for(auto Item: TreeModel->getItems()){ + TreeModel = + std::make_unique(FeatureModel.get(), TreeView); + for (auto Item : TreeModel->getItems()) { connect(Item, &FeatureTreeItem::inspectSource, this, &FeatureModelEditor::inspectFeatureSources); connect(Item, &FeatureTreeItem::addChildFeature, this, &FeatureModelEditor::featureAddDialogChild); - connect(Item, &FeatureTreeItem::removeFeature, this, &FeatureModelEditor::removeFeature); + connect(Item, &FeatureTreeItem::removeFeature, this, + &FeatureModelEditor::removeFeature); } - connect(TreeView,&QTreeView::pressed,this, + connect(TreeView, &QTreeView::pressed, this, &FeatureModelEditor::loadFeatureFromIndex); TreeView->setModel(TreeModel.get()); TreeView->setContextMenuPolicy(Qt::CustomContextMenu); - connect(TreeView, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(createTreeContextMenu(const QPoint &))); + connect(TreeView, SIGNAL(customContextMenuRequested(const QPoint &)), this, + SLOT(createTreeContextMenu(const QPoint &))); } -///Build the graph view +/// Build the graph view void FeatureModelEditor::buildGraph() { Graph = std::make_unique(FeatureModel.get()); for (auto &Node : *Graph->getNodes()) { @@ -116,97 +122,108 @@ void FeatureModelEditor::buildGraph() { &FeatureModelEditor::inspectFeatureSources); } } -void FeatureModelEditor::featureAddDialog(){ featureAddDialogChild(nullptr); -} -///Spawn a Dialog to select data to add a Feature -void FeatureModelEditor::featureAddDialogChild(Feature* ParentFeature) { - FeatureAddDialog AddDialog(Graph.get(),this, ParentFeature); - if(AddDialog.exec() == QDialog::Accepted){ - Feature* Parent = FeatureModel->getFeature(AddDialog.getParent().toStdString()); +void FeatureModelEditor::featureAddDialog() { featureAddDialogChild(nullptr); } +/// Spawn a Dialog to select data to add a Feature +void FeatureModelEditor::featureAddDialogChild(Feature *ParentFeature) { + FeatureAddDialog AddDialog(Graph.get(), this, ParentFeature); + if (AddDialog.exec() == QDialog::Accepted) { + Feature *Parent = + FeatureModel->getFeature(AddDialog.getParent().toStdString()); auto NewFeature = AddDialog.getFeature(); auto *NewNode = Graph->addNode(NewFeature.get(), Graph->getNode(Parent->getName().str())); - auto *NewTreeItem = TreeModel->addFeature(NewFeature.get(),Parent->getName().str()); - connect(NewTreeItem,&FeatureTreeItem::inspectSource, this,&FeatureModelEditor::inspectFeatureSources); + auto *NewTreeItem = + TreeModel->addFeature(NewFeature.get(), Parent->getName().str()); + connect(NewTreeItem, &FeatureTreeItem::inspectSource, this, + &FeatureModelEditor::inspectFeatureSources); connect(NewNode, &FeatureNode::clicked, this, - &FeatureModelEditor::loadFeature); + &FeatureModelEditor::loadFeature); connect(NewNode, &FeatureNode::inspectSource, this, - &FeatureModelEditor::inspectFeatureSources); - auto Transaction = vara::feature::FeatureModelTransaction::openTransaction(*FeatureModel); - auto PotentialRelations = Parent->getChildren(1); - if(!PotentialRelations.empty()){ - Transaction.addFeature(std::move(NewFeature),*PotentialRelations.begin()); + &FeatureModelEditor::inspectFeatureSources); + auto Transaction = vara::feature::FeatureModelTransaction< + vara::feature::detail::ModifyTransactionMode>:: + openTransaction(*FeatureModel); + auto PotentialRelations = + Parent->getChildren(1); + if (!PotentialRelations.empty()) { + Transaction.addFeature(std::move(NewFeature), + *PotentialRelations.begin()); } else { - Transaction.addFeature(std::move(NewFeature),Parent); + Transaction.addFeature(std::move(NewFeature), Parent); } Transaction.commit(); - } + } } -void FeatureModelEditor::removeFeature(bool Recursive,Feature* Feature) { - TreeModel->deleteFeatureItem(Recursive,Feature); - Graph->deleteNode(Recursive,Feature); - Ui->featureInfo->clear(); - vara::feature::removeFeature(*FeatureModel,Feature,Recursive); +void FeatureModelEditor::removeFeature(bool Recursive, Feature *Feature) { + TreeModel->deleteFeatureItem(Recursive, Feature); + Graph->deleteNode(Recursive, Feature); + Ui->featureInfo->clear(); + vara::feature::removeFeature(*FeatureModel, Feature, Recursive); } - -///Save the current State of the Feature Model +/// Save the current State of the Feature Model void FeatureModelEditor::save() { - SavePath = QFileDialog::getSaveFileName(this,tr("Save File"),ModelPath,tr("XML files (*.xml)")); - vara::feature::FeatureModelXmlWriter FMWrite{*FeatureModel}; - FMWrite.writeFeatureModel(SavePath.toStdString()); + SavePath = QFileDialog::getSaveFileName(this, tr("Save File"), ModelPath, + tr("XML files (*.xml)")); + vara::feature::FeatureModelXmlWriter FMWrite{*FeatureModel}; + FMWrite.writeFeatureModel(SavePath.toStdString()); } - - -/// Loead the source files of the Feature to be selectable by the user and set the Feature as CurrentFeature. -/// \param Feature -void FeatureModelEditor::inspectFeatureSources(vara::feature::Feature *Feature) { - CurrentFeature = Feature; - if(Repository.isEmpty()){ +/// Loead the source files of the Feature to be selectable by the user and set +/// the Feature as CurrentFeature. \param Feature +void FeatureModelEditor::inspectFeatureSources( + vara::feature::Feature *Feature) { + CurrentFeature = Feature; + if (Repository.isEmpty()) { Repository = QFileDialog::getExistingDirectory(); - } - Ui->sources->clear(); - for(const auto& Source : Feature->getLocations()){ - Ui->sources->addItem(QString::fromStdString(Source.getPath().string())); - } - Ui->sourcesLable->setText( QString::fromStdString("Sources for: "+Feature->getName().str())); - if(Ui->sources->count() == 1){ - loadSource(Ui->sources->itemText(0)); - } else { - Ui->sources->setPlaceholderText("Select File"); - } + } + Ui->sources->clear(); + for (const auto &Source : Feature->getLocations()) { + Ui->sources->addItem(QString::fromStdString(Source.getPath().string())); + } + Ui->sourcesLable->setText( + QString::fromStdString("Sources for: " + Feature->getName().str())); + if (Ui->sources->count() == 1) { + loadSource(Ui->sources->itemText(0)); + } else { + Ui->sources->setPlaceholderText("Select File"); + } } /// Create the Context menu for inspecting sources in the tree view /// \param Pos Position of the cursor used to find the clicked item void FeatureModelEditor::createTreeContextMenu(const QPoint &Pos) { - auto Index = TreeView->indexAt(Pos); - if(Index.isValid()){ - FeatureTreeItem* Item = static_cast(Index.internalPointer())->child(Index.row()); - Item->contextMenu(TreeView->mapToGlobal(Pos)); - } - + auto Index = TreeView->indexAt(Pos); + if (Index.isValid()) { + FeatureTreeItem *Item = + static_cast(Index.internalPointer()) + ->child(Index.row()); + Item->contextMenu(TreeView->mapToGlobal(Pos)); + } } -/// Load the selected file into the textedit and mark the sources of the selected feature -void FeatureModelEditor::loadSource(const QString &RelativePath){ +/// Load the selected file into the textedit and mark the sources of the +/// selected feature +void FeatureModelEditor::loadSource(const QString &RelativePath) { Ui->textEdit->clear(); auto SourcePath = Repository + "/" + RelativePath; QFile File(SourcePath); - if(File.exists()){ - File.open(QFile::ReadOnly | QFile::Text); - QTextStream ReadFile(&File); - Ui->textEdit->setText(ReadFile.readAll()); - std::cout << CurrentFeature->toString(); - std::vector Locations{}; - std::copy_if(CurrentFeature->getLocationsBegin(),CurrentFeature->getLocationsEnd(),std::back_inserter(Locations),[&RelativePath](auto const& Loc){return RelativePath.toStdString()==Loc.getPath();}); - for (auto &Location:Locations) { - markLocation(Location); - } + if (File.exists()) { + File.open(QFile::ReadOnly | QFile::Text); + QTextStream ReadFile(&File); + Ui->textEdit->setText(ReadFile.readAll()); + std::cout << CurrentFeature->toString(); + std::vector Locations{}; + std::copy_if( + CurrentFeature->getLocationsBegin(), CurrentFeature->getLocationsEnd(), + std::back_inserter(Locations), [&RelativePath](auto const &Loc) { + return RelativePath.toStdString() == Loc.getPath(); + }); + for (auto &Location : Locations) { + markLocation(Location); + } } - } /// Mark the given SourceRange with the given Format /// \param Fmt Format to mark with @@ -221,7 +238,7 @@ void FeatureModelEditor::markLocation( Cursor.movePosition(QTextCursor::Down, QTextCursor::MoveAnchor, Location.getStart()->getLineNumber() - 1); Cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::MoveAnchor, - Location.getStart()->getColumnOffset()-1); + Location.getStart()->getColumnOffset() - 1); Cursor.movePosition(QTextCursor::Down, QTextCursor::KeepAnchor, Location.getEnd()->getLineNumber() - Location.getStart()->getLineNumber()); @@ -231,16 +248,17 @@ void FeatureModelEditor::markLocation( Cursor.setCharFormat(Fmt); } -///Load a sourcefile to then add a location from it -void FeatureModelEditor::addSourceFile(){ - if(!Repository.isEmpty()) { - QString const Path = QFileDialog::getOpenFileName( - this, tr("Select Source File"), Repository, - tr("C Files (*.c *c++ *.h)")); - Ui->sources->addItem(Path.sliced(Repository.length())); +/// Load a sourcefile to then add a location from it +void FeatureModelEditor::addSourceFile() { + if (!Repository.isEmpty()) { + QString const Path = + QFileDialog::getOpenFileName(this, tr("Select Source File"), Repository, + tr("C Files (*.c *c++ *.h)")); + Ui->sources->addItem(Path.sliced(Repository.length())); } } -/// Add the user selected Part of the textedit as a source for the active Feature +/// Add the user selected Part of the textedit as a source for the active +/// Feature void FeatureModelEditor::addSource() { auto TextEdit = Ui->textEdit; auto Cursor = TextEdit->textCursor(); @@ -251,17 +269,22 @@ void FeatureModelEditor::addSource() { int lines = 1; auto Block = Cursor.block(); while (Cursor.position() > Block.position()) { - Cursor.movePosition(QTextCursor::MoveOperation::Up); - lines++; + Cursor.movePosition(QTextCursor::MoveOperation::Up); + lines++; } Block = Block.previous(); - while(Block.isValid()){ - lines+=Block.lineCount(); - Block = Block.previous(); + while (Block.isValid()) { + lines += Block.lineCount(); + Block = Block.previous(); } - auto Range = vara::feature::FeatureSourceRange(Ui->sources->currentText().toStdString(),vara::feature::FeatureSourceRange::FeatureSourceLocation(lines,start-lineStart+1),vara::feature::FeatureSourceRange::FeatureSourceLocation(lines,end-lineStart)); + auto Range = vara::feature::FeatureSourceRange( + Ui->sources->currentText().toStdString(), + vara::feature::FeatureSourceRange::FeatureSourceLocation( + lines, start - lineStart + 1), + vara::feature::FeatureSourceRange::FeatureSourceLocation( + lines, end - lineStart)); auto LocationTransAction = Transaction::openTransaction(*FeatureModel); - LocationTransAction.addLocation(CurrentFeature,Range); + LocationTransAction.addLocation(CurrentFeature, Range); LocationTransAction.commit(); markLocation(Range); } diff --git a/tools/fm-editor/FeatureModelEditor.h b/tools/fm-editor/FeatureModelEditor.h index 6b89268aa..05317b942 100644 --- a/tools/fm-editor/FeatureModelEditor.h +++ b/tools/fm-editor/FeatureModelEditor.h @@ -26,33 +26,33 @@ class FeatureModelEditor : public QMainWindow { private: Ui::FeatureModelEditor *Ui; std::unique_ptr Graph{}; - QTreeView* TreeView; + QTreeView *TreeView; std::unique_ptr TreeModel{}; std::unique_ptr FeatureModel{}; - QString Repository {}; - vara::feature::Feature* CurrentFeature; - QString SavePath {}; - QString ModelPath {}; + QString Repository{}; + vara::feature::Feature *CurrentFeature; + QString SavePath{}; + QString ModelPath{}; public slots: void addSource(); void loadFeature(const vara::feature::Feature *Feature); void inspectFeatureSources(vara::feature::Feature *Feature); void loadGraph(); - void featureAddDialogChild(vara::feature::Feature* = nullptr); - //void addNode(const QString& Name, FeatureNode *Parent); + void featureAddDialogChild(vara::feature::Feature * = nullptr); + // void addNode(const QString& Name, FeatureNode *Parent); void loadSource(const QString &RelativePath); void createTreeContextMenu(const QPoint &Pos); void addSourceFile(); void loadFeatureFromIndex(const QModelIndex &Index); void save(); void featureAddDialog(); - void removeFeature(bool Recursive, vara::feature::Feature* Feature); + void removeFeature(bool Recursive, vara::feature::Feature *Feature); + private: void clean(); void buildGraph(); void buildTree(); void markLocation(vara::feature::FeatureSourceRange &Location) const; - }; #endif // VARA_FEATURE_FEATUREMODELEDITOR_H From e01fd2f3c89718c046b350bca9b0b38b2afe61ff Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 22 Feb 2023 14:57:30 +0100 Subject: [PATCH 031/106] Apply suggestions from formater Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- tools/fm-editor/Utils.h | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tools/fm-editor/Utils.h b/tools/fm-editor/Utils.h index f727f1b15..e93dded28 100644 --- a/tools/fm-editor/Utils.h +++ b/tools/fm-editor/Utils.h @@ -6,30 +6,30 @@ #define VARA_FEATURE_UTILS_H #include -template -struct ActionBuilder{ - ActionBuilder(QMenu* Menu,T* Receiver) : Menu(Menu), Receiver(Receiver) {} - template - void addActions(std::pair Action,std::pair... Actions) { - auto *A = new QAction(Action.first,Receiver); - QObject::connect(A,&QAction::triggered,Receiver,Action.second); +template +struct ActionBuilder { + ActionBuilder(QMenu *Menu, T *Receiver) : Menu(Menu), Receiver(Receiver) {} + template + void addActions(std::pair Action, + std::pair... Actions) { + auto *A = new QAction(Action.first, Receiver); + QObject::connect(A, &QAction::triggered, Receiver, Action.second); Menu->addAction(A); addActions(Actions...); } void addActions() {} + private: - QMenu* Menu; - T* Receiver; + QMenu *Menu; + T *Receiver; }; - -template -QMenu* buildMenu(T* Receiver,std::pair... Actions ) { +template +QMenu *buildMenu(T *Receiver, std::pair... Actions) { auto Menu = new QMenu; - ActionBuilder Builder(Menu,Receiver); + ActionBuilder Builder(Menu, Receiver); Builder.addActions(Actions...); return Menu; } - #endif // VARA_FEATURE_UTILS_H From ba588a4051f0b7362a0d6ad693de9a0003a6d6d8 Mon Sep 17 00:00:00 2001 From: Nerum Date: Wed, 22 Feb 2023 15:07:36 +0100 Subject: [PATCH 032/106] revert accidental rename by clion --- unittests/Feature/FeatureModelTransaction.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/unittests/Feature/FeatureModelTransaction.cpp b/unittests/Feature/FeatureModelTransaction.cpp index 7e5422bde..629f57062 100644 --- a/unittests/Feature/FeatureModelTransaction.cpp +++ b/unittests/Feature/FeatureModelTransaction.cpp @@ -104,7 +104,7 @@ TEST_F(FeatureModelTransactionCopyTest, addFeatureToModel) { size_t FMSizeBefore = FM->size(); auto FT = FeatureModelCopyTransaction::openTransaction(*FM); - FT.featureAddDialogChild(std::make_unique("ab"), + FT.addFeature(std::make_unique("ab"), FM->getFeature("a")); EXPECT_EQ(FMSizeBefore, FM->size()); @@ -134,7 +134,7 @@ TEST_F(FeatureModelTransactionCopyTest, addFeatureToModelThenAbort) { size_t FMSizeBefore = FM->size(); auto FT = FeatureModelCopyTransaction::openTransaction(*FM); - FT.featureAddDialogChild(std::make_unique("ab"), + FT.addFeature(std::make_unique("ab"), FM->getFeature("a")); EXPECT_EQ(FMSizeBefore, FM->size()); @@ -189,7 +189,7 @@ TEST_F(FeatureModelTransactionModifyTest, addFeatureToModel) { size_t FMSizeBefore = FM->size(); auto FT = FeatureModelModifyTransaction::openTransaction(*FM); - FT.featureAddDialogChild(std::make_unique("ab"), + FT.addFeature(std::make_unique("ab"), FM->getFeature("a")); EXPECT_EQ(FMSizeBefore, FM->size()); @@ -210,7 +210,7 @@ TEST_F(FeatureModelTransactionModifyTest, addFeatureToModelThenAboard) { size_t FMSizeBefore = FM->size(); auto FT = FeatureModelModifyTransaction::openTransaction(*FM); - FT.featureAddDialogChild(std::make_unique("ab"), + FT.addFeature(std::make_unique("ab"), FM->getFeature("a")); EXPECT_EQ(FMSizeBefore, FM->size()); From ea1d7e8d5f9752bf4763a4c3b674e6446bb1c8d1 Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 23 Feb 2023 16:01:21 +0100 Subject: [PATCH 033/106] Apply formatting suggestions from code review Co-authored-by: Florian Sattler --- .github/workflows/build.yml | 1 - tools/fm-editor/CMakeLists.txt | 8 +++---- tools/fm-editor/FeatureAddDialog.cpp | 9 ++++---- tools/fm-editor/FeatureAddDialog.h | 7 +++--- tools/fm-editor/FeatureModelEditor.cpp | 19 +++++++++++----- tools/fm-editor/FeatureModelEditor.h | 4 +++- tools/fm-editor/Utils.h | 5 +---- tools/fm-editor/graph/FeatureEdge.cpp | 10 +++++---- tools/fm-editor/graph/FeatureEdge.h | 3 ++- tools/fm-editor/graph/FeatureModelGraph.cpp | 22 +++++++++++-------- tools/fm-editor/graph/FeatureModelGraph.h | 9 ++++++-- tools/fm-editor/graph/FeatureNode.cpp | 12 +++++----- tools/fm-editor/graph/FeatureNode.h | 10 ++++++--- tools/fm-editor/main.cpp | 7 +----- tools/fm-editor/tree/FeatureTreeItem.cpp | 15 ++++++++----- tools/fm-editor/tree/FeatureTreeItem.h | 4 ---- tools/fm-editor/tree/FeatureTreeViewModel.cpp | 16 ++++++++------ tools/fm-editor/tree/FeatureTreeViewModel.h | 11 +++++----- 18 files changed, 95 insertions(+), 77 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9a9b5989a..206a99abb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -53,7 +53,6 @@ jobs: sudo apt-get update sudo apt download libclang-rt-14-dev sudo dpkg --force-all -i libclang-rt-14-dev* - - name: Build ${{ matrix.build }} with LLVM ${{ matrix.llvm-major }} env: BUILD_TYPE: ${{ matrix.build }} diff --git a/tools/fm-editor/CMakeLists.txt b/tools/fm-editor/CMakeLists.txt index 8287c951c..0b315f0a4 100644 --- a/tools/fm-editor/CMakeLists.txt +++ b/tools/fm-editor/CMakeLists.txt @@ -2,7 +2,7 @@ set(LLVM_LINK_COMPONENTS Support Demangle Core - ) +) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) find_package(Qt6 REQUIRED COMPONENTS Widgets) @@ -24,15 +24,15 @@ add_vara_executable(fm-editor fileview/syntaxHighlite/qsourcehighliter.h fileview/syntaxHighlite/qsourcehighliter.cpp fileview/syntaxHighlite/languagedata.h fileview/syntaxHighlite/languagedata.cpp fileview/syntaxHighlite/qsourcehighliterthemes.h fileview/syntaxHighlite/qsourcehighliterthemes.cpp - ) +) target_link_libraries(fm-editor LINK_PRIVATE VaRAFeature Qt::Widgets ${STD_FS_LIB} - ) +) add_custom_target(check-vara-fm-editor COMMAND fm-editor xml/test.xml -viewer cat | dot | grep . -q WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../unittests/resources - ) +) diff --git a/tools/fm-editor/FeatureAddDialog.cpp b/tools/fm-editor/FeatureAddDialog.cpp index b4a5b1beb..1060e21cb 100644 --- a/tools/fm-editor/FeatureAddDialog.cpp +++ b/tools/fm-editor/FeatureAddDialog.cpp @@ -1,10 +1,7 @@ -// -// Created by simon on 29.11.22. -// - #include "FeatureAddDialog.h" #include "graph/FeatureModelGraph.h" #include "graph/FeatureNode.h" + using vara::feature::Feature; using vara::feature::FeatureModel; FeatureAddDialog::FeatureAddDialog(FeatureModelGraph *Graph, QWidget *Parent, @@ -39,10 +36,13 @@ void FeatureAddDialog::featureType(int index) { NumericFeature->setVisible(false); } } + vara::feature::Feature::FeatureKind FeatureAddDialog::getFeatureKind() { return vara::feature::Feature::FeatureKind(FeatureKind->currentIndex()); } + bool FeatureAddDialog::isOptional() { return optinalCheck->isChecked(); } + QString FeatureAddDialog::getOutpuString() { return outpuString->text(); } std::vector stringToIntVector(string &Input) { @@ -51,6 +51,7 @@ std::vector stringToIntVector(string &Input) { for (std::string Substring; std::getline(InStream, Substring, ',');) { Out.push_back(std::stoi(Substring)); + } return Out; } diff --git a/tools/fm-editor/FeatureAddDialog.h b/tools/fm-editor/FeatureAddDialog.h index e6054edee..f7b2e2004 100644 --- a/tools/fm-editor/FeatureAddDialog.h +++ b/tools/fm-editor/FeatureAddDialog.h @@ -1,11 +1,9 @@ -// -// Created by simon on 29.11.22. -// - #ifndef VARA_FEATURE_FEATUREADDDIALOG_H #define VARA_FEATURE_FEATUREADDDIALOG_H + #include "graph/FeatureModelGraph.h" #include "ui_FeatureAddDialog.h" + #include #include @@ -20,6 +18,7 @@ class FeatureAddDialog : public QDialog, public Ui::Add { std::unique_ptr getFeature(); vara::feature::Feature::FeatureKind getFeatureKind(); bool isOptional(); + public slots: void featureType(int index); diff --git a/tools/fm-editor/FeatureModelEditor.cpp b/tools/fm-editor/FeatureModelEditor.cpp index f390d1625..3ee0633bc 100644 --- a/tools/fm-editor/FeatureModelEditor.cpp +++ b/tools/fm-editor/FeatureModelEditor.cpp @@ -1,7 +1,3 @@ -// -// Created by simon on 07.11.22. -// - #include "FeatureModelEditor.h" #include "FeatureAddDialog.h" #include "fileview/syntaxHighlite/qsourcehighliter.h" @@ -11,9 +7,12 @@ #include "vara/Feature/FeatureModel.h" #include "vara/Feature/FeatureModelTransaction.h" #include "vara/Feature/FeatureModelWriter.h" + #include #include + namespace fs = std::filesystem; + using vara::feature::FeatureModel; using Transaction = vara::feature::FeatureModelTransaction< vara::feature::detail::ModifyTransactionMode>; @@ -55,6 +54,7 @@ void FeatureModelEditor::loadFeatureFromIndex(const QModelIndex &Index) { } } } + /// Clear all Fields that should be emptied when loading a new Model void FeatureModelEditor::clean() { SavePath.clear(); @@ -80,8 +80,10 @@ void FeatureModelEditor::loadGraph() { Ui->ModelFile->setText(Path); FeatureModel = vara::feature::loadFeatureModel(Path.toStdString()); } + // create Graph view buildGraph(); + // create Tree View buildTree(); Ui->tabWidget->addTab(Graph.get(),"GraphView"); @@ -122,7 +124,9 @@ void FeatureModelEditor::buildGraph() { &FeatureModelEditor::inspectFeatureSources); } } + void FeatureModelEditor::featureAddDialog() { featureAddDialogChild(nullptr); } + /// Spawn a Dialog to select data to add a Feature void FeatureModelEditor::featureAddDialogChild(Feature *ParentFeature) { FeatureAddDialog AddDialog(Graph.get(), this, ParentFeature); @@ -191,7 +195,9 @@ void FeatureModelEditor::inspectFeatureSources( Ui->sources->setPlaceholderText("Select File"); } } + /// Create the Context menu for inspecting sources in the tree view +/// /// \param Pos Position of the cursor used to find the clicked item void FeatureModelEditor::createTreeContextMenu(const QPoint &Pos) { auto Index = TreeView->indexAt(Pos); @@ -225,9 +231,11 @@ void FeatureModelEditor::loadSource(const QString &RelativePath) { } } } + /// Mark the given SourceRange with the given Format +/// /// \param Fmt Format to mark with -/// \param Cursor Cursor +/// \param Cursor the cursor /// \param Location Location to mark void FeatureModelEditor::markLocation( vara::feature::FeatureSourceRange &Location) const { @@ -257,6 +265,7 @@ void FeatureModelEditor::addSourceFile() { Ui->sources->addItem(Path.sliced(Repository.length())); } } + /// Add the user selected Part of the textedit as a source for the active /// Feature void FeatureModelEditor::addSource() { diff --git a/tools/fm-editor/FeatureModelEditor.h b/tools/fm-editor/FeatureModelEditor.h index 05317b942..1bdafa07b 100644 --- a/tools/fm-editor/FeatureModelEditor.h +++ b/tools/fm-editor/FeatureModelEditor.h @@ -1,4 +1,3 @@ - #ifndef VARA_FEATURE_FEATUREMODELEDITOR_H #define VARA_FEATURE_FEATUREMODELEDITOR_H @@ -11,12 +10,14 @@ #include #include #include + QT_BEGIN_NAMESPACE namespace Ui { class FeatureModelEditor; } // namespace Ui QT_END_NAMESPACE + class FeatureModelEditor : public QMainWindow { Q_OBJECT public: @@ -33,6 +34,7 @@ class FeatureModelEditor : public QMainWindow { vara::feature::Feature *CurrentFeature; QString SavePath{}; QString ModelPath{}; + public slots: void addSource(); void loadFeature(const vara::feature::Feature *Feature); diff --git a/tools/fm-editor/Utils.h b/tools/fm-editor/Utils.h index e93dded28..de32e3f14 100644 --- a/tools/fm-editor/Utils.h +++ b/tools/fm-editor/Utils.h @@ -1,11 +1,8 @@ -// -// Created by simon on 20.02.23. -// - #ifndef VARA_FEATURE_UTILS_H #define VARA_FEATURE_UTILS_H #include + template struct ActionBuilder { ActionBuilder(QMenu *Menu, T *Receiver) : Menu(Menu), Receiver(Receiver) {} diff --git a/tools/fm-editor/graph/FeatureEdge.cpp b/tools/fm-editor/graph/FeatureEdge.cpp index 07bf7da6f..d07a634c2 100644 --- a/tools/fm-editor/graph/FeatureEdge.cpp +++ b/tools/fm-editor/graph/FeatureEdge.cpp @@ -1,7 +1,3 @@ -// -// Created by simon on 04.11.22. -// - #include "FeatureEdge.h" #include "FeatureNode.h" @@ -15,8 +11,11 @@ FeatureEdge::FeatureEdge(FeatureNode *SourceNode, FeatureNode *TargetNode) TargetNode->setParentEdge(this); adjust(); } + FeatureNode *FeatureEdge::sourceNode() const { return Source; } + FeatureNode *FeatureEdge::targetNode() const { return Target; } + void FeatureEdge::adjust() { if (!Source || !Target) { return; @@ -35,6 +34,7 @@ void FeatureEdge::adjust() { SourcePoint = TargetPoint = Line.p1(); } } + QRectF FeatureEdge::boundingRect() const { if (!Source || !Target) { return {}; @@ -48,6 +48,7 @@ QRectF FeatureEdge::boundingRect() const { .normalized() .adjusted(-Extra, -Extra, Extra, Extra); } + void FeatureEdge::paint(QPainter *Painter, const QStyleOptionGraphicsItem *Option, QWidget *Widget) { @@ -65,6 +66,7 @@ void FeatureEdge::paint(QPainter *Painter, Painter->setBrush(QBrush(Target->isOptional()?Qt::white:Qt::black)); Painter->drawEllipse(TargetPoint,4,4); } + void FeatureEdge::setSourceNode(FeatureNode *Node) { Source = Node; Node->addChildEdge(this); diff --git a/tools/fm-editor/graph/FeatureEdge.h b/tools/fm-editor/graph/FeatureEdge.h index acc2555ba..abf682bc8 100644 --- a/tools/fm-editor/graph/FeatureEdge.h +++ b/tools/fm-editor/graph/FeatureEdge.h @@ -1,9 +1,10 @@ - #ifndef VARA_FEATURE_FEATUREEDGE_H #define VARA_FEATURE_FEATUREEDGE_H #include + class FeatureNode; + class FeatureEdge : public QGraphicsItem{ public: FeatureEdge(FeatureNode *SourceNode, FeatureNode *TargetNode); diff --git a/tools/fm-editor/graph/FeatureModelGraph.cpp b/tools/fm-editor/graph/FeatureModelGraph.cpp index 410b40cf5..e6577854a 100644 --- a/tools/fm-editor/graph/FeatureModelGraph.cpp +++ b/tools/fm-editor/graph/FeatureModelGraph.cpp @@ -1,15 +1,14 @@ -// -// Created by simon on 04.11.22. -// - #include "FeatureModelGraph.h" #include "vara/Feature/Feature.h" #include "vara/Feature/FeatureModel.h" #include "vara/Feature/FeatureModelTransaction.h" -#include #include #include + +#include + using vara::feature::Feature; + FeatureModelGraph::FeatureModelGraph(vara::feature::FeatureModel * FeatureModel, QWidget *Parent) : QGraphicsView(Parent), EntryNode(new FeatureNode(FeatureModel->getRoot())), FeatureModel(FeatureModel) { @@ -81,8 +80,10 @@ int FeatureModelGraph::positionRec(const int CurrentDepth, const std::vectorkey()) { case Qt::Key_Plus: @@ -95,6 +96,7 @@ void FeatureModelGraph::keyPressEvent(QKeyEvent *Event) { QGraphicsView::keyPressEvent(Event); } } + #if QT_CONFIG(wheelevent) void FeatureModelGraph::wheelEvent(QWheelEvent *Event) { scaleView(pow(2., -Event->angleDelta().y() / 240.0)); @@ -132,6 +134,7 @@ void FeatureModelGraph::drawBackground(QPainter *Painter, const QRectF &Rect) { Painter->setPen(Qt::lightGray); Painter->setPen(Qt::black); } + void FeatureModelGraph::scaleView(qreal ScaleFactor) { qreal Factor = transform() .scale(ScaleFactor, ScaleFactor) @@ -143,9 +146,10 @@ void FeatureModelGraph::scaleView(qreal ScaleFactor) { scale(ScaleFactor, ScaleFactor); } + void FeatureModelGraph::zoomIn() { scaleView(qreal(1.2)); } -void FeatureModelGraph::zoomOut() { scaleView(1 / qreal(1.2)); } +void FeatureModelGraph::zoomOut() { scaleView(1 / qreal(1.2)); } FeatureNode* FeatureModelGraph::addNode(Feature* Feature, FeatureNode* Parent) { auto NewNode = std::make_unique(Feature); @@ -162,15 +166,15 @@ FeatureNode* FeatureModelGraph::addNode(Feature* Feature, FeatureNode* Parent) { return NewNodeRaw; } - FeatureNode* FeatureModelGraph::getNode(std::string Name) { auto It = std::find_if(Nodes.begin(),Nodes.end(),[&Name](auto const &Node){return Node->getName() == Name;}); if (It != Nodes.end()) { return It->get(); } - return nullptr; + return nullptr; } + void FeatureModelGraph::deleteNode(bool Recursive, FeatureNode* Node) { auto *Parent = Node->parent()->sourceNode(); if(!Recursive){ @@ -189,8 +193,8 @@ void FeatureModelGraph::deleteNode(bool Recursive, FeatureNode* Node) { scene()->removeItem(Node->parent()); Nodes.erase(std::find_if(Nodes.begin(), Nodes.end(),[Node](auto &N){return N.get() == Node;})); - } + void FeatureModelGraph::deleteNode(bool Recursive, vara::feature::Feature *Feature) { auto * Node = getNode(Feature->getName().str()); diff --git a/tools/fm-editor/graph/FeatureModelGraph.h b/tools/fm-editor/graph/FeatureModelGraph.h index 30525c9d3..f222d7c18 100644 --- a/tools/fm-editor/graph/FeatureModelGraph.h +++ b/tools/fm-editor/graph/FeatureModelGraph.h @@ -1,11 +1,12 @@ - #ifndef VARA_FEATURE_FEATUREMODELGRAPH_H #define VARA_FEATURE_FEATUREMODELGRAPH_H #include "vara/Feature/FeatureModel.h" #include "FeatureNode.h" -#include #include "FeatureEdge.h" + +#include + class FeatureModelGraph : public QGraphicsView { Q_OBJECT @@ -18,18 +19,22 @@ class FeatureModelGraph : public QGraphicsView { FeatureNode*addNode(vara::feature::Feature *Feature,FeatureNode* Parent); void deleteNode(bool Recursive, vara::feature::Feature* Feature); void deleteNode(bool Recursive, FeatureNode* Node); + public slots: void zoomIn(); void zoomOut(); protected: void keyPressEvent(QKeyEvent *Event) override; + #if QT_CONFIG(wheelevent) void wheelEvent(QWheelEvent *Event) override; #endif + void drawBackground(QPainter *Painter, const QRectF &Rect) override; void scaleView(qreal ScaleFactor); + private: void reload(); void buildRec(FeatureNode *CurrentFeatureNode); diff --git a/tools/fm-editor/graph/FeatureNode.cpp b/tools/fm-editor/graph/FeatureNode.cpp index 447c87d9c..22f5ec3c9 100644 --- a/tools/fm-editor/graph/FeatureNode.cpp +++ b/tools/fm-editor/graph/FeatureNode.cpp @@ -1,7 +1,3 @@ -// -// Created by simon on 04.11.22. -// - #include "FeatureNode.h" #include "FeatureEdge.h" #include "FeatureModelGraph.h" @@ -23,6 +19,7 @@ void FeatureNode::addChildEdge(FeatureEdge *Edge) { ChildEdges.push_back(Edge); Edge->adjust(); } + void FeatureNode::setParentEdge(FeatureEdge *Edge) { ParentEdge = Edge; Edge->adjust(); @@ -56,11 +53,11 @@ void FeatureNode::paint(QPainter *Painter, QBrush Brush(Qt::darkYellow); if (Option->state & QStyle::State_Sunken) { Brush.setColor(QColor(Qt::yellow).lighter(120)); - } else { } - Painter->setBrush(Brush); + Painter->setBrush(Brush); Painter->setPen(QPen(Qt::black, 0)); + int W = width(); Painter->drawRect(-W / 2, -10, W, 20); Painter->setPen(QPen(Qt::black, 1)); @@ -126,8 +123,9 @@ int FeatureNode::childrenWidth() const { } int Result = 0; for (auto *Child : ChildEdges){ - Result +=Child->targetNode()->childrenWidth(); + Result += Child->targetNode()->childrenWidth(); } + return std::max(Result,width()); } diff --git a/tools/fm-editor/graph/FeatureNode.h b/tools/fm-editor/graph/FeatureNode.h index 2afb5d13b..1e39fefe5 100644 --- a/tools/fm-editor/graph/FeatureNode.h +++ b/tools/fm-editor/graph/FeatureNode.h @@ -1,17 +1,18 @@ - #ifndef VARA_FEATURE_FEATURENODE_H #define VARA_FEATURE_FEATURENODE_H #include "vara/Feature/Feature.h" #include "FeatureNode.h" + #include #include #include + class FeatureEdge; class FeatureModelGraph; -class FeatureNode : public QObject,public QGraphicsItem{ - Q_OBJECT +class FeatureNode : public QObject, public QGraphicsItem { + Q_OBJECT public: void removeChild(FeatureNode *Child); @@ -35,15 +36,18 @@ class FeatureNode : public QObject,public QGraphicsItem{ }; [[nodiscard]] std::string getName() const {return Feature->getName().str();}; ~FeatureNode() {std::destroy(ChildEdges.begin(), ChildEdges.end());} + signals: void clicked(const vara::feature::Feature *Feature); void inspectSource(vara::feature::Feature *Feature); + protected: QVariant itemChange(GraphicsItemChange Change, const QVariant &Value) override; void mousePressEvent(QGraphicsSceneMouseEvent *Event) override; void mouseReleaseEvent(QGraphicsSceneMouseEvent *Event) override; void contextMenuEvent(QGraphicsSceneContextMenuEvent *Event) override; + private: std::vector ChildEdges; FeatureEdge * ParentEdge = nullptr; diff --git a/tools/fm-editor/main.cpp b/tools/fm-editor/main.cpp index 788bb8974..a52c517e4 100644 --- a/tools/fm-editor/main.cpp +++ b/tools/fm-editor/main.cpp @@ -1,7 +1,3 @@ -// -// Created by simon on 04.11.22. -// - #include "FeatureModelEditor.h" #include "graph/FeatureModelGraph.h" #include "vara/Feature/FeatureModel.h" @@ -10,8 +6,7 @@ #include #include -int main(int argc, char **argv) -{ +int main(int argc, char *argv[]) { QApplication App(argc, argv); FeatureModelEditor W; W.show(); diff --git a/tools/fm-editor/tree/FeatureTreeItem.cpp b/tools/fm-editor/tree/FeatureTreeItem.cpp index af4e1a8bc..9529ac911 100644 --- a/tools/fm-editor/tree/FeatureTreeItem.cpp +++ b/tools/fm-editor/tree/FeatureTreeItem.cpp @@ -1,10 +1,10 @@ -// -// Created by simon on 02.02.23. -// #include "FeatureTreeItem.h" +#include "../Utils.h" + #include + #include -#include "../Utils.h" + QVariant numericValue(vara::feature::Feature* Item) { if(Item->getKind()==vara::feature::Feature::FeatureKind::FK_NUMERIC){ auto *NumItem = dynamic_cast(Item); @@ -27,7 +27,6 @@ QVariant numericValue(vara::feature::Feature* Item) { return {}; } - QVariant locationString(vara::feature::Feature* Item){ auto Locs = Item->getLocations(); std::stringstream StrS; @@ -37,15 +36,19 @@ QVariant locationString(vara::feature::Feature* Item){ StrS << llvm::formatv("{0}", Fsr.toString()).str(); }); } + return QString::fromStdString(StrS.str()); } + FeatureTreeItem* FeatureTreeItem::createFeatureTreeItem( vara::feature::FeatureTreeNode *Item) { if(Item->getKind() == vara::feature::FeatureTreeNode::NodeKind::NK_RELATIONSHIP){ return new FeatureTreeItemRelation(dynamic_cast(Item)); } + return new FeatureTreeItemFeature(dynamic_cast(Item)); } + void FeatureTreeItem::addChild(FeatureTreeItem* Child) { if(!Children.empty() && Children[0]->getKind()==vara::feature::FeatureTreeNode::NodeKind::NK_RELATIONSHIP){ Children[0]->addChild(Child); @@ -54,6 +57,7 @@ void FeatureTreeItem::addChild(FeatureTreeItem* Child) { Child->setParent(this); } } + std::vector FeatureTreeItem::getChildrenRecursive() { auto Nodes = std::vector{Children}; for(auto Child: Children){ @@ -78,6 +82,7 @@ QVariant FeatureTreeItemFeature::data(int Column) const { void FeatureTreeItemFeature::inspect() { emit(inspectSource(Item)); } + void FeatureTreeItemFeature::contextMenu(QPoint Pos) { auto* Menu =buildMenu(this, std::pair(QString("Inspect Sources"),&FeatureTreeItemFeature::inspect), diff --git a/tools/fm-editor/tree/FeatureTreeItem.h b/tools/fm-editor/tree/FeatureTreeItem.h index f30a41f7e..1e617da6c 100644 --- a/tools/fm-editor/tree/FeatureTreeItem.h +++ b/tools/fm-editor/tree/FeatureTreeItem.h @@ -1,7 +1,3 @@ -// -// Created by simon on 02.02.23. -// - #ifndef VARA_FEATURE_FEATURETREEITEM_H #define VARA_FEATURE_FEATURETREEITEM_H #include "vara/Feature/Feature.h" diff --git a/tools/fm-editor/tree/FeatureTreeViewModel.cpp b/tools/fm-editor/tree/FeatureTreeViewModel.cpp index ab996c21d..c6d0db889 100644 --- a/tools/fm-editor/tree/FeatureTreeViewModel.cpp +++ b/tools/fm-editor/tree/FeatureTreeViewModel.cpp @@ -89,9 +89,11 @@ QVariant FeatureTreeViewModel::headerData(int Section, } return {}; } + std::vector FeatureTreeViewModel::getItems() { return Items; } + FeatureTreeItem * FeatureTreeViewModel::addFeature(vara::feature::Feature *Feature, std::string Parent) { @@ -102,6 +104,7 @@ FeatureTreeViewModel::addFeature(vara::feature::Feature *Feature, Items.push_back(NewItem); return NewItem; } + return nullptr; } @@ -116,8 +119,11 @@ void FeatureTreeViewModel::deleteFeatureItem(bool Recursive, } void FeatureTreeViewModel::deleteItem(bool Recursive, FeatureTreeItem *Item) { - - if (!Recursive) { + if(Recursive) { + for (auto *Child : Item->getChildren()) { + deleteItem(Recursive,Child); + } + } else { auto *Parent = Item->parent(); if (Parent) { for (auto *Child : Item->getChildren()) { @@ -128,11 +134,7 @@ void FeatureTreeViewModel::deleteItem(bool Recursive, FeatureTreeItem *Item) { Parent->getChildren().erase(ItemPos); } } - if(Recursive) { - for (auto *Child : Item->getChildren()) { - deleteItem(Recursive,Child); - } - } + Items.erase(std::find(Items.begin(), Items.end(), Item)); emit(layoutAboutToBeChanged()); delete Item; diff --git a/tools/fm-editor/tree/FeatureTreeViewModel.h b/tools/fm-editor/tree/FeatureTreeViewModel.h index 74c193adc..8d83b45ab 100644 --- a/tools/fm-editor/tree/FeatureTreeViewModel.h +++ b/tools/fm-editor/tree/FeatureTreeViewModel.h @@ -1,12 +1,11 @@ -// -// Created by simon on 02.02.23. -// - #ifndef VARA_FEATURE_FEATURETREEVIEWMODEL_H #define VARA_FEATURE_FEATURETREEVIEWMODEL_H + #include "FeatureTreeItem.h" #include "vara/Feature/FeatureModel.h" + #include + class FeatureTreeViewModel : public QAbstractItemModel { public: FeatureTreeViewModel(vara::feature::FeatureModel* Model, QObject *Parent): QAbstractItemModel(Parent), Model(Model), RootItem(FeatureTreeItem::createFeatureTreeItem(Model->getRoot())) { @@ -32,14 +31,14 @@ class FeatureTreeViewModel : public QAbstractItemModel { if(Item != Items.end()) { return *Item; } + return nullptr; } -// bool removeRows(int row, int count, const QModelIndex &parent) override; + private: vara::feature::FeatureModel* Model; FeatureTreeItem* RootItem; std::vector Items; - }; #endif // VARA_FEATURE_FEATURETREEVIEWMODEL_H From 7e848fd100b68d6864ab68ec3bfed9fe96be031e Mon Sep 17 00:00:00 2001 From: Nerum Date: Thu, 23 Feb 2023 15:46:57 +0100 Subject: [PATCH 034/106] move qsourcehighlite to be a submodule instead of copied code --- .gitmodules | 3 + external/qsourcehighlite | 1 + tools/fm-editor/CMakeLists.txt | 15 +- tools/fm-editor/FeatureModelEditor.cpp | 2 +- .../fileview/syntaxHighlite/languagedata.cpp | 6324 ----------------- .../fileview/syntaxHighlite/languagedata.h | 222 - .../syntaxHighlite/qsourcehighliter.cpp | 940 --- .../syntaxHighlite/qsourcehighliter.h | 169 - .../syntaxHighlite/qsourcehighliterthemes.cpp | 72 - .../syntaxHighlite/qsourcehighliterthemes.h | 38 - 10 files changed, 14 insertions(+), 7772 deletions(-) create mode 160000 external/qsourcehighlite delete mode 100644 tools/fm-editor/fileview/syntaxHighlite/languagedata.cpp delete mode 100644 tools/fm-editor/fileview/syntaxHighlite/languagedata.h delete mode 100644 tools/fm-editor/fileview/syntaxHighlite/qsourcehighliter.cpp delete mode 100644 tools/fm-editor/fileview/syntaxHighlite/qsourcehighliter.h delete mode 100644 tools/fm-editor/fileview/syntaxHighlite/qsourcehighliterthemes.cpp delete mode 100644 tools/fm-editor/fileview/syntaxHighlite/qsourcehighliterthemes.h diff --git a/.gitmodules b/.gitmodules index 31eac579b..753e87577 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,3 +13,6 @@ [submodule "external/csv-parser"] path = external/csv-parser url = https://github.com/vincentlaucsb/csv-parser +[submodule "external/qsourcehighlite"] + path = external/qsourcehighlite + url = git@github.com:Waqar144/QSourceHighlite.git diff --git a/external/qsourcehighlite b/external/qsourcehighlite new file mode 160000 index 000000000..f1ed26f26 --- /dev/null +++ b/external/qsourcehighlite @@ -0,0 +1 @@ +Subproject commit f1ed26f26d980360422a0295e49bf676abe7e416 diff --git a/tools/fm-editor/CMakeLists.txt b/tools/fm-editor/CMakeLists.txt index 0b315f0a4..b5f4adaa6 100644 --- a/tools/fm-editor/CMakeLists.txt +++ b/tools/fm-editor/CMakeLists.txt @@ -6,6 +6,7 @@ set(LLVM_LINK_COMPONENTS set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) find_package(Qt6 REQUIRED COMPONENTS Widgets) +include_directories(../../external/qsourcehighlite) add_vara_executable(fm-editor main.cpp graph/FeatureModelGraph.h @@ -19,12 +20,14 @@ add_vara_executable(fm-editor tree/FeatureTreeItem.h tree/FeatureTreeItem.cpp FeatureModelEditor.h FeatureModelEditor.cpp - FeatureModelEditor.ui - FeatureAddDialog.h FeatureAddDialog.cpp FeatureAddDialog.ui - fileview/syntaxHighlite/qsourcehighliter.h fileview/syntaxHighlite/qsourcehighliter.cpp - fileview/syntaxHighlite/languagedata.h fileview/syntaxHighlite/languagedata.cpp - fileview/syntaxHighlite/qsourcehighliterthemes.h fileview/syntaxHighlite/qsourcehighliterthemes.cpp -) + FeatureAddDialog.h FeatureAddDialog.cpp + ../../external/qsourcehighlite/qsourcehighliter.h + ../../external/qsourcehighlite/qsourcehighliter.cpp + ../../external/qsourcehighlite/languagedata.h + ../../external/qsourcehighlite/languagedata.cpp + ../../external/qsourcehighlite/qsourcehighliterthemes.h + ../../external/qsourcehighlite/qsourcehighliterthemes.cpp + ) target_link_libraries(fm-editor LINK_PRIVATE VaRAFeature diff --git a/tools/fm-editor/FeatureModelEditor.cpp b/tools/fm-editor/FeatureModelEditor.cpp index 3ee0633bc..43132ea63 100644 --- a/tools/fm-editor/FeatureModelEditor.cpp +++ b/tools/fm-editor/FeatureModelEditor.cpp @@ -1,6 +1,6 @@ #include "FeatureModelEditor.h" #include "FeatureAddDialog.h" -#include "fileview/syntaxHighlite/qsourcehighliter.h" +#include "qsourcehighliter.h" #include "graph/FeatureModelGraph.h" #include "graph/FeatureNode.h" #include "ui_FeatureModelEditor.h" diff --git a/tools/fm-editor/fileview/syntaxHighlite/languagedata.cpp b/tools/fm-editor/fileview/syntaxHighlite/languagedata.cpp deleted file mode 100644 index dc416f87f..000000000 --- a/tools/fm-editor/fileview/syntaxHighlite/languagedata.cpp +++ /dev/null @@ -1,6324 +0,0 @@ -/* - * Copyright (c) 2019-2020 Waqar Ahmed -- - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -#include -#include -#include "languagedata.h" -/* ------------------------ - * TEMPLATE FOR LANG DATA - * ------------------------- - * - * loadXXXData, where XXX is the language - * keywords are the language keywords e.g, const - * types are built-in types i.e, int, char, var - * literals are words like, true false - * builtin are the library functions - * other can contain any other thing, for e.g, in cpp it contains the preprocessor - - xxx_keywords = { - }; - - xxx_types = { - }; - - xxx_literals = { - }; - - xxx_builtin = { - }; - - xxx_other = { - }; - -*/ - -namespace QSourceHighlite { - -/**********************************************************/ -/* LuaData ************************************************/ -/**********************************************************/ - -static bool luaDataInitialized = false; -static LanguageData lua_keywords; -static LanguageData lua_types; -static LanguageData lua_builtin; -static LanguageData lua_literals; -static LanguageData lua_other; -void initLuaData() { - lua_keywords = LanguageData{ - {('a'), QLatin1String("and")}, - {('b'), QLatin1String("break")}, - {('d'), QLatin1String("do")}, - {('e'), QLatin1String("else")}, - {('e'), QLatin1String("elseif")}, - {('e'), QLatin1String("end")}, - {('f'), QLatin1String("for")}, - {('f'), QLatin1String("function")}, - {('i'), QLatin1String("if")}, - {('i'), QLatin1String("in")}, - {('l'), QLatin1String("local")}, - {('n'), QLatin1String("not")}, - {('o'), QLatin1String("or")}, - {('r'), QLatin1String("repeat")}, - {('r'), QLatin1String("require")}, - {('r'), QLatin1String("return")}, - {('t'), QLatin1String("then")}, - {('u'), QLatin1String("until")}, - {('w'), QLatin1String("while")}}; - - lua_literals = LanguageData{ - {('f'), QLatin1String("false")}, - {('n'), QLatin1String("nil")}, - {('t'), QLatin1String("true")}}; - - lua_other = LanguageData{ - {('_'), QLatin1String("_G")}, - {('_'), QLatin1String("__add")}, - {('_'), QLatin1String("__call")}, - {('_'), QLatin1String("__contact")}, - {('_'), QLatin1String("__div")}, - {('_'), QLatin1String("__eq")}, - {('_'), QLatin1String("__index")}, - {('_'), QLatin1String("__le")}, - {('_'), QLatin1String("__lt")}, - {('_'), QLatin1String("__mod")}, - {('_'), QLatin1String("__mul")}, - {('_'), QLatin1String("__newindex")}, - {('_'), QLatin1String("__sub")}, - {('_'), QLatin1String("__tostring")}, - {('_'), QLatin1String("__unm")} - }; - - lua_builtin = LanguageData{ - {('d'), QLatin1String("debug")}, - {('d'), QLatin1String("dofile")}, - {('g'), QLatin1String("getfenv")}, - {('g'), QLatin1String("gethook")}, - {('g'), QLatin1String("getinfo")}, - {('g'), QLatin1String("getlocal")}, - {('g'), QLatin1String("getmetatable")}, - {('g'), QLatin1String("getregistry")}, - {('g'), QLatin1String("getupvalue")}, - {('i'), QLatin1String("ipairs")}, - {('l'), QLatin1String("load")}, - {('l'), QLatin1String("loadfile")}, - {('l'), QLatin1String("loadstring")}, - {('n'), QLatin1String("next")}, - {('p'), QLatin1String("pairs")}, - {('p'), QLatin1String("print")}, - {('r'), QLatin1String("rawequal")}, - {('r'), QLatin1String("rawget")}, - {('r'), QLatin1String("rawset")}, - {('s'), QLatin1String("select")}, - {('s'), QLatin1String("setfenv")}, - {('s'), QLatin1String("sethook")}, - {('s'), QLatin1String("setlocal")}, - {('s'), QLatin1String("setmetatable")}, - {('s'), QLatin1String("setupvalue")}, - {('t'), QLatin1String("tonumber")}, - {('t'), QLatin1String("tostring")}, - {('t'), QLatin1String("traceback")}, - {('t'), QLatin1String("type")}, - {('u'), QLatin1String("unpack")} - }; - -} - -void loadLuaData(LanguageData &typess, - LanguageData &keywordss, - LanguageData &builtins, - LanguageData &literalss, - LanguageData &others){ - if (!luaDataInitialized) { - initLuaData(); - luaDataInitialized = true; - } - typess = lua_types; - keywordss = lua_keywords; - builtins = lua_builtin; - literalss = lua_literals; - others = lua_other; -} - -/**********************************************************/ -/* C/C++ Data *********************************************/ -/**********************************************************/ - -static bool cppDataInitialized = false; -static LanguageData cpp_keywords; -static LanguageData cpp_types; -static LanguageData cpp_builtin; -static LanguageData cpp_literals; -static LanguageData cpp_other; -void initCppData() { - cpp_keywords = LanguageData{ - {('a'), QLatin1String("alignas")}, - {('a'), QLatin1String("alignof")}, - {('a'), QLatin1String("and")}, - {('a'), QLatin1String("and_eq")}, - {('a'), QLatin1String("asm")}, - {('b'), QLatin1String("bit_and")}, - {('b'), QLatin1String("bit_or")}, - {('b'), QLatin1String("break")}, - {('c'), QLatin1String("case")}, - {('c'), QLatin1String("catch")}, - {('c'), QLatin1String("compl")}, - {('c'), QLatin1String("concept")}, - {('c'), QLatin1String("const")}, - {('c'), QLatin1String("constinit")}, - {('c'), QLatin1String("constexpr")}, - {('c'), QLatin1String("consteval")}, - {('c'), QLatin1String("const_cast")}, - {('c'), QLatin1String("continue")}, - {('c'), QLatin1String("co_await")}, - {('c'), QLatin1String("co_return")}, - {('c'), QLatin1String("co_yield")}, - {('d'), QLatin1String("decltype")}, - {('d'), QLatin1String("default")}, - {('d'), QLatin1String("delete")}, - {('d'), QLatin1String("do")}, - {('d'), QLatin1String("dynamic_cast")}, - {('e'), QLatin1String("else")}, - {('e'), QLatin1String("explicit")}, - {('e'), QLatin1String("export")}, - {('e'), QLatin1String("extern")}, - {('f'), QLatin1String("for")}, - {('f'), QLatin1String("friend")}, - {('g'), QLatin1String("goto")}, - {('i'), QLatin1String("if")}, - {('i'), QLatin1String("inline")}, - {('m'), QLatin1String("mutable")}, - {('n'), QLatin1String("new")}, - {('n'), QLatin1String("not")}, - {('n'), QLatin1String("not_eq")}, - {('n'), QLatin1String("noexcept")}, - {('o'), QLatin1String("or")}, - {('o'), QLatin1String("or_eq")}, - {('o'), QLatin1String("operator")}, - {('p'), QLatin1String("private")}, - {('p'), QLatin1String("protected")}, - {('p'), QLatin1String("public")}, - {('r'), QLatin1String("register")}, - {('r'), QLatin1String("reinterpret_cast")}, - {('r'), QLatin1String("requires")}, - {('r'), QLatin1String("return")}, - {('s'), QLatin1String("signal")}, - {('s'), QLatin1String("sizeof")}, - {('s'), QLatin1String("slot")}, - {('s'), QLatin1String("static")}, - {('s'), QLatin1String("static_assert")}, - {('s'), QLatin1String("static_cast")}, - {('s'), QLatin1String("switch")}, - {('t'), QLatin1String("template")}, - {('t'), QLatin1String("this")}, - {('t'), QLatin1String("thread_local")}, - {('t'), QLatin1String("throw")}, - {('t'), QLatin1String("try")}, - {('t'), QLatin1String("typeid")}, - {('t'), QLatin1String("typedef")}, - {('t'), QLatin1String("typename")}, - {('u'), QLatin1String("using")}, - {('v'), QLatin1String("volatile")}, - {('w'), QLatin1String("while")}, - {('x'), QLatin1String("xor")}, - {('x'), QLatin1String("xor_eq")}}; - - cpp_types = { - {('a'), QLatin1String("auto")}, - {('b'), QLatin1String("bool")}, - {('c'), QLatin1String("char")}, - {('c'), QLatin1String("char8_t")}, - {('c'), QLatin1String("char16_t")}, - {('c'), QLatin1String("char32_t")}, - {('c'), QLatin1String("class")}, - {('d'), QLatin1String("double")}, - {('e'), QLatin1String("enum")}, - {('f'), QLatin1String("float")}, - {('i'), QLatin1String("int")}, - {('i'), QLatin1String("int8_t")}, - {('i'), QLatin1String("int16_t")}, - {('i'), QLatin1String("int32_t")}, - {('i'), QLatin1String("int64_t")}, - {('i'), QLatin1String("int_fast8_t")}, - {('i'), QLatin1String("int_fast16_t")}, - {('i'), QLatin1String("int_fast32_t")}, - {('i'), QLatin1String("int_fast64_t")}, - {('i'), QLatin1String("intmax_t")}, - {('i'), QLatin1String("intptr_t")}, - {('l'), QLatin1String("long")}, - {('n'), QLatin1String("namespace")}, - {('Q'), QLatin1String("QHash")}, - {('Q'), QLatin1String("QList")}, - {('Q'), QLatin1String("QMap")}, - {('Q'), QLatin1String("QString")}, - {('Q'), QLatin1String("QVector")}, - {('s'), QLatin1String("short")}, - {('s'), QLatin1String("size_t")}, - {('s'), QLatin1String("signed")}, - {('s'), QLatin1String("struct")}, - {('s'), QLatin1String("ssize_t")}, - {('u'), QLatin1String("uint8_t")}, - {('u'), QLatin1String("uint16_t")}, - {('u'), QLatin1String("uint32_t")}, - {('u'), QLatin1String("uint64_t")}, - {('u'), QLatin1String("uint_fast8_t")}, - {('u'), QLatin1String("uint_fast16_t")}, - {('u'), QLatin1String("uint_fast32_t")}, - {('u'), QLatin1String("uint_fast64_t")}, - {('u'), QLatin1String("uint_least8_t")}, - {('u'), QLatin1String("uint_least16_t")}, - {('u'), QLatin1String("uint_least32_t")}, - {('u'), QLatin1String("uint_least64_t")}, - {('u'), QLatin1String("uintmax_t")}, - {('u'), QLatin1String("uintptr_t")}, - {('u'), QLatin1String("unsigned")}, - {('u'), QLatin1String("union")}, - {('v'), QLatin1String("void")}, - {('w'), QLatin1String("wchar_t")}}; - - cpp_literals = { - {('f'), QLatin1String("false")}, - {('n'), QLatin1String("nullptr")}, - {('N'), QLatin1String("NULL")}, - {('t'), QLatin1String("true")} - }; - - cpp_builtin = { - {('s'), QLatin1String("std")}, - {('s'), QLatin1String("string")}, - {('w'), QLatin1String("wstring")}, - {('c'), QLatin1String("cin")}, - {('c'), QLatin1String("cout")}, - {('c'), QLatin1String("cerr")}, - {('c'), QLatin1String("clog")}, - {('s'), QLatin1String("stdin")}, - {('s'), QLatin1String("stdout")}, - {('s'), QLatin1String("stderr")}, - {('s'), QLatin1String("stringstream")}, - {('i'), QLatin1String("istringstream")}, - {('o'), QLatin1String("ostringstream")}, - {('a'), QLatin1String("auto_ptr")}, - {('d'), QLatin1String("deque")}, - {('l'), QLatin1String("list")}, - {('q'), QLatin1String("queue")}, - {('s'), QLatin1String("stack")}, - {('v'), QLatin1String("vector")}, - {('m'), QLatin1String("map")}, - {('s'), QLatin1String("set")}, - {('b'), QLatin1String("bitset")}, - {('m'), QLatin1String("multiset")}, - {('m'), QLatin1String("multimap")}, - {('u'), QLatin1String("unordered_set")}, - {('u'), QLatin1String("unordered_map")}, - {('u'), QLatin1String("unordered_multiset")}, - {('u'), QLatin1String("unordered_multimap")}, - {('a'), QLatin1String("array")}, - {('s'), QLatin1String("shared_ptr")}, - {('a'), QLatin1String("abort")}, - {('t'), QLatin1String("terminate")}, - {('a'), QLatin1String("abs")}, - {('a'), QLatin1String("acos")}, - {('a'), QLatin1String("asin")}, - {('a'), QLatin1String("atan2")}, - {('a'), QLatin1String("atan")}, - {('c'), QLatin1String("calloc")}, - {('c'), QLatin1String("ceil")}, - {('c'), QLatin1String("cosh")}, - {('c'), QLatin1String("cos")}, - {('e'), QLatin1String("exit")}, - {('e'), QLatin1String("exp")}, - {('f'), QLatin1String("fabs")}, - {('f'), QLatin1String("floor")}, - {('f'), QLatin1String("fmod")}, - {('f'), QLatin1String("fprintf")}, - {('f'), QLatin1String("fputs")}, - {('f'), QLatin1String("free")}, - {('f'), QLatin1String("frexp")}, - {('f'), QLatin1String("fscanf")}, - {('f'), QLatin1String("future")}, - {('i'), QLatin1String("isalnum")}, - {('i'), QLatin1String("isalpha")}, - {('i'), QLatin1String("iscntrl")}, - {('i'), QLatin1String("isdigit")}, - {('i'), QLatin1String("isgraph")}, - {('i'), QLatin1String("islower")}, - {('i'), QLatin1String("isprint")}, - {('i'), QLatin1String("ispunct")}, - {('i'), QLatin1String("isspace")}, - {('i'), QLatin1String("isupper")}, - {('i'), QLatin1String("isxdigit")}, - {('t'), QLatin1String("tolower")}, - {('t'), QLatin1String("toupper")}, - {('l'), QLatin1String("labs")}, - {('l'), QLatin1String("ldexp")}, - {('l'), QLatin1String("log10")}, - {('l'), QLatin1String("log")}, - {('m'), QLatin1String("malloc")}, - {('r'), QLatin1String("realloc")}, - {('m'), QLatin1String("main")}, - {('m'), QLatin1String("memchr")}, - {('m'), QLatin1String("memcmp")}, - {('m'), QLatin1String("memcpy")}, - {('m'), QLatin1String("memset")}, - {('m'), QLatin1String("modf")}, - {('p'), QLatin1String("pow")}, - {('p'), QLatin1String("printf")}, - {('p'), QLatin1String("putchar")}, - {('p'), QLatin1String("puts")}, - {('s'), QLatin1String("scanf")}, - {('s'), QLatin1String("sinh")}, - {('s'), QLatin1String("sin")}, - {('s'), QLatin1String("snprintf")}, - {('s'), QLatin1String("sprintf")}, - {('s'), QLatin1String("sqrt")}, - {('s'), QLatin1String("sscanf")}, - {('s'), QLatin1String("strcat")}, - {('s'), QLatin1String("strchr")}, - {('s'), QLatin1String("strcmp")}, - {('s'), QLatin1String("strcpy")}, - {('s'), QLatin1String("strcspn")}, - {('s'), QLatin1String("strlen")}, - {('s'), QLatin1String("strncat")}, - {('s'), QLatin1String("strncmp")}, - {('s'), QLatin1String("strncpy")}, - {('s'), QLatin1String("strpbrk")}, - {('s'), QLatin1String("strrchr")}, - {('s'), QLatin1String("strspn")}, - {('s'), QLatin1String("strstr")}, - {('t'), QLatin1String("tanh")}, - {('t'), QLatin1String("tan")}, - {('v'), QLatin1String("vfprintf")}, - {('v'), QLatin1String("vprintf")}, - {('v'), QLatin1String("vsprintf")}, - {('e'), QLatin1String("endl")}, - {('i'), QLatin1String("initializer_list")}, - {('u'), QLatin1String("unique_ptr")}, - {('c'), QLatin1String("complex")}, - {('i'), QLatin1String("imaginary")} - }; - - cpp_other = { - {('d'), QLatin1String("define")}, - {('e'), QLatin1String("else")}, - {('e'), QLatin1String("elif")}, - {('e'), QLatin1String("endif")}, - {('e'), QLatin1String("error")}, - {('i'), QLatin1String("if")}, - {('i'), QLatin1String("ifdef")}, - {('i'), QLatin1String("ifndef")}, - {('i'), QLatin1String("include")}, - {('l'), QLatin1String("line")}, - {('p'), QLatin1String("pragma")}, - {('P'), QLatin1String("_Pragma")}, - {('u'), QLatin1String("undef")}, - {('w'), QLatin1String("warning")} - }; -} -void loadCppData(LanguageData &typess, - LanguageData &keywordss, - LanguageData &builtins, - LanguageData &literalss, - LanguageData &others){ - if (!cppDataInitialized) { - initCppData(); - cppDataInitialized = true; - } - - typess = cpp_types; - keywordss = cpp_keywords; - builtins = cpp_builtin; - literalss = cpp_literals; - others = cpp_other; - -} - -/**********************************************************/ -/* Shell Data *********************************************/ -/**********************************************************/ - -static bool shellDataInitialized = false; -static LanguageData shell_keywords; -static LanguageData shell_types; -static LanguageData shell_literals; -static LanguageData shell_builtin; -static LanguageData shell_other; -void initShellData() { - shell_keywords = { - {('i'), QLatin1String("if")}, - {('t'), QLatin1String("then")}, - {('e'), QLatin1String("else")}, - {('e'), QLatin1String("elif")}, - {('f'), QLatin1String("fi")}, - {('f'), QLatin1String("for")}, - {('w'), QLatin1String("while")}, - {('i'), QLatin1String("in")}, - {('d'), QLatin1String("do")}, - {('d'), QLatin1String("done")}, - {('c'), QLatin1String("case")}, - {('e'), QLatin1String("esac")}, - {('f'), QLatin1String("function")} - }; - - shell_types = {}; - - shell_literals = { - {('f'), QLatin1String("false")}, - {('t'), QLatin1String("true")} - }; - - shell_builtin = { - {('b'), QLatin1String("break")}, - {('c'), QLatin1String("cd")}, - {('c'), QLatin1String("continue")}, - {('e'), QLatin1String("eval")}, - {('e'), QLatin1String("exec")}, - {('e'), QLatin1String("exit")}, - {('e'), QLatin1String("export")}, - {('g'), QLatin1String("getopts")}, - {('h'), QLatin1String("hash")}, - {('p'), QLatin1String("pwd")}, - {('r'), QLatin1String("readonly")}, - {('r'), QLatin1String("return")}, - {('s'), QLatin1String("shift")}, - {('t'), QLatin1String("test")}, - {('t'), QLatin1String("timestrap")}, - {('u'), QLatin1String("umask")}, - {('u'), QLatin1String("unset")}, - {('B'), QLatin1String("Bash")}, - {('a'), QLatin1String("alias")}, - {('b'), QLatin1String("bind")}, - {('b'), QLatin1String("builtin")}, - {('c'), QLatin1String("caller")}, - {('c'), QLatin1String("command")}, - {('d'), QLatin1String("declare")}, - {('e'), QLatin1String("echo")}, - {('e'), QLatin1String("enable")}, - {('h'), QLatin1String("help")}, - {('l'), QLatin1String("let")}, - {('l'), QLatin1String("local")}, - {('l'), QLatin1String("logout")}, - {('m'), QLatin1String("mapfile")}, - {('p'), QLatin1String("printfread")}, - {('r'), QLatin1String("readarray")}, - {('s'), QLatin1String("source")}, - {('t'), QLatin1String("type")}, - {('t'), QLatin1String("typeset")}, - {('u'), QLatin1String("ulimit")}, - {('u'), QLatin1String("unalias")}, - {('m'), QLatin1String("modifiers")}, - {('s'), QLatin1String("set")}, - {('s'), QLatin1String("shopt")}, - {('a'), QLatin1String("autoload")}, - {('b'), QLatin1String("bg")}, - {('b'), QLatin1String("bindkey")}, - {('b'), QLatin1String("bye")}, - {('c'), QLatin1String("cap")}, - {('c'), QLatin1String("chdir")}, - {('c'), QLatin1String("clone")}, - {('c'), QLatin1String("comparguments")}, - {('c'), QLatin1String("compcall")}, - {('c'), QLatin1String("compctl")}, - {('c'), QLatin1String("compdescribe")}, - {('c'), QLatin1String("compfilescompgroups")}, - {('c'), QLatin1String("compquote")}, - {('c'), QLatin1String("comptags")}, - {('c'), QLatin1String("comptry")}, - {('c'), QLatin1String("compvalues")}, - {('d'), QLatin1String("dirs")}, - {('d'), QLatin1String("disable")}, - {('d'), QLatin1String("disown")}, - {('e'), QLatin1String("echotc")}, - {('e'), QLatin1String("echoti")}, - {('e'), QLatin1String("emulatefc")}, - {('f'), QLatin1String("fg")}, - {('f'), QLatin1String("float")}, - {('f'), QLatin1String("functions")}, - {('g'), QLatin1String("getcap")}, - {('g'), QLatin1String("getln")}, - {('h'), QLatin1String("history")}, - {('i'), QLatin1String("integer")}, - {('j'), QLatin1String("jobs")}, - {('k'), QLatin1String("kill")}, - {('l'), QLatin1String("limit")}, - {('l'), QLatin1String("log")}, - {('n'), QLatin1String("noglob")}, - {('p'), QLatin1String("popd")}, - {('p'), QLatin1String("printpushd")}, - {('p'), QLatin1String("pushln")}, - {('r'), QLatin1String("rehash")}, - {('s'), QLatin1String("sched")}, - {('s'), QLatin1String("setcap")}, - {('s'), QLatin1String("setopt")}, - {('s'), QLatin1String("stat")}, - {('s'), QLatin1String("suspend")}, - {('t'), QLatin1String("ttyctl")}, - {('u'), QLatin1String("unfunction")}, - {('u'), QLatin1String("unhash")}, - {('u'), QLatin1String("unlimitunsetopt")}, - {('v'), QLatin1String("vared")}, - {('w'), QLatin1String("wait")}, - {('w'), QLatin1String("whence")}, - {('w'), QLatin1String("where")}, - {('w'), QLatin1String("which")}, - {('z'), QLatin1String("zcompile")}, - {('z'), QLatin1String("zformat")}, - {('z'), QLatin1String("zftp")}, - {('z'), QLatin1String("zle")}, - {('z'), QLatin1String("zmodload")}, - {('z'), QLatin1String("zparseopts")}, - {('z'), QLatin1String("zprof")}, - {('z'), QLatin1String("zpty")}, - {('z'), QLatin1String("zregexparse")}, - {('z'), QLatin1String("zsocket")}, - {('z'), QLatin1String("zstyle")}, - {('z'), QLatin1String("ztcp")}, - {('g'), QLatin1String("git")}, - {('r'), QLatin1String("rm")}, - {('s'), QLatin1String("sudo")}, - {('f'), QLatin1String("fdisk")}, - {('a'), QLatin1String("apt")}, - {('s'), QLatin1String("snap")}, - {('f'), QLatin1String("flatpak")}, - {('s'), QLatin1String("snapcraft")}, - {('y'), QLatin1String("yaourt")}, - {('n'), QLatin1String("nmcli")}, - {('p'), QLatin1String("pacman")}, - {('p'), QLatin1String("pamac")}, - {('f'), QLatin1String("fsck")}, - {('m'), QLatin1String("mount")}, - {('m'), QLatin1String("mkdir")}, - {('m'), QLatin1String("mkswap")}, - {('s'), QLatin1String("sleep")}, - {('l'), QLatin1String("ls")}, - {('w'), QLatin1String("wget")}, - {('k'), QLatin1String("kill")}, - {('k'), QLatin1String("killall")}, - {('g'), QLatin1String("gdb")}, - {('Q'), QLatin1String("QOwnNotes")}, - {('q'), QLatin1String("qownnotes")}, - {('d'), QLatin1String("docker")}, - {('o'), QLatin1String("openssl")}, - {('p'), QLatin1String("php")}, - {('p'), QLatin1String("python")}, - {('p'), QLatin1String("perl")}, - {('g'), QLatin1String("go")}, - {('c'), QLatin1String("curl")} - }; - - shell_other = {}; -} - -void loadShellData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other) { - if (!shellDataInitialized) { - initShellData(); - shellDataInitialized = true; - } - types = shell_types; - keywords = shell_keywords; - builtin = shell_builtin; - literals = shell_literals; - other = shell_other; - -} - -/**********************************************************/ -/* JS Data *********************************************/ -/**********************************************************/ -static bool JSDataInitialized = false; -static LanguageData js_keywords; -static LanguageData js_types; -static LanguageData js_literals; -static LanguageData js_builtin; -static LanguageData js_other; -void initJSData() { - js_keywords = { - {('i'), QLatin1String("in")}, - {('o'), QLatin1String("of")}, - {('i'), QLatin1String("if")}, - {('f'), QLatin1String("for")}, - {('w'), QLatin1String("while")}, - {('f'), QLatin1String("finally")}, - {('n'), QLatin1String("new")}, - {('f'), QLatin1String("function")}, - {('d'), QLatin1String("do")}, - {('r'), QLatin1String("return")}, - {('v'), QLatin1String("void")}, - {('e'), QLatin1String("else")}, - {('b'), QLatin1String("break")}, - {('c'), QLatin1String("catch")}, - {('i'), QLatin1String("instanceof")}, - {('w'), QLatin1String("with")}, - {('t'), QLatin1String("throw")}, - {('c'), QLatin1String("case")}, - {('d'), QLatin1String("default")}, - {('t'), QLatin1String("try")}, - {('t'), QLatin1String("this")}, - {('s'), QLatin1String("switch")}, - {('c'), QLatin1String("continue")}, - {('t'), QLatin1String("typeof")}, - {('d'), QLatin1String("delete")}, - {('l'), QLatin1String("let")}, - {('y'), QLatin1String("yield")}, - {('c'), QLatin1String("const")}, - {('e'), QLatin1String("export")}, - {('s'), QLatin1String("super")}, - {('d'), QLatin1String("debugger")}, - {('a'), QLatin1String("as")}, - {('a'), QLatin1String("async")}, - {('a'), QLatin1String("await")}, - {('s'), QLatin1String("static")}, - {('i'), QLatin1String("import")}, - {('f'), QLatin1String("from")}, - {('a'), QLatin1String("as")} - }; - - js_types = { - {('v'), QLatin1String("var")}, - {('c'), QLatin1String("class")}, - {('b'), QLatin1String("byte")}, - {('e'), QLatin1String("enum")}, - {('f'), QLatin1String("float")}, - {('s'), QLatin1String("short")}, - {('l'), QLatin1String("long")}, - {('i'), QLatin1String("int")}, - {('v'), QLatin1String("void")}, - {('b'), QLatin1String("boolean")}, - {('d'), QLatin1String("double")} - }; - - js_literals = { - {('f'), QLatin1String("false")}, - {('n'), QLatin1String("null")}, - {('t'), QLatin1String("true")}, - {('u'), QLatin1String("undefined")}, - {('N'), QLatin1String("NaN")}, - {('I'), QLatin1String("Infinity")} - }; - - js_builtin = { - {('e'), QLatin1String("eval")}, - {('i'), QLatin1String("isFinite")}, - {('i'), QLatin1String("isNaN")}, - {('p'), QLatin1String("parseFloat")}, - {('p'), QLatin1String("parseInt")}, - {('d'), QLatin1String("decodeURI")}, - {('d'), QLatin1String("decodeURIComponent")}, - {('e'), QLatin1String("encodeURI")}, - {('e'), QLatin1String("encodeURIComponent")}, - {('e'), QLatin1String("escape")}, - {('u'), QLatin1String("unescape")}, - {('O'), QLatin1String("Object")}, - {('F'), QLatin1String("Function")}, - {('B'), QLatin1String("Boolean")}, - {('E'), QLatin1String("Error")}, - {('E'), QLatin1String("EvalError")}, - {('I'), QLatin1String("InternalError")}, - {('R'), QLatin1String("RangeError")}, - {('R'), QLatin1String("ReferenceError")}, - {('S'), QLatin1String("StopIteration")}, - {('S'), QLatin1String("SyntaxError")}, - {('T'), QLatin1String("TypeError")}, - {('U'), QLatin1String("URIError")}, - {('N'), QLatin1String("Number")}, - {('M'), QLatin1String("Math")}, - {('D'), QLatin1String("Date")}, - {('S'), QLatin1String("String")}, - {('R'), QLatin1String("RegExp")}, - {('A'), QLatin1String("Array")}, - {('F'), QLatin1String("Float32Array")}, - {('F'), QLatin1String("Float64Array")}, - {('I'), QLatin1String("Int16Array")}, - {('I'), QLatin1String("Int32Array")}, - {('I'), QLatin1String("Int8Array")}, - {('U'), QLatin1String("Uint16Array")}, - {('U'), QLatin1String("Uint32Array")}, - {('U'), QLatin1String("Uint8Array")}, - {('U'), QLatin1String("Uint8ClampedArray")}, - {('A'), QLatin1String("ArrayBuffer")}, - {('D'), QLatin1String("DataView")}, - {('J'), QLatin1String("JSON")}, - {('I'), QLatin1String("Intl")}, - {('a'), QLatin1String("arguments")}, - {('r'), QLatin1String("require")}, - {('m'), QLatin1String("module")}, - {('c'), QLatin1String("console")}, - {('w'), QLatin1String("window")}, - {('d'), QLatin1String("document")}, - {('S'), QLatin1String("Symbol")}, - {('S'), QLatin1String("Set")}, - {('M'), QLatin1String("Map")}, - {('W'), QLatin1String("WeakSet")}, - {('W'), QLatin1String("WeakMap")}, - {('P'), QLatin1String("Proxy")}, - {('R'), QLatin1String("Reflect")}, - {('P'), QLatin1String("Promise")} - }; - - js_other = {}; -} - -void loadJSData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other) { - if (!JSDataInitialized) { - initJSData(); - JSDataInitialized = true; - } - types = js_types; - keywords = js_keywords; - builtin = js_builtin; - literals = js_literals; - other = js_other; -} - -/**********************************************************/ -/* PHP Data *********************************************/ -/**********************************************************/ -static bool PHPDataInitialized = false; -static LanguageData php_keywords; -static LanguageData php_types; -static LanguageData php_literals; -static LanguageData php_builtin; -static LanguageData php_other; -void initPHPData() { - php_keywords = { - {('a'), QLatin1String("and")}, - {('l'), QLatin1String("list")}, - {('a'), QLatin1String("abstract")}, - {('g'), QLatin1String("global")}, - {('p'), QLatin1String("private")}, - {('e'), QLatin1String("echo")}, - {('i'), QLatin1String("interface")}, - {('a'), QLatin1String("as")}, - {('s'), QLatin1String("static")}, - {('e'), QLatin1String("endswitch")}, - {('i'), QLatin1String("if")}, - {('e'), QLatin1String("endwhile")}, - {('o'), QLatin1String("or")}, - {('c'), QLatin1String("const")}, - {('f'), QLatin1String("for")}, - {('e'), QLatin1String("endforeach")}, - {('s'), QLatin1String("self")}, - {('w'), QLatin1String("while")}, - {('i'), QLatin1String("isset")}, - {('p'), QLatin1String("public")}, - {('p'), QLatin1String("protected")}, - {('e'), QLatin1String("exit")}, - {('f'), QLatin1String("foreach")}, - {('t'), QLatin1String("throw")}, - {('e'), QLatin1String("elseif")}, - {('e'), QLatin1String("empty")}, - {('d'), QLatin1String("do")}, - {('x'), QLatin1String("xor")}, - {('r'), QLatin1String("return")}, - {('p'), QLatin1String("parent")}, - {('c'), QLatin1String("clone")}, - {('u'), QLatin1String("use")}, - {('e'), QLatin1String("else")}, - {('b'), QLatin1String("break")}, - {('p'), QLatin1String("print")}, - {('e'), QLatin1String("eval")}, - {('n'), QLatin1String("new")}, - {('c'), QLatin1String("catch")}, - {('c'), QLatin1String("case")}, - {('e'), QLatin1String("exception")}, - {('d'), QLatin1String("default")}, - {('d'), QLatin1String("die")}, - {('e'), QLatin1String("enddeclare")}, - {('f'), QLatin1String("final")}, - {('t'), QLatin1String("try")}, - {('s'), QLatin1String("switch")}, - {('c'), QLatin1String("continue")}, - {('e'), QLatin1String("endfor")}, - {('e'), QLatin1String("endif")}, - {('d'), QLatin1String("declare")}, - {('u'), QLatin1String("unset")}, - {('t'), QLatin1String("trait")}, - {('g'), QLatin1String("goto")}, - {('i'), QLatin1String("instanceof")}, - {('i'), QLatin1String("insteadof")}, - {('y'), QLatin1String("yield")}, - {('f'), QLatin1String("finally")} - }; - - php_types = { - {('v'), QLatin1String("var")}, - {('c'), QLatin1String("class")}, - {('e'), QLatin1String("enum")}, - {('a'), QLatin1String("array")} - }; - - php_literals = { - {('f'), QLatin1String("false")}, - {('t'), QLatin1String("true")}, - {('n'), QLatin1String("null")} - }; - - php_builtin = { - - - }; - - php_other = { - {('i'), QLatin1String("include_once")}, - {('i'), QLatin1String("include")}, - {('_'), QLatin1String("__FILE__")}, - {('r'), QLatin1String("require")}, - {('r'), QLatin1String("require_once")}, - {('_'), QLatin1String("__CLASS__")}, - {('_'), QLatin1String("__LINE__")}, - {('_'), QLatin1String("__METHOD__")}, - {('_'), QLatin1String("__FUNCTION__")}, - {('_'), QLatin1String("__DIR__")}, - {('_'), QLatin1String("__NAMESPACE__")}, - - {('S'), QLatin1String("SERVER")}, - {('G'), QLatin1String("GET")}, - {('P'), QLatin1String("POST")}, - {('F'), QLatin1String("FILES")}, - {('R'), QLatin1String("REQUEST")}, - {('S'), QLatin1String("SESSION")}, - {('E'), QLatin1String("ENV")}, - {('C'), QLatin1String("COOKIE")}, - {('G'), QLatin1String("GLOBALS")}, - {('H'), QLatin1String("HTTP_RAW_POST_DATA")}, - {('a'), QLatin1String("argc")}, - {('a'), QLatin1String("argv")}, - {('p'), QLatin1String("php_errormsg")}, - {('h'), QLatin1String("http_response_header")} -}; -} -void loadPHPData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other) { - if (!PHPDataInitialized) { - initPHPData(); - PHPDataInitialized = true; - } - types = php_types; - keywords = php_keywords; - builtin = php_builtin; - literals = php_literals; - other = php_other; -} - -/**********************************************************/ -/* QML Data *********************************************/ -/**********************************************************/ -static bool QMLDataInitialized = false; -static LanguageData qml_keywords; -static LanguageData qml_types; -static LanguageData qml_literals; -static LanguageData qml_builtin; -static LanguageData qml_other; - -void initQMLData() { - qml_keywords = { - {('d'), QLatin1String("default")}, - {('p'), QLatin1String("property")}, - {('i'), QLatin1String("int")}, - {('v'), QLatin1String("var")}, - {('s'), QLatin1String("string")}, - {('f'), QLatin1String("function")}, - {('r'), QLatin1String("readonly")}, - {('M'), QLatin1String("MouseArea")}, - {('d'), QLatin1String("delegate")}, - {('i'), QLatin1String("if")}, - {('e'), QLatin1String("else")}, - - {('e'), QLatin1String("eval")}, - {('i'), QLatin1String("isFinite")}, - {('i'), QLatin1String("isNaN")}, - {('p'), QLatin1String("parseFloat")}, - {('p'), QLatin1String("parseInt")}, - {('d'), QLatin1String("decodeURI")}, - {('d'), QLatin1String("decodeURIComponent")}, - {('e'), QLatin1String("encodeURI")}, - {('e'), QLatin1String("encodeURIComponent")}, - {('e'), QLatin1String("escape")}, - {('u'), QLatin1String("unescape")}, - {('O'), QLatin1String("Object")}, - {('E'), QLatin1String("Error")}, - {('E'), QLatin1String("EvalError")}, - {('I'), QLatin1String("InternalError")}, - {('R'), QLatin1String("RangeError")}, - {('R'), QLatin1String("ReferenceError")}, - {('S'), QLatin1String("StopIteration")}, - {('S'), QLatin1String("SyntaxError")}, - {('T'), QLatin1String("TypeError")}, - {('U'), QLatin1String("URIError")}, - {('N'), QLatin1String("Number")}, - {('M'), QLatin1String("Math")}, - {('D'), QLatin1String("Date")}, - {('S'), QLatin1String("String")}, - {('R'), QLatin1String("RegExp")}, - {('A'), QLatin1String("Array")}, - {('F'), QLatin1String("Float32Array")}, - {('F'), QLatin1String("Float64Array")}, - {('I'), QLatin1String("Int16Array")}, - {('I'), QLatin1String("Int32Array")}, - {('I'), QLatin1String("Int8Array")}, - {('U'), QLatin1String("Uint16Array")}, - {('U'), QLatin1String("Uint32Array")}, - {('U'), QLatin1String("Uint8Array")}, - {('U'), QLatin1String("Uint8ClampedArray")}, - {('A'), QLatin1String("ArrayBuffer")}, - {('D'), QLatin1String("DataView")}, - {('J'), QLatin1String("JSON")}, - {('I'), QLatin1String("Intl")}, - {('a'), QLatin1String("arguments")}, - {('m'), QLatin1String("module")}, - {('c'), QLatin1String("console")}, - {('w'), QLatin1String("window")}, - {('d'), QLatin1String("document")}, - {('S'), QLatin1String("Symbol")}, - {('S'), QLatin1String("Set")}, - {('M'), QLatin1String("Map")}, - {('W'), QLatin1String("WeakSet")}, - {('W'), QLatin1String("WeakMap")}, - {('P'), QLatin1String("Proxy")}, - {('R'), QLatin1String("Reflect")}, - {('B'), QLatin1String("Behavior")}, - {('c'), QLatin1String("color")}, - {('c'), QLatin1String("coordinate")}, - {('d'), QLatin1String("date")}, - {('e'), QLatin1String("enumeration")}, - {('f'), QLatin1String("font")}, - {('g'), QLatin1String("geocircle")}, - {('g'), QLatin1String("georectangle")}, - {('g'), QLatin1String("geoshape")}, - {('l'), QLatin1String("list")}, - {('m'), QLatin1String("matrix4x4")}, - {('p'), QLatin1String("parent")}, - {('p'), QLatin1String("point")}, - {('q'), QLatin1String("quaternion")}, - {('r'), QLatin1String("real")}, - {('s'), QLatin1String("size")}, - {('s'), QLatin1String("string")}, - {('v'), QLatin1String("variant")}, - {('v'), QLatin1String("vector2d")}, - {('v'), QLatin1String("vector3d")}, - {('v'), QLatin1String("vector4d")}, - {('P'), QLatin1String("Promise")} -}; - - qml_types = { - {('R'), QLatin1String("Rectangle")}, - {('T'), QLatin1String("Text")}, - {('c'), QLatin1String("color")}, - {('I'), QLatin1String("Item")}, - {('u'), QLatin1String("url")}, - {('C'), QLatin1String("Component")}, - {('B'), QLatin1String("Button")}, - {('T'), QLatin1String("TextInput")}, - {('L'), QLatin1String("ListView")}, - - -}; - - qml_literals = { - {('f'), QLatin1String("false")}, - {('t'), QLatin1String("true")} -}; - - qml_builtin = { - -}; - - qml_other = { - {('i'), QLatin1String("import")} -}; -} -void loadQMLData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other){ - if (!QMLDataInitialized) { - initQMLData(); - QMLDataInitialized = true; - } - types = qml_types; - keywords = qml_keywords; - builtin = qml_builtin; - literals = qml_literals; - other = qml_other; -} - -/**********************************************************/ -/* Python Data *********************************************/ -/**********************************************************/ -static bool PyDataInitialized = false; -static LanguageData py_keywords; -static LanguageData py_types; -static LanguageData py_literals; -static LanguageData py_builtin; -static LanguageData py_other; - -void initPyData() { - py_keywords = { - {('a'), QLatin1String("and")}, - {('e'), QLatin1String("elif")}, - {('i'), QLatin1String("is")}, - {('g'), QLatin1String("global")}, - {('a'), QLatin1String("as")}, - {('i'), QLatin1String("in")}, - {('i'), QLatin1String("if")}, - {('f'), QLatin1String("from")}, - {('r'), QLatin1String("raise")}, - {('f'), QLatin1String("for")}, - {('e'), QLatin1String("except")}, - {('f'), QLatin1String("finally")}, - {('p'), QLatin1String("print")}, - {('p'), QLatin1String("pass")}, - {('r'), QLatin1String("return")}, - {('e'), QLatin1String("exec")}, - {('e'), QLatin1String("else")}, - {('b'), QLatin1String("break")}, - {('n'), QLatin1String("not")}, - {('w'), QLatin1String("with")}, - {('c'), QLatin1String("class")}, - {('a'), QLatin1String("assert")}, - {('y'), QLatin1String("yield")}, - {('t'), QLatin1String("try")}, - {('w'), QLatin1String("while")}, - {('c'), QLatin1String("continue")}, - {('d'), QLatin1String("del")}, - {('o'), QLatin1String("or")}, - {('d'), QLatin1String("def")}, - {('l'), QLatin1String("lambda")}, - {('a'), QLatin1String("async")}, - {('a'), QLatin1String("await")}, - {('n'), QLatin1String("nonlocal")}, - }; - - py_types = { - - }; - - py_literals = { - {('F'), QLatin1String("False")}, - {('T'), QLatin1String("True")}, - {('N'), QLatin1String("None")} - }; - - py_builtin = { - { ('_'), QLatin1String("__import__") }, - { ('a'), QLatin1String("abs") }, - { ('a'), QLatin1String("all") }, - { ('a'), QLatin1String("any") }, - { ('a'), QLatin1String("apply") }, - { ('a'), QLatin1String("ascii") }, - { ('b'), QLatin1String("basestring") }, - { ('b'), QLatin1String("bin") }, - { ('b'), QLatin1String("bool") }, - { ('b'), QLatin1String("buffer") }, - { ('b'), QLatin1String("bytearray") }, - { ('b'), QLatin1String("bytes") }, - { ('c'), QLatin1String("callable") }, - { ('c'), QLatin1String("chr") }, - { ('c'), QLatin1String("classmethod") }, - { ('c'), QLatin1String("cmp") }, - { ('c'), QLatin1String("coerce") }, - { ('c'), QLatin1String("compile") }, - { ('c'), QLatin1String("complex") }, - { ('d'), QLatin1String("delattr") }, - { ('d'), QLatin1String("dict") }, - { ('d'), QLatin1String("dir") }, - { ('d'), QLatin1String("divmod") }, - { ('e'), QLatin1String("enumerate") }, - { ('e'), QLatin1String("eval") }, - { ('e'), QLatin1String("execfile") }, - { ('f'), QLatin1String("file") }, - { ('f'), QLatin1String("filter") }, - { ('f'), QLatin1String("float") }, - { ('f'), QLatin1String("format") }, - { ('f'), QLatin1String("frozenset") }, - { ('g'), QLatin1String("getattr") }, - { ('g'), QLatin1String("globals") }, - { ('h'), QLatin1String("hasattr") }, - { ('h'), QLatin1String("hash") }, - { ('h'), QLatin1String("help") }, - { ('h'), QLatin1String("hex") }, - { ('i'), QLatin1String("id") }, - { ('i'), QLatin1String("input") }, - { ('i'), QLatin1String("int") }, - { ('i'), QLatin1String("intern") }, - { ('i'), QLatin1String("isinstance") }, - { ('i'), QLatin1String("issubclass") }, - { ('i'), QLatin1String("iter") }, - { ('l'), QLatin1String("len") }, - { ('l'), QLatin1String("list") }, - { ('l'), QLatin1String("locals") }, - { ('l'), QLatin1String("long") }, - { ('m'), QLatin1String("map") }, - { ('m'), QLatin1String("max") }, - { ('m'), QLatin1String("memoryview") }, - { ('m'), QLatin1String("min") }, - { ('n'), QLatin1String("next") }, - { ('o'), QLatin1String("object") }, - { ('o'), QLatin1String("oct") }, - { ('o'), QLatin1String("open") }, - { ('o'), QLatin1String("ord") }, - { ('p'), QLatin1String("pow") }, - { ('p'), QLatin1String("property") }, - { ('r'), QLatin1String("range") }, - { ('r'), QLatin1String("raw_input") }, - { ('r'), QLatin1String("reduce") }, - { ('r'), QLatin1String("reload") }, - { ('r'), QLatin1String("repr") }, - { ('r'), QLatin1String("reversed") }, - { ('r'), QLatin1String("round") }, - { ('s'), QLatin1String("set") }, - { ('s'), QLatin1String("setattr") }, - { ('s'), QLatin1String("slice") }, - { ('s'), QLatin1String("sorted") }, - { ('s'), QLatin1String("staticmethod") }, - { ('s'), QLatin1String("str") }, - { ('s'), QLatin1String("sum") }, - { ('s'), QLatin1String("super") }, - { ('t'), QLatin1String("tuple") }, - { ('t'), QLatin1String("type") }, - { ('u'), QLatin1String("unichr") }, - { ('u'), QLatin1String("unicode") }, - { ('v'), QLatin1String("vars") }, - { ('x'), QLatin1String("xrange") }, - { ('z'), QLatin1String("zip") } - }; - - py_other = { - {('i'), QLatin1String("import")} - }; -} -void loadPythonData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other){ - if (!PyDataInitialized) { - initPyData(); - PyDataInitialized = true; - } - types = py_types; - keywords = py_keywords; - builtin = py_builtin; - literals = py_literals; - other = py_other; -} - -/********************************************************/ -/*** Rust DATA ***********************************/ -/********************************************************/ -static bool rustDataInitialized = false; -static LanguageData rust_keywords; -static LanguageData rust_types; -static LanguageData rust_literals; -static LanguageData rust_builtin; -static LanguageData rust_other; -void initRustData() { -rust_keywords = { - {('a'), QLatin1String("abstract")}, - {('a'), QLatin1String("alignof")}, - {('a'), QLatin1String("as")}, - {('a'), QLatin1String("async")}, - {('a'), QLatin1String("await")}, - {('b'), QLatin1String("be")}, - {('b'), QLatin1String("box")}, - {('b'), QLatin1String("break")}, - {('c'), QLatin1String("const")}, - {('c'), QLatin1String("continue")}, - {('c'), QLatin1String("crate")}, - {('d'), QLatin1String("do")}, - {('d'), QLatin1String("dyn")}, - {('e'), QLatin1String("else")}, - {('e'), QLatin1String("extern")}, - {('f'), QLatin1String("final")}, - {('f'), QLatin1String("fn")}, - {('f'), QLatin1String("for")}, - {('i'), QLatin1String("if")}, - {('i'), QLatin1String("impl")}, - {('i'), QLatin1String("in")}, - {('l'), QLatin1String("let")}, - {('l'), QLatin1String("loop")}, - {('m'), QLatin1String("match")}, - {('m'), QLatin1String("mod")}, - {('m'), QLatin1String("move")}, - {('m'), QLatin1String("mut")}, - {('o'), QLatin1String("offsetof")}, - {('o'), QLatin1String("once")}, - {('o'), QLatin1String("override")}, - {('p'), QLatin1String("priv")}, - {('p'), QLatin1String("pub")}, - {('p'), QLatin1String("pure")}, - {('r'), QLatin1String("ref")}, - {('r'), QLatin1String("return")}, - {('s'), QLatin1String("sizeof")}, - {('s'), QLatin1String("static")}, - {('s'), QLatin1String("self")}, - {('S'), QLatin1String("Self")}, - {('s'), QLatin1String("super")}, - {('t'), QLatin1String("trait")}, - {('t'), QLatin1String("type")}, - {('t'), QLatin1String("typeof")}, - {('u'), QLatin1String("unsafe")}, - {('u'), QLatin1String("unsized")}, - {('u'), QLatin1String("use")}, - {('v'), QLatin1String("virtual")}, - {('w'), QLatin1String("where")}, - {('w'), QLatin1String("while")}, - {('y'), QLatin1String("yield")}, -}; - -rust_types = { - {('u'), QLatin1String("union")}, - {('e'), QLatin1String("enum")}, - {('s'), QLatin1String("struct")}, - - {('i'), QLatin1String("i8")}, - {('i'), QLatin1String("i16")}, - {('i'), QLatin1String("i32")}, - {('i'), QLatin1String("i64")}, - {('i'), QLatin1String("i128")}, - {('i'), QLatin1String("isize")}, - {('u'), QLatin1String("u8")}, - {('u'), QLatin1String("u16")}, - {('u'), QLatin1String("u32")}, - {('u'), QLatin1String("u64")}, - {('u'), QLatin1String("u128")}, - {('u'), QLatin1String("usize")}, - {('f'), QLatin1String("f32")}, - {('f'), QLatin1String("f64")}, - {('s'), QLatin1String("str")}, - {('c'), QLatin1String("char")}, - {('b'), QLatin1String("bool")}, - {('B'), QLatin1String("Box")}, - {('O'), QLatin1String("Option")}, - {('R'), QLatin1String("Result")}, - {('S'), QLatin1String("String")}, - {('V'), QLatin1String("Vec")} -}; - -rust_literals = { - {('f'), QLatin1String("false")}, - {('t'), QLatin1String("true")} -}; - -rust_builtin = { - -}; - -rust_other = { - {('a'), QLatin1String("assert!")}, - {('a'), QLatin1String("assert_eq!")}, - {('b'), QLatin1String("bitflags!")}, - {('b'), QLatin1String("bytes!")}, - {('c'), QLatin1String("cfg!")}, - {('c'), QLatin1String("col!")}, - {('c'), QLatin1String("concat!")}, - {('c'), QLatin1String("concat_idents!")}, - {('d'), QLatin1String("debug_assert!")}, - {('d'), QLatin1String("debug_assert_eq!")}, - {('e'), QLatin1String("env!")}, - {('p'), QLatin1String("panic!")}, - {('f'), QLatin1String("file!")}, - {('f'), QLatin1String("format!")}, - {('f'), QLatin1String("format_args!")}, - {('i'), QLatin1String("include_bin!")}, - {('i'), QLatin1String("include_str!")}, - {('l'), QLatin1String("line!")}, - {('l'), QLatin1String("local_data_key!")}, - {('m'), QLatin1String("module_path!")}, - {('o'), QLatin1String("option_env!")}, - {('p'), QLatin1String("print!")}, - {('p'), QLatin1String("println!")}, - {('s'), QLatin1String("select!")}, - {('s'), QLatin1String("stringify!")}, - {('t'), QLatin1String("try!")}, - {('u'), QLatin1String("unimplemented!")}, - {('u'), QLatin1String("unreachable!")}, - {('v'), QLatin1String("vec!")}, - {('w'), QLatin1String("write!")}, - {('w'), QLatin1String("writeln!")}, - {('m'), QLatin1String("macro_rules!")}, - {('a'), QLatin1String("assert_ne!")}, - {('d'), QLatin1String("debug_assert_ne!")} -}; -} -void loadRustData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other) { - if (!rustDataInitialized) { - initRustData(); - rustDataInitialized = true; - } - types = rust_types; - keywords = rust_keywords; - builtin = rust_builtin; - literals = rust_literals; - other = rust_other; -} - -/********************************************************/ -/*** Java DATA ***********************************/ -/********************************************************/ -static bool javaDataInitialized = false; -static LanguageData java_keywords; -static LanguageData java_types; -static LanguageData java_literals; -static LanguageData java_builtin; -static LanguageData java_other; -void initJavaData() { - java_keywords = { - {('a'), QLatin1String("abstract")}, - {('a'), QLatin1String("assert")}, - {('b'), QLatin1String("break")}, - {('c'), QLatin1String("case")}, - {('c'), QLatin1String("catch")}, - {('c'), QLatin1String("const")}, - {('c'), QLatin1String("continue")}, - {('d'), QLatin1String("default")}, - {('d'), QLatin1String("do")}, - {('e'), QLatin1String("else")}, - {('e'), QLatin1String("exports")}, - {('e'), QLatin1String("extends")}, - {('f'), QLatin1String("final")}, - {('f'), QLatin1String("finally")}, - {('f'), QLatin1String("for")}, - {('g'), QLatin1String("goto")}, - {('i'), QLatin1String("if")}, - {('i'), QLatin1String("implements")}, - {('i'), QLatin1String("import")}, - {('i'), QLatin1String("instanceof")}, - {('i'), QLatin1String("interface")}, - {('l'), QLatin1String("long")}, - {('m'), QLatin1String("module")}, - {('n'), QLatin1String("native")}, - {('n'), QLatin1String("new")}, - {('n'), QLatin1String("null")}, - {('o'), QLatin1String("open")}, - {('o'), QLatin1String("opens")}, - {('p'), QLatin1String("package")}, - {('p'), QLatin1String("private")}, - {('p'), QLatin1String("protected")}, - {('p'), QLatin1String("provides")}, - {('p'), QLatin1String("public")}, - {('r'), QLatin1String("requires")}, - {('r'), QLatin1String("return")}, - {('s'), QLatin1String("static")}, - {('s'), QLatin1String("strictfp")}, - {('s'), QLatin1String("super")}, - {('s'), QLatin1String("switch")}, - {('s'), QLatin1String("synchronized")}, - {('t'), QLatin1String("this")}, - {('t'), QLatin1String("throw")}, - {('t'), QLatin1String("throws")}, - {('t'), QLatin1String("to")}, - {('t'), QLatin1String("transient")}, - {('t'), QLatin1String("transitive")}, - {('t'), QLatin1String("try")}, - {('u'), QLatin1String("uses")}, - {('v'), QLatin1String("var")}, - {('v'), QLatin1String("volatile")}, - {('w'), QLatin1String("while")}, - {('w'), QLatin1String("with")}, - {('y'), QLatin1String("yield")} - }; - - java_types = { - {('v'), QLatin1String("void")}, - {('f'), QLatin1String("float")}, - {('b'), QLatin1String("boolean")}, - {('b'), QLatin1String("byte")}, - {('i'), QLatin1String("int")}, - {('c'), QLatin1String("char")}, - {('c'), QLatin1String("class")}, - {('d'), QLatin1String("double")}, - {('e'), QLatin1String("enum")}, - {('s'), QLatin1String("short")}, - - }; - - java_literals = { - {('f'), QLatin1String("false")}, - {('t'), QLatin1String("true")} - }; - - java_builtin = { - - }; - - java_other = { - - }; -} -void loadJavaData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other) { - if (!javaDataInitialized) { - initJavaData(); - javaDataInitialized = true; - } - types = java_types; - keywords = java_keywords; - builtin = java_builtin; - literals = java_literals; - other = java_other; -} - -/********************************************************/ -/*** C# DATA *************************************/ -/********************************************************/ -static bool csharpDataInitialized = false; -static LanguageData csharp_keywords; -static LanguageData csharp_types; -static LanguageData csharp_literals; -static LanguageData csharp_builtin; -static LanguageData csharp_other; -void initCSharpData() { - csharp_keywords = { - {('a'), QLatin1String("abstract")}, - {('a'), QLatin1String("add")}, - {('a'), QLatin1String("alias")}, - {('a'), QLatin1String("as")}, - {('a'), QLatin1String("ascending")}, - {('a'), QLatin1String("async")}, - {('a'), QLatin1String("await")}, - {('b'), QLatin1String("base")}, - {('b'), QLatin1String("break")}, - {('c'), QLatin1String("case")}, - {('c'), QLatin1String("catch")}, - {('c'), QLatin1String("checked")}, - {('c'), QLatin1String("const")}, - {('c'), QLatin1String("continue")}, - {('d'), QLatin1String("decimal")}, - {('d'), QLatin1String("default")}, - {('d'), QLatin1String("delegate")}, - {('d'), QLatin1String("descending")}, - {('d'), QLatin1String("do")}, - {('d'), QLatin1String("dynamic")}, - {('e'), QLatin1String("else")}, - {('e'), QLatin1String("event")}, - {('e'), QLatin1String("explicit")}, - {('e'), QLatin1String("extern")}, - {('f'), QLatin1String("finally")}, - {('f'), QLatin1String("fixed")}, - {('f'), QLatin1String("for")}, - {('f'), QLatin1String("foreach")}, - {('f'), QLatin1String("from")}, - {('g'), QLatin1String("get")}, - {('g'), QLatin1String("global")}, - {('g'), QLatin1String("goto")}, - {('g'), QLatin1String("group")}, - {('i'), QLatin1String("if")}, - {('i'), QLatin1String("implicit")}, - {('i'), QLatin1String("in")}, - {('i'), QLatin1String("interface")}, - {('i'), QLatin1String("internal")}, - {('i'), QLatin1String("into")}, - {('i'), QLatin1String("is")}, - {('j'), QLatin1String("join")}, - {('l'), QLatin1String("let")}, - {('l'), QLatin1String("lock")}, - {('l'), QLatin1String("long")}, - {('n'), QLatin1String("namespace")}, - {('n'), QLatin1String("new")}, - {('o'), QLatin1String("object")}, - {('o'), QLatin1String("operator")}, - {('o'), QLatin1String("orderby")}, - {('o'), QLatin1String("out")}, - {('o'), QLatin1String("override")}, - {('p'), QLatin1String("params")}, - {('p'), QLatin1String("partial")}, - {('p'), QLatin1String("private")}, - {('p'), QLatin1String("protected")}, - {('p'), QLatin1String("public")}, - {('r'), QLatin1String("readonly")}, - {('r'), QLatin1String("ref")}, - {('r'), QLatin1String("remove")}, - {('r'), QLatin1String("return")}, - {('s'), QLatin1String("sealed")}, - {('s'), QLatin1String("select")}, - {('s'), QLatin1String("set")}, - {('s'), QLatin1String("sizeof")}, - {('s'), QLatin1String("stackalloc")}, - {('s'), QLatin1String("static")}, - {('s'), QLatin1String("switch")}, - {('t'), QLatin1String("this")}, - {('t'), QLatin1String("throw")}, - {('t'), QLatin1String("try")}, - {('t'), QLatin1String("typeof")}, - {('u'), QLatin1String("unchecked")}, - {('u'), QLatin1String("unsafe")}, - {('u'), QLatin1String("using")}, - {('v'), QLatin1String("value")}, - {('v'), QLatin1String("virtual")}, - {('v'), QLatin1String("volatile")}, - {('w'), QLatin1String("where")}, - {('w'), QLatin1String("while")}, - {('y'), QLatin1String("yield")} - }; - - csharp_types = { - {('b'), QLatin1String("bool")}, - {('b'), QLatin1String("byte")}, - {('c'), QLatin1String("char")}, - {('c'), QLatin1String("class")}, - {('d'), QLatin1String("double")}, - {('e'), QLatin1String("enum")}, - {('f'), QLatin1String("float")}, - {('i'), QLatin1String("int")}, - {('s'), QLatin1String("sbyte")}, - {('s'), QLatin1String("short")}, - {('s'), QLatin1String("string")}, - {('s'), QLatin1String("struct")}, - {('u'), QLatin1String("uint")}, - {('u'), QLatin1String("ulong")}, - {('u'), QLatin1String("ushort")}, - {('v'), QLatin1String("var")}, - {('v'), QLatin1String("void")}, - }; - - csharp_literals = { - {('f'), QLatin1String("false")}, - {('t'), QLatin1String("true")}, - {('n'), QLatin1String("null")} - }; - - csharp_builtin = { - - }; - - csharp_other = { - {('d'), QLatin1String("define")}, - {('e'), QLatin1String("elif")}, - {('e'), QLatin1String("else")}, - {('e'), QLatin1String("endif")}, - {('e'), QLatin1String("endregion")}, - {('e'), QLatin1String("error")}, - {('i'), QLatin1String("if")}, - {('l'), QLatin1String("line")}, - {('p'), QLatin1String("pragma")}, - {('r'), QLatin1String("region")}, - {('u'), QLatin1String("undef")}, - {('w'), QLatin1String("warning")} - }; -} -void loadCSharpData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other){ - if (!csharpDataInitialized) { - initCSharpData(); - csharpDataInitialized = true; - } - types = csharp_types; - keywords = csharp_keywords; - builtin = csharp_builtin; - literals = csharp_literals; - other = csharp_other; -} - -/********************************************************/ -/*** Go DATA *************************************/ -/********************************************************/ -static bool goDataInitialized = false; -static LanguageData go_keywords; -static LanguageData go_types; -static LanguageData go_literals; -static LanguageData go_builtin; -static LanguageData go_other; -void initGoData(){ - go_keywords = { - {('b'), QLatin1String("break")}, - {('c'), QLatin1String("case")}, - {('c'), QLatin1String("chan")}, - {('c'), QLatin1String("const")}, - {('c'), QLatin1String("continue")}, - {('d'), QLatin1String("default")}, - {('d'), QLatin1String("defer")}, - {('e'), QLatin1String("else")}, - {('f'), QLatin1String("fallthrough")}, - {('f'), QLatin1String("for")}, - {('f'), QLatin1String("func")}, - {('g'), QLatin1String("go")}, - {('t'), QLatin1String("to")}, - {('i'), QLatin1String("if")}, - {('i'), QLatin1String("import")}, - {('i'), QLatin1String("interface")}, - {('p'), QLatin1String("package")}, - {('r'), QLatin1String("range")}, - {('r'), QLatin1String("return")}, - {('s'), QLatin1String("select")}, - {('s'), QLatin1String("struct")}, - {('s'), QLatin1String("switch")}, - {('t'), QLatin1String("type")}, - }; - - go_types = { - {('m'), QLatin1String("map")}, - {('s'), QLatin1String("struct")}, - {('v'), QLatin1String("var")}, - {('b'), QLatin1String("bool")}, - {('b'), QLatin1String("byte")}, - {('c'), QLatin1String("complex64")}, - {('c'), QLatin1String("complex128")}, - {('f'), QLatin1String("float32")}, - {('f'), QLatin1String("float64")}, - {('i'), QLatin1String("int8")}, - {('i'), QLatin1String("int16")}, - {('i'), QLatin1String("int32")}, - {('i'), QLatin1String("int64")}, - {('s'), QLatin1String("string")}, - {('u'), QLatin1String("uint8")}, - {('u'), QLatin1String("uint16")}, - {('u'), QLatin1String("uint32")}, - {('u'), QLatin1String("uint64")}, - {('i'), QLatin1String("int")}, - {('u'), QLatin1String("uint")}, - {('u'), QLatin1String("uintptr")}, - {('r'), QLatin1String("rune")} - }; - - go_literals = { - {('f'), QLatin1String("false")}, - {('t'), QLatin1String("true")}, - {('n'), QLatin1String("nil")}, - {('i'), QLatin1String("iota")} - }; - - go_builtin = { - {('a'), QLatin1String("append")}, - {('c'), QLatin1String("cap")}, - {('c'), QLatin1String("close")}, - {('c'), QLatin1String("complex")}, - {('c'), QLatin1String("copy")}, - {('i'), QLatin1String("imag")}, - {('l'), QLatin1String("len")}, - {('m'), QLatin1String("make")}, - {('n'), QLatin1String("new")}, - {('p'), QLatin1String("panic")}, - {('p'), QLatin1String("print")}, - {('p'), QLatin1String("println")}, - {('r'), QLatin1String("real")}, - {('r'), QLatin1String("recover")}, - {('d'), QLatin1String("delete")} - }; - - go_other = { - - }; -} -void loadGoData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other) { - if (!goDataInitialized) { - initGoData(); - goDataInitialized = true; - } - types = go_types; - keywords = go_keywords; - builtin = go_builtin; - literals = go_literals; - other = go_other; -} - -/********************************************************/ -/*** V DATA **************************************/ -/********************************************************/ -static bool vDataInitialized = false; -static LanguageData v_keywords; -static LanguageData v_types; -static LanguageData v_literals; -static LanguageData v_builtin; -static LanguageData v_other; -void initVData() { - v_keywords = { - {('b'), QLatin1String("break")}, - {('c'), QLatin1String("const")}, - {('c'), QLatin1String("continue")}, - {('d'), QLatin1String("defer")}, - {('e'), QLatin1String("else")}, - {('f'), QLatin1String("for")}, - {('f'), QLatin1String("fn")}, - {('g'), QLatin1String("go")}, - {('g'), QLatin1String("goto")}, - {('i'), QLatin1String("if")}, - {('i'), QLatin1String("import")}, - {('i'), QLatin1String("interface")}, - {('r'), QLatin1String("return")}, - {('s'), QLatin1String("struct")}, - {('s'), QLatin1String("switch")}, - {('t'), QLatin1String("type")}, - {('p'), QLatin1String("pub")}, - {('o'), QLatin1String("or")}, - {('n'), QLatin1String("none")} - }; - - v_types = { - {('m'), QLatin1String("map")}, - {('s'), QLatin1String("struct")}, - {('b'), QLatin1String("bool")}, - {('b'), QLatin1String("byte")}, - {('f'), QLatin1String("f32")}, - {('f'), QLatin1String("f64")}, - {('i'), QLatin1String("i8")}, - {('i'), QLatin1String("i16")}, - {('i'), QLatin1String("int")}, - {('i'), QLatin1String("i64")}, - {('i'), QLatin1String("i128")}, - {('s'), QLatin1String("string")}, - {('u'), QLatin1String("u16")}, - {('u'), QLatin1String("u32")}, - {('u'), QLatin1String("u64")}, - {('u'), QLatin1String("u128")}, - {('u'), QLatin1String("byteptr")}, - {('u'), QLatin1String("voidptr")}, - {('r'), QLatin1String("rune")} - }; - - v_literals = { - {('f'), QLatin1String("false")}, - {('t'), QLatin1String("true")}, - }; - - v_builtin = { - }; - - v_other = { - - }; -} -void loadVData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other) { - if (!vDataInitialized) { - initVData(); - vDataInitialized = true; - } - types = v_types; - keywords = v_keywords; - builtin = v_builtin; - literals = v_literals; - other = v_other; -} - -/********************************************************/ -/*** SQL DATA ************************************/ -/********************************************************/ -static bool sqlDataInitialized = false; -static LanguageData sql_keywords; -static LanguageData sql_types; -static LanguageData sql_literals; -static LanguageData sql_builtin; -static LanguageData sql_other; -void initSQLData() { - sql_keywords = { - {('A'), QLatin1String("ACTION")}, - {('A'), QLatin1String("ADD")}, - {('A'), QLatin1String("AFTER")}, - {('A'), QLatin1String("ALGORITHM")}, - {('A'), QLatin1String("ALL")}, - {('A'), QLatin1String("ALTER")}, - {('A'), QLatin1String("ANALYZE")}, - {('A'), QLatin1String("ANY")}, - {('A'), QLatin1String("APPLY")}, - {('A'), QLatin1String("AS")}, - {('A'), QLatin1String("ASC")}, - {('A'), QLatin1String("AUTHORIZATION")}, - {('A'), QLatin1String("AUTO_INCREMENT")}, - {('B'), QLatin1String("BACKUP")}, - {('B'), QLatin1String("BDB")}, - {('B'), QLatin1String("BEGIN")}, - {('B'), QLatin1String("BERKELEYDB")}, - {('B'), QLatin1String("BIGINT")}, - {('B'), QLatin1String("BINARY")}, - {('B'), QLatin1String("BIT")}, - {('B'), QLatin1String("BLOB")}, - {('B'), QLatin1String("BOOL")}, - {('B'), QLatin1String("BOOLEAN")}, - {('B'), QLatin1String("BREAK")}, - {('B'), QLatin1String("BROWSE")}, - {('B'), QLatin1String("BTREE")}, - {('B'), QLatin1String("BULK")}, - {('B'), QLatin1String("BY")}, - {('C'), QLatin1String("CALL")}, - {('C'), QLatin1String("CASCADED")}, - {('C'), QLatin1String("CASE")}, - {('C'), QLatin1String("CHAIN")}, - {('C'), QLatin1String("CHARACTER")}, - {('S'), QLatin1String("SET")}, - {('C'), QLatin1String("CHECKPOINT")}, - {('C'), QLatin1String("CLOSE")}, - {('C'), QLatin1String("CLUSTERED")}, - {('C'), QLatin1String("COALESCE")}, - {('C'), QLatin1String("COLLATE")}, - {('C'), QLatin1String("COLUMNS")}, - {('C'), QLatin1String("COMMENT")}, - {('C'), QLatin1String("COMMITTED")}, - {('C'), QLatin1String("COMPUTE")}, - {('C'), QLatin1String("CONNECT")}, - {('C'), QLatin1String("CONSISTENT")}, - {('C'), QLatin1String("CONSTRAINT")}, - {('C'), QLatin1String("CONTAINSTABLE")}, - {('C'), QLatin1String("CONTINUE")}, - {('C'), QLatin1String("CONVERT")}, - {('C'), QLatin1String("CREATE")}, - {('C'), QLatin1String("CROSS")}, - {('C'), QLatin1String("CURRENT_DATE")}, - {('_'), QLatin1String("_TIME")}, - {('_'), QLatin1String("_TIMESTAMP")}, - {('_'), QLatin1String("_USER")}, - {('C'), QLatin1String("CURSOR")}, - {('C'), QLatin1String("CYCLE")}, - {('D'), QLatin1String("DATABASES")}, - {('D'), QLatin1String("DATETIME")}, - {('D'), QLatin1String("DAY")}, - {('D'), QLatin1String("DBCC")}, - {('D'), QLatin1String("DEALLOCATE")}, - {('D'), QLatin1String("DEC")}, - {('D'), QLatin1String("DECIMAL")}, - {('D'), QLatin1String("DECLARE")}, - {('D'), QLatin1String("DEFAULT")}, - {('D'), QLatin1String("DEFINER")}, - {('D'), QLatin1String("DELAYED")}, - {('D'), QLatin1String("DELETE")}, - {('D'), QLatin1String("DELIMITERS")}, - {('D'), QLatin1String("DENY")}, - {('D'), QLatin1String("DESC")}, - {('D'), QLatin1String("DESCRIBE")}, - {('D'), QLatin1String("DETERMINISTIC")}, - {('D'), QLatin1String("DISABLE")}, - {('D'), QLatin1String("DISCARD")}, - {('D'), QLatin1String("DISK")}, - {('D'), QLatin1String("DISTINCT")}, - {('D'), QLatin1String("DISTINCTROW")}, - {('D'), QLatin1String("DISTRIBUTED")}, - {('D'), QLatin1String("DO")}, - {('D'), QLatin1String("DOUBLE")}, - {('D'), QLatin1String("DROP")}, - {('D'), QLatin1String("DUMMY")}, - {('D'), QLatin1String("DUMPFILE")}, - {('D'), QLatin1String("DUPLICATE")}, - {('E'), QLatin1String("ELSEIF")}, - {('E'), QLatin1String("ENABLE")}, - {('E'), QLatin1String("ENCLOSED")}, - {('E'), QLatin1String("END")}, - {('E'), QLatin1String("ENGINE")}, - {('E'), QLatin1String("ENUM")}, - {('E'), QLatin1String("ERRLVL")}, - {('E'), QLatin1String("ERRORS")}, - {('E'), QLatin1String("ESCAPED")}, - {('E'), QLatin1String("EXCEPT")}, - {('E'), QLatin1String("EXECUTE")}, - {('E'), QLatin1String("EXISTS")}, - {('E'), QLatin1String("EXIT")}, - {('E'), QLatin1String("EXPLAIN")}, - {('E'), QLatin1String("EXTENDED")}, - {('F'), QLatin1String("FETCH")}, - {('F'), QLatin1String("FIELDS")}, - {('F'), QLatin1String("FILE")}, - {('F'), QLatin1String("FILLFACTOR")}, - {('F'), QLatin1String("FIRST")}, - {('F'), QLatin1String("FIXED")}, - {('F'), QLatin1String("FLOAT")}, - {('F'), QLatin1String("FOLLOWING")}, - {('F'), QLatin1String("FOR")}, - {('E'), QLatin1String("EACH")}, - {('R'), QLatin1String("ROW")}, - {('F'), QLatin1String("FORCE")}, - {('F'), QLatin1String("FOREIGN")}, - {('F'), QLatin1String("FREETEXTTABLE")}, - {('F'), QLatin1String("FROM")}, - {('F'), QLatin1String("FULL")}, - {('F'), QLatin1String("FUNCTION")}, - {('G'), QLatin1String("GEOMETRYCOLLECTION")}, - {('G'), QLatin1String("GLOBAL")}, - {('G'), QLatin1String("GOTO")}, - {('G'), QLatin1String("GRANT")}, - {('G'), QLatin1String("GROUP")}, - {('H'), QLatin1String("HANDLER")}, - {('H'), QLatin1String("HASH")}, - {('H'), QLatin1String("HAVING")}, - {('H'), QLatin1String("HOLDLOCK")}, - {('H'), QLatin1String("HOUR")}, - {('I'), QLatin1String("IDENTITY_INSERT")}, - {('C'), QLatin1String("COL")}, - {('I'), QLatin1String("IF")}, - {('I'), QLatin1String("IGNORE")}, - {('I'), QLatin1String("IMPORT")}, - {('I'), QLatin1String("INDEX")}, - {('I'), QLatin1String("INFILE")}, - {('I'), QLatin1String("INNER")}, - {('I'), QLatin1String("INNODB")}, - {('I'), QLatin1String("INOUT")}, - {('I'), QLatin1String("INSERT")}, - {('I'), QLatin1String("INT")}, - {('I'), QLatin1String("INTEGER")}, - {('I'), QLatin1String("INTERSECT")}, - {('I'), QLatin1String("INTERVAL")}, - {('I'), QLatin1String("INTO")}, - {('I'), QLatin1String("INVOKER")}, - {('I'), QLatin1String("ISOLATION")}, - {('I'), QLatin1String("ITERATE")}, - {('J'), QLatin1String("JOIN")}, - {('K'), QLatin1String("KEYS")}, - {('K'), QLatin1String("KILL")}, - {('L'), QLatin1String("LANGUAGE")}, - {('L'), QLatin1String("LAST")}, - {('L'), QLatin1String("LEAVE")}, - {('L'), QLatin1String("LEFT")}, - {('L'), QLatin1String("LEVEL")}, - {('L'), QLatin1String("LIMIT")}, - {('L'), QLatin1String("LINENO")}, - {('L'), QLatin1String("LINES")}, - {('L'), QLatin1String("LINESTRING")}, - {('L'), QLatin1String("LOAD")}, - {('L'), QLatin1String("LOCAL")}, - {('L'), QLatin1String("LOCK")}, - {('L'), QLatin1String("LONGBLOB")}, - {('T'), QLatin1String("TEXT")}, - {('L'), QLatin1String("LOOP")}, - {('M'), QLatin1String("MATCHED")}, - {('M'), QLatin1String("MEDIUMBLOB")}, - {('I'), QLatin1String("INT")}, - {('T'), QLatin1String("TEXT")}, - {('M'), QLatin1String("MERGE")}, - {('M'), QLatin1String("MIDDLEINT")}, - {('M'), QLatin1String("MINUTE")}, - {('M'), QLatin1String("MODE")}, - {('M'), QLatin1String("MODIFIES")}, - {('M'), QLatin1String("MODIFY")}, - {('M'), QLatin1String("MONTH")}, - {('M'), QLatin1String("MULTILINESTRING")}, - {('P'), QLatin1String("POINT")}, - {('P'), QLatin1String("POLYGON")}, - {('N'), QLatin1String("NATIONAL")}, - {('N'), QLatin1String("NATURAL")}, - {('N'), QLatin1String("NCHAR")}, - {('N'), QLatin1String("NEXT")}, - {('N'), QLatin1String("NO")}, - {('N'), QLatin1String("NONCLUSTERED")}, - {('N'), QLatin1String("NULLIF")}, - {('N'), QLatin1String("NUMERIC")}, - {('O'), QLatin1String("OFF")}, - {('O'), QLatin1String("OFFSETS")}, - {('O'), QLatin1String("ON")}, - {('O'), QLatin1String("OPENDATASOURCE")}, - {('Q'), QLatin1String("QUERY")}, - {('R'), QLatin1String("ROWSET")}, - {('O'), QLatin1String("OPTIMIZE")}, - {('O'), QLatin1String("OPTIONALLY")}, - {('O'), QLatin1String("ORDER")}, - {('O'), QLatin1String("OUTER")}, - {('F'), QLatin1String("FILE")}, - {('O'), QLatin1String("OVER")}, - {('P'), QLatin1String("PARTIAL")}, - {('P'), QLatin1String("PARTITION")}, - {('P'), QLatin1String("PERCENT")}, - {('P'), QLatin1String("PIVOT")}, - {('P'), QLatin1String("PLAN")}, - {('P'), QLatin1String("POINT")}, - {('P'), QLatin1String("POLYGON")}, - {('P'), QLatin1String("PRECEDING")}, - {('P'), QLatin1String("PRECISION")}, - {('P'), QLatin1String("PREPARE")}, - {('P'), QLatin1String("PREV")}, - {('P'), QLatin1String("PRIMARY")}, - {('P'), QLatin1String("PRINT")}, - {('P'), QLatin1String("PRIVILEGES")}, - {('P'), QLatin1String("PROCEDURE")}, - {('P'), QLatin1String("PUBLIC")}, - {('P'), QLatin1String("PURGE")}, - {('Q'), QLatin1String("QUICK")}, - {('R'), QLatin1String("RAISERROR")}, - {('R'), QLatin1String("READS")}, - {('R'), QLatin1String("REAL")}, - {('R'), QLatin1String("RECONFIGURE")}, - {('R'), QLatin1String("REFERENCES")}, - {('R'), QLatin1String("RELEASE")}, - {('R'), QLatin1String("RENAME")}, - {('R'), QLatin1String("REPEATABLE")}, - {('R'), QLatin1String("REPLACE")}, - {('R'), QLatin1String("REPLICATION")}, - {('R'), QLatin1String("REQUIRE")}, - {('R'), QLatin1String("RESIGNAL")}, - {('R'), QLatin1String("RESTORE")}, - {('R'), QLatin1String("RESTRICT")}, - {('R'), QLatin1String("RETURNS")}, - {('R'), QLatin1String("REVOKE")}, - {('R'), QLatin1String("RIGHT")}, - {('R'), QLatin1String("ROLLBACK")}, - {('R'), QLatin1String("ROUTINE")}, - {('R'), QLatin1String("ROWCOUNT")}, - {('G'), QLatin1String("GUIDCOL")}, - {('R'), QLatin1String("RTREE")}, - {('R'), QLatin1String("RULE")}, - {('S'), QLatin1String("SAVEPOINT")}, - {('S'), QLatin1String("SCHEMA")}, - {('S'), QLatin1String("SECOND")}, - {('S'), QLatin1String("SELECT")}, - {('S'), QLatin1String("SERIALIZABLE")}, - {('S'), QLatin1String("SESSION_USER")}, - {('S'), QLatin1String("SETUSER")}, - {('S'), QLatin1String("SHARE")}, - {('S'), QLatin1String("SHOW")}, - {('S'), QLatin1String("SHUTDOWN")}, - {('S'), QLatin1String("SIMPLE")}, - {('S'), QLatin1String("SMALLINT")}, - {('S'), QLatin1String("SNAPSHOT")}, - {('S'), QLatin1String("SOME")}, - {('S'), QLatin1String("SONAME")}, - {('S'), QLatin1String("SQL")}, - {('S'), QLatin1String("STARTING")}, - {('S'), QLatin1String("STATISTICS")}, - {('S'), QLatin1String("STATUS")}, - {('S'), QLatin1String("STRIPED")}, - {('S'), QLatin1String("SYSTEM_USER")}, - {('T'), QLatin1String("TABLES")}, - {('T'), QLatin1String("TABLESPACE")}, - {('T'), QLatin1String("TEMPORARY")}, - {('T'), QLatin1String("TABLE")}, - {('T'), QLatin1String("TERMINATED")}, - {('T'), QLatin1String("TEXTSIZE")}, - {('T'), QLatin1String("THEN")}, - {('T'), QLatin1String("TIMESTAMP")}, - {('T'), QLatin1String("TINYBLOB")}, - {('I'), QLatin1String("INT")}, - {('T'), QLatin1String("TEXT")}, - {('T'), QLatin1String("TOP")}, - {('T'), QLatin1String("TRANSACTIONS")}, - {('T'), QLatin1String("TRIGGER")}, - {('T'), QLatin1String("TRUNCATE")}, - {('T'), QLatin1String("TSEQUAL")}, - {('T'), QLatin1String("TYPES")}, - {('U'), QLatin1String("UNBOUNDED")}, - {('U'), QLatin1String("UNCOMMITTED")}, - {('U'), QLatin1String("UNDEFINED")}, - {('U'), QLatin1String("UNION")}, - {('U'), QLatin1String("UNIQUE")}, - {('U'), QLatin1String("UNLOCK")}, - {('U'), QLatin1String("UNPIVOT")}, - {('U'), QLatin1String("UNSIGNED")}, - {('U'), QLatin1String("UPDATETEXT")}, - {('U'), QLatin1String("USAGE")}, - {('U'), QLatin1String("USE")}, - {('U'), QLatin1String("USER")}, - {('U'), QLatin1String("USING")}, - {('V'), QLatin1String("VALUES")}, - {('V'), QLatin1String("VARBINARY")}, - {('C'), QLatin1String("CHAR")}, - {('C'), QLatin1String("CHARACTER")}, - {('Y'), QLatin1String("YING")}, - {('V'), QLatin1String("VIEW")}, - {('W'), QLatin1String("WAITFOR")}, - {('W'), QLatin1String("WARNINGS")}, - {('W'), QLatin1String("WHEN")}, - {('W'), QLatin1String("WHERE")}, - {('W'), QLatin1String("WHILE")}, - {('W'), QLatin1String("WITH")}, - {('R'), QLatin1String("ROLLUP")}, - {('I'), QLatin1String("IN")}, - {('W'), QLatin1String("WORK")}, - {('W'), QLatin1String("WRITETEXT")}, - {('Y'), QLatin1String("YEAR")} - }; - - sql_types = { - - }; - - sql_literals = { - {('A'), QLatin1String("TRUE")}, - {('F'), QLatin1String("FALSE")}, - {('N'), QLatin1String("NULL")}, - }; - - sql_builtin = { - {('A'), QLatin1String("AVG")}, - {('C'), QLatin1String("COUNT")}, - {('F'), QLatin1String("FIRST")}, - {('F'), QLatin1String("FORMAT")}, - {('L'), QLatin1String("LAST")}, - {('L'), QLatin1String("LCASE")}, - {('L'), QLatin1String("LEN")}, - {('M'), QLatin1String("MAX")}, - {('M'), QLatin1String("MID")}, - {('M'), QLatin1String("MIN")}, - {('M'), QLatin1String("MOD")}, - {('N'), QLatin1String("NOW")}, - {('R'), QLatin1String("ROUND")}, - {('S'), QLatin1String("SUM")}, - {('U'), QLatin1String("UCASE")} - }; - - sql_other = { - - }; -} -void loadSQLData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other) { - if (!sqlDataInitialized) { - initSQLData(); - sqlDataInitialized = true; - } - types = sql_types; - keywords = sql_keywords; - builtin = sql_builtin; - literals = sql_literals; - other = sql_other; -} - -/********************************************************/ -/*** JSON DATA ***********************************/ -/********************************************************/ -static bool jsonDataInitialized = false; -static LanguageData json_keywords; -static LanguageData json_types; -static LanguageData json_literals; -static LanguageData json_builtin; -static LanguageData json_other; -void initJSONData() { - json_keywords = { - }; - - json_types = { - }; - - json_literals = { - {('f'), QLatin1String("false")}, - {('t'), QLatin1String("true")}, - {('n'), QLatin1String("null")} - }; - - json_builtin = { - }; - - json_other = { -}; -} -void loadJSONData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other) { - if (!jsonDataInitialized) { - initJSONData(); - jsonDataInitialized = true; - } - types = json_types; - keywords = json_keywords; - builtin = json_builtin; - literals = json_literals; - other = json_other; -} - -/********************************************************/ -/*** CSS DATA ***********************************/ -/********************************************************/ -static bool cssDataInitialized = false; -static LanguageData css_keywords; -static LanguageData css_types; -static LanguageData css_literals; -static LanguageData css_builtin; -static LanguageData css_other; -void initCSSData() { - css_keywords = { - {'i', QLatin1String("important")}, - {'p', QLatin1String("px")}, - {'e', QLatin1String("em")} - }; - - css_types = { - {'a', QLatin1String("align")}, - {'c', QLatin1String("content")}, - {'i', QLatin1String("items")}, - {'s', QLatin1String("self")}, - {'a', QLatin1String("all")}, - {'a', QLatin1String("animation")}, - {'d', QLatin1String("delay")}, - {'d', QLatin1String("direction")}, - {'d', QLatin1String("duration")}, - {'f', QLatin1String("fill")}, - {'m', QLatin1String("mode")}, - {'i', QLatin1String("iteration")}, - {'c', QLatin1String("count")}, - {'n', QLatin1String("name")}, - {'p', QLatin1String("play")}, - {'s', QLatin1String("state")}, - {'t', QLatin1String("timing")}, - {'f', QLatin1String("function")}, - {'a', QLatin1String("azimuth")}, - {'b', QLatin1String("backface")}, - {'v', QLatin1String("visibility")}, - {'a', QLatin1String("attachment")}, - {'b', QLatin1String("blend")}, - {'m', QLatin1String("mode")}, - {'c', QLatin1String("clip")}, - {'c', QLatin1String("color")}, - {'i', QLatin1String("image")}, - {'o', QLatin1String("origin")}, - {'p', QLatin1String("position")}, - {'r', QLatin1String("repeat")}, - {'s', QLatin1String("size")}, - {'b', QLatin1String("background")}, - {'b', QLatin1String("bleed")}, - {'c', QLatin1String("color")}, - {'r', QLatin1String("radius")}, - {'r', QLatin1String("radius")}, - {'s', QLatin1String("style")}, - {'w', QLatin1String("width")}, - {'b', QLatin1String("bottom")}, - {'c', QLatin1String("collapse")}, - {'c', QLatin1String("color")}, - {'i', QLatin1String("image")}, - {'o', QLatin1String("outset")}, - {'r', QLatin1String("repeat")}, - {'s', QLatin1String("source")}, - {'s', QLatin1String("slice")}, - {'w', QLatin1String("width")}, - {'c', QLatin1String("color")}, - {'s', QLatin1String("style")}, - {'w', QLatin1String("width")}, - {'l', QLatin1String("left")}, - {'r', QLatin1String("radius")}, - {'c', QLatin1String("color")}, - {'s', QLatin1String("style")}, - {'w', QLatin1String("width")}, - {'r', QLatin1String("right")}, - {'s', QLatin1String("spacing")}, - {'s', QLatin1String("style")}, - {'c', QLatin1String("color")}, - {'l', QLatin1String("left")}, - {'r', QLatin1String("radius")}, - {'r', QLatin1String("radius")}, - {'s', QLatin1String("style")}, - {'w', QLatin1String("width")}, - {'t', QLatin1String("top")}, - {'w', QLatin1String("width")}, - {'b', QLatin1String("border")}, - {'b', QLatin1String("bottom")}, - {'b', QLatin1String("break")}, - {'b', QLatin1String("box")}, - {'s', QLatin1String("shadow")}, - {'b', QLatin1String("box")}, - {'s', QLatin1String("sizing")}, - {'a', QLatin1String("after")}, - {'b', QLatin1String("before")}, - {'b', QLatin1String("break")}, - {'i', QLatin1String("inside")}, - {'c', QLatin1String("caption")}, - {'s', QLatin1String("side")}, - {'c', QLatin1String("caret")}, - {'c', QLatin1String("color")}, - {'c', QLatin1String("clear")}, - {'c', QLatin1String("clip")}, - {'c', QLatin1String("color")}, - {'c', QLatin1String("columns")}, - {'c', QLatin1String("column")}, - {'c', QLatin1String("count")}, - {'f', QLatin1String("fill")}, - {'g', QLatin1String("gap")}, - {'r', QLatin1String("rule")}, - {'c', QLatin1String("color")}, - {'s', QLatin1String("style")}, - {'w', QLatin1String("width")}, - {'s', QLatin1String("span")}, - {'w', QLatin1String("width")}, - {'c', QLatin1String("content")}, - {'i', QLatin1String("increment")}, - {'c', QLatin1String("counter")}, - {'r', QLatin1String("reset")}, - {'a', QLatin1String("after")}, - {'b', QLatin1String("before")}, - {'c', QLatin1String("cue")}, - {'c', QLatin1String("cursor")}, - {'d', QLatin1String("direction")}, - {'d', QLatin1String("display")}, - {'e', QLatin1String("elevation")}, - {'e', QLatin1String("empty")}, - {'c', QLatin1String("cells")}, - {'f', QLatin1String("filter")}, - {'f', QLatin1String("flex")}, - {'b', QLatin1String("basis")}, - {'d', QLatin1String("direction")}, - {'f', QLatin1String("feature")}, - {'s', QLatin1String("settings")}, - {'f', QLatin1String("flex")}, - {'f', QLatin1String("flow")}, - {'g', QLatin1String("grow")}, - {'s', QLatin1String("shrink")}, - {'w', QLatin1String("wrap")}, - {'f', QLatin1String("float")}, - {'f', QLatin1String("family")}, - {'k', QLatin1String("kerning")}, - {'l', QLatin1String("language")}, - {'o', QLatin1String("override")}, - {'a', QLatin1String("adjust")}, - {'s', QLatin1String("size")}, - {'s', QLatin1String("stretch")}, - {'s', QLatin1String("style")}, - {'s', QLatin1String("synthesis")}, - {'v', QLatin1String("variant")}, - {'a', QLatin1String("alternates")}, - {'c', QLatin1String("caps")}, - {'e', QLatin1String("east")}, - {'a', QLatin1String("asian")}, - {'l', QLatin1String("ligatures")}, - {'n', QLatin1String("numeric")}, - {'p', QLatin1String("position")}, - {'w', QLatin1String("weight")}, - {'f', QLatin1String("font")}, - {'a', QLatin1String("area")}, - {'a', QLatin1String("auto")}, - {'c', QLatin1String("columns")}, - {'f', QLatin1String("flow")}, - {'r', QLatin1String("rows")}, - {'e', QLatin1String("end")}, - {'g', QLatin1String("gap")}, - {'s', QLatin1String("start")}, - {'c', QLatin1String("column")}, - {'g', QLatin1String("gap")}, - {'e', QLatin1String("end")}, - {'g', QLatin1String("gap")}, - {'s', QLatin1String("start")}, - {'r', QLatin1String("row")}, - {'a', QLatin1String("areas")}, - {'c', QLatin1String("columns")}, - {'r', QLatin1String("rows")}, - {'t', QLatin1String("template")}, - {'g', QLatin1String("grid")}, - {'h', QLatin1String("hanging")}, - {'p', QLatin1String("punctuation")}, - {'h', QLatin1String("height")}, - {'h', QLatin1String("hyphens")}, - {'i', QLatin1String("isolation")}, - {'j', QLatin1String("justify")}, - {'c', QLatin1String("content")}, - {'i', QLatin1String("items")}, - {'s', QLatin1String("self")}, - {'l', QLatin1String("leftimage")}, - {'l', QLatin1String("letter")}, - {'s', QLatin1String("spacing")}, - {'b', QLatin1String("break")}, - {'l', QLatin1String("line")}, - {'s', QLatin1String("style")}, - {'i', QLatin1String("image")}, - {'s', QLatin1String("style")}, - {'p', QLatin1String("position")}, - {'t', QLatin1String("type")}, - {'l', QLatin1String("list")}, - {'s', QLatin1String("style")}, - {'b', QLatin1String("bottom")}, - {'l', QLatin1String("left")}, - {'r', QLatin1String("right")}, - {'t', QLatin1String("top")}, - {'m', QLatin1String("margin")}, - {'m', QLatin1String("marker")}, - {'o', QLatin1String("offset")}, - {'m', QLatin1String("marks")}, - {'m', QLatin1String("max")}, - {'h', QLatin1String("height")}, - {'w', QLatin1String("width")}, - {'m', QLatin1String("min")}, - {'m', QLatin1String("mix")}, - {'b', QLatin1String("blend")}, - {'m', QLatin1String("mode")}, - {'n', QLatin1String("nav")}, - {'u', QLatin1String("up")}, - {'d', QLatin1String("down")}, - {'l', QLatin1String("left")}, - {'r', QLatin1String("right")}, - {'o', QLatin1String("opacity")}, - {'o', QLatin1String("order")}, - {'o', QLatin1String("orphans")}, - {'c', QLatin1String("color")}, - {'o', QLatin1String("offset")}, - {'s', QLatin1String("style")}, - {'w', QLatin1String("width")}, - {'o', QLatin1String("outline")}, - {'w', QLatin1String("wrap")}, - {'o', QLatin1String("overflow")}, - {'b', QLatin1String("bottom")}, - {'l', QLatin1String("left")}, - {'r', QLatin1String("right")}, - {'t', QLatin1String("top")}, - {'p', QLatin1String("padding")}, - {'b', QLatin1String("break")}, - {'a', QLatin1String("after")}, - {'b', QLatin1String("before")}, - {'i', QLatin1String("inside")}, - {'p', QLatin1String("page")}, - {'a', QLatin1String("after")}, - {'b', QLatin1String("before")}, - {'p', QLatin1String("pause")}, - {'p', QLatin1String("perspective")}, - {'o', QLatin1String("origin")}, - {'r', QLatin1String("range")}, - {'p', QLatin1String("pitch")}, - {'c', QLatin1String("content")}, - {'i', QLatin1String("items")}, - {'p', QLatin1String("place")}, - {'s', QLatin1String("self")}, - {'p', QLatin1String("play")}, - {'d', QLatin1String("during")}, - {'p', QLatin1String("position")}, - {'q', QLatin1String("quotes")}, - {'r', QLatin1String("resize")}, - {'r', QLatin1String("rest")}, - {'a', QLatin1String("after")}, - {'b', QLatin1String("before")}, - {'r', QLatin1String("rest")}, - {'r', QLatin1String("richness")}, - {'r', QLatin1String("right")}, - {'s', QLatin1String("size")}, - {'h', QLatin1String("header")}, - {'n', QLatin1String("numeral")}, - {'s', QLatin1String("speak")}, - {'p', QLatin1String("punctuation")}, - {'s', QLatin1String("speak")}, - {'s', QLatin1String("speech")}, - {'r', QLatin1String("rate")}, - {'s', QLatin1String("stress")}, - {'t', QLatin1String("tab")}, - {'s', QLatin1String("size")}, - {'t', QLatin1String("table")}, - {'l', QLatin1String("layout")}, - {'t', QLatin1String("text")}, - {'a', QLatin1String("align")}, - {'l', QLatin1String("last")}, - {'d', QLatin1String("decoration")}, - {'c', QLatin1String("color")}, - {'l', QLatin1String("line")}, - {'s', QLatin1String("skip")}, - {'s', QLatin1String("style")}, - {'i', QLatin1String("indent")}, - {'o', QLatin1String("overflow")}, - {'s', QLatin1String("shadow")}, - {'t', QLatin1String("transform")}, - {'u', QLatin1String("underline")}, - {'p', QLatin1String("position")}, - {'t', QLatin1String("top")}, - {'t', QLatin1String("transform")}, - {'o', QLatin1String("origin")}, - {'s', QLatin1String("style")}, - {'t', QLatin1String("transition")}, - {'d', QLatin1String("delay")}, - {'d', QLatin1String("duration")}, - {'p', QLatin1String("property")}, - {'t', QLatin1String("timing")}, - {'f', QLatin1String("function")}, - {'u', QLatin1String("unicode")}, - {'b', QLatin1String("bidi")}, - {'v', QLatin1String("vertical")}, - {'a', QLatin1String("align")}, - {'v', QLatin1String("visibility")}, - {'b', QLatin1String("balance")}, - {'d', QLatin1String("duration")}, - {'f', QLatin1String("family")}, - {'p', QLatin1String("pitch")}, - {'r', QLatin1String("range")}, - {'r', QLatin1String("rate")}, - {'s', QLatin1String("stress")}, - {'v', QLatin1String("volume")}, - {'v', QLatin1String("voice")}, - {'v', QLatin1String("volume")}, - {'w', QLatin1String("white")}, - {'s', QLatin1String("space")}, - {'w', QLatin1String("widows")}, - {'w', QLatin1String("width")}, - {'w', QLatin1String("will")}, - {'c', QLatin1String("change")}, - {'w', QLatin1String("word")}, - {'b', QLatin1String("break")}, - {'s', QLatin1String("spacing")}, - {'w', QLatin1String("wrap")}, - {'x', QLatin1String("x")}, - {'y', QLatin1String("y")}, - {'z', QLatin1String("z")}, - {'i', QLatin1String("index")}, - {'r', QLatin1String("rgb")}, - {'s', QLatin1String("sans")}, - {'s', QLatin1String("serif")}, - {'n', QLatin1String("normal")} - }; - - css_literals = { - }; - - css_builtin = { - }; - - css_other = { - }; -} -void loadCSSData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other) { - if (!cssDataInitialized) { - initCSSData(); - cssDataInitialized = true; - } - types = css_types; - keywords = css_keywords; - builtin = css_builtin; - literals = css_literals; - other = css_other; -} - -/********************************************************/ -/*** Typescript DATA *********************************/ -/********************************************************/ -static bool typescriptDataInitialized = false; -static LanguageData typescript_keywords; -static LanguageData typescript_types; -static LanguageData typescript_literals; -static LanguageData typescript_builtin; -static LanguageData typescript_other; -void initTypescriptData() { - typescript_keywords = { - {'i', QLatin1String("in")}, - {'i', QLatin1String("if")}, - {'f', QLatin1String("for")}, - {'w', QLatin1String("while")}, - {'f', QLatin1String("finally")}, - {'n', QLatin1String("new")}, - {'f', QLatin1String("function")}, - {'d', QLatin1String("do")}, - {'r', QLatin1String("return")}, - {'v', QLatin1String("void")}, - {'e', QLatin1String("else")}, - {'b', QLatin1String("break")}, - {'c', QLatin1String("catch")}, - {'i', QLatin1String("instanceof")}, - {'w', QLatin1String("with")}, - {'t', QLatin1String("throw")}, - {'c', QLatin1String("case")}, - {'d', QLatin1String("default")}, - {'t', QLatin1String("try")}, - {'t', QLatin1String("this")}, - {'s', QLatin1String("switch")}, - {'c', QLatin1String("continue")}, - {'t', QLatin1String("typeof")}, - {'d', QLatin1String("delete")}, - {'l', QLatin1String("let")}, - {'y', QLatin1String("yield")}, - {'c', QLatin1String("const")}, - {'p', QLatin1String("public")}, - {'p', QLatin1String("private")}, - {'p', QLatin1String("protected")}, - {'g', QLatin1String("get")}, - {'s', QLatin1String("set")}, - {'s', QLatin1String("super")}, - {'s', QLatin1String("static")}, - {'i', QLatin1String("implements")}, - {'e', QLatin1String("export")}, - {'i', QLatin1String("import")}, - {'d', QLatin1String("declare")}, - {'t', QLatin1String("type")}, - {'n', QLatin1String("namespace")}, - {'a', QLatin1String("abstract")}, - {'a', QLatin1String("as")}, - {'f', QLatin1String("from")}, - {'e', QLatin1String("extends")}, - {'a', QLatin1String("async")}, - {'a', QLatin1String("await")} - }; - - typescript_types = { - {'v', QLatin1String("var")}, - {'c', QLatin1String("class")}, - {'e', QLatin1String("enum")} - }; - - typescript_literals = { - {('f'), QLatin1String("false")}, - {('n'), QLatin1String("null")}, - {('t'), QLatin1String("true")}, - {('u'), QLatin1String("undefined")}, - {('N'), QLatin1String("NaN")}, - {('I'), QLatin1String("Infinity")} - }; - - typescript_builtin = { - {'e', QLatin1String("eval")}, - {'i', QLatin1String("isFinite")}, - {'i', QLatin1String("isNaN")}, - {'p', QLatin1String("parseFloat")}, - {'p', QLatin1String("parseInt")}, - {'d', QLatin1String("decodeURI")}, - {'d', QLatin1String("decodeURIComponent")}, - {'e', QLatin1String("encodeURI")}, - {'e', QLatin1String("encodeURIComponent")}, - {'e', QLatin1String("escape")}, - {'u', QLatin1String("unescape")}, - {'O', QLatin1String("Object")}, - {'F', QLatin1String("Function")}, - {'B', QLatin1String("Boolean")}, - {'E', QLatin1String("Error")}, - {'E', QLatin1String("EvalError")}, - {'I', QLatin1String("InternalError")}, - {'R', QLatin1String("RangeError")}, - {'R', QLatin1String("ReferenceError")}, - {'S', QLatin1String("StopIteration")}, - {'S', QLatin1String("SyntaxError")}, - {'T', QLatin1String("TypeError")}, - {'U', QLatin1String("URIError")}, - {'N', QLatin1String("Number")}, - {'M', QLatin1String("Math")}, - {'D', QLatin1String("Date")}, - {'S', QLatin1String("String")}, - {'R', QLatin1String("RegExp")}, - {'A', QLatin1String("Array")}, - {'F', QLatin1String("Float32Array")}, - {'F', QLatin1String("Float64Array")}, - {'I', QLatin1String("Int16Array")}, - {'I', QLatin1String("Int32Array")}, - {'I', QLatin1String("Int8Array")}, - {'U', QLatin1String("Uint16Array")}, - {'U', QLatin1String("Uint32Array")}, - {'U', QLatin1String("Uint8Array")}, - {'U', QLatin1String("Uint8ClampedArray")}, - {'A', QLatin1String("ArrayBuffer")}, - {'D', QLatin1String("DataView")}, - {'J', QLatin1String("JSON")}, - {'I', QLatin1String("Intl")}, - {'a', QLatin1String("arguments")}, - {'r', QLatin1String("require")}, - {'m', QLatin1String("module")}, - {'c', QLatin1String("console")}, - {'w', QLatin1String("window")}, - {'d', QLatin1String("document")}, - {'a', QLatin1String("any")}, - {'n', QLatin1String("number")}, - {'b', QLatin1String("boolean")}, - {'s', QLatin1String("string")}, - {'v', QLatin1String("void")}, - {'P', QLatin1String("Promise")} - }; - - typescript_other = { -}; -} -void loadTypescriptData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other) { - if (!typescriptDataInitialized) { - initTypescriptData(); - typescriptDataInitialized = true; - } - types = typescript_types; - keywords = typescript_keywords; - builtin = typescript_builtin; - literals = typescript_literals; - other = typescript_other; -} - -/********************************************************/ -/*** YAML DATA ***************************************/ -/********************************************************/ -static bool YAMLDataInitialized = false; -static LanguageData YAML_keywords; -static LanguageData YAML_types; -static LanguageData YAML_literals; -static LanguageData YAML_builtin; -static LanguageData YAML_other; -void initYAMLData() { - YAML_keywords = {}; - YAML_types = {}; - YAML_literals = { - {('f'), QLatin1String("false")}, - {('t'), QLatin1String("true")}, - {('n'), QLatin1String("null")}, - }; - - YAML_builtin = {}; - YAML_other = {}; -} -void loadYAMLData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other) { - if (!YAMLDataInitialized) { - initYAMLData(); - YAMLDataInitialized = true; - } - types = YAML_types; - keywords = YAML_keywords; - builtin = YAML_builtin; - literals = YAML_literals; - other = YAML_other; -} - -/********************************************************/ -/*** VEX DATA ***************************************/ -/********************************************************/ -static bool vexDataInitialized = false; -static LanguageData vex_keywords; -static LanguageData vex_types; -static LanguageData vex_literals; -static LanguageData vex_builtin; -static LanguageData vex_other; -void initVEXData() { - vex_keywords = { - {'b', QLatin1String("break")}, - {'c', QLatin1String("continue")}, - {'d', QLatin1String("do")}, - {'e', QLatin1String("else")}, - {'f', QLatin1String("for")}, - {'f', QLatin1String("foreach")}, - {'f', QLatin1String("forpoints")}, - {'f', QLatin1String("function")}, - {'g', QLatin1String("gather")}, - {'i', QLatin1String("if")}, - {'i', QLatin1String("illuminance")}, - {'r', QLatin1String("return")}, - {'w', QLatin1String("while")} - }; - vex_types = { - {'b', QLatin1String("bsdf")}, - {'c', QLatin1String("char")}, - {'c', QLatin1String("color")}, - {'f', QLatin1String("float")}, - {'i', QLatin1String("int")}, - {'i', QLatin1String("integer")}, - {'m', QLatin1String("matrix")}, - {'m', QLatin1String("matrix2")}, - {'m', QLatin1String("matrix3")}, - {'m', QLatin1String("matrix4")}, - {'n', QLatin1String("normal")}, - {'p', QLatin1String("point")}, - {'s', QLatin1String("string")}, - {'s', QLatin1String("struct")}, - {'t', QLatin1String("typedef")}, - {'u', QLatin1String("union")}, - {'v', QLatin1String("vector")}, - {'v', QLatin1String("vector2")}, - {'v', QLatin1String("vector4")}, - {'v', QLatin1String("void")}, - }; - vex_literals = { - {('f'), QLatin1String("false")}, - {('t'), QLatin1String("true")}, - {('n'), QLatin1String("null")}, - }; - - vex_builtin = { - {'D', QLatin1String("Du")}, - {'D', QLatin1String("Dv")}, - {'D', QLatin1String("Dw")}, - {'a', QLatin1String("abs")}, - {'a', QLatin1String("accessframe")}, - {'a', QLatin1String("acos")}, - {'a', QLatin1String("addattrib")}, - {'a', QLatin1String("addattribute")}, - {'a', QLatin1String("adddetailattrib")}, - {'a', QLatin1String("addgroup")}, - {'a', QLatin1String("addpoint")}, - {'a', QLatin1String("addpointattrib")}, - {'a', QLatin1String("addprim")}, - {'a', QLatin1String("addprimattrib")}, - {'a', QLatin1String("addvariablename")}, - {'a', QLatin1String("addvertex")}, - {'a', QLatin1String("addvertexattrib")}, - {'a', QLatin1String("addvisualizer")}, - {'a', QLatin1String("agentaddclip")}, - {'a', QLatin1String("agentclipcatalog")}, - {'a', QLatin1String("agentclipchannel")}, - {'a', QLatin1String("agentcliplength")}, - {'a', QLatin1String("agentclipnames")}, - {'a', QLatin1String("agentclipsample")}, - {'a', QLatin1String("agentclipsamplelocal")}, - {'a', QLatin1String("agentclipsamplerate")}, - {'a', QLatin1String("agentclipsampleworld")}, - {'a', QLatin1String("agentcliptimes")}, - {'a', QLatin1String("agentclipweights")}, - {'a', QLatin1String("agentcollisionlayer")}, - {'a', QLatin1String("agentcurrentlayer")}, - {'a', QLatin1String("agentlayerbindings")}, - {'a', QLatin1String("agentlayers")}, - {'a', QLatin1String("agentlayershapes")}, - {'a', QLatin1String("agentlocaltransform")}, - {'a', QLatin1String("agentlocaltransforms")}, - {'a', QLatin1String("agentrigchildren")}, - {'a', QLatin1String("agentrigfind")}, - {'a', QLatin1String("agentrigparent")}, - {'a', QLatin1String("agenttransformcount")}, - {'a', QLatin1String("agenttransformnames")}, - {'a', QLatin1String("agenttransformtolocal")}, - {'a', QLatin1String("agenttransformtoworld")}, - {'a', QLatin1String("agentworldtransform")}, - {'a', QLatin1String("agentworldtransforms")}, - {'a', QLatin1String("albedo")}, - {'a', QLatin1String("alphaname")}, - {'a', QLatin1String("ambient")}, - {'a', QLatin1String("anoise")}, - {'a', QLatin1String("append")}, - {'a', QLatin1String("area")}, - {'a', QLatin1String("argsort")}, - {'a', QLatin1String("array")}, - {'a', QLatin1String("ashikhmin")}, - {'a', QLatin1String("asin")}, - {'a', QLatin1String("assert_enabled")}, - {'a', QLatin1String("assign")}, - {'a', QLatin1String("atan")}, - {'a', QLatin1String("atan2")}, - {'a', QLatin1String("atof")}, - {'a', QLatin1String("atoi")}, - {'a', QLatin1String("atten")}, - {'a', QLatin1String("attrib")}, - {'a', QLatin1String("attribclass")}, - {'a', QLatin1String("attribsize")}, - {'a', QLatin1String("attribtype")}, - {'a', QLatin1String("attribtypeinfo")}, - {'a', QLatin1String("avg")}, - {'b', QLatin1String("binput")}, - {'b', QLatin1String("blackbody")}, - {'b', QLatin1String("blinn")}, - {'b', QLatin1String("blinnBRDF")}, - {'b', QLatin1String("bouncelabel")}, - {'b', QLatin1String("bouncemask")}, - {'b', QLatin1String("bumpmap")}, - {'b', QLatin1String("bumpmapA")}, - {'b', QLatin1String("bumpmapB")}, - {'b', QLatin1String("bumpmapG")}, - {'b', QLatin1String("bumpmapL")}, - {'b', QLatin1String("bumpmapR")}, - {'b', QLatin1String("bumpname")}, - {'c', QLatin1String("cbrt")}, - {'c', QLatin1String("ceil")}, - {'c', QLatin1String("ch")}, - {'c', QLatin1String("ch3")}, - {'c', QLatin1String("ch4")}, - {'c', QLatin1String("chend")}, - {'c', QLatin1String("chendf")}, - {'c', QLatin1String("chendt")}, - {'c', QLatin1String("chf")}, - {'c', QLatin1String("chi")}, - {'c', QLatin1String("chinput")}, - {'c', QLatin1String("chname")}, - {'c', QLatin1String("chnumchan")}, - {'c', QLatin1String("chp")}, - {'c', QLatin1String("chr")}, - {'c', QLatin1String("chramp")}, - {'c', QLatin1String("chrate")}, - {'c', QLatin1String("chs")}, - {'c', QLatin1String("chsraw")}, - {'c', QLatin1String("chstart")}, - {'c', QLatin1String("chstartf")}, - {'c', QLatin1String("chstartt")}, - {'c', QLatin1String("chv")}, - {'c', QLatin1String("cinput")}, - {'c', QLatin1String("ckspline")}, - {'c', QLatin1String("clamp")}, - {'c', QLatin1String("clip")}, - {'c', QLatin1String("colormap")}, - {'c', QLatin1String("colorname")}, - {'c', QLatin1String("computenormal")}, - {'c', QLatin1String("concat")}, - {'c', QLatin1String("cone")}, - {'c', QLatin1String("cos")}, - {'c', QLatin1String("cosh")}, - {'c', QLatin1String("cracktransform")}, - {'c', QLatin1String("cross")}, - {'c', QLatin1String("cspline")}, - {'c', QLatin1String("ctransform")}, - {'c', QLatin1String("curlnoise")}, - {'c', QLatin1String("curlnoise2d")}, - {'c', QLatin1String("curlxnoise")}, - {'c', QLatin1String("curlxnoise2d")}, - {'c', QLatin1String("cvex_bsdf")}, - {'d', QLatin1String("degrees")}, - {'d', QLatin1String("depthmap")}, - {'d', QLatin1String("depthname")}, - {'d', QLatin1String("detail")}, - {'d', QLatin1String("detailattrib")}, - {'d', QLatin1String("detailattribsize")}, - {'d', QLatin1String("detailattribtype")}, - {'d', QLatin1String("detailattribtypeinfo")}, - {'d', QLatin1String("detailintrinsic")}, - {'d', QLatin1String("determinant")}, - {'d', QLatin1String("diffuse")}, - {'d', QLatin1String("diffuseBRDF")}, - {'d', QLatin1String("dihedral")}, - {'d', QLatin1String("dimport")}, - {'d', QLatin1String("distance")}, - {'d', QLatin1String("distance2")}, - {'d', QLatin1String("dot")}, - {'d', QLatin1String("dsmpixel")}, - {'e', QLatin1String("eigenvalues")}, - {'e', QLatin1String("endswith")}, - {'e', QLatin1String("environment")}, - {'e', QLatin1String("erf")}, - {'e', QLatin1String("erf_inv")}, - {'e', QLatin1String("erfc")}, - {'e', QLatin1String("error")}, - {'e', QLatin1String("eulertoquaternion")}, - {'e', QLatin1String("eval_bsdf")}, - {'e', QLatin1String("exp")}, - {'e', QLatin1String("expand_udim")}, - {'e', QLatin1String("expandpointgroup")}, - {'e', QLatin1String("expandprimgroup")}, - {'f', QLatin1String("fastshadow")}, - {'f', QLatin1String("filamentsample")}, - {'f', QLatin1String("file_stat")}, - {'f', QLatin1String("filtershadow")}, - {'f', QLatin1String("filterstep")}, - {'f', QLatin1String("find")}, - {'f', QLatin1String("findattribval")}, - {'f', QLatin1String("findattribvalcount")}, - {'f', QLatin1String("finput")}, - {'f', QLatin1String("fit")}, - {'f', QLatin1String("fit01")}, - {'f', QLatin1String("fit10")}, - {'f', QLatin1String("fit11")}, - {'f', QLatin1String("floor")}, - {'f', QLatin1String("flownoise")}, - {'f', QLatin1String("flowpnoise")}, - {'f', QLatin1String("frac")}, - {'f', QLatin1String("fresnel")}, - {'f', QLatin1String("fromNDC")}, - {'f', QLatin1String("frontface")}, - {'f', QLatin1String("fuzzify")}, - {'f', QLatin1String("fuzzy_and")}, - {'f', QLatin1String("fuzzy_defuzz_centroid")}, - {'f', QLatin1String("fuzzy_nand")}, - {'f', QLatin1String("fuzzy_nor")}, - {'f', QLatin1String("fuzzy_not")}, - {'f', QLatin1String("fuzzy_nxor")}, - {'f', QLatin1String("fuzzy_or")}, - {'f', QLatin1String("fuzzy_xor")}, - {'g', QLatin1String("geoself")}, - {'g', QLatin1String("getattrib")}, - {'g', QLatin1String("getattribute")}, - {'g', QLatin1String("getbbox")}, - {'g', QLatin1String("getblurP")}, - {'g', QLatin1String("getbounces")}, - {'g', QLatin1String("getbounds")}, - {'g', QLatin1String("getcomp")}, - {'g', QLatin1String("getcomponents")}, - {'g', QLatin1String("getderiv")}, - {'g', QLatin1String("getfogname")}, - {'g', QLatin1String("getglobalraylevel")}, - {'g', QLatin1String("getlight")}, - {'g', QLatin1String("getlightid")}, - {'g', QLatin1String("getlightname")}, - {'g', QLatin1String("getlights")}, - {'g', QLatin1String("getlightscope")}, - {'g', QLatin1String("getmaterial")}, - {'g', QLatin1String("getobjectname")}, - {'g', QLatin1String("getphotonlight")}, - {'g', QLatin1String("getpointbbox")}, - {'g', QLatin1String("getprimid")}, - {'g', QLatin1String("getptextureid")}, - {'g', QLatin1String("getraylevel")}, - {'g', QLatin1String("getrayweight")}, - {'g', QLatin1String("getsamplestore")}, - {'g', QLatin1String("getscope")}, - {'g', QLatin1String("getsmoothP")}, - {'g', QLatin1String("getspace")}, - {'g', QLatin1String("getuvobjects")}, - {'g', QLatin1String("getuvtangents")}, - {'g', QLatin1String("gradient")}, - {'h', QLatin1String("hair")}, - {'h', QLatin1String("hasattrib")}, - {'h', QLatin1String("hasdetailattrib")}, - {'h', QLatin1String("haslight")}, - {'h', QLatin1String("hasplane")}, - {'h', QLatin1String("haspointattrib")}, - {'h', QLatin1String("hasprimattrib")}, - {'h', QLatin1String("hasvertexattrib")}, - {'h', QLatin1String("hedge_dstpoint")}, - {'h', QLatin1String("hedge_dstvertex")}, - {'h', QLatin1String("hedge_equivcount")}, - {'h', QLatin1String("hedge_isequiv")}, - {'h', QLatin1String("hedge_isprimary")}, - {'h', QLatin1String("hedge_isvalid")}, - {'h', QLatin1String("hedge_next")}, - {'h', QLatin1String("hedge_nextequiv")}, - {'h', QLatin1String("hedge_postdstpoint")}, - {'h', QLatin1String("hedge_postdstvertex")}, - {'h', QLatin1String("hedge_presrcpoint")}, - {'h', QLatin1String("hedge_presrcvertex")}, - {'h', QLatin1String("hedge_prev")}, - {'h', QLatin1String("hedge_prim")}, - {'h', QLatin1String("hedge_primary")}, - {'h', QLatin1String("hedge_srcpoint")}, - {'h', QLatin1String("hedge_srcvertex")}, - {'h', QLatin1String("henyeygreenstein")}, - {'h', QLatin1String("hscript_noise")}, - {'h', QLatin1String("hscript_rand")}, - {'h', QLatin1String("hscript_snoise")}, - {'h', QLatin1String("hscript_sturb")}, - {'h', QLatin1String("hscript_turb")}, - {'h', QLatin1String("hsvtorgb")}, - {'i', QLatin1String("iaspect")}, - {'i', QLatin1String("ichname")}, - {'i', QLatin1String("ident")}, - {'i', QLatin1String("idtopoint")}, - {'i', QLatin1String("idtoprim")}, - {'i', QLatin1String("iend")}, - {'i', QLatin1String("iendtime")}, - {'i', QLatin1String("ihasplane")}, - {'i', QLatin1String("import")}, - {'i', QLatin1String("ingroup")}, - {'i', QLatin1String("inpointgroup")}, - {'i', QLatin1String("inprimgroup")}, - {'i', QLatin1String("insert")}, - {'i', QLatin1String("instance")}, - {'i', QLatin1String("interpolate")}, - {'i', QLatin1String("intersect")}, - {'i', QLatin1String("intersect_all")}, - {'i', QLatin1String("intersect_lights")}, - {'i', QLatin1String("inumplanes")}, - {'i', QLatin1String("invert")}, - {'i', QLatin1String("invertexgroup")}, - {'i', QLatin1String("iplaneindex")}, - {'i', QLatin1String("iplanename")}, - {'i', QLatin1String("iplanesize")}, - {'i', QLatin1String("irate")}, - {'i', QLatin1String("irradiance")}, - {'i', QLatin1String("isalpha")}, - {'i', QLatin1String("isbound")}, - {'i', QLatin1String("isconnected")}, - {'i', QLatin1String("isdigit")}, - {'i', QLatin1String("isfinite")}, - {'i', QLatin1String("isfogray")}, - {'i', QLatin1String("isframes")}, - {'i', QLatin1String("isnan")}, - {'i', QLatin1String("isotropic")}, - {'i', QLatin1String("israytracing")}, - {'i', QLatin1String("issamples")}, - {'i', QLatin1String("isseconds")}, - {'i', QLatin1String("isshadowray")}, - {'i', QLatin1String("istart")}, - {'i', QLatin1String("istarttime")}, - {'i', QLatin1String("isuvrendering")}, - {'i', QLatin1String("isvalidindex")}, - {'i', QLatin1String("isvarying")}, - {'i', QLatin1String("itoa")}, - {'i', QLatin1String("ixres")}, - {'i', QLatin1String("iyres")}, - {'j', QLatin1String("join")}, - {'k', QLatin1String("kspline")}, - {'l', QLatin1String("len")}, - {'l', QLatin1String("length")}, - {'l', QLatin1String("length2")}, - {'l', QLatin1String("lerp")}, - {'l', QLatin1String("lightid")}, - {'l', QLatin1String("limit_sample_space")}, - {'l', QLatin1String("limport")}, - {'l', QLatin1String("lkspline")}, - {'l', QLatin1String("log")}, - {'l', QLatin1String("log10")}, - {'l', QLatin1String("lookat")}, - {'l', QLatin1String("lspline")}, - {'l', QLatin1String("lstrip")}, - {'l', QLatin1String("luminance")}, - {'l', QLatin1String("lumname")}, - {'m', QLatin1String("makebasis")}, - {'m', QLatin1String("maketransform")}, - {'m', QLatin1String("maskname")}, - {'m', QLatin1String("match")}, - {'m', QLatin1String("matchvex_blinn")}, - {'m', QLatin1String("matchvex_specular")}, - {'m', QLatin1String("mattrib")}, - {'m', QLatin1String("max")}, - {'m', QLatin1String("mdensity")}, - {'m', QLatin1String("metaimport")}, - {'m', QLatin1String("metamarch")}, - {'m', QLatin1String("metanext")}, - {'m', QLatin1String("metastart")}, - {'m', QLatin1String("metaweight")}, - {'m', QLatin1String("min")}, - {'m', QLatin1String("minpos")}, - {'m', QLatin1String("mspace")}, - {'n', QLatin1String("nametopoint")}, - {'n', QLatin1String("nametoprim")}, - {'n', QLatin1String("nbouncetypes")}, - {'n', QLatin1String("nearpoint")}, - {'n', QLatin1String("nearpoints")}, - {'n', QLatin1String("neighbour")}, - {'n', QLatin1String("neighbourcount")}, - {'n', QLatin1String("neighbours")}, - {'n', QLatin1String("newgroup")}, - {'n', QLatin1String("newsampler")}, - {'n', QLatin1String("nextsample")}, - {'n', QLatin1String("ninput")}, - {'n', QLatin1String("noise")}, - {'n', QLatin1String("noised")}, - {'n', QLatin1String("normal_bsdf")}, - {'n', QLatin1String("normalize")}, - {'n', QLatin1String("normalname")}, - {'n', QLatin1String("npoints")}, - {'n', QLatin1String("npointsgroup")}, - {'n', QLatin1String("nprimitives")}, - {'n', QLatin1String("nprimitivesgroup")}, - {'n', QLatin1String("nrandom")}, - {'n', QLatin1String("ntransform")}, - {'n', QLatin1String("nuniqueval")}, - {'n', QLatin1String("nvertices")}, - {'n', QLatin1String("nverticesgroup")}, - {'o', QLatin1String("occlusion")}, - {'o', QLatin1String("onoise")}, - {'o', QLatin1String("opdigits")}, - {'o', QLatin1String("opend")}, - {'o', QLatin1String("opfullpath")}, - {'o', QLatin1String("opstart")}, - {'o', QLatin1String("optransform")}, - {'o', QLatin1String("ord")}, - {'o', QLatin1String("osd_facecount")}, - {'o', QLatin1String("osd_firstpatch")}, - {'o', QLatin1String("osd_limitsurface")}, - {'o', QLatin1String("osd_limitsurfacevertex")}, - {'o', QLatin1String("osd_patchcount")}, - {'o', QLatin1String("osd_patches")}, - {'o', QLatin1String("outerproduct")}, - {'o', QLatin1String("ow_nspace")}, - {'o', QLatin1String("ow_space")}, - {'o', QLatin1String("ow_vspace")}, - {'p', QLatin1String("pack_inttosafefloat")}, - {'p', QLatin1String("pathtrace")}, - {'p', QLatin1String("pcclose")}, - {'p', QLatin1String("pcconvex")}, - {'p', QLatin1String("pcexport")}, - {'p', QLatin1String("pcfarthest")}, - {'p', QLatin1String("pcfilter")}, - {'p', QLatin1String("pcfind")}, - {'p', QLatin1String("pcfind_radius")}, - {'p', QLatin1String("pcgenerate")}, - {'p', QLatin1String("pcimport")}, - {'p', QLatin1String("pcimportbyidx3")}, - {'p', QLatin1String("pcimportbyidx4")}, - {'p', QLatin1String("pcimportbyidxf")}, - {'p', QLatin1String("pcimportbyidxi")}, - {'p', QLatin1String("pcimportbyidxp")}, - {'p', QLatin1String("pcimportbyidxs")}, - {'p', QLatin1String("pcimportbyidxv")}, - {'p', QLatin1String("pciterate")}, - {'p', QLatin1String("pcnumfound")}, - {'p', QLatin1String("pcopen")}, - {'p', QLatin1String("pcopenlod")}, - {'p', QLatin1String("pcsampleleaf")}, - {'p', QLatin1String("pcsize")}, - {'p', QLatin1String("pcunshaded")}, - {'p', QLatin1String("pcwrite")}, - {'p', QLatin1String("pgfind")}, - {'p', QLatin1String("phong")}, - {'p', QLatin1String("phongBRDF")}, - {'p', QLatin1String("phonglobe")}, - {'p', QLatin1String("photonmap")}, - {'p', QLatin1String("planeindex")}, - {'p', QLatin1String("planename")}, - {'p', QLatin1String("planesize")}, - {'p', QLatin1String("pluralize")}, - {'p', QLatin1String("pnoise")}, - {'p', QLatin1String("point")}, - {'p', QLatin1String("pointattrib")}, - {'p', QLatin1String("pointattribsize")}, - {'p', QLatin1String("pointattribtype")}, - {'p', QLatin1String("pointattribtypeinfo")}, - {'p', QLatin1String("pointedge")}, - {'p', QLatin1String("pointhedge")}, - {'p', QLatin1String("pointhedgenext")}, - {'p', QLatin1String("pointname")}, - {'p', QLatin1String("pointprims")}, - {'p', QLatin1String("pointvertex")}, - {'p', QLatin1String("pointvertices")}, - {'p', QLatin1String("polardecomp")}, - {'p', QLatin1String("pop")}, - {'p', QLatin1String("pow")}, - {'p', QLatin1String("prim")}, - {'p', QLatin1String("prim_attribute")}, - {'p', QLatin1String("prim_normal")}, - {'p', QLatin1String("primattrib")}, - {'p', QLatin1String("primattribsize")}, - {'p', QLatin1String("primattribtype")}, - {'p', QLatin1String("primattribtypeinfo")}, - {'p', QLatin1String("primhedge")}, - {'p', QLatin1String("primintrinsic")}, - {'p', QLatin1String("primpoint")}, - {'p', QLatin1String("primpoints")}, - {'p', QLatin1String("primuv")}, - {'p', QLatin1String("primvertex")}, - {'p', QLatin1String("primvertexcount")}, - {'p', QLatin1String("primvertices")}, - {'p', QLatin1String("print_once")}, - {'p', QLatin1String("printf")}, - {'p', QLatin1String("product")}, - {'p', QLatin1String("ptexture")}, - {'p', QLatin1String("ptlined")}, - {'p', QLatin1String("ptransform")}, - {'p', QLatin1String("push")}, - {'q', QLatin1String("qconvert")}, - {'q', QLatin1String("qdistance")}, - {'q', QLatin1String("qinvert")}, - {'q', QLatin1String("qmultiply")}, - {'q', QLatin1String("qrotate")}, - {'q', QLatin1String("quaternion")}, - {'r', QLatin1String("radians")}, - {'r', QLatin1String("rand")}, - {'r', QLatin1String("random")}, - {'r', QLatin1String("random_fhash")}, - {'r', QLatin1String("random_ihash")}, - {'r', QLatin1String("random_shash")}, - {'r', QLatin1String("random_sobol")}, - {'r', QLatin1String("rawbumpmap")}, - {'r', QLatin1String("rawbumpmapA")}, - {'r', QLatin1String("rawbumpmapB")}, - {'r', QLatin1String("rawbumpmapG")}, - {'r', QLatin1String("rawbumpmapL")}, - {'r', QLatin1String("rawbumpmapR")}, - {'r', QLatin1String("rawcolormap")}, - {'r', QLatin1String("rayhittest")}, - {'r', QLatin1String("rayimport")}, - {'r', QLatin1String("re_find")}, - {'r', QLatin1String("re_findall")}, - {'r', QLatin1String("re_match")}, - {'r', QLatin1String("re_replace")}, - {'r', QLatin1String("re_split")}, - {'r', QLatin1String("reflect")}, - {'r', QLatin1String("reflectlight")}, - {'r', QLatin1String("refract")}, - {'r', QLatin1String("refractlight")}, - {'r', QLatin1String("relativepath")}, - {'r', QLatin1String("relbbox")}, - {'r', QLatin1String("relpointbbox")}, - {'r', QLatin1String("removegroup")}, - {'r', QLatin1String("removeindex")}, - {'r', QLatin1String("removepoint")}, - {'r', QLatin1String("removeprim")}, - {'r', QLatin1String("removevalue")}, - {'r', QLatin1String("renderstate")}, - {'r', QLatin1String("reorder")}, - {'r', QLatin1String("resample_linear")}, - {'r', QLatin1String("resize")}, - {'r', QLatin1String("resolvemissedray")}, - {'r', QLatin1String("reverse")}, - {'r', QLatin1String("rgbtohsv")}, - {'r', QLatin1String("rgbtoxyz")}, - {'r', QLatin1String("rint")}, - {'r', QLatin1String("rotate")}, - {'r', QLatin1String("rotate_x_to")}, - {'r', QLatin1String("rstrip")}, - {'s', QLatin1String("sample_bsdf")}, - {'s', QLatin1String("sample_cauchy")}, - {'s', QLatin1String("sample_circle_arc")}, - {'s', QLatin1String("sample_circle_edge_uniform")}, - {'s', QLatin1String("sample_circle_slice")}, - {'s', QLatin1String("sample_circle_uniform")}, - {'s', QLatin1String("sample_direction_cone")}, - {'s', QLatin1String("sample_direction_uniform")}, - {'s', QLatin1String("sample_discrete")}, - {'s', QLatin1String("sample_exponential")}, - {'s', QLatin1String("sample_geometry")}, - {'s', QLatin1String("sample_hemisphere")}, - {'s', QLatin1String("sample_hypersphere_cone")}, - {'s', QLatin1String("sample_hypersphere_uniform")}, - {'s', QLatin1String("sample_light")}, - {'s', QLatin1String("sample_lognormal")}, - {'s', QLatin1String("sample_lognormal_by_median")}, - {'s', QLatin1String("sample_normal")}, - {'s', QLatin1String("sample_orientation_cone")}, - {'s', QLatin1String("sample_orientation_uniform")}, - {'s', QLatin1String("sample_photon")}, - {'s', QLatin1String("sample_sphere_cone")}, - {'s', QLatin1String("sample_sphere_uniform")}, - {'s', QLatin1String("sampledisk")}, - {'s', QLatin1String("scale")}, - {'s', QLatin1String("select")}, - {'s', QLatin1String("sensor_panorama_create")}, - {'s', QLatin1String("sensor_panorama_getcolor")}, - {'s', QLatin1String("sensor_panorama_getcone")}, - {'s', QLatin1String("sensor_panorama_getdepth")}, - {'s', QLatin1String("sensor_save")}, - {'s', QLatin1String("serialize")}, - {'s', QLatin1String("set")}, - {'s', QLatin1String("setagentclipnames")}, - {'s', QLatin1String("setagentcliptimes")}, - {'s', QLatin1String("setagentclipweights")}, - {'s', QLatin1String("setagentcollisionlayer")}, - {'s', QLatin1String("setagentcurrentlayer")}, - {'s', QLatin1String("setagentlocaltransform")}, - {'s', QLatin1String("setagentlocaltransforms")}, - {'s', QLatin1String("setagentworldtransform")}, - {'s', QLatin1String("setagentworldtransforms")}, - {'s', QLatin1String("setattrib")}, - {'s', QLatin1String("setattribtypeinfo")}, - {'s', QLatin1String("setcomp")}, - {'s', QLatin1String("setcurrentlight")}, - {'s', QLatin1String("setdetailattrib")}, - {'s', QLatin1String("setpointattrib")}, - {'s', QLatin1String("setpointgroup")}, - {'s', QLatin1String("setprimattrib")}, - {'s', QLatin1String("setprimgroup")}, - {'s', QLatin1String("setprimintrinsic")}, - {'s', QLatin1String("setprimvertex")}, - {'s', QLatin1String("setsamplestore")}, - {'s', QLatin1String("setvertexattrib")}, - {'s', QLatin1String("setvertexgroup")}, - {'s', QLatin1String("setvertexpoint")}, - {'s', QLatin1String("shadow")}, - {'s', QLatin1String("shadow_light")}, - {'s', QLatin1String("shadowmap")}, - {'s', QLatin1String("shimport")}, - {'s', QLatin1String("shl")}, - {'s', QLatin1String("shr")}, - {'s', QLatin1String("shrz")}, - {'s', QLatin1String("sign")}, - {'s', QLatin1String("simport")}, - {'s', QLatin1String("sin")}, - {'s', QLatin1String("sinh")}, - {'s', QLatin1String("sleep")}, - {'s', QLatin1String("slerp")}, - {'s', QLatin1String("slice")}, - {'s', QLatin1String("slideframe")}, - {'s', QLatin1String("smooth")}, - {'s', QLatin1String("smoothrotation")}, - {'s', QLatin1String("snoise")}, - {'s', QLatin1String("solvecubic")}, - {'s', QLatin1String("solvepoly")}, - {'s', QLatin1String("solvequadratic")}, - {'s', QLatin1String("sort")}, - {'s', QLatin1String("specular")}, - {'s', QLatin1String("specularBRDF")}, - {'s', QLatin1String("spline")}, - {'s', QLatin1String("split")}, - {'s', QLatin1String("splitpath")}, - {'s', QLatin1String("sprintf")}, - {'s', QLatin1String("sqrt")}, - {'s', QLatin1String("startswith")}, - {'s', QLatin1String("storelightexport")}, - {'s', QLatin1String("strip")}, - {'s', QLatin1String("strlen")}, - {'s', QLatin1String("sum")}, - {'s', QLatin1String("switch")}, - {'s', QLatin1String("swizzle")}, - {'t', QLatin1String("tan")}, - {'t', QLatin1String("tanh")}, - {'t', QLatin1String("tet_adjacent")}, - {'t', QLatin1String("tet_faceindex")}, - {'t', QLatin1String("teximport")}, - {'t', QLatin1String("texprintf")}, - {'t', QLatin1String("texture")}, - {'t', QLatin1String("texture3d")}, - {'t', QLatin1String("texture3dBox")}, - {'t', QLatin1String("titlecase")}, - {'t', QLatin1String("toNDC")}, - {'t', QLatin1String("tolower")}, - {'t', QLatin1String("toupper")}, - {'t', QLatin1String("trace")}, - {'t', QLatin1String("translate")}, - {'t', QLatin1String("translucent")}, - {'t', QLatin1String("transpose")}, - {'t', QLatin1String("trunc")}, - {'t', QLatin1String("tw_nspace")}, - {'t', QLatin1String("tw_space")}, - {'t', QLatin1String("tw_vspace")}, - {'u', QLatin1String("uniqueval")}, - {'u', QLatin1String("unpack_intfromsafefloat")}, - {'u', QLatin1String("unserialize")}, - {'u', QLatin1String("upush")}, - {'u', QLatin1String("uvunwrap")}, - {'v', QLatin1String("variance")}, - {'v', QLatin1String("velocityname")}, - {'v', QLatin1String("vertex")}, - {'v', QLatin1String("vertexattrib")}, - {'v', QLatin1String("vertexattribsize")}, - {'v', QLatin1String("vertexattribtype")}, - {'v', QLatin1String("vertexattribtypeinfo")}, - {'v', QLatin1String("vertexhedge")}, - {'v', QLatin1String("vertexindex")}, - {'v', QLatin1String("vertexnext")}, - {'v', QLatin1String("vertexpoint")}, - {'v', QLatin1String("vertexprev")}, - {'v', QLatin1String("vertexprim")}, - {'v', QLatin1String("vertexprimindex")}, - {'v', QLatin1String("vnoise")}, - {'v', QLatin1String("volume")}, - {'v', QLatin1String("volumegradient")}, - {'v', QLatin1String("volumeindex")}, - {'v', QLatin1String("volumeindexorigin")}, - {'v', QLatin1String("volumeindextopos")}, - {'v', QLatin1String("volumeindexv")}, - {'v', QLatin1String("volumepostoindex")}, - {'v', QLatin1String("volumeres")}, - {'v', QLatin1String("volumesample")}, - {'v', QLatin1String("volumesamplev")}, - {'v', QLatin1String("vtransform")}, - {'w', QLatin1String("warning")}, - {'w', QLatin1String("wireblinn")}, - {'w', QLatin1String("wirediffuse")}, - {'w', QLatin1String("wnoise")}, - {'w', QLatin1String("wo_nspace")}, - {'w', QLatin1String("wo_space")}, - {'w', QLatin1String("wo_vspace")}, - {'w', QLatin1String("writepixel")}, - {'w', QLatin1String("wt_nspace")}, - {'w', QLatin1String("wt_space")}, - {'w', QLatin1String("wt_vspace")}, - {'x', QLatin1String("xnoise")}, - {'x', QLatin1String("xnoised")}, - {'x', QLatin1String("xyzdist")}, - {'x', QLatin1String("xyztorgb")} - }; - vex_other = { - {('d'), QLatin1String("define")}, - {('e'), QLatin1String("else")}, - {('e'), QLatin1String("endif")}, - {('i'), QLatin1String("if")}, - {('i'), QLatin1String("ifdef")}, - {('i'), QLatin1String("ifndef")}, - {('i'), QLatin1String("include")}, - {('p'), QLatin1String("pragma")}, - {('u'), QLatin1String("undef")}, - }; -} -void loadVEXData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other) { - if (!vexDataInitialized) { - initVEXData(); - vexDataInitialized = true; - } - types = vex_types; - keywords = vex_keywords; - builtin = vex_builtin; - literals = vex_literals; - other = vex_other; -} - -/********************************************************/ -/*** CMAKE DATA ***************************************/ -/********************************************************/ -static bool cmakeDataInitialized = false; -static QMultiHash cmake_keywords; -static QMultiHash cmake_types; -static QMultiHash cmake_literals; -static QMultiHash cmake_builtin; -static QMultiHash cmake_other; -void initCMakeData() { - cmake_keywords = { - {'b', QLatin1String("break")}, - {'c', QLatin1String("cmake_host_system_information")}, - {'c', QLatin1String("cmake_minimum_required")}, - {'c', QLatin1String("cmake_parse_arguments")}, - {'c', QLatin1String("cmake_policy")}, - {'c', QLatin1String("configure_file")}, - {'c', QLatin1String("continue")}, - {'e', QLatin1String("elseif")}, - {'e', QLatin1String("else")}, - {'e', QLatin1String("endforeach")}, - {'e', QLatin1String("endfunction")}, - {'e', QLatin1String("endif")}, - {'e', QLatin1String("endmacro")}, - {'e', QLatin1String("endwhile")}, - {'e', QLatin1String("execute_process")}, - {'f', QLatin1String("file")}, - {'f', QLatin1String("find_file")}, - {'f', QLatin1String("find_library")}, - {'f', QLatin1String("find_package")}, - {'f', QLatin1String("find_path")}, - {'f', QLatin1String("find_program")}, - {'f', QLatin1String("foreach")}, - {'f', QLatin1String("function")}, - {'g', QLatin1String("get_cmake_property")}, - {'g', QLatin1String("get_directory_property")}, - {'g', QLatin1String("get_filename_component")}, - {'g', QLatin1String("get_property")}, - {'i', QLatin1String("if")}, - {'i', QLatin1String("include")}, - {'i', QLatin1String("include_guard")}, - {'l', QLatin1String("list")}, - {'m', QLatin1String("macro")}, - {'m', QLatin1String("mark_as_advanced")}, - {'m', QLatin1String("math")}, - {'m', QLatin1String("message")}, - {'o', QLatin1String("option")}, - {'r', QLatin1String("return")}, - {'s', QLatin1String("separate_arguments")}, - {'s', QLatin1String("set_directory_properties")}, - {'s', QLatin1String("set")}, - {'s', QLatin1String("set_property")}, - {'s', QLatin1String("site_name")}, - {'s', QLatin1String("string")}, - {'u', QLatin1String("unset")}, - {'v', QLatin1String("variable_watch")}, - {'w', QLatin1String("while")}, - {'a', QLatin1String("add_compile_definitions")}, - {'a', QLatin1String("add_compile_options")}, - {'A', QLatin1String("ADD_COMPILE_OPTIONS")}, - {'a', QLatin1String("add_custom_command")}, - {'a', QLatin1String("add_custom_target")}, - {'a', QLatin1String("add_definitions")}, - {'a', QLatin1String("add_dependencies")}, - {'a', QLatin1String("add_executable")}, - {'a', QLatin1String("add_library")}, - {'a', QLatin1String("add_link_options")}, - {'a', QLatin1String("add_subdirectory")}, - {'a', QLatin1String("add_test")}, - {'a', QLatin1String("aux_source_directory")}, - {'b', QLatin1String("build_command")}, - {'c', QLatin1String("create_test_sourcelist")}, - {'d', QLatin1String("define_property")}, - {'e', QLatin1String("enable_language")}, - {'e', QLatin1String("enable_testing")}, - {'e', QLatin1String("export")}, - {'f', QLatin1String("fltk_wrap_ui")}, - {'g', QLatin1String("get_source_file_property")}, - {'g', QLatin1String("get_target_property")}, - {'g', QLatin1String("get_test_property")}, - {'i', QLatin1String("include_directories")}, - {'i', QLatin1String("include_external_msproject")}, - {'i', QLatin1String("include_regular_expression")}, - {'i', QLatin1String("install")}, - {'l', QLatin1String("link_directories")}, - {'l', QLatin1String("link_libraries")}, - {'l', QLatin1String("load_cache")}, - {'p', QLatin1String("project")}, - {'q', QLatin1String("qt_wrap_cpp")}, - {'q', QLatin1String("qt_wrap_ui")}, - {'r', QLatin1String("remove_definitions")}, - {'s', QLatin1String("set_source_files_properties")}, - {'s', QLatin1String("set_target_properties")}, - {'s', QLatin1String("set_tests_properties")}, - {'s', QLatin1String("source_group")}, - {'t', QLatin1String("target_compile_definitions")}, - {'t', QLatin1String("target_compile_features")}, - {'t', QLatin1String("target_compile_options")}, - {'t', QLatin1String("target_include_directories")}, - {'t', QLatin1String("target_link_directories")}, - {'t', QLatin1String("target_link_libraries")}, - {'t', QLatin1String("target_link_options")}, - {'t', QLatin1String("target_sources")}, - {'t', QLatin1String("try_compile")}, - {'t', QLatin1String("try_run")}, - {'c', QLatin1String("ctest_build")}, - {'c', QLatin1String("ctest_configure")}, - {'c', QLatin1String("ctest_coverage")}, - {'c', QLatin1String("ctest_empty_binary_directory")}, - {'c', QLatin1String("ctest_memcheck")}, - {'c', QLatin1String("ctest_read_custom_files")}, - {'c', QLatin1String("ctest_run_script")}, - {'c', QLatin1String("ctest_sleep")}, - {'c', QLatin1String("ctest_start")}, - {'c', QLatin1String("ctest_submit")}, - {'c', QLatin1String("ctest_test")}, - {'c', QLatin1String("ctest_update")}, - {'c', QLatin1String("ctest_upload")}, - {'b', QLatin1String("build_name")}, - {'e', QLatin1String("exec_program")}, - {'e', QLatin1String("export_library_dependencies")}, - {'i', QLatin1String("install_files")}, - {'i', QLatin1String("install_programs")}, - {'i', QLatin1String("install_targets")}, - {'l', QLatin1String("load_command")}, - {'m', QLatin1String("make_directory")}, - {'o', QLatin1String("output_required_files")}, - {'r', QLatin1String("remove")}, - {'s', QLatin1String("subdir_depends")}, - {'s', QLatin1String("subdirs")}, - {'u', QLatin1String("use_mangled_mesa")}, - {'u', QLatin1String("utility_source")}, - {'v', QLatin1String("variable_requires")}, - {'w', QLatin1String("write_file")}, - {'q', QLatin1String("qt5_use_modules")}, - {'q', QLatin1String("qt5_use_package")}, - {'q', QLatin1String("qt5_wrap_cpp")}, - {'a', QLatin1String("and")}, - {'o', QLatin1String("or")}, - {'n', QLatin1String("not")}, - {'c', QLatin1String("command")}, - {'p', QLatin1String("policy")}, - {'t', QLatin1String("target")}, - {'t', QLatin1String("test")}, - {'e', QLatin1String("exists")}, - {'i', QLatin1String("is_newer_than")}, - {'i', QLatin1String("is_directory")}, - {'i', QLatin1String("is_symlink")}, - {'i', QLatin1String("is_absolute")}, - {'m', QLatin1String("matches")}, - {'l', QLatin1String("less")}, - {'g', QLatin1String("greater")}, - {'e', QLatin1String("equal")}, - {'l', QLatin1String("less_equal")}, - {'g', QLatin1String("greater_equal")}, - {'s', QLatin1String("strless")}, - {'s', QLatin1String("strgreater")}, - {'s', QLatin1String("strequal")}, - {'s', QLatin1String("strless_equal")}, - {'s', QLatin1String("strgreater_equal")}, - {'v', QLatin1String("version_less")}, - {'v', QLatin1String("version_greater")}, - {'v', QLatin1String("version_equal")}, - {'v', QLatin1String("version_less_equal")}, - {'v', QLatin1String("version_greater_equal")}, - {'i', QLatin1String("in_list")}, - {'d', QLatin1String("defined")} - }; - cmake_types = {}; - cmake_literals = { - {'o', QLatin1String("on")}, - {'o', QLatin1String("off")}, - {'O', QLatin1String("ON")}, - {'O', QLatin1String("OFF")}, - {'t', QLatin1String("true")}, - {'f', QLatin1String("false")}, - {'T', QLatin1String("TRUE")}, - {'F', QLatin1String("FALSE")} - }; - cmake_builtin = { - {'A', QLatin1String("ALLOW_DUPLICATE_CUSTOM_TARGETS")}, - {'A', QLatin1String("AUTOGEN_TARGETS_FOLDER")}, - {'A', QLatin1String("AUTOMOC_TARGETS_FOLDER")}, - {'D', QLatin1String("DEBUG_CONFIGURATIONS")}, - {'D', QLatin1String("DISABLED_FEATURES")}, - {'E', QLatin1String("ENABLED_FEATURES")}, - {'E', QLatin1String("ENABLED_LANGUAGES")}, - {'F', QLatin1String("FIND_LIBRARY_USE_LIB64_PATHS")}, - {'F', QLatin1String("FIND_LIBRARY_USE_OPENBSD_VERSIONING")}, - {'G', QLatin1String("GLOBAL_DEPENDS_DEBUG_MODE")}, - {'G', QLatin1String("GLOBAL_DEPENDS_NO_CYCLES")}, - {'I', QLatin1String("IN_TRY_COMPILE")}, - {'P', QLatin1String("PACKAGES_FOUND")}, - {'P', QLatin1String("PACKAGES_NOT_FOUND")}, - {'J', QLatin1String("JOB_POOLS")}, - {'P', QLatin1String("PREDEFINED_TARGETS_FOLDER")}, - {'E', QLatin1String("ECLIPSE_EXTRA_NATURES")}, - {'R', QLatin1String("REPORT_UNDEFINED_PROPERTIES")}, - {'R', QLatin1String("RULE_LAUNCH_COMPILE")}, - {'R', QLatin1String("RULE_LAUNCH_CUSTOM")}, - {'R', QLatin1String("RULE_LAUNCH_LINK")}, - {'R', QLatin1String("RULE_MESSAGES")}, - {'T', QLatin1String("TARGET_ARCHIVES_MAY_BE_SHARED_LIBS")}, - {'T', QLatin1String("TARGET_SUPPORTS_SHARED_LIBS")}, - {'U', QLatin1String("USE_FOLDERS")}, - {'A', QLatin1String("ADDITIONAL_MAKE_CLEAN_FILES")}, - {'C', QLatin1String("CACHE_VARIABLES")}, - {'C', QLatin1String("CLEAN_NO_CUSTOM")}, - {'C', QLatin1String("CMAKE_CONFIGURE_DEPENDS")}, - {'C', QLatin1String("COMPILE_DEFINITIONS")}, - {'C', QLatin1String("COMPILE_OPTIONS")}, - {'D', QLatin1String("DEFINITIONS")}, - {'E', QLatin1String("EXCLUDE_FROM_ALL")}, - {'I', QLatin1String("IMPLICIT_DEPENDS_INCLUDE_TRANSFORM")}, - {'I', QLatin1String("INCLUDE_DIRECTORIES")}, - {'I', QLatin1String("INCLUDE_REGULAR_EXPRESSION")}, - {'I', QLatin1String("INTERPROCEDURAL_OPTIMIZATION")}, - {'L', QLatin1String("LINK_DIRECTORIES")}, - {'L', QLatin1String("LISTFILE_STACK")}, - {'M', QLatin1String("MACROS")}, - {'P', QLatin1String("PARENT_DIRECTORY")}, - {'R', QLatin1String("RULE_LAUNCH_COMPILE")}, - {'R', QLatin1String("RULE_LAUNCH_CUSTOM")}, - {'R', QLatin1String("RULE_LAUNCH_LINK")}, - {'T', QLatin1String("TEST_INCLUDE_FILE")}, - {'V', QLatin1String("VARIABLES")}, - {'A', QLatin1String("ALIASED_TARGET")}, - {'A', QLatin1String("ARCHIVE_OUTPUT_DIRECTORY")}, - {'A', QLatin1String("ARCHIVE_OUTPUT_NAME")}, - {'A', QLatin1String("AUTOGEN_TARGET_DEPENDS")}, - {'A', QLatin1String("AUTOMOC_MOC_OPTIONS")}, - {'A', QLatin1String("AUTOMOC")}, - {'A', QLatin1String("AUTOUIC")}, - {'A', QLatin1String("AUTOUIC_OPTIONS")}, - {'A', QLatin1String("AUTORCC")}, - {'A', QLatin1String("AUTORCC_OPTIONS")}, - {'B', QLatin1String("BUILD_WITH_INSTALL_RPATH")}, - {'B', QLatin1String("BUNDLE_EXTENSION")}, - {'B', QLatin1String("BUNDLE")}, - {'C', QLatin1String("COMPATIBLE_INTERFACE_BOOL")}, - {'C', QLatin1String("COMPATIBLE_INTERFACE_NUMBER_MAX")}, - {'C', QLatin1String("COMPATIBLE_INTERFACE_NUMBER_MIN")}, - {'C', QLatin1String("COMPATIBLE_INTERFACE_STRING")}, - {'C', QLatin1String("COMPILE_DEFINITIONS")}, - {'C', QLatin1String("COMPILE_FLAGS")}, - {'C', QLatin1String("COMPILE_OPTIONS")}, - {'D', QLatin1String("DEBUG_POSTFIX")}, - {'D', QLatin1String("DEFINE_SYMBOL")}, - {'E', QLatin1String("EchoString")}, - {'E', QLatin1String("ENABLE_EXPORTS")}, - {'E', QLatin1String("EXCLUDE_FROM_ALL")}, - {'E', QLatin1String("EXCLUDE_FROM_DEFAULT_BUILD")}, - {'E', QLatin1String("EXPORT_NAME")}, - {'F', QLatin1String("FOLDER")}, - {'F', QLatin1String("Fortran_FORMAT")}, - {'F', QLatin1String("Fortran_MODULE_DIRECTORY")}, - {'F', QLatin1String("FRAMEWORK")}, - {'G', QLatin1String("GENERATOR_FILE_NAME")}, - {'G', QLatin1String("GNUtoMS")}, - {'H', QLatin1String("HAS_CXX")}, - {'I', QLatin1String("IMPLICIT_DEPENDS_INCLUDE_TRANSFORM")}, - {'I', QLatin1String("IMPORTED_CONFIGURATIONS")}, - {'I', QLatin1String("IMPORTED_IMPLIB")}, - {'I', QLatin1String("IMPORTED_LINK_DEPENDENT_LIBRARIES")}, - {'I', QLatin1String("IMPORTED_LINK_INTERFACE_LANGUAGES")}, - {'I', QLatin1String("IMPORTED_LINK_INTERFACE_LIBRARIES")}, - {'I', QLatin1String("IMPORTED_LINK_INTERFACE_MULTIPLICITY")}, - {'I', QLatin1String("IMPORTED_LOCATION")}, - {'I', QLatin1String("IMPORTED_NO_SONAME")}, - {'I', QLatin1String("IMPORTED")}, - {'I', QLatin1String("IMPORTED_SONAME")}, - {'I', QLatin1String("IMPORT_PREFIX")}, - {'I', QLatin1String("IMPORT_SUFFIX")}, - {'I', QLatin1String("INCLUDE_DIRECTORIES")}, - {'I', QLatin1String("INSTALL_NAME_DIR")}, - {'I', QLatin1String("INSTALL_RPATH")}, - {'I', QLatin1String("INSTALL_RPATH_USE_LINK_PATH")}, - {'I', QLatin1String("INTERFACE_AUTOUIC_OPTIONS")}, - {'I', QLatin1String("INTERFACE_COMPILE_DEFINITIONS")}, - {'I', QLatin1String("INTERFACE_COMPILE_OPTIONS")}, - {'I', QLatin1String("INTERFACE_INCLUDE_DIRECTORIES")}, - {'I', QLatin1String("INTERFACE_LINK_LIBRARIES")}, - {'I', QLatin1String("INTERFACE_POSITION_INDEPENDENT_CODE")}, - {'I', QLatin1String("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES")}, - {'I', QLatin1String("INTERPROCEDURAL_OPTIMIZATION")}, - {'J', QLatin1String("JOB_POOL_COMPILE")}, - {'J', QLatin1String("JOB_POOL_LINK")}, - {'L', QLatin1String("LABELS")}, - {'L', QLatin1String("LIBRARY_OUTPUT_DIRECTORY")}, - {'L', QLatin1String("LIBRARY_OUTPUT_NAME")}, - {'L', QLatin1String("LINK_DEPENDS_NO_SHARED")}, - {'L', QLatin1String("LINK_DEPENDS")}, - {'L', QLatin1String("LINKER_LANGUAGE")}, - {'L', QLatin1String("LINK_FLAGS")}, - {'L', QLatin1String("LINK_INTERFACE_LIBRARIES")}, - {'L', QLatin1String("LINK_INTERFACE_MULTIPLICITY")}, - {'L', QLatin1String("LINK_LIBRARIES")}, - {'L', QLatin1String("LINK_SEARCH_END_STATIC")}, - {'L', QLatin1String("LINK_SEARCH_START_STATIC")}, - {'L', QLatin1String("LOCATION")}, - {'M', QLatin1String("MACOSX_BUNDLE_INFO_PLIST")}, - {'M', QLatin1String("MACOSX_BUNDLE")}, - {'M', QLatin1String("MACOSX_FRAMEWORK_INFO_PLIST")}, - {'M', QLatin1String("MACOSX_RPATH")}, -// {'N', QLatin1String("NAME")}, - {'N', QLatin1String("NO_SONAME")}, - {'N', QLatin1String("NO_SYSTEM_FROM_IMPORTED")}, - {'O', QLatin1String("OSX_ARCHITECTURES")}, - {'O', QLatin1String("OUTPUT_NAME")}, - {'P', QLatin1String("PDB_NAME")}, - {'P', QLatin1String("PDB_OUTPUT_DIRECTORY")}, - {'P', QLatin1String("POSITION_INDEPENDENT_CODE")}, - {'P', QLatin1String("POST_INSTALL_SCRIPT")}, - {'P', QLatin1String("PREFIX")}, - {'P', QLatin1String("PROPERTY")}, - {'P', QLatin1String("PRE_INSTALL_SCRIPT")}, - {'P', QLatin1String("PRIVATE_HEADER")}, - {'P', QLatin1String("PROJECT_LABEL")}, - {'P', QLatin1String("PUBLIC_HEADER")}, - {'R', QLatin1String("RESOURCE")}, - {'R', QLatin1String("RULE_LAUNCH_COMPILE")}, - {'R', QLatin1String("RULE_LAUNCH_CUSTOM")}, - {'R', QLatin1String("RULE_LAUNCH_LINK")}, - {'R', QLatin1String("RUNTIME_OUTPUT_DIRECTORY")}, - {'R', QLatin1String("RUNTIME_OUTPUT_NAME")}, - {'S', QLatin1String("SKIP_BUILD_RPATH")}, - {'S', QLatin1String("SOURCES")}, - {'S', QLatin1String("SOVERSION")}, - {'S', QLatin1String("STATIC_LIBRARY_FLAGS")}, - {'S', QLatin1String("SUFFIX")}, - {'T', QLatin1String("TARGET")}, - {'T', QLatin1String("TYPE")}, - {'V', QLatin1String("VERSION")}, - {'V', QLatin1String("VISIBILITY_INLINES_HIDDEN")}, - {'V', QLatin1String("VS_DOTNET_REFERENCES")}, - {'V', QLatin1String("VS_DOTNET_TARGET_FRAMEWORK_VERSION")}, - {'V', QLatin1String("VS_GLOBAL_KEYWORD")}, - {'V', QLatin1String("VS_GLOBAL_PROJECT_TYPES")}, - {'V', QLatin1String("VS_GLOBAL_ROOTNAMESPACE")}, - {'V', QLatin1String("VS_KEYWORD")}, - {'V', QLatin1String("VS_SCC_AUXPATH")}, - {'V', QLatin1String("VS_SCC_LOCALPATH")}, - {'V', QLatin1String("VS_SCC_PROJECTNAME")}, - {'V', QLatin1String("VS_SCC_PROVIDER")}, - {'V', QLatin1String("VS_WINRT_EXTENSIONS")}, - {'V', QLatin1String("VS_WINRT_REFERENCES")}, - {'W', QLatin1String("WIN32_EXECUTABLE")}, - {'A', QLatin1String("ATTACHED_FILES_ON_FAIL")}, - {'A', QLatin1String("ATTACHED_FILES")}, - {'C', QLatin1String("COST")}, - {'D', QLatin1String("DEPENDS")}, - {'E', QLatin1String("ENVIRONMENT")}, - {'F', QLatin1String("FAIL_REGULAR_EXPRESSION")}, - {'L', QLatin1String("LABELS")}, - {'M', QLatin1String("MEASUREMENT")}, - {'P', QLatin1String("PASS_REGULAR_EXPRESSION")}, - {'P', QLatin1String("PROCESSORS")}, - {'R', QLatin1String("REQUIRED_FILES")}, - {'R', QLatin1String("RESOURCE_LOCK")}, - {'R', QLatin1String("RUN_SERIAL")}, - {'S', QLatin1String("SKIP_RETURN_CODE")}, - {'T', QLatin1String("TIMEOUT")}, - {'W', QLatin1String("WILL_FAIL")}, - {'W', QLatin1String("WORKING_DIRECTORY")}, - {'A', QLatin1String("ABSTRACT")}, - {'A', QLatin1String("AUTOUIC_OPTIONS")}, - {'A', QLatin1String("AUTORCC_OPTIONS")}, - {'C', QLatin1String("COMPILE_DEFINITIONS")}, - {'C', QLatin1String("COMPILE_FLAGS")}, - {'E', QLatin1String("EXTERNAL_OBJECT")}, - {'F', QLatin1String("Fortran_FORMAT")}, - {'G', QLatin1String("GENERATED")}, - {'H', QLatin1String("HEADER_FILE_ONLY")}, - {'K', QLatin1String("KEEP_EXTENSION")}, - {'L', QLatin1String("LABELS")}, -// {'L', QLatin1String("LANGUAGE")}, - {'L', QLatin1String("LOCATION")}, - {'M', QLatin1String("MACOSX_PACKAGE_LOCATION")}, - {'O', QLatin1String("OBJECT_DEPENDS")}, - {'O', QLatin1String("OBJECT_OUTPUTS")}, - {'S', QLatin1String("SYMBOLIC")}, - {'W', QLatin1String("WRAP_EXCLUDE")}, - {'A', QLatin1String("ADVANCED")}, - {'H', QLatin1String("HELPSTRING")}, - {'M', QLatin1String("MODIFIED")}, - {'S', QLatin1String("STRINGS")}, - {'T', QLatin1String("TYPE")}, - {'V', QLatin1String("VALUE")} - }; - cmake_other = { - {'C', QLatin1String("CMAKE_ARGC")}, - {'C', QLatin1String("CMAKE_ARGV0")}, - {'C', QLatin1String("CMAKE_AR")}, - {'C', QLatin1String("CMAKE_BINARY_DIR")}, - {'C', QLatin1String("CMAKE_BUILD_TOOL")}, - {'C', QLatin1String("CMAKE_CACHEFILE_DIR")}, - {'C', QLatin1String("CMAKE_CACHE_MAJOR_VERSION")}, - {'C', QLatin1String("CMAKE_CACHE_MINOR_VERSION")}, - {'C', QLatin1String("CMAKE_CACHE_PATCH_VERSION")}, - {'C', QLatin1String("CMAKE_CFG_INTDIR")}, - {'C', QLatin1String("CMAKE_COMMAND")}, - {'C', QLatin1String("CMAKE_CROSSCOMPILING")}, - {'C', QLatin1String("CMAKE_CTEST_COMMAND")}, - {'C', QLatin1String("CMAKE_CURRENT_BINARY_DIR")}, - {'C', QLatin1String("CMAKE_CURRENT_LIST_DIR")}, - {'C', QLatin1String("CMAKE_CURRENT_LIST_FILE")}, - {'C', QLatin1String("CMAKE_CURRENT_LIST_LINE")}, - {'C', QLatin1String("CMAKE_CURRENT_SOURCE_DIR")}, - {'C', QLatin1String("CMAKE_DL_LIBS")}, - {'C', QLatin1String("CMAKE_EDIT_COMMAND")}, - {'C', QLatin1String("CMAKE_EXECUTABLE_SUFFIX")}, - {'C', QLatin1String("CMAKE_EXTRA_GENERATOR")}, - {'C', QLatin1String("CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES")}, - {'C', QLatin1String("CMAKE_GENERATOR")}, - {'C', QLatin1String("CMAKE_GENERATOR_TOOLSET")}, - {'C', QLatin1String("CMAKE_HOME_DIRECTORY")}, - {'C', QLatin1String("CMAKE_IMPORT_LIBRARY_PREFIX")}, - {'C', QLatin1String("CMAKE_IMPORT_LIBRARY_SUFFIX")}, - {'C', QLatin1String("CMAKE_JOB_POOL_COMPILE")}, - {'C', QLatin1String("CMAKE_JOB_POOL_LINK")}, - {'C', QLatin1String("CMAKE_LINK_LIBRARY_SUFFIX")}, - {'C', QLatin1String("CMAKE_MAJOR_VERSION")}, - {'C', QLatin1String("CMAKE_MAKE_PROGRAM")}, - {'C', QLatin1String("CMAKE_MINIMUM_REQUIRED_VERSION")}, - {'C', QLatin1String("CMAKE_MINOR_VERSION")}, - {'C', QLatin1String("CMAKE_PARENT_LIST_FILE")}, - {'C', QLatin1String("CMAKE_PATCH_VERSION")}, - {'C', QLatin1String("CMAKE_PROJECT_NAME")}, - {'C', QLatin1String("CMAKE_RANLIB")}, - {'C', QLatin1String("CMAKE_ROOT")}, - {'C', QLatin1String("CMAKE_SCRIPT_MODE_FILE")}, - {'C', QLatin1String("CMAKE_SHARED_LIBRARY_PREFIX")}, - {'C', QLatin1String("CMAKE_SHARED_LIBRARY_SUFFIX")}, - {'C', QLatin1String("CMAKE_SHARED_MODULE_PREFIX")}, - {'C', QLatin1String("CMAKE_SHARED_MODULE_SUFFIX")}, - {'C', QLatin1String("CMAKE_SIZEOF_VOID_P")}, - {'C', QLatin1String("CMAKE_SKIP_INSTALL_RULES")}, - {'C', QLatin1String("CMAKE_SKIP_RPATH")}, - {'C', QLatin1String("CMAKE_SOURCE_DIR")}, - {'C', QLatin1String("CMAKE_STANDARD_LIBRARIES")}, - {'C', QLatin1String("CMAKE_STATIC_LIBRARY_PREFIX")}, - {'C', QLatin1String("CMAKE_STATIC_LIBRARY_SUFFIX")}, - {'C', QLatin1String("CMAKE_TOOLCHAIN_FILE")}, - {'C', QLatin1String("CMAKE_TWEAK_VERSION")}, - {'C', QLatin1String("CMAKE_VERBOSE_MAKEFILE")}, - {'C', QLatin1String("CMAKE_VERSION")}, - {'C', QLatin1String("CMAKE_VS_DEVENV_COMMAND")}, - {'C', QLatin1String("CMAKE_VS_INTEL_Fortran_PROJECT_VERSION")}, - {'C', QLatin1String("CMAKE_VS_MSBUILD_COMMAND")}, - {'C', QLatin1String("CMAKE_VS_MSDEV_COMMAND")}, - {'C', QLatin1String("CMAKE_VS_PLATFORM_TOOLSET")}, - {'C', QLatin1String("CMAKE_XCODE_PLATFORM_TOOLSET")}, - {'P', QLatin1String("PROJECT_BINARY_DIR")}, -// {'P', QLatin1String("PROJECT_NAME")}, - {'P', QLatin1String("PROJECT_SOURCE_DIR")}, - {'P', QLatin1String("PROJECT_VERSION")}, - {'P', QLatin1String("PROJECT_VERSION_MAJOR")}, - {'P', QLatin1String("PROJECT_VERSION_MINOR")}, - {'P', QLatin1String("PROJECT_VERSION_PATCH")}, - {'P', QLatin1String("PROJECT_VERSION_TWEAK")}, - {'B', QLatin1String("BUILD_SHARED_LIBS")}, - {'C', QLatin1String("CMAKE_ABSOLUTE_DESTINATION_FILES")}, - {'C', QLatin1String("CMAKE_APPBUNDLE_PATH")}, - {'C', QLatin1String("CMAKE_AUTOMOC_RELAXED_MODE")}, - {'C', QLatin1String("CMAKE_BACKWARDS_COMPATIBILITY")}, - {'C', QLatin1String("CMAKE_BUILD_TYPE")}, - {'C', QLatin1String("CMAKE_COLOR_MAKEFILE")}, - {'C', QLatin1String("CMAKE_CONFIGURATION_TYPES")}, - {'C', QLatin1String("CMAKE_DEBUG_TARGET_PROPERTIES")}, - {'C', QLatin1String("CMAKE_ERROR_DEPRECATED")}, - {'C', QLatin1String("CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION")}, - {'C', QLatin1String("CMAKE_SYSROOT")}, - {'C', QLatin1String("CMAKE_FIND_LIBRARY_PREFIXES")}, - {'C', QLatin1String("CMAKE_FIND_LIBRARY_SUFFIXES")}, - {'C', QLatin1String("CMAKE_FIND_NO_INSTALL_PREFIX")}, - {'C', QLatin1String("CMAKE_FIND_PACKAGE_WARN_NO_MODULE")}, - {'C', QLatin1String("CMAKE_FIND_ROOT_PATH")}, - {'C', QLatin1String("CMAKE_FIND_ROOT_PATH_MODE_INCLUDE")}, - {'C', QLatin1String("CMAKE_FIND_ROOT_PATH_MODE_LIBRARY")}, - {'C', QLatin1String("CMAKE_FIND_ROOT_PATH_MODE_PACKAGE")}, - {'C', QLatin1String("CMAKE_FIND_ROOT_PATH_MODE_PROGRAM")}, - {'C', QLatin1String("CMAKE_FRAMEWORK_PATH")}, - {'C', QLatin1String("CMAKE_IGNORE_PATH")}, - {'C', QLatin1String("CMAKE_INCLUDE_PATH")}, - {'C', QLatin1String("CMAKE_INCLUDE_DIRECTORIES_BEFORE")}, - {'C', QLatin1String("CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE")}, - {'C', QLatin1String("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME")}, - {'C', QLatin1String("CMAKE_INSTALL_PREFIX")}, - {'C', QLatin1String("CMAKE_LIBRARY_PATH")}, - {'C', QLatin1String("CMAKE_MFC_FLAG")}, - {'C', QLatin1String("CMAKE_MODULE_PATH")}, - {'C', QLatin1String("CMAKE_NOT_USING_CONFIG_FLAGS")}, - {'C', QLatin1String("CMAKE_PREFIX_PATH")}, - {'C', QLatin1String("CMAKE_PROGRAM_PATH")}, - {'C', QLatin1String("CMAKE_SKIP_INSTALL_ALL_DEPENDENCY")}, - {'C', QLatin1String("CMAKE_STAGING_PREFIX")}, - {'C', QLatin1String("CMAKE_SYSTEM_IGNORE_PATH")}, - {'C', QLatin1String("CMAKE_SYSTEM_INCLUDE_PATH")}, - {'C', QLatin1String("CMAKE_SYSTEM_LIBRARY_PATH")}, - {'C', QLatin1String("CMAKE_SYSTEM_PREFIX_PATH")}, - {'C', QLatin1String("CMAKE_SYSTEM_PROGRAM_PATH")}, - {'C', QLatin1String("CMAKE_USER_MAKE_RULES_OVERRIDE")}, - {'C', QLatin1String("CMAKE_WARN_DEPRECATED")}, - {'C', QLatin1String("CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION")}, - {'A', QLatin1String("APPLE")}, - {'B', QLatin1String("BORLAND")}, - {'C', QLatin1String("CMAKE_CL_64")}, - {'C', QLatin1String("CMAKE_COMPILER_2005")}, - {'C', QLatin1String("CMAKE_HOST_APPLE")}, - {'C', QLatin1String("CMAKE_HOST_SYSTEM_NAME")}, - {'C', QLatin1String("CMAKE_HOST_SYSTEM_PROCESSOR")}, - {'C', QLatin1String("CMAKE_HOST_SYSTEM")}, - {'C', QLatin1String("CMAKE_HOST_SYSTEM_VERSION")}, - {'C', QLatin1String("CMAKE_HOST_UNIX")}, - {'C', QLatin1String("CMAKE_HOST_WIN32")}, - {'C', QLatin1String("CMAKE_LIBRARY_ARCHITECTURE_REGEX")}, - {'C', QLatin1String("CMAKE_LIBRARY_ARCHITECTURE")}, - {'C', QLatin1String("CMAKE_OBJECT_PATH_MAX")}, - {'C', QLatin1String("CMAKE_SYSTEM_NAME")}, - {'C', QLatin1String("CMAKE_SYSTEM_PROCESSOR")}, - {'C', QLatin1String("CMAKE_SYSTEM")}, - {'C', QLatin1String("CMAKE_SYSTEM_VERSION")}, - {'C', QLatin1String("CYGWIN")}, - {'E', QLatin1String("ENV")}, - {'M', QLatin1String("MSVC10")}, - {'M', QLatin1String("MSVC11")}, - {'M', QLatin1String("MSVC12")}, - {'M', QLatin1String("MSVC60")}, - {'M', QLatin1String("MSVC70")}, - {'M', QLatin1String("MSVC71")}, - {'M', QLatin1String("MSVC80")}, - {'M', QLatin1String("MSVC90")}, - {'M', QLatin1String("MSVC_IDE")}, - {'M', QLatin1String("MSVC")}, - {'M', QLatin1String("MSVC_VERSION")}, - {'U', QLatin1String("UNIX")}, - {'W', QLatin1String("WIN32")}, - {'X', QLatin1String("XCODE_VERSION")}, - {'C', QLatin1String("CMAKE_ARCHIVE_OUTPUT_DIRECTORY")}, - {'C', QLatin1String("CMAKE_AUTOMOC_MOC_OPTIONS")}, - {'C', QLatin1String("CMAKE_AUTOMOC")}, - {'C', QLatin1String("CMAKE_AUTORCC")}, - {'C', QLatin1String("CMAKE_AUTORCC_OPTIONS")}, - {'C', QLatin1String("CMAKE_AUTOUIC")}, - {'C', QLatin1String("CMAKE_AUTOUIC_OPTIONS")}, - {'C', QLatin1String("CMAKE_BUILD_WITH_INSTALL_RPATH")}, - {'C', QLatin1String("CMAKE_DEBUG_POSTFIX")}, - {'C', QLatin1String("CMAKE_EXE_LINKER_FLAGS")}, - {'C', QLatin1String("CMAKE_Fortran_FORMAT")}, - {'C', QLatin1String("CMAKE_Fortran_MODULE_DIRECTORY")}, - {'C', QLatin1String("CMAKE_GNUtoMS")}, - {'C', QLatin1String("CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE")}, - {'C', QLatin1String("CMAKE_INCLUDE_CURRENT_DIR")}, - {'C', QLatin1String("CMAKE_INSTALL_NAME_DIR")}, - {'C', QLatin1String("CMAKE_INSTALL_RPATH")}, - {'C', QLatin1String("CMAKE_INSTALL_RPATH_USE_LINK_PATH")}, - {'C', QLatin1String("CMAKE_LIBRARY_OUTPUT_DIRECTORY")}, - {'C', QLatin1String("CMAKE_LIBRARY_PATH_FLAG")}, - {'C', QLatin1String("CMAKE_LINK_DEF_FILE_FLAG")}, - {'C', QLatin1String("CMAKE_LINK_DEPENDS_NO_SHARED")}, - {'C', QLatin1String("CMAKE_LINK_INTERFACE_LIBRARIES")}, - {'C', QLatin1String("CMAKE_LINK_LIBRARY_FILE_FLAG")}, - {'C', QLatin1String("CMAKE_LINK_LIBRARY_FLAG")}, - {'C', QLatin1String("CMAKE_MACOSX_BUNDLE")}, - {'C', QLatin1String("CMAKE_MACOSX_RPATH")}, - {'C', QLatin1String("CMAKE_MODULE_LINKER_FLAGS")}, - {'C', QLatin1String("CMAKE_NO_BUILTIN_CHRPATH")}, - {'C', QLatin1String("CMAKE_NO_SYSTEM_FROM_IMPORTED")}, - {'C', QLatin1String("CMAKE_OSX_ARCHITECTURES")}, - {'C', QLatin1String("CMAKE_OSX_DEPLOYMENT_TARGET")}, - {'C', QLatin1String("CMAKE_OSX_SYSROOT")}, - {'C', QLatin1String("CMAKE_PDB_OUTPUT_DIRECTORY")}, - {'C', QLatin1String("CMAKE_POSITION_INDEPENDENT_CODE")}, - {'C', QLatin1String("CMAKE_RUNTIME_OUTPUT_DIRECTORY")}, - {'C', QLatin1String("CMAKE_SHARED_LINKER_FLAGS")}, - {'C', QLatin1String("CMAKE_SKIP_BUILD_RPATH")}, - {'C', QLatin1String("CMAKE_SKIP_INSTALL_RPATH")}, - {'C', QLatin1String("CMAKE_STATIC_LINKER_FLAGS")}, - {'C', QLatin1String("CMAKE_TRY_COMPILE_CONFIGURATION")}, - {'C', QLatin1String("CMAKE_USE_RELATIVE_PATHS")}, - {'C', QLatin1String("CMAKE_VISIBILITY_INLINES_HIDDEN")}, - {'C', QLatin1String("CMAKE_WIN32_EXECUTABLE")}, - {'E', QLatin1String("EXECUTABLE_OUTPUT_PATH")}, - {'L', QLatin1String("LIBRARY_OUTPUT_PATH")}, - {'C', QLatin1String("CMAKE_Fortran_MODDIR_DEFAULT")}, - {'C', QLatin1String("CMAKE_Fortran_MODDIR_FLAG")}, - {'C', QLatin1String("CMAKE_Fortran_MODOUT_FLAG")}, - {'C', QLatin1String("CMAKE_INTERNAL_PLATFORM_ABI")}, - {'C', QLatin1String("CPACK_ABSOLUTE_DESTINATION_FILES")}, - {'C', QLatin1String("CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY")}, - {'C', QLatin1String("CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION")}, - {'C', QLatin1String("CPACK_INCLUDE_TOPLEVEL_DIRECTORY")}, - {'C', QLatin1String("CPACK_INSTALL_SCRIPT")}, - {'C', QLatin1String("CPACK_PACKAGING_INSTALL_PREFIX")}, - {'C', QLatin1String("CPACK_SET_DESTDIR")}, - {'C', QLatin1String("CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION")} - }; -} - -void loadCMakeData(QMultiHash &types, QMultiHash &keywords, QMultiHash &builtin, QMultiHash &literals, QMultiHash &other) -{ - if (!cmakeDataInitialized) { - initCMakeData(); - cmakeDataInitialized = true; - } - types = cmake_types; - keywords = cmake_keywords; - builtin = cmake_builtin; - literals = cmake_literals; - other = cmake_other; -} - -/********************************************************/ -/*** MAKE DATA ***************************************/ -/********************************************************/ -static bool makeDataInitialized = false; -static QMultiHash make_keywords; -static QMultiHash make_types; -static QMultiHash make_literals; -static QMultiHash make_builtin; -static QMultiHash make_other; -void initMakeData() { - make_keywords = { - {'i', QLatin1String("include")}, - {'d', QLatin1String("define")}, - {'e', QLatin1String("else")}, - {'e', QLatin1String("endef")}, - {'e', QLatin1String("endif")}, - {'e', QLatin1String("export")}, - {'i', QLatin1String("ifn?def")}, - {'i', QLatin1String("ifn?eq")}, - {'i', QLatin1String("include")}, - {'o', QLatin1String("override")}, - {'p', QLatin1String("private")}, - {'s', QLatin1String("sinclude")}, - {'u', QLatin1String("undefine")}, - {'u', QLatin1String("unexport")}, - {'v', QLatin1String("vpath")} - }; - make_types = { - {'a', QLatin1String("addsuffix")}, - {'a', QLatin1String("abspath")}, - {'a', QLatin1String("and")}, - {'a', QLatin1String("ar")}, - {'b', QLatin1String("basename")}, - {'c', QLatin1String("call")}, - {'d', QLatin1String("dir")}, - {'e', QLatin1String("error")}, - {'e', QLatin1String("eval")}, - {'f', QLatin1String("file")}, - {'f', QLatin1String("filter")}, - {'f', QLatin1String("find")}, - {'f', QLatin1String("findstring")}, - {'f', QLatin1String("firstword")}, - {'f', QLatin1String("flavor")}, - {'f', QLatin1String("foreach")}, - {'g', QLatin1String("guile")}, - {'i', QLatin1String("if")}, - {'i', QLatin1String("info")}, - {'i', QLatin1String("install")}, - {'j', QLatin1String("join")}, - {'l', QLatin1String("lastword")}, - {'l', QLatin1String("load")}, - {'n', QLatin1String("notdir")}, - {'o', QLatin1String("or")}, - {'o', QLatin1String("origin")}, - {'p', QLatin1String("patsubst")}, - {'r', QLatin1String("ranlib")}, - {'r', QLatin1String("realpath")}, - {'r', QLatin1String("rm")}, - {'s', QLatin1String("shell")}, - {'s', QLatin1String("sort")}, - {'s', QLatin1String("strip")}, - {'s', QLatin1String("subst")}, - {'s', QLatin1String("suffix")}, - {'v', QLatin1String("value")}, - {'w', QLatin1String("warning")}, - {'w', QLatin1String("wildcard")}, - {'w', QLatin1String("word")} - }; - make_literals = { - {'t', QLatin1String("true")}, - {'f', QLatin1String("false")}, - }; - make_builtin = { - }; - make_other = { - {'C', QLatin1String("CFLAGS")}, - {'L', QLatin1String("LIBS")}, - {'P', QLatin1String("PREFIX")}, - }; -} - -void loadMakeData(QMultiHash &types, QMultiHash &keywords, QMultiHash &builtin, QMultiHash &literals, QMultiHash &other) -{ - if (!makeDataInitialized) { - initMakeData(); - makeDataInitialized = true; - } - types = make_types; - keywords = make_keywords; - builtin = make_builtin; - literals = make_literals; - other = make_other; -} - -void loadAsmData(QMultiHash& types, QMultiHash& keywords, QMultiHash& builtin, QMultiHash& literals, QMultiHash& other) -{ - Q_UNUSED(literals); - types = { - { 'i', QLatin1String("ip") }, - { 'e', QLatin1String("eip") }, - { 'r', QLatin1String("rip") }, - { 'a', QLatin1String("al") }, - { 'a', QLatin1String("ah") }, - { 'b', QLatin1String("bl") }, - { 'b', QLatin1String("bh") }, - { 'c', QLatin1String("cl") }, - { 'c', QLatin1String("ch") }, - { 'd', QLatin1String("dl") }, - { 'd', QLatin1String("dh") }, - { 's', QLatin1String("sil") }, - { 'd', QLatin1String("dil") }, - { 'b', QLatin1String("bpl") }, - { 's', QLatin1String("spl") }, - { 'r', QLatin1String("r8b") }, - { 'r', QLatin1String("r9b") }, - { 'r', QLatin1String("r10b") }, - { 'r', QLatin1String("r11b") }, - { 'r', QLatin1String("r12b") }, - { 'r', QLatin1String("r13b") }, - { 'r', QLatin1String("r14b") }, - { 'r', QLatin1String("r15b") }, - { 'b', QLatin1String("bx") }, - { 'c', QLatin1String("cx") }, - { 'd', QLatin1String("dx") }, - { 's', QLatin1String("si") }, - { 'd', QLatin1String("di") }, - { 'b', QLatin1String("bp") }, - { 's', QLatin1String("sp") }, - { 'r', QLatin1String("r8w") }, - { 'r', QLatin1String("r9w") }, - { 'r', QLatin1String("r10w") }, - { 'r', QLatin1String("r11w") }, - { 'r', QLatin1String("r12w") }, - { 'r', QLatin1String("r13w") }, - { 'r', QLatin1String("r14w") }, - { 'r', QLatin1String("r15w") }, - { 'e', QLatin1String("eax") }, - { 'e', QLatin1String("ebx") }, - { 'e', QLatin1String("ecx") }, - { 'e', QLatin1String("edx") }, - { 'e', QLatin1String("esi") }, - { 'e', QLatin1String("edi") }, - { 'e', QLatin1String("ebp") }, - { 'e', QLatin1String("esp") }, - { 'e', QLatin1String("eip") }, - { 'r', QLatin1String("r8d") }, - { 'r', QLatin1String("r9d") }, - { 'r', QLatin1String("r10d") }, - { 'r', QLatin1String("r11d") }, - { 'r', QLatin1String("r12d") }, - { 'r', QLatin1String("r13d") }, - { 'r', QLatin1String("r14d") }, - { 'r', QLatin1String("r15d") }, - { 'r', QLatin1String("rax") }, - { 'r', QLatin1String("rbx") }, - { 'r', QLatin1String("rcx") }, - { 'r', QLatin1String("rdx") }, - { 'r', QLatin1String("rsi") }, - { 'r', QLatin1String("rdi") }, - { 'r', QLatin1String("rbp") }, - { 'r', QLatin1String("rsp") }, - { 'r', QLatin1String("r8") }, - { 'r', QLatin1String("r9") }, - { 'r', QLatin1String("r10") }, - { 'r', QLatin1String("r11") }, - { 'r', QLatin1String("r12") }, - { 'r', QLatin1String("r13") }, - { 'r', QLatin1String("r14") }, - { 'r', QLatin1String("r15") }, - { 'd', QLatin1String("ds") }, - { 'e', QLatin1String("es") }, - { 'f', QLatin1String("fs") }, - { 'g', QLatin1String("gs") }, - { 's', QLatin1String("ss") }, - { 's', QLatin1String("st0") }, - { 's', QLatin1String("st1") }, - { 's', QLatin1String("st2") }, - { 's', QLatin1String("st3") }, - { 's', QLatin1String("st4") }, - { 's', QLatin1String("st5") }, - { 's', QLatin1String("st6") }, - { 's', QLatin1String("st7") }, - { 'm', QLatin1String("mm0") }, - { 'm', QLatin1String("mm1") }, - { 'm', QLatin1String("mm2") }, - { 'm', QLatin1String("mm3") }, - { 'm', QLatin1String("mm4") }, - { 'm', QLatin1String("mm5") }, - { 'm', QLatin1String("mm6") }, - { 'm', QLatin1String("mm7") }, - { 'x', QLatin1String("xmm0") }, - { 'x', QLatin1String("xmm1") }, - { 'x', QLatin1String("xmm2") }, - { 'x', QLatin1String("xmm3") }, - { 'x', QLatin1String("xmm4") }, - { 'x', QLatin1String("xmm5") }, - { 'x', QLatin1String("xmm6") }, - { 'x', QLatin1String("xmm7") }, - { 'x', QLatin1String("xmm8") }, - { 'x', QLatin1String("xmm9") }, - { 'x', QLatin1String("xmm10") }, - { 'x', QLatin1String("xmm11") }, - { 'x', QLatin1String("xmm12") }, - { 'x', QLatin1String("xmm13") }, - { 'x', QLatin1String("xmm14") }, - { 'x', QLatin1String("xmm15") }, - { 'x', QLatin1String("xmm16") }, - { 'x', QLatin1String("xmm17") }, - { 'x', QLatin1String("xmm18") }, - { 'x', QLatin1String("xmm19") }, - { 'x', QLatin1String("xmm20") }, - { 'x', QLatin1String("xmm21") }, - { 'x', QLatin1String("xmm22") }, - { 'x', QLatin1String("xmm23") }, - { 'x', QLatin1String("xmm24") }, - { 'x', QLatin1String("xmm25") }, - { 'x', QLatin1String("xmm26") }, - { 'x', QLatin1String("xmm27") }, - { 'x', QLatin1String("xmm28") }, - { 'x', QLatin1String("xmm29") }, - { 'x', QLatin1String("xmm30") }, - { 'x', QLatin1String("xmm31") }, - { 'y', QLatin1String("ymm0") }, - { 'y', QLatin1String("ymm1") }, - { 'y', QLatin1String("ymm2") }, - { 'y', QLatin1String("ymm3") }, - { 'y', QLatin1String("ymm4") }, - { 'y', QLatin1String("ymm5") }, - { 'y', QLatin1String("ymm6") }, - { 'y', QLatin1String("ymm7") }, - { 'y', QLatin1String("ymm8") }, - { 'y', QLatin1String("ymm9") }, - { 'y', QLatin1String("ymm10") }, - { 'y', QLatin1String("ymm11") }, - { 'y', QLatin1String("ymm12") }, - { 'y', QLatin1String("ymm13") }, - { 'y', QLatin1String("ymm14") }, - { 'y', QLatin1String("ymm15") }, - { 'y', QLatin1String("ymm16") }, - { 'y', QLatin1String("ymm17") }, - { 'y', QLatin1String("ymm18") }, - { 'y', QLatin1String("ymm19") }, - { 'y', QLatin1String("ymm20") }, - { 'y', QLatin1String("ymm21") }, - { 'y', QLatin1String("ymm22") }, - { 'y', QLatin1String("ymm23") }, - { 'y', QLatin1String("ymm24") }, - { 'y', QLatin1String("ymm25") }, - { 'y', QLatin1String("ymm26") }, - { 'y', QLatin1String("ymm27") }, - { 'y', QLatin1String("ymm28") }, - { 'y', QLatin1String("ymm29") }, - { 'y', QLatin1String("ymm30") }, - { 'y', QLatin1String("ymm31") }, - { 'z', QLatin1String("zmm0") }, - { 'z', QLatin1String("zmm1") }, - { 'z', QLatin1String("zmm2") }, - { 'z', QLatin1String("zmm3") }, - { 'z', QLatin1String("zmm4") }, - { 'z', QLatin1String("zmm5") }, - { 'z', QLatin1String("zmm6") }, - { 'z', QLatin1String("zmm7") }, - { 'z', QLatin1String("zmm8") }, - { 'z', QLatin1String("zmm9") }, - { 'z', QLatin1String("zmm10") }, - { 'z', QLatin1String("zmm11") }, - { 'z', QLatin1String("zmm12") }, - { 'z', QLatin1String("zmm13") }, - { 'z', QLatin1String("zmm14") }, - { 'z', QLatin1String("zmm15") }, - { 'z', QLatin1String("zmm16") }, - { 'z', QLatin1String("zmm17") }, - { 'z', QLatin1String("zmm18") }, - { 'z', QLatin1String("zmm19") }, - { 'z', QLatin1String("zmm20") }, - { 'z', QLatin1String("zmm21") }, - { 'z', QLatin1String("zmm22") }, - { 'z', QLatin1String("zmm23") }, - { 'z', QLatin1String("zmm24") }, - { 'z', QLatin1String("zmm25") }, - { 'z', QLatin1String("zmm26") }, - { 'z', QLatin1String("zmm27") }, - { 'z', QLatin1String("zmm28") }, - { 'z', QLatin1String("zmm29") }, - { 'z', QLatin1String("zmm30") }, - { 'z', QLatin1String("zmm31") }, - { 'k', QLatin1String("k0") }, - { 'k', QLatin1String("k1") }, - { 'k', QLatin1String("k2") }, - { 'k', QLatin1String("k3") }, - { 'k', QLatin1String("k4") }, - { 'k', QLatin1String("k5") }, - { 'k', QLatin1String("k6") }, - { 'k', QLatin1String("k7") }, - { 'b', QLatin1String("bnd0") }, - { 'b', QLatin1String("bnd1") }, - { 'b', QLatin1String("bnd2") }, - { 'b', QLatin1String("bnd3") }, - { 'c', QLatin1String("cr0") }, - { 'c', QLatin1String("cr1") }, - { 'c', QLatin1String("cr2") }, - { 'c', QLatin1String("cr3") }, - { 'c', QLatin1String("cr4") }, - { 'c', QLatin1String("cr8") }, - { 'd', QLatin1String("dr0") }, - { 'd', QLatin1String("dr1") }, - { 'd', QLatin1String("dr2") }, - { 'd', QLatin1String("dr3") }, - { 'd', QLatin1String("dr8") }, - { 't', QLatin1String("tr3") }, - { 't', QLatin1String("tr4") }, - { 't', QLatin1String("tr5") }, - { 't', QLatin1String("tr6") }, - { 't', QLatin1String("tr7") }, - { 'r', QLatin1String("r0") }, - { 'r', QLatin1String("r1") }, - { 'r', QLatin1String("r2") }, - { 'r', QLatin1String("r3") }, - { 'r', QLatin1String("r4") }, - { 'r', QLatin1String("r5") }, - { 'r', QLatin1String("r6") }, - { 'r', QLatin1String("r7") }, - { 'r', QLatin1String("r0b") }, - { 'r', QLatin1String("r1b") }, - { 'r', QLatin1String("r2b") }, - { 'r', QLatin1String("r3b") }, - { 'r', QLatin1String("r4b") }, - { 'r', QLatin1String("r5b") }, - { 'r', QLatin1String("r6b") }, - { 'r', QLatin1String("r7b") }, - { 'r', QLatin1String("r0w") }, - { 'r', QLatin1String("r1w") }, - { 'r', QLatin1String("r2w") }, - { 'r', QLatin1String("r3w") }, - { 'r', QLatin1String("r4w") }, - { 'r', QLatin1String("r5w") }, - { 'r', QLatin1String("r6w") }, - { 'r', QLatin1String("r7w") }, - { 'r', QLatin1String("r0d") }, - { 'r', QLatin1String("r1d") }, - { 'r', QLatin1String("r2d") }, - { 'r', QLatin1String("r3d") }, - { 'r', QLatin1String("r4d") }, - { 'r', QLatin1String("r5d") }, - { 'r', QLatin1String("r6d") }, - { 'r', QLatin1String("r7d") }, - { 'r', QLatin1String("r0h") }, - { 'r', QLatin1String("r1h") }, - { 'r', QLatin1String("r2h") }, - { 'r', QLatin1String("r3h") }, - { 'r', QLatin1String("r0l") }, - { 'r', QLatin1String("r1l") }, - { 'r', QLatin1String("r2l") }, - { 'r', QLatin1String("r3l") }, - { 'r', QLatin1String("r4l") }, - { 'r', QLatin1String("r5l") }, - { 'r', QLatin1String("r6l") }, - { 'r', QLatin1String("r7l") }, - { 'r', QLatin1String("r8l") }, - { 'r', QLatin1String("r9l") }, - { 'r', QLatin1String("r10l") }, - { 'r', QLatin1String("r11l") }, - { 'r', QLatin1String("r12l") }, - { 'r', QLatin1String("r13l") }, - { 'r', QLatin1String("r14l") }, - { 'r', QLatin1String("r15l") }, - { 'd', QLatin1String("db") }, - { 'd', QLatin1String("dw") }, - { 'd', QLatin1String("dd") }, - { 'd', QLatin1String("dq") }, - { 'd', QLatin1String("dt") }, - { 'd', QLatin1String("ddq") }, - { 'd', QLatin1String("do") }, - { 'd', QLatin1String("dy") }, - { 'd', QLatin1String("dz") }, - { 'r', QLatin1String("resb") }, - { 'r', QLatin1String("resw") }, - { 'r', QLatin1String("resd") }, - { 'r', QLatin1String("resq") }, - { 'r', QLatin1String("rest") }, - { 'r', QLatin1String("resdq") }, - { 'r', QLatin1String("reso") }, - { 'r', QLatin1String("resy") }, - { 'r', QLatin1String("resz") }, - { 'i', QLatin1String("inc") }, - { 'b', QLatin1String("bin") }, - { 'e', QLatin1String("equ") }, - { 't', QLatin1String("times") }, - { 'b', QLatin1String("byte") }, - { 'w', QLatin1String("word") }, - { 'd', QLatin1String("dword") }, - { 'q', QLatin1String("qword") }, - { 'n', QLatin1String("nosplit") }, - { 'r', QLatin1String("rel") }, - { 'a', QLatin1String("abs") }, - { 's', QLatin1String("seg") }, - { 'w', QLatin1String("wrt") }, - { 's', QLatin1String("strict") }, - { 'n', QLatin1String("near") }, - { 'f', QLatin1String("far") }, - { 'a', QLatin1String("a32") }, - { 'p', QLatin1String("ptr") } - }; - - keywords = { - { 'l', QLatin1String("lock") }, - { 'r', QLatin1String("rep") }, - { 'r', QLatin1String("repe") }, - { 'r', QLatin1String("repz") }, - { 'r', QLatin1String("repne") }, - { 'r', QLatin1String("repnz") }, - { 'x', QLatin1String("xaquire") }, - { 'x', QLatin1String("xrelease") }, - { 'b', QLatin1String("bnd") }, - { 'n', QLatin1String("nobnd") }, - { 'a', QLatin1String("aaa") }, - { 'a', QLatin1String("aad") }, - { 'a', QLatin1String("aam") }, - { 'a', QLatin1String("aas") }, - { 'a', QLatin1String("adc") }, - { 'a', QLatin1String("add") }, - { 'a', QLatin1String("addl") }, - { 'a', QLatin1String("and") }, - { 'a', QLatin1String("arpl") }, - { 'b', QLatin1String("bb0_reset") }, - { 'b', QLatin1String("bb1_reset") }, - { 'b', QLatin1String("bound") }, - { 'b', QLatin1String("bsf") }, - { 'b', QLatin1String("bsr") }, - { 'b', QLatin1String("bswap") }, - { 'b', QLatin1String("bt") }, - { 'b', QLatin1String("btc") }, - { 'b', QLatin1String("btr") }, - { 'b', QLatin1String("bts") }, - { 'c', QLatin1String("call") }, - { 'c', QLatin1String("cbw") }, - { 'c', QLatin1String("cdq") }, - { 'c', QLatin1String("cdqe") }, - { 'c', QLatin1String("clc") }, - { 'c', QLatin1String("cld") }, - { 'c', QLatin1String("cli") }, - { 'c', QLatin1String("clts") }, - { 'c', QLatin1String("cltd") }, - { 'c', QLatin1String("cmc") }, - { 'c', QLatin1String("cmp") }, - { 'c', QLatin1String("cmpl") }, - { 'c', QLatin1String("cmpsb") }, - { 'c', QLatin1String("cmpsd") }, - { 'c', QLatin1String("cmpsq") }, - { 'c', QLatin1String("cmpsw") }, - { 'c', QLatin1String("cmpxchg") }, - { 'c', QLatin1String("cmpxchg486") }, - { 'c', QLatin1String("cmpxchg8b") }, - { 'c', QLatin1String("cmpxchg16b") }, - { 'c', QLatin1String("cpuid") }, - { 'c', QLatin1String("cpu_read") }, - { 'c', QLatin1String("cpu_write") }, - { 'c', QLatin1String("cqo") }, - { 'c', QLatin1String("cwd") }, - { 'c', QLatin1String("cwde") }, - { 'd', QLatin1String("daa") }, - { 'd', QLatin1String("das") }, - { 'd', QLatin1String("dec") }, - { 'd', QLatin1String("div") }, - { 'd', QLatin1String("dmint") }, - { 'e', QLatin1String("emms") }, - { 'e', QLatin1String("enter") }, - { 'e', QLatin1String("equ") }, - { 'f', QLatin1String("f2xm1") }, - { 'f', QLatin1String("fabs") }, - { 'f', QLatin1String("fadd") }, - { 'f', QLatin1String("faddp") }, - { 'f', QLatin1String("fbld") }, - { 'f', QLatin1String("fbstp") }, - { 'f', QLatin1String("fchs") }, - { 'f', QLatin1String("fclex") }, - { 'f', QLatin1String("fcmovb") }, - { 'f', QLatin1String("fcmovbe") }, - { 'f', QLatin1String("fcmove") }, - { 'f', QLatin1String("fcmovnb") }, - { 'f', QLatin1String("fcmovnbe") }, - { 'f', QLatin1String("fcmovne") }, - { 'f', QLatin1String("fcmovnu") }, - { 'f', QLatin1String("fcmovu") }, - { 'f', QLatin1String("fcom") }, - { 'f', QLatin1String("fcomi") }, - { 'f', QLatin1String("fcomip") }, - { 'f', QLatin1String("fcomp") }, - { 'f', QLatin1String("fcompp") }, - { 'f', QLatin1String("fcos") }, - { 'f', QLatin1String("fdecstp") }, - { 'f', QLatin1String("fdisi") }, - { 'f', QLatin1String("fdiv") }, - { 'f', QLatin1String("fdivp") }, - { 'f', QLatin1String("fdivr") }, - { 'f', QLatin1String("fdivrp") }, - { 'f', QLatin1String("femms") }, - { 'f', QLatin1String("feni") }, - { 'f', QLatin1String("ffree") }, - { 'f', QLatin1String("ffreep") }, - { 'f', QLatin1String("fiadd") }, - { 'f', QLatin1String("ficom") }, - { 'f', QLatin1String("ficomp") }, - { 'f', QLatin1String("fidiv") }, - { 'f', QLatin1String("fidivr") }, - { 'f', QLatin1String("fild") }, - { 'f', QLatin1String("fimul") }, - { 'f', QLatin1String("fincstp") }, - { 'f', QLatin1String("finit") }, - { 'f', QLatin1String("fist") }, - { 'f', QLatin1String("fistp") }, - { 'f', QLatin1String("fisttp") }, - { 'f', QLatin1String("fisub") }, - { 'f', QLatin1String("fisubr") }, - { 'f', QLatin1String("fld") }, - { 'f', QLatin1String("fld1") }, - { 'f', QLatin1String("fldcw") }, - { 'f', QLatin1String("fldenv") }, - { 'f', QLatin1String("fldl2e") }, - { 'f', QLatin1String("fldl2t") }, - { 'f', QLatin1String("fldlg2") }, - { 'f', QLatin1String("fldln2") }, - { 'f', QLatin1String("fldpi") }, - { 'f', QLatin1String("fldz") }, - { 'f', QLatin1String("fmul") }, - { 'f', QLatin1String("fmulp") }, - { 'f', QLatin1String("fnclex") }, - { 'f', QLatin1String("fndisi") }, - { 'f', QLatin1String("fneni") }, - { 'f', QLatin1String("fninit") }, - { 'f', QLatin1String("fnop") }, - { 'f', QLatin1String("fnsave") }, - { 'f', QLatin1String("fnstcw") }, - { 'f', QLatin1String("fnstenv") }, - { 'f', QLatin1String("fnstsw") }, - { 'f', QLatin1String("fpatan") }, - { 'f', QLatin1String("fprem") }, - { 'f', QLatin1String("fprem1") }, - { 'f', QLatin1String("fptan") }, - { 'f', QLatin1String("frndint") }, - { 'f', QLatin1String("frstor") }, - { 'f', QLatin1String("fsave") }, - { 'f', QLatin1String("fscale") }, - { 'f', QLatin1String("fsetpm") }, - { 'f', QLatin1String("fsin") }, - { 'f', QLatin1String("fsincos") }, - { 'f', QLatin1String("fsqrt") }, - { 'f', QLatin1String("fst") }, - { 'f', QLatin1String("fstcw") }, - { 'f', QLatin1String("fstenv") }, - { 'f', QLatin1String("fstp") }, - { 'f', QLatin1String("fstsw") }, - { 'f', QLatin1String("fsub") }, - { 'f', QLatin1String("fsubp") }, - { 'f', QLatin1String("fsubr") }, - { 'f', QLatin1String("fsubrp") }, - { 'f', QLatin1String("ftst") }, - { 'f', QLatin1String("fucom") }, - { 'f', QLatin1String("fucomi") }, - { 'f', QLatin1String("fucomip") }, - { 'f', QLatin1String("fucomp") }, - { 'f', QLatin1String("fucompp") }, - { 'f', QLatin1String("fxam") }, - { 'f', QLatin1String("fxch") }, - { 'f', QLatin1String("fxtract") }, - { 'f', QLatin1String("fyl2x") }, - { 'f', QLatin1String("fyl2xp1") }, - { 'g', QLatin1String("global") }, - { 'g', QLatin1String("globl") }, - { 'h', QLatin1String("hlt") }, - { 'i', QLatin1String("ibts") }, - { 'i', QLatin1String("icebp") }, - { 'i', QLatin1String("idiv") }, - { 'i', QLatin1String("idivl") }, - { 'i', QLatin1String("idivq") }, - { 'i', QLatin1String("imul") }, - { 'i', QLatin1String("imull") }, - { 'i', QLatin1String("imulq") }, - { 'i', QLatin1String("in") }, - { 'i', QLatin1String("inc") }, - { 'i', QLatin1String("incbin") }, - { 'i', QLatin1String("insb") }, - { 'i', QLatin1String("insd") }, - { 'i', QLatin1String("insw") }, - { 'i', QLatin1String("int") }, - { 'i', QLatin1String("int01") }, - { 'i', QLatin1String("int1") }, - { 'i', QLatin1String("int03") }, - { 'i', QLatin1String("int3") }, - { 'i', QLatin1String("into") }, - { 'i', QLatin1String("invd") }, - { 'i', QLatin1String("invpcid") }, - { 'i', QLatin1String("invlpg") }, - { 'i', QLatin1String("invlpga") }, - { 'i', QLatin1String("iret") }, - { 'i', QLatin1String("iretd") }, - { 'i', QLatin1String("iretq") }, - { 'i', QLatin1String("iretw") }, - { 'j', QLatin1String("jcxz") }, - { 'j', QLatin1String("jecxz") }, - { 'j', QLatin1String("jrcxz") }, - { 'j', QLatin1String("jmp") }, - { 'j', QLatin1String("jmpe") }, - { 'l', QLatin1String("lahf") }, - { 'l', QLatin1String("lar") }, - { 'l', QLatin1String("lds") }, - { 'l', QLatin1String("lea") }, - { 'l', QLatin1String("leal") }, - { 'l', QLatin1String("leaq") }, - { 'l', QLatin1String("leave") }, - { 'l', QLatin1String("les") }, - { 'l', QLatin1String("lfence") }, - { 'l', QLatin1String("lfs") }, - { 'l', QLatin1String("lgdt") }, - { 'l', QLatin1String("lgs") }, - { 'l', QLatin1String("lidt") }, - { 'l', QLatin1String("lldt") }, - { 'l', QLatin1String("lmsw") }, - { 'l', QLatin1String("loadall") }, - { 'l', QLatin1String("loadall286") }, - { 'l', QLatin1String("lodsb") }, - { 'l', QLatin1String("lodsd") }, - { 'l', QLatin1String("lodsq") }, - { 'l', QLatin1String("lodsw") }, - { 'l', QLatin1String("loop") }, - { 'l', QLatin1String("loope") }, - { 'l', QLatin1String("loopne") }, - { 'l', QLatin1String("loopnz") }, - { 'l', QLatin1String("loopz") }, - { 'l', QLatin1String("lsl") }, - { 'l', QLatin1String("lss") }, - { 'l', QLatin1String("ltr") }, - { 'm', QLatin1String("mfence") }, - { 'm', QLatin1String("monitor") }, - { 'm', QLatin1String("mov") }, - { 'm', QLatin1String("movd") }, - { 'm', QLatin1String("movl") }, - { 'm', QLatin1String("movq") }, - { 'm', QLatin1String("movsb") }, - { 'm', QLatin1String("movsd") }, - { 'm', QLatin1String("movsq") }, - { 'm', QLatin1String("movsw") }, - { 'm', QLatin1String("movsx") }, - { 'm', QLatin1String("movsxd") }, - { 'm', QLatin1String("movzx") }, - { 'm', QLatin1String("mul") }, - { 'm', QLatin1String("mwait") }, - { 'n', QLatin1String("neg") }, - { 'n', QLatin1String("nop") }, - { 'n', QLatin1String("not") }, - { 'o', QLatin1String("or") }, - { 'o', QLatin1String("out") }, - { 'o', QLatin1String("outsb") }, - { 'o', QLatin1String("outsd") }, - { 'o', QLatin1String("outsw") }, - { 'p', QLatin1String("packssdw") }, - { 'p', QLatin1String("packsswb") }, - { 'p', QLatin1String("packuswb") }, - { 'p', QLatin1String("paddb") }, - { 'p', QLatin1String("paddd") }, - { 'p', QLatin1String("paddsb") }, - { 'p', QLatin1String("paddsiw") }, - { 'p', QLatin1String("paddsw") }, - { 'p', QLatin1String("paddusb") }, - { 'p', QLatin1String("paddusw") }, - { 'p', QLatin1String("paddw") }, - { 'p', QLatin1String("pand") }, - { 'p', QLatin1String("pandn") }, - { 'p', QLatin1String("pause") }, - { 'p', QLatin1String("paveb") }, - { 'p', QLatin1String("pavgusb") }, - { 'p', QLatin1String("pcmpeqb") }, - { 'p', QLatin1String("pcmpeqd") }, - { 'p', QLatin1String("pcmpeqw") }, - { 'p', QLatin1String("pcmpgtb") }, - { 'p', QLatin1String("pcmpgtd") }, - { 'p', QLatin1String("pcmpgtw") }, - { 'p', QLatin1String("pdistib") }, - { 'p', QLatin1String("pf2id") }, - { 'p', QLatin1String("pfacc") }, - { 'p', QLatin1String("pfadd") }, - { 'p', QLatin1String("pfcmpeq") }, - { 'p', QLatin1String("pfcmpge") }, - { 'p', QLatin1String("pfcmpgt") }, - { 'p', QLatin1String("pfmax") }, - { 'p', QLatin1String("pfmin") }, - { 'p', QLatin1String("pfmul") }, - { 'p', QLatin1String("pfrcp") }, - { 'p', QLatin1String("pfrcpit1") }, - { 'p', QLatin1String("pfrcpit2") }, - { 'p', QLatin1String("pfrsqit1") }, - { 'p', QLatin1String("pfrsqrt") }, - { 'p', QLatin1String("pfsub") }, - { 'p', QLatin1String("pfsubr") }, - { 'p', QLatin1String("pi2fd") }, - { 'p', QLatin1String("pmachriw") }, - { 'p', QLatin1String("pmaddwd") }, - { 'p', QLatin1String("pmagw") }, - { 'p', QLatin1String("pmulhriw") }, - { 'p', QLatin1String("pmulhrwa") }, - { 'p', QLatin1String("pmulhrwc") }, - { 'p', QLatin1String("pmulhw") }, - { 'p', QLatin1String("pmullw") }, - { 'p', QLatin1String("pmvgezb") }, - { 'p', QLatin1String("pmvlzb") }, - { 'p', QLatin1String("pmvnzb") }, - { 'p', QLatin1String("pmvzb") }, - { 'p', QLatin1String("pop") }, - { 'p', QLatin1String("popq") }, - { 'p', QLatin1String("popa") }, - { 'p', QLatin1String("popad") }, - { 'p', QLatin1String("popaw") }, - { 'p', QLatin1String("popf") }, - { 'p', QLatin1String("popfd") }, - { 'p', QLatin1String("popfq") }, - { 'p', QLatin1String("popfw") }, - { 'p', QLatin1String("por") }, - { 'p', QLatin1String("prefetch") }, - { 'p', QLatin1String("prefetchw") }, - { 'p', QLatin1String("pslld") }, - { 'p', QLatin1String("psllq") }, - { 'p', QLatin1String("psllw") }, - { 'p', QLatin1String("psrad") }, - { 'p', QLatin1String("psraw") }, - { 'p', QLatin1String("psrld") }, - { 'p', QLatin1String("psrlq") }, - { 'p', QLatin1String("psrlw") }, - { 'p', QLatin1String("psubb") }, - { 'p', QLatin1String("psubd") }, - { 'p', QLatin1String("psubsb") }, - { 'p', QLatin1String("psubsiw") }, - { 'p', QLatin1String("psubsw") }, - { 'p', QLatin1String("psubusb") }, - { 'p', QLatin1String("psubusw") }, - { 'p', QLatin1String("psubw") }, - { 'p', QLatin1String("punpckhbw") }, - { 'p', QLatin1String("punpckhdq") }, - { 'p', QLatin1String("punpckhwd") }, - { 'p', QLatin1String("punpcklbw") }, - { 'p', QLatin1String("punpckldq") }, - { 'p', QLatin1String("punpcklwd") }, - { 'p', QLatin1String("push") }, - { 'p', QLatin1String("pusha") }, - { 'p', QLatin1String("pushq") }, - { 'p', QLatin1String("pushad") }, - { 'p', QLatin1String("pushaw") }, - { 'p', QLatin1String("pushf") }, - { 'p', QLatin1String("pushfd") }, - { 'p', QLatin1String("pushfq") }, - { 'p', QLatin1String("pushfw") }, - { 'p', QLatin1String("pxor") }, - { 'r', QLatin1String("rcl") }, - { 'r', QLatin1String("rcr") }, - { 'r', QLatin1String("rdshr") }, - { 'r', QLatin1String("rdmsr") }, - { 'r', QLatin1String("rdpmc") }, - { 'r', QLatin1String("rdtsc") }, - { 'r', QLatin1String("rdtscp") }, - { 'r', QLatin1String("ret") }, - { 'r', QLatin1String("retf") }, - { 'r', QLatin1String("retn") }, - { 'r', QLatin1String("retq") }, - { 'r', QLatin1String("rol") }, - { 'r', QLatin1String("ror") }, - { 'r', QLatin1String("rdm") }, - { 'r', QLatin1String("rsdc") }, - { 'r', QLatin1String("rsldt") }, - { 'r', QLatin1String("rsm") }, - { 'r', QLatin1String("rsts") }, - { 's', QLatin1String("sahf") }, - { 's', QLatin1String("sal") }, - { 's', QLatin1String("sall") }, - { 's', QLatin1String("salq") }, - { 's', QLatin1String("salc") }, - { 's', QLatin1String("sar") }, - { 's', QLatin1String("sarl") }, - { 's', QLatin1String("sarq") }, - { 's', QLatin1String("sbb") }, - { 's', QLatin1String("scasb") }, - { 's', QLatin1String("scasd") }, - { 's', QLatin1String("scasq") }, - { 's', QLatin1String("scasw") }, - { 's', QLatin1String("sfence") }, - { 's', QLatin1String("sgdt") }, - { 's', QLatin1String("shl") }, - { 's', QLatin1String("shll") }, - { 's', QLatin1String("shllq") }, - { 's', QLatin1String("shld") }, - { 's', QLatin1String("shr") }, - { 's', QLatin1String("shrd") }, - { 's', QLatin1String("sidt") }, - { 's', QLatin1String("sldt") }, - { 's', QLatin1String("skinit") }, - { 's', QLatin1String("smi") }, - { 's', QLatin1String("smint") }, - { 's', QLatin1String("smintold") }, - { 's', QLatin1String("smsw") }, - { 's', QLatin1String("stc") }, - { 's', QLatin1String("std") }, - { 's', QLatin1String("sti") }, - { 's', QLatin1String("stosb") }, - { 's', QLatin1String("stosd") }, - { 's', QLatin1String("stosq") }, - { 's', QLatin1String("stosw") }, - { 's', QLatin1String("str") }, - { 's', QLatin1String("sub") }, - { 's', QLatin1String("svdc") }, - { 's', QLatin1String("svldt") }, - { 's', QLatin1String("svts") }, - { 's', QLatin1String("swapgs") }, - { 's', QLatin1String("syscall") }, - { 's', QLatin1String("sysenter") }, - { 's', QLatin1String("sysexit") }, - { 's', QLatin1String("sysret") }, - { 't', QLatin1String("test") }, - { 't', QLatin1String("testl") }, - { 't', QLatin1String("testq") }, - { 'u', QLatin1String("ud0") }, - { 'u', QLatin1String("ud1") }, - { 'u', QLatin1String("ud2b") }, - { 'u', QLatin1String("ud2") }, - { 'u', QLatin1String("ud2a") }, - { 'u', QLatin1String("umov") }, - { 'v', QLatin1String("verr") }, - { 'v', QLatin1String("verw") }, - { 'f', QLatin1String("fwait") }, - { 'w', QLatin1String("wbinvd") }, - { 'w', QLatin1String("wrshr") }, - { 'w', QLatin1String("wrmsr") }, - { 'x', QLatin1String("xadd") }, - { 'x', QLatin1String("xbts") }, - { 'x', QLatin1String("xchg") }, - { 'x', QLatin1String("xlatb") }, - { 'x', QLatin1String("xlat") }, - { 'x', QLatin1String("xor") }, - { 'c', QLatin1String("cmove") }, - { 'c', QLatin1String("cmovz") }, - { 'c', QLatin1String("cmovne") }, - { 'c', QLatin1String("cmovnz") }, - { 'c', QLatin1String("cmova") }, - { 'c', QLatin1String("cmovnbe") }, - { 'c', QLatin1String("cmovae") }, - { 'c', QLatin1String("cmovnb") }, - { 'c', QLatin1String("cmovb") }, - { 'c', QLatin1String("cmovnae") }, - { 'c', QLatin1String("cmovbe") }, - { 'c', QLatin1String("cmovna") }, - { 'c', QLatin1String("cmovg") }, - { 'c', QLatin1String("cmovnle") }, - { 'c', QLatin1String("cmovge") }, - { 'c', QLatin1String("cmovnl") }, - { 'c', QLatin1String("cmovl") }, - { 'c', QLatin1String("cmovnge") }, - { 'c', QLatin1String("cmovle") }, - { 'c', QLatin1String("cmovng") }, - { 'c', QLatin1String("cmovc") }, - { 'c', QLatin1String("cmovnc") }, - { 'c', QLatin1String("cmovo") }, - { 'c', QLatin1String("cmovno") }, - { 'c', QLatin1String("cmovs") }, - { 'c', QLatin1String("cmovns") }, - { 'c', QLatin1String("cmovp") }, - { 'c', QLatin1String("cmovpe") }, - { 'c', QLatin1String("cmovnp") }, - { 'c', QLatin1String("cmovpo") }, - { 'j', QLatin1String("je") }, - { 'j', QLatin1String("jz") }, - { 'j', QLatin1String("jne") }, - { 'j', QLatin1String("jnz") }, - { 'j', QLatin1String("ja") }, - { 'j', QLatin1String("jnbe") }, - { 'j', QLatin1String("jae") }, - { 'j', QLatin1String("jnb") }, - { 'j', QLatin1String("jb") }, - { 'j', QLatin1String("jnae") }, - { 'j', QLatin1String("jbe") }, - { 'j', QLatin1String("jna") }, - { 'j', QLatin1String("jg") }, - { 'j', QLatin1String("jnle") }, - { 'j', QLatin1String("jge") }, - { 'j', QLatin1String("jnl") }, - { 'j', QLatin1String("jl") }, - { 'j', QLatin1String("jnge") }, - { 'j', QLatin1String("jle") }, - { 'j', QLatin1String("jng") }, - { 'j', QLatin1String("jc") }, - { 'j', QLatin1String("jnc") }, - { 'j', QLatin1String("jo") }, - { 'j', QLatin1String("jno") }, - { 'j', QLatin1String("js") }, - { 'j', QLatin1String("jns") }, - { 'j', QLatin1String("jpo") }, - { 'j', QLatin1String("jnp") }, - { 'j', QLatin1String("jpe") }, - { 'j', QLatin1String("jp") }, - { 's', QLatin1String("sete") }, - { 's', QLatin1String("setz") }, - { 's', QLatin1String("setne") }, - { 's', QLatin1String("setnz") }, - { 's', QLatin1String("seta") }, - { 's', QLatin1String("setnbe") }, - { 's', QLatin1String("setae") }, - { 's', QLatin1String("setnb") }, - { 's', QLatin1String("setnc") }, - { 's', QLatin1String("setb") }, - { 's', QLatin1String("setnae") }, - { 's', QLatin1String("setcset") }, - { 's', QLatin1String("setbe") }, - { 's', QLatin1String("setna") }, - { 's', QLatin1String("setg") }, - { 's', QLatin1String("setnle") }, - { 's', QLatin1String("setge") }, - { 's', QLatin1String("setnl") }, - { 's', QLatin1String("setl") }, - { 's', QLatin1String("setnge") }, - { 's', QLatin1String("setle") }, - { 's', QLatin1String("setng") }, - { 's', QLatin1String("sets") }, - { 's', QLatin1String("setns") }, - { 's', QLatin1String("seto") }, - { 's', QLatin1String("setno") }, - { 's', QLatin1String("setpe") }, - { 's', QLatin1String("setp") }, - { 's', QLatin1String("setpo") }, - { 's', QLatin1String("setnp") }, - { 'a', QLatin1String("addps") }, - { 'a', QLatin1String("addss") }, - { 'a', QLatin1String("andnps") }, - { 'a', QLatin1String("andps") }, - { 'c', QLatin1String("cmpeqps") }, - { 'c', QLatin1String("cmpeqss") }, - { 'c', QLatin1String("cmpleps") }, - { 'c', QLatin1String("cmpless") }, - { 'c', QLatin1String("cmpltps") }, - { 'c', QLatin1String("cmpltss") }, - { 'c', QLatin1String("cmpneqps") }, - { 'c', QLatin1String("cmpneqss") }, - { 'c', QLatin1String("cmpnleps") }, - { 'c', QLatin1String("cmpnless") }, - { 'c', QLatin1String("cmpnltps") }, - { 'c', QLatin1String("cmpnltss") }, - { 'c', QLatin1String("cmpordps") }, - { 'c', QLatin1String("cmpordss") }, - { 'c', QLatin1String("cmpunordps") }, - { 'c', QLatin1String("cmpunordss") }, - { 'c', QLatin1String("cmpps") }, - { 'c', QLatin1String("cmpss") }, - { 'c', QLatin1String("comiss") }, - { 'c', QLatin1String("cvtpi2ps") }, - { 'c', QLatin1String("cvtps2pi") }, - { 'c', QLatin1String("cvtsi2ss") }, - { 'c', QLatin1String("cvtss2si") }, - { 'c', QLatin1String("cvttps2pi") }, - { 'c', QLatin1String("cvttss2si") }, - { 'd', QLatin1String("divps") }, - { 'd', QLatin1String("divss") }, - { 'l', QLatin1String("ldmxcsr") }, - { 'm', QLatin1String("maxps") }, - { 'm', QLatin1String("maxss") }, - { 'm', QLatin1String("minps") }, - { 'm', QLatin1String("minss") }, - { 'm', QLatin1String("movaps") }, - { 'm', QLatin1String("movhps") }, - { 'm', QLatin1String("movlhps") }, - { 'm', QLatin1String("movlps") }, - { 'm', QLatin1String("movhlps") }, - { 'm', QLatin1String("movmskps") }, - { 'm', QLatin1String("movntps") }, - { 'm', QLatin1String("movss") }, - { 'm', QLatin1String("movups") }, - { 'm', QLatin1String("mulps") }, - { 'm', QLatin1String("mulss") }, - { 'o', QLatin1String("orps") }, - { 'r', QLatin1String("rcpps") }, - { 'r', QLatin1String("rcpss") }, - { 'r', QLatin1String("rsqrtps") }, - { 'r', QLatin1String("rsqrtss") }, - { 's', QLatin1String("shufps") }, - { 's', QLatin1String("sqrtps") }, - { 's', QLatin1String("sqrtss") }, - { 's', QLatin1String("stmxcsr") }, - { 's', QLatin1String("subps") }, - { 's', QLatin1String("subss") }, - { 'u', QLatin1String("ucomiss") }, - { 'u', QLatin1String("unpckhps") }, - { 'u', QLatin1String("unpcklps") }, - { 'x', QLatin1String("xorps") }, - { 'f', QLatin1String("fxrstor") }, - { 'f', QLatin1String("fxrstor64") }, - { 'f', QLatin1String("fxsave") }, - { 'f', QLatin1String("fxsave64") }, - { 'x', QLatin1String("xgetbv") }, - { 'x', QLatin1String("xsetbv") }, - { 'x', QLatin1String("xsave") }, - { 'x', QLatin1String("xsave64") }, - { 'x', QLatin1String("xsaveopt") }, - { 'x', QLatin1String("xsaveopt64") }, - { 'x', QLatin1String("xrstor") }, - { 'x', QLatin1String("xrstor64") }, - { 'p', QLatin1String("prefetchnta") }, - { 'p', QLatin1String("prefetcht0") }, - { 'p', QLatin1String("prefetcht1") }, - { 'p', QLatin1String("prefetcht2") }, - { 'm', QLatin1String("maskmovq") }, - { 'm', QLatin1String("movntq") }, - { 'p', QLatin1String("pavgb") }, - { 'p', QLatin1String("pavgw") }, - { 'p', QLatin1String("pextrw") }, - { 'p', QLatin1String("pinsrw") }, - { 'p', QLatin1String("pmaxsw") }, - { 'p', QLatin1String("pmaxub") }, - { 'p', QLatin1String("pminsw") }, - { 'p', QLatin1String("pminub") }, - { 'p', QLatin1String("pmovmskb") }, - { 'p', QLatin1String("pmulhuw") }, - { 'p', QLatin1String("psadbw") }, - { 'p', QLatin1String("pshufw") }, - { 'p', QLatin1String("pf2iw") }, - { 'p', QLatin1String("pfnacc") }, - { 'p', QLatin1String("pfpnacc") }, - { 'p', QLatin1String("pi2fw") }, - { 'p', QLatin1String("pswapd") }, - { 'm', QLatin1String("maskmovdqu") }, - { 'c', QLatin1String("clflush") }, - { 'm', QLatin1String("movntdq") }, - { 'm', QLatin1String("movnti") }, - { 'm', QLatin1String("movntpd") }, - { 'm', QLatin1String("movdqa") }, - { 'm', QLatin1String("movdqu") }, - { 'm', QLatin1String("movdq2q") }, - { 'm', QLatin1String("movq2dq") }, - { 'p', QLatin1String("paddq") }, - { 'p', QLatin1String("pmuludq") }, - { 'p', QLatin1String("pshufd") }, - { 'p', QLatin1String("pshufhw") }, - { 'p', QLatin1String("pshuflw") }, - { 'p', QLatin1String("pslldq") }, - { 'p', QLatin1String("psrldq") }, - { 'p', QLatin1String("psubq") }, - { 'p', QLatin1String("punpckhqdq") }, - { 'p', QLatin1String("punpcklqdq") }, - { 'a', QLatin1String("addpd") }, - { 'a', QLatin1String("addsd") }, - { 'a', QLatin1String("andnpd") }, - { 'a', QLatin1String("andpd") }, - { 'c', QLatin1String("cmpeqpd") }, - { 'c', QLatin1String("cmpeqsd") }, - { 'c', QLatin1String("cmplepd") }, - { 'c', QLatin1String("cmplesd") }, - { 'c', QLatin1String("cmpltpd") }, - { 'c', QLatin1String("cmpltsd") }, - { 'c', QLatin1String("cmpneqpd") }, - { 'c', QLatin1String("cmpneqsd") }, - { 'c', QLatin1String("cmpnlepd") }, - { 'c', QLatin1String("cmpnlesd") }, - { 'c', QLatin1String("cmpnltpd") }, - { 'c', QLatin1String("cmpnltsd") }, - { 'c', QLatin1String("cmpordpd") }, - { 'c', QLatin1String("cmpordsd") }, - { 'c', QLatin1String("cmpunordpd") }, - { 'c', QLatin1String("cmpunordsd") }, - { 'c', QLatin1String("cmppd") }, - { 'c', QLatin1String("comisd") }, - { 'c', QLatin1String("cvtdq2pd") }, - { 'c', QLatin1String("cvtdq2ps") }, - { 'c', QLatin1String("cvtpd2dq") }, - { 'c', QLatin1String("cvtpd2pi") }, - { 'c', QLatin1String("cvtpd2ps") }, - { 'c', QLatin1String("cvtpi2pd") }, - { 'c', QLatin1String("cvtps2dq") }, - { 'c', QLatin1String("cvtps2pd") }, - { 'c', QLatin1String("cvtsd2si") }, - { 'c', QLatin1String("cvtsd2ss") }, - { 'c', QLatin1String("cvtsi2sd") }, - { 'c', QLatin1String("cvtss2sd") }, - { 'c', QLatin1String("cvttpd2pi") }, - { 'c', QLatin1String("cvttpd2dq") }, - { 'c', QLatin1String("cvttps2dq") }, - { 'c', QLatin1String("cvttsd2si") }, - { 'd', QLatin1String("divpd") }, - { 'd', QLatin1String("divsd") }, - { 'm', QLatin1String("maxpd") }, - { 'm', QLatin1String("maxsd") }, - { 'm', QLatin1String("minpd") }, - { 'm', QLatin1String("minsd") }, - { 'm', QLatin1String("movapd") }, - { 'm', QLatin1String("movhpd") }, - { 'm', QLatin1String("movlpd") }, - { 'm', QLatin1String("movmskpd") }, - { 'm', QLatin1String("movupd") }, - { 'm', QLatin1String("mulpd") }, - { 'm', QLatin1String("mulsd") }, - { 'o', QLatin1String("orpd") }, - { 's', QLatin1String("shufpd") }, - { 's', QLatin1String("sqrtpd") }, - { 's', QLatin1String("sqrtsd") }, - { 's', QLatin1String("subpd") }, - { 's', QLatin1String("subsd") }, - { 'u', QLatin1String("ucomisd") }, - { 'u', QLatin1String("unpckhpd") }, - { 'u', QLatin1String("unpcklpd") }, - { 'x', QLatin1String("xorpd") }, - { 'a', QLatin1String("addsubpd") }, - { 'a', QLatin1String("addsubps") }, - { 'h', QLatin1String("haddpd") }, - { 'h', QLatin1String("haddps") }, - { 'h', QLatin1String("hsubpd") }, - { 'h', QLatin1String("hsubps") }, - { 'l', QLatin1String("lddqu") }, - { 'm', QLatin1String("movddup") }, - { 'm', QLatin1String("movshdup") }, - { 'm', QLatin1String("movsldup") }, - { 'c', QLatin1String("clgi") }, - { 's', QLatin1String("stgi") }, - { 'v', QLatin1String("vmcall") }, - { 'v', QLatin1String("vmclear") }, - { 'v', QLatin1String("vmfunc") }, - { 'v', QLatin1String("vmlaunch") }, - { 'v', QLatin1String("vmload") }, - { 'v', QLatin1String("vmmcall") }, - { 'v', QLatin1String("vmptrld") }, - { 'v', QLatin1String("vmptrst") }, - { 'v', QLatin1String("vmread") }, - { 'v', QLatin1String("vmresume") }, - { 'v', QLatin1String("vmrun") }, - { 'v', QLatin1String("vmsave") }, - { 'v', QLatin1String("vmwrite") }, - { 'v', QLatin1String("vmxoff") }, - { 'v', QLatin1String("vmxon") }, - { 'i', QLatin1String("invept") }, - { 'i', QLatin1String("invvpid") }, - { 'p', QLatin1String("pabsb") }, - { 'p', QLatin1String("pabsw") }, - { 'p', QLatin1String("pabsd") }, - { 'p', QLatin1String("palignr") }, - { 'p', QLatin1String("phaddw") }, - { 'p', QLatin1String("phaddd") }, - { 'p', QLatin1String("phaddsw") }, - { 'p', QLatin1String("phsubw") }, - { 'p', QLatin1String("phsubd") }, - { 'p', QLatin1String("phsubsw") }, - { 'p', QLatin1String("pmaddubsw") }, - { 'p', QLatin1String("pmulhrsw") }, - { 'p', QLatin1String("pshufb") }, - { 'p', QLatin1String("psignb") }, - { 'p', QLatin1String("psignw") }, - { 'p', QLatin1String("psignd") }, - { 'e', QLatin1String("extrq") }, - { 'i', QLatin1String("insertq") }, - { 'm', QLatin1String("movntsd") }, - { 'm', QLatin1String("movntss") }, - { 'l', QLatin1String("lzcnt") }, - { 'b', QLatin1String("blendpd") }, - { 'b', QLatin1String("blendps") }, - { 'b', QLatin1String("blendvpd") }, - { 'b', QLatin1String("blendvps") }, - { 'd', QLatin1String("dppd") }, - { 'd', QLatin1String("dpps") }, - { 'e', QLatin1String("extractps") }, - { 'i', QLatin1String("insertps") }, - { 'm', QLatin1String("movntdqa") }, - { 'm', QLatin1String("mpsadbw") }, - { 'p', QLatin1String("packusdw") }, - { 'p', QLatin1String("pblendvb") }, - { 'p', QLatin1String("pblendw") }, - { 'p', QLatin1String("pcmpeqq") }, - { 'p', QLatin1String("pextrb") }, - { 'p', QLatin1String("pextrd") }, - { 'p', QLatin1String("pextrq") }, - { 'p', QLatin1String("phminposuw") }, - { 'p', QLatin1String("pinsrb") }, - { 'p', QLatin1String("pinsrd") }, - { 'p', QLatin1String("pinsrq") }, - { 'p', QLatin1String("pmaxsb") }, - { 'p', QLatin1String("pmaxsd") }, - { 'p', QLatin1String("pmaxud") }, - { 'p', QLatin1String("pmaxuw") }, - { 'p', QLatin1String("pminsb") }, - { 'p', QLatin1String("pminsd") }, - { 'p', QLatin1String("pminud") }, - { 'p', QLatin1String("pminuw") }, - { 'p', QLatin1String("pmovsxbw") }, - { 'p', QLatin1String("pmovsxbd") }, - { 'p', QLatin1String("pmovsxbq") }, - { 'p', QLatin1String("pmovsxwd") }, - { 'p', QLatin1String("pmovsxwq") }, - { 'p', QLatin1String("pmovsxdq") }, - { 'p', QLatin1String("pmovzxbw") }, - { 'p', QLatin1String("pmovzxbd") }, - { 'p', QLatin1String("pmovzxbq") }, - { 'p', QLatin1String("pmovzxwd") }, - { 'p', QLatin1String("pmovzxwq") }, - { 'p', QLatin1String("pmovzxdq") }, - { 'p', QLatin1String("pmuldq") }, - { 'p', QLatin1String("pmulld") }, - { 'p', QLatin1String("ptest") }, - { 'r', QLatin1String("roundpd") }, - { 'r', QLatin1String("roundps") }, - { 'r', QLatin1String("roundsd") }, - { 'r', QLatin1String("roundss") }, - { 'c', QLatin1String("crc32") }, - { 'p', QLatin1String("pcmpestri") }, - { 'p', QLatin1String("pcmpestrm") }, - { 'p', QLatin1String("pcmpistri") }, - { 'p', QLatin1String("pcmpistrm") }, - { 'p', QLatin1String("pcmpgtq") }, - { 'p', QLatin1String("popcnt") }, - { 'g', QLatin1String("getsec") }, - { 'p', QLatin1String("pfrcpv") }, - { 'p', QLatin1String("pfrsqrtv") }, - { 'm', QLatin1String("movbe") }, - { 'a', QLatin1String("aesenc") }, - { 'a', QLatin1String("aesenclast") }, - { 'a', QLatin1String("aesdec") }, - { 'a', QLatin1String("aesdeclast") }, - { 'a', QLatin1String("aesimc") }, - { 'a', QLatin1String("aeskeygenassist") }, - { 'v', QLatin1String("vaesenc") }, - { 'v', QLatin1String("vaesenclast") }, - { 'v', QLatin1String("vaesdec") }, - { 'v', QLatin1String("vaesdeclast") }, - { 'v', QLatin1String("vaesimc") }, - { 'v', QLatin1String("vaeskeygenassist") }, - { 'v', QLatin1String("vaddpd") }, - { 'v', QLatin1String("vaddps") }, - { 'v', QLatin1String("vaddsd") }, - { 'v', QLatin1String("vaddss") }, - { 'v', QLatin1String("vaddsubpd") }, - { 'v', QLatin1String("vaddsubps") }, - { 'v', QLatin1String("vandpd") }, - { 'v', QLatin1String("vandps") }, - { 'v', QLatin1String("vandnpd") }, - { 'v', QLatin1String("vandnps") }, - { 'v', QLatin1String("vblendpd") }, - { 'v', QLatin1String("vblendps") }, - { 'v', QLatin1String("vblendvpd") }, - { 'v', QLatin1String("vblendvps") }, - { 'v', QLatin1String("vbroadcastss") }, - { 'v', QLatin1String("vbroadcastsd") }, - { 'v', QLatin1String("vbroadcastf128") }, - { 'v', QLatin1String("vcmpeq_ospd") }, - { 'v', QLatin1String("vcmpeqpd") }, - { 'v', QLatin1String("vcmplt_ospd") }, - { 'v', QLatin1String("vcmpltpd") }, - { 'v', QLatin1String("vcmple_ospd") }, - { 'v', QLatin1String("vcmplepd") }, - { 'v', QLatin1String("vcmpunord_qpd") }, - { 'v', QLatin1String("vcmpunordpd") }, - { 'v', QLatin1String("vcmpneq_uqpd") }, - { 'v', QLatin1String("vcmpneqpd") }, - { 'v', QLatin1String("vcmpnlt_uspd") }, - { 'v', QLatin1String("vcmpnltpd") }, - { 'v', QLatin1String("vcmpnle_uspd") }, - { 'v', QLatin1String("vcmpnlepd") }, - { 'v', QLatin1String("vcmpord_qpd") }, - { 'v', QLatin1String("vcmpordpd") }, - { 'v', QLatin1String("vcmpeq_uqpd") }, - { 'v', QLatin1String("vcmpnge_uspd") }, - { 'v', QLatin1String("vcmpngepd") }, - { 'v', QLatin1String("vcmpngt_uspd") }, - { 'v', QLatin1String("vcmpngtpd") }, - { 'v', QLatin1String("vcmpfalse_oqpd") }, - { 'v', QLatin1String("vcmpfalsepd") }, - { 'v', QLatin1String("vcmpneq_oqpd") }, - { 'v', QLatin1String("vcmpge_ospd") }, - { 'v', QLatin1String("vcmpgepd") }, - { 'v', QLatin1String("vcmpgt_ospd") }, - { 'v', QLatin1String("vcmpgtpd") }, - { 'v', QLatin1String("vcmptrue_uqpd") }, - { 'v', QLatin1String("vcmptruepd") }, - { 'v', QLatin1String("vcmplt_oqpd") }, - { 'v', QLatin1String("vcmple_oqpd") }, - { 'v', QLatin1String("vcmpunord_spd") }, - { 'v', QLatin1String("vcmpneq_uspd") }, - { 'v', QLatin1String("vcmpnlt_uqpd") }, - { 'v', QLatin1String("vcmpnle_uqpd") }, - { 'v', QLatin1String("vcmpord_spd") }, - { 'v', QLatin1String("vcmpeq_uspd") }, - { 'v', QLatin1String("vcmpnge_uqpd") }, - { 'v', QLatin1String("vcmpngt_uqpd") }, - { 'v', QLatin1String("vcmpfalse_ospd") }, - { 'v', QLatin1String("vcmpneq_ospd") }, - { 'v', QLatin1String("vcmpge_oqpd") }, - { 'v', QLatin1String("vcmpgt_oqpd") }, - { 'v', QLatin1String("vcmptrue_uspd") }, - { 'v', QLatin1String("vcmppd") }, - { 'v', QLatin1String("vcmpeq_osps") }, - { 'v', QLatin1String("vcmpeqps") }, - { 'v', QLatin1String("vcmplt_osps") }, - { 'v', QLatin1String("vcmpltps") }, - { 'v', QLatin1String("vcmple_osps") }, - { 'v', QLatin1String("vcmpleps") }, - { 'v', QLatin1String("vcmpunord_qps") }, - { 'v', QLatin1String("vcmpunordps") }, - { 'v', QLatin1String("vcmpneq_uqps") }, - { 'v', QLatin1String("vcmpneqps") }, - { 'v', QLatin1String("vcmpnlt_usps") }, - { 'v', QLatin1String("vcmpnltps") }, - { 'v', QLatin1String("vcmpnle_usps") }, - { 'v', QLatin1String("vcmpnleps") }, - { 'v', QLatin1String("vcmpord_qps") }, - { 'v', QLatin1String("vcmpordps") }, - { 'v', QLatin1String("vcmpeq_uqps") }, - { 'v', QLatin1String("vcmpnge_usps") }, - { 'v', QLatin1String("vcmpngeps") }, - { 'v', QLatin1String("vcmpngt_usps") }, - { 'v', QLatin1String("vcmpngtps") }, - { 'v', QLatin1String("vcmpfalse_oqps") }, - { 'v', QLatin1String("vcmpfalseps") }, - { 'v', QLatin1String("vcmpneq_oqps") }, - { 'v', QLatin1String("vcmpge_osps") }, - { 'v', QLatin1String("vcmpgeps") }, - { 'v', QLatin1String("vcmpgt_osps") }, - { 'v', QLatin1String("vcmpgtps") }, - { 'v', QLatin1String("vcmptrue_uqps") }, - { 'v', QLatin1String("vcmptrueps") }, - { 'v', QLatin1String("vcmplt_oqps") }, - { 'v', QLatin1String("vcmple_oqps") }, - { 'v', QLatin1String("vcmpunord_sps") }, - { 'v', QLatin1String("vcmpneq_usps") }, - { 'v', QLatin1String("vcmpnlt_uqps") }, - { 'v', QLatin1String("vcmpnle_uqps") }, - { 'v', QLatin1String("vcmpord_sps") }, - { 'v', QLatin1String("vcmpeq_usps") }, - { 'v', QLatin1String("vcmpnge_uqps") }, - { 'v', QLatin1String("vcmpngt_uqps") }, - { 'v', QLatin1String("vcmpfalse_osps") }, - { 'v', QLatin1String("vcmpneq_osps") }, - { 'v', QLatin1String("vcmpge_oqps") }, - { 'v', QLatin1String("vcmpgt_oqps") }, - { 'v', QLatin1String("vcmptrue_usps") }, - { 'v', QLatin1String("vcmpps") }, - { 'v', QLatin1String("vcmpeq_ossd") }, - { 'v', QLatin1String("vcmpeqsd") }, - { 'v', QLatin1String("vcmplt_ossd") }, - { 'v', QLatin1String("vcmpltsd") }, - { 'v', QLatin1String("vcmple_ossd") }, - { 'v', QLatin1String("vcmplesd") }, - { 'v', QLatin1String("vcmpunord_qsd") }, - { 'v', QLatin1String("vcmpunordsd") }, - { 'v', QLatin1String("vcmpneq_uqsd") }, - { 'v', QLatin1String("vcmpneqsd") }, - { 'v', QLatin1String("vcmpnlt_ussd") }, - { 'v', QLatin1String("vcmpnltsd") }, - { 'v', QLatin1String("vcmpnle_ussd") }, - { 'v', QLatin1String("vcmpnlesd") }, - { 'v', QLatin1String("vcmpord_qsd") }, - { 'v', QLatin1String("vcmpordsd") }, - { 'v', QLatin1String("vcmpeq_uqsd") }, - { 'v', QLatin1String("vcmpnge_ussd") }, - { 'v', QLatin1String("vcmpngesd") }, - { 'v', QLatin1String("vcmpngt_ussd") }, - { 'v', QLatin1String("vcmpngtsd") }, - { 'v', QLatin1String("vcmpfalse_oqsd") }, - { 'v', QLatin1String("vcmpfalsesd") }, - { 'v', QLatin1String("vcmpneq_oqsd") }, - { 'v', QLatin1String("vcmpge_ossd") }, - { 'v', QLatin1String("vcmpgesd") }, - { 'v', QLatin1String("vcmpgt_ossd") }, - { 'v', QLatin1String("vcmpgtsd") }, - { 'v', QLatin1String("vcmptrue_uqsd") }, - { 'v', QLatin1String("vcmptruesd") }, - { 'v', QLatin1String("vcmplt_oqsd") }, - { 'v', QLatin1String("vcmple_oqsd") }, - { 'v', QLatin1String("vcmpunord_ssd") }, - { 'v', QLatin1String("vcmpneq_ussd") }, - { 'v', QLatin1String("vcmpnlt_uqsd") }, - { 'v', QLatin1String("vcmpnle_uqsd") }, - { 'v', QLatin1String("vcmpord_ssd") }, - { 'v', QLatin1String("vcmpeq_ussd") }, - { 'v', QLatin1String("vcmpnge_uqsd") }, - { 'v', QLatin1String("vcmpngt_uqsd") }, - { 'v', QLatin1String("vcmpfalse_ossd") }, - { 'v', QLatin1String("vcmpneq_ossd") }, - { 'v', QLatin1String("vcmpge_oqsd") }, - { 'v', QLatin1String("vcmpgt_oqsd") }, - { 'v', QLatin1String("vcmptrue_ussd") }, - { 'v', QLatin1String("vcmpsd") }, - { 'v', QLatin1String("vcmpeq_osss") }, - { 'v', QLatin1String("vcmpeqss") }, - { 'v', QLatin1String("vcmplt_osss") }, - { 'v', QLatin1String("vcmpltss") }, - { 'v', QLatin1String("vcmple_osss") }, - { 'v', QLatin1String("vcmpless") }, - { 'v', QLatin1String("vcmpunord_qss") }, - { 'v', QLatin1String("vcmpunordss") }, - { 'v', QLatin1String("vcmpneq_uqss") }, - { 'v', QLatin1String("vcmpneqss") }, - { 'v', QLatin1String("vcmpnlt_usss") }, - { 'v', QLatin1String("vcmpnltss") }, - { 'v', QLatin1String("vcmpnle_usss") }, - { 'v', QLatin1String("vcmpnless") }, - { 'v', QLatin1String("vcmpord_qss") }, - { 'v', QLatin1String("vcmpordss") }, - { 'v', QLatin1String("vcmpeq_uqss") }, - { 'v', QLatin1String("vcmpnge_usss") }, - { 'v', QLatin1String("vcmpngess") }, - { 'v', QLatin1String("vcmpngt_usss") }, - { 'v', QLatin1String("vcmpngtss") }, - { 'v', QLatin1String("vcmpfalse_oqss") }, - { 'v', QLatin1String("vcmpfalsess") }, - { 'v', QLatin1String("vcmpneq_oqss") }, - { 'v', QLatin1String("vcmpge_osss") }, - { 'v', QLatin1String("vcmpgess") }, - { 'v', QLatin1String("vcmpgt_osss") }, - { 'v', QLatin1String("vcmpgtss") }, - { 'v', QLatin1String("vcmptrue_uqss") }, - { 'v', QLatin1String("vcmptruess") }, - { 'v', QLatin1String("vcmplt_oqss") }, - { 'v', QLatin1String("vcmple_oqss") }, - { 'v', QLatin1String("vcmpunord_sss") }, - { 'v', QLatin1String("vcmpneq_usss") }, - { 'v', QLatin1String("vcmpnlt_uqss") }, - { 'v', QLatin1String("vcmpnle_uqss") }, - { 'v', QLatin1String("vcmpord_sss") }, - { 'v', QLatin1String("vcmpeq_usss") }, - { 'v', QLatin1String("vcmpnge_uqss") }, - { 'v', QLatin1String("vcmpngt_uqss") }, - { 'v', QLatin1String("vcmpfalse_osss") }, - { 'v', QLatin1String("vcmpneq_osss") }, - { 'v', QLatin1String("vcmpge_oqss") }, - { 'v', QLatin1String("vcmpgt_oqss") }, - { 'v', QLatin1String("vcmptrue_usss") }, - { 'v', QLatin1String("vcmpss") }, - { 'v', QLatin1String("vcomisd") }, - { 'v', QLatin1String("vcomiss") }, - { 'v', QLatin1String("vcvtdq2pd") }, - { 'v', QLatin1String("vcvtdq2ps") }, - { 'v', QLatin1String("vcvtpd2dq") }, - { 'v', QLatin1String("vcvtpd2ps") }, - { 'v', QLatin1String("vcvtps2dq") }, - { 'v', QLatin1String("vcvtps2pd") }, - { 'v', QLatin1String("vcvtsd2si") }, - { 'v', QLatin1String("vcvtsd2ss") }, - { 'v', QLatin1String("vcvtsi2sd") }, - { 'v', QLatin1String("vcvtsi2ss") }, - { 'v', QLatin1String("vcvtss2sd") }, - { 'v', QLatin1String("vcvtss2si") }, - { 'v', QLatin1String("vcvttpd2dq") }, - { 'v', QLatin1String("vcvttps2dq") }, - { 'v', QLatin1String("vcvttsd2si") }, - { 'v', QLatin1String("vcvttss2si") }, - { 'v', QLatin1String("vdivpd") }, - { 'v', QLatin1String("vdivps") }, - { 'v', QLatin1String("vdivsd") }, - { 'v', QLatin1String("vdivss") }, - { 'v', QLatin1String("vdppd") }, - { 'v', QLatin1String("vdpps") }, - { 'v', QLatin1String("vextractf128") }, - { 'v', QLatin1String("vextractps") }, - { 'v', QLatin1String("vhaddpd") }, - { 'v', QLatin1String("vhaddps") }, - { 'v', QLatin1String("vhsubpd") }, - { 'v', QLatin1String("vhsubps") }, - { 'v', QLatin1String("vinsertf128") }, - { 'v', QLatin1String("vinsertps") }, - { 'v', QLatin1String("vlddqu") }, - { 'v', QLatin1String("vldqqu") }, - { 'v', QLatin1String("vldmxcsr") }, - { 'v', QLatin1String("vmaskmovdqu") }, - { 'v', QLatin1String("vmaskmovps") }, - { 'v', QLatin1String("vmaskmovpd") }, - { 'v', QLatin1String("vmaxpd") }, - { 'v', QLatin1String("vmaxps") }, - { 'v', QLatin1String("vmaxsd") }, - { 'v', QLatin1String("vmaxss") }, - { 'v', QLatin1String("vminpd") }, - { 'v', QLatin1String("vminps") }, - { 'v', QLatin1String("vminsd") }, - { 'v', QLatin1String("vminss") }, - { 'v', QLatin1String("vmovapd") }, - { 'v', QLatin1String("vmovaps") }, - { 'v', QLatin1String("vmovd") }, - { 'v', QLatin1String("vmovq") }, - { 'v', QLatin1String("vmovddup") }, - { 'v', QLatin1String("vmovdqa") }, - { 'v', QLatin1String("vmovqqa") }, - { 'v', QLatin1String("vmovdqu") }, - { 'v', QLatin1String("vmovqqu") }, - { 'v', QLatin1String("vmovhlps") }, - { 'v', QLatin1String("vmovhpd") }, - { 'v', QLatin1String("vmovhps") }, - { 'v', QLatin1String("vmovlhps") }, - { 'v', QLatin1String("vmovlpd") }, - { 'v', QLatin1String("vmovlps") }, - { 'v', QLatin1String("vmovmskpd") }, - { 'v', QLatin1String("vmovmskps") }, - { 'v', QLatin1String("vmovntdq") }, - { 'v', QLatin1String("vmovntqq") }, - { 'v', QLatin1String("vmovntdqa") }, - { 'v', QLatin1String("vmovntpd") }, - { 'v', QLatin1String("vmovntps") }, - { 'v', QLatin1String("vmovsd") }, - { 'v', QLatin1String("vmovshdup") }, - { 'v', QLatin1String("vmovsldup") }, - { 'v', QLatin1String("vmovss") }, - { 'v', QLatin1String("vmovupd") }, - { 'v', QLatin1String("vmovups") }, - { 'v', QLatin1String("vmpsadbw") }, - { 'v', QLatin1String("vmulpd") }, - { 'v', QLatin1String("vmulps") }, - { 'v', QLatin1String("vmulsd") }, - { 'v', QLatin1String("vmulss") }, - { 'v', QLatin1String("vorpd") }, - { 'v', QLatin1String("vorps") }, - { 'v', QLatin1String("vpabsb") }, - { 'v', QLatin1String("vpabsw") }, - { 'v', QLatin1String("vpabsd") }, - { 'v', QLatin1String("vpacksswb") }, - { 'v', QLatin1String("vpackssdw") }, - { 'v', QLatin1String("vpackuswb") }, - { 'v', QLatin1String("vpackusdw") }, - { 'v', QLatin1String("vpaddb") }, - { 'v', QLatin1String("vpaddw") }, - { 'v', QLatin1String("vpaddd") }, - { 'v', QLatin1String("vpaddq") }, - { 'v', QLatin1String("vpaddsb") }, - { 'v', QLatin1String("vpaddsw") }, - { 'v', QLatin1String("vpaddusb") }, - { 'v', QLatin1String("vpaddusw") }, - { 'v', QLatin1String("vpalignr") }, - { 'v', QLatin1String("vpand") }, - { 'v', QLatin1String("vpandn") }, - { 'v', QLatin1String("vpavgb") }, - { 'v', QLatin1String("vpavgw") }, - { 'v', QLatin1String("vpblendvb") }, - { 'v', QLatin1String("vpblendw") }, - { 'v', QLatin1String("vpcmpestri") }, - { 'v', QLatin1String("vpcmpestrm") }, - { 'v', QLatin1String("vpcmpistri") }, - { 'v', QLatin1String("vpcmpistrm") }, - { 'v', QLatin1String("vpcmpeqb") }, - { 'v', QLatin1String("vpcmpeqw") }, - { 'v', QLatin1String("vpcmpeqd") }, - { 'v', QLatin1String("vpcmpeqq") }, - { 'v', QLatin1String("vpcmpgtb") }, - { 'v', QLatin1String("vpcmpgtw") }, - { 'v', QLatin1String("vpcmpgtd") }, - { 'v', QLatin1String("vpcmpgtq") }, - { 'v', QLatin1String("vpermilpd") }, - { 'v', QLatin1String("vpermilps") }, - { 'v', QLatin1String("vperm2f128") }, - { 'v', QLatin1String("vpextrb") }, - { 'v', QLatin1String("vpextrw") }, - { 'v', QLatin1String("vpextrd") }, - { 'v', QLatin1String("vpextrq") }, - { 'v', QLatin1String("vphaddw") }, - { 'v', QLatin1String("vphaddd") }, - { 'v', QLatin1String("vphaddsw") }, - { 'v', QLatin1String("vphminposuw") }, - { 'v', QLatin1String("vphsubw") }, - { 'v', QLatin1String("vphsubd") }, - { 'v', QLatin1String("vphsubsw") }, - { 'v', QLatin1String("vpinsrb") }, - { 'v', QLatin1String("vpinsrw") }, - { 'v', QLatin1String("vpinsrd") }, - { 'v', QLatin1String("vpinsrq") }, - { 'v', QLatin1String("vpmaddwd") }, - { 'v', QLatin1String("vpmaddubsw") }, - { 'v', QLatin1String("vpmaxsb") }, - { 'v', QLatin1String("vpmaxsw") }, - { 'v', QLatin1String("vpmaxsd") }, - { 'v', QLatin1String("vpmaxub") }, - { 'v', QLatin1String("vpmaxuw") }, - { 'v', QLatin1String("vpmaxud") }, - { 'v', QLatin1String("vpminsb") }, - { 'v', QLatin1String("vpminsw") }, - { 'v', QLatin1String("vpminsd") }, - { 'v', QLatin1String("vpminub") }, - { 'v', QLatin1String("vpminuw") }, - { 'v', QLatin1String("vpminud") }, - { 'v', QLatin1String("vpmovmskb") }, - { 'v', QLatin1String("vpmovsxbw") }, - { 'v', QLatin1String("vpmovsxbd") }, - { 'v', QLatin1String("vpmovsxbq") }, - { 'v', QLatin1String("vpmovsxwd") }, - { 'v', QLatin1String("vpmovsxwq") }, - { 'v', QLatin1String("vpmovsxdq") }, - { 'v', QLatin1String("vpmovzxbw") }, - { 'v', QLatin1String("vpmovzxbd") }, - { 'v', QLatin1String("vpmovzxbq") }, - { 'v', QLatin1String("vpmovzxwd") }, - { 'v', QLatin1String("vpmovzxwq") }, - { 'v', QLatin1String("vpmovzxdq") }, - { 'v', QLatin1String("vpmulhuw") }, - { 'v', QLatin1String("vpmulhrsw") }, - { 'v', QLatin1String("vpmulhw") }, - { 'v', QLatin1String("vpmullw") }, - { 'v', QLatin1String("vpmulld") }, - { 'v', QLatin1String("vpmuludq") }, - { 'v', QLatin1String("vpmuldq") }, - { 'v', QLatin1String("vpor") }, - { 'v', QLatin1String("vpsadbw") }, - { 'v', QLatin1String("vpshufb") }, - { 'v', QLatin1String("vpshufd") }, - { 'v', QLatin1String("vpshufhw") }, - { 'v', QLatin1String("vpshuflw") }, - { 'v', QLatin1String("vpsignb") }, - { 'v', QLatin1String("vpsignw") }, - { 'v', QLatin1String("vpsignd") }, - { 'v', QLatin1String("vpslldq") }, - { 'v', QLatin1String("vpsrldq") }, - { 'v', QLatin1String("vpsllw") }, - { 'v', QLatin1String("vpslld") }, - { 'v', QLatin1String("vpsllq") }, - { 'v', QLatin1String("vpsraw") }, - { 'v', QLatin1String("vpsrad") }, - { 'v', QLatin1String("vpsrlw") }, - { 'v', QLatin1String("vpsrld") }, - { 'v', QLatin1String("vpsrlq") }, - { 'v', QLatin1String("vptest") }, - { 'v', QLatin1String("vpsubb") }, - { 'v', QLatin1String("vpsubw") }, - { 'v', QLatin1String("vpsubd") }, - { 'v', QLatin1String("vpsubq") }, - { 'v', QLatin1String("vpsubsb") }, - { 'v', QLatin1String("vpsubsw") }, - { 'v', QLatin1String("vpsubusb") }, - { 'v', QLatin1String("vpsubusw") }, - { 'v', QLatin1String("vpunpckhbw") }, - { 'v', QLatin1String("vpunpckhwd") }, - { 'v', QLatin1String("vpunpckhdq") }, - { 'v', QLatin1String("vpunpckhqdq") }, - { 'v', QLatin1String("vpunpcklbw") }, - { 'v', QLatin1String("vpunpcklwd") }, - { 'v', QLatin1String("vpunpckldq") }, - { 'v', QLatin1String("vpunpcklqdq") }, - { 'v', QLatin1String("vpxor") }, - { 'v', QLatin1String("vrcpps") }, - { 'v', QLatin1String("vrcpss") }, - { 'v', QLatin1String("vrsqrtps") }, - { 'v', QLatin1String("vrsqrtss") }, - { 'v', QLatin1String("vroundpd") }, - { 'v', QLatin1String("vroundps") }, - { 'v', QLatin1String("vroundsd") }, - { 'v', QLatin1String("vroundss") }, - { 'v', QLatin1String("vshufpd") }, - { 'v', QLatin1String("vshufps") }, - { 'v', QLatin1String("vsqrtpd") }, - { 'v', QLatin1String("vsqrtps") }, - { 'v', QLatin1String("vsqrtsd") }, - { 'v', QLatin1String("vsqrtss") }, - { 'v', QLatin1String("vstmxcsr") }, - { 'v', QLatin1String("vsubpd") }, - { 'v', QLatin1String("vsubps") }, - { 'v', QLatin1String("vsubsd") }, - { 'v', QLatin1String("vsubss") }, - { 'v', QLatin1String("vtestps") }, - { 'v', QLatin1String("vtestpd") }, - { 'v', QLatin1String("vucomisd") }, - { 'v', QLatin1String("vucomiss") }, - { 'v', QLatin1String("vunpckhpd") }, - { 'v', QLatin1String("vunpckhps") }, - { 'v', QLatin1String("vunpcklpd") }, - { 'v', QLatin1String("vunpcklps") }, - { 'v', QLatin1String("vxorpd") }, - { 'v', QLatin1String("vxorps") }, - { 'v', QLatin1String("vzeroall") }, - { 'v', QLatin1String("vzeroupper") }, - { 'p', QLatin1String("pclmullqlqdq") }, - { 'p', QLatin1String("pclmulhqlqdq") }, - { 'p', QLatin1String("pclmullqhqdq") }, - { 'p', QLatin1String("pclmulhqhqdq") }, - { 'p', QLatin1String("pclmulqdq") }, - { 'v', QLatin1String("vpclmullqlqdq") }, - { 'v', QLatin1String("vpclmulhqlqdq") }, - { 'v', QLatin1String("vpclmullqhqdq") }, - { 'v', QLatin1String("vpclmulhqhqdq") }, - { 'v', QLatin1String("vpclmulqdq") }, - { 'v', QLatin1String("vfmadd132ps") }, - { 'v', QLatin1String("vfmadd132pd") }, - { 'v', QLatin1String("vfmadd312ps") }, - { 'v', QLatin1String("vfmadd312pd") }, - { 'v', QLatin1String("vfmadd213ps") }, - { 'v', QLatin1String("vfmadd213pd") }, - { 'v', QLatin1String("vfmadd123ps") }, - { 'v', QLatin1String("vfmadd123pd") }, - { 'v', QLatin1String("vfmadd231ps") }, - { 'v', QLatin1String("vfmadd231pd") }, - { 'v', QLatin1String("vfmadd321ps") }, - { 'v', QLatin1String("vfmadd321pd") }, - { 'v', QLatin1String("vfmaddsub132ps") }, - { 'v', QLatin1String("vfmaddsub132pd") }, - { 'v', QLatin1String("vfmaddsub312ps") }, - { 'v', QLatin1String("vfmaddsub312pd") }, - { 'v', QLatin1String("vfmaddsub213ps") }, - { 'v', QLatin1String("vfmaddsub213pd") }, - { 'v', QLatin1String("vfmaddsub123ps") }, - { 'v', QLatin1String("vfmaddsub123pd") }, - { 'v', QLatin1String("vfmaddsub231ps") }, - { 'v', QLatin1String("vfmaddsub231pd") }, - { 'v', QLatin1String("vfmaddsub321ps") }, - { 'v', QLatin1String("vfmaddsub321pd") }, - { 'v', QLatin1String("vfmsub132ps") }, - { 'v', QLatin1String("vfmsub132pd") }, - { 'v', QLatin1String("vfmsub312ps") }, - { 'v', QLatin1String("vfmsub312pd") }, - { 'v', QLatin1String("vfmsub213ps") }, - { 'v', QLatin1String("vfmsub213pd") }, - { 'v', QLatin1String("vfmsub123ps") }, - { 'v', QLatin1String("vfmsub123pd") }, - { 'v', QLatin1String("vfmsub231ps") }, - { 'v', QLatin1String("vfmsub231pd") }, - { 'v', QLatin1String("vfmsub321ps") }, - { 'v', QLatin1String("vfmsub321pd") }, - { 'v', QLatin1String("vfmsubadd132ps") }, - { 'v', QLatin1String("vfmsubadd132pd") }, - { 'v', QLatin1String("vfmsubadd312ps") }, - { 'v', QLatin1String("vfmsubadd312pd") }, - { 'v', QLatin1String("vfmsubadd213ps") }, - { 'v', QLatin1String("vfmsubadd213pd") }, - { 'v', QLatin1String("vfmsubadd123ps") }, - { 'v', QLatin1String("vfmsubadd123pd") }, - { 'v', QLatin1String("vfmsubadd231ps") }, - { 'v', QLatin1String("vfmsubadd231pd") }, - { 'v', QLatin1String("vfmsubadd321ps") }, - { 'v', QLatin1String("vfmsubadd321pd") }, - { 'v', QLatin1String("vfnmadd132ps") }, - { 'v', QLatin1String("vfnmadd132pd") }, - { 'v', QLatin1String("vfnmadd312ps") }, - { 'v', QLatin1String("vfnmadd312pd") }, - { 'v', QLatin1String("vfnmadd213ps") }, - { 'v', QLatin1String("vfnmadd213pd") }, - { 'v', QLatin1String("vfnmadd123ps") }, - { 'v', QLatin1String("vfnmadd123pd") }, - { 'v', QLatin1String("vfnmadd231ps") }, - { 'v', QLatin1String("vfnmadd231pd") }, - { 'v', QLatin1String("vfnmadd321ps") }, - { 'v', QLatin1String("vfnmadd321pd") }, - { 'v', QLatin1String("vfnmsub132ps") }, - { 'v', QLatin1String("vfnmsub132pd") }, - { 'v', QLatin1String("vfnmsub312ps") }, - { 'v', QLatin1String("vfnmsub312pd") }, - { 'v', QLatin1String("vfnmsub213ps") }, - { 'v', QLatin1String("vfnmsub213pd") }, - { 'v', QLatin1String("vfnmsub123ps") }, - { 'v', QLatin1String("vfnmsub123pd") }, - { 'v', QLatin1String("vfnmsub231ps") }, - { 'v', QLatin1String("vfnmsub231pd") }, - { 'v', QLatin1String("vfnmsub321ps") }, - { 'v', QLatin1String("vfnmsub321pd") }, - { 'v', QLatin1String("vfmadd132ss") }, - { 'v', QLatin1String("vfmadd132sd") }, - { 'v', QLatin1String("vfmadd312ss") }, - { 'v', QLatin1String("vfmadd312sd") }, - { 'v', QLatin1String("vfmadd213ss") }, - { 'v', QLatin1String("vfmadd213sd") }, - { 'v', QLatin1String("vfmadd123ss") }, - { 'v', QLatin1String("vfmadd123sd") }, - { 'v', QLatin1String("vfmadd231ss") }, - { 'v', QLatin1String("vfmadd231sd") }, - { 'v', QLatin1String("vfmadd321ss") }, - { 'v', QLatin1String("vfmadd321sd") }, - { 'v', QLatin1String("vfmsub132ss") }, - { 'v', QLatin1String("vfmsub132sd") }, - { 'v', QLatin1String("vfmsub312ss") }, - { 'v', QLatin1String("vfmsub312sd") }, - { 'v', QLatin1String("vfmsub213ss") }, - { 'v', QLatin1String("vfmsub213sd") }, - { 'v', QLatin1String("vfmsub123ss") }, - { 'v', QLatin1String("vfmsub123sd") }, - { 'v', QLatin1String("vfmsub231ss") }, - { 'v', QLatin1String("vfmsub231sd") }, - { 'v', QLatin1String("vfmsub321ss") }, - { 'v', QLatin1String("vfmsub321sd") }, - { 'v', QLatin1String("vfnmadd132ss") }, - { 'v', QLatin1String("vfnmadd132sd") }, - { 'v', QLatin1String("vfnmadd312ss") }, - { 'v', QLatin1String("vfnmadd312sd") }, - { 'v', QLatin1String("vfnmadd213ss") }, - { 'v', QLatin1String("vfnmadd213sd") }, - { 'v', QLatin1String("vfnmadd123ss") }, - { 'v', QLatin1String("vfnmadd123sd") }, - { 'v', QLatin1String("vfnmadd231ss") }, - { 'v', QLatin1String("vfnmadd231sd") }, - { 'v', QLatin1String("vfnmadd321ss") }, - { 'v', QLatin1String("vfnmadd321sd") }, - { 'v', QLatin1String("vfnmsub132ss") }, - { 'v', QLatin1String("vfnmsub132sd") }, - { 'v', QLatin1String("vfnmsub312ss") }, - { 'v', QLatin1String("vfnmsub312sd") }, - { 'v', QLatin1String("vfnmsub213ss") }, - { 'v', QLatin1String("vfnmsub213sd") }, - { 'v', QLatin1String("vfnmsub123ss") }, - { 'v', QLatin1String("vfnmsub123sd") }, - { 'v', QLatin1String("vfnmsub231ss") }, - { 'v', QLatin1String("vfnmsub231sd") }, - { 'v', QLatin1String("vfnmsub321ss") }, - { 'v', QLatin1String("vfnmsub321sd") }, - { 'r', QLatin1String("rdfsbase") }, - { 'r', QLatin1String("rdgsbase") }, - { 'r', QLatin1String("rdrand") }, - { 'w', QLatin1String("wrfsbase") }, - { 'w', QLatin1String("wrgsbase") }, - { 'v', QLatin1String("vcvtph2ps") }, - { 'v', QLatin1String("vcvtps2ph") }, - { 'a', QLatin1String("adcx") }, - { 'a', QLatin1String("adox") }, - { 'r', QLatin1String("rdseed") }, - { 'c', QLatin1String("clac") }, - { 's', QLatin1String("stac") }, - { 'x', QLatin1String("xstore") }, - { 'x', QLatin1String("xcryptecb") }, - { 'x', QLatin1String("xcryptcbc") }, - { 'x', QLatin1String("xcryptctr") }, - { 'x', QLatin1String("xcryptcfb") }, - { 'x', QLatin1String("xcryptofb") }, - { 'm', QLatin1String("montmul") }, - { 'x', QLatin1String("xsha1") }, - { 'x', QLatin1String("xsha256") }, - { 'l', QLatin1String("llwpcb") }, - { 's', QLatin1String("slwpcb") }, - { 'l', QLatin1String("lwpval") }, - { 'l', QLatin1String("lwpins") }, - { 'v', QLatin1String("vfmaddpd") }, - { 'v', QLatin1String("vfmaddps") }, - { 'v', QLatin1String("vfmaddsd") }, - { 'v', QLatin1String("vfmaddss") }, - { 'v', QLatin1String("vfmaddsubpd") }, - { 'v', QLatin1String("vfmaddsubps") }, - { 'v', QLatin1String("vfmsubaddpd") }, - { 'v', QLatin1String("vfmsubaddps") }, - { 'v', QLatin1String("vfmsubpd") }, - { 'v', QLatin1String("vfmsubps") }, - { 'v', QLatin1String("vfmsubsd") }, - { 'v', QLatin1String("vfmsubss") }, - { 'v', QLatin1String("vfnmaddpd") }, - { 'v', QLatin1String("vfnmaddps") }, - { 'v', QLatin1String("vfnmaddsd") }, - { 'v', QLatin1String("vfnmaddss") }, - { 'v', QLatin1String("vfnmsubpd") }, - { 'v', QLatin1String("vfnmsubps") }, - { 'v', QLatin1String("vfnmsubsd") }, - { 'v', QLatin1String("vfnmsubss") }, - { 'v', QLatin1String("vfrczpd") }, - { 'v', QLatin1String("vfrczps") }, - { 'v', QLatin1String("vfrczsd") }, - { 'v', QLatin1String("vfrczss") }, - { 'v', QLatin1String("vpcmov") }, - { 'v', QLatin1String("vpcomb") }, - { 'v', QLatin1String("vpcomd") }, - { 'v', QLatin1String("vpcomq") }, - { 'v', QLatin1String("vpcomub") }, - { 'v', QLatin1String("vpcomud") }, - { 'v', QLatin1String("vpcomuq") }, - { 'v', QLatin1String("vpcomuw") }, - { 'v', QLatin1String("vpcomw") }, - { 'v', QLatin1String("vphaddbd") }, - { 'v', QLatin1String("vphaddbq") }, - { 'v', QLatin1String("vphaddbw") }, - { 'v', QLatin1String("vphadddq") }, - { 'v', QLatin1String("vphaddubd") }, - { 'v', QLatin1String("vphaddubq") }, - { 'v', QLatin1String("vphaddubw") }, - { 'v', QLatin1String("vphaddudq") }, - { 'v', QLatin1String("vphadduwd") }, - { 'v', QLatin1String("vphadduwq") }, - { 'v', QLatin1String("vphaddwd") }, - { 'v', QLatin1String("vphaddwq") }, - { 'v', QLatin1String("vphsubbw") }, - { 'v', QLatin1String("vphsubdq") }, - { 'v', QLatin1String("vphsubwd") }, - { 'v', QLatin1String("vpmacsdd") }, - { 'v', QLatin1String("vpmacsdqh") }, - { 'v', QLatin1String("vpmacsdql") }, - { 'v', QLatin1String("vpmacssdd") }, - { 'v', QLatin1String("vpmacssdqh") }, - { 'v', QLatin1String("vpmacssdql") }, - { 'v', QLatin1String("vpmacsswd") }, - { 'v', QLatin1String("vpmacssww") }, - { 'v', QLatin1String("vpmacswd") }, - { 'v', QLatin1String("vpmacsww") }, - { 'v', QLatin1String("vpmadcsswd") }, - { 'v', QLatin1String("vpmadcswd") }, - { 'v', QLatin1String("vpperm") }, - { 'v', QLatin1String("vprotb") }, - { 'v', QLatin1String("vprotd") }, - { 'v', QLatin1String("vprotq") }, - { 'v', QLatin1String("vprotw") }, - { 'v', QLatin1String("vpshab") }, - { 'v', QLatin1String("vpshad") }, - { 'v', QLatin1String("vpshaq") }, - { 'v', QLatin1String("vpshaw") }, - { 'v', QLatin1String("vpshlb") }, - { 'v', QLatin1String("vpshld") }, - { 'v', QLatin1String("vpshlq") }, - { 'v', QLatin1String("vpshlw") }, - { 'v', QLatin1String("vbroadcasti128") }, - { 'v', QLatin1String("vpblendd") }, - { 'v', QLatin1String("vpbroadcastb") }, - { 'v', QLatin1String("vpbroadcastw") }, - { 'v', QLatin1String("vpbroadcastd") }, - { 'v', QLatin1String("vpbroadcastq") }, - { 'v', QLatin1String("vpermd") }, - { 'v', QLatin1String("vpermpd") }, - { 'v', QLatin1String("vpermps") }, - { 'v', QLatin1String("vpermq") }, - { 'v', QLatin1String("vperm2i128") }, - { 'v', QLatin1String("vextracti128") }, - { 'v', QLatin1String("vinserti128") }, - { 'v', QLatin1String("vpmaskmovd") }, - { 'v', QLatin1String("vpmaskmovq") }, - { 'v', QLatin1String("vpsllvd") }, - { 'v', QLatin1String("vpsllvq") }, - { 'v', QLatin1String("vpsravd") }, - { 'v', QLatin1String("vpsrlvd") }, - { 'v', QLatin1String("vpsrlvq") }, - { 'v', QLatin1String("vgatherdpd") }, - { 'v', QLatin1String("vgatherqpd") }, - { 'v', QLatin1String("vgatherdps") }, - { 'v', QLatin1String("vgatherqps") }, - { 'v', QLatin1String("vpgatherdd") }, - { 'v', QLatin1String("vpgatherqd") }, - { 'v', QLatin1String("vpgatherdq") }, - { 'v', QLatin1String("vpgatherqq") }, - { 'x', QLatin1String("xabort") }, - { 'x', QLatin1String("xbegin") }, - { 'x', QLatin1String("xend") }, - { 'x', QLatin1String("xtest") }, - { 'a', QLatin1String("andn") }, - { 'b', QLatin1String("bextr") }, - { 'b', QLatin1String("blci") }, - { 'b', QLatin1String("blcic") }, - { 'b', QLatin1String("blsi") }, - { 'b', QLatin1String("blsic") }, - { 'b', QLatin1String("blcfill") }, - { 'b', QLatin1String("blsfill") }, - { 'b', QLatin1String("blcmsk") }, - { 'b', QLatin1String("blsmsk") }, - { 'b', QLatin1String("blsr") }, - { 'b', QLatin1String("blcs") }, - { 'b', QLatin1String("bzhi") }, - { 'm', QLatin1String("mulx") }, - { 'p', QLatin1String("pdep") }, - { 'p', QLatin1String("pext") }, - { 'r', QLatin1String("rorx") }, - { 's', QLatin1String("sarx") }, - { 's', QLatin1String("shlx") }, - { 's', QLatin1String("shrx") }, - { 't', QLatin1String("tzcnt") }, - { 't', QLatin1String("tzmsk") }, - { 't', QLatin1String("t1mskc") }, - { 'v', QLatin1String("valignd") }, - { 'v', QLatin1String("valignq") }, - { 'v', QLatin1String("vblendmpd") }, - { 'v', QLatin1String("vblendmps") }, - { 'v', QLatin1String("vbroadcastf32x4") }, - { 'v', QLatin1String("vbroadcastf64x4") }, - { 'v', QLatin1String("vbroadcasti32x4") }, - { 'v', QLatin1String("vbroadcasti64x4") }, - { 'v', QLatin1String("vcompresspd") }, - { 'v', QLatin1String("vcompressps") }, - { 'v', QLatin1String("vcvtpd2udq") }, - { 'v', QLatin1String("vcvtps2udq") }, - { 'v', QLatin1String("vcvtsd2usi") }, - { 'v', QLatin1String("vcvtss2usi") }, - { 'v', QLatin1String("vcvttpd2udq") }, - { 'v', QLatin1String("vcvttps2udq") }, - { 'v', QLatin1String("vcvttsd2usi") }, - { 'v', QLatin1String("vcvttss2usi") }, - { 'v', QLatin1String("vcvtudq2pd") }, - { 'v', QLatin1String("vcvtudq2ps") }, - { 'v', QLatin1String("vcvtusi2sd") }, - { 'v', QLatin1String("vcvtusi2ss") }, - { 'v', QLatin1String("vexpandpd") }, - { 'v', QLatin1String("vexpandps") }, - { 'v', QLatin1String("vextractf32x4") }, - { 'v', QLatin1String("vextractf64x4") }, - { 'v', QLatin1String("vextracti32x4") }, - { 'v', QLatin1String("vextracti64x4") }, - { 'v', QLatin1String("vfixupimmpd") }, - { 'v', QLatin1String("vfixupimmps") }, - { 'v', QLatin1String("vfixupimmsd") }, - { 'v', QLatin1String("vfixupimmss") }, - { 'v', QLatin1String("vgetexppd") }, - { 'v', QLatin1String("vgetexpps") }, - { 'v', QLatin1String("vgetexpsd") }, - { 'v', QLatin1String("vgetexpss") }, - { 'v', QLatin1String("vgetmantpd") }, - { 'v', QLatin1String("vgetmantps") }, - { 'v', QLatin1String("vgetmantsd") }, - { 'v', QLatin1String("vgetmantss") }, - { 'v', QLatin1String("vinsertf32x4") }, - { 'v', QLatin1String("vinsertf64x4") }, - { 'v', QLatin1String("vinserti32x4") }, - { 'v', QLatin1String("vinserti64x4") }, - { 'v', QLatin1String("vmovdqa32") }, - { 'v', QLatin1String("vmovdqa64") }, - { 'v', QLatin1String("vmovdqu32") }, - { 'v', QLatin1String("vmovdqu64") }, - { 'v', QLatin1String("vpabsq") }, - { 'v', QLatin1String("vpandd") }, - { 'v', QLatin1String("vpandnd") }, - { 'v', QLatin1String("vpandnq") }, - { 'v', QLatin1String("vpandq") }, - { 'v', QLatin1String("vpblendmd") }, - { 'v', QLatin1String("vpblendmq") }, - { 'v', QLatin1String("vpcmpltd") }, - { 'v', QLatin1String("vpcmpled") }, - { 'v', QLatin1String("vpcmpneqd") }, - { 'v', QLatin1String("vpcmpnltd") }, - { 'v', QLatin1String("vpcmpnled") }, - { 'v', QLatin1String("vpcmpd") }, - { 'v', QLatin1String("vpcmpltq") }, - { 'v', QLatin1String("vpcmpleq") }, - { 'v', QLatin1String("vpcmpneqq") }, - { 'v', QLatin1String("vpcmpnltq") }, - { 'v', QLatin1String("vpcmpnleq") }, - { 'v', QLatin1String("vpcmpq") }, - { 'v', QLatin1String("vpcmpequd") }, - { 'v', QLatin1String("vpcmpltud") }, - { 'v', QLatin1String("vpcmpleud") }, - { 'v', QLatin1String("vpcmpnequd") }, - { 'v', QLatin1String("vpcmpnltud") }, - { 'v', QLatin1String("vpcmpnleud") }, - { 'v', QLatin1String("vpcmpud") }, - { 'v', QLatin1String("vpcmpequq") }, - { 'v', QLatin1String("vpcmpltuq") }, - { 'v', QLatin1String("vpcmpleuq") }, - { 'v', QLatin1String("vpcmpnequq") }, - { 'v', QLatin1String("vpcmpnltuq") }, - { 'v', QLatin1String("vpcmpnleuq") }, - { 'v', QLatin1String("vpcmpuq") }, - { 'v', QLatin1String("vpcompressd") }, - { 'v', QLatin1String("vpcompressq") }, - { 'v', QLatin1String("vpermi2d") }, - { 'v', QLatin1String("vpermi2pd") }, - { 'v', QLatin1String("vpermi2ps") }, - { 'v', QLatin1String("vpermi2q") }, - { 'v', QLatin1String("vpermt2d") }, - { 'v', QLatin1String("vpermt2pd") }, - { 'v', QLatin1String("vpermt2ps") }, - { 'v', QLatin1String("vpermt2q") }, - { 'v', QLatin1String("vpexpandd") }, - { 'v', QLatin1String("vpexpandq") }, - { 'v', QLatin1String("vpmaxsq") }, - { 'v', QLatin1String("vpmaxuq") }, - { 'v', QLatin1String("vpminsq") }, - { 'v', QLatin1String("vpminuq") }, - { 'v', QLatin1String("vpmovdb") }, - { 'v', QLatin1String("vpmovdw") }, - { 'v', QLatin1String("vpmovqb") }, - { 'v', QLatin1String("vpmovqd") }, - { 'v', QLatin1String("vpmovqw") }, - { 'v', QLatin1String("vpmovsdb") }, - { 'v', QLatin1String("vpmovsdw") }, - { 'v', QLatin1String("vpmovsqb") }, - { 'v', QLatin1String("vpmovsqd") }, - { 'v', QLatin1String("vpmovsqw") }, - { 'v', QLatin1String("vpmovusdb") }, - { 'v', QLatin1String("vpmovusdw") }, - { 'v', QLatin1String("vpmovusqb") }, - { 'v', QLatin1String("vpmovusqd") }, - { 'v', QLatin1String("vpmovusqw") }, - { 'v', QLatin1String("vpord") }, - { 'v', QLatin1String("vporq") }, - { 'v', QLatin1String("vprold") }, - { 'v', QLatin1String("vprolq") }, - { 'v', QLatin1String("vprolvd") }, - { 'v', QLatin1String("vprolvq") }, - { 'v', QLatin1String("vprord") }, - { 'v', QLatin1String("vprorq") }, - { 'v', QLatin1String("vprorvd") }, - { 'v', QLatin1String("vprorvq") }, - { 'v', QLatin1String("vpscatterdd") }, - { 'v', QLatin1String("vpscatterdq") }, - { 'v', QLatin1String("vpscatterqd") }, - { 'v', QLatin1String("vpscatterqq") }, - { 'v', QLatin1String("vpsraq") }, - { 'v', QLatin1String("vpsravq") }, - { 'v', QLatin1String("vpternlogd") }, - { 'v', QLatin1String("vpternlogq") }, - { 'v', QLatin1String("vptestmd") }, - { 'v', QLatin1String("vptestmq") }, - { 'v', QLatin1String("vptestnmd") }, - { 'v', QLatin1String("vptestnmq") }, - { 'v', QLatin1String("vpxord") }, - { 'v', QLatin1String("vpxorq") }, - { 'v', QLatin1String("vrcp14pd") }, - { 'v', QLatin1String("vrcp14ps") }, - { 'v', QLatin1String("vrcp14sd") }, - { 'v', QLatin1String("vrcp14ss") }, - { 'v', QLatin1String("vrndscalepd") }, - { 'v', QLatin1String("vrndscaleps") }, - { 'v', QLatin1String("vrndscalesd") }, - { 'v', QLatin1String("vrndscaless") }, - { 'v', QLatin1String("vrsqrt14pd") }, - { 'v', QLatin1String("vrsqrt14ps") }, - { 'v', QLatin1String("vrsqrt14sd") }, - { 'v', QLatin1String("vrsqrt14ss") }, - { 'v', QLatin1String("vscalefpd") }, - { 'v', QLatin1String("vscalefps") }, - { 'v', QLatin1String("vscalefsd") }, - { 'v', QLatin1String("vscalefss") }, - { 'v', QLatin1String("vscatterdpd") }, - { 'v', QLatin1String("vscatterdps") }, - { 'v', QLatin1String("vscatterqpd") }, - { 'v', QLatin1String("vscatterqps") }, - { 'v', QLatin1String("vshuff32x4") }, - { 'v', QLatin1String("vshuff64x2") }, - { 'v', QLatin1String("vshufi32x4") }, - { 'v', QLatin1String("vshufi64x2") }, - { 'k', QLatin1String("kandnw") }, - { 'k', QLatin1String("kandw") }, - { 'k', QLatin1String("kmovw") }, - { 'k', QLatin1String("knotw") }, - { 'k', QLatin1String("kortestw") }, - { 'k', QLatin1String("korw") }, - { 'k', QLatin1String("kshiftlw") }, - { 'k', QLatin1String("kshiftrw") }, - { 'k', QLatin1String("kunpckbw") }, - { 'k', QLatin1String("kxnorw") }, - { 'k', QLatin1String("kxorw") }, - { 'v', QLatin1String("vpbroadcastmb2q") }, - { 'v', QLatin1String("vpbroadcastmw2d") }, - { 'v', QLatin1String("vpconflictd") }, - { 'v', QLatin1String("vpconflictq") }, - { 'v', QLatin1String("vplzcntd") }, - { 'v', QLatin1String("vplzcntq") }, - { 'v', QLatin1String("vexp2pd") }, - { 'v', QLatin1String("vexp2ps") }, - { 'v', QLatin1String("vrcp28pd") }, - { 'v', QLatin1String("vrcp28ps") }, - { 'v', QLatin1String("vrcp28sd") }, - { 'v', QLatin1String("vrcp28ss") }, - { 'v', QLatin1String("vrsqrt28pd") }, - { 'v', QLatin1String("vrsqrt28ps") }, - { 'v', QLatin1String("vrsqrt28sd") }, - { 'v', QLatin1String("vrsqrt28ss") }, - { 'v', QLatin1String("vgatherpf0dpd") }, - { 'v', QLatin1String("vgatherpf0dps") }, - { 'v', QLatin1String("vgatherpf0qpd") }, - { 'v', QLatin1String("vgatherpf0qps") }, - { 'v', QLatin1String("vgatherpf1dpd") }, - { 'v', QLatin1String("vgatherpf1dps") }, - { 'v', QLatin1String("vgatherpf1qpd") }, - { 'v', QLatin1String("vgatherpf1qps") }, - { 'v', QLatin1String("vscatterpf0dpd") }, - { 'v', QLatin1String("vscatterpf0dps") }, - { 'v', QLatin1String("vscatterpf0qpd") }, - { 'v', QLatin1String("vscatterpf0qps") }, - { 'v', QLatin1String("vscatterpf1dpd") }, - { 'v', QLatin1String("vscatterpf1dps") }, - { 'v', QLatin1String("vscatterpf1qpd") }, - { 'v', QLatin1String("vscatterpf1qps") }, - { 'p', QLatin1String("prefetchwt1") }, - { 'b', QLatin1String("bndmk") }, - { 'b', QLatin1String("bndcl") }, - { 'b', QLatin1String("bndcu") }, - { 'b', QLatin1String("bndcn") }, - { 'b', QLatin1String("bndmov") }, - { 'b', QLatin1String("bndldx") }, - { 'b', QLatin1String("bndstx") }, - { 's', QLatin1String("sha1rnds4") }, - { 's', QLatin1String("sha1nexte") }, - { 's', QLatin1String("sha1msg1") }, - { 's', QLatin1String("sha1msg2") }, - { 's', QLatin1String("sha256rnds2") }, - { 's', QLatin1String("sha256msg1") }, - { 's', QLatin1String("sha256msg2") }, - { 'h', QLatin1String("hint_nop") }, - }; - - other = { - { 's', QLatin1String("section") }, - }; - builtin = { - - { 't', QLatin1String("text") }, - { 'c', QLatin1String("code") }, - { 'd', QLatin1String("data") }, - { 'b', QLatin1String("bss") } - }; -} - -} diff --git a/tools/fm-editor/fileview/syntaxHighlite/languagedata.h b/tools/fm-editor/fileview/syntaxHighlite/languagedata.h deleted file mode 100644 index fe244e0a0..000000000 --- a/tools/fm-editor/fileview/syntaxHighlite/languagedata.h +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Copyright (c) 2019-2020 Waqar Ahmed -- - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -#ifndef QOWNLANGUAGEDATA_H -#define QOWNLANGUAGEDATA_H - -template -class QMultiHash; - -class QLatin1String; - -namespace QSourceHighlite { - -using LanguageData = QMultiHash; - -/**********************************************************/ -/* LuaData ************************************************/ -/**********************************************************/ -void loadLuaData(LanguageData &typess, - LanguageData &keywordss, - LanguageData &builtins, - LanguageData &literalss, - LanguageData &others); - -/**********************************************************/ -/* C/C++ Data *********************************************/ -/**********************************************************/ -void loadCppData(LanguageData &typess, - LanguageData &keywordss, - LanguageData &builtins, - LanguageData &literalss, - LanguageData &others); - -/**********************************************************/ -/* Shell Data *********************************************/ -/**********************************************************/ -void loadShellData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other); - -/**********************************************************/ -/* JS Data *********************************************/ -/**********************************************************/ -void loadJSData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other); - -/**********************************************************/ -/* PHP Data *********************************************/ -/**********************************************************/ -void loadPHPData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other); - -/**********************************************************/ -/* QML Data *********************************************/ -/**********************************************************/ -void loadQMLData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other); - -/**********************************************************/ -/* Python Data *********************************************/ -/**********************************************************/ -void loadPythonData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other); - -/********************************************************/ -/*** Rust DATA ***********************************/ -/********************************************************/ -void loadRustData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other); - -/********************************************************/ -/*** Java DATA ***********************************/ -/********************************************************/ -void loadJavaData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other); - -/********************************************************/ -/*** C# DATA *************************************/ -/********************************************************/ -void loadCSharpData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other); - -/********************************************************/ -/*** Go DATA *************************************/ -/********************************************************/ -void loadGoData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other); - -/********************************************************/ -/*** V DATA **************************************/ -/********************************************************/ -void loadVData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other); - -/********************************************************/ -/*** SQL DATA ************************************/ -/********************************************************/ -void loadSQLData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other); - -/********************************************************/ -/*** JSON DATA ***********************************/ -/********************************************************/ -void loadJSONData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other); - -/********************************************************/ -/*** CSS DATA ***********************************/ -/********************************************************/ -void loadCSSData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other); - -/********************************************************/ -/*** Typescript DATA *********************************/ -/********************************************************/ -void loadTypescriptData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other); - -/********************************************************/ -/*** YAML DATA ***************************************/ -/********************************************************/ -void loadYAMLData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other); - -/********************************************************/ -/*** VEX DATA ***************************************/ -/********************************************************/ -void loadVEXData(LanguageData &types, - LanguageData &keywords, - LanguageData &builtin, - LanguageData &literals, - LanguageData &other); - -/********************************************************/ -/*** CMake DATA **************************************/ -/********************************************************/ -void loadCMakeData(QMultiHash &types, - QMultiHash &keywords, - QMultiHash &builtin, - QMultiHash &literals, - QMultiHash &other); - -/********************************************************/ -/*** Make DATA ***************************************/ -/********************************************************/ -void loadMakeData(QMultiHash& types, - QMultiHash& keywords, - QMultiHash& builtin, - QMultiHash& literals, - QMultiHash& other); - -void loadAsmData(QMultiHash& types, - QMultiHash& keywords, - QMultiHash& builtin, - QMultiHash& literals, - QMultiHash& other); -} -#endif diff --git a/tools/fm-editor/fileview/syntaxHighlite/qsourcehighliter.cpp b/tools/fm-editor/fileview/syntaxHighlite/qsourcehighliter.cpp deleted file mode 100644 index ed4cf64fe..000000000 --- a/tools/fm-editor/fileview/syntaxHighlite/qsourcehighliter.cpp +++ /dev/null @@ -1,940 +0,0 @@ -/* - * Copyright (c) 2019-2020 Waqar Ahmed -- - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -#include "qsourcehighliter.h" -#include "languagedata.h" -#include "qsourcehighliterthemes.h" - -#include -#include -#include - -namespace QSourceHighlite { - -QSourceHighliter::QSourceHighliter(QTextDocument *doc) - : QSyntaxHighlighter(doc), - _language(CodeC) -{ - initFormats(); -} - -QSourceHighliter::QSourceHighliter(QTextDocument *doc, QSourceHighliter::Themes theme) - : QSyntaxHighlighter(doc), - _language(CodeC) -{ - setTheme(theme); -} - -void QSourceHighliter::initFormats() { - /**************************************** - * Formats for syntax highlighting - ***************************************/ - - QTextCharFormat format = QTextCharFormat(); - - _formats[Token::CodeBlock] = format; - format = QTextCharFormat(); - - format.setForeground(QColor("#F92672")); - _formats[Token::CodeKeyWord] = format; - format = QTextCharFormat(); - - format.setForeground(QColor("#a39b4e")); - _formats[Token::CodeString] = format; - format = QTextCharFormat(); - - format.setForeground(QColor("#75715E")); - _formats[Token::CodeComment] = format; - format = QTextCharFormat(); - - format.setForeground(QColor("#54aebf")); - _formats[Token::CodeType] = format; - - format = QTextCharFormat(); - format.setForeground(QColor("#db8744")); - _formats[Token::CodeOther] = format; - - format = QTextCharFormat(); - format.setForeground(QColor("#AE81FF")); - _formats[Token::CodeNumLiteral] = format; - - format = QTextCharFormat(); - format.setForeground(QColor("#018a0f")); - _formats[Token::CodeBuiltIn] = format; -} - -void QSourceHighliter::setCurrentLanguage(Language language) { - if (language != _language) - _language = language; -} - -QSourceHighliter::Language QSourceHighliter::currentLanguage() { - return _language; -} - -void QSourceHighliter::setTheme(QSourceHighliter::Themes theme) -{ - _formats = QSourceHighliterTheme::theme(theme); - rehighlight(); -} - -void QSourceHighliter::highlightBlock(const QString &text) -{ - if (currentBlock() == document()->firstBlock()) { - setCurrentBlockState(_language); - } else { - previousBlockState() == _language ? - setCurrentBlockState(_language) : - setCurrentBlockState(_language + 1); - } - - highlightSyntax(text); -} - -/** - * @brief Does the code syntax highlighting - * @param text - */ -void QSourceHighliter::highlightSyntax(const QString &text) -{ - if (text.isEmpty()) return; - - const auto textLen = text.length(); - - QChar comment; - bool isCSS = false; - bool isYAML = false; - bool isMake = false; - bool isAsm = false; - bool isSQL = false; - - LanguageData keywords{}, - others{}, - types{}, - builtin{}, - literals{}; - - switch (currentBlockState()) { - case CodeLua : - case CodeLuaComment : - loadLuaData(types, keywords, builtin, literals, others); - break; - case CodeCpp : - case CodeCppComment : - loadCppData(types, keywords, builtin, literals, others); - break; - case CodeJs : - case CodeJsComment : - loadJSData(types, keywords, builtin, literals, others); - break; - case CodeC : - case CodeCComment : - loadCppData(types, keywords, builtin, literals, others); - break; - case CodeBash : - loadShellData(types, keywords, builtin, literals, others); - comment = QLatin1Char('#'); - break; - case CodePHP : - case CodePHPComment : - loadPHPData(types, keywords, builtin, literals, others); - break; - case CodeQML : - case CodeQMLComment : - loadQMLData(types, keywords, builtin, literals, others); - break; - case CodePython : - loadPythonData(types, keywords, builtin, literals, others); - comment = QLatin1Char('#'); - break; - case CodeRust : - case CodeRustComment : - loadRustData(types, keywords, builtin, literals, others); - break; - case CodeJava : - case CodeJavaComment : - loadJavaData(types, keywords, builtin, literals, others); - break; - case CodeCSharp : - case CodeCSharpComment : - loadCSharpData(types, keywords, builtin, literals, others); - break; - case CodeGo : - case CodeGoComment : - loadGoData(types, keywords, builtin, literals, others); - break; - case CodeV : - case CodeVComment : - loadVData(types, keywords, builtin, literals, others); - break; - case CodeSQL : - isSQL = true; - loadSQLData(types, keywords, builtin, literals, others); - break; - case CodeJSON : - loadJSONData(types, keywords, builtin, literals, others); - break; - case CodeXML : - xmlHighlighter(text); - return; - case CodeCSS : - case CodeCSSComment : - isCSS = true; - loadCSSData(types, keywords, builtin, literals, others); - break; - case CodeTypeScript: - case CodeTypeScriptComment: - loadTypescriptData(types, keywords, builtin, literals, others); - break; - case CodeYAML: - isYAML = true; - loadYAMLData(types, keywords, builtin, literals, others); - comment = QLatin1Char('#'); - break; - case CodeINI: - comment = QLatin1Char('#'); - break; - case CodeVex: - case CodeVexComment: - loadVEXData(types, keywords, builtin, literals, others); - break; - case CodeCMake: - loadCMakeData(types, keywords, builtin, literals, others); - comment = QLatin1Char('#'); - break; - case CodeMake: - isMake = true; - loadMakeData(types, keywords, builtin, literals, others); - comment = QLatin1Char('#'); - break; - case CodeAsm: - isAsm = true; - loadAsmData(types, keywords, builtin, literals, others); - comment = QLatin1Char('#'); - break; - default: - break; - } - - // keep the default code block format - // this statement is very slow - // TODO: do this formatting when necessary instead of - // applying it to the whole block in the beginning - setFormat(0, textLen, _formats[CodeBlock]); - - auto applyCodeFormat = - [this](int i, const LanguageData &data, - const QString &text, const QTextCharFormat &fmt) -> int { - // check if we are at the beginning OR if this is the start of a word - if (i == 0 || (!text.at(i - 1).isLetterOrNumber() && - text.at(i-1) != QLatin1Char('_'))) { - const auto wordList = data.values(text.at(i).toLatin1()); - for (const QLatin1String &word : wordList) { - // we have a word match check - // 1. if we are at the end - // 2. if we have a complete word - if (word == strMidRef(text, i, word.size()) && - (i + word.size() == text.length() || - (!text.at(i + word.size()).isLetterOrNumber() && - text.at(i + word.size()) != QLatin1Char('_')))) { - setFormat(i, word.size(), fmt); - i += word.size(); - } - } - } - return i; - }; - - const QTextCharFormat &formatType = _formats[CodeType]; - const QTextCharFormat &formatKeyword = _formats[CodeKeyWord]; - const QTextCharFormat &formatComment = _formats[CodeComment]; - const QTextCharFormat &formatNumLit = _formats[CodeNumLiteral]; - const QTextCharFormat &formatBuiltIn = _formats[CodeBuiltIn]; - const QTextCharFormat &formatOther = _formats[CodeOther]; - - for (int i = 0; i < textLen; ++i) { - - if (currentBlockState() % 2 != 0) goto Comment; - - while (i < textLen && !text[i].isLetter()) { - if (text[i].isSpace()) { - ++i; - //make sure we don't cross the bound - if (i == textLen) return; - if (text[i].isLetter()) break; - else continue; - } - //inline comment - if (comment.isNull() && text[i] == QLatin1Char('/')) { - if((i+1) < textLen){ - if(text[i+1] == QLatin1Char('/')) { - setFormat(i, textLen, formatComment); - return; - } else if(text[i+1] == QLatin1Char('*')) { - Comment: - int next = text.indexOf(QLatin1String("*/")); - if (next == -1) { - //we didn't find a comment end. - //Check if we are already in a comment block - if (currentBlockState() % 2 == 0) - setCurrentBlockState(currentBlockState() + 1); - setFormat(i, textLen, formatComment); - return; - } else { - //we found a comment end - //mark this block as code if it was previously comment - //first check if the comment ended on the same line - //if modulo 2 is not equal to zero, it means we are in a comment - //-1 will set this block's state as language - if (currentBlockState() % 2 != 0) { - setCurrentBlockState(currentBlockState() - 1); - } - next += 2; - setFormat(i, next - i, formatComment); - i = next; - if (i >= textLen) return; - } - } - } - } else if (isSQL && comment.isNull() && text[i] == QLatin1Char('-')) { - if((i+1) < textLen){ - if(text[i+1] == QLatin1Char('-')) { - setFormat(i, textLen, formatComment); - return; - } - } - } else if (text[i] == comment) { - setFormat(i, textLen, formatComment); - i = textLen; - //integer literal - } else if (text[i].isNumber()) { - i = highlightNumericLiterals(text, i); - //string literals - } else if (text[i] == QLatin1Char('\"')) { - i = highlightStringLiterals('\"', text, i); - } else if (text[i] == QLatin1Char('\'')) { - i = highlightStringLiterals('\'', text, i); - } - if (i >= textLen) { - break; - } - ++i; - } - - const int pos = i; - - if (i == textLen || !text[i].isLetter()) continue; - - /* Highlight Types */ - i = applyCodeFormat(i, types, text, formatType); - /************************************************ - next letter is usually a space, in that case - going forward is useless, so continue; - We can ++i here and go to the beginning of the next word - so that the next formatter can check for formatting but this will - cause problems in case the next word is also of 'Type' or the current - type(keyword/builtin). We can work around it and reset the value of i - in the beginning of the loop to the word's first letter but I am not - sure about its efficiency yet. - ************************************************/ - if (i == textLen || !text[i].isLetter()) continue; - - /* Highlight Keywords */ - i = applyCodeFormat(i, keywords, text, formatKeyword); - if (i == textLen || !text[i].isLetter()) continue; - - /* Highlight Literals (true/false/NULL,nullptr) */ - i = applyCodeFormat(i, literals, text, formatNumLit); - if (i == textLen || !text[i].isLetter()) continue; - - /* Highlight Builtin library stuff */ - i = applyCodeFormat(i, builtin, text, formatBuiltIn); - if (i == textLen || !text[i].isLetter()) continue; - - /* Highlight other stuff (preprocessor etc.) */ - if (( i == 0 || !text.at(i-1).isLetter()) && others.contains(text[i].toLatin1())) { - const QList wordList = others.values(text[i].toLatin1()); - for(const QLatin1String &word : wordList) { - if (word == strMidRef(text, i, word.size()) // we have a word match - && - (i + word.size() == text.length() // check if we are at the end - || - !text.at(i + word.size()).isLetter()) //OR if we have a complete word - ) { - currentBlockState() == CodeCpp ? - setFormat(i - 1, word.size() + 1, formatOther) : - setFormat(i, word.size(), formatOther); - i += word.size(); - } - } - } - - //we were unable to find any match, lets skip this word - if (pos == i) { - int count = i; - while (count < textLen) { - if (!text[count].isLetter()) break; - ++count; - } - i = count; - } - } - - if (isCSS) cssHighlighter(text); - if (isYAML) ymlHighlighter(text); - if (isMake) makeHighlighter(text); - if (isAsm) asmHighlighter(text); -} - -/** - * @brief Highlight string literals in code - * @param strType str type i.e., ' or " - * @param text the text being scanned - * @param i pos of i in loop - * @return pos of i after the string - */ -int QSourceHighliter::highlightStringLiterals(const QChar strType, const QString &text, int i) { - setFormat(i, 1, _formats[CodeString]); - ++i; - - while (i < text.length()) { - //look for string end - //make sure it's not an escape seq - if (text.at(i) == strType && text.at(i-1) != QLatin1Char('\\')) { - setFormat(i, 1, _formats[CodeString]); - ++i; - break; - } - //look for escape sequence - if (text.at(i) == QLatin1Char('\\') && (i+1) < text.length()) { - int len = 0; - switch(text.at(i+1).toLatin1()) { - case 'a': - case 'b': - case 'e': - case 'f': - case 'n': - case 'r': - case 't': - case 'v': - case '\'': - case '"': - case '\\': - case '\?': - //2 because we have to highlight \ as well as the following char - len = 2; - break; - //octal esc sequence \123 - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - { - if (i + 4 <= text.length()) { - bool isCurrentOctal = true; - if (!isOctal(text.at(i+2).toLatin1())) { - isCurrentOctal = false; - break; - } - if (!isOctal(text.at(i+3).toLatin1())) { - isCurrentOctal = false; - break; - } - len = isCurrentOctal ? 4 : 0; - } - break; - } - //hex numbers \xFA - case 'x': - { - if (i + 3 <= text.length()) { - bool isCurrentHex = true; - if (!isHex(text.at(i+2).toLatin1())) { - isCurrentHex = false; - break; - } - if (!isHex(text.at(i+3).toLatin1())) { - isCurrentHex = false; - break; - } - len = isCurrentHex ? 4 : 0; - } - break; - } - //TODO: implement unicode code point escaping - default: - break; - } - - //if len is zero, that means this wasn't an esc seq - //increment i so that we skip this backslash - if (len == 0) { - setFormat(i, 1, _formats[CodeString]); - ++i; - continue; - } - - setFormat(i, len, _formats[CodeNumLiteral]); - i += len; - continue; - } - setFormat(i, 1, _formats[CodeString]); - ++i; - } - return i; -} - -/** - * @brief Highlight number literals in code - * @param text the text being scanned - * @param i pos of i in loop - * @return pos of i after the number - */ -int QSourceHighliter::highlightNumericLiterals(const QString &text, int i) -{ - bool isPreAllowed = false; - if (i == 0) isPreAllowed = true; - else { - //these values are allowed before a number - switch(text.at(i - 1).toLatin1()) { - //css number - case ':': - if (currentBlockState() == CodeCSS) - isPreAllowed = true; - break; - case '$': - if (currentBlockState() == CodeAsm) - isPreAllowed = true; - break; - case '[': - case '(': - case '{': - case ' ': - case ',': - case '=': - case '+': - case '-': - case '*': - case '/': - case '%': - case '<': - case '>': - isPreAllowed = true; - break; - } - } - - if (!isPreAllowed) return i; - - const int start = i; - - if ((i+1) >= text.length()) { - setFormat(i, 1, _formats[CodeNumLiteral]); - return ++i; - } - - ++i; - //hex numbers highlighting (only if there's a preceding zero) - if (text.at(i) == QChar('x') && text.at(i - 1) == QChar('0')) - ++i; - - while (i < text.length()) { - if (!text.at(i).isNumber() && text.at(i) != QChar('.') && - text.at(i) != QChar('e')) //exponent - break; - ++i; - } - - bool isPostAllowed = false; - if (i == text.length()) { - //cant have e at the end - if (text.at(i - 1) != QChar('e')) - isPostAllowed = true; - } else { - //these values are allowed after a number - switch(text.at(i).toLatin1()) { - case ']': - case ')': - case '}': - case ' ': - case ',': - case '=': - case '+': - case '-': - case '*': - case '/': - case '%': - case '>': - case '<': - case ';': - isPostAllowed = true; - break; - // for 100u, 1.0F - case 'p': - if (currentBlockState() == CodeCSS) - if (i + 1 < text.length() && text.at(i+1) == QChar('x')) { - if (i + 2 == text.length() || !text.at(i+2).isLetterOrNumber()) - isPostAllowed = true; - } - break; - case 'e': - if (currentBlockState() == CodeCSS) - if (i + 1 < text.length() && text.at(i+1) == QChar('m')) { - if (i + 2 == text.length() || !text.at(i+2).isLetterOrNumber()) - isPostAllowed = true; - } - break; - case 'u': - case 'l': - case 'f': - case 'U': - case 'L': - case 'F': - if (i + 1 == text.length() || !text.at(i+1).isLetterOrNumber()) { - isPostAllowed = true; - ++i; - } - break; - } - } - if (isPostAllowed) { - int end = i; - setFormat(start, end - start, _formats[CodeNumLiteral]); - } - //decrement so that the index is at the last number, not after it - return --i; -} - -/** - * @brief The YAML highlighter - * @param text - * @details This function post processes a line after the main syntax - * highlighter has run for additional highlighting. It does these things - * - * If the current line is a comment, skip it - * - * Highlight all the words that have a colon after them as 'keyword' except: - * If the word is a string, skip it. - * If the colon is in between a path, skip it (C:\) - * - * Once the colon is found, the function will skip every character except 'h' - * - * If an h letter is found, check the next 4/5 letters for http/https and - * highlight them as a link (underlined) - */ -void QSourceHighliter::ymlHighlighter(const QString &text) { - if (text.isEmpty()) return; - const auto textLen = text.length(); - bool colonNotFound = false; - - //if this is a comment don't do anything and just return - if (text.trimmed().at(0) == QLatin1Char('#')) - return; - - for (int i = 0; i < textLen; ++i) { - if (!text.at(i).isLetter()) continue; - - if (colonNotFound && text.at(i) != QLatin1Char('h')) continue; - - //we found a string literal, skip it - if (i != 0 && (text.at(i-1) == QLatin1Char('"') || text.at(i-1) == QLatin1Char('\''))) { - const int next = text.indexOf(text.at(i-1), i); - if (next == -1) break; - i = next; - continue; - } - - const int colon = text.indexOf(QLatin1Char(':'), i); - - //if colon isn't found, we set this true - if (colon == -1) colonNotFound = true; - - if (!colonNotFound) { - //if the line ends here, format and return - if (colon+1 == textLen) { - setFormat(i, colon - i, _formats[CodeKeyWord]); - return; - } else { - //colon is found, check if it isn't some path or something else - if (!(text.at(colon+1) == QLatin1Char('\\') && text.at(colon+1) == QLatin1Char('/'))) { - setFormat(i, colon - i, _formats[CodeKeyWord]); - } - } - } - - //underlined links - if (text.at(i) == QLatin1Char('h')) { - if (strMidRef(text, i, 5) == QLatin1String("https") || - strMidRef(text, i, 4) == QLatin1String("http")) { - int space = text.indexOf(QChar(' '), i); - if (space == -1) space = textLen; - QTextCharFormat f = _formats[CodeString]; - f.setUnderlineStyle(QTextCharFormat::SingleUnderline); - setFormat(i, space - i, f); - i = space; - } - } - } -} - -void QSourceHighliter::cssHighlighter(const QString &text) -{ - if (text.isEmpty()) return; - const auto textLen = text.length(); - for (int i = 0; i= textLen) return; - if (text[i + 1].isSpace() || text[i+1].isNumber()) continue; - int space = text.indexOf(QLatin1Char(' '), i); - if (space < 0) { - space = text.indexOf('{'); - if (space < 0) { - space = textLen; - } - } - setFormat(i, space - i, _formats[CodeKeyWord]); - i = space; - } else if (text[i] == QLatin1Char('c')) { - if (strMidRef(text, i, 5) == QLatin1String("color")) { - i += 5; - int colon = text.indexOf(QLatin1Char(':'), i); - if (colon < 0) continue; - i = colon; - i++; - while(i < textLen) { - if (!text[i].isSpace()) break; - i++; - } - int semicolon = text.indexOf(QLatin1Char(';')); - if (semicolon < 0) semicolon = textLen; - const QString color = text.mid(i, semicolon-i); - QTextCharFormat f = _formats[CodeBlock]; - QColor c(color); - if (color.startsWith(QLatin1String("rgb"))) { - int t = text.indexOf(QLatin1Char('('), i); - int rPos = text.indexOf(QLatin1Char(','), t); - int gPos = text.indexOf(QLatin1Char(','), rPos+1); - int bPos = text.indexOf(QLatin1Char(')'), gPos); - if (rPos > -1 && gPos > -1 && bPos > -1) { - const auto r = strMidRef(text, t+1, rPos - (t+1)); - const auto g = strMidRef(text, rPos+1, gPos - (rPos + 1)); - const auto b = strMidRef(text, gPos+1, bPos - (gPos+1)); - c.setRgb(r.toInt(), g.toInt(), b.toInt()); - } else { - c = _formats[CodeBlock].background().color(); - } - } - - if (!c.isValid()) { - continue; - } - - int lightness{}; - QColor foreground; - //really dark - if (c.lightness() <= 20) { - foreground = Qt::white; - } else if (c.lightness() > 20 && c.lightness() <= 51){ - foreground = QColor("#ccc"); - } else if (c.lightness() > 51 && c.lightness() <= 78){ - foreground = QColor("#bbb"); - } else if (c.lightness() > 78 && c.lightness() <= 110){ - foreground = QColor("#bbb"); - } else if (c.lightness() > 127) { - lightness = c.lightness() + 100; - foreground = c.darker(lightness); - } - else { - lightness = c.lightness() + 100; - foreground = c.lighter(lightness); - } - - f.setBackground(c); - f.setForeground(foreground); - setFormat(i, semicolon - i, QTextCharFormat()); //clear prev format - setFormat(i, semicolon - i, f); - i = semicolon; - } - } - } -} - - -void QSourceHighliter::xmlHighlighter(const QString &text) { - if (text.isEmpty()) return; - const auto textLen = text.length(); - - setFormat(0, textLen, _formats[CodeBlock]); - - for (int i = 0; i < textLen; ++i) { - if (text[i] == QLatin1Char('<') && text[i+1] != QLatin1Char('!')) { - - const int found = text.indexOf(QLatin1Char('>'), i); - if (found > 0) { - ++i; - if (text[i] == QLatin1Char('/')) ++i; - setFormat(i, found - i, _formats[CodeKeyWord]); - } - } - - if (text[i] == QLatin1Char('=')) { - int lastSpace = text.lastIndexOf(QLatin1Char(' '), i); - if (lastSpace == i-1) lastSpace = text.lastIndexOf(QLatin1Char(' '), i-2); - if (lastSpace > 0) { - setFormat(lastSpace, i - lastSpace, _formats[CodeBuiltIn]); - } - } - - if (text[i] == QLatin1Char('\"')) { - const int pos = i; - int cnt = 1; - ++i; - //bound check - if ( (i+1) >= textLen) return; - while (i < textLen) { - if (text[i] == QLatin1Char('\"')) { - ++cnt; - ++i; - break; - } - ++i; ++cnt; - //bound check - if ( (i+1) >= textLen) { - ++cnt; - break; - } - } - setFormat(pos, cnt, _formats[CodeString]); - } - } -} - -void QSourceHighliter::makeHighlighter(const QString &text) -{ - int colonPos = text.indexOf(QLatin1Char(':')); - if (colonPos == -1) - return; - setFormat(0, colonPos, _formats[Token::CodeBuiltIn]); -} - -/** - * @brief highlight inline labels such as 'func()' in "call func()" - * @param text - */ -void QSourceHighliter::highlightInlineAsmLabels(const QString &text) -{ -#define Q(s) QStringLiteral(s) - static const QString jumps[27] = { - //0 - 19 - Q("jmp"), Q("je"), Q("jne"), Q("jz"), Q("jnz"), Q("ja"), Q("jb"), Q("jg"), Q("jge"), Q("jae"), Q("jl"), Q("jle"), - Q("jbe"), Q("jo"), Q("jno"), Q("js"), Q("jns"), Q("jcxz"), Q("jecxz"), Q("jrcxz"), - //20 - 24 - Q("loop"), Q("loope"), Q("loopne"), Q("loopz"), Q("loopnz"), - //25 - 26 - Q("call"), Q("callq") - }; -#undef Q - - auto format = _formats[Token::CodeBuiltIn]; - format.setFontUnderline(true); - - const QString trimmed = text.trimmed(); - int start = -1; - int end = -1; - char c{}; - if (!trimmed.isEmpty()) - c = trimmed.at(0).toLatin1(); - if (c == 'j') { - start = 0; end = 20; - } else if (c == 'c') { - start = 25; end = 27; - } else if (c == 'l') { - start = 20; end = 25; - } else { - return; - } - - auto skipSpaces = [&text](int& j){ - while (text.at(j).isSpace()) j++; - return j; - }; - - for (int i = start; i < end; ++i) { - if (trimmed.startsWith(jumps[i])) { - int j = 0; - skipSpaces(j); - j = j + jumps[i].length() + 1; - skipSpaces(j); - int len = text.length() - j; - setFormat(j, len, format); - } - } -} - -void QSourceHighliter::asmHighlighter(const QString& text) -{ - highlightInlineAsmLabels(text); - //label highlighting - //examples: - //L1: - //LFB1: # local func begin - // - //following e.gs are not a label - //mov %eax, Count::count(%rip) - //.string ": #%s" - - //look for the last occurence of a colon - int colonPos = text.lastIndexOf(QLatin1Char(':')); - if (colonPos == -1) - return; - //check if this colon is in a comment maybe? - bool isComment = text.lastIndexOf('#', colonPos) != -1; - if (isComment) { - int commentPos = text.lastIndexOf('#', colonPos); - colonPos = text.lastIndexOf(':', commentPos); - } - - auto format = _formats[Token::CodeBuiltIn]; - format.setFontUnderline(true); - - if (colonPos >= text.length() - 1) { - setFormat(0, colonPos, format); - } - - int i = 0; - bool isLabel = true; - for (i = colonPos + 1; i < text.length(); ++i) { - if (!text.at(i).isSpace()) { - isLabel = false; - break; - } - } - - if (!isLabel && i < text.length() && text.at(i) == QLatin1Char('#')) - setFormat(0, colonPos, format); -} -} diff --git a/tools/fm-editor/fileview/syntaxHighlite/qsourcehighliter.h b/tools/fm-editor/fileview/syntaxHighlite/qsourcehighliter.h deleted file mode 100644 index 2008720e3..000000000 --- a/tools/fm-editor/fileview/syntaxHighlite/qsourcehighliter.h +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright (c) 2019-2020 Waqar Ahmed -- - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -#ifndef QSOURCEHIGHLITER_H -#define QSOURCEHIGHLITER_H - -#include - -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) -#include -#endif - -namespace QSourceHighlite { - -class QSourceHighliter : public QSyntaxHighlighter -{ -public: - enum Themes { - Monokai = 1 - }; - - explicit QSourceHighliter(QTextDocument *doc); - QSourceHighliter(QTextDocument *doc, Themes theme); - - //languages - /********* - * When adding a language make sure that its value is a multiple of 2 - * This is because we use the next number as comment for that language - * In case the language doesn't support multiline comments in the traditional C++ - * sense, leave the next value empty. Otherwise mark the next value as comment for - * that language. - * e.g - * CodeCpp = 200 - * CodeCppComment = 201 - */ - enum Language { - //languages - CodeCpp = 200, - CodeCppComment = 201, - CodeJs = 202, - CodeJsComment = 203, - CodeC = 204, - CodeCComment = 205, - CodeBash = 206, - CodePHP = 208, - CodePHPComment = 209, - CodeQML = 210, - CodeQMLComment = 211, - CodePython = 212, - CodeRust = 214, - CodeRustComment = 215, - CodeJava = 216, - CodeJavaComment = 217, - CodeCSharp = 218, - CodeCSharpComment = 219, - CodeGo = 220, - CodeGoComment = 221, - CodeV = 222, - CodeVComment = 223, - CodeSQL = 224, - CodeJSON = 226, - CodeXML = 228, - CodeCSS = 230, - CodeCSSComment = 231, - CodeTypeScript = 232, - CodeTypeScriptComment = 233, - CodeYAML = 234, - CodeINI = 236, - CodeVex = 238, - CodeVexComment = 239, - CodeCMake = 240, - CodeMake = 242, - CodeAsm = 244, - CodeLua = 246, - CodeLuaComment = 247 - }; - Q_ENUM(Language) - - enum Token { - CodeBlock, - CodeKeyWord, - CodeString, - CodeComment, - CodeType, - CodeOther, - CodeNumLiteral, - CodeBuiltIn, - }; - Q_ENUM(Token) - - void setCurrentLanguage(Language language); - Q_REQUIRED_RESULT Language currentLanguage(); - void setTheme(Themes theme); - -protected: - void highlightBlock(const QString &text) override; - -private: - void highlightSyntax(const QString &text); - Q_REQUIRED_RESULT int highlightNumericLiterals(const QString &text, int i); - Q_REQUIRED_RESULT int highlightStringLiterals(const QChar strType, const QString &text, int i); - - /** - * @brief returns true if c is octal - * @param c the char being checked - * @returns true if the number is octal, false otherwise - */ - Q_REQUIRED_RESULT static constexpr inline bool isOctal(const char c) { - return (c >= '0' && c <= '7'); - } - - /** - * @brief returns true if c is hex - * @param c the char being checked - * @returns true if the number is hex, false otherwise - */ - Q_REQUIRED_RESULT static constexpr inline bool isHex(const char c) { - return ( - (c >= '0' && c <= '9') || - (c >= 'a' && c <= 'f') || - (c >= 'A' && c <= 'F') - ); - } - - void cssHighlighter(const QString &text); - void ymlHighlighter(const QString &text); - void xmlHighlighter(const QString &text); - void makeHighlighter(const QString &text); - void highlightInlineAsmLabels(const QString& text); - void asmHighlighter(const QString& text); - void initFormats(); - -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - static inline QStringView strMidRef(const QString& str, qsizetype position, qsizetype n = -1) - { - return QStringView(str).mid(position, n); - } -#else - static inline QStringRef strMidRef(const QString& str, int position, int n = -1) - { - return str.midRef(position, n); - } -#endif - - QHash _formats; - Language _language; -}; -} -#endif // QSOURCEHIGHLITER_H diff --git a/tools/fm-editor/fileview/syntaxHighlite/qsourcehighliterthemes.cpp b/tools/fm-editor/fileview/syntaxHighlite/qsourcehighliterthemes.cpp deleted file mode 100644 index 5ba7a8b2b..000000000 --- a/tools/fm-editor/fileview/syntaxHighlite/qsourcehighliterthemes.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2019-2020 Waqar Ahmed -- - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -#include "qsourcehighliterthemes.h" - -namespace QSourceHighlite { - -static QHash formats() -{ - QHash _formats; - - QTextCharFormat defaultFormat = QTextCharFormat(); - - _formats[QSourceHighliter::Token::CodeBlock] = defaultFormat; - _formats[QSourceHighliter::Token::CodeKeyWord] = defaultFormat; - _formats[QSourceHighliter::Token::CodeString] = defaultFormat; - _formats[QSourceHighliter::Token::CodeComment] = defaultFormat; - _formats[QSourceHighliter::Token::CodeType] = defaultFormat; - _formats[QSourceHighliter::Token::CodeOther] = defaultFormat; - _formats[QSourceHighliter::Token::CodeNumLiteral] = defaultFormat; - _formats[QSourceHighliter::Token::CodeBuiltIn] = defaultFormat; - - return _formats; -} - -static QHash monokai() -{ - QHash _formats = formats(); - - _formats[QSourceHighliter::Token::CodeBlock].setForeground(QColor(227, 226, 214)); - _formats[QSourceHighliter::Token::CodeKeyWord].setForeground(QColor(249, 38, 114)); - _formats[QSourceHighliter::Token::CodeString].setForeground(QColor(230, 219, 116)); - _formats[QSourceHighliter::Token::CodeComment].setForeground(QColor(117, 113, 94)); - _formats[QSourceHighliter::Token::CodeType].setForeground(QColor(102, 217, 239)); - _formats[QSourceHighliter::Token::CodeOther].setForeground(QColor(249, 38, 114)); - _formats[QSourceHighliter::Token::CodeNumLiteral].setForeground(QColor(174, 129, 255)); - _formats[QSourceHighliter::Token::CodeBuiltIn].setForeground(QColor(166, 226, 46)); - - return _formats; -} - -QHash - QSourceHighliterTheme::theme(QSourceHighliter::Themes theme) { - switch (theme) { - case QSourceHighliter::Themes::Monokai: - return monokai(); - default: - return {}; - } -} - -} diff --git a/tools/fm-editor/fileview/syntaxHighlite/qsourcehighliterthemes.h b/tools/fm-editor/fileview/syntaxHighlite/qsourcehighliterthemes.h deleted file mode 100644 index eacabaec0..000000000 --- a/tools/fm-editor/fileview/syntaxHighlite/qsourcehighliterthemes.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2019-2020 Waqar Ahmed -- - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -#ifndef QSOURCEHIGHLITERTHEMES_H -#define QSOURCEHIGHLITERTHEMES_H - -#include "qsourcehighliter.h" - -namespace QSourceHighlite { - -namespace QSourceHighliterTheme -{ - QHash theme(QSourceHighliter::Themes); - -} // namespace QSourceHighliterTheme - -} // namespace QSourceHighlite -#endif // QSOURCEHIGHLITERTHEMES_H From 5e90a342c4568b0a51cc5fa906089d9a171cf47a Mon Sep 17 00:00:00 2001 From: Nerum Date: Thu, 23 Feb 2023 15:48:08 +0100 Subject: [PATCH 035/106] reformat --- tools/fm-editor/FeatureModelEditor.cpp | 9 +- tools/fm-editor/graph/FeatureEdge.cpp | 11 +- tools/fm-editor/graph/FeatureEdge.h | 5 +- tools/fm-editor/graph/FeatureModelGraph.cpp | 111 +++++++++-------- tools/fm-editor/graph/FeatureModelGraph.h | 25 ++-- tools/fm-editor/graph/FeatureNode.cpp | 54 ++++---- tools/fm-editor/graph/FeatureNode.h | 30 +++-- tools/fm-editor/tree/FeatureTreeItem.cpp | 93 ++++++++------ tools/fm-editor/tree/FeatureTreeItem.h | 116 +++++++++--------- tools/fm-editor/tree/FeatureTreeViewModel.cpp | 22 ++-- tools/fm-editor/tree/FeatureTreeViewModel.h | 52 ++++---- 11 files changed, 285 insertions(+), 243 deletions(-) diff --git a/tools/fm-editor/FeatureModelEditor.cpp b/tools/fm-editor/FeatureModelEditor.cpp index 43132ea63..a79caadb4 100644 --- a/tools/fm-editor/FeatureModelEditor.cpp +++ b/tools/fm-editor/FeatureModelEditor.cpp @@ -1,8 +1,8 @@ #include "FeatureModelEditor.h" #include "FeatureAddDialog.h" -#include "qsourcehighliter.h" #include "graph/FeatureModelGraph.h" #include "graph/FeatureNode.h" +#include "qsourcehighliter.h" #include "ui_FeatureModelEditor.h" #include "vara/Feature/FeatureModel.h" #include "vara/Feature/FeatureModelTransaction.h" @@ -86,9 +86,10 @@ void FeatureModelEditor::loadGraph() { // create Tree View buildTree(); - Ui->tabWidget->addTab(Graph.get(),"GraphView"); - Ui->tabWidget->addTab(TreeView,"TreeView"); - connect(Ui->sources,&QComboBox::currentTextChanged, this,&FeatureModelEditor::loadSource); + Ui->tabWidget->addTab(Graph.get(), "GraphView"); + Ui->tabWidget->addTab(TreeView, "TreeView"); + connect(Ui->sources, &QComboBox::currentTextChanged, this, + &FeatureModelEditor::loadSource); Ui->actionSave->setEnabled(true); Ui->actionAddFeature->setEnabled(true); } diff --git a/tools/fm-editor/graph/FeatureEdge.cpp b/tools/fm-editor/graph/FeatureEdge.cpp index d07a634c2..c5fb6b4d6 100644 --- a/tools/fm-editor/graph/FeatureEdge.cpp +++ b/tools/fm-editor/graph/FeatureEdge.cpp @@ -54,17 +54,18 @@ void FeatureEdge::paint(QPainter *Painter, QWidget *Widget) { if (!Source || !Target) { return; -} + } QLineF Line(SourcePoint, TargetPoint); if (qFuzzyCompare(Line.length(), qreal(0.))) { return; -} + } - Painter->setPen(QPen(Qt::black, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); + Painter->setPen( + QPen(Qt::black, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); Painter->drawLine(Line); - Painter->setBrush(QBrush(Target->isOptional()?Qt::white:Qt::black)); - Painter->drawEllipse(TargetPoint,4,4); + Painter->setBrush(QBrush(Target->isOptional() ? Qt::white : Qt::black)); + Painter->drawEllipse(TargetPoint, 4, 4); } void FeatureEdge::setSourceNode(FeatureNode *Node) { diff --git a/tools/fm-editor/graph/FeatureEdge.h b/tools/fm-editor/graph/FeatureEdge.h index abf682bc8..f67a52ac6 100644 --- a/tools/fm-editor/graph/FeatureEdge.h +++ b/tools/fm-editor/graph/FeatureEdge.h @@ -11,14 +11,15 @@ class FeatureEdge : public QGraphicsItem{ [[nodiscard]] FeatureNode *sourceNode() const; [[nodiscard]] FeatureNode *targetNode() const; - void setSourceNode(FeatureNode* Node); + void setSourceNode(FeatureNode *Node); void adjust(); enum { Type = UserType + 2 }; [[nodiscard]] int type() const override { return Type; } protected: QRectF boundingRect() const override; - void paint(QPainter *Painter, const QStyleOptionGraphicsItem *Option, QWidget *Widget) override; + void paint(QPainter *Painter, const QStyleOptionGraphicsItem *Option, + QWidget *Widget) override; private: FeatureNode *Source, *Target; diff --git a/tools/fm-editor/graph/FeatureModelGraph.cpp b/tools/fm-editor/graph/FeatureModelGraph.cpp index e6577854a..fd9f824ef 100644 --- a/tools/fm-editor/graph/FeatureModelGraph.cpp +++ b/tools/fm-editor/graph/FeatureModelGraph.cpp @@ -2,6 +2,7 @@ #include "vara/Feature/Feature.h" #include "vara/Feature/FeatureModel.h" #include "vara/Feature/FeatureModelTransaction.h" + #include #include @@ -9,9 +10,11 @@ using vara::feature::Feature; -FeatureModelGraph::FeatureModelGraph(vara::feature::FeatureModel * FeatureModel, +FeatureModelGraph::FeatureModelGraph(vara::feature::FeatureModel *FeatureModel, QWidget *Parent) - : QGraphicsView(Parent), EntryNode(new FeatureNode(FeatureModel->getRoot())), FeatureModel(FeatureModel) { + : QGraphicsView(Parent), + EntryNode(new FeatureNode(FeatureModel->getRoot())), + FeatureModel(FeatureModel) { auto *Scene = new QGraphicsScene(this); Scene->setItemIndexMethod(QGraphicsScene::NoIndex); @@ -22,20 +25,23 @@ FeatureModelGraph::FeatureModelGraph(vara::feature::FeatureModel * FeatureModel, setTransformationAnchor(AnchorUnderMouse); scale(qreal(0.8), qreal(0.8)); reload(); - Scene->setSceneRect(0, 0, EntryNode->childrenWidth()+100, 100*EntryNode->childrenDepth()+100); + Scene->setSceneRect(0, 0, EntryNode->childrenWidth() + 100, + 100 * EntryNode->childrenDepth() + 100); } -void FeatureModelGraph::reload(){ +void FeatureModelGraph::reload() { Nodes.push_back(std::unique_ptr(EntryNode)); auto *Scene = this->scene(); Scene->clear(); Scene->addItem(EntryNode); buildRec(EntryNode); - auto NextChildren =std::vector(EntryNode->children().size()); + auto NextChildren = std::vector(EntryNode->children().size()); auto CurrentChildren = EntryNode->children(); - std::transform(CurrentChildren.begin(),CurrentChildren.end(),NextChildren.begin(),[](FeatureEdge* Edge){return Edge->targetNode();}); - positionRec(1,NextChildren,5); - EntryNode->setPos(EntryNode->childrenWidth()/2,10); + std::transform(CurrentChildren.begin(), CurrentChildren.end(), + NextChildren.begin(), + [](FeatureEdge *Edge) { return Edge->targetNode(); }); + positionRec(1, NextChildren, 5); + EntryNode->setPos(EntryNode->childrenWidth() / 2, 10); } void FeatureModelGraph::buildRec(FeatureNode *CurrentFeatureNode) { @@ -49,36 +55,38 @@ void FeatureModelGraph::buildRec(FeatureNode *CurrentFeatureNode) { buildRec(Node.get()); Nodes.push_back(std::move(Node)); } - for (auto *Relation : - CurrentFeatureNode->getFeature()->getChildren( - 1)) { - for (auto *Feature :Relation->getChildren( - 1)) { - auto Node = std::make_unique(Feature); - auto *Edge = new FeatureEdge(CurrentFeatureNode, Node.get()); - scene()->addItem(Edge); - scene()->addItem(Node.get()); - buildRec(Node.get()); - Nodes.push_back(std::move(Node)); - } + for (auto *Relation : CurrentFeatureNode->getFeature() + ->getChildren(1)) { + for (auto *Feature : Relation->getChildren(1)) { + auto Node = std::make_unique(Feature); + auto *Edge = new FeatureEdge(CurrentFeatureNode, Node.get()); + scene()->addItem(Edge); + scene()->addItem(Node.get()); + buildRec(Node.get()); + Nodes.push_back(std::move(Node)); + } } } -int FeatureModelGraph::positionRec(const int CurrentDepth, const std::vector& Children, const unsigned long Offset){ - if(Children.empty()){ - return CurrentDepth-1; +int FeatureModelGraph::positionRec(const int CurrentDepth, + const std::vector &Children, + const unsigned long Offset) { + if (Children.empty()) { + return CurrentDepth - 1; } int MaxDepth = CurrentDepth; auto NextOffset = Offset; - for(FeatureNode* Node : Children){ - auto NextChildren =std::vector(Node->children().size()); + for (FeatureNode *Node : Children) { + auto NextChildren = std::vector(Node->children().size()); auto CurrentChildren = Node->children(); - std::transform(CurrentChildren.begin(),CurrentChildren.end(),NextChildren.begin(),[](FeatureEdge* Edge){return Edge->targetNode();}); - int const Depth = positionRec(CurrentDepth+1,NextChildren,NextOffset); - int Width = Node->childrenWidth()+5; - Node->setPos(NextOffset+Width/2,100*CurrentDepth); - NextOffset+=Width; - MaxDepth = MaxDepthtargetNode(); }); + int const Depth = positionRec(CurrentDepth + 1, NextChildren, NextOffset); + int Width = Node->childrenWidth() + 5; + Node->setPos(NextOffset + Width / 2, 100 * CurrentDepth); + NextOffset += Width; + MaxDepth = MaxDepth < Depth ? Depth : MaxDepth; } return MaxDepth; @@ -151,23 +159,27 @@ void FeatureModelGraph::zoomIn() { scaleView(qreal(1.2)); } void FeatureModelGraph::zoomOut() { scaleView(1 / qreal(1.2)); } -FeatureNode* FeatureModelGraph::addNode(Feature* Feature, FeatureNode* Parent) { +FeatureNode *FeatureModelGraph::addNode(Feature *Feature, FeatureNode *Parent) { auto NewNode = std::make_unique(Feature); - auto * NewEdge = new FeatureEdge(Parent,NewNode.get()); + auto *NewEdge = new FeatureEdge(Parent, NewNode.get()); scene()->addItem(NewEdge); scene()->addItem(NewNode.get()); auto NewNodeRaw = NewNode.get(); Nodes.push_back(std::move(NewNode)); - auto NextChildren =std::vector(EntryNode->children().size()); + auto NextChildren = std::vector(EntryNode->children().size()); auto CurrentChildren = EntryNode->children(); - std::transform(CurrentChildren.begin(),CurrentChildren.end(),NextChildren.begin(),[](FeatureEdge* Edge){return Edge->targetNode();}); - positionRec(1,NextChildren,5); - EntryNode->setPos(EntryNode->childrenWidth()/2,10); + std::transform(CurrentChildren.begin(), CurrentChildren.end(), + NextChildren.begin(), + [](FeatureEdge *Edge) { return Edge->targetNode(); }); + positionRec(1, NextChildren, 5); + EntryNode->setPos(EntryNode->childrenWidth() / 2, 10); return NewNodeRaw; } -FeatureNode* FeatureModelGraph::getNode(std::string Name) { - auto It = std::find_if(Nodes.begin(),Nodes.end(),[&Name](auto const &Node){return Node->getName() == Name;}); +FeatureNode *FeatureModelGraph::getNode(std::string Name) { + auto It = std::find_if(Nodes.begin(), Nodes.end(), [&Name](auto const &Node) { + return Node->getName() == Name; + }); if (It != Nodes.end()) { return It->get(); } @@ -175,28 +187,29 @@ FeatureNode* FeatureModelGraph::getNode(std::string Name) { return nullptr; } -void FeatureModelGraph::deleteNode(bool Recursive, FeatureNode* Node) { +void FeatureModelGraph::deleteNode(bool Recursive, FeatureNode *Node) { auto *Parent = Node->parent()->sourceNode(); - if(!Recursive){ - for(auto *Child: Node->children()){ - Child->setSourceNode(Parent); + if (!Recursive) { + for (auto *Child : Node->children()) { + Child->setSourceNode(Parent); } Node->children().clear(); - }else { - for(auto *Child: Node->children()){ - deleteNode(true,Child->targetNode()); + } else { + for (auto *Child : Node->children()) { + deleteNode(true, Child->targetNode()); } } Parent->removeChild(Node); scene()->removeItem(Node); scene()->removeItem(Node->parent()); - Nodes.erase(std::find_if(Nodes.begin(), Nodes.end(),[Node](auto &N){return N.get() == Node;})); + Nodes.erase(std::find_if(Nodes.begin(), Nodes.end(), + [Node](auto &N) { return N.get() == Node; })); } void FeatureModelGraph::deleteNode(bool Recursive, vara::feature::Feature *Feature) { - auto * Node = getNode(Feature->getName().str()); - deleteNode(Recursive,Node); + auto *Node = getNode(Feature->getName().str()); + deleteNode(Recursive, Node); } diff --git a/tools/fm-editor/graph/FeatureModelGraph.h b/tools/fm-editor/graph/FeatureModelGraph.h index f222d7c18..ca76027c3 100644 --- a/tools/fm-editor/graph/FeatureModelGraph.h +++ b/tools/fm-editor/graph/FeatureModelGraph.h @@ -1,25 +1,23 @@ #ifndef VARA_FEATURE_FEATUREMODELGRAPH_H #define VARA_FEATURE_FEATUREMODELGRAPH_H -#include "vara/Feature/FeatureModel.h" -#include "FeatureNode.h" #include "FeatureEdge.h" +#include "FeatureNode.h" +#include "vara/Feature/FeatureModel.h" #include - class FeatureModelGraph : public QGraphicsView { Q_OBJECT public: - FeatureModelGraph(vara::feature::FeatureModel * FeatureModel, + FeatureModelGraph(vara::feature::FeatureModel *FeatureModel, QWidget *Parent = nullptr); - auto getNodes() {return &Nodes;}; + auto getNodes() { return &Nodes; }; void itemMoved(); - FeatureNode* getNode(std::string Name); - FeatureNode*addNode(vara::feature::Feature *Feature,FeatureNode* Parent); - void deleteNode(bool Recursive, vara::feature::Feature* Feature); - void deleteNode(bool Recursive, FeatureNode* Node); - + FeatureNode *getNode(std::string Name); + FeatureNode *addNode(vara::feature::Feature *Feature, FeatureNode *Parent); + void deleteNode(bool Recursive, vara::feature::Feature *Feature); + void deleteNode(bool Recursive, FeatureNode *Node); public slots: void zoomIn(); void zoomOut(); @@ -39,9 +37,10 @@ public slots: void reload(); void buildRec(FeatureNode *CurrentFeatureNode); int TimerId = 0; - FeatureNode* EntryNode; - int positionRec(int CurrentDepth, const std::vector& Children,unsigned long Offset); - vara::feature::FeatureModel* FeatureModel; + FeatureNode *EntryNode; + int positionRec(int CurrentDepth, const std::vector &Children, + unsigned long Offset); + vara::feature::FeatureModel *FeatureModel; std::vector> Nodes; }; diff --git a/tools/fm-editor/graph/FeatureNode.cpp b/tools/fm-editor/graph/FeatureNode.cpp index 22f5ec3c9..9fe162a50 100644 --- a/tools/fm-editor/graph/FeatureNode.cpp +++ b/tools/fm-editor/graph/FeatureNode.cpp @@ -4,9 +4,9 @@ #include #include +#include #include #include -#include FeatureNode::FeatureNode(vara::feature::Feature *Feature) : Feature(Feature) { setFlag(ItemIsMovable); @@ -25,13 +25,9 @@ void FeatureNode::setParentEdge(FeatureEdge *Edge) { Edge->adjust(); } -std::vector FeatureNode::children() { - return ChildEdges; -} +std::vector FeatureNode::children() { return ChildEdges; } -FeatureEdge * FeatureNode::parent() { - return ParentEdge; -} +FeatureEdge *FeatureNode::parent() { return ParentEdge; } QRectF FeatureNode::boundingRect() const { qreal Adjust = 2; @@ -61,7 +57,7 @@ void FeatureNode::paint(QPainter *Painter, int W = width(); Painter->drawRect(-W / 2, -10, W, 20); Painter->setPen(QPen(Qt::black, 1)); - Painter->drawText(-W/2+5, 5, Name); + Painter->drawText(-W / 2 + 5, 5, Name); } QVariant FeatureNode::itemChange(QGraphicsItem::GraphicsItemChange Change, @@ -82,9 +78,11 @@ QVariant FeatureNode::itemChange(QGraphicsItem::GraphicsItemChange Change, return QGraphicsItem::itemChange(Change, Value); } -void FeatureNode::removeChild(FeatureNode* Child){ - auto EdgePos = std::find_if(ChildEdges.begin(), ChildEdges.end(), [Child](auto *Edge){return Edge->targetNode()==Child;}); - if(EdgePos!=ChildEdges.end()){ +void FeatureNode::removeChild(FeatureNode *Child) { + auto EdgePos = + std::find_if(ChildEdges.begin(), ChildEdges.end(), + [Child](auto *Edge) { return Edge->targetNode() == Child; }); + if (EdgePos != ChildEdges.end()) { ChildEdges.erase(EdgePos); } } @@ -105,12 +103,9 @@ void FeatureNode::contextMenuEvent(QGraphicsSceneContextMenuEvent *Event) { auto *Inspect = new QAction("Inspect Sources", this); Menu->addAction(Inspect); Menu->popup(Event->screenPos()); - connect(Inspect, &QAction::triggered, - this, &FeatureNode::inspect); -} -void FeatureNode::inspect() { - emit(inspectSource(Feature)); + connect(Inspect, &QAction::triggered, this, &FeatureNode::inspect); } +void FeatureNode::inspect() { emit(inspectSource(Feature)); } int FeatureNode::width() const { auto Name = Feature->getName(); @@ -118,27 +113,26 @@ int FeatureNode::width() const { } int FeatureNode::childrenWidth() const { - if(ChildEdges.empty()){ + if (ChildEdges.empty()) { return width(); } int Result = 0; - for (auto *Child : ChildEdges){ - Result += Child->targetNode()->childrenWidth(); - } - - return std::max(Result,width()); + for (auto *Child : ChildEdges) { + Result += Child->targetNode()->childrenWidth(); + } + return std::max(Result, width()); } -int FeatureNode::childrenDepth() const{ - if(ChildEdges.empty()){ +int FeatureNode::childrenDepth() const { + if (ChildEdges.empty()) { return 1; } int MaxDepth = 0; - for(auto *Child: ChildEdges){ - int const ChildDepth = Child->targetNode()->childrenDepth(); - if(ChildDepth +1> MaxDepth){ - MaxDepth = ChildDepth +1; - } + for (auto *Child : ChildEdges) { + int const ChildDepth = Child->targetNode()->childrenDepth(); + if (ChildDepth + 1 > MaxDepth) { + MaxDepth = ChildDepth + 1; } - return MaxDepth; + } + return MaxDepth; } diff --git a/tools/fm-editor/graph/FeatureNode.h b/tools/fm-editor/graph/FeatureNode.h index 1e39fefe5..60ce3d85b 100644 --- a/tools/fm-editor/graph/FeatureNode.h +++ b/tools/fm-editor/graph/FeatureNode.h @@ -1,8 +1,8 @@ #ifndef VARA_FEATURE_FEATURENODE_H #define VARA_FEATURE_FEATURENODE_H -#include "vara/Feature/Feature.h" #include "FeatureNode.h" +#include "vara/Feature/Feature.h" #include #include @@ -16,41 +16,45 @@ class FeatureNode : public QObject, public QGraphicsItem { public: void removeChild(FeatureNode *Child); - FeatureNode( vara::feature::Feature *Feature); + FeatureNode(vara::feature::Feature *Feature); [[nodiscard]] int width() const; void addChildEdge(FeatureEdge *Edge); void setParentEdge(FeatureEdge *Edge); [[nodiscard]] std::vector children(); - [[nodiscard]] FeatureEdge * parent(); + [[nodiscard]] FeatureEdge *parent(); [[nodiscard]] int childrenWidth() const; [[nodiscard]] int childrenDepth() const; enum { Type = UserType + 1 }; [[nodiscard]] int type() const override { return Type; } - vara::feature::Feature* getFeature(){return Feature;}; + vara::feature::Feature *getFeature() { return Feature; }; [[nodiscard]] QRectF boundingRect() const override; [[nodiscard]] QPainterPath shape() const override; - void paint(QPainter *Painter, const QStyleOptionGraphicsItem *Option, QWidget *Widget) override; - bool isOptional() {return Feature->isOptional();} + void paint(QPainter *Painter, const QStyleOptionGraphicsItem *Option, + QWidget *Widget) override; + bool isOptional() { return Feature->isOptional(); } [[nodiscard]] QString getQName() const { return QString::fromStdString(Feature->getName().str()); }; - [[nodiscard]] std::string getName() const {return Feature->getName().str();}; - ~FeatureNode() {std::destroy(ChildEdges.begin(), ChildEdges.end());} - + [[nodiscard]] std::string getName() const { + return Feature->getName().str(); + }; + ~FeatureNode() { std::destroy(ChildEdges.begin(), ChildEdges.end()); } + signals: void clicked(const vara::feature::Feature *Feature); void inspectSource(vara::feature::Feature *Feature); - + protected: - QVariant itemChange(GraphicsItemChange Change, const QVariant &Value) override; + QVariant itemChange(GraphicsItemChange Change, + const QVariant &Value) override; void mousePressEvent(QGraphicsSceneMouseEvent *Event) override; void mouseReleaseEvent(QGraphicsSceneMouseEvent *Event) override; void contextMenuEvent(QGraphicsSceneContextMenuEvent *Event) override; - + private: std::vector ChildEdges; - FeatureEdge * ParentEdge = nullptr; + FeatureEdge *ParentEdge = nullptr; vara::feature::Feature *Feature; void inspect(); diff --git a/tools/fm-editor/tree/FeatureTreeItem.cpp b/tools/fm-editor/tree/FeatureTreeItem.cpp index 9529ac911..730b2ff00 100644 --- a/tools/fm-editor/tree/FeatureTreeItem.cpp +++ b/tools/fm-editor/tree/FeatureTreeItem.cpp @@ -5,29 +5,33 @@ #include -QVariant numericValue(vara::feature::Feature* Item) { - if(Item->getKind()==vara::feature::Feature::FeatureKind::FK_NUMERIC){ - auto *NumItem = dynamic_cast(Item); - string Result ="["; - if(std::holds_alternative(NumItem->getValues())){ - auto range = std::get(NumItem->getValues()); - Result+= std::to_string(range.first) +", "+std::to_string(range.second) + "]"; +QVariant numericValue(vara::feature::Feature *Item) { + if (Item->getKind() == vara::feature::Feature::FeatureKind::FK_NUMERIC) { + auto *NumItem = dynamic_cast(Item); + string Result = "["; + if (std::holds_alternative( + NumItem->getValues())) { + auto range = std::get( + NumItem->getValues()); + Result += std::to_string(range.first) + ", " + + std::to_string(range.second) + "]"; } else { - auto Range = std::get(NumItem->getValues()); - for(auto It = Range.begin();It!=Range.end();It++){ - if(It!=Range.begin()){ - Result+=","; + auto Range = std::get( + NumItem->getValues()); + for (auto It = Range.begin(); It != Range.end(); It++) { + if (It != Range.begin()) { + Result += ","; } - Result+=std::to_string(*It.base()); + Result += std::to_string(*It.base()); } - Result+="]"; + Result += "]"; } - return QString::fromStdString(Result); + return QString::fromStdString(Result); } return {}; } -QVariant locationString(vara::feature::Feature* Item){ +QVariant locationString(vara::feature::Feature *Item) { auto Locs = Item->getLocations(); std::stringstream StrS; if (Item->hasLocations()) { @@ -44,13 +48,23 @@ FeatureTreeItem* FeatureTreeItem::createFeatureTreeItem( vara::feature::FeatureTreeNode *Item) { if(Item->getKind() == vara::feature::FeatureTreeNode::NodeKind::NK_RELATIONSHIP){ return new FeatureTreeItemRelation(dynamic_cast(Item)); +FeatureTreeItem * +FeatureTreeItem::createFeatureTreeItem(vara::feature::FeatureTreeNode *Item) { + if (Item->getKind() == + vara::feature::FeatureTreeNode::NodeKind::NK_RELATIONSHIP) { + return new FeatureTreeItemRelation( + dynamic_cast(Item)); } + return new FeatureTreeItemFeature( + dynamic_cast(Item)); return new FeatureTreeItemFeature(dynamic_cast(Item)); } -void FeatureTreeItem::addChild(FeatureTreeItem* Child) { - if(!Children.empty() && Children[0]->getKind()==vara::feature::FeatureTreeNode::NodeKind::NK_RELATIONSHIP){ +void FeatureTreeItem::addChild(FeatureTreeItem *Child) { + if (!Children.empty() && + Children[0]->getKind() == + vara::feature::FeatureTreeNode::NodeKind::NK_RELATIONSHIP) { Children[0]->addChild(Child); } else { Children.push_back(Child); @@ -59,48 +73,47 @@ void FeatureTreeItem::addChild(FeatureTreeItem* Child) { } std::vector FeatureTreeItem::getChildrenRecursive() { - auto Nodes = std::vector{Children}; - for(auto Child: Children){ + auto Nodes = std::vector{Children}; + for (auto Child : Children) { auto ChildNodes = Child->getChildrenRecursive(); - Nodes.insert(Nodes.end(),ChildNodes.begin(), ChildNodes.end()); + Nodes.insert(Nodes.end(), ChildNodes.begin(), ChildNodes.end()); } return Nodes; } QVariant FeatureTreeItemFeature::data(int Column) const { switch (Column) { - case 0: return QString::fromStdString(Item->getName().str()); - case 1: return Item->isOptional()? QVariant("✓"):QVariant("x"); - case 2: return numericValue(Item); - case 3: return locationString(Item); - case 4: return QString::fromStdString(Item->getOutputString().str()); + case 0: + return QString::fromStdString(Item->getName().str()); + case 1: + return Item->isOptional() ? QVariant("✓") : QVariant("x"); + case 2: + return numericValue(Item); + case 3: + return locationString(Item); + case 4: + return QString::fromStdString(Item->getOutputString().str()); default: return {}; } } -void FeatureTreeItemFeature::inspect() { - emit(inspectSource(Item)); -} +void FeatureTreeItemFeature::inspect() { emit(inspectSource(Item)); } void FeatureTreeItemFeature::contextMenu(QPoint Pos) { - auto* Menu =buildMenu(this, - std::pair(QString("Inspect Sources"),&FeatureTreeItemFeature::inspect), - std::pair(QString("Add Child"),&FeatureTreeItemFeature::addChild), - std::pair(QString("Remove"),&FeatureTreeItemFeature::remove)); - //TODO Make recursive Removal work + auto *Menu = buildMenu( + this, + std::pair(QString("Inspect Sources"), &FeatureTreeItemFeature::inspect), + std::pair(QString("Add Child"), &FeatureTreeItemFeature::addChild), + std::pair(QString("Remove"), &FeatureTreeItemFeature::remove)); + // TODO Make recursive Removal work Menu->popup(Pos); } - -void FeatureTreeItemFeature::remove() { - emit(removeFeature(false,Item)); -} +void FeatureTreeItemFeature::remove() { emit(removeFeature(false, Item)); } void FeatureTreeItemFeature::removeRecursive() { emit(removeFeature(true, Item)); } -void FeatureTreeItemFeature::addChild() { - emit(addChildFeature(Item)); -} +void FeatureTreeItemFeature::addChild() { emit(addChildFeature(Item)); } diff --git a/tools/fm-editor/tree/FeatureTreeItem.h b/tools/fm-editor/tree/FeatureTreeItem.h index 1e617da6c..f2fe2d010 100644 --- a/tools/fm-editor/tree/FeatureTreeItem.h +++ b/tools/fm-editor/tree/FeatureTreeItem.h @@ -6,107 +6,115 @@ #include #include #include -class FeatureTreeItem: public QObject { +class FeatureTreeItem : public QObject { Q_OBJECT public: FeatureTreeItem *child(int Row) { - if(Row<0||Row>Children.size()) { + if (Row < 0 || Row > Children.size()) { return nullptr; } return Children[Row]; } - int childCount() { - return Children.size(); - } + int childCount() { return Children.size(); } std::vector getChildrenRecursive(); int row() { - if(Parent) { - auto pos =std::find(Parent->Children.begin(), Parent->Children.end(), this); - if ( pos!=Parent->Children.end()){ - return pos-Parent->Children.begin(); + if (Parent) { + auto pos = + std::find(Parent->Children.begin(), Parent->Children.end(), this); + if (pos != Parent->Children.end()) { + return pos - Parent->Children.begin(); } } return 0; } - FeatureTreeItem* parent() { - return Parent; - } - void addChild(FeatureTreeItem* Child); - std::vector& getChildren() {return Children;} + FeatureTreeItem *parent() { return Parent; } + void addChild(FeatureTreeItem *Child); + std::vector &getChildren() { return Children; } [[nodiscard]] virtual int columnCount() const = 0; [[nodiscard]] virtual QVariant data(int Column) const = 0; - FeatureTreeItem static *createFeatureTreeItem(vara::feature::FeatureTreeNode* Item); - static bool booleanColumn(int Column) {return false;} + FeatureTreeItem static * + createFeatureTreeItem(vara::feature::FeatureTreeNode *Item); + static bool booleanColumn(int Column) { return false; } virtual void contextMenu(QPoint Pos) = 0; - vara::feature::FeatureTreeNode::NodeKind getKind() {return Kind;} - virtual string getName() {return "";}; - void setParent(FeatureTreeItem*ParentItem) {this->Parent = ParentItem;} + vara::feature::FeatureTreeNode::NodeKind getKind() { return Kind; } + virtual string getName() { return ""; }; + void setParent(FeatureTreeItem *ParentItem) { this->Parent = ParentItem; } signals: void inspectSource(vara::feature::Feature *Feature); void addChildFeature(vara::feature::Feature *Feature); - void removeFeature(bool Recursive,vara::feature::Feature *Feature); + void removeFeature(bool Recursive, vara::feature::Feature *Feature); + protected: - FeatureTreeItem(vara::feature::FeatureTreeNode* Item ,vara::feature::FeatureTreeNode::NodeKind Kind): Kind(Kind) { - for(auto *Child : Item->children()){ - if(vara::feature::Relationship::classof(Child)) { - auto child = createFeatureTreeItem(dynamic_cast(Child)); + FeatureTreeItem(vara::feature::FeatureTreeNode *Item, + vara::feature::FeatureTreeNode::NodeKind Kind) + : Kind(Kind) { + for (auto *Child : Item->children()) { + if (vara::feature::Relationship::classof(Child)) { + auto child = createFeatureTreeItem( + dynamic_cast(Child)); Children.push_back(child); child->setParent(this); - }else { - auto child = createFeatureTreeItem(dynamic_cast(Child)); + } else { + auto child = createFeatureTreeItem( + dynamic_cast(Child)); Children.push_back(child); child->setParent(this); } } } - FeatureTreeItem* Parent = nullptr; + FeatureTreeItem *Parent = nullptr; - std::vector Children = {}; + std::vector Children = {}; private: const vara::feature::FeatureTreeNode::NodeKind Kind; }; - -class FeatureTreeItemFeature: public FeatureTreeItem{ +class FeatureTreeItemFeature : public FeatureTreeItem { Q_OBJECT public: -virtual ~FeatureTreeItemFeature() = default; - FeatureTreeItemFeature(vara::feature::Feature* Item): FeatureTreeItem(Item,vara::feature::FeatureTreeNode::NodeKind::NK_FEATURE), Item(Item) {} + virtual ~FeatureTreeItemFeature() = default; + FeatureTreeItemFeature(vara::feature::Feature *Item) + : FeatureTreeItem(Item, + vara::feature::FeatureTreeNode::NodeKind::NK_FEATURE), + Item(Item) {} [[nodiscard]] QVariant data(int Column) const override; - [[nodiscard]] int columnCount() const override {return 5;} - static bool booleanColumn(int Column) {return Column==1;} + [[nodiscard]] int columnCount() const override { return 5; } + static bool booleanColumn(int Column) { return Column == 1; } void contextMenu(QPoint Pos) override; - const vara::feature::Feature* getItem() const {return Item;} - string getName() override {return Item->getName().str();} + const vara::feature::Feature *getItem() const { return Item; } + string getName() override { return Item->getName().str(); } public slots: void inspect(); void addChild(); void removeRecursive(); void remove(); -private: - vara::feature::Feature* Item; - +private: + vara::feature::Feature *Item; }; - -class FeatureTreeItemRelation: public FeatureTreeItem { +class FeatureTreeItemRelation : public FeatureTreeItem { public: -virtual ~FeatureTreeItemRelation() = default; -FeatureTreeItemRelation(vara::feature::Relationship* Item): FeatureTreeItem(Item,vara::feature::FeatureTreeNode::NodeKind::NK_RELATIONSHIP),Item(Item) {} -[[nodiscard]] QVariant data(int Column) const override{ - if(Column==0) { - return QString::fromStdString(relationType()); -} -return {}; -} -[[nodiscard]] int columnCount() const override {return 1;} -void contextMenu(QPoint Pos) override{} + virtual ~FeatureTreeItemRelation() = default; + FeatureTreeItemRelation(vara::feature::Relationship *Item) + : FeatureTreeItem( + Item, vara::feature::FeatureTreeNode::NodeKind::NK_RELATIONSHIP), + Item(Item) {} + [[nodiscard]] QVariant data(int Column) const override { + if (Column == 0) { + return QString::fromStdString(relationType()); + } + return {}; + } + [[nodiscard]] int columnCount() const override { return 1; } + void contextMenu(QPoint Pos) override {} + private: - vara::feature::Relationship* Item; - static const vara::feature::FeatureTreeNode::NodeKind Kind = vara::feature::FeatureTreeNode::NodeKind::NK_RELATIONSHIP; + vara::feature::Relationship *Item; + static const vara::feature::FeatureTreeNode::NodeKind Kind = + vara::feature::FeatureTreeNode::NodeKind::NK_RELATIONSHIP; [[nodiscard]] std::string relationType() const { std::string Type; switch (Item->getKind()) { @@ -122,6 +130,4 @@ void contextMenu(QPoint Pos) override{} } }; - - #endif // VARA_FEATURE_FEATURETREEITEM_H diff --git a/tools/fm-editor/tree/FeatureTreeViewModel.cpp b/tools/fm-editor/tree/FeatureTreeViewModel.cpp index c6d0db889..1172cb95c 100644 --- a/tools/fm-editor/tree/FeatureTreeViewModel.cpp +++ b/tools/fm-editor/tree/FeatureTreeViewModel.cpp @@ -11,9 +11,10 @@ QModelIndex FeatureTreeViewModel::index(int Row, int Column, if (!Parent.isValid()) { ParentItem = RootItem; } else { - ParentItem = static_cast(Parent.internalPointer())->child(Parent.row()); + ParentItem = static_cast(Parent.internalPointer()) + ->child(Parent.row()); } - if(ParentItem->childCount() <=0){ + if (ParentItem->childCount() <= 0) { return {}; } auto *ChildItem = ParentItem->child(Row); @@ -41,13 +42,15 @@ int FeatureTreeViewModel::rowCount(const QModelIndex &Parent) const { if (!Parent.isValid()) { ParentItem = RootItem; } else { - ParentItem = static_cast(Parent.internalPointer())->child(Parent.row()); + ParentItem = static_cast(Parent.internalPointer()) + ->child(Parent.row()); } return ParentItem->childCount(); } int FeatureTreeViewModel::columnCount(const QModelIndex &Parent) const { if (Parent.isValid()) { - auto Item = static_cast(Parent.internalPointer())->child(Parent.row()); + auto Item = static_cast(Parent.internalPointer()) + ->child(Parent.row()); return Item->columnCount(); } return RootItem->columnCount(); @@ -56,12 +59,14 @@ QVariant FeatureTreeViewModel::data(const QModelIndex &Index, int Role) const { if (!Index.isValid() || Role != Qt::DisplayRole) { return {}; } - auto *Item = static_cast(Index.internalPointer())->child(Index.row()); + auto *Item = static_cast(Index.internalPointer()) + ->child(Index.row()); return Item->data(Index.column()); } Qt::ItemFlags FeatureTreeViewModel::flags(const QModelIndex &Index) const { if (Index.isValid()) { - auto *Item = static_cast(Index.internalPointer())->child(Index.row()); + auto *Item = static_cast(Index.internalPointer()) + ->child(Index.row()); if (Item->booleanColumn(Index.column())) { return Qt::ItemIsUserCheckable | Qt::ItemIsSelectable | Qt::ItemIsEnabled; } @@ -104,7 +109,7 @@ FeatureTreeViewModel::addFeature(vara::feature::Feature *Feature, Items.push_back(NewItem); return NewItem; } - + return nullptr; } @@ -113,7 +118,7 @@ void FeatureTreeViewModel::deleteFeatureItem(bool Recursive, emit(layoutAboutToBeChanged()); auto Item = getItem(Feature->getName().str()); if (Item) { - deleteItem(Recursive,Item); + deleteItem(Recursive, Item); } emit(layoutChanged()); } @@ -134,7 +139,6 @@ void FeatureTreeViewModel::deleteItem(bool Recursive, FeatureTreeItem *Item) { Parent->getChildren().erase(ItemPos); } } - Items.erase(std::find(Items.begin(), Items.end(), Item)); emit(layoutAboutToBeChanged()); delete Item; diff --git a/tools/fm-editor/tree/FeatureTreeViewModel.h b/tools/fm-editor/tree/FeatureTreeViewModel.h index 8d83b45ab..723036d0c 100644 --- a/tools/fm-editor/tree/FeatureTreeViewModel.h +++ b/tools/fm-editor/tree/FeatureTreeViewModel.h @@ -8,37 +8,43 @@ class FeatureTreeViewModel : public QAbstractItemModel { public: - FeatureTreeViewModel(vara::feature::FeatureModel* Model, QObject *Parent): QAbstractItemModel(Parent), Model(Model), RootItem(FeatureTreeItem::createFeatureTreeItem(Model->getRoot())) { + FeatureTreeViewModel(vara::feature::FeatureModel *Model, QObject *Parent) + : QAbstractItemModel(Parent), Model(Model), + RootItem(FeatureTreeItem::createFeatureTreeItem(Model->getRoot())) { Items = RootItem->getChildrenRecursive(); Items.push_back(RootItem); } - ~FeatureTreeViewModel() override{ - std::destroy(Items.begin(), Items.end()); - } - std::vector getItems(); - [[nodiscard]] QVariant data(const QModelIndex &Index, int Role = Qt::DisplayRole)const override; - [[nodiscard]] int rowCount(const QModelIndex &Parent = QModelIndex()) const override; - [[nodiscard]] QModelIndex index(int Row, int Column, const QModelIndex &Parent = QModelIndex()) const override; + ~FeatureTreeViewModel() override { std::destroy(Items.begin(), Items.end()); } + std::vector getItems(); + [[nodiscard]] QVariant data(const QModelIndex &Index, + int Role = Qt::DisplayRole) const override; + [[nodiscard]] int + rowCount(const QModelIndex &Parent = QModelIndex()) const override; + [[nodiscard]] QModelIndex + index(int Row, int Column, + const QModelIndex &Parent = QModelIndex()) const override; [[nodiscard]] QModelIndex parent(const QModelIndex &Child) const override; - [[nodiscard]] int columnCount(const QModelIndex &Parent = QModelIndex()) const override; + [[nodiscard]] int + columnCount(const QModelIndex &Parent = QModelIndex()) const override; [[nodiscard]] Qt::ItemFlags flags(const QModelIndex &Index) const override; - [[nodiscard]] QVariant headerData(int Section, Qt::Orientation Orientation, int Role = Qt::DisplayRole) const override; - FeatureTreeItem* addFeature(vara::feature::Feature* Item,string Parent); - void deleteFeatureItem(bool Recursive,vara::feature::Feature* Feature); - void deleteItem(bool Recursive, FeatureTreeItem* Item); - FeatureTreeItem* getItem(string Name) { - auto Item = std::find_if(Items.begin(), Items.end(),[&Name](auto I){return I->getName()== Name;}); - if(Item != Items.end()) { - return *Item; + [[nodiscard]] QVariant headerData(int Section, Qt::Orientation Orientation, + int Role = Qt::DisplayRole) const override; + FeatureTreeItem *addFeature(vara::feature::Feature *Item, string Parent); + void deleteFeatureItem(bool Recursive, vara::feature::Feature *Feature); + void deleteItem(bool Recursive, FeatureTreeItem *Item); + FeatureTreeItem *getItem(string Name) { + auto Item = std::find_if(Items.begin(), Items.end(), + [&Name](auto I) { return I->getName() == Name; }); + if (Item != Items.end()) { + return *Item; + } + return nullptr; } - return nullptr; - } - private: - vara::feature::FeatureModel* Model; - FeatureTreeItem* RootItem; - std::vector Items; + vara::feature::FeatureModel *Model; + FeatureTreeItem *RootItem; + std::vector Items; }; #endif // VARA_FEATURE_FEATURETREEVIEWMODEL_H From 4df3126d6146a41e24097a0933307d3d8c200800 Mon Sep 17 00:00:00 2001 From: Nerum Date: Thu, 23 Feb 2023 17:01:27 +0100 Subject: [PATCH 036/106] Apply Suggestions from code review --- tools/fm-editor/CMakeLists.txt | 1 + tools/fm-editor/FeatureAddDialog.cpp | 8 ++-- tools/fm-editor/FeatureAddDialog.h | 2 +- tools/fm-editor/FeatureModelEditor.cpp | 28 +++++++------ tools/fm-editor/FeatureModelEditor.h | 7 ++-- tools/fm-editor/Utils.h | 6 +-- tools/fm-editor/graph/FeatureEdge.cpp | 1 + tools/fm-editor/graph/FeatureEdge.h | 2 +- tools/fm-editor/graph/FeatureModelGraph.cpp | 11 ++--- tools/fm-editor/graph/FeatureModelGraph.h | 2 + tools/fm-editor/graph/FeatureNode.cpp | 13 +++--- tools/fm-editor/graph/FeatureNode.h | 5 ++- tools/fm-editor/main.cpp | 8 +--- tools/fm-editor/tree/FeatureTreeItem.cpp | 25 +++-------- tools/fm-editor/tree/FeatureTreeItem.h | 15 ++++++- tools/fm-editor/tree/FeatureTreeViewModel.cpp | 41 +++++++++++++------ tools/fm-editor/tree/FeatureTreeViewModel.h | 1 + 17 files changed, 98 insertions(+), 78 deletions(-) diff --git a/tools/fm-editor/CMakeLists.txt b/tools/fm-editor/CMakeLists.txt index b5f4adaa6..afaab1064 100644 --- a/tools/fm-editor/CMakeLists.txt +++ b/tools/fm-editor/CMakeLists.txt @@ -21,6 +21,7 @@ add_vara_executable(fm-editor tree/FeatureTreeItem.cpp FeatureModelEditor.h FeatureModelEditor.cpp FeatureAddDialog.h FeatureAddDialog.cpp + Utils.h ../../external/qsourcehighlite/qsourcehighliter.h ../../external/qsourcehighlite/qsourcehighliter.cpp ../../external/qsourcehighlite/languagedata.h diff --git a/tools/fm-editor/FeatureAddDialog.cpp b/tools/fm-editor/FeatureAddDialog.cpp index 1060e21cb..a4c564787 100644 --- a/tools/fm-editor/FeatureAddDialog.cpp +++ b/tools/fm-editor/FeatureAddDialog.cpp @@ -9,13 +9,13 @@ FeatureAddDialog::FeatureAddDialog(FeatureModelGraph *Graph, QWidget *Parent, : QDialog(Parent) { setupUi(this); NodeNames = QStringList(); - if (!ParentFeature) { + if (ParentFeature) { + NodeNames.push_back(QString::fromStdString(ParentFeature->getName().str())); + Nodes->setEnabled(false); + } else { for (const auto &Node : *Graph->getNodes()) { NodeNames.push_back(Node->getQName()); } - } else { - NodeNames.push_back(QString::fromStdString(ParentFeature->getName().str())); - Nodes->setEnabled(false); } this->Nodes->addItems(NodeNames); this->FeatureKind->addItems(QStringList{"Binary", "Numeric"}); diff --git a/tools/fm-editor/FeatureAddDialog.h b/tools/fm-editor/FeatureAddDialog.h index f7b2e2004..f18f429b0 100644 --- a/tools/fm-editor/FeatureAddDialog.h +++ b/tools/fm-editor/FeatureAddDialog.h @@ -18,7 +18,7 @@ class FeatureAddDialog : public QDialog, public Ui::Add { std::unique_ptr getFeature(); vara::feature::Feature::FeatureKind getFeatureKind(); bool isOptional(); - + public slots: void featureType(int index); diff --git a/tools/fm-editor/FeatureModelEditor.cpp b/tools/fm-editor/FeatureModelEditor.cpp index a79caadb4..ab9d485c6 100644 --- a/tools/fm-editor/FeatureModelEditor.cpp +++ b/tools/fm-editor/FeatureModelEditor.cpp @@ -83,11 +83,12 @@ void FeatureModelEditor::loadGraph() { // create Graph view buildGraph(); - + // create Tree View buildTree(); + Ui->tabWidget->addTab(Graph.get(), "GraphView"); - Ui->tabWidget->addTab(TreeView, "TreeView"); + Ui->tabWidget->addTab(TreeView.get(), "TreeView"); connect(Ui->sources, &QComboBox::currentTextChanged, this, &FeatureModelEditor::loadSource); Ui->actionSave->setEnabled(true); @@ -96,9 +97,9 @@ void FeatureModelEditor::loadGraph() { /// Build the Treeview void FeatureModelEditor::buildTree() { - TreeView = new QTreeView(); + TreeView = std::make_unique(); TreeModel = - std::make_unique(FeatureModel.get(), TreeView); + std::make_unique(FeatureModel.get(), TreeView.get()); for (auto Item : TreeModel->getItems()) { connect(Item, &FeatureTreeItem::inspectSource, this, &FeatureModelEditor::inspectFeatureSources); @@ -107,11 +108,11 @@ void FeatureModelEditor::buildTree() { connect(Item, &FeatureTreeItem::removeFeature, this, &FeatureModelEditor::removeFeature); } - connect(TreeView, &QTreeView::pressed, this, + connect(TreeView.get(), &QTreeView::pressed, this, &FeatureModelEditor::loadFeatureFromIndex); TreeView->setModel(TreeModel.get()); TreeView->setContextMenuPolicy(Qt::CustomContextMenu); - connect(TreeView, SIGNAL(customContextMenuRequested(const QPoint &)), this, + connect(TreeView.get(), SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(createTreeContextMenu(const QPoint &))); } @@ -176,8 +177,10 @@ void FeatureModelEditor::save() { FMWrite.writeFeatureModel(SavePath.toStdString()); } -/// Loead the source files of the Feature to be selectable by the user and set -/// the Feature as CurrentFeature. \param Feature +/// Load the source files of the Feature to be selectable by the user and set +/// the Feature as CurrentFeature. +/// +/// \param Feature Selected Feature void FeatureModelEditor::inspectFeatureSources( vara::feature::Feature *Feature) { CurrentFeature = Feature; @@ -196,7 +199,6 @@ void FeatureModelEditor::inspectFeatureSources( Ui->sources->setPlaceholderText("Select File"); } } - /// Create the Context menu for inspecting sources in the tree view /// /// \param Pos Position of the cursor used to find the clicked item @@ -210,8 +212,9 @@ void FeatureModelEditor::createTreeContextMenu(const QPoint &Pos) { } } -/// Load the selected file into the textedit and mark the sources of the -/// selected feature +/// Load the selected file into the textedit and mark the sources of the selected feature +/// +/// \param RelativePath path to the source file relative to the repository path void FeatureModelEditor::loadSource(const QString &RelativePath) { Ui->textEdit->clear(); auto SourcePath = Repository + "/" + RelativePath; @@ -220,7 +223,6 @@ void FeatureModelEditor::loadSource(const QString &RelativePath) { File.open(QFile::ReadOnly | QFile::Text); QTextStream ReadFile(&File); Ui->textEdit->setText(ReadFile.readAll()); - std::cout << CurrentFeature->toString(); std::vector Locations{}; std::copy_if( CurrentFeature->getLocationsBegin(), CurrentFeature->getLocationsEnd(), @@ -236,7 +238,7 @@ void FeatureModelEditor::loadSource(const QString &RelativePath) { /// Mark the given SourceRange with the given Format /// /// \param Fmt Format to mark with -/// \param Cursor the cursor +/// \param Cursor Cursor /// \param Location Location to mark void FeatureModelEditor::markLocation( vara::feature::FeatureSourceRange &Location) const { diff --git a/tools/fm-editor/FeatureModelEditor.h b/tools/fm-editor/FeatureModelEditor.h index 1bdafa07b..ec472e977 100644 --- a/tools/fm-editor/FeatureModelEditor.h +++ b/tools/fm-editor/FeatureModelEditor.h @@ -6,6 +6,7 @@ #include "vara/Feature/Feature.h" #include "vara/Feature/FeatureModel.h" #include "vara/Feature/FeatureModelTransaction.h" + #include #include #include @@ -17,7 +18,6 @@ class FeatureModelEditor; } // namespace Ui QT_END_NAMESPACE - class FeatureModelEditor : public QMainWindow { Q_OBJECT public: @@ -27,21 +27,20 @@ class FeatureModelEditor : public QMainWindow { private: Ui::FeatureModelEditor *Ui; std::unique_ptr Graph{}; - QTreeView *TreeView; + std::unique_ptr TreeView; std::unique_ptr TreeModel{}; std::unique_ptr FeatureModel{}; QString Repository{}; vara::feature::Feature *CurrentFeature; QString SavePath{}; QString ModelPath{}; - + public slots: void addSource(); void loadFeature(const vara::feature::Feature *Feature); void inspectFeatureSources(vara::feature::Feature *Feature); void loadGraph(); void featureAddDialogChild(vara::feature::Feature * = nullptr); - // void addNode(const QString& Name, FeatureNode *Parent); void loadSource(const QString &RelativePath); void createTreeContextMenu(const QPoint &Pos); void addSourceFile(); diff --git a/tools/fm-editor/Utils.h b/tools/fm-editor/Utils.h index de32e3f14..c002bb25f 100644 --- a/tools/fm-editor/Utils.h +++ b/tools/fm-editor/Utils.h @@ -22,9 +22,9 @@ struct ActionBuilder { }; template -QMenu *buildMenu(T *Receiver, std::pair... Actions) { - auto Menu = new QMenu; - ActionBuilder Builder(Menu, Receiver); +std::unique_ptr buildMenu(T *Receiver, std::pair... Actions) { + auto Menu = std::make_unique(); + ActionBuilder Builder(Menu.get(), Receiver); Builder.addActions(Actions...); return Menu; } diff --git a/tools/fm-editor/graph/FeatureEdge.cpp b/tools/fm-editor/graph/FeatureEdge.cpp index c5fb6b4d6..2ab7e99d4 100644 --- a/tools/fm-editor/graph/FeatureEdge.cpp +++ b/tools/fm-editor/graph/FeatureEdge.cpp @@ -57,6 +57,7 @@ void FeatureEdge::paint(QPainter *Painter, } QLineF Line(SourcePoint, TargetPoint); + if (qFuzzyCompare(Line.length(), qreal(0.))) { return; } diff --git a/tools/fm-editor/graph/FeatureEdge.h b/tools/fm-editor/graph/FeatureEdge.h index f67a52ac6..b10d85938 100644 --- a/tools/fm-editor/graph/FeatureEdge.h +++ b/tools/fm-editor/graph/FeatureEdge.h @@ -5,7 +5,7 @@ class FeatureNode; -class FeatureEdge : public QGraphicsItem{ +class FeatureEdge : public QGraphicsItem { public: FeatureEdge(FeatureNode *SourceNode, FeatureNode *TargetNode); diff --git a/tools/fm-editor/graph/FeatureModelGraph.cpp b/tools/fm-editor/graph/FeatureModelGraph.cpp index fd9f824ef..4dbae107f 100644 --- a/tools/fm-editor/graph/FeatureModelGraph.cpp +++ b/tools/fm-editor/graph/FeatureModelGraph.cpp @@ -15,6 +15,7 @@ FeatureModelGraph::FeatureModelGraph(vara::feature::FeatureModel *FeatureModel, : QGraphicsView(Parent), EntryNode(new FeatureNode(FeatureModel->getRoot())), FeatureModel(FeatureModel) { + auto *Scene = new QGraphicsScene(this); Scene->setItemIndexMethod(QGraphicsScene::NoIndex); @@ -189,16 +190,16 @@ FeatureNode *FeatureModelGraph::getNode(std::string Name) { void FeatureModelGraph::deleteNode(bool Recursive, FeatureNode *Node) { auto *Parent = Node->parent()->sourceNode(); - if (!Recursive) { + if (Recursive) { for (auto *Child : Node->children()) { - Child->setSourceNode(Parent); + deleteNode(true, Child->targetNode()); } - - Node->children().clear(); } else { for (auto *Child : Node->children()) { - deleteNode(true, Child->targetNode()); + Child->setSourceNode(Parent); } + + Node->children().clear(); } Parent->removeChild(Node); scene()->removeItem(Node); diff --git a/tools/fm-editor/graph/FeatureModelGraph.h b/tools/fm-editor/graph/FeatureModelGraph.h index ca76027c3..07279ad57 100644 --- a/tools/fm-editor/graph/FeatureModelGraph.h +++ b/tools/fm-editor/graph/FeatureModelGraph.h @@ -6,6 +6,7 @@ #include "vara/Feature/FeatureModel.h" #include + class FeatureModelGraph : public QGraphicsView { Q_OBJECT @@ -18,6 +19,7 @@ class FeatureModelGraph : public QGraphicsView { FeatureNode *addNode(vara::feature::Feature *Feature, FeatureNode *Parent); void deleteNode(bool Recursive, vara::feature::Feature *Feature); void deleteNode(bool Recursive, FeatureNode *Node); + public slots: void zoomIn(); void zoomOut(); diff --git a/tools/fm-editor/graph/FeatureNode.cpp b/tools/fm-editor/graph/FeatureNode.cpp index 9fe162a50..40fe38793 100644 --- a/tools/fm-editor/graph/FeatureNode.cpp +++ b/tools/fm-editor/graph/FeatureNode.cpp @@ -4,7 +4,6 @@ #include #include -#include #include #include @@ -13,6 +12,8 @@ FeatureNode::FeatureNode(vara::feature::Feature *Feature) : Feature(Feature) { setFlag(ItemSendsGeometryChanges); setCacheMode(DeviceCoordinateCache); setZValue(-1); + ContextMenu = std::make_unique(); + ContextMenu->addAction("Inspect Sources", this, &FeatureNode::inspect); } void FeatureNode::addChildEdge(FeatureEdge *Edge) { @@ -99,11 +100,7 @@ void FeatureNode::mouseReleaseEvent(QGraphicsSceneMouseEvent *Event) { } void FeatureNode::contextMenuEvent(QGraphicsSceneContextMenuEvent *Event) { - auto *Menu = new QMenu; - auto *Inspect = new QAction("Inspect Sources", this); - Menu->addAction(Inspect); - Menu->popup(Event->screenPos()); - connect(Inspect, &QAction::triggered, this, &FeatureNode::inspect); + ContextMenu->popup(Event->screenPos()); } void FeatureNode::inspect() { emit(inspectSource(Feature)); } @@ -116,10 +113,12 @@ int FeatureNode::childrenWidth() const { if (ChildEdges.empty()) { return width(); } + int Result = 0; for (auto *Child : ChildEdges) { Result += Child->targetNode()->childrenWidth(); } + return std::max(Result, width()); } @@ -127,6 +126,7 @@ int FeatureNode::childrenDepth() const { if (ChildEdges.empty()) { return 1; } + int MaxDepth = 0; for (auto *Child : ChildEdges) { int const ChildDepth = Child->targetNode()->childrenDepth(); @@ -134,5 +134,6 @@ int FeatureNode::childrenDepth() const { MaxDepth = ChildDepth + 1; } } + return MaxDepth; } diff --git a/tools/fm-editor/graph/FeatureNode.h b/tools/fm-editor/graph/FeatureNode.h index 60ce3d85b..af661ce2d 100644 --- a/tools/fm-editor/graph/FeatureNode.h +++ b/tools/fm-editor/graph/FeatureNode.h @@ -7,6 +7,7 @@ #include #include #include +#include class FeatureEdge; class FeatureModelGraph; @@ -38,7 +39,7 @@ class FeatureNode : public QObject, public QGraphicsItem { [[nodiscard]] std::string getName() const { return Feature->getName().str(); }; - ~FeatureNode() { std::destroy(ChildEdges.begin(), ChildEdges.end()); } + ~FeatureNode() override { std::destroy(ChildEdges.begin(), ChildEdges.end()); } signals: void clicked(const vara::feature::Feature *Feature); @@ -56,7 +57,7 @@ class FeatureNode : public QObject, public QGraphicsItem { std::vector ChildEdges; FeatureEdge *ParentEdge = nullptr; vara::feature::Feature *Feature; - + std::unique_ptr ContextMenu; void inspect(); }; diff --git a/tools/fm-editor/main.cpp b/tools/fm-editor/main.cpp index a52c517e4..1c048e323 100644 --- a/tools/fm-editor/main.cpp +++ b/tools/fm-editor/main.cpp @@ -1,13 +1,9 @@ #include "FeatureModelEditor.h" -#include "graph/FeatureModelGraph.h" -#include "vara/Feature/FeatureModel.h" #include -#include -#include -int main(int argc, char *argv[]) { - QApplication App(argc, argv); +int main(int argc, char **argv) { + QApplication const App(argc, argv); FeatureModelEditor W; W.show(); return App.exec(); diff --git a/tools/fm-editor/tree/FeatureTreeItem.cpp b/tools/fm-editor/tree/FeatureTreeItem.cpp index 730b2ff00..c7b8019b4 100644 --- a/tools/fm-editor/tree/FeatureTreeItem.cpp +++ b/tools/fm-editor/tree/FeatureTreeItem.cpp @@ -1,8 +1,6 @@ #include "FeatureTreeItem.h" -#include "../Utils.h" #include - #include QVariant numericValue(vara::feature::Feature *Item) { @@ -44,21 +42,15 @@ QVariant locationString(vara::feature::Feature *Item) { return QString::fromStdString(StrS.str()); } -FeatureTreeItem* FeatureTreeItem::createFeatureTreeItem( - vara::feature::FeatureTreeNode *Item) { - if(Item->getKind() == vara::feature::FeatureTreeNode::NodeKind::NK_RELATIONSHIP){ - return new FeatureTreeItemRelation(dynamic_cast(Item)); -FeatureTreeItem * -FeatureTreeItem::createFeatureTreeItem(vara::feature::FeatureTreeNode *Item) { +FeatureTreeItem *FeatureTreeItem::createFeatureTreeItem(vara::feature::FeatureTreeNode *Item) { if (Item->getKind() == vara::feature::FeatureTreeNode::NodeKind::NK_RELATIONSHIP) { return new FeatureTreeItemRelation( - dynamic_cast(Item)); + dyn_cast(Item)); } - return new FeatureTreeItemFeature( - dynamic_cast(Item)); - return new FeatureTreeItemFeature(dynamic_cast(Item)); + return new FeatureTreeItemFeature( + dyn_cast(Item)); } void FeatureTreeItem::addChild(FeatureTreeItem *Child) { @@ -78,6 +70,7 @@ std::vector FeatureTreeItem::getChildrenRecursive() { auto ChildNodes = Child->getChildrenRecursive(); Nodes.insert(Nodes.end(), ChildNodes.begin(), ChildNodes.end()); } + return Nodes; } @@ -101,13 +94,7 @@ QVariant FeatureTreeItemFeature::data(int Column) const { void FeatureTreeItemFeature::inspect() { emit(inspectSource(Item)); } void FeatureTreeItemFeature::contextMenu(QPoint Pos) { - auto *Menu = buildMenu( - this, - std::pair(QString("Inspect Sources"), &FeatureTreeItemFeature::inspect), - std::pair(QString("Add Child"), &FeatureTreeItemFeature::addChild), - std::pair(QString("Remove"), &FeatureTreeItemFeature::remove)); - // TODO Make recursive Removal work - Menu->popup(Pos); + ContextMenu->popup(Pos); } void FeatureTreeItemFeature::remove() { emit(removeFeature(false, Item)); } diff --git a/tools/fm-editor/tree/FeatureTreeItem.h b/tools/fm-editor/tree/FeatureTreeItem.h index f2fe2d010..ecb435a12 100644 --- a/tools/fm-editor/tree/FeatureTreeItem.h +++ b/tools/fm-editor/tree/FeatureTreeItem.h @@ -1,7 +1,11 @@ #ifndef VARA_FEATURE_FEATURETREEITEM_H #define VARA_FEATURE_FEATURETREEITEM_H + #include "vara/Feature/Feature.h" #include "vara/Feature/Relationship.h" +#include "../Utils.h" + +#include #include #include #include @@ -78,7 +82,15 @@ class FeatureTreeItemFeature : public FeatureTreeItem { FeatureTreeItemFeature(vara::feature::Feature *Item) : FeatureTreeItem(Item, vara::feature::FeatureTreeNode::NodeKind::NK_FEATURE), - Item(Item) {} + Item(Item) { + ContextMenu = buildMenu( + this, + std::pair(QString("Inspect Sources"), &FeatureTreeItemFeature::inspect), + std::pair(QString("Add Child"), &FeatureTreeItemFeature::addChild), + std::pair(QString("Remove"), &FeatureTreeItemFeature::remove)); + // TODO Make recursive Removal work + + } [[nodiscard]] QVariant data(int Column) const override; [[nodiscard]] int columnCount() const override { return 5; } static bool booleanColumn(int Column) { return Column == 1; } @@ -93,6 +105,7 @@ public slots: private: vara::feature::Feature *Item; + std::unique_ptr ContextMenu; }; class FeatureTreeItemRelation : public FeatureTreeItem { diff --git a/tools/fm-editor/tree/FeatureTreeViewModel.cpp b/tools/fm-editor/tree/FeatureTreeViewModel.cpp index 1172cb95c..a7a06d928 100644 --- a/tools/fm-editor/tree/FeatureTreeViewModel.cpp +++ b/tools/fm-editor/tree/FeatureTreeViewModel.cpp @@ -1,7 +1,3 @@ -// -// Created by simon on 02.02.23. -// - #include "FeatureTreeViewModel.h" QModelIndex FeatureTreeViewModel::index(int Row, int Column, @@ -14,13 +10,16 @@ QModelIndex FeatureTreeViewModel::index(int Row, int Column, ParentItem = static_cast(Parent.internalPointer()) ->child(Parent.row()); } + if (ParentItem->childCount() <= 0) { return {}; } + auto *ChildItem = ParentItem->child(Row); if (ChildItem) { return createIndex(Row, Column, ParentItem); } + return {}; } @@ -28,16 +27,20 @@ QModelIndex FeatureTreeViewModel::parent(const QModelIndex &Child) const { if (!Child.isValid()) { return {}; } + auto *ParentItem = static_cast(Child.internalPointer()); if (ParentItem && ParentItem != RootItem) { return createIndex(ParentItem->row(), 0, ParentItem->parent()); } + return {}; } + int FeatureTreeViewModel::rowCount(const QModelIndex &Parent) const { if (Parent.column() > 0) { return 0; } + FeatureTreeItem *ParentItem; if (!Parent.isValid()) { ParentItem = RootItem; @@ -45,24 +48,30 @@ int FeatureTreeViewModel::rowCount(const QModelIndex &Parent) const { ParentItem = static_cast(Parent.internalPointer()) ->child(Parent.row()); } + return ParentItem->childCount(); } + int FeatureTreeViewModel::columnCount(const QModelIndex &Parent) const { if (Parent.isValid()) { auto Item = static_cast(Parent.internalPointer()) ->child(Parent.row()); return Item->columnCount(); } + return RootItem->columnCount(); } + QVariant FeatureTreeViewModel::data(const QModelIndex &Index, int Role) const { if (!Index.isValid() || Role != Qt::DisplayRole) { return {}; } + auto *Item = static_cast(Index.internalPointer()) ->child(Index.row()); return Item->data(Index.column()); } + Qt::ItemFlags FeatureTreeViewModel::flags(const QModelIndex &Index) const { if (Index.isValid()) { auto *Item = static_cast(Index.internalPointer()) @@ -70,9 +79,12 @@ Qt::ItemFlags FeatureTreeViewModel::flags(const QModelIndex &Index) const { if (Item->booleanColumn(Index.column())) { return Qt::ItemIsUserCheckable | Qt::ItemIsSelectable | Qt::ItemIsEnabled; } + } + return QAbstractItemModel::flags(Index); } + QVariant FeatureTreeViewModel::headerData(int Section, Qt::Orientation Orientation, int Role) const { @@ -92,6 +104,7 @@ QVariant FeatureTreeViewModel::headerData(int Section, return QString("Todo"); } } + return {}; } @@ -99,8 +112,7 @@ std::vector FeatureTreeViewModel::getItems() { return Items; } -FeatureTreeItem * -FeatureTreeViewModel::addFeature(vara::feature::Feature *Feature, +FeatureTreeItem *FeatureTreeViewModel::addFeature(vara::feature::Feature *Feature, std::string Parent) { auto Item = getItem(Parent); if (Item) { @@ -120,15 +132,13 @@ void FeatureTreeViewModel::deleteFeatureItem(bool Recursive, if (Item) { deleteItem(Recursive, Item); } + emit(layoutChanged()); } void FeatureTreeViewModel::deleteItem(bool Recursive, FeatureTreeItem *Item) { - if(Recursive) { - for (auto *Child : Item->getChildren()) { - deleteItem(Recursive,Child); - } - } else { + + if (!Recursive) { auto *Parent = Item->parent(); if (Parent) { for (auto *Child : Item->getChildren()) { @@ -139,8 +149,13 @@ void FeatureTreeViewModel::deleteItem(bool Recursive, FeatureTreeItem *Item) { Parent->getChildren().erase(ItemPos); } } + + if (Recursive) { + for (auto *Child : Item->getChildren()) { + deleteItem(Recursive, Child); + } + } + Items.erase(std::find(Items.begin(), Items.end(), Item)); - emit(layoutAboutToBeChanged()); delete Item; - emit(layoutChanged()); } diff --git a/tools/fm-editor/tree/FeatureTreeViewModel.h b/tools/fm-editor/tree/FeatureTreeViewModel.h index 723036d0c..98ec7fb6e 100644 --- a/tools/fm-editor/tree/FeatureTreeViewModel.h +++ b/tools/fm-editor/tree/FeatureTreeViewModel.h @@ -38,6 +38,7 @@ class FeatureTreeViewModel : public QAbstractItemModel { if (Item != Items.end()) { return *Item; } + return nullptr; } From b3b1a2fc6384b0997093a4f2a60183e19c0654da Mon Sep 17 00:00:00 2001 From: Nerum Date: Thu, 2 Mar 2023 11:11:41 +0100 Subject: [PATCH 037/106] remove accidental changes --- .github/workflows/build.yml | 1 + unittests/Feature/FeatureModelTransaction.cpp | 12 ++++-------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 206a99abb..17d274acb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -53,6 +53,7 @@ jobs: sudo apt-get update sudo apt download libclang-rt-14-dev sudo dpkg --force-all -i libclang-rt-14-dev* + - name: Build ${{ matrix.build }} with LLVM ${{ matrix.llvm-major }} env: BUILD_TYPE: ${{ matrix.build }} diff --git a/unittests/Feature/FeatureModelTransaction.cpp b/unittests/Feature/FeatureModelTransaction.cpp index 629f57062..a25220175 100644 --- a/unittests/Feature/FeatureModelTransaction.cpp +++ b/unittests/Feature/FeatureModelTransaction.cpp @@ -104,8 +104,7 @@ TEST_F(FeatureModelTransactionCopyTest, addFeatureToModel) { size_t FMSizeBefore = FM->size(); auto FT = FeatureModelCopyTransaction::openTransaction(*FM); - FT.addFeature(std::make_unique("ab"), - FM->getFeature("a")); + FT.addFeature(std::make_unique("ab"), FM->getFeature("a")); EXPECT_EQ(FMSizeBefore, FM->size()); EXPECT_TRUE(FM->getFeature("a")); @@ -134,8 +133,7 @@ TEST_F(FeatureModelTransactionCopyTest, addFeatureToModelThenAbort) { size_t FMSizeBefore = FM->size(); auto FT = FeatureModelCopyTransaction::openTransaction(*FM); - FT.addFeature(std::make_unique("ab"), - FM->getFeature("a")); + FT.addFeature(std::make_unique("ab"), FM->getFeature("a")); EXPECT_EQ(FMSizeBefore, FM->size()); EXPECT_TRUE(FM->getFeature("a")); @@ -189,8 +187,7 @@ TEST_F(FeatureModelTransactionModifyTest, addFeatureToModel) { size_t FMSizeBefore = FM->size(); auto FT = FeatureModelModifyTransaction::openTransaction(*FM); - FT.addFeature(std::make_unique("ab"), - FM->getFeature("a")); + FT.addFeature(std::make_unique("ab"), FM->getFeature("a")); EXPECT_EQ(FMSizeBefore, FM->size()); EXPECT_TRUE(FM->getFeature("a")); @@ -210,8 +207,7 @@ TEST_F(FeatureModelTransactionModifyTest, addFeatureToModelThenAboard) { size_t FMSizeBefore = FM->size(); auto FT = FeatureModelModifyTransaction::openTransaction(*FM); - FT.addFeature(std::make_unique("ab"), - FM->getFeature("a")); + FT.addFeature(std::make_unique("ab"), FM->getFeature("a")); EXPECT_EQ(FMSizeBefore, FM->size()); EXPECT_TRUE(FM->getFeature("a")); From e84b72c8612289ee91500362948e266b0caac888 Mon Sep 17 00:00:00 2001 From: Nerum Date: Thu, 2 Mar 2023 11:11:59 +0100 Subject: [PATCH 038/106] Fix formating --- tools/fm-editor/CMakeLists.txt | 2 +- tools/fm-editor/main.cpp | 2 +- tools/fm-editor/tree/FeatureTreeItem.cpp | 6 +++--- tools/fm-editor/tree/FeatureTreeItem.h | 2 +- tools/fm-editor/tree/FeatureTreeViewModel.cpp | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/fm-editor/CMakeLists.txt b/tools/fm-editor/CMakeLists.txt index afaab1064..4f6be596f 100644 --- a/tools/fm-editor/CMakeLists.txt +++ b/tools/fm-editor/CMakeLists.txt @@ -28,7 +28,7 @@ add_vara_executable(fm-editor ../../external/qsourcehighlite/languagedata.cpp ../../external/qsourcehighlite/qsourcehighliterthemes.h ../../external/qsourcehighlite/qsourcehighliterthemes.cpp - ) +) target_link_libraries(fm-editor LINK_PRIVATE VaRAFeature diff --git a/tools/fm-editor/main.cpp b/tools/fm-editor/main.cpp index 1c048e323..d2aee1249 100644 --- a/tools/fm-editor/main.cpp +++ b/tools/fm-editor/main.cpp @@ -7,4 +7,4 @@ int main(int argc, char **argv) { FeatureModelEditor W; W.show(); return App.exec(); -} \ No newline at end of file +} diff --git a/tools/fm-editor/tree/FeatureTreeItem.cpp b/tools/fm-editor/tree/FeatureTreeItem.cpp index c7b8019b4..bbbc4d103 100644 --- a/tools/fm-editor/tree/FeatureTreeItem.cpp +++ b/tools/fm-editor/tree/FeatureTreeItem.cpp @@ -42,15 +42,15 @@ QVariant locationString(vara::feature::Feature *Item) { return QString::fromStdString(StrS.str()); } -FeatureTreeItem *FeatureTreeItem::createFeatureTreeItem(vara::feature::FeatureTreeNode *Item) { +FeatureTreeItem * +FeatureTreeItem::createFeatureTreeItem(vara::feature::FeatureTreeNode *Item) { if (Item->getKind() == vara::feature::FeatureTreeNode::NodeKind::NK_RELATIONSHIP) { return new FeatureTreeItemRelation( dyn_cast(Item)); } - return new FeatureTreeItemFeature( - dyn_cast(Item)); + return new FeatureTreeItemFeature(dyn_cast(Item)); } void FeatureTreeItem::addChild(FeatureTreeItem *Child) { diff --git a/tools/fm-editor/tree/FeatureTreeItem.h b/tools/fm-editor/tree/FeatureTreeItem.h index ecb435a12..0f4e1a780 100644 --- a/tools/fm-editor/tree/FeatureTreeItem.h +++ b/tools/fm-editor/tree/FeatureTreeItem.h @@ -3,7 +3,7 @@ #include "vara/Feature/Feature.h" #include "vara/Feature/Relationship.h" -#include "../Utils.h" +#include "" #include #include diff --git a/tools/fm-editor/tree/FeatureTreeViewModel.cpp b/tools/fm-editor/tree/FeatureTreeViewModel.cpp index a7a06d928..a6c8e45ac 100644 --- a/tools/fm-editor/tree/FeatureTreeViewModel.cpp +++ b/tools/fm-editor/tree/FeatureTreeViewModel.cpp @@ -79,7 +79,6 @@ Qt::ItemFlags FeatureTreeViewModel::flags(const QModelIndex &Index) const { if (Item->booleanColumn(Index.column())) { return Qt::ItemIsUserCheckable | Qt::ItemIsSelectable | Qt::ItemIsEnabled; } - } return QAbstractItemModel::flags(Index); @@ -112,7 +111,8 @@ std::vector FeatureTreeViewModel::getItems() { return Items; } -FeatureTreeItem *FeatureTreeViewModel::addFeature(vara::feature::Feature *Feature, +FeatureTreeItem * +FeatureTreeViewModel::addFeature(vara::feature::Feature *Feature, std::string Parent) { auto Item = getItem(Parent); if (Item) { From af8dc5850c24c2cb4f39967e100119d09c17a988 Mon Sep 17 00:00:00 2001 From: Nerum Date: Thu, 2 Mar 2023 11:13:20 +0100 Subject: [PATCH 039/106] Let addAction create the action instead of handling that our self's. --- tools/fm-editor/Utils.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/fm-editor/Utils.h b/tools/fm-editor/Utils.h index c002bb25f..a46acd645 100644 --- a/tools/fm-editor/Utils.h +++ b/tools/fm-editor/Utils.h @@ -9,9 +9,7 @@ struct ActionBuilder { template void addActions(std::pair Action, std::pair... Actions) { - auto *A = new QAction(Action.first, Receiver); - QObject::connect(A, &QAction::triggered, Receiver, Action.second); - Menu->addAction(A); + Menu->addAction(Action.first,Receiver,Action.second); addActions(Actions...); } void addActions() {} From 70fec0aaed2f8d45a32a720f523020e2efa114ce Mon Sep 17 00:00:00 2001 From: Nerum Date: Thu, 2 Mar 2023 11:14:26 +0100 Subject: [PATCH 040/106] Fix typo --- tools/fm-editor/FeatureAddDialog.cpp | 4 ++-- tools/fm-editor/FeatureAddDialog.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/fm-editor/FeatureAddDialog.cpp b/tools/fm-editor/FeatureAddDialog.cpp index a4c564787..6627ccf58 100644 --- a/tools/fm-editor/FeatureAddDialog.cpp +++ b/tools/fm-editor/FeatureAddDialog.cpp @@ -43,7 +43,7 @@ vara::feature::Feature::FeatureKind FeatureAddDialog::getFeatureKind() { bool FeatureAddDialog::isOptional() { return optinalCheck->isChecked(); } -QString FeatureAddDialog::getOutpuString() { return outpuString->text(); } +QString FeatureAddDialog::getOutputString() { return outpuString->text(); } std::vector stringToIntVector(string &Input) { std::stringstream InStream(Input); @@ -59,7 +59,7 @@ std::vector stringToIntVector(string &Input) { std::unique_ptr FeatureAddDialog::getFeature() { const std::string Name = getName().toStdString(); const bool Optional = isOptional(); - const std::string OutputString = getOutpuString().toStdString(); + const std::string OutputString = getOutputString().toStdString(); vara::feature::NumericFeature::ValuesVariantType ValueRange; switch (getFeatureKind()) { diff --git a/tools/fm-editor/FeatureAddDialog.h b/tools/fm-editor/FeatureAddDialog.h index f18f429b0..2ec0acec8 100644 --- a/tools/fm-editor/FeatureAddDialog.h +++ b/tools/fm-editor/FeatureAddDialog.h @@ -14,7 +14,7 @@ class FeatureAddDialog : public QDialog, public Ui::Add { vara::feature::Feature *ParentFeature = nullptr); QString getName(); QString getParent(); - QString getOutpuString(); + QString getOutputString(); std::unique_ptr getFeature(); vara::feature::Feature::FeatureKind getFeatureKind(); bool isOptional(); From ddb71b294f2be99da40016bd05143348e02e86f9 Mon Sep 17 00:00:00 2001 From: Nerum Date: Thu, 2 Mar 2023 11:24:44 +0100 Subject: [PATCH 041/106] Extract Numeric Feature Creation to its own method for better readability --- tools/fm-editor/FeatureAddDialog.cpp | 51 ++++++++++++++++------------ tools/fm-editor/FeatureAddDialog.h | 9 ++--- 2 files changed, 34 insertions(+), 26 deletions(-) diff --git a/tools/fm-editor/FeatureAddDialog.cpp b/tools/fm-editor/FeatureAddDialog.cpp index 6627ccf58..76ac613eb 100644 --- a/tools/fm-editor/FeatureAddDialog.cpp +++ b/tools/fm-editor/FeatureAddDialog.cpp @@ -25,9 +25,9 @@ FeatureAddDialog::FeatureAddDialog(FeatureModelGraph *Graph, QWidget *Parent, &FeatureAddDialog::featureType); } -QString FeatureAddDialog::getName() { return name->text(); } +QString FeatureAddDialog::getName() const { return name->text(); } -QString FeatureAddDialog::getParent() { return Nodes->currentText(); } +QString FeatureAddDialog::getParent() const { return Nodes->currentText(); } void FeatureAddDialog::featureType(int index) { if (index == 1) { @@ -41,9 +41,9 @@ vara::feature::Feature::FeatureKind FeatureAddDialog::getFeatureKind() { return vara::feature::Feature::FeatureKind(FeatureKind->currentIndex()); } -bool FeatureAddDialog::isOptional() { return optinalCheck->isChecked(); } +bool FeatureAddDialog::isOptional() const { return optinalCheck->isChecked(); } -QString FeatureAddDialog::getOutputString() { return outpuString->text(); } +QString FeatureAddDialog::getOutputString() const { return outpuString->text(); } std::vector stringToIntVector(string &Input) { std::stringstream InStream(Input); @@ -60,7 +60,6 @@ std::unique_ptr FeatureAddDialog::getFeature() { const std::string Name = getName().toStdString(); const bool Optional = isOptional(); const std::string OutputString = getOutputString().toStdString(); - vara::feature::NumericFeature::ValuesVariantType ValueRange; switch (getFeatureKind()) { case Feature::FeatureKind::FK_BINARY: @@ -68,25 +67,33 @@ std::unique_ptr FeatureAddDialog::getFeature() { Name, Optional, std::vector(), OutputString); case Feature::FeatureKind::FK_NUMERIC: { - std::unique_ptr SF{}; - if (range->isChecked()) { - ValueRange = vara::feature::NumericFeature::ValueRangeType(min->value(), - max->value()); - if (lhs->isChecked()) { - SF = std::make_unique( - stepOperant->value(), vara::feature::StepFunction::StepOperation( - stepOperator->currentIndex())); - } - } else { - auto ValueString = values->text().toStdString(); - ValueRange = stringToIntVector(ValueString); - } - return std::make_unique( - Name, ValueRange, Optional, - std::vector(), OutputString, - std::move(SF)); + return getNumericFeature(); } default: return std::make_unique(Name); } } + +std::unique_ptr FeatureAddDialog::getNumericFeature() const { + const std::string Name = getName().toStdString(); + const bool Optional = isOptional(); + const std::string OutputString = getOutputString().toStdString(); + std::unique_ptr SF{}; + vara::feature::NumericFeature::ValuesVariantType ValueRange; + if (range->isChecked()) { + ValueRange = vara::feature::NumericFeature::ValueRangeType(min->value(), + max->value()); + if (lhs->isChecked()) { + SF = std::make_unique( + stepOperant->value(), vara::feature::StepFunction::StepOperation( + stepOperator->currentIndex())); + } + } else { + auto ValueString = values->text().toStdString(); + ValueRange = stringToIntVector(ValueString); + } + return std::make_unique( + Name, ValueRange, Optional, + std::vector(), OutputString, + std::move(SF)); +} diff --git a/tools/fm-editor/FeatureAddDialog.h b/tools/fm-editor/FeatureAddDialog.h index 2ec0acec8..4304847cd 100644 --- a/tools/fm-editor/FeatureAddDialog.h +++ b/tools/fm-editor/FeatureAddDialog.h @@ -12,12 +12,12 @@ class FeatureAddDialog : public QDialog, public Ui::Add { public: FeatureAddDialog(FeatureModelGraph *Graph, QWidget *Parent, vara::feature::Feature *ParentFeature = nullptr); - QString getName(); - QString getParent(); - QString getOutputString(); + QString getName() const; + QString getParent() const; + QString getOutputString() const; std::unique_ptr getFeature(); vara::feature::Feature::FeatureKind getFeatureKind(); - bool isOptional(); + bool isOptional() const ; public slots: void featureType(int index); @@ -26,6 +26,7 @@ public slots: QStringList NodeNames; vara::feature::StepFunction::StepOperation getStepOperation(); + std::unique_ptr getNumericFeature() const; }; #endif // VARA_FEATURE_FEATUREADDDIALOG_H From d0f2dd823e3951a0d1f2fea058286c5d1768000f Mon Sep 17 00:00:00 2001 From: Nerum Date: Thu, 2 Mar 2023 11:41:22 +0100 Subject: [PATCH 042/106] Include Utils directly --- tools/fm-editor/CMakeLists.txt | 3 ++- tools/fm-editor/tree/FeatureTreeItem.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/fm-editor/CMakeLists.txt b/tools/fm-editor/CMakeLists.txt index 4f6be596f..aba5190ec 100644 --- a/tools/fm-editor/CMakeLists.txt +++ b/tools/fm-editor/CMakeLists.txt @@ -7,6 +7,8 @@ set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) find_package(Qt6 REQUIRED COMPONENTS Widgets) include_directories(../../external/qsourcehighlite) +include_directories(.) + add_vara_executable(fm-editor main.cpp graph/FeatureModelGraph.h @@ -21,7 +23,6 @@ add_vara_executable(fm-editor tree/FeatureTreeItem.cpp FeatureModelEditor.h FeatureModelEditor.cpp FeatureAddDialog.h FeatureAddDialog.cpp - Utils.h ../../external/qsourcehighlite/qsourcehighliter.h ../../external/qsourcehighlite/qsourcehighliter.cpp ../../external/qsourcehighlite/languagedata.h diff --git a/tools/fm-editor/tree/FeatureTreeItem.h b/tools/fm-editor/tree/FeatureTreeItem.h index 0f4e1a780..e90078d40 100644 --- a/tools/fm-editor/tree/FeatureTreeItem.h +++ b/tools/fm-editor/tree/FeatureTreeItem.h @@ -1,9 +1,9 @@ #ifndef VARA_FEATURE_FEATURETREEITEM_H #define VARA_FEATURE_FEATURETREEITEM_H +#include "Utils.h" #include "vara/Feature/Feature.h" #include "vara/Feature/Relationship.h" -#include "" #include #include From 9fd125733b71f05ba23f0bf2480e01b0b442ddfd Mon Sep 17 00:00:00 2001 From: Nerum Date: Thu, 2 Mar 2023 11:46:53 +0100 Subject: [PATCH 043/106] Add some documentation --- tools/fm-editor/FeatureAddDialog.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/fm-editor/FeatureAddDialog.cpp b/tools/fm-editor/FeatureAddDialog.cpp index 76ac613eb..af7c3df71 100644 --- a/tools/fm-editor/FeatureAddDialog.cpp +++ b/tools/fm-editor/FeatureAddDialog.cpp @@ -56,6 +56,7 @@ std::vector stringToIntVector(string &Input) { return Out; } +///Retrieve the Feature defined by the dialog this should only be called after the dialog was accepted std::unique_ptr FeatureAddDialog::getFeature() { const std::string Name = getName().toStdString(); const bool Optional = isOptional(); From 6941ea2cba2e276fd5fc0b83c521864b2cf87882 Mon Sep 17 00:00:00 2001 From: Nerum Date: Thu, 2 Mar 2023 11:47:16 +0100 Subject: [PATCH 044/106] Remove Unused Methods --- tools/fm-editor/graph/FeatureEdge.cpp | 1 - tools/fm-editor/graph/FeatureModelGraph.h | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/fm-editor/graph/FeatureEdge.cpp b/tools/fm-editor/graph/FeatureEdge.cpp index 2ab7e99d4..6c218f342 100644 --- a/tools/fm-editor/graph/FeatureEdge.cpp +++ b/tools/fm-editor/graph/FeatureEdge.cpp @@ -27,7 +27,6 @@ void FeatureEdge::adjust() { prepareGeometryChange(); if (Length > qreal(20.)) { - QPointF EdgeOffset((Line.dx() * 10) / Length, (Line.dy() * 10) / Length); SourcePoint = Line.p1(); TargetPoint = Line.p2(); } else { diff --git a/tools/fm-editor/graph/FeatureModelGraph.h b/tools/fm-editor/graph/FeatureModelGraph.h index 07279ad57..80864e345 100644 --- a/tools/fm-editor/graph/FeatureModelGraph.h +++ b/tools/fm-editor/graph/FeatureModelGraph.h @@ -14,7 +14,6 @@ class FeatureModelGraph : public QGraphicsView { FeatureModelGraph(vara::feature::FeatureModel *FeatureModel, QWidget *Parent = nullptr); auto getNodes() { return &Nodes; }; - void itemMoved(); FeatureNode *getNode(std::string Name); FeatureNode *addNode(vara::feature::Feature *Feature, FeatureNode *Parent); void deleteNode(bool Recursive, vara::feature::Feature *Feature); @@ -44,6 +43,7 @@ public slots: unsigned long Offset); vara::feature::FeatureModel *FeatureModel; std::vector> Nodes; + std::unique_ptr Scene; }; #endif // VARA_FEATURE_FEATUREMODELGRAPH_H From 0b191f1ae537d412efdbd8e7750aeba22e486a7e Mon Sep 17 00:00:00 2001 From: Nerum Date: Thu, 2 Mar 2023 11:48:19 +0100 Subject: [PATCH 045/106] Use dyn_cast correctly --- tools/fm-editor/tree/FeatureTreeItem.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/fm-editor/tree/FeatureTreeItem.cpp b/tools/fm-editor/tree/FeatureTreeItem.cpp index bbbc4d103..6a0e34253 100644 --- a/tools/fm-editor/tree/FeatureTreeItem.cpp +++ b/tools/fm-editor/tree/FeatureTreeItem.cpp @@ -47,10 +47,10 @@ FeatureTreeItem::createFeatureTreeItem(vara::feature::FeatureTreeNode *Item) { if (Item->getKind() == vara::feature::FeatureTreeNode::NodeKind::NK_RELATIONSHIP) { return new FeatureTreeItemRelation( - dyn_cast(Item)); + llvm::dyn_cast(Item)); } - return new FeatureTreeItemFeature(dyn_cast(Item)); + return new FeatureTreeItemFeature(llvm::dyn_cast(Item)); } void FeatureTreeItem::addChild(FeatureTreeItem *Child) { From 2dc309b4f0d58bb43c31dd64254ef9f666c1aadf Mon Sep 17 00:00:00 2001 From: Nerum Date: Thu, 2 Mar 2023 11:52:44 +0100 Subject: [PATCH 046/106] only create new Treeview if we none exits --- tools/fm-editor/FeatureModelEditor.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/fm-editor/FeatureModelEditor.cpp b/tools/fm-editor/FeatureModelEditor.cpp index ab9d485c6..280ff497f 100644 --- a/tools/fm-editor/FeatureModelEditor.cpp +++ b/tools/fm-editor/FeatureModelEditor.cpp @@ -97,7 +97,9 @@ void FeatureModelEditor::loadGraph() { /// Build the Treeview void FeatureModelEditor::buildTree() { - TreeView = std::make_unique(); + if(!TreeView){ + TreeView = std::make_unique(this); + } TreeModel = std::make_unique(FeatureModel.get(), TreeView.get()); for (auto Item : TreeModel->getItems()) { From e0d1dd8b57d307c68ac053b41bc2ce04f5766a5c Mon Sep 17 00:00:00 2001 From: Nerum Date: Thu, 2 Mar 2023 11:56:12 +0100 Subject: [PATCH 047/106] format --- tools/fm-editor/FeatureAddDialog.cpp | 14 ++++++++------ tools/fm-editor/FeatureAddDialog.h | 2 +- tools/fm-editor/FeatureModelEditor.cpp | 13 +++++++------ tools/fm-editor/Utils.h | 5 +++-- tools/fm-editor/graph/FeatureNode.h | 6 ++++-- tools/fm-editor/tree/FeatureTreeItem.cpp | 7 +++++-- tools/fm-editor/tree/FeatureTreeItem.h | 1 - 7 files changed, 28 insertions(+), 20 deletions(-) diff --git a/tools/fm-editor/FeatureAddDialog.cpp b/tools/fm-editor/FeatureAddDialog.cpp index af7c3df71..fad08eada 100644 --- a/tools/fm-editor/FeatureAddDialog.cpp +++ b/tools/fm-editor/FeatureAddDialog.cpp @@ -43,7 +43,9 @@ vara::feature::Feature::FeatureKind FeatureAddDialog::getFeatureKind() { bool FeatureAddDialog::isOptional() const { return optinalCheck->isChecked(); } -QString FeatureAddDialog::getOutputString() const { return outpuString->text(); } +QString FeatureAddDialog::getOutputString() const { + return outpuString->text(); +} std::vector stringToIntVector(string &Input) { std::stringstream InStream(Input); @@ -51,12 +53,12 @@ std::vector stringToIntVector(string &Input) { for (std::string Substring; std::getline(InStream, Substring, ',');) { Out.push_back(std::stoi(Substring)); - } return Out; } -///Retrieve the Feature defined by the dialog this should only be called after the dialog was accepted +/// Retrieve the Feature defined by the dialog this should only be called after +/// the dialog was accepted std::unique_ptr FeatureAddDialog::getFeature() { const std::string Name = getName().toStdString(); const bool Optional = isOptional(); @@ -94,7 +96,7 @@ std::unique_ptr FeatureAddDialog::getNumericFeature() const { ValueRange = stringToIntVector(ValueString); } return std::make_unique( - Name, ValueRange, Optional, - std::vector(), OutputString, - std::move(SF)); + Name, ValueRange, Optional, + std::vector(), OutputString, + std::move(SF)); } diff --git a/tools/fm-editor/FeatureAddDialog.h b/tools/fm-editor/FeatureAddDialog.h index 4304847cd..2440a5f29 100644 --- a/tools/fm-editor/FeatureAddDialog.h +++ b/tools/fm-editor/FeatureAddDialog.h @@ -17,7 +17,7 @@ class FeatureAddDialog : public QDialog, public Ui::Add { QString getOutputString() const; std::unique_ptr getFeature(); vara::feature::Feature::FeatureKind getFeatureKind(); - bool isOptional() const ; + bool isOptional() const; public slots: void featureType(int index); diff --git a/tools/fm-editor/FeatureModelEditor.cpp b/tools/fm-editor/FeatureModelEditor.cpp index 280ff497f..31525501f 100644 --- a/tools/fm-editor/FeatureModelEditor.cpp +++ b/tools/fm-editor/FeatureModelEditor.cpp @@ -97,11 +97,11 @@ void FeatureModelEditor::loadGraph() { /// Build the Treeview void FeatureModelEditor::buildTree() { - if(!TreeView){ + if (!TreeView) { TreeView = std::make_unique(this); } - TreeModel = - std::make_unique(FeatureModel.get(), TreeView.get()); + TreeModel = std::make_unique(FeatureModel.get(), + TreeView.get()); for (auto Item : TreeModel->getItems()) { connect(Item, &FeatureTreeItem::inspectSource, this, &FeatureModelEditor::inspectFeatureSources); @@ -114,8 +114,8 @@ void FeatureModelEditor::buildTree() { &FeatureModelEditor::loadFeatureFromIndex); TreeView->setModel(TreeModel.get()); TreeView->setContextMenuPolicy(Qt::CustomContextMenu); - connect(TreeView.get(), SIGNAL(customContextMenuRequested(const QPoint &)), this, - SLOT(createTreeContextMenu(const QPoint &))); + connect(TreeView.get(), SIGNAL(customContextMenuRequested(const QPoint &)), + this, SLOT(createTreeContextMenu(const QPoint &))); } /// Build the graph view @@ -214,7 +214,8 @@ void FeatureModelEditor::createTreeContextMenu(const QPoint &Pos) { } } -/// Load the selected file into the textedit and mark the sources of the selected feature +/// Load the selected file into the textedit and mark the sources of the +/// selected feature /// /// \param RelativePath path to the source file relative to the repository path void FeatureModelEditor::loadSource(const QString &RelativePath) { diff --git a/tools/fm-editor/Utils.h b/tools/fm-editor/Utils.h index a46acd645..d83646815 100644 --- a/tools/fm-editor/Utils.h +++ b/tools/fm-editor/Utils.h @@ -9,7 +9,7 @@ struct ActionBuilder { template void addActions(std::pair Action, std::pair... Actions) { - Menu->addAction(Action.first,Receiver,Action.second); + Menu->addAction(Action.first, Receiver, Action.second); addActions(Actions...); } void addActions() {} @@ -20,7 +20,8 @@ struct ActionBuilder { }; template -std::unique_ptr buildMenu(T *Receiver, std::pair... Actions) { +std::unique_ptr buildMenu(T *Receiver, + std::pair... Actions) { auto Menu = std::make_unique(); ActionBuilder Builder(Menu.get(), Receiver); Builder.addActions(Actions...); diff --git a/tools/fm-editor/graph/FeatureNode.h b/tools/fm-editor/graph/FeatureNode.h index af661ce2d..e419748f4 100644 --- a/tools/fm-editor/graph/FeatureNode.h +++ b/tools/fm-editor/graph/FeatureNode.h @@ -6,8 +6,8 @@ #include #include -#include #include +#include class FeatureEdge; class FeatureModelGraph; @@ -39,7 +39,9 @@ class FeatureNode : public QObject, public QGraphicsItem { [[nodiscard]] std::string getName() const { return Feature->getName().str(); }; - ~FeatureNode() override { std::destroy(ChildEdges.begin(), ChildEdges.end()); } + ~FeatureNode() override { + std::destroy(ChildEdges.begin(), ChildEdges.end()); + } signals: void clicked(const vara::feature::Feature *Feature); diff --git a/tools/fm-editor/tree/FeatureTreeItem.cpp b/tools/fm-editor/tree/FeatureTreeItem.cpp index 6a0e34253..af00f5677 100644 --- a/tools/fm-editor/tree/FeatureTreeItem.cpp +++ b/tools/fm-editor/tree/FeatureTreeItem.cpp @@ -47,10 +47,13 @@ FeatureTreeItem::createFeatureTreeItem(vara::feature::FeatureTreeNode *Item) { if (Item->getKind() == vara::feature::FeatureTreeNode::NodeKind::NK_RELATIONSHIP) { return new FeatureTreeItemRelation( - llvm::dyn_cast(Item)); + llvm::dyn_cast(Item)); } - return new FeatureTreeItemFeature(llvm::dyn_cast(Item)); + return new FeatureTreeItemFeature( + llvm::dyn_cast( + Item)); } void FeatureTreeItem::addChild(FeatureTreeItem *Child) { diff --git a/tools/fm-editor/tree/FeatureTreeItem.h b/tools/fm-editor/tree/FeatureTreeItem.h index e90078d40..87b473af1 100644 --- a/tools/fm-editor/tree/FeatureTreeItem.h +++ b/tools/fm-editor/tree/FeatureTreeItem.h @@ -89,7 +89,6 @@ class FeatureTreeItemFeature : public FeatureTreeItem { std::pair(QString("Add Child"), &FeatureTreeItemFeature::addChild), std::pair(QString("Remove"), &FeatureTreeItemFeature::remove)); // TODO Make recursive Removal work - } [[nodiscard]] QVariant data(int Column) const override; [[nodiscard]] int columnCount() const override { return 5; } From 3cfb05048ae42d159d7c39f9d5009ee964cb068a Mon Sep 17 00:00:00 2001 From: Nerum Date: Thu, 2 Mar 2023 11:58:41 +0100 Subject: [PATCH 048/106] make the highlighter a unique pointer --- tools/fm-editor/FeatureModelEditor.cpp | 6 +++--- tools/fm-editor/FeatureModelEditor.h | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/fm-editor/FeatureModelEditor.cpp b/tools/fm-editor/FeatureModelEditor.cpp index 31525501f..858cb7113 100644 --- a/tools/fm-editor/FeatureModelEditor.cpp +++ b/tools/fm-editor/FeatureModelEditor.cpp @@ -23,9 +23,9 @@ FeatureModelEditor::FeatureModelEditor(QWidget *Parent) Ui->setupUi(this); Ui->textEdit->setReadOnly(true); - auto *Highliter = - new QSourceHighlite::QSourceHighliter(Ui->textEdit->document()); - Highliter->setCurrentLanguage(QSourceHighlite::QSourceHighliter::CodeCpp); + Highlighter = std::make_unique( + Ui->textEdit->document()); + Highlighter->setCurrentLanguage(QSourceHighlite::QSourceHighliter::CodeCpp); QObject::connect(Ui->loadModel, &QPushButton::pressed, this, &FeatureModelEditor::loadGraph); QObject::connect(Ui->actionAddFeature, &QAction::triggered, this, diff --git a/tools/fm-editor/FeatureModelEditor.h b/tools/fm-editor/FeatureModelEditor.h index ec472e977..a5e072844 100644 --- a/tools/fm-editor/FeatureModelEditor.h +++ b/tools/fm-editor/FeatureModelEditor.h @@ -2,6 +2,7 @@ #define VARA_FEATURE_FEATUREMODELEDITOR_H #include "graph/FeatureModelGraph.h" +#include "qsourcehighliter.h" #include "tree/FeatureTreeViewModel.h" #include "vara/Feature/Feature.h" #include "vara/Feature/FeatureModel.h" @@ -54,6 +55,7 @@ public slots: void buildGraph(); void buildTree(); void markLocation(vara::feature::FeatureSourceRange &Location) const; + std::unique_ptr Highlighter; }; #endif // VARA_FEATURE_FEATUREMODELEDITOR_H From a3f56e88cf42eff7b15e1daa293feb95b1c2f27a Mon Sep 17 00:00:00 2001 From: Nerum Date: Thu, 2 Mar 2023 12:10:20 +0100 Subject: [PATCH 049/106] fix typos --- tools/fm-editor/FeatureAddDialog.cpp | 6 ++-- tools/fm-editor/FeatureAddDialog.h | 1 - tools/fm-editor/FeatureAddDialog.ui | 14 ++++----- tools/fm-editor/FeatureModelEditor.cpp | 42 ++++++++++++-------------- 4 files changed, 30 insertions(+), 33 deletions(-) diff --git a/tools/fm-editor/FeatureAddDialog.cpp b/tools/fm-editor/FeatureAddDialog.cpp index fad08eada..9ab419e60 100644 --- a/tools/fm-editor/FeatureAddDialog.cpp +++ b/tools/fm-editor/FeatureAddDialog.cpp @@ -41,10 +41,10 @@ vara::feature::Feature::FeatureKind FeatureAddDialog::getFeatureKind() { return vara::feature::Feature::FeatureKind(FeatureKind->currentIndex()); } -bool FeatureAddDialog::isOptional() const { return optinalCheck->isChecked(); } +bool FeatureAddDialog::isOptional() const { return optionalCheck->isChecked(); } QString FeatureAddDialog::getOutputString() const { - return outpuString->text(); + return outputString->text(); } std::vector stringToIntVector(string &Input) { @@ -88,7 +88,7 @@ std::unique_ptr FeatureAddDialog::getNumericFeature() const { max->value()); if (lhs->isChecked()) { SF = std::make_unique( - stepOperant->value(), vara::feature::StepFunction::StepOperation( + stepOperand->value(), vara::feature::StepFunction::StepOperation( stepOperator->currentIndex())); } } else { diff --git a/tools/fm-editor/FeatureAddDialog.h b/tools/fm-editor/FeatureAddDialog.h index 2440a5f29..251f3147e 100644 --- a/tools/fm-editor/FeatureAddDialog.h +++ b/tools/fm-editor/FeatureAddDialog.h @@ -25,7 +25,6 @@ public slots: private: QStringList NodeNames; - vara::feature::StepFunction::StepOperation getStepOperation(); std::unique_ptr getNumericFeature() const; }; diff --git a/tools/fm-editor/FeatureAddDialog.ui b/tools/fm-editor/FeatureAddDialog.ui index 1be4e6af6..fd27514d7 100644 --- a/tools/fm-editor/FeatureAddDialog.ui +++ b/tools/fm-editor/FeatureAddDialog.ui @@ -41,7 +41,7 @@ - + Optional @@ -68,10 +68,10 @@ - + - + Name @@ -135,7 +135,7 @@ - + 10000000.000000000000000 @@ -171,7 +171,7 @@ - Value is Left Operant + Value is Left Operand @@ -192,11 +192,11 @@ Add accept() - + 248 254 - + 157 274 diff --git a/tools/fm-editor/FeatureModelEditor.cpp b/tools/fm-editor/FeatureModelEditor.cpp index 858cb7113..440355577 100644 --- a/tools/fm-editor/FeatureModelEditor.cpp +++ b/tools/fm-editor/FeatureModelEditor.cpp @@ -1,8 +1,7 @@ -#include "FeatureModelEditor.h" #include "FeatureAddDialog.h" +#include "FeatureModelEditor.h" #include "graph/FeatureModelGraph.h" #include "graph/FeatureNode.h" -#include "qsourcehighliter.h" #include "ui_FeatureModelEditor.h" #include "vara/Feature/FeatureModel.h" #include "vara/Feature/FeatureModelTransaction.h" @@ -11,7 +10,6 @@ #include #include -namespace fs = std::filesystem; using vara::feature::FeatureModel; using Transaction = vara::feature::FeatureModelTransaction< @@ -46,11 +44,11 @@ void FeatureModelEditor::loadFeature(const vara::feature::Feature *Feature) { /// Get a Feature from an Index of the TreeView and display its information. void FeatureModelEditor::loadFeatureFromIndex(const QModelIndex &Index) { if (Index.isValid()) { - auto Item = static_cast(Index.internalPointer()) + auto* Item = static_cast(Index.internalPointer()) ->child(Index.row()); if (Item->getKind() == vara::feature::FeatureTreeNode::NodeKind::NK_FEATURE) { - loadFeature(static_cast(Item)->getItem()); + loadFeature(dynamic_cast(Item)->getItem()); } } } @@ -102,7 +100,7 @@ void FeatureModelEditor::buildTree() { } TreeModel = std::make_unique(FeatureModel.get(), TreeView.get()); - for (auto Item : TreeModel->getItems()) { + for (auto* Item : TreeModel->getItems()) { connect(Item, &FeatureTreeItem::inspectSource, this, &FeatureModelEditor::inspectFeatureSources); connect(Item, &FeatureTreeItem::addChildFeature, this, @@ -114,8 +112,8 @@ void FeatureModelEditor::buildTree() { &FeatureModelEditor::loadFeatureFromIndex); TreeView->setModel(TreeModel.get()); TreeView->setContextMenuPolicy(Qt::CustomContextMenu); - connect(TreeView.get(), SIGNAL(customContextMenuRequested(const QPoint &)), - this, SLOT(createTreeContextMenu(const QPoint &))); + connect(TreeView.get(), SIGNAL(customContextMenuRequested(QPoint)), + this, SLOT(createTreeContextMenu(QPoint))); } /// Build the graph view @@ -250,15 +248,15 @@ void FeatureModelEditor::markLocation( QTextCursor Cursor(Ui->textEdit->document()); Cursor.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor); Cursor.movePosition(QTextCursor::Down, QTextCursor::MoveAnchor, - Location.getStart()->getLineNumber() - 1); + int(Location.getStart()->getLineNumber()) - 1); Cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::MoveAnchor, - Location.getStart()->getColumnOffset() - 1); + int(Location.getStart()->getColumnOffset()) - 1); Cursor.movePosition(QTextCursor::Down, QTextCursor::KeepAnchor, - Location.getEnd()->getLineNumber() - - Location.getStart()->getLineNumber()); + int(Location.getEnd()->getLineNumber()) - + int(Location.getStart()->getLineNumber())); Cursor.movePosition(QTextCursor::StartOfLine, QTextCursor::KeepAnchor); Cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, - Location.getEnd()->getColumnOffset()); + int(Location.getEnd()->getColumnOffset())); Cursor.setCharFormat(Fmt); } @@ -275,29 +273,29 @@ void FeatureModelEditor::addSourceFile() { /// Add the user selected Part of the textedit as a source for the active /// Feature void FeatureModelEditor::addSource() { - auto TextEdit = Ui->textEdit; + auto * TextEdit = Ui->textEdit; auto Cursor = TextEdit->textCursor(); - int start = Cursor.selectionStart(); - int end = Cursor.selectionEnd(); + int const Start = Cursor.selectionStart(); + int const End = Cursor.selectionEnd(); Cursor.movePosition(QTextCursor::MoveOperation::StartOfLine); - int lineStart = Cursor.position(); - int lines = 1; + int const LineStart = Cursor.position(); + int Lines = 1; auto Block = Cursor.block(); while (Cursor.position() > Block.position()) { Cursor.movePosition(QTextCursor::MoveOperation::Up); - lines++; + Lines++; } Block = Block.previous(); while (Block.isValid()) { - lines += Block.lineCount(); + Lines += Block.lineCount(); Block = Block.previous(); } auto Range = vara::feature::FeatureSourceRange( Ui->sources->currentText().toStdString(), vara::feature::FeatureSourceRange::FeatureSourceLocation( - lines, start - lineStart + 1), + Lines, Start - LineStart + 1), vara::feature::FeatureSourceRange::FeatureSourceLocation( - lines, end - lineStart)); + Lines, End - LineStart)); auto LocationTransAction = Transaction::openTransaction(*FeatureModel); LocationTransAction.addLocation(CurrentFeature, Range); LocationTransAction.commit(); From 6cd51d77b059167c7a6994d3ffd91fc1ddf2cf8c Mon Sep 17 00:00:00 2001 From: Nerum Date: Thu, 2 Mar 2023 13:08:18 +0100 Subject: [PATCH 050/106] rework menu for FeatureTreeItems to use a QueuedConnection for remove in order to close the menu before it gets deleted. --- tools/fm-editor/FeatureModelEditor.cpp | 10 ++-- tools/fm-editor/Utils.h | 31 ----------- tools/fm-editor/tree/FeatureTreeItem.cpp | 6 +-- tools/fm-editor/tree/FeatureTreeItem.h | 51 +++++++------------ tools/fm-editor/tree/FeatureTreeViewModel.cpp | 14 ++--- tools/fm-editor/tree/FeatureTreeViewModel.h | 42 ++++++++++++--- 6 files changed, 68 insertions(+), 86 deletions(-) delete mode 100644 tools/fm-editor/Utils.h diff --git a/tools/fm-editor/FeatureModelEditor.cpp b/tools/fm-editor/FeatureModelEditor.cpp index 440355577..5538a4084 100644 --- a/tools/fm-editor/FeatureModelEditor.cpp +++ b/tools/fm-editor/FeatureModelEditor.cpp @@ -48,7 +48,7 @@ void FeatureModelEditor::loadFeatureFromIndex(const QModelIndex &Index) { ->child(Index.row()); if (Item->getKind() == vara::feature::FeatureTreeNode::NodeKind::NK_FEATURE) { - loadFeature(dynamic_cast(Item)->getItem()); + loadFeature(dynamic_cast(Item)->getFeature()); } } } @@ -100,12 +100,12 @@ void FeatureModelEditor::buildTree() { } TreeModel = std::make_unique(FeatureModel.get(), TreeView.get()); - for (auto* Item : TreeModel->getItems()) { - connect(Item, &FeatureTreeItem::inspectSource, this, + for (auto &Item : *TreeModel->getItems()) { + connect(Item.get(), &FeatureTreeItem::inspectSource, this, &FeatureModelEditor::inspectFeatureSources); - connect(Item, &FeatureTreeItem::addChildFeature, this, + connect(Item.get(), &FeatureTreeItem::addChildFeature, this, &FeatureModelEditor::featureAddDialogChild); - connect(Item, &FeatureTreeItem::removeFeature, this, + connect(Item.get(), &FeatureTreeItem::removeFeature, this, &FeatureModelEditor::removeFeature); } connect(TreeView.get(), &QTreeView::pressed, this, diff --git a/tools/fm-editor/Utils.h b/tools/fm-editor/Utils.h deleted file mode 100644 index d83646815..000000000 --- a/tools/fm-editor/Utils.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef VARA_FEATURE_UTILS_H -#define VARA_FEATURE_UTILS_H - -#include - -template -struct ActionBuilder { - ActionBuilder(QMenu *Menu, T *Receiver) : Menu(Menu), Receiver(Receiver) {} - template - void addActions(std::pair Action, - std::pair... Actions) { - Menu->addAction(Action.first, Receiver, Action.second); - addActions(Actions...); - } - void addActions() {} - -private: - QMenu *Menu; - T *Receiver; -}; - -template -std::unique_ptr buildMenu(T *Receiver, - std::pair... Actions) { - auto Menu = std::make_unique(); - ActionBuilder Builder(Menu.get(), Receiver); - Builder.addActions(Actions...); - return Menu; -} - -#endif // VARA_FEATURE_UTILS_H diff --git a/tools/fm-editor/tree/FeatureTreeItem.cpp b/tools/fm-editor/tree/FeatureTreeItem.cpp index af00f5677..ed615bc5c 100644 --- a/tools/fm-editor/tree/FeatureTreeItem.cpp +++ b/tools/fm-editor/tree/FeatureTreeItem.cpp @@ -42,16 +42,16 @@ QVariant locationString(vara::feature::Feature *Item) { return QString::fromStdString(StrS.str()); } -FeatureTreeItem * +std::unique_ptr FeatureTreeItem::createFeatureTreeItem(vara::feature::FeatureTreeNode *Item) { if (Item->getKind() == vara::feature::FeatureTreeNode::NodeKind::NK_RELATIONSHIP) { - return new FeatureTreeItemRelation( + return std::make_unique( llvm::dyn_cast(Item)); } - return new FeatureTreeItemFeature( + return std::make_unique( llvm::dyn_cast( Item)); } diff --git a/tools/fm-editor/tree/FeatureTreeItem.h b/tools/fm-editor/tree/FeatureTreeItem.h index 87b473af1..cc71d58b9 100644 --- a/tools/fm-editor/tree/FeatureTreeItem.h +++ b/tools/fm-editor/tree/FeatureTreeItem.h @@ -1,7 +1,6 @@ #ifndef VARA_FEATURE_FEATURETREEITEM_H #define VARA_FEATURE_FEATURETREEITEM_H -#include "Utils.h" #include "vara/Feature/Feature.h" #include "vara/Feature/Relationship.h" @@ -36,10 +35,11 @@ class FeatureTreeItem : public QObject { std::vector &getChildren() { return Children; } [[nodiscard]] virtual int columnCount() const = 0; [[nodiscard]] virtual QVariant data(int Column) const = 0; - FeatureTreeItem static * - createFeatureTreeItem(vara::feature::FeatureTreeNode *Item); + std::unique_ptr static createFeatureTreeItem( + vara::feature::FeatureTreeNode *Item); static bool booleanColumn(int Column) { return false; } virtual void contextMenu(QPoint Pos) = 0; + virtual vara::feature::FeatureTreeNode *getItem() const = 0; vara::feature::FeatureTreeNode::NodeKind getKind() { return Kind; } virtual string getName() { return ""; }; void setParent(FeatureTreeItem *ParentItem) { this->Parent = ParentItem; } @@ -49,23 +49,7 @@ class FeatureTreeItem : public QObject { void removeFeature(bool Recursive, vara::feature::Feature *Feature); protected: - FeatureTreeItem(vara::feature::FeatureTreeNode *Item, - vara::feature::FeatureTreeNode::NodeKind Kind) - : Kind(Kind) { - for (auto *Child : Item->children()) { - if (vara::feature::Relationship::classof(Child)) { - auto child = createFeatureTreeItem( - dynamic_cast(Child)); - Children.push_back(child); - child->setParent(this); - } else { - auto child = createFeatureTreeItem( - dynamic_cast(Child)); - Children.push_back(child); - child->setParent(this); - } - } - } + FeatureTreeItem(vara::feature::FeatureTreeNode::NodeKind Kind) : Kind(Kind) {} FeatureTreeItem *Parent = nullptr; @@ -80,39 +64,41 @@ class FeatureTreeItemFeature : public FeatureTreeItem { public: virtual ~FeatureTreeItemFeature() = default; FeatureTreeItemFeature(vara::feature::Feature *Item) - : FeatureTreeItem(Item, - vara::feature::FeatureTreeNode::NodeKind::NK_FEATURE), + : FeatureTreeItem(vara::feature::FeatureTreeNode::NodeKind::NK_FEATURE), Item(Item) { - ContextMenu = buildMenu( - this, - std::pair(QString("Inspect Sources"), &FeatureTreeItemFeature::inspect), - std::pair(QString("Add Child"), &FeatureTreeItemFeature::addChild), - std::pair(QString("Remove"), &FeatureTreeItemFeature::remove)); - // TODO Make recursive Removal work + ContextMenu = std::make_unique(); + ContextMenu->addAction("Inspect Sources", this, + &FeatureTreeItemFeature::inspect); + ContextMenu->addAction("Add Child", this, + &FeatureTreeItemFeature::addChild); + RemoveAction = std::make_unique("Remove"); + connect(RemoveAction.get(), &QAction::triggered, this, + &FeatureTreeItemFeature::remove,Qt::QueuedConnection); } [[nodiscard]] QVariant data(int Column) const override; [[nodiscard]] int columnCount() const override { return 5; } static bool booleanColumn(int Column) { return Column == 1; } void contextMenu(QPoint Pos) override; - const vara::feature::Feature *getItem() const { return Item; } + vara::feature::FeatureTreeNode *getItem() const override { return Item; } + const vara::feature::Feature *getFeature() const { return Item; } string getName() override { return Item->getName().str(); } public slots: void inspect(); void addChild(); - void removeRecursive(); void remove(); private: vara::feature::Feature *Item; std::unique_ptr ContextMenu; + std::unique_ptr RemoveAction; }; class FeatureTreeItemRelation : public FeatureTreeItem { public: - virtual ~FeatureTreeItemRelation() = default; + ~FeatureTreeItemRelation() override = default; FeatureTreeItemRelation(vara::feature::Relationship *Item) : FeatureTreeItem( - Item, vara::feature::FeatureTreeNode::NodeKind::NK_RELATIONSHIP), + vara::feature::FeatureTreeNode::NodeKind::NK_RELATIONSHIP), Item(Item) {} [[nodiscard]] QVariant data(int Column) const override { if (Column == 0) { @@ -122,6 +108,7 @@ class FeatureTreeItemRelation : public FeatureTreeItem { } [[nodiscard]] int columnCount() const override { return 1; } void contextMenu(QPoint Pos) override {} + vara::feature::FeatureTreeNode *getItem() const override { return Item; } private: vara::feature::Relationship *Item; diff --git a/tools/fm-editor/tree/FeatureTreeViewModel.cpp b/tools/fm-editor/tree/FeatureTreeViewModel.cpp index a6c8e45ac..20e7e4eed 100644 --- a/tools/fm-editor/tree/FeatureTreeViewModel.cpp +++ b/tools/fm-editor/tree/FeatureTreeViewModel.cpp @@ -107,8 +107,8 @@ QVariant FeatureTreeViewModel::headerData(int Section, return {}; } -std::vector FeatureTreeViewModel::getItems() { - return Items; +std::vector>* FeatureTreeViewModel::getItems() { + return &Items; } FeatureTreeItem * @@ -117,9 +117,10 @@ FeatureTreeViewModel::addFeature(vara::feature::Feature *Feature, auto Item = getItem(Parent); if (Item) { auto NewItem = FeatureTreeItem::createFeatureTreeItem(Feature); - Item->addChild(NewItem); - Items.push_back(NewItem); - return NewItem; + Item->addChild(NewItem.get()); + auto *NewItemRaw = NewItem.get(); + Items.push_back(std::move(NewItem)); + return NewItemRaw; } return nullptr; @@ -156,6 +157,5 @@ void FeatureTreeViewModel::deleteItem(bool Recursive, FeatureTreeItem *Item) { } } - Items.erase(std::find(Items.begin(), Items.end(), Item)); - delete Item; + Items.erase(std::find_if(Items.begin(), Items.end(), [Item](auto &I) {return I.get()==Item;})); } diff --git a/tools/fm-editor/tree/FeatureTreeViewModel.h b/tools/fm-editor/tree/FeatureTreeViewModel.h index 98ec7fb6e..56c6b6cf1 100644 --- a/tools/fm-editor/tree/FeatureTreeViewModel.h +++ b/tools/fm-editor/tree/FeatureTreeViewModel.h @@ -9,13 +9,18 @@ class FeatureTreeViewModel : public QAbstractItemModel { public: FeatureTreeViewModel(vara::feature::FeatureModel *Model, QObject *Parent) - : QAbstractItemModel(Parent), Model(Model), - RootItem(FeatureTreeItem::createFeatureTreeItem(Model->getRoot())) { - Items = RootItem->getChildrenRecursive(); - Items.push_back(RootItem); + : QAbstractItemModel(Parent), Model(Model) + { + auto UniqueRoot = FeatureTreeItem::createFeatureTreeItem(Model->getRoot()); + RootItem = UniqueRoot.get(); + Items.push_back(std::move(UniqueRoot)); + buildRecursive(RootItem); + } + + ~FeatureTreeViewModel() override { std::destroy(Items.begin(), Items.end()); } - std::vector getItems(); + std::vector>* getItems(); [[nodiscard]] QVariant data(const QModelIndex &Index, int Role = Qt::DisplayRole) const override; [[nodiscard]] int @@ -34,18 +39,39 @@ class FeatureTreeViewModel : public QAbstractItemModel { void deleteItem(bool Recursive, FeatureTreeItem *Item); FeatureTreeItem *getItem(string Name) { auto Item = std::find_if(Items.begin(), Items.end(), - [&Name](auto I) { return I->getName() == Name; }); + [&Name](const auto &I) { return I->getName() == Name; }); if (Item != Items.end()) { - return *Item; + return Item->get(); } return nullptr; } private: + void buildRecursive(FeatureTreeItem* Parent) { + for (auto *ChildItem : Parent->getItem()->children()) { + FeatureTreeItem* RawChild; + if (vara::feature::Relationship::classof(ChildItem)) { + auto Child = FeatureTreeItem::createFeatureTreeItem( + dynamic_cast(ChildItem)); + Parent->addChild(Child.get()); + Child->setParent(Parent); + RawChild = Child.get(); + Items.push_back(std::move(Child)); + } else { + auto Child = FeatureTreeItem::createFeatureTreeItem( + dynamic_cast(ChildItem)); + Parent->addChild(Child.get()); + Child->setParent(Parent); + RawChild = Child.get(); + Items.push_back(std::move(Child)); + } + buildRecursive(RawChild); + } + } vara::feature::FeatureModel *Model; FeatureTreeItem *RootItem; - std::vector Items; + std::vector> Items; }; #endif // VARA_FEATURE_FEATURETREEVIEWMODEL_H From 7a3ee48ff99a098955feafacb84ef38bba5a9a1b Mon Sep 17 00:00:00 2001 From: Nerum Date: Thu, 2 Mar 2023 13:09:17 +0100 Subject: [PATCH 051/106] format --- tools/fm-editor/FeatureModelEditor.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tools/fm-editor/FeatureModelEditor.cpp b/tools/fm-editor/FeatureModelEditor.cpp index 5538a4084..09d9d8979 100644 --- a/tools/fm-editor/FeatureModelEditor.cpp +++ b/tools/fm-editor/FeatureModelEditor.cpp @@ -1,5 +1,5 @@ -#include "FeatureAddDialog.h" #include "FeatureModelEditor.h" +#include "FeatureAddDialog.h" #include "graph/FeatureModelGraph.h" #include "graph/FeatureNode.h" #include "ui_FeatureModelEditor.h" @@ -10,7 +10,6 @@ #include #include - using vara::feature::FeatureModel; using Transaction = vara::feature::FeatureModelTransaction< vara::feature::detail::ModifyTransactionMode>; @@ -44,8 +43,8 @@ void FeatureModelEditor::loadFeature(const vara::feature::Feature *Feature) { /// Get a Feature from an Index of the TreeView and display its information. void FeatureModelEditor::loadFeatureFromIndex(const QModelIndex &Index) { if (Index.isValid()) { - auto* Item = static_cast(Index.internalPointer()) - ->child(Index.row()); + auto *Item = static_cast(Index.internalPointer()) + ->child(Index.row()); if (Item->getKind() == vara::feature::FeatureTreeNode::NodeKind::NK_FEATURE) { loadFeature(dynamic_cast(Item)->getFeature()); @@ -112,8 +111,8 @@ void FeatureModelEditor::buildTree() { &FeatureModelEditor::loadFeatureFromIndex); TreeView->setModel(TreeModel.get()); TreeView->setContextMenuPolicy(Qt::CustomContextMenu); - connect(TreeView.get(), SIGNAL(customContextMenuRequested(QPoint)), - this, SLOT(createTreeContextMenu(QPoint))); + connect(TreeView.get(), SIGNAL(customContextMenuRequested(QPoint)), this, + SLOT(createTreeContextMenu(QPoint))); } /// Build the graph view @@ -273,7 +272,7 @@ void FeatureModelEditor::addSourceFile() { /// Add the user selected Part of the textedit as a source for the active /// Feature void FeatureModelEditor::addSource() { - auto * TextEdit = Ui->textEdit; + auto *TextEdit = Ui->textEdit; auto Cursor = TextEdit->textCursor(); int const Start = Cursor.selectionStart(); int const End = Cursor.selectionEnd(); From 0860ac8d73a9be785edb0867f7fe095f74869cf3 Mon Sep 17 00:00:00 2001 From: Nerum Date: Thu, 2 Mar 2023 13:20:06 +0100 Subject: [PATCH 052/106] format --- tools/fm-editor/tree/FeatureTreeItem.h | 2 +- tools/fm-editor/tree/FeatureTreeViewModel.cpp | 6 ++++-- tools/fm-editor/tree/FeatureTreeViewModel.h | 16 +++++++--------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tools/fm-editor/tree/FeatureTreeItem.h b/tools/fm-editor/tree/FeatureTreeItem.h index cc71d58b9..a50173e44 100644 --- a/tools/fm-editor/tree/FeatureTreeItem.h +++ b/tools/fm-editor/tree/FeatureTreeItem.h @@ -73,7 +73,7 @@ class FeatureTreeItemFeature : public FeatureTreeItem { &FeatureTreeItemFeature::addChild); RemoveAction = std::make_unique("Remove"); connect(RemoveAction.get(), &QAction::triggered, this, - &FeatureTreeItemFeature::remove,Qt::QueuedConnection); + &FeatureTreeItemFeature::remove, Qt::QueuedConnection); } [[nodiscard]] QVariant data(int Column) const override; [[nodiscard]] int columnCount() const override { return 5; } diff --git a/tools/fm-editor/tree/FeatureTreeViewModel.cpp b/tools/fm-editor/tree/FeatureTreeViewModel.cpp index 20e7e4eed..8db1a06c0 100644 --- a/tools/fm-editor/tree/FeatureTreeViewModel.cpp +++ b/tools/fm-editor/tree/FeatureTreeViewModel.cpp @@ -107,7 +107,8 @@ QVariant FeatureTreeViewModel::headerData(int Section, return {}; } -std::vector>* FeatureTreeViewModel::getItems() { +std::vector> * +FeatureTreeViewModel::getItems() { return &Items; } @@ -157,5 +158,6 @@ void FeatureTreeViewModel::deleteItem(bool Recursive, FeatureTreeItem *Item) { } } - Items.erase(std::find_if(Items.begin(), Items.end(), [Item](auto &I) {return I.get()==Item;})); + Items.erase(std::find_if(Items.begin(), Items.end(), + [Item](auto &I) { return I.get() == Item; })); } diff --git a/tools/fm-editor/tree/FeatureTreeViewModel.h b/tools/fm-editor/tree/FeatureTreeViewModel.h index 56c6b6cf1..d9707b409 100644 --- a/tools/fm-editor/tree/FeatureTreeViewModel.h +++ b/tools/fm-editor/tree/FeatureTreeViewModel.h @@ -9,18 +9,15 @@ class FeatureTreeViewModel : public QAbstractItemModel { public: FeatureTreeViewModel(vara::feature::FeatureModel *Model, QObject *Parent) - : QAbstractItemModel(Parent), Model(Model) - { + : QAbstractItemModel(Parent), Model(Model) { auto UniqueRoot = FeatureTreeItem::createFeatureTreeItem(Model->getRoot()); RootItem = UniqueRoot.get(); Items.push_back(std::move(UniqueRoot)); buildRecursive(RootItem); - } - ~FeatureTreeViewModel() override { std::destroy(Items.begin(), Items.end()); } - std::vector>* getItems(); + std::vector> *getItems(); [[nodiscard]] QVariant data(const QModelIndex &Index, int Role = Qt::DisplayRole) const override; [[nodiscard]] int @@ -38,8 +35,9 @@ class FeatureTreeViewModel : public QAbstractItemModel { void deleteFeatureItem(bool Recursive, vara::feature::Feature *Feature); void deleteItem(bool Recursive, FeatureTreeItem *Item); FeatureTreeItem *getItem(string Name) { - auto Item = std::find_if(Items.begin(), Items.end(), - [&Name](const auto &I) { return I->getName() == Name; }); + auto Item = + std::find_if(Items.begin(), Items.end(), + [&Name](const auto &I) { return I->getName() == Name; }); if (Item != Items.end()) { return Item->get(); } @@ -48,9 +46,9 @@ class FeatureTreeViewModel : public QAbstractItemModel { } private: - void buildRecursive(FeatureTreeItem* Parent) { + void buildRecursive(FeatureTreeItem *Parent) { for (auto *ChildItem : Parent->getItem()->children()) { - FeatureTreeItem* RawChild; + FeatureTreeItem *RawChild; if (vara::feature::Relationship::classof(ChildItem)) { auto Child = FeatureTreeItem::createFeatureTreeItem( dynamic_cast(ChildItem)); From 53aa4f5b3798ab002542cc42179c1d0a1d29a45a Mon Sep 17 00:00:00 2001 From: Nerum Date: Thu, 2 Mar 2023 13:36:44 +0100 Subject: [PATCH 053/106] add support for Both qt5 and 6 --- tools/fm-editor/CMakeLists.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/fm-editor/CMakeLists.txt b/tools/fm-editor/CMakeLists.txt index aba5190ec..a4a4a3234 100644 --- a/tools/fm-editor/CMakeLists.txt +++ b/tools/fm-editor/CMakeLists.txt @@ -4,8 +4,11 @@ set(LLVM_LINK_COMPONENTS Core ) set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTOUIC ON) -find_package(Qt6 REQUIRED COMPONENTS Widgets) +set(CMAKE_AUTOUI C ON) +find_package(Qt6 COMPONENTS Widgets) +if (NOT Qt6_FOUND) + find_package(Qt5 5.15 REQUIRED COMPONENTS Widgets) +endif() include_directories(../../external/qsourcehighlite) include_directories(.) From de394e63896597176cac15147cdc98db8c448887 Mon Sep 17 00:00:00 2001 From: Nerum Date: Thu, 2 Mar 2023 15:49:56 +0100 Subject: [PATCH 054/106] Make everything qt5 compatible --- tools/fm-editor/CMakeLists.txt | 2 +- tools/fm-editor/FeatureAddDialog.cpp | 2 +- tools/fm-editor/FeatureAddDialog.h | 2 +- tools/fm-editor/FeatureModelEditor.cpp | 3 ++- tools/fm-editor/tree/FeatureTreeItem.cpp | 4 ---- 5 files changed, 5 insertions(+), 8 deletions(-) diff --git a/tools/fm-editor/CMakeLists.txt b/tools/fm-editor/CMakeLists.txt index a4a4a3234..590a340de 100644 --- a/tools/fm-editor/CMakeLists.txt +++ b/tools/fm-editor/CMakeLists.txt @@ -4,7 +4,7 @@ set(LLVM_LINK_COMPONENTS Core ) set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTOUI C ON) +set(CMAKE_AUTOUIC ON) find_package(Qt6 COMPONENTS Widgets) if (NOT Qt6_FOUND) find_package(Qt5 5.15 REQUIRED COMPONENTS Widgets) diff --git a/tools/fm-editor/FeatureAddDialog.cpp b/tools/fm-editor/FeatureAddDialog.cpp index 9ab419e60..8524f3ae1 100644 --- a/tools/fm-editor/FeatureAddDialog.cpp +++ b/tools/fm-editor/FeatureAddDialog.cpp @@ -21,7 +21,7 @@ FeatureAddDialog::FeatureAddDialog(FeatureModelGraph *Graph, QWidget *Parent, this->FeatureKind->addItems(QStringList{"Binary", "Numeric"}); stepOperator->addItems(QStringList{"Add +", "Multiply *", "Exp ^"}); NumericFeature->setVisible(false); - connect(FeatureKind, &QComboBox::activated, this, + connect(FeatureKind, QOverload::of(&QComboBox::activated), this, &FeatureAddDialog::featureType); } diff --git a/tools/fm-editor/FeatureAddDialog.h b/tools/fm-editor/FeatureAddDialog.h index 251f3147e..7b1345413 100644 --- a/tools/fm-editor/FeatureAddDialog.h +++ b/tools/fm-editor/FeatureAddDialog.h @@ -20,7 +20,7 @@ class FeatureAddDialog : public QDialog, public Ui::Add { bool isOptional() const; public slots: - void featureType(int index); + void featureType(int Index); private: QStringList NodeNames; diff --git a/tools/fm-editor/FeatureModelEditor.cpp b/tools/fm-editor/FeatureModelEditor.cpp index 09d9d8979..b17c2da13 100644 --- a/tools/fm-editor/FeatureModelEditor.cpp +++ b/tools/fm-editor/FeatureModelEditor.cpp @@ -9,6 +9,7 @@ #include #include +#include using vara::feature::FeatureModel; using Transaction = vara::feature::FeatureModelTransaction< @@ -265,7 +266,7 @@ void FeatureModelEditor::addSourceFile() { QString const Path = QFileDialog::getOpenFileName(this, tr("Select Source File"), Repository, tr("C Files (*.c *c++ *.h)")); - Ui->sources->addItem(Path.sliced(Repository.length())); + Ui->sources->addItem(Path.mid(Repository.length())); } } diff --git a/tools/fm-editor/tree/FeatureTreeItem.cpp b/tools/fm-editor/tree/FeatureTreeItem.cpp index ed615bc5c..e41ae72ef 100644 --- a/tools/fm-editor/tree/FeatureTreeItem.cpp +++ b/tools/fm-editor/tree/FeatureTreeItem.cpp @@ -102,8 +102,4 @@ void FeatureTreeItemFeature::contextMenu(QPoint Pos) { void FeatureTreeItemFeature::remove() { emit(removeFeature(false, Item)); } -void FeatureTreeItemFeature::removeRecursive() { - emit(removeFeature(true, Item)); -} - void FeatureTreeItemFeature::addChild() { emit(addChildFeature(Item)); } From 82df3c6c44058ba169623b5ec3402972e38707b8 Mon Sep 17 00:00:00 2001 From: Nerum Date: Thu, 2 Mar 2023 15:52:11 +0100 Subject: [PATCH 055/106] Add qt6-dev install to github workflow --- .github/workflows/build.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 17d274acb..4091f8599 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -46,7 +46,11 @@ jobs: sudo add-apt-repository -y 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-15 main' sudo apt-get update sudo apt-get -y install --no-install-recommends clang-${{ matrix.llvm-major }} llvm-${{ matrix.llvm-major }}-dev clang-tidy-14 - + - name: Install Tool Dependencies + shell: bash + run: | + sudo apt-get update + sudo apt-get install qt6-base-dev - name: Workaround for sanitizer shell: bash run: | From c64c18e1d6ffa53f128e5ef094bf7b7357647e6b Mon Sep 17 00:00:00 2001 From: Nerum Date: Thu, 2 Mar 2023 16:03:40 +0100 Subject: [PATCH 056/106] Use qt5-dev in github workflow --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4091f8599..34a596dd4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -50,7 +50,7 @@ jobs: shell: bash run: | sudo apt-get update - sudo apt-get install qt6-base-dev + sudo apt-get install qtbase5-dev qtdeclarative5-dev - name: Workaround for sanitizer shell: bash run: | From d1616ff705be1e14a78eb737f931ade81495b249 Mon Sep 17 00:00:00 2001 From: Nerum Date: Thu, 2 Mar 2023 16:42:25 +0100 Subject: [PATCH 057/106] Allow for qt versions older than 5.15 --- tools/fm-editor/CMakeLists.txt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/fm-editor/CMakeLists.txt b/tools/fm-editor/CMakeLists.txt index 590a340de..d172987c4 100644 --- a/tools/fm-editor/CMakeLists.txt +++ b/tools/fm-editor/CMakeLists.txt @@ -5,10 +5,9 @@ set(LLVM_LINK_COMPONENTS ) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) -find_package(Qt6 COMPONENTS Widgets) -if (NOT Qt6_FOUND) - find_package(Qt5 5.15 REQUIRED COMPONENTS Widgets) -endif() +find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets) +find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets) + include_directories(../../external/qsourcehighlite) include_directories(.) @@ -36,7 +35,7 @@ add_vara_executable(fm-editor target_link_libraries(fm-editor LINK_PRIVATE VaRAFeature - Qt::Widgets + Qt${QT_VERSION_MAJOR}::Widgets ${STD_FS_LIB} ) From fee14dbac9ac20a7ecfb318358e2ef28a28faf53 Mon Sep 17 00:00:00 2001 From: Nerum Date: Thu, 2 Mar 2023 17:00:00 +0100 Subject: [PATCH 058/106] Remove setPlaceHolderText if qt < 5.15 --- tools/fm-editor/CMakeLists.txt | 4 +++- tools/fm-editor/FeatureModelEditor.cpp | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/fm-editor/CMakeLists.txt b/tools/fm-editor/CMakeLists.txt index d172987c4..269904a84 100644 --- a/tools/fm-editor/CMakeLists.txt +++ b/tools/fm-editor/CMakeLists.txt @@ -7,7 +7,9 @@ set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets) - +if(QT_VERSION_MAJOR GREATER 5 OR QT_VERSION_MINOR GREATER_EQUAL 15) + add_compile_definitions(QT_HAS_SETPLACEHOLDERTEXT) +endif() include_directories(../../external/qsourcehighlite) include_directories(.) diff --git a/tools/fm-editor/FeatureModelEditor.cpp b/tools/fm-editor/FeatureModelEditor.cpp index b17c2da13..1915fe1c9 100644 --- a/tools/fm-editor/FeatureModelEditor.cpp +++ b/tools/fm-editor/FeatureModelEditor.cpp @@ -195,9 +195,12 @@ void FeatureModelEditor::inspectFeatureSources( QString::fromStdString("Sources for: " + Feature->getName().str())); if (Ui->sources->count() == 1) { loadSource(Ui->sources->itemText(0)); - } else { + } +#ifdef QT_HAS_SETPLACEHOLDERTEXT + else { Ui->sources->setPlaceholderText("Select File"); } +#endif } /// Create the Context menu for inspecting sources in the tree view /// From 67408052aff992b74e10d55d2244231268614863 Mon Sep 17 00:00:00 2001 From: Nerum Date: Thu, 2 Mar 2023 17:35:21 +0100 Subject: [PATCH 059/106] Fix source location marking --- tools/fm-editor/FeatureModelEditor.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/tools/fm-editor/FeatureModelEditor.cpp b/tools/fm-editor/FeatureModelEditor.cpp index 1915fe1c9..b00c1bfd4 100644 --- a/tools/fm-editor/FeatureModelEditor.cpp +++ b/tools/fm-editor/FeatureModelEditor.cpp @@ -238,7 +238,12 @@ void FeatureModelEditor::loadSource(const QString &RelativePath) { } } } - +void setCursorLineAndColumn (QTextCursor &Cursor, int Line, int Col, + QTextCursor::MoveMode Mode) +{ + QTextBlock const B = Cursor.document()->findBlockByLineNumber(Line); + Cursor.setPosition(B.position() + Col, Mode); +} /// Mark the given SourceRange with the given Format /// /// \param Fmt Format to mark with @@ -250,19 +255,13 @@ void FeatureModelEditor::markLocation( Fmt.setBackground(Qt::darkYellow); QTextCursor Cursor(Ui->textEdit->document()); Cursor.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor); - Cursor.movePosition(QTextCursor::Down, QTextCursor::MoveAnchor, - int(Location.getStart()->getLineNumber()) - 1); - Cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::MoveAnchor, - int(Location.getStart()->getColumnOffset()) - 1); - Cursor.movePosition(QTextCursor::Down, QTextCursor::KeepAnchor, - int(Location.getEnd()->getLineNumber()) - - int(Location.getStart()->getLineNumber())); - Cursor.movePosition(QTextCursor::StartOfLine, QTextCursor::KeepAnchor); - Cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, - int(Location.getEnd()->getColumnOffset())); + setCursorLineAndColumn(Cursor,Location.getStart()->getLineNumber()-1,Location.getStart()->getColumnOffset()-1,QTextCursor::MoveAnchor); + setCursorLineAndColumn(Cursor,Location.getEnd()->getLineNumber()-1,Location.getEnd()->getColumnOffset()-1,QTextCursor::KeepAnchor); Cursor.setCharFormat(Fmt); } + + /// Load a sourcefile to then add a location from it void FeatureModelEditor::addSourceFile() { if (!Repository.isEmpty()) { From d842541504fa1850058076db597ca0e2712343be Mon Sep 17 00:00:00 2001 From: Nerum Date: Thu, 2 Mar 2023 17:37:37 +0100 Subject: [PATCH 060/106] format --- tools/fm-editor/FeatureModelEditor.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tools/fm-editor/FeatureModelEditor.cpp b/tools/fm-editor/FeatureModelEditor.cpp index b00c1bfd4..f14421c0f 100644 --- a/tools/fm-editor/FeatureModelEditor.cpp +++ b/tools/fm-editor/FeatureModelEditor.cpp @@ -238,9 +238,8 @@ void FeatureModelEditor::loadSource(const QString &RelativePath) { } } } -void setCursorLineAndColumn (QTextCursor &Cursor, int Line, int Col, - QTextCursor::MoveMode Mode) -{ +void setCursorLineAndColumn(QTextCursor &Cursor, int Line, int Col, + QTextCursor::MoveMode Mode) { QTextBlock const B = Cursor.document()->findBlockByLineNumber(Line); Cursor.setPosition(B.position() + Col, Mode); } @@ -255,13 +254,15 @@ void FeatureModelEditor::markLocation( Fmt.setBackground(Qt::darkYellow); QTextCursor Cursor(Ui->textEdit->document()); Cursor.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor); - setCursorLineAndColumn(Cursor,Location.getStart()->getLineNumber()-1,Location.getStart()->getColumnOffset()-1,QTextCursor::MoveAnchor); - setCursorLineAndColumn(Cursor,Location.getEnd()->getLineNumber()-1,Location.getEnd()->getColumnOffset()-1,QTextCursor::KeepAnchor); + setCursorLineAndColumn(Cursor, Location.getStart()->getLineNumber() - 1, + Location.getStart()->getColumnOffset() - 1, + QTextCursor::MoveAnchor); + setCursorLineAndColumn(Cursor, Location.getEnd()->getLineNumber() - 1, + Location.getEnd()->getColumnOffset() - 1, + QTextCursor::KeepAnchor); Cursor.setCharFormat(Fmt); } - - /// Load a sourcefile to then add a location from it void FeatureModelEditor::addSourceFile() { if (!Repository.isEmpty()) { From 4825b9db99629782f203a422f993a557123b9085 Mon Sep 17 00:00:00 2001 From: Nerum Date: Thu, 2 Mar 2023 17:38:01 +0100 Subject: [PATCH 061/106] format --- tools/fm-editor/FeatureModelEditor.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/fm-editor/FeatureModelEditor.cpp b/tools/fm-editor/FeatureModelEditor.cpp index f14421c0f..0397b21e8 100644 --- a/tools/fm-editor/FeatureModelEditor.cpp +++ b/tools/fm-editor/FeatureModelEditor.cpp @@ -238,11 +238,13 @@ void FeatureModelEditor::loadSource(const QString &RelativePath) { } } } + void setCursorLineAndColumn(QTextCursor &Cursor, int Line, int Col, QTextCursor::MoveMode Mode) { QTextBlock const B = Cursor.document()->findBlockByLineNumber(Line); Cursor.setPosition(B.position() + Col, Mode); } + /// Mark the given SourceRange with the given Format /// /// \param Fmt Format to mark with From e6f7e8cf4fe35131a53589bf039af1651620700f Mon Sep 17 00:00:00 2001 From: Nerum Date: Fri, 3 Mar 2023 09:54:44 +0100 Subject: [PATCH 062/106] fix lint --- include/vara/Feature/FeatureModelTransaction.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/vara/Feature/FeatureModelTransaction.h b/include/vara/Feature/FeatureModelTransaction.h index ec126ffba..3afad9c23 100644 --- a/include/vara/Feature/FeatureModelTransaction.h +++ b/include/vara/Feature/FeatureModelTransaction.h @@ -970,22 +970,22 @@ class FeatureModelCopyTransactionBase { [[nodiscard]] FeatureTreeNode *translateFeature(FeatureTreeNode &F) { if(F.getKind()==FeatureTreeNode::NodeKind::NK_RELATIONSHIP) { - int i = 0; + int I = 0; FeatureTreeNode* Parent = F.getParent(); while(Parent->getKind()!=FeatureTreeNode::NodeKind::NK_FEATURE){ Parent = Parent->getParent(); - i++; + I++; } - auto ParentFeature = dynamic_cast(Parent); + auto *ParentFeature = llvm::dyn_cast(Parent); ParentFeature = FM->getFeature(ParentFeature->getName()); Relationship *Base = *ParentFeature->getChildren(0).begin(); - for (i = i - 1; i < 0; i--) { + for (I = I - 1; I < 0; I--) { Base = *Base->getChildren(0).begin(); } return Base; } - return FM->getFeature(dynamic_cast(F).getName()); + return FM->getFeature(llvm::dyn_cast(&F)->getName()); } std::unique_ptr FM; From 2f244ca7f8a22cda87fa0a04e6a80dd5d7650994 Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 14 Mar 2023 15:55:38 +0100 Subject: [PATCH 063/106] Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- include/vara/Feature/FeatureModelTransaction.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/vara/Feature/FeatureModelTransaction.h b/include/vara/Feature/FeatureModelTransaction.h index 3afad9c23..b811152af 100644 --- a/include/vara/Feature/FeatureModelTransaction.h +++ b/include/vara/Feature/FeatureModelTransaction.h @@ -976,7 +976,7 @@ class FeatureModelCopyTransactionBase { Parent = Parent->getParent(); I++; } - auto *ParentFeature = llvm::dyn_cast(Parent); + auto *ParentFeature = llvm::dyn_cast(Parent); ParentFeature = FM->getFeature(ParentFeature->getName()); Relationship *Base = *ParentFeature->getChildren(0).begin(); for (I = I - 1; I < 0; I--) { @@ -985,7 +985,8 @@ class FeatureModelCopyTransactionBase { return Base; } - return FM->getFeature(llvm::dyn_cast(&F)->getName()); + return FM->getFeature( + llvm::dyn_cast(&F)->getName()); } std::unique_ptr FM; From 01863157ee0d30efa5220efa3a5690dbf1451881 Mon Sep 17 00:00:00 2001 From: Nerum Date: Wed, 15 Mar 2023 11:44:16 +0100 Subject: [PATCH 064/106] cleanup clang-tidy errors --- external/qsourcehighlite | 2 +- .../vara/Feature/FeatureModelTransaction.h | 13 ++------- tools/fm-editor/CMakeLists.txt | 8 +++++- tools/fm-editor/FeatureAddDialog.cpp | 4 +-- tools/fm-editor/FeatureModelEditor.cpp | 10 +++---- tools/fm-editor/FeatureModelEditor.h | 2 +- tools/fm-editor/graph/FeatureModelGraph.cpp | 28 +++++++++---------- tools/fm-editor/graph/FeatureNode.cpp | 14 +++++----- tools/fm-editor/main.cpp | 2 +- tools/fm-editor/tree/FeatureTreeItem.cpp | 8 +++--- tools/fm-editor/tree/FeatureTreeItem.h | 4 +-- tools/fm-editor/tree/FeatureTreeViewModel.cpp | 10 ++++--- 12 files changed, 52 insertions(+), 53 deletions(-) diff --git a/external/qsourcehighlite b/external/qsourcehighlite index f1ed26f26..ad768b4bf 160000 --- a/external/qsourcehighlite +++ b/external/qsourcehighlite @@ -1 +1 @@ -Subproject commit f1ed26f26d980360422a0295e49bf676abe7e416 +Subproject commit ad768b4bfe777c5bbabd92d4068514a659a6e2ae diff --git a/include/vara/Feature/FeatureModelTransaction.h b/include/vara/Feature/FeatureModelTransaction.h index b811152af..f39d4588b 100644 --- a/include/vara/Feature/FeatureModelTransaction.h +++ b/include/vara/Feature/FeatureModelTransaction.h @@ -970,21 +970,14 @@ class FeatureModelCopyTransactionBase { [[nodiscard]] FeatureTreeNode *translateFeature(FeatureTreeNode &F) { if(F.getKind()==FeatureTreeNode::NodeKind::NK_RELATIONSHIP) { - int I = 0; FeatureTreeNode* Parent = F.getParent(); - while(Parent->getKind()!=FeatureTreeNode::NodeKind::NK_FEATURE){ - Parent = Parent->getParent(); - I++; - } - auto *ParentFeature = llvm::dyn_cast(Parent); + assert(Parent->getKind()==FeatureTreeNode::NodeKind::NK_FEATURE); + auto *ParentFeature = llvm::dyn_cast(Parent); ParentFeature = FM->getFeature(ParentFeature->getName()); Relationship *Base = *ParentFeature->getChildren(0).begin(); - for (I = I - 1; I < 0; I--) { - Base = *Base->getChildren(0).begin(); - } + Base = *Base->getChildren(0).begin(); return Base; } - return FM->getFeature( llvm::dyn_cast(&F)->getName()); } diff --git a/tools/fm-editor/CMakeLists.txt b/tools/fm-editor/CMakeLists.txt index 269904a84..31c823063 100644 --- a/tools/fm-editor/CMakeLists.txt +++ b/tools/fm-editor/CMakeLists.txt @@ -8,7 +8,7 @@ set(CMAKE_AUTOUIC ON) find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets) if(QT_VERSION_MAJOR GREATER 5 OR QT_VERSION_MINOR GREATER_EQUAL 15) - add_compile_definitions(QT_HAS_SETPLACEHOLDERTEXT) + # add_compile_definitions(QT_HAS_SETPLACEHOLDERTEXT) endif() include_directories(../../external/qsourcehighlite) include_directories(.) @@ -45,3 +45,9 @@ add_custom_target(check-vara-fm-editor COMMAND fm-editor xml/test.xml -viewer cat | dot | grep . -q WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../unittests/resources ) + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/[project_name]_autogen/.clang-tidy" " +--- +Checks: '-*,llvm-twine-local' +... +") \ No newline at end of file diff --git a/tools/fm-editor/FeatureAddDialog.cpp b/tools/fm-editor/FeatureAddDialog.cpp index 8524f3ae1..046c5bd93 100644 --- a/tools/fm-editor/FeatureAddDialog.cpp +++ b/tools/fm-editor/FeatureAddDialog.cpp @@ -29,8 +29,8 @@ QString FeatureAddDialog::getName() const { return name->text(); } QString FeatureAddDialog::getParent() const { return Nodes->currentText(); } -void FeatureAddDialog::featureType(int index) { - if (index == 1) { +void FeatureAddDialog::featureType(int Index) { + if (Index == 1) { NumericFeature->setVisible(true); } else { NumericFeature->setVisible(false); diff --git a/tools/fm-editor/FeatureModelEditor.cpp b/tools/fm-editor/FeatureModelEditor.cpp index 0397b21e8..e551a8549 100644 --- a/tools/fm-editor/FeatureModelEditor.cpp +++ b/tools/fm-editor/FeatureModelEditor.cpp @@ -10,8 +10,6 @@ #include #include #include - -using vara::feature::FeatureModel; using Transaction = vara::feature::FeatureModelTransaction< vara::feature::detail::ModifyTransactionMode>; using vara::feature::Feature; @@ -256,11 +254,11 @@ void FeatureModelEditor::markLocation( Fmt.setBackground(Qt::darkYellow); QTextCursor Cursor(Ui->textEdit->document()); Cursor.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor); - setCursorLineAndColumn(Cursor, Location.getStart()->getLineNumber() - 1, - Location.getStart()->getColumnOffset() - 1, + setCursorLineAndColumn(Cursor, int(Location.getStart()->getLineNumber()) - 1, + int(Location.getStart()->getColumnOffset()) - 1, QTextCursor::MoveAnchor); - setCursorLineAndColumn(Cursor, Location.getEnd()->getLineNumber() - 1, - Location.getEnd()->getColumnOffset() - 1, + setCursorLineAndColumn(Cursor, int(Location.getEnd()->getLineNumber()) - 1, + int(Location.getEnd()->getColumnOffset()) - 1, QTextCursor::KeepAnchor); Cursor.setCharFormat(Fmt); } diff --git a/tools/fm-editor/FeatureModelEditor.h b/tools/fm-editor/FeatureModelEditor.h index a5e072844..32d3b6ee5 100644 --- a/tools/fm-editor/FeatureModelEditor.h +++ b/tools/fm-editor/FeatureModelEditor.h @@ -32,7 +32,7 @@ class FeatureModelEditor : public QMainWindow { std::unique_ptr TreeModel{}; std::unique_ptr FeatureModel{}; QString Repository{}; - vara::feature::Feature *CurrentFeature; + vara::feature::Feature *CurrentFeature = nullptr; QString SavePath{}; QString ModelPath{}; diff --git a/tools/fm-editor/graph/FeatureModelGraph.cpp b/tools/fm-editor/graph/FeatureModelGraph.cpp index 4dbae107f..8a008ec94 100644 --- a/tools/fm-editor/graph/FeatureModelGraph.cpp +++ b/tools/fm-editor/graph/FeatureModelGraph.cpp @@ -42,7 +42,7 @@ void FeatureModelGraph::reload() { NextChildren.begin(), [](FeatureEdge *Edge) { return Edge->targetNode(); }); positionRec(1, NextChildren, 5); - EntryNode->setPos(EntryNode->childrenWidth() / 2, 10); + EntryNode->setPos(EntryNode->childrenWidth() / 2.0, 10); } void FeatureModelGraph::buildRec(FeatureNode *CurrentFeatureNode) { @@ -85,7 +85,7 @@ int FeatureModelGraph::positionRec(const int CurrentDepth, [](FeatureEdge *Edge) { return Edge->targetNode(); }); int const Depth = positionRec(CurrentDepth + 1, NextChildren, NextOffset); int Width = Node->childrenWidth() + 5; - Node->setPos(NextOffset + Width / 2, 100 * CurrentDepth); + Node->setPos(double(NextOffset) + Width / 2.0, 100 * CurrentDepth); NextOffset += Width; MaxDepth = MaxDepth < Depth ? Depth : MaxDepth; } @@ -113,14 +113,14 @@ void FeatureModelGraph::wheelEvent(QWheelEvent *Event) { #endif void FeatureModelGraph::drawBackground(QPainter *Painter, const QRectF &Rect) { - Q_UNUSED(Rect); + Q_UNUSED(Rect) // Shadow - QRectF SceneRect = this->sceneRect(); - QRectF RightShadow(SceneRect.right(), SceneRect.top() + 5, 5, - SceneRect.height()); - QRectF BottomShadow(SceneRect.left() + 5, SceneRect.bottom(), - SceneRect.width(), 5); + QRectF const SceneRect = this->sceneRect(); + QRectF const RightShadow(SceneRect.right(), SceneRect.top() + 5, 5, + SceneRect.height()); + QRectF const BottomShadow(SceneRect.left() + 5, SceneRect.bottom(), + SceneRect.width(), 5); if (RightShadow.intersects(Rect) || RightShadow.contains(Rect)) { Painter->fillRect(RightShadow, Qt::darkGray); } @@ -145,10 +145,10 @@ void FeatureModelGraph::drawBackground(QPainter *Painter, const QRectF &Rect) { } void FeatureModelGraph::scaleView(qreal ScaleFactor) { - qreal Factor = transform() - .scale(ScaleFactor, ScaleFactor) - .mapRect(QRectF(0, 0, 1, 1)) - .width(); + qreal const Factor = transform() + .scale(ScaleFactor, ScaleFactor) + .mapRect(QRectF(0, 0, 1, 1)) + .width(); if (Factor < 0.07 || Factor > 100) { return; } @@ -165,7 +165,7 @@ FeatureNode *FeatureModelGraph::addNode(Feature *Feature, FeatureNode *Parent) { auto *NewEdge = new FeatureEdge(Parent, NewNode.get()); scene()->addItem(NewEdge); scene()->addItem(NewNode.get()); - auto NewNodeRaw = NewNode.get(); + auto *NewNodeRaw = NewNode.get(); Nodes.push_back(std::move(NewNode)); auto NextChildren = std::vector(EntryNode->children().size()); auto CurrentChildren = EntryNode->children(); @@ -173,7 +173,7 @@ FeatureNode *FeatureModelGraph::addNode(Feature *Feature, FeatureNode *Parent) { NextChildren.begin(), [](FeatureEdge *Edge) { return Edge->targetNode(); }); positionRec(1, NextChildren, 5); - EntryNode->setPos(EntryNode->childrenWidth() / 2, 10); + EntryNode->setPos(EntryNode->childrenWidth() / 2.0, 10); return NewNodeRaw; } diff --git a/tools/fm-editor/graph/FeatureNode.cpp b/tools/fm-editor/graph/FeatureNode.cpp index 40fe38793..a9b1501ed 100644 --- a/tools/fm-editor/graph/FeatureNode.cpp +++ b/tools/fm-editor/graph/FeatureNode.cpp @@ -31,15 +31,15 @@ std::vector FeatureNode::children() { return ChildEdges; } FeatureEdge *FeatureNode::parent() { return ParentEdge; } QRectF FeatureNode::boundingRect() const { - qreal Adjust = 2; - int W = width(); - return {-W / 2 - Adjust, -10 - Adjust, W + Adjust, 23 + Adjust}; + qreal const Adjust = 2; + int const W = width(); + return {-W / 2.0 - Adjust, -10 - Adjust, W + Adjust, 23 + Adjust}; } QPainterPath FeatureNode::shape() const { QPainterPath Path; - int W = width(); - Path.addRect(-W / 2, -10, W, 20); + int const W = width(); + Path.addRect(-W / 2.0, -10, W, 20); return Path; } @@ -55,7 +55,7 @@ void FeatureNode::paint(QPainter *Painter, Painter->setBrush(Brush); Painter->setPen(QPen(Qt::black, 0)); - int W = width(); + int const W = width(); Painter->drawRect(-W / 2, -10, W, 20); Painter->setPen(QPen(Qt::black, 1)); Painter->drawText(-W / 2 + 5, 5, Name); @@ -106,7 +106,7 @@ void FeatureNode::inspect() { emit(inspectSource(Feature)); } int FeatureNode::width() const { auto Name = Feature->getName(); - return 15 + 5 * Name.str().length(); + return 15 + 5 * int(Name.str().length()); } int FeatureNode::childrenWidth() const { diff --git a/tools/fm-editor/main.cpp b/tools/fm-editor/main.cpp index d2aee1249..4081d8fae 100644 --- a/tools/fm-editor/main.cpp +++ b/tools/fm-editor/main.cpp @@ -6,5 +6,5 @@ int main(int argc, char **argv) { QApplication const App(argc, argv); FeatureModelEditor W; W.show(); - return App.exec(); + return QApplication::exec(); } diff --git a/tools/fm-editor/tree/FeatureTreeItem.cpp b/tools/fm-editor/tree/FeatureTreeItem.cpp index e41ae72ef..c36a0b48e 100644 --- a/tools/fm-editor/tree/FeatureTreeItem.cpp +++ b/tools/fm-editor/tree/FeatureTreeItem.cpp @@ -9,10 +9,10 @@ QVariant numericValue(vara::feature::Feature *Item) { string Result = "["; if (std::holds_alternative( NumItem->getValues())) { - auto range = std::get( + auto Range = std::get( NumItem->getValues()); - Result += std::to_string(range.first) + ", " + - std::to_string(range.second) + "]"; + Result += std::to_string(Range.first) + ", " + + std::to_string(Range.second) + "]"; } else { auto Range = std::get( NumItem->getValues()); @@ -69,7 +69,7 @@ void FeatureTreeItem::addChild(FeatureTreeItem *Child) { std::vector FeatureTreeItem::getChildrenRecursive() { auto Nodes = std::vector{Children}; - for (auto Child : Children) { + for (auto *Child : Children) { auto ChildNodes = Child->getChildrenRecursive(); Nodes.insert(Nodes.end(), ChildNodes.begin(), ChildNodes.end()); } diff --git a/tools/fm-editor/tree/FeatureTreeItem.h b/tools/fm-editor/tree/FeatureTreeItem.h index a50173e44..2e9a66391 100644 --- a/tools/fm-editor/tree/FeatureTreeItem.h +++ b/tools/fm-editor/tree/FeatureTreeItem.h @@ -37,7 +37,7 @@ class FeatureTreeItem : public QObject { [[nodiscard]] virtual QVariant data(int Column) const = 0; std::unique_ptr static createFeatureTreeItem( vara::feature::FeatureTreeNode *Item); - static bool booleanColumn(int Column) { return false; } + bool booleanColumn(int Column) { return false; } virtual void contextMenu(QPoint Pos) = 0; virtual vara::feature::FeatureTreeNode *getItem() const = 0; vara::feature::FeatureTreeNode::NodeKind getKind() { return Kind; } @@ -77,7 +77,7 @@ class FeatureTreeItemFeature : public FeatureTreeItem { } [[nodiscard]] QVariant data(int Column) const override; [[nodiscard]] int columnCount() const override { return 5; } - static bool booleanColumn(int Column) { return Column == 1; } + bool booleanColumn(int Column) { return Column == 1; } void contextMenu(QPoint Pos) override; vara::feature::FeatureTreeNode *getItem() const override { return Item; } const vara::feature::Feature *getFeature() const { return Item; } diff --git a/tools/fm-editor/tree/FeatureTreeViewModel.cpp b/tools/fm-editor/tree/FeatureTreeViewModel.cpp index 8db1a06c0..48feccb93 100644 --- a/tools/fm-editor/tree/FeatureTreeViewModel.cpp +++ b/tools/fm-editor/tree/FeatureTreeViewModel.cpp @@ -1,5 +1,7 @@ #include "FeatureTreeViewModel.h" +#include + QModelIndex FeatureTreeViewModel::index(int Row, int Column, const QModelIndex &Parent) const { FeatureTreeItem *ParentItem; @@ -54,8 +56,8 @@ int FeatureTreeViewModel::rowCount(const QModelIndex &Parent) const { int FeatureTreeViewModel::columnCount(const QModelIndex &Parent) const { if (Parent.isValid()) { - auto Item = static_cast(Parent.internalPointer()) - ->child(Parent.row()); + auto *Item = static_cast(Parent.internalPointer()) + ->child(Parent.row()); return Item->columnCount(); } @@ -115,7 +117,7 @@ FeatureTreeViewModel::getItems() { FeatureTreeItem * FeatureTreeViewModel::addFeature(vara::feature::Feature *Feature, std::string Parent) { - auto Item = getItem(Parent); + auto *Item = getItem(std::move(Parent)); if (Item) { auto NewItem = FeatureTreeItem::createFeatureTreeItem(Feature); Item->addChild(NewItem.get()); @@ -130,7 +132,7 @@ FeatureTreeViewModel::addFeature(vara::feature::Feature *Feature, void FeatureTreeViewModel::deleteFeatureItem(bool Recursive, vara::feature::Feature *Feature) { emit(layoutAboutToBeChanged()); - auto Item = getItem(Feature->getName().str()); + auto *Item = getItem(Feature->getName().str()); if (Item) { deleteItem(Recursive, Item); } From ddbdf9fbe3a351f130d9480b3edf8627f9491d15 Mon Sep 17 00:00:00 2001 From: Nerum Date: Wed, 15 Mar 2023 12:23:51 +0100 Subject: [PATCH 065/106] cleanup clang-tidy errors --- external/qsourcehighlite | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/qsourcehighlite b/external/qsourcehighlite index ad768b4bf..f1ed26f26 160000 --- a/external/qsourcehighlite +++ b/external/qsourcehighlite @@ -1 +1 @@ -Subproject commit ad768b4bfe777c5bbabd92d4068514a659a6e2ae +Subproject commit f1ed26f26d980360422a0295e49bf676abe7e416 From 5d0d0a6e9fcc4eaa31b7ffa449ec5b446a468f4b Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 15 Mar 2023 14:33:10 +0100 Subject: [PATCH 066/106] Update include/vara/Feature/FeatureModelTransaction.h Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- include/vara/Feature/FeatureModelTransaction.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/vara/Feature/FeatureModelTransaction.h b/include/vara/Feature/FeatureModelTransaction.h index f39d4588b..e53f493f4 100644 --- a/include/vara/Feature/FeatureModelTransaction.h +++ b/include/vara/Feature/FeatureModelTransaction.h @@ -969,10 +969,10 @@ class FeatureModelCopyTransactionBase { } [[nodiscard]] FeatureTreeNode *translateFeature(FeatureTreeNode &F) { - if(F.getKind()==FeatureTreeNode::NodeKind::NK_RELATIONSHIP) { - FeatureTreeNode* Parent = F.getParent(); - assert(Parent->getKind()==FeatureTreeNode::NodeKind::NK_FEATURE); - auto *ParentFeature = llvm::dyn_cast(Parent); + if (F.getKind() == FeatureTreeNode::NodeKind::NK_RELATIONSHIP) { + FeatureTreeNode *Parent = F.getParent(); + assert(Parent->getKind() == FeatureTreeNode::NodeKind::NK_FEATURE); + auto *ParentFeature = llvm::dyn_cast(Parent); ParentFeature = FM->getFeature(ParentFeature->getName()); Relationship *Base = *ParentFeature->getChildren(0).begin(); Base = *Base->getChildren(0).begin(); From cc6c1ba2ba8537a3fce6d9ff7a202b429a99b7ce Mon Sep 17 00:00:00 2001 From: Nerum Date: Wed, 15 Mar 2023 14:36:12 +0100 Subject: [PATCH 067/106] cleanup clang-tidy errors --- include/vara/Feature/FeatureModelTransaction.h | 7 ++++--- tools/fm-editor/FeatureAddDialog.cpp | 1 - tools/fm-editor/tree/FeatureTreeViewModel.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/vara/Feature/FeatureModelTransaction.h b/include/vara/Feature/FeatureModelTransaction.h index e53f493f4..677443ddd 100644 --- a/include/vara/Feature/FeatureModelTransaction.h +++ b/include/vara/Feature/FeatureModelTransaction.h @@ -971,15 +971,16 @@ class FeatureModelCopyTransactionBase { [[nodiscard]] FeatureTreeNode *translateFeature(FeatureTreeNode &F) { if (F.getKind() == FeatureTreeNode::NodeKind::NK_RELATIONSHIP) { FeatureTreeNode *Parent = F.getParent(); - assert(Parent->getKind() == FeatureTreeNode::NodeKind::NK_FEATURE); auto *ParentFeature = llvm::dyn_cast(Parent); + assert(ParentFeature != nullptr); ParentFeature = FM->getFeature(ParentFeature->getName()); Relationship *Base = *ParentFeature->getChildren(0).begin(); Base = *Base->getChildren(0).begin(); return Base; } - return FM->getFeature( - llvm::dyn_cast(&F)->getName()); + auto *CastF = llvm::dyn_cast(&F); + assert(CastF != nullptr); + return FM->getFeature(CastF->getName()); } std::unique_ptr FM; diff --git a/tools/fm-editor/FeatureAddDialog.cpp b/tools/fm-editor/FeatureAddDialog.cpp index 046c5bd93..fb25e46a6 100644 --- a/tools/fm-editor/FeatureAddDialog.cpp +++ b/tools/fm-editor/FeatureAddDialog.cpp @@ -3,7 +3,6 @@ #include "graph/FeatureNode.h" using vara::feature::Feature; -using vara::feature::FeatureModel; FeatureAddDialog::FeatureAddDialog(FeatureModelGraph *Graph, QWidget *Parent, Feature *ParentFeature) : QDialog(Parent) { diff --git a/tools/fm-editor/tree/FeatureTreeViewModel.h b/tools/fm-editor/tree/FeatureTreeViewModel.h index d9707b409..c9145c70e 100644 --- a/tools/fm-editor/tree/FeatureTreeViewModel.h +++ b/tools/fm-editor/tree/FeatureTreeViewModel.h @@ -31,7 +31,7 @@ class FeatureTreeViewModel : public QAbstractItemModel { [[nodiscard]] Qt::ItemFlags flags(const QModelIndex &Index) const override; [[nodiscard]] QVariant headerData(int Section, Qt::Orientation Orientation, int Role = Qt::DisplayRole) const override; - FeatureTreeItem *addFeature(vara::feature::Feature *Item, string Parent); + FeatureTreeItem *addFeature(vara::feature::Feature *Feature, string Parent); void deleteFeatureItem(bool Recursive, vara::feature::Feature *Feature); void deleteItem(bool Recursive, FeatureTreeItem *Item); FeatureTreeItem *getItem(string Name) { From f14a5108595cca06ec44df1286ac8cbcce840d7a Mon Sep 17 00:00:00 2001 From: Nerum Date: Wed, 15 Mar 2023 16:51:55 +0100 Subject: [PATCH 068/106] write clang tidy overwrite to the correct directory --- tools/fm-editor/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/fm-editor/CMakeLists.txt b/tools/fm-editor/CMakeLists.txt index 31c823063..955259ae6 100644 --- a/tools/fm-editor/CMakeLists.txt +++ b/tools/fm-editor/CMakeLists.txt @@ -46,7 +46,7 @@ add_custom_target(check-vara-fm-editor WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../unittests/resources ) -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/[project_name]_autogen/.clang-tidy" " +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/fm-editor_autogen/.clang-tidy" " --- Checks: '-*,llvm-twine-local' ... From 18643cf00a8ebbf1c26f7b8f7f65a56924bbf579 Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 13 Apr 2023 15:26:42 +0200 Subject: [PATCH 069/106] Update .gitmodules Co-authored-by: Florian Sattler --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index adb06282e..e1523618e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -12,7 +12,7 @@ url = https://github.com/kthohr/gcem.git [submodule "external/csv-parser"] path = external/csv-parser - url = url = https://github.com/se-sic/csv-parser.git + url = https://github.com/se-sic/csv-parser.git [submodule "external/qsourcehighlite"] path = external/qsourcehighlite url = git@github.com:Waqar144/QSourceHighlite.git From 59d2daa683beb71e20b8ad0e01a26641b66fe27e Mon Sep 17 00:00:00 2001 From: Nerum Date: Mon, 17 Apr 2023 14:17:37 +0200 Subject: [PATCH 070/106] reformat CMakeLists.txt --- tools/fm-editor/CMakeLists.txt | 86 +++++++++++++++++++--------------- 1 file changed, 49 insertions(+), 37 deletions(-) diff --git a/tools/fm-editor/CMakeLists.txt b/tools/fm-editor/CMakeLists.txt index 955259ae6..a59d78682 100644 --- a/tools/fm-editor/CMakeLists.txt +++ b/tools/fm-editor/CMakeLists.txt @@ -1,53 +1,65 @@ -set(LLVM_LINK_COMPONENTS - Support - Demangle - Core -) +set(LLVM_LINK_COMPONENTS Support Demangle Core) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) -find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets) +find_package( + QT + NAMES + Qt6 + Qt5 + REQUIRED + COMPONENTS Widgets +) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets) if(QT_VERSION_MAJOR GREATER 5 OR QT_VERSION_MINOR GREATER_EQUAL 15) - # add_compile_definitions(QT_HAS_SETPLACEHOLDERTEXT) + # add_compile_definitions(QT_HAS_SETPLACEHOLDERTEXT) endif() include_directories(../../external/qsourcehighlite) include_directories(.) -add_vara_executable(fm-editor - main.cpp - graph/FeatureModelGraph.h - graph/FeatureModelGraph.cpp - graph/FeatureNode.h - graph/FeatureNode.cpp - graph/FeatureEdge.h - graph/FeatureEdge.cpp - tree/FeatureTreeViewModel.h - tree/FeatureTreeViewModel.cpp - tree/FeatureTreeItem.h - tree/FeatureTreeItem.cpp - FeatureModelEditor.h FeatureModelEditor.cpp - FeatureAddDialog.h FeatureAddDialog.cpp - ../../external/qsourcehighlite/qsourcehighliter.h - ../../external/qsourcehighlite/qsourcehighliter.cpp - ../../external/qsourcehighlite/languagedata.h - ../../external/qsourcehighlite/languagedata.cpp - ../../external/qsourcehighlite/qsourcehighliterthemes.h - ../../external/qsourcehighlite/qsourcehighliterthemes.cpp +add_vara_executable( + fm-editor + main.cpp + graph/FeatureModelGraph.h + graph/FeatureModelGraph.cpp + graph/FeatureNode.h + graph/FeatureNode.cpp + graph/FeatureEdge.h + graph/FeatureEdge.cpp + tree/FeatureTreeViewModel.h + tree/FeatureTreeViewModel.cpp + tree/FeatureTreeItem.h + tree/FeatureTreeItem.cpp + FeatureModelEditor.h + FeatureModelEditor.cpp + FeatureAddDialog.h + FeatureAddDialog.cpp + ../../external/qsourcehighlite/qsourcehighliter.h + ../../external/qsourcehighlite/qsourcehighliter.cpp + ../../external/qsourcehighlite/languagedata.h + ../../external/qsourcehighlite/languagedata.cpp + ../../external/qsourcehighlite/qsourcehighliterthemes.h + ../../external/qsourcehighlite/qsourcehighliterthemes.cpp ) -target_link_libraries(fm-editor - LINK_PRIVATE - VaRAFeature - Qt${QT_VERSION_MAJOR}::Widgets - ${STD_FS_LIB} +target_link_libraries( + fm-editor + LINK_PRIVATE + VaRAFeature + Qt${QT_VERSION_MAJOR}::Widgets + ${STD_FS_LIB} ) -add_custom_target(check-vara-fm-editor - COMMAND fm-editor xml/test.xml -viewer cat | dot | grep . -q - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../unittests/resources +add_custom_target( + check-vara-fm-editor + COMMAND fm-editor xml/test.xml -viewer cat | dot | grep . -q + COMMENT "Unittests" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../unittests/resources ) -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/fm-editor_autogen/.clang-tidy" " +file( + WRITE "${CMAKE_CURRENT_BINARY_DIR}/fm-editor_autogen/.clang-tidy" + " --- Checks: '-*,llvm-twine-local' ... -") \ No newline at end of file +" +) From 2550447d730c77e2f2ace8bf6ba20b3e8f1f0738 Mon Sep 17 00:00:00 2001 From: Nerum Date: Mon, 17 Apr 2023 15:04:47 +0200 Subject: [PATCH 071/106] keep asserts to check for correct cast in release build. --- include/vara/Feature/FeatureModelTransaction.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/vara/Feature/FeatureModelTransaction.h b/include/vara/Feature/FeatureModelTransaction.h index 677443ddd..71c511f35 100644 --- a/include/vara/Feature/FeatureModelTransaction.h +++ b/include/vara/Feature/FeatureModelTransaction.h @@ -972,14 +972,18 @@ class FeatureModelCopyTransactionBase { if (F.getKind() == FeatureTreeNode::NodeKind::NK_RELATIONSHIP) { FeatureTreeNode *Parent = F.getParent(); auto *ParentFeature = llvm::dyn_cast(Parent); +#undef NDEBUG assert(ParentFeature != nullptr); +#define NDEBUG ParentFeature = FM->getFeature(ParentFeature->getName()); Relationship *Base = *ParentFeature->getChildren(0).begin(); Base = *Base->getChildren(0).begin(); return Base; } auto *CastF = llvm::dyn_cast(&F); +#undef NDEBUG assert(CastF != nullptr); +#define NDEBUG return FM->getFeature(CastF->getName()); } From dfc752bc1cdce7a0f9cee998cdea7b5233137e34 Mon Sep 17 00:00:00 2001 From: Nerum Date: Mon, 17 Apr 2023 15:35:16 +0200 Subject: [PATCH 072/106] keep asserts to check for correct cast in release build. --- include/vara/Feature/FeatureModelTransaction.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/vara/Feature/FeatureModelTransaction.h b/include/vara/Feature/FeatureModelTransaction.h index 71c511f35..cef258956 100644 --- a/include/vara/Feature/FeatureModelTransaction.h +++ b/include/vara/Feature/FeatureModelTransaction.h @@ -973,15 +973,14 @@ class FeatureModelCopyTransactionBase { FeatureTreeNode *Parent = F.getParent(); auto *ParentFeature = llvm::dyn_cast(Parent); #undef NDEBUG +#include assert(ParentFeature != nullptr); -#define NDEBUG ParentFeature = FM->getFeature(ParentFeature->getName()); Relationship *Base = *ParentFeature->getChildren(0).begin(); Base = *Base->getChildren(0).begin(); return Base; } auto *CastF = llvm::dyn_cast(&F); -#undef NDEBUG assert(CastF != nullptr); #define NDEBUG return FM->getFeature(CastF->getName()); From 75ee65a20c37152b0a639a1b7e147b11ad70bc6d Mon Sep 17 00:00:00 2001 From: Nerum Date: Wed, 19 Apr 2023 10:26:14 +0200 Subject: [PATCH 073/106] Replace the asserts for nullpointer with aborts --- include/vara/Feature/FeatureModelTransaction.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/include/vara/Feature/FeatureModelTransaction.h b/include/vara/Feature/FeatureModelTransaction.h index cef258956..c1f4753bb 100644 --- a/include/vara/Feature/FeatureModelTransaction.h +++ b/include/vara/Feature/FeatureModelTransaction.h @@ -972,17 +972,21 @@ class FeatureModelCopyTransactionBase { if (F.getKind() == FeatureTreeNode::NodeKind::NK_RELATIONSHIP) { FeatureTreeNode *Parent = F.getParent(); auto *ParentFeature = llvm::dyn_cast(Parent); -#undef NDEBUG -#include - assert(ParentFeature != nullptr); + if (ParentFeature == nullptr) { + // The Parent of a Relationship should always be a Feature + abort(); + } ParentFeature = FM->getFeature(ParentFeature->getName()); Relationship *Base = *ParentFeature->getChildren(0).begin(); Base = *Base->getChildren(0).begin(); return Base; } auto *CastF = llvm::dyn_cast(&F); - assert(CastF != nullptr); -#define NDEBUG + if (CastF == nullptr) { + // There are only Features and Relationship nodes if F was not a + // Relationship it has to be a Feature + abort(); + } return FM->getFeature(CastF->getName()); } From d068a825cd08f470dc098a4ab7dae1662658ac7e Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 16 May 2023 12:14:42 +0200 Subject: [PATCH 074/106] Apply suggestions from code review Co-authored-by: Florian Sattler Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- tools/fm-editor/CMakeLists.txt | 2 +- tools/fm-editor/FeatureAddDialog.cpp | 2 +- tools/fm-editor/FeatureAddDialog.h | 1 + tools/fm-editor/FeatureModelEditor.cpp | 12 +++++------ tools/fm-editor/FeatureModelEditor.h | 1 + tools/fm-editor/graph/FeatureModelGraph.cpp | 15 +++++++------- tools/fm-editor/graph/FeatureNode.cpp | 9 ++++---- tools/fm-editor/main.cpp | 2 +- tools/fm-editor/tree/FeatureTreeItem.cpp | 5 ++++- tools/fm-editor/tree/FeatureTreeItem.h | 23 ++++++++++++++++++--- tools/fm-editor/tree/FeatureTreeViewModel.h | 5 +++-- 11 files changed, 50 insertions(+), 27 deletions(-) diff --git a/tools/fm-editor/CMakeLists.txt b/tools/fm-editor/CMakeLists.txt index a59d78682..3e532639e 100644 --- a/tools/fm-editor/CMakeLists.txt +++ b/tools/fm-editor/CMakeLists.txt @@ -57,7 +57,7 @@ add_custom_target( file( WRITE "${CMAKE_CURRENT_BINARY_DIR}/fm-editor_autogen/.clang-tidy" - " +" --- Checks: '-*,llvm-twine-local' ... diff --git a/tools/fm-editor/FeatureAddDialog.cpp b/tools/fm-editor/FeatureAddDialog.cpp index fb25e46a6..db7485d7b 100644 --- a/tools/fm-editor/FeatureAddDialog.cpp +++ b/tools/fm-editor/FeatureAddDialog.cpp @@ -63,7 +63,6 @@ std::unique_ptr FeatureAddDialog::getFeature() { const bool Optional = isOptional(); const std::string OutputString = getOutputString().toStdString(); switch (getFeatureKind()) { - case Feature::FeatureKind::FK_BINARY: return std::make_unique( Name, Optional, std::vector(), @@ -82,6 +81,7 @@ std::unique_ptr FeatureAddDialog::getNumericFeature() const { const std::string OutputString = getOutputString().toStdString(); std::unique_ptr SF{}; vara::feature::NumericFeature::ValuesVariantType ValueRange; + if (range->isChecked()) { ValueRange = vara::feature::NumericFeature::ValueRangeType(min->value(), max->value()); diff --git a/tools/fm-editor/FeatureAddDialog.h b/tools/fm-editor/FeatureAddDialog.h index 7b1345413..7933397e3 100644 --- a/tools/fm-editor/FeatureAddDialog.h +++ b/tools/fm-editor/FeatureAddDialog.h @@ -9,6 +9,7 @@ class FeatureAddDialog : public QDialog, public Ui::Add { Q_OBJECT + public: FeatureAddDialog(FeatureModelGraph *Graph, QWidget *Parent, vara::feature::Feature *ParentFeature = nullptr); diff --git a/tools/fm-editor/FeatureModelEditor.cpp b/tools/fm-editor/FeatureModelEditor.cpp index e551a8549..06c0869d6 100644 --- a/tools/fm-editor/FeatureModelEditor.cpp +++ b/tools/fm-editor/FeatureModelEditor.cpp @@ -10,6 +10,7 @@ #include #include #include + using Transaction = vara::feature::FeatureModelTransaction< vara::feature::detail::ModifyTransactionMode>; using vara::feature::Feature; @@ -35,8 +36,7 @@ FeatureModelEditor::FeatureModelEditor(QWidget *Parent) /// Display the information of a Feature void FeatureModelEditor::loadFeature(const vara::feature::Feature *Feature) { - auto FeatureString = Feature->toString(); - Ui->featureInfo->setText(QString::fromStdString(FeatureString)); + Ui->featureInfo->setText(QString::fromStdString(Feature->toString())); } /// Get a Feature from an Index of the TreeView and display its information. @@ -200,6 +200,7 @@ void FeatureModelEditor::inspectFeatureSources( } #endif } + /// Create the Context menu for inspecting sources in the tree view /// /// \param Pos Position of the cursor used to find the clicked item @@ -236,7 +237,6 @@ void FeatureModelEditor::loadSource(const QString &RelativePath) { } } } - void setCursorLineAndColumn(QTextCursor &Cursor, int Line, int Col, QTextCursor::MoveMode Mode) { QTextBlock const B = Cursor.document()->findBlockByLineNumber(Line); @@ -278,10 +278,10 @@ void FeatureModelEditor::addSourceFile() { void FeatureModelEditor::addSource() { auto *TextEdit = Ui->textEdit; auto Cursor = TextEdit->textCursor(); - int const Start = Cursor.selectionStart(); - int const End = Cursor.selectionEnd(); + const int Start = Cursor.selectionStart(); + const int End = Cursor.selectionEnd(); Cursor.movePosition(QTextCursor::MoveOperation::StartOfLine); - int const LineStart = Cursor.position(); + const int LineStart = Cursor.position(); int Lines = 1; auto Block = Cursor.block(); while (Cursor.position() > Block.position()) { diff --git a/tools/fm-editor/FeatureModelEditor.h b/tools/fm-editor/FeatureModelEditor.h index 32d3b6ee5..b7beca257 100644 --- a/tools/fm-editor/FeatureModelEditor.h +++ b/tools/fm-editor/FeatureModelEditor.h @@ -21,6 +21,7 @@ QT_END_NAMESPACE class FeatureModelEditor : public QMainWindow { Q_OBJECT + public: explicit FeatureModelEditor(QWidget *Parent = nullptr); ~FeatureModelEditor() override = default; diff --git a/tools/fm-editor/graph/FeatureModelGraph.cpp b/tools/fm-editor/graph/FeatureModelGraph.cpp index 8a008ec94..e14a01ebd 100644 --- a/tools/fm-editor/graph/FeatureModelGraph.cpp +++ b/tools/fm-editor/graph/FeatureModelGraph.cpp @@ -75,6 +75,7 @@ int FeatureModelGraph::positionRec(const int CurrentDepth, if (Children.empty()) { return CurrentDepth - 1; } + int MaxDepth = CurrentDepth; auto NextOffset = Offset; for (FeatureNode *Node : Children) { @@ -116,10 +117,10 @@ void FeatureModelGraph::drawBackground(QPainter *Painter, const QRectF &Rect) { Q_UNUSED(Rect) // Shadow - QRectF const SceneRect = this->sceneRect(); - QRectF const RightShadow(SceneRect.right(), SceneRect.top() + 5, 5, + const QRectF SceneRect = this->sceneRect(); + const QRectF RightShadow(SceneRect.right(), SceneRect.top() + 5, 5, SceneRect.height()); - QRectF const BottomShadow(SceneRect.left() + 5, SceneRect.bottom(), + const QRectF BottomShadow(SceneRect.left() + 5, SceneRect.bottom(), SceneRect.width(), 5); if (RightShadow.intersects(Rect) || RightShadow.contains(Rect)) { Painter->fillRect(RightShadow, Qt::darkGray); @@ -145,7 +146,7 @@ void FeatureModelGraph::drawBackground(QPainter *Painter, const QRectF &Rect) { } void FeatureModelGraph::scaleView(qreal ScaleFactor) { - qreal const Factor = transform() + const qreal Factor = transform() .scale(ScaleFactor, ScaleFactor) .mapRect(QRectF(0, 0, 1, 1)) .width(); @@ -174,11 +175,12 @@ FeatureNode *FeatureModelGraph::addNode(Feature *Feature, FeatureNode *Parent) { [](FeatureEdge *Edge) { return Edge->targetNode(); }); positionRec(1, NextChildren, 5); EntryNode->setPos(EntryNode->childrenWidth() / 2.0, 10); + return NewNodeRaw; } FeatureNode *FeatureModelGraph::getNode(std::string Name) { - auto It = std::find_if(Nodes.begin(), Nodes.end(), [&Name](auto const &Node) { + auto It = std::find_if(Nodes.begin(), Nodes.end(), [&Name](const auto &Node) { return Node->getName() == Name; }); if (It != Nodes.end()) { @@ -211,6 +213,5 @@ void FeatureModelGraph::deleteNode(bool Recursive, FeatureNode *Node) { void FeatureModelGraph::deleteNode(bool Recursive, vara::feature::Feature *Feature) { - auto *Node = getNode(Feature->getName().str()); - deleteNode(Recursive, Node); + deleteNode(Recursive, getNode(Feature->getName().str())); } diff --git a/tools/fm-editor/graph/FeatureNode.cpp b/tools/fm-editor/graph/FeatureNode.cpp index a9b1501ed..17a0e8ba3 100644 --- a/tools/fm-editor/graph/FeatureNode.cpp +++ b/tools/fm-editor/graph/FeatureNode.cpp @@ -31,14 +31,14 @@ std::vector FeatureNode::children() { return ChildEdges; } FeatureEdge *FeatureNode::parent() { return ParentEdge; } QRectF FeatureNode::boundingRect() const { - qreal const Adjust = 2; - int const W = width(); + const qreal Adjust = 2; + const int W = width(); return {-W / 2.0 - Adjust, -10 - Adjust, W + Adjust, 23 + Adjust}; } QPainterPath FeatureNode::shape() const { QPainterPath Path; - int const W = width(); + const int W = width(); Path.addRect(-W / 2.0, -10, W, 20); return Path; } @@ -105,8 +105,7 @@ void FeatureNode::contextMenuEvent(QGraphicsSceneContextMenuEvent *Event) { void FeatureNode::inspect() { emit(inspectSource(Feature)); } int FeatureNode::width() const { - auto Name = Feature->getName(); - return 15 + 5 * int(Name.str().length()); + return 15 + 5 * int(Feature->getName().size()); } int FeatureNode::childrenWidth() const { diff --git a/tools/fm-editor/main.cpp b/tools/fm-editor/main.cpp index 4081d8fae..2920654a4 100644 --- a/tools/fm-editor/main.cpp +++ b/tools/fm-editor/main.cpp @@ -3,7 +3,7 @@ #include int main(int argc, char **argv) { - QApplication const App(argc, argv); + const QApplication App(argc, argv); FeatureModelEditor W; W.show(); return QApplication::exec(); diff --git a/tools/fm-editor/tree/FeatureTreeItem.cpp b/tools/fm-editor/tree/FeatureTreeItem.cpp index c36a0b48e..0fa64e761 100644 --- a/tools/fm-editor/tree/FeatureTreeItem.cpp +++ b/tools/fm-editor/tree/FeatureTreeItem.cpp @@ -1,11 +1,12 @@ #include "FeatureTreeItem.h" #include + #include QVariant numericValue(vara::feature::Feature *Item) { if (Item->getKind() == vara::feature::Feature::FeatureKind::FK_NUMERIC) { - auto *NumItem = dynamic_cast(Item); + auto *NumItem = llvm::dyn_cast(Item); string Result = "["; if (std::holds_alternative( NumItem->getValues())) { @@ -24,8 +25,10 @@ QVariant numericValue(vara::feature::Feature *Item) { } Result += "]"; } + return QString::fromStdString(Result); } + return {}; } diff --git a/tools/fm-editor/tree/FeatureTreeItem.h b/tools/fm-editor/tree/FeatureTreeItem.h index 2e9a66391..b661eb6b0 100644 --- a/tools/fm-editor/tree/FeatureTreeItem.h +++ b/tools/fm-editor/tree/FeatureTreeItem.h @@ -4,22 +4,31 @@ #include "vara/Feature/Feature.h" #include "vara/Feature/Relationship.h" +#include + #include #include #include -#include + #include + class FeatureTreeItem : public QObject { Q_OBJECT + public: FeatureTreeItem *child(int Row) { if (Row < 0 || Row > Children.size()) { + return nullptr; } + return Children[Row]; } + int childCount() { return Children.size(); } + std::vector getChildrenRecursive(); + int row() { if (Parent) { auto pos = @@ -28,8 +37,10 @@ class FeatureTreeItem : public QObject { return pos - Parent->Children.begin(); } } + return 0; } + FeatureTreeItem *parent() { return Parent; } void addChild(FeatureTreeItem *Child); std::vector &getChildren() { return Children; } @@ -43,6 +54,7 @@ class FeatureTreeItem : public QObject { vara::feature::FeatureTreeNode::NodeKind getKind() { return Kind; } virtual string getName() { return ""; }; void setParent(FeatureTreeItem *ParentItem) { this->Parent = ParentItem; } + signals: void inspectSource(vara::feature::Feature *Feature); void addChildFeature(vara::feature::Feature *Feature); @@ -61,8 +73,8 @@ class FeatureTreeItem : public QObject { class FeatureTreeItemFeature : public FeatureTreeItem { Q_OBJECT + public: - virtual ~FeatureTreeItemFeature() = default; FeatureTreeItemFeature(vara::feature::Feature *Item) : FeatureTreeItem(vara::feature::FeatureTreeNode::NodeKind::NK_FEATURE), Item(Item) { @@ -75,6 +87,8 @@ class FeatureTreeItemFeature : public FeatureTreeItem { connect(RemoveAction.get(), &QAction::triggered, this, &FeatureTreeItemFeature::remove, Qt::QueuedConnection); } + virtual ~FeatureTreeItemFeature() = default; + [[nodiscard]] QVariant data(int Column) const override; [[nodiscard]] int columnCount() const override { return 5; } bool booleanColumn(int Column) { return Column == 1; } @@ -82,6 +96,7 @@ class FeatureTreeItemFeature : public FeatureTreeItem { vara::feature::FeatureTreeNode *getItem() const override { return Item; } const vara::feature::Feature *getFeature() const { return Item; } string getName() override { return Item->getName().str(); } + public slots: void inspect(); void addChild(); @@ -95,11 +110,12 @@ public slots: class FeatureTreeItemRelation : public FeatureTreeItem { public: - ~FeatureTreeItemRelation() override = default; FeatureTreeItemRelation(vara::feature::Relationship *Item) : FeatureTreeItem( vara::feature::FeatureTreeNode::NodeKind::NK_RELATIONSHIP), Item(Item) {} + ~FeatureTreeItemRelation() override = default; + [[nodiscard]] QVariant data(int Column) const override { if (Column == 0) { return QString::fromStdString(relationType()); @@ -114,6 +130,7 @@ class FeatureTreeItemRelation : public FeatureTreeItem { vara::feature::Relationship *Item; static const vara::feature::FeatureTreeNode::NodeKind Kind = vara::feature::FeatureTreeNode::NodeKind::NK_RELATIONSHIP; + [[nodiscard]] std::string relationType() const { std::string Type; switch (Item->getKind()) { diff --git a/tools/fm-editor/tree/FeatureTreeViewModel.h b/tools/fm-editor/tree/FeatureTreeViewModel.h index c9145c70e..aa5df4644 100644 --- a/tools/fm-editor/tree/FeatureTreeViewModel.h +++ b/tools/fm-editor/tree/FeatureTreeViewModel.h @@ -15,8 +15,8 @@ class FeatureTreeViewModel : public QAbstractItemModel { Items.push_back(std::move(UniqueRoot)); buildRecursive(RootItem); } - ~FeatureTreeViewModel() override { std::destroy(Items.begin(), Items.end()); } + std::vector> *getItems(); [[nodiscard]] QVariant data(const QModelIndex &Index, int Role = Qt::DisplayRole) const override; @@ -58,7 +58,7 @@ class FeatureTreeViewModel : public QAbstractItemModel { Items.push_back(std::move(Child)); } else { auto Child = FeatureTreeItem::createFeatureTreeItem( - dynamic_cast(ChildItem)); + llvm::dyn_cast(ChildItem)); Parent->addChild(Child.get()); Child->setParent(Parent); RawChild = Child.get(); @@ -67,6 +67,7 @@ class FeatureTreeViewModel : public QAbstractItemModel { buildRecursive(RawChild); } } + vara::feature::FeatureModel *Model; FeatureTreeItem *RootItem; std::vector> Items; From e7fe6b8e9ec4814230cc0f34f591fa9d841cb95f Mon Sep 17 00:00:00 2001 From: Simon Friedel Date: Tue, 20 Jun 2023 17:30:13 +0200 Subject: [PATCH 075/106] Remove special case for old qt versions --- tools/fm-editor/CMakeLists.txt | 3 --- tools/fm-editor/FeatureModelEditor.cpp | 2 -- 2 files changed, 5 deletions(-) diff --git a/tools/fm-editor/CMakeLists.txt b/tools/fm-editor/CMakeLists.txt index 3e532639e..cdfff2fed 100644 --- a/tools/fm-editor/CMakeLists.txt +++ b/tools/fm-editor/CMakeLists.txt @@ -10,9 +10,6 @@ find_package( COMPONENTS Widgets ) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets) -if(QT_VERSION_MAJOR GREATER 5 OR QT_VERSION_MINOR GREATER_EQUAL 15) - # add_compile_definitions(QT_HAS_SETPLACEHOLDERTEXT) -endif() include_directories(../../external/qsourcehighlite) include_directories(.) diff --git a/tools/fm-editor/FeatureModelEditor.cpp b/tools/fm-editor/FeatureModelEditor.cpp index 06c0869d6..b123823f8 100644 --- a/tools/fm-editor/FeatureModelEditor.cpp +++ b/tools/fm-editor/FeatureModelEditor.cpp @@ -194,11 +194,9 @@ void FeatureModelEditor::inspectFeatureSources( if (Ui->sources->count() == 1) { loadSource(Ui->sources->itemText(0)); } -#ifdef QT_HAS_SETPLACEHOLDERTEXT else { Ui->sources->setPlaceholderText("Select File"); } -#endif } /// Create the Context menu for inspecting sources in the tree view From d344c67d8a5b33e2b319f0de53acfd4841c20bc1 Mon Sep 17 00:00:00 2001 From: Simon Friedel Date: Tue, 20 Jun 2023 17:30:49 +0200 Subject: [PATCH 076/106] Cleanup --- tools/fm-editor/graph/FeatureModelGraph.cpp | 5 ++--- tools/fm-editor/graph/FeatureModelGraph.h | 1 - tools/fm-editor/tree/FeatureTreeItem.cpp | 2 +- tools/fm-editor/tree/FeatureTreeViewModel.h | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/tools/fm-editor/graph/FeatureModelGraph.cpp b/tools/fm-editor/graph/FeatureModelGraph.cpp index e14a01ebd..11f6e7813 100644 --- a/tools/fm-editor/graph/FeatureModelGraph.cpp +++ b/tools/fm-editor/graph/FeatureModelGraph.cpp @@ -16,10 +16,9 @@ FeatureModelGraph::FeatureModelGraph(vara::feature::FeatureModel *FeatureModel, EntryNode(new FeatureNode(FeatureModel->getRoot())), FeatureModel(FeatureModel) { - auto *Scene = new QGraphicsScene(this); + Scene = std::make_unique(this); Scene->setItemIndexMethod(QGraphicsScene::NoIndex); - - setScene(Scene); + setScene(Scene.get()); setCacheMode(CacheBackground); setViewportUpdateMode(BoundingRectViewportUpdate); setRenderHint(QPainter::Antialiasing); diff --git a/tools/fm-editor/graph/FeatureModelGraph.h b/tools/fm-editor/graph/FeatureModelGraph.h index 80864e345..29c44799e 100644 --- a/tools/fm-editor/graph/FeatureModelGraph.h +++ b/tools/fm-editor/graph/FeatureModelGraph.h @@ -37,7 +37,6 @@ public slots: private: void reload(); void buildRec(FeatureNode *CurrentFeatureNode); - int TimerId = 0; FeatureNode *EntryNode; int positionRec(int CurrentDepth, const std::vector &Children, unsigned long Offset); diff --git a/tools/fm-editor/tree/FeatureTreeItem.cpp b/tools/fm-editor/tree/FeatureTreeItem.cpp index 0fa64e761..ce0b4e061 100644 --- a/tools/fm-editor/tree/FeatureTreeItem.cpp +++ b/tools/fm-editor/tree/FeatureTreeItem.cpp @@ -6,7 +6,7 @@ QVariant numericValue(vara::feature::Feature *Item) { if (Item->getKind() == vara::feature::Feature::FeatureKind::FK_NUMERIC) { - auto *NumItem = llvm::dyn_cast(Item); + auto *NumItem = llvm::dyn_cast(Item); string Result = "["; if (std::holds_alternative( NumItem->getValues())) { diff --git a/tools/fm-editor/tree/FeatureTreeViewModel.h b/tools/fm-editor/tree/FeatureTreeViewModel.h index aa5df4644..195c2783f 100644 --- a/tools/fm-editor/tree/FeatureTreeViewModel.h +++ b/tools/fm-editor/tree/FeatureTreeViewModel.h @@ -58,7 +58,7 @@ class FeatureTreeViewModel : public QAbstractItemModel { Items.push_back(std::move(Child)); } else { auto Child = FeatureTreeItem::createFeatureTreeItem( - llvm::dyn_cast(ChildItem)); + llvm::dyn_cast(ChildItem)); Parent->addChild(Child.get()); Child->setParent(Parent); RawChild = Child.get(); From bb33e0cc7ad0645d885b09cd57a69bbd72cac2e4 Mon Sep 17 00:00:00 2001 From: Simon Friedel Date: Tue, 20 Jun 2023 17:32:36 +0200 Subject: [PATCH 077/106] Automatically select newly added source files --- tools/fm-editor/FeatureModelEditor.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/fm-editor/FeatureModelEditor.cpp b/tools/fm-editor/FeatureModelEditor.cpp index b123823f8..f6bac6d05 100644 --- a/tools/fm-editor/FeatureModelEditor.cpp +++ b/tools/fm-editor/FeatureModelEditor.cpp @@ -268,6 +268,7 @@ void FeatureModelEditor::addSourceFile() { QFileDialog::getOpenFileName(this, tr("Select Source File"), Repository, tr("C Files (*.c *c++ *.h)")); Ui->sources->addItem(Path.mid(Repository.length())); + Ui->sources->setCurrentIndex(Ui->sources->count()-1); } } From 56cd7ef47eae527b7d66c3f6f9f525c4a225b5c4 Mon Sep 17 00:00:00 2001 From: Simon Friedel Date: Tue, 20 Jun 2023 17:35:54 +0200 Subject: [PATCH 078/106] Add Q_Interface declaration to FeatureNode.h --- tools/fm-editor/graph/FeatureNode.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/fm-editor/graph/FeatureNode.h b/tools/fm-editor/graph/FeatureNode.h index e419748f4..fed1eac07 100644 --- a/tools/fm-editor/graph/FeatureNode.h +++ b/tools/fm-editor/graph/FeatureNode.h @@ -14,7 +14,7 @@ class FeatureModelGraph; class FeatureNode : public QObject, public QGraphicsItem { Q_OBJECT - + Q_INTERFACES(QGraphicsItem) public: void removeChild(FeatureNode *Child); FeatureNode(vara::feature::Feature *Feature); From c4e02e25f2ead488b5bdc30a43bdd814a25255ad Mon Sep 17 00:00:00 2001 From: Simon Friedel Date: Tue, 20 Jun 2023 17:41:38 +0200 Subject: [PATCH 079/106] Fix Formatting --- tools/fm-editor/CMakeLists.txt | 2 +- tools/fm-editor/FeatureModelEditor.cpp | 5 ++--- tools/fm-editor/graph/FeatureModelGraph.cpp | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/fm-editor/CMakeLists.txt b/tools/fm-editor/CMakeLists.txt index cdfff2fed..af3b1a954 100644 --- a/tools/fm-editor/CMakeLists.txt +++ b/tools/fm-editor/CMakeLists.txt @@ -54,7 +54,7 @@ add_custom_target( file( WRITE "${CMAKE_CURRENT_BINARY_DIR}/fm-editor_autogen/.clang-tidy" -" + " --- Checks: '-*,llvm-twine-local' ... diff --git a/tools/fm-editor/FeatureModelEditor.cpp b/tools/fm-editor/FeatureModelEditor.cpp index f6bac6d05..b69b7591e 100644 --- a/tools/fm-editor/FeatureModelEditor.cpp +++ b/tools/fm-editor/FeatureModelEditor.cpp @@ -193,8 +193,7 @@ void FeatureModelEditor::inspectFeatureSources( QString::fromStdString("Sources for: " + Feature->getName().str())); if (Ui->sources->count() == 1) { loadSource(Ui->sources->itemText(0)); - } - else { + } else { Ui->sources->setPlaceholderText("Select File"); } } @@ -268,7 +267,7 @@ void FeatureModelEditor::addSourceFile() { QFileDialog::getOpenFileName(this, tr("Select Source File"), Repository, tr("C Files (*.c *c++ *.h)")); Ui->sources->addItem(Path.mid(Repository.length())); - Ui->sources->setCurrentIndex(Ui->sources->count()-1); + Ui->sources->setCurrentIndex(Ui->sources->count() - 1); } } diff --git a/tools/fm-editor/graph/FeatureModelGraph.cpp b/tools/fm-editor/graph/FeatureModelGraph.cpp index 11f6e7813..1e1f4f225 100644 --- a/tools/fm-editor/graph/FeatureModelGraph.cpp +++ b/tools/fm-editor/graph/FeatureModelGraph.cpp @@ -174,7 +174,7 @@ FeatureNode *FeatureModelGraph::addNode(Feature *Feature, FeatureNode *Parent) { [](FeatureEdge *Edge) { return Edge->targetNode(); }); positionRec(1, NextChildren, 5); EntryNode->setPos(EntryNode->childrenWidth() / 2.0, 10); - + return NewNodeRaw; } From 004cfaa5a157b5a68713de85ea82b07e067db48c Mon Sep 17 00:00:00 2001 From: Simon Friedel Date: Tue, 20 Jun 2023 17:49:29 +0200 Subject: [PATCH 080/106] add source locations only once to selection --- tools/fm-editor/FeatureModelEditor.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/fm-editor/FeatureModelEditor.cpp b/tools/fm-editor/FeatureModelEditor.cpp index b69b7591e..48a7ea6ac 100644 --- a/tools/fm-editor/FeatureModelEditor.cpp +++ b/tools/fm-editor/FeatureModelEditor.cpp @@ -186,9 +186,11 @@ void FeatureModelEditor::inspectFeatureSources( Repository = QFileDialog::getExistingDirectory(); } Ui->sources->clear(); + QSet Locations = {}; for (const auto &Source : Feature->getLocations()) { - Ui->sources->addItem(QString::fromStdString(Source.getPath().string())); + Locations.insert(QString::fromStdString(Source.getPath().string())); } + Ui->sources->addItems(Locations.values()); Ui->sourcesLable->setText( QString::fromStdString("Sources for: " + Feature->getName().str())); if (Ui->sources->count() == 1) { From 1d743182783055fd9adde130a21ff47316ed2576 Mon Sep 17 00:00:00 2001 From: Nerum Date: Wed, 26 Jul 2023 11:26:03 +0200 Subject: [PATCH 081/106] Add separator between feature locations --- tools/fm-editor/tree/FeatureTreeItem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/fm-editor/tree/FeatureTreeItem.cpp b/tools/fm-editor/tree/FeatureTreeItem.cpp index ce0b4e061..e23c2b40b 100644 --- a/tools/fm-editor/tree/FeatureTreeItem.cpp +++ b/tools/fm-editor/tree/FeatureTreeItem.cpp @@ -38,7 +38,7 @@ QVariant locationString(vara::feature::Feature *Item) { if (Item->hasLocations()) { std::for_each(Locs.begin(), Locs.end(), [&StrS](const vara::feature::FeatureSourceRange &Fsr) { - StrS << llvm::formatv("{0}", Fsr.toString()).str(); + StrS << llvm::formatv("{0}; ", Fsr.toString()).str(); }); } From 0d3150f8278477c6345bb0083facb4712a325ae0 Mon Sep 17 00:00:00 2001 From: Nerum Date: Wed, 26 Jul 2023 11:26:22 +0200 Subject: [PATCH 082/106] Make graph movable --- tools/fm-editor/graph/FeatureModelGraph.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/fm-editor/graph/FeatureModelGraph.cpp b/tools/fm-editor/graph/FeatureModelGraph.cpp index 1e1f4f225..fe9a60844 100644 --- a/tools/fm-editor/graph/FeatureModelGraph.cpp +++ b/tools/fm-editor/graph/FeatureModelGraph.cpp @@ -25,6 +25,7 @@ FeatureModelGraph::FeatureModelGraph(vara::feature::FeatureModel *FeatureModel, setTransformationAnchor(AnchorUnderMouse); scale(qreal(0.8), qreal(0.8)); reload(); + setDragMode(ScrollHandDrag); Scene->setSceneRect(0, 0, EntryNode->childrenWidth() + 100, 100 * EntryNode->childrenDepth() + 100); } @@ -149,7 +150,7 @@ void FeatureModelGraph::scaleView(qreal ScaleFactor) { .scale(ScaleFactor, ScaleFactor) .mapRect(QRectF(0, 0, 1, 1)) .width(); - if (Factor < 0.07 || Factor > 100) { + if (Factor < 0.3 || Factor > 5) { return; } From c4bead23859c380a5644b08b3fc6fbd4ff07ea5f Mon Sep 17 00:00:00 2001 From: Nerum Date: Wed, 26 Jul 2023 11:29:31 +0200 Subject: [PATCH 083/106] Check ModelPath before loading FeatureModel --- tools/fm-editor/FeatureModelEditor.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/tools/fm-editor/FeatureModelEditor.cpp b/tools/fm-editor/FeatureModelEditor.cpp index 48a7ea6ac..da271fb37 100644 --- a/tools/fm-editor/FeatureModelEditor.cpp +++ b/tools/fm-editor/FeatureModelEditor.cpp @@ -66,8 +66,7 @@ void FeatureModelEditor::clean() { void FeatureModelEditor::loadGraph() { clean(); ModelPath = Ui->ModelFile->text(); - FeatureModel = vara::feature::loadFeatureModel(ModelPath.toStdString()); - if (!FeatureModel) { + if (ModelPath.isEmpty()) { QString const Path = QFileDialog::getOpenFileName( this, tr("Open Model"), "/home", tr("XML files (*.xml)")); if (Path.isEmpty()) { @@ -75,8 +74,12 @@ void FeatureModelEditor::loadGraph() { } Ui->ModelFile->setText(Path); FeatureModel = vara::feature::loadFeatureModel(Path.toStdString()); + } else { + FeatureModel = vara::feature::loadFeatureModel(ModelPath.toStdString()); + } + if (!FeatureModel) { + return; } - // create Graph view buildGraph(); @@ -278,8 +281,11 @@ void FeatureModelEditor::addSourceFile() { void FeatureModelEditor::addSource() { auto *TextEdit = Ui->textEdit; auto Cursor = TextEdit->textCursor(); - const int Start = Cursor.selectionStart(); - const int End = Cursor.selectionEnd(); + int Start = Cursor.selectionStart(); + int End = Cursor.selectionEnd(); + if (Start > End) { + std::swap(Start, End); + } Cursor.movePosition(QTextCursor::MoveOperation::StartOfLine); const int LineStart = Cursor.position(); int Lines = 1; @@ -298,7 +304,7 @@ void FeatureModelEditor::addSource() { vara::feature::FeatureSourceRange::FeatureSourceLocation( Lines, Start - LineStart + 1), vara::feature::FeatureSourceRange::FeatureSourceLocation( - Lines, End - LineStart)); + Lines, End - LineStart + 1)); auto LocationTransAction = Transaction::openTransaction(*FeatureModel); LocationTransAction.addLocation(CurrentFeature, Range); LocationTransAction.commit(); From 61c923de5b337c0872cc0de684c8f0196e4c99b4 Mon Sep 17 00:00:00 2001 From: Nerum Date: Thu, 27 Jul 2023 10:19:19 +0200 Subject: [PATCH 084/106] Fix spacing and cut off for node labels --- tools/fm-editor/graph/FeatureModelGraph.cpp | 2 +- tools/fm-editor/graph/FeatureNode.cpp | 19 ++++++++++++------- tools/fm-editor/graph/FeatureNode.h | 1 + 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/tools/fm-editor/graph/FeatureModelGraph.cpp b/tools/fm-editor/graph/FeatureModelGraph.cpp index fe9a60844..82a0f1570 100644 --- a/tools/fm-editor/graph/FeatureModelGraph.cpp +++ b/tools/fm-editor/graph/FeatureModelGraph.cpp @@ -85,7 +85,7 @@ int FeatureModelGraph::positionRec(const int CurrentDepth, NextChildren.begin(), [](FeatureEdge *Edge) { return Edge->targetNode(); }); int const Depth = positionRec(CurrentDepth + 1, NextChildren, NextOffset); - int Width = Node->childrenWidth() + 5; + int Width = Node->childrenWidth(); Node->setPos(double(NextOffset) + Width / 2.0, 100 * CurrentDepth); NextOffset += Width; MaxDepth = MaxDepth < Depth ? Depth : MaxDepth; diff --git a/tools/fm-editor/graph/FeatureNode.cpp b/tools/fm-editor/graph/FeatureNode.cpp index 17a0e8ba3..43f085380 100644 --- a/tools/fm-editor/graph/FeatureNode.cpp +++ b/tools/fm-editor/graph/FeatureNode.cpp @@ -31,15 +31,17 @@ std::vector FeatureNode::children() { return ChildEdges; } FeatureEdge *FeatureNode::parent() { return ParentEdge; } QRectF FeatureNode::boundingRect() const { + const qreal Adjust = 2; const int W = width(); - return {-W / 2.0 - Adjust, -10 - Adjust, W + Adjust, 23 + Adjust}; + return {-(W + widthAdjust) / 2.0 - Adjust, -10 - Adjust, + W + widthAdjust + Adjust, 23 + 2 * Adjust}; } QPainterPath FeatureNode::shape() const { QPainterPath Path; const int W = width(); - Path.addRect(-W / 2.0, -10, W, 20); + Path.addRect(-(W + widthAdjust) / 2.0, -10, W + widthAdjust, 20); return Path; } @@ -56,9 +58,9 @@ void FeatureNode::paint(QPainter *Painter, Painter->setPen(QPen(Qt::black, 0)); int const W = width(); - Painter->drawRect(-W / 2, -10, W, 20); + Painter->drawRect(-(W + widthAdjust) / 2, -10, W + widthAdjust, 20); Painter->setPen(QPen(Qt::black, 1)); - Painter->drawText(-W / 2 + 5, 5, Name); + Painter->drawText(-W / 2, 5, Name); } QVariant FeatureNode::itemChange(QGraphicsItem::GraphicsItemChange Change, @@ -105,20 +107,23 @@ void FeatureNode::contextMenuEvent(QGraphicsSceneContextMenuEvent *Event) { void FeatureNode::inspect() { emit(inspectSource(Feature)); } int FeatureNode::width() const { - return 15 + 5 * int(Feature->getName().size()); + const QFontMetrics fm((QFont())); + + return fm.boundingRect(getQName()).width(); } int FeatureNode::childrenWidth() const { if (ChildEdges.empty()) { - return width(); + return width() + 1.5 * widthAdjust; } int Result = 0; for (auto *Child : ChildEdges) { Result += Child->targetNode()->childrenWidth(); + Result += widthAdjust / 2; } - return std::max(Result, width()); + return std::max(Result, width() + widthAdjust); } int FeatureNode::childrenDepth() const { diff --git a/tools/fm-editor/graph/FeatureNode.h b/tools/fm-editor/graph/FeatureNode.h index fed1eac07..c2e4ec7d5 100644 --- a/tools/fm-editor/graph/FeatureNode.h +++ b/tools/fm-editor/graph/FeatureNode.h @@ -61,6 +61,7 @@ class FeatureNode : public QObject, public QGraphicsItem { vara::feature::Feature *Feature; std::unique_ptr ContextMenu; void inspect(); + const int widthAdjust = 10; }; #endif // VARA_FEATURE_FEATURENODE_H From 0392b583a4f71e3d1e2fcef0f316bd895c42623f Mon Sep 17 00:00:00 2001 From: Nerum Date: Thu, 27 Jul 2023 10:41:00 +0200 Subject: [PATCH 085/106] Fix formatting --- tools/fm-editor/CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/fm-editor/CMakeLists.txt b/tools/fm-editor/CMakeLists.txt index af3b1a954..23921deda 100644 --- a/tools/fm-editor/CMakeLists.txt +++ b/tools/fm-editor/CMakeLists.txt @@ -54,9 +54,9 @@ add_custom_target( file( WRITE "${CMAKE_CURRENT_BINARY_DIR}/fm-editor_autogen/.clang-tidy" - " ---- -Checks: '-*,llvm-twine-local' -... -" + " + --- + Checks: '-*,llvm-twine-local' + ... + " ) From 061bff178fa0b24e128c7b5e93e10c7eed4c05b7 Mon Sep 17 00:00:00 2001 From: Lukas Abelt Date: Mon, 18 Sep 2023 10:33:22 +0200 Subject: [PATCH 086/106] * Switched to use selection changed option for navigating through feature list --- tools/fm-editor/FeatureModelEditor.cpp | 11 ++++++++--- tools/fm-editor/FeatureModelEditor.h | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/tools/fm-editor/FeatureModelEditor.cpp b/tools/fm-editor/FeatureModelEditor.cpp index da271fb37..6717ed54a 100644 --- a/tools/fm-editor/FeatureModelEditor.cpp +++ b/tools/fm-editor/FeatureModelEditor.cpp @@ -40,7 +40,13 @@ void FeatureModelEditor::loadFeature(const vara::feature::Feature *Feature) { } /// Get a Feature from an Index of the TreeView and display its information. -void FeatureModelEditor::loadFeatureFromIndex(const QModelIndex &Index) { +void FeatureModelEditor::loadFeatureFromSelection(const QItemSelection &Selection) { + if ( Selection.size() != 1 ){ + return; + } + + auto Index = Selection.indexes().at(0); + if (Index.isValid()) { auto *Item = static_cast(Index.internalPointer()) ->child(Index.row()); @@ -109,12 +115,11 @@ void FeatureModelEditor::buildTree() { connect(Item.get(), &FeatureTreeItem::removeFeature, this, &FeatureModelEditor::removeFeature); } - connect(TreeView.get(), &QTreeView::pressed, this, - &FeatureModelEditor::loadFeatureFromIndex); TreeView->setModel(TreeModel.get()); TreeView->setContextMenuPolicy(Qt::CustomContextMenu); connect(TreeView.get(), SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(createTreeContextMenu(QPoint))); + connect(TreeView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &FeatureModelEditor::loadFeatureFromSelection); } /// Build the graph view diff --git a/tools/fm-editor/FeatureModelEditor.h b/tools/fm-editor/FeatureModelEditor.h index b7beca257..c07997c4d 100644 --- a/tools/fm-editor/FeatureModelEditor.h +++ b/tools/fm-editor/FeatureModelEditor.h @@ -46,7 +46,7 @@ public slots: void loadSource(const QString &RelativePath); void createTreeContextMenu(const QPoint &Pos); void addSourceFile(); - void loadFeatureFromIndex(const QModelIndex &Index); + void loadFeatureFromSelection(const QItemSelection &Selection); void save(); void featureAddDialog(); void removeFeature(bool Recursive, vara::feature::Feature *Feature); From b141fd3c7272aac68327e1da97314b675ceacc5e Mon Sep 17 00:00:00 2001 From: Lukas Abelt Date: Tue, 26 Sep 2023 10:27:22 +0200 Subject: [PATCH 087/106] * Added action to create new feature models --- tools/fm-editor/FeatureModelEditor.cpp | 26 ++++++++++++++++++++++++++ tools/fm-editor/FeatureModelEditor.h | 1 + tools/fm-editor/FeatureModelEditor.ui | 9 +++++++++ 3 files changed, 36 insertions(+) diff --git a/tools/fm-editor/FeatureModelEditor.cpp b/tools/fm-editor/FeatureModelEditor.cpp index 6717ed54a..d2b0d1089 100644 --- a/tools/fm-editor/FeatureModelEditor.cpp +++ b/tools/fm-editor/FeatureModelEditor.cpp @@ -32,6 +32,7 @@ FeatureModelEditor::FeatureModelEditor(QWidget *Parent) &FeatureModelEditor::addSource); connect(Ui->addSourceFile, &QPushButton::pressed, this, &FeatureModelEditor::addSourceFile); + connect(Ui->actionCreateNewFM, &QAction::triggered, this, &FeatureModelEditor::createNewModel); } /// Display the information of a Feature @@ -315,3 +316,28 @@ void FeatureModelEditor::addSource() { LocationTransAction.commit(); markLocation(Range); } +void FeatureModelEditor::createNewModel() { + ModelPath = QFileDialog::getSaveFileName(this, tr("Save File"), ".", + tr("XML files (*.xml)")); + + if(ModelPath.isEmpty()){ + return; + } + + FeatureModel = std::make_unique("FeatureModel", + std::make_unique("root"), + fs::path(ModelPath.toStdString())); + + // create Graph view + buildGraph(); + + // create Tree View + buildTree(); + + Ui->tabWidget->addTab(Graph.get(), "GraphView"); + Ui->tabWidget->addTab(TreeView.get(), "TreeView"); + connect(Ui->sources, &QComboBox::currentTextChanged, this, + &FeatureModelEditor::loadSource); + Ui->actionSave->setEnabled(true); + Ui->actionAddFeature->setEnabled(true); +} diff --git a/tools/fm-editor/FeatureModelEditor.h b/tools/fm-editor/FeatureModelEditor.h index c07997c4d..32d6be8fe 100644 --- a/tools/fm-editor/FeatureModelEditor.h +++ b/tools/fm-editor/FeatureModelEditor.h @@ -50,6 +50,7 @@ public slots: void save(); void featureAddDialog(); void removeFeature(bool Recursive, vara::feature::Feature *Feature); + void createNewModel(); private: void clean(); diff --git a/tools/fm-editor/FeatureModelEditor.ui b/tools/fm-editor/FeatureModelEditor.ui index 61efa65f5..a9992cf1f 100644 --- a/tools/fm-editor/FeatureModelEditor.ui +++ b/tools/fm-editor/FeatureModelEditor.ui @@ -180,6 +180,7 @@ Edit + @@ -194,6 +195,14 @@ AddFeature + + + true + + + Create New Model + + false From 19b317e0a4d6f64a9468377dc3baf0bf93c840de Mon Sep 17 00:00:00 2001 From: Lukas Abelt Date: Tue, 26 Sep 2023 10:51:57 +0200 Subject: [PATCH 088/106] * Improvements to save and added saveAs --- tools/fm-editor/FeatureModelEditor.cpp | 16 ++++++++++++++-- tools/fm-editor/FeatureModelEditor.h | 1 + tools/fm-editor/FeatureModelEditor.ui | 12 ++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/tools/fm-editor/FeatureModelEditor.cpp b/tools/fm-editor/FeatureModelEditor.cpp index d2b0d1089..7a14bf1b4 100644 --- a/tools/fm-editor/FeatureModelEditor.cpp +++ b/tools/fm-editor/FeatureModelEditor.cpp @@ -28,6 +28,7 @@ FeatureModelEditor::FeatureModelEditor(QWidget *Parent) QObject::connect(Ui->actionAddFeature, &QAction::triggered, this, &FeatureModelEditor::featureAddDialog); connect(Ui->actionSave, &QAction::triggered, this, &FeatureModelEditor::save); + connect(Ui->actionSaveAs, &QAction::triggered, this, &FeatureModelEditor::saveAs); connect(Ui->addSource, &QPushButton::pressed, this, &FeatureModelEditor::addSource); connect(Ui->addSourceFile, &QPushButton::pressed, this, @@ -79,6 +80,8 @@ void FeatureModelEditor::loadGraph() { if (Path.isEmpty()) { return; } + + ModelPath = SavePath = Path; Ui->ModelFile->setText(Path); FeatureModel = vara::feature::loadFeatureModel(Path.toStdString()); } else { @@ -98,6 +101,7 @@ void FeatureModelEditor::loadGraph() { connect(Ui->sources, &QComboBox::currentTextChanged, this, &FeatureModelEditor::loadSource); Ui->actionSave->setEnabled(true); + Ui->actionSaveAs->setEnabled(true); Ui->actionAddFeature->setEnabled(true); } @@ -178,12 +182,20 @@ void FeatureModelEditor::removeFeature(bool Recursive, Feature *Feature) { /// Save the current State of the Feature Model void FeatureModelEditor::save() { - SavePath = QFileDialog::getSaveFileName(this, tr("Save File"), ModelPath, - tr("XML files (*.xml)")); + if(SavePath.isEmpty()){ + SavePath = QFileDialog::getSaveFileName(this, tr("Save File"), ModelPath, + tr("XML files (*.xml)")); + } vara::feature::FeatureModelXmlWriter FMWrite{*FeatureModel}; FMWrite.writeFeatureModel(SavePath.toStdString()); } +void FeatureModelEditor::saveAs() { + SavePath = QFileDialog::getSaveFileName(this, tr("Save File"), ModelPath, + tr("XML files (*.xml)")); + save(); +} + /// Load the source files of the Feature to be selectable by the user and set /// the Feature as CurrentFeature. /// diff --git a/tools/fm-editor/FeatureModelEditor.h b/tools/fm-editor/FeatureModelEditor.h index 32d6be8fe..add54ae30 100644 --- a/tools/fm-editor/FeatureModelEditor.h +++ b/tools/fm-editor/FeatureModelEditor.h @@ -48,6 +48,7 @@ public slots: void addSourceFile(); void loadFeatureFromSelection(const QItemSelection &Selection); void save(); + void saveAs(); void featureAddDialog(); void removeFeature(bool Recursive, vara::feature::Feature *Feature); void createNewModel(); diff --git a/tools/fm-editor/FeatureModelEditor.ui b/tools/fm-editor/FeatureModelEditor.ui index a9992cf1f..aabbed207 100644 --- a/tools/fm-editor/FeatureModelEditor.ui +++ b/tools/fm-editor/FeatureModelEditor.ui @@ -183,6 +183,7 @@ + @@ -214,6 +215,17 @@ Ctrl+S + + + false + + + Save + + + Ctrl+Alt+S + + From 9e00b3fa37a3323364458af2b0914031f71fd383 Mon Sep 17 00:00:00 2001 From: Lukas Abelt Date: Tue, 26 Sep 2023 10:58:04 +0200 Subject: [PATCH 089/106] * Added All Files filter to add source --- tools/fm-editor/FeatureModelEditor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/fm-editor/FeatureModelEditor.cpp b/tools/fm-editor/FeatureModelEditor.cpp index 7a14bf1b4..9e980c57f 100644 --- a/tools/fm-editor/FeatureModelEditor.cpp +++ b/tools/fm-editor/FeatureModelEditor.cpp @@ -288,7 +288,7 @@ void FeatureModelEditor::addSourceFile() { if (!Repository.isEmpty()) { QString const Path = QFileDialog::getOpenFileName(this, tr("Select Source File"), Repository, - tr("C Files (*.c *c++ *.h)")); + tr("C Files (*.c *c++ *.h) ;; All Files (*.*)")); Ui->sources->addItem(Path.mid(Repository.length())); Ui->sources->setCurrentIndex(Ui->sources->count() - 1); } From b7dd95fd6eac61ee518bb46fbed574798254ad2b Mon Sep 17 00:00:00 2001 From: Lukas Abelt Date: Tue, 26 Sep 2023 11:04:33 +0200 Subject: [PATCH 090/106] * Added guard to avoid adding empty source range --- tools/fm-editor/FeatureModelEditor.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/fm-editor/FeatureModelEditor.cpp b/tools/fm-editor/FeatureModelEditor.cpp index 9e980c57f..54f9a35e2 100644 --- a/tools/fm-editor/FeatureModelEditor.cpp +++ b/tools/fm-editor/FeatureModelEditor.cpp @@ -301,6 +301,11 @@ void FeatureModelEditor::addSource() { auto Cursor = TextEdit->textCursor(); int Start = Cursor.selectionStart(); int End = Cursor.selectionEnd(); + + if(Start==End){ + return; + } + if (Start > End) { std::swap(Start, End); } From b4bb9c594065d2836b58ffb77bbe6a8a1be3a10b Mon Sep 17 00:00:00 2001 From: Lukas Abelt Date: Tue, 26 Sep 2023 11:10:37 +0200 Subject: [PATCH 091/106] * Set correct line wrap mode for source code preview --- tools/fm-editor/FeatureModelEditor.ui | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/fm-editor/FeatureModelEditor.ui b/tools/fm-editor/FeatureModelEditor.ui index aabbed207..e68f99365 100644 --- a/tools/fm-editor/FeatureModelEditor.ui +++ b/tools/fm-editor/FeatureModelEditor.ui @@ -31,7 +31,11 @@ - + + + QTextEdit::NoWrap + + From 5f649cd602a931210b9f75365fedf11d84762063 Mon Sep 17 00:00:00 2001 From: Nerum Date: Mon, 30 Oct 2023 15:41:19 +0100 Subject: [PATCH 092/106] load Models from cwd --- tools/fm-editor/FeatureModelEditor.cpp | 56 ++++++++++++++++---------- 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/tools/fm-editor/FeatureModelEditor.cpp b/tools/fm-editor/FeatureModelEditor.cpp index 54f9a35e2..bbbe5a840 100644 --- a/tools/fm-editor/FeatureModelEditor.cpp +++ b/tools/fm-editor/FeatureModelEditor.cpp @@ -28,12 +28,14 @@ FeatureModelEditor::FeatureModelEditor(QWidget *Parent) QObject::connect(Ui->actionAddFeature, &QAction::triggered, this, &FeatureModelEditor::featureAddDialog); connect(Ui->actionSave, &QAction::triggered, this, &FeatureModelEditor::save); - connect(Ui->actionSaveAs, &QAction::triggered, this, &FeatureModelEditor::saveAs); + connect(Ui->actionSaveAs, &QAction::triggered, this, + &FeatureModelEditor::saveAs); connect(Ui->addSource, &QPushButton::pressed, this, &FeatureModelEditor::addSource); connect(Ui->addSourceFile, &QPushButton::pressed, this, &FeatureModelEditor::addSourceFile); - connect(Ui->actionCreateNewFM, &QAction::triggered, this, &FeatureModelEditor::createNewModel); + connect(Ui->actionCreateNewFM, &QAction::triggered, this, + &FeatureModelEditor::createNewModel); } /// Display the information of a Feature @@ -42,8 +44,9 @@ void FeatureModelEditor::loadFeature(const vara::feature::Feature *Feature) { } /// Get a Feature from an Index of the TreeView and display its information. -void FeatureModelEditor::loadFeatureFromSelection(const QItemSelection &Selection) { - if ( Selection.size() != 1 ){ +void FeatureModelEditor::loadFeatureFromSelection( + const QItemSelection &Selection) { + if (Selection.size() != 1) { return; } @@ -76,7 +79,9 @@ void FeatureModelEditor::loadGraph() { ModelPath = Ui->ModelFile->text(); if (ModelPath.isEmpty()) { QString const Path = QFileDialog::getOpenFileName( - this, tr("Open Model"), "/home", tr("XML files (*.xml)")); + this, tr("Open Model"), + QString::fromStdString(std::filesystem::current_path().string()), + tr("XML files (*.xml)")); if (Path.isEmpty()) { return; } @@ -124,16 +129,17 @@ void FeatureModelEditor::buildTree() { TreeView->setContextMenuPolicy(Qt::CustomContextMenu); connect(TreeView.get(), SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(createTreeContextMenu(QPoint))); - connect(TreeView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &FeatureModelEditor::loadFeatureFromSelection); + connect(TreeView->selectionModel(), &QItemSelectionModel::selectionChanged, + this, &FeatureModelEditor::loadFeatureFromSelection); } /// Build the graph view void FeatureModelEditor::buildGraph() { Graph = std::make_unique(FeatureModel.get()); for (auto &Node : *Graph->getNodes()) { - QObject::connect(Node.get(), &FeatureNode::clicked, this, + QObject::connect(Node, &FeatureNode::clicked, this, &FeatureModelEditor::loadFeature); - QObject::connect(Node.get(), &FeatureNode::inspectSource, this, + QObject::connect(Node, &FeatureNode::inspectSource, this, &FeatureModelEditor::inspectFeatureSources); } } @@ -182,7 +188,7 @@ void FeatureModelEditor::removeFeature(bool Recursive, Feature *Feature) { /// Save the current State of the Feature Model void FeatureModelEditor::save() { - if(SavePath.isEmpty()){ + if (SavePath.isEmpty()) { SavePath = QFileDialog::getSaveFileName(this, tr("Save File"), ModelPath, tr("XML files (*.xml)")); } @@ -191,9 +197,12 @@ void FeatureModelEditor::save() { } void FeatureModelEditor::saveAs() { - SavePath = QFileDialog::getSaveFileName(this, tr("Save File"), ModelPath, - tr("XML files (*.xml)")); - save(); + auto Path = QFileDialog::getSaveFileName(this, tr("Save File"), ModelPath, + tr("XML files (*.xml)")); + if (!Path.isEmpty()) { + SavePath = Path; + save(); + } } /// Load the source files of the Feature to be selectable by the user and set @@ -245,6 +254,7 @@ void FeatureModelEditor::loadSource(const QString &RelativePath) { if (File.exists()) { File.open(QFile::ReadOnly | QFile::Text); QTextStream ReadFile(&File); + Ui->textEdit->setLineWrapMode(QTextEdit::LineWrapMode::NoWrap); Ui->textEdit->setText(ReadFile.readAll()); std::vector Locations{}; std::copy_if( @@ -286,9 +296,9 @@ void FeatureModelEditor::markLocation( /// Load a sourcefile to then add a location from it void FeatureModelEditor::addSourceFile() { if (!Repository.isEmpty()) { - QString const Path = - QFileDialog::getOpenFileName(this, tr("Select Source File"), Repository, - tr("C Files (*.c *c++ *.h) ;; All Files (*.*)")); + QString const Path = QFileDialog::getOpenFileName( + this, tr("Select Source File"), Repository, + tr("C Files (*.c *c++ *.h) ;; All Files (*.*)")); Ui->sources->addItem(Path.mid(Repository.length())); Ui->sources->setCurrentIndex(Ui->sources->count() - 1); } @@ -297,12 +307,16 @@ void FeatureModelEditor::addSourceFile() { /// Add the user selected Part of the textedit as a source for the active /// Feature void FeatureModelEditor::addSource() { + if (Ui->sources->currentText().isEmpty()) { + return; + } + auto *TextEdit = Ui->textEdit; auto Cursor = TextEdit->textCursor(); int Start = Cursor.selectionStart(); int End = Cursor.selectionEnd(); - if(Start==End){ + if (Start == End) { return; } @@ -335,15 +349,15 @@ void FeatureModelEditor::addSource() { } void FeatureModelEditor::createNewModel() { ModelPath = QFileDialog::getSaveFileName(this, tr("Save File"), ".", - tr("XML files (*.xml)")); + tr("XML files (*.xml)")); - if(ModelPath.isEmpty()){ + if (ModelPath.isEmpty()) { return; } - FeatureModel = std::make_unique("FeatureModel", - std::make_unique("root"), - fs::path(ModelPath.toStdString())); + FeatureModel = std::make_unique( + "FeatureModel", std::make_unique("root"), + fs::path(ModelPath.toStdString())); // create Graph view buildGraph(); From 963ce6336455ece2279bb36909d157e1658c54f7 Mon Sep 17 00:00:00 2001 From: Nerum Date: Mon, 30 Oct 2023 15:44:30 +0100 Subject: [PATCH 093/106] do not use smart pointers in graphics view let qGraphics Scene handel the memory managment --- tools/fm-editor/FeatureModelEditor.ui | 4 +-- tools/fm-editor/graph/FeatureModelGraph.cpp | 39 ++++++++++----------- tools/fm-editor/graph/FeatureModelGraph.h | 2 +- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/tools/fm-editor/FeatureModelEditor.ui b/tools/fm-editor/FeatureModelEditor.ui index e68f99365..2538eacf1 100644 --- a/tools/fm-editor/FeatureModelEditor.ui +++ b/tools/fm-editor/FeatureModelEditor.ui @@ -177,7 +177,7 @@ 0 0 943 - 30 + 34 @@ -224,7 +224,7 @@ false - Save + Save As Ctrl+Alt+S diff --git a/tools/fm-editor/graph/FeatureModelGraph.cpp b/tools/fm-editor/graph/FeatureModelGraph.cpp index 82a0f1570..12914a7e2 100644 --- a/tools/fm-editor/graph/FeatureModelGraph.cpp +++ b/tools/fm-editor/graph/FeatureModelGraph.cpp @@ -31,7 +31,7 @@ FeatureModelGraph::FeatureModelGraph(vara::feature::FeatureModel *FeatureModel, } void FeatureModelGraph::reload() { - Nodes.push_back(std::unique_ptr(EntryNode)); + Nodes.push_back(EntryNode); auto *Scene = this->scene(); Scene->clear(); Scene->addItem(EntryNode); @@ -49,22 +49,22 @@ void FeatureModelGraph::buildRec(FeatureNode *CurrentFeatureNode) { for (auto *Feature : CurrentFeatureNode->getFeature()->getChildren( 1)) { - auto Node = std::make_unique(Feature); - auto *Edge = new FeatureEdge(CurrentFeatureNode, Node.get()); + auto *Node = new FeatureNode(Feature); + auto *Edge = new FeatureEdge(CurrentFeatureNode, Node); scene()->addItem(Edge); - scene()->addItem(Node.get()); - buildRec(Node.get()); - Nodes.push_back(std::move(Node)); + scene()->addItem(Node); + Nodes.push_back(Node); + buildRec(Node); } for (auto *Relation : CurrentFeatureNode->getFeature() ->getChildren(1)) { for (auto *Feature : Relation->getChildren(1)) { - auto Node = std::make_unique(Feature); - auto *Edge = new FeatureEdge(CurrentFeatureNode, Node.get()); + auto *Node = new FeatureNode(Feature); + auto *Edge = new FeatureEdge(CurrentFeatureNode, Node); scene()->addItem(Edge); - scene()->addItem(Node.get()); - buildRec(Node.get()); - Nodes.push_back(std::move(Node)); + scene()->addItem(Node); + buildRec(Node); + Nodes.push_back(Node); } } } @@ -85,7 +85,7 @@ int FeatureModelGraph::positionRec(const int CurrentDepth, NextChildren.begin(), [](FeatureEdge *Edge) { return Edge->targetNode(); }); int const Depth = positionRec(CurrentDepth + 1, NextChildren, NextOffset); - int Width = Node->childrenWidth(); + int const Width = Node->childrenWidth(); Node->setPos(double(NextOffset) + Width / 2.0, 100 * CurrentDepth); NextOffset += Width; MaxDepth = MaxDepth < Depth ? Depth : MaxDepth; @@ -162,12 +162,11 @@ void FeatureModelGraph::zoomIn() { scaleView(qreal(1.2)); } void FeatureModelGraph::zoomOut() { scaleView(1 / qreal(1.2)); } FeatureNode *FeatureModelGraph::addNode(Feature *Feature, FeatureNode *Parent) { - auto NewNode = std::make_unique(Feature); - auto *NewEdge = new FeatureEdge(Parent, NewNode.get()); + auto *NewNode = new FeatureNode(Feature); + auto *NewEdge = new FeatureEdge(Parent, NewNode); scene()->addItem(NewEdge); - scene()->addItem(NewNode.get()); - auto *NewNodeRaw = NewNode.get(); - Nodes.push_back(std::move(NewNode)); + scene()->addItem(NewNode); + Nodes.push_back(NewNode); auto NextChildren = std::vector(EntryNode->children().size()); auto CurrentChildren = EntryNode->children(); std::transform(CurrentChildren.begin(), CurrentChildren.end(), @@ -176,7 +175,7 @@ FeatureNode *FeatureModelGraph::addNode(Feature *Feature, FeatureNode *Parent) { positionRec(1, NextChildren, 5); EntryNode->setPos(EntryNode->childrenWidth() / 2.0, 10); - return NewNodeRaw; + return NewNode; } FeatureNode *FeatureModelGraph::getNode(std::string Name) { @@ -184,7 +183,7 @@ FeatureNode *FeatureModelGraph::getNode(std::string Name) { return Node->getName() == Name; }); if (It != Nodes.end()) { - return It->get(); + return *It; } return nullptr; @@ -208,7 +207,7 @@ void FeatureModelGraph::deleteNode(bool Recursive, FeatureNode *Node) { scene()->removeItem(Node->parent()); Nodes.erase(std::find_if(Nodes.begin(), Nodes.end(), - [Node](auto &N) { return N.get() == Node; })); + [Node](auto &N) { return N == Node; })); } void FeatureModelGraph::deleteNode(bool Recursive, diff --git a/tools/fm-editor/graph/FeatureModelGraph.h b/tools/fm-editor/graph/FeatureModelGraph.h index 29c44799e..b36bb2a45 100644 --- a/tools/fm-editor/graph/FeatureModelGraph.h +++ b/tools/fm-editor/graph/FeatureModelGraph.h @@ -41,7 +41,7 @@ public slots: int positionRec(int CurrentDepth, const std::vector &Children, unsigned long Offset); vara::feature::FeatureModel *FeatureModel; - std::vector> Nodes; + std::vector Nodes; std::unique_ptr Scene; }; From 4e510e7d341f5d1da088b2b74564be4db91cb912 Mon Sep 17 00:00:00 2001 From: Nerum Date: Mon, 30 Oct 2023 15:44:55 +0100 Subject: [PATCH 094/106] update tree view when adding features --- tools/fm-editor/tree/FeatureTreeViewModel.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/fm-editor/tree/FeatureTreeViewModel.cpp b/tools/fm-editor/tree/FeatureTreeViewModel.cpp index 48feccb93..aeee9e6e3 100644 --- a/tools/fm-editor/tree/FeatureTreeViewModel.cpp +++ b/tools/fm-editor/tree/FeatureTreeViewModel.cpp @@ -119,10 +119,12 @@ FeatureTreeViewModel::addFeature(vara::feature::Feature *Feature, std::string Parent) { auto *Item = getItem(std::move(Parent)); if (Item) { + emit(layoutAboutToBeChanged()); auto NewItem = FeatureTreeItem::createFeatureTreeItem(Feature); Item->addChild(NewItem.get()); auto *NewItemRaw = NewItem.get(); Items.push_back(std::move(NewItem)); + emit(layoutChanged()); return NewItemRaw; } From 6e5614ce01b6815972030e6bdd5707984c8672ee Mon Sep 17 00:00:00 2001 From: Simon Friedel Date: Mon, 20 Nov 2023 12:44:55 +0100 Subject: [PATCH 095/106] Fix clang-tidy exclusion of generated files --- tools/fm-editor/CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/fm-editor/CMakeLists.txt b/tools/fm-editor/CMakeLists.txt index 23921deda..2988f53e7 100644 --- a/tools/fm-editor/CMakeLists.txt +++ b/tools/fm-editor/CMakeLists.txt @@ -55,8 +55,7 @@ add_custom_target( file( WRITE "${CMAKE_CURRENT_BINARY_DIR}/fm-editor_autogen/.clang-tidy" " - --- - Checks: '-*,llvm-twine-local' +Checks: '-*,llvm-twine-local' ... " ) From 1c016ad1ae8cd2f600871b5bb5baa437e6ba7ff3 Mon Sep 17 00:00:00 2001 From: Simon Friedel Date: Mon, 20 Nov 2023 12:45:07 +0100 Subject: [PATCH 096/106] Fix clang warnings --- tools/fm-editor/tree/FeatureTreeItem.h | 2 +- tools/fm-editor/tree/FeatureTreeViewModel.h | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/fm-editor/tree/FeatureTreeItem.h b/tools/fm-editor/tree/FeatureTreeItem.h index b661eb6b0..182060da1 100644 --- a/tools/fm-editor/tree/FeatureTreeItem.h +++ b/tools/fm-editor/tree/FeatureTreeItem.h @@ -16,7 +16,7 @@ class FeatureTreeItem : public QObject { Q_OBJECT public: - FeatureTreeItem *child(int Row) { + FeatureTreeItem *child(size_t Row) { if (Row < 0 || Row > Children.size()) { return nullptr; diff --git a/tools/fm-editor/tree/FeatureTreeViewModel.h b/tools/fm-editor/tree/FeatureTreeViewModel.h index 195c2783f..a60bbc1e5 100644 --- a/tools/fm-editor/tree/FeatureTreeViewModel.h +++ b/tools/fm-editor/tree/FeatureTreeViewModel.h @@ -9,7 +9,7 @@ class FeatureTreeViewModel : public QAbstractItemModel { public: FeatureTreeViewModel(vara::feature::FeatureModel *Model, QObject *Parent) - : QAbstractItemModel(Parent), Model(Model) { + : QAbstractItemModel(Parent) { auto UniqueRoot = FeatureTreeItem::createFeatureTreeItem(Model->getRoot()); RootItem = UniqueRoot.get(); Items.push_back(std::move(UniqueRoot)); @@ -67,8 +67,6 @@ class FeatureTreeViewModel : public QAbstractItemModel { buildRecursive(RawChild); } } - - vara::feature::FeatureModel *Model; FeatureTreeItem *RootItem; std::vector> Items; }; From 90ff5a834138c9473b06520a0ab41308af039ee1 Mon Sep 17 00:00:00 2001 From: Simon Friedel Date: Mon, 20 Nov 2023 13:07:45 +0100 Subject: [PATCH 097/106] Show root feature in treeview --- tools/fm-editor/tree/FeatureTreeViewModel.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/fm-editor/tree/FeatureTreeViewModel.h b/tools/fm-editor/tree/FeatureTreeViewModel.h index a60bbc1e5..7277f20bf 100644 --- a/tools/fm-editor/tree/FeatureTreeViewModel.h +++ b/tools/fm-editor/tree/FeatureTreeViewModel.h @@ -11,11 +11,15 @@ class FeatureTreeViewModel : public QAbstractItemModel { FeatureTreeViewModel(vara::feature::FeatureModel *Model, QObject *Parent) : QAbstractItemModel(Parent) { auto UniqueRoot = FeatureTreeItem::createFeatureTreeItem(Model->getRoot()); - RootItem = UniqueRoot.get(); + RootItem = new FeatureTreeItemFeature(nullptr); + RootItem->addChild(UniqueRoot.get()); + auto RawRoot = UniqueRoot.get(); Items.push_back(std::move(UniqueRoot)); - buildRecursive(RootItem); + buildRecursive(RawRoot); } - ~FeatureTreeViewModel() override { std::destroy(Items.begin(), Items.end()); } + ~FeatureTreeViewModel() override { + delete RootItem; + std::destroy(Items.begin(), Items.end()); } std::vector> *getItems(); [[nodiscard]] QVariant data(const QModelIndex &Index, From bfc46bcb070ac5dc97d64a03ddbe381eeb7ef403 Mon Sep 17 00:00:00 2001 From: Simon Friedel Date: Mon, 20 Nov 2023 13:14:47 +0100 Subject: [PATCH 098/106] Fix format --- tools/fm-editor/tree/FeatureTreeViewModel.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/fm-editor/tree/FeatureTreeViewModel.h b/tools/fm-editor/tree/FeatureTreeViewModel.h index 7277f20bf..a6071f3d7 100644 --- a/tools/fm-editor/tree/FeatureTreeViewModel.h +++ b/tools/fm-editor/tree/FeatureTreeViewModel.h @@ -19,7 +19,8 @@ class FeatureTreeViewModel : public QAbstractItemModel { } ~FeatureTreeViewModel() override { delete RootItem; - std::destroy(Items.begin(), Items.end()); } + std::destroy(Items.begin(), Items.end()); + } std::vector> *getItems(); [[nodiscard]] QVariant data(const QModelIndex &Index, From 8a2a93d860036ee228072cd3e5af6a06225202df Mon Sep 17 00:00:00 2001 From: Simon Friedel Date: Tue, 21 Nov 2023 14:55:17 +0100 Subject: [PATCH 099/106] dont display data fro empty Feature Tree Item --- tools/fm-editor/tree/FeatureTreeItem.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/fm-editor/tree/FeatureTreeItem.cpp b/tools/fm-editor/tree/FeatureTreeItem.cpp index e23c2b40b..3c8e74320 100644 --- a/tools/fm-editor/tree/FeatureTreeItem.cpp +++ b/tools/fm-editor/tree/FeatureTreeItem.cpp @@ -81,6 +81,9 @@ std::vector FeatureTreeItem::getChildrenRecursive() { } QVariant FeatureTreeItemFeature::data(int Column) const { + if (Item == nullptr) { + return {}; + } switch (Column) { case 0: return QString::fromStdString(Item->getName().str()); From 6190334bead1f92418c6627404066ddd42fd56a5 Mon Sep 17 00:00:00 2001 From: Simon Friedel Date: Tue, 21 Nov 2023 15:41:45 +0100 Subject: [PATCH 100/106] fix clang tidy errors --- tools/fm-editor/CMakeLists.txt | 3 +-- tools/fm-editor/graph/FeatureNode.cpp | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/fm-editor/CMakeLists.txt b/tools/fm-editor/CMakeLists.txt index 2988f53e7..129139824 100644 --- a/tools/fm-editor/CMakeLists.txt +++ b/tools/fm-editor/CMakeLists.txt @@ -54,8 +54,7 @@ add_custom_target( file( WRITE "${CMAKE_CURRENT_BINARY_DIR}/fm-editor_autogen/.clang-tidy" - " -Checks: '-*,llvm-twine-local' + "Checks: '-*,llvm-twine-local' ... " ) diff --git a/tools/fm-editor/graph/FeatureNode.cpp b/tools/fm-editor/graph/FeatureNode.cpp index 43f085380..8a8db6590 100644 --- a/tools/fm-editor/graph/FeatureNode.cpp +++ b/tools/fm-editor/graph/FeatureNode.cpp @@ -107,14 +107,14 @@ void FeatureNode::contextMenuEvent(QGraphicsSceneContextMenuEvent *Event) { void FeatureNode::inspect() { emit(inspectSource(Feature)); } int FeatureNode::width() const { - const QFontMetrics fm((QFont())); + const QFontMetrics Fm((QFont())); - return fm.boundingRect(getQName()).width(); + return Fm.boundingRect(getQName()).width(); } int FeatureNode::childrenWidth() const { if (ChildEdges.empty()) { - return width() + 1.5 * widthAdjust; + return width() + int(1.5 * widthAdjust); } int Result = 0; From 2c6c4759102195d89b2bb57a174a6866408a1684 Mon Sep 17 00:00:00 2001 From: Simon Friedel Date: Tue, 5 Dec 2023 10:05:01 +0100 Subject: [PATCH 101/106] fix clang tidy errors --- tools/fm-editor/CMakeLists.txt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/fm-editor/CMakeLists.txt b/tools/fm-editor/CMakeLists.txt index 129139824..1a8b5d1a9 100644 --- a/tools/fm-editor/CMakeLists.txt +++ b/tools/fm-editor/CMakeLists.txt @@ -52,9 +52,7 @@ add_custom_target( WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../unittests/resources ) -file( - WRITE "${CMAKE_CURRENT_BINARY_DIR}/fm-editor_autogen/.clang-tidy" - "Checks: '-*,llvm-twine-local' - ... +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/fm-editor_autogen/.clang-tidy" + "Checks: '-*,llvm-twine-local' " ) From 7c19b0cd19aea53b987339e35b0c7b52e2a9990d Mon Sep 17 00:00:00 2001 From: Simon Friedel Date: Tue, 5 Dec 2023 10:09:50 +0100 Subject: [PATCH 102/106] move item null check in FeatureTreeItem --- tools/fm-editor/tree/FeatureTreeItem.cpp | 32 ++++++++++++------------ 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tools/fm-editor/tree/FeatureTreeItem.cpp b/tools/fm-editor/tree/FeatureTreeItem.cpp index 3c8e74320..f0be10b07 100644 --- a/tools/fm-editor/tree/FeatureTreeItem.cpp +++ b/tools/fm-editor/tree/FeatureTreeItem.cpp @@ -81,23 +81,23 @@ std::vector FeatureTreeItem::getChildrenRecursive() { } QVariant FeatureTreeItemFeature::data(int Column) const { - if (Item == nullptr) { - return {}; - } - switch (Column) { - case 0: - return QString::fromStdString(Item->getName().str()); - case 1: - return Item->isOptional() ? QVariant("✓") : QVariant("x"); - case 2: - return numericValue(Item); - case 3: - return locationString(Item); - case 4: - return QString::fromStdString(Item->getOutputString().str()); - default: - return {}; + if (Item != nullptr) { + switch (Column) { + case 0: + return QString::fromStdString(Item->getName().str()); + case 1: + return Item->isOptional() ? QVariant("✓") : QVariant("x"); + case 2: + return numericValue(Item); + case 3: + return locationString(Item); + case 4: + return QString::fromStdString(Item->getOutputString().str()); + default: + return {}; + } } + return {}; } void FeatureTreeItemFeature::inspect() { emit(inspectSource(Item)); } From 1913c349e8ecaebd0548e24d9ac824781dfeebb7 Mon Sep 17 00:00:00 2001 From: Simon Friedel Date: Tue, 5 Dec 2023 12:08:22 +0100 Subject: [PATCH 103/106] Add extra abstraction for "ghost" root item in treeview --- tools/fm-editor/FeatureModelEditor.cpp | 3 +- tools/fm-editor/tree/FeatureTreeItem.cpp | 4 +- tools/fm-editor/tree/FeatureTreeItem.h | 56 ++++++++++++++------- tools/fm-editor/tree/FeatureTreeViewModel.h | 2 +- 4 files changed, 40 insertions(+), 25 deletions(-) diff --git a/tools/fm-editor/FeatureModelEditor.cpp b/tools/fm-editor/FeatureModelEditor.cpp index bbbe5a840..6597b87fd 100644 --- a/tools/fm-editor/FeatureModelEditor.cpp +++ b/tools/fm-editor/FeatureModelEditor.cpp @@ -55,8 +55,7 @@ void FeatureModelEditor::loadFeatureFromSelection( if (Index.isValid()) { auto *Item = static_cast(Index.internalPointer()) ->child(Index.row()); - if (Item->getKind() == - vara::feature::FeatureTreeNode::NodeKind::NK_FEATURE) { + if (Item->getKind() == ItemKind::IK_Feature) { loadFeature(dynamic_cast(Item)->getFeature()); } } diff --git a/tools/fm-editor/tree/FeatureTreeItem.cpp b/tools/fm-editor/tree/FeatureTreeItem.cpp index f0be10b07..c3c0cc592 100644 --- a/tools/fm-editor/tree/FeatureTreeItem.cpp +++ b/tools/fm-editor/tree/FeatureTreeItem.cpp @@ -60,9 +60,7 @@ FeatureTreeItem::createFeatureTreeItem(vara::feature::FeatureTreeNode *Item) { } void FeatureTreeItem::addChild(FeatureTreeItem *Child) { - if (!Children.empty() && - Children[0]->getKind() == - vara::feature::FeatureTreeNode::NodeKind::NK_RELATIONSHIP) { + if (!Children.empty() && Children[0]->getKind() == ItemKind::IK_Relation) { Children[0]->addChild(Child); } else { Children.push_back(Child); diff --git a/tools/fm-editor/tree/FeatureTreeItem.h b/tools/fm-editor/tree/FeatureTreeItem.h index 182060da1..344e65c7c 100644 --- a/tools/fm-editor/tree/FeatureTreeItem.h +++ b/tools/fm-editor/tree/FeatureTreeItem.h @@ -12,6 +12,13 @@ #include +enum ItemKind { + IK_Feature, + IK_Relation, + IK_Root + +}; + class FeatureTreeItem : public QObject { Q_OBJECT @@ -48,10 +55,10 @@ class FeatureTreeItem : public QObject { [[nodiscard]] virtual QVariant data(int Column) const = 0; std::unique_ptr static createFeatureTreeItem( vara::feature::FeatureTreeNode *Item); - bool booleanColumn(int Column) { return false; } + bool booleanColumn(int Column) { return false; }; virtual void contextMenu(QPoint Pos) = 0; virtual vara::feature::FeatureTreeNode *getItem() const = 0; - vara::feature::FeatureTreeNode::NodeKind getKind() { return Kind; } + virtual ItemKind getKind() = 0; virtual string getName() { return ""; }; void setParent(FeatureTreeItem *ParentItem) { this->Parent = ParentItem; } @@ -61,14 +68,25 @@ class FeatureTreeItem : public QObject { void removeFeature(bool Recursive, vara::feature::Feature *Feature); protected: - FeatureTreeItem(vara::feature::FeatureTreeNode::NodeKind Kind) : Kind(Kind) {} + FeatureTreeItem() = default; FeatureTreeItem *Parent = nullptr; std::vector Children = {}; +}; -private: - const vara::feature::FeatureTreeNode::NodeKind Kind; +class FeatureTreeItemRoot : public FeatureTreeItem { + Q_OBJECT + +public: + FeatureTreeItemRoot(){}; + [[nodiscard]] int columnCount() const override { return 5; }; + [[nodiscard]] QVariant data(int Column) const override { return {}; }; + void contextMenu(QPoint Pos) override{}; + [[nodiscard]] vara::feature::FeatureTreeNode *getItem() const override { + return nullptr; + }; + ItemKind getKind() override { return IK_Root; }; }; class FeatureTreeItemFeature : public FeatureTreeItem { @@ -76,8 +94,7 @@ class FeatureTreeItemFeature : public FeatureTreeItem { public: FeatureTreeItemFeature(vara::feature::Feature *Item) - : FeatureTreeItem(vara::feature::FeatureTreeNode::NodeKind::NK_FEATURE), - Item(Item) { + : FeatureTreeItem(), Item(Item) { ContextMenu = std::make_unique(); ContextMenu->addAction("Inspect Sources", this, &FeatureTreeItemFeature::inspect); @@ -87,16 +104,20 @@ class FeatureTreeItemFeature : public FeatureTreeItem { connect(RemoveAction.get(), &QAction::triggered, this, &FeatureTreeItemFeature::remove, Qt::QueuedConnection); } - virtual ~FeatureTreeItemFeature() = default; + ~FeatureTreeItemFeature() override = default; [[nodiscard]] QVariant data(int Column) const override; [[nodiscard]] int columnCount() const override { return 5; } bool booleanColumn(int Column) { return Column == 1; } void contextMenu(QPoint Pos) override; - vara::feature::FeatureTreeNode *getItem() const override { return Item; } - const vara::feature::Feature *getFeature() const { return Item; } + [[nodiscard]] vara::feature::FeatureTreeNode *getItem() const override { + return Item; + } + [[nodiscard]] const vara::feature::Feature *getFeature() const { + return Item; + } string getName() override { return Item->getName().str(); } - + ItemKind getKind() override { return IK_Feature; } public slots: void inspect(); void addChild(); @@ -110,10 +131,7 @@ public slots: class FeatureTreeItemRelation : public FeatureTreeItem { public: - FeatureTreeItemRelation(vara::feature::Relationship *Item) - : FeatureTreeItem( - vara::feature::FeatureTreeNode::NodeKind::NK_RELATIONSHIP), - Item(Item) {} + FeatureTreeItemRelation(vara::feature::Relationship *Item) : Item(Item){}; ~FeatureTreeItemRelation() override = default; [[nodiscard]] QVariant data(int Column) const override { @@ -124,13 +142,13 @@ class FeatureTreeItemRelation : public FeatureTreeItem { } [[nodiscard]] int columnCount() const override { return 1; } void contextMenu(QPoint Pos) override {} - vara::feature::FeatureTreeNode *getItem() const override { return Item; } + [[nodiscard]] vara::feature::FeatureTreeNode *getItem() const override { + return Item; + } + ItemKind getKind() override { return IK_Relation; } private: vara::feature::Relationship *Item; - static const vara::feature::FeatureTreeNode::NodeKind Kind = - vara::feature::FeatureTreeNode::NodeKind::NK_RELATIONSHIP; - [[nodiscard]] std::string relationType() const { std::string Type; switch (Item->getKind()) { diff --git a/tools/fm-editor/tree/FeatureTreeViewModel.h b/tools/fm-editor/tree/FeatureTreeViewModel.h index a6071f3d7..00ae1acc3 100644 --- a/tools/fm-editor/tree/FeatureTreeViewModel.h +++ b/tools/fm-editor/tree/FeatureTreeViewModel.h @@ -11,7 +11,7 @@ class FeatureTreeViewModel : public QAbstractItemModel { FeatureTreeViewModel(vara::feature::FeatureModel *Model, QObject *Parent) : QAbstractItemModel(Parent) { auto UniqueRoot = FeatureTreeItem::createFeatureTreeItem(Model->getRoot()); - RootItem = new FeatureTreeItemFeature(nullptr); + RootItem = new FeatureTreeItemRoot(); RootItem->addChild(UniqueRoot.get()); auto RawRoot = UniqueRoot.get(); Items.push_back(std::move(UniqueRoot)); From dfad1c1a5579688006c0ac5109e3a586596ce456 Mon Sep 17 00:00:00 2001 From: Simon Friedel Date: Tue, 5 Dec 2023 12:44:06 +0100 Subject: [PATCH 104/106] check nullability after cast to numeric feature --- tools/fm-editor/tree/FeatureTreeItem.cpp | 65 ++++++++++++------------ 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/tools/fm-editor/tree/FeatureTreeItem.cpp b/tools/fm-editor/tree/FeatureTreeItem.cpp index c3c0cc592..792fb5f9e 100644 --- a/tools/fm-editor/tree/FeatureTreeItem.cpp +++ b/tools/fm-editor/tree/FeatureTreeItem.cpp @@ -7,26 +7,28 @@ QVariant numericValue(vara::feature::Feature *Item) { if (Item->getKind() == vara::feature::Feature::FeatureKind::FK_NUMERIC) { auto *NumItem = llvm::dyn_cast(Item); - string Result = "["; - if (std::holds_alternative( - NumItem->getValues())) { - auto Range = std::get( - NumItem->getValues()); - Result += std::to_string(Range.first) + ", " + - std::to_string(Range.second) + "]"; - } else { - auto Range = std::get( - NumItem->getValues()); - for (auto It = Range.begin(); It != Range.end(); It++) { - if (It != Range.begin()) { - Result += ","; + if (NumItem != nullptr) { + string Result = "["; + if (std::holds_alternative( + NumItem->getValues())) { + auto Range = std::get( + NumItem->getValues()); + Result += std::to_string(Range.first) + ", " + + std::to_string(Range.second) + "]"; + } else { + auto Range = std::get( + NumItem->getValues()); + for (auto It = Range.begin(); It != Range.end(); It++) { + if (It != Range.begin()) { + Result += ","; + } + Result += std::to_string(*It.base()); } - Result += std::to_string(*It.base()); + Result += "]"; } - Result += "]"; - } - return QString::fromStdString(Result); + return QString::fromStdString(Result); + } } return {}; @@ -79,23 +81,20 @@ std::vector FeatureTreeItem::getChildrenRecursive() { } QVariant FeatureTreeItemFeature::data(int Column) const { - if (Item != nullptr) { - switch (Column) { - case 0: - return QString::fromStdString(Item->getName().str()); - case 1: - return Item->isOptional() ? QVariant("✓") : QVariant("x"); - case 2: - return numericValue(Item); - case 3: - return locationString(Item); - case 4: - return QString::fromStdString(Item->getOutputString().str()); - default: - return {}; - } + switch (Column) { + case 0: + return QString::fromStdString(Item->getName().str()); + case 1: + return Item->isOptional() ? QVariant("✓") : QVariant("x"); + case 2: + return numericValue(Item); + case 3: + return locationString(Item); + case 4: + return QString::fromStdString(Item->getOutputString().str()); + default: + return {}; } - return {}; } void FeatureTreeItemFeature::inspect() { emit(inspectSource(Item)); } From a3ea75716fd2832de9da784d3b3be2334d74b0d5 Mon Sep 17 00:00:00 2001 From: Nerum Date: Fri, 17 Nov 2023 10:05:21 +0100 Subject: [PATCH 105/106] add context menu functionality to newly added features --- tools/fm-editor/FeatureModelEditor.cpp | 16 ++++++---------- tools/fm-editor/tree/FeatureTreeItem.h | 4 +--- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/tools/fm-editor/FeatureModelEditor.cpp b/tools/fm-editor/FeatureModelEditor.cpp index 6597b87fd..f7ef5b2f1 100644 --- a/tools/fm-editor/FeatureModelEditor.cpp +++ b/tools/fm-editor/FeatureModelEditor.cpp @@ -163,6 +163,10 @@ void FeatureModelEditor::featureAddDialogChild(Feature *ParentFeature) { &FeatureModelEditor::loadFeature); connect(NewNode, &FeatureNode::inspectSource, this, &FeatureModelEditor::inspectFeatureSources); + connect(NewTreeItem, &FeatureTreeItem::addChildFeature, this, + &FeatureModelEditor::featureAddDialogChild); + connect(NewTreeItem, &FeatureTreeItem::removeFeature, this, + &FeatureModelEditor::removeFeature); auto Transaction = vara::feature::FeatureModelTransaction< vara::feature::detail::ModifyTransactionMode>:: openTransaction(*FeatureModel); @@ -346,17 +350,9 @@ void FeatureModelEditor::addSource() { LocationTransAction.commit(); markLocation(Range); } -void FeatureModelEditor::createNewModel() { - ModelPath = QFileDialog::getSaveFileName(this, tr("Save File"), ".", - tr("XML files (*.xml)")); - if (ModelPath.isEmpty()) { - return; - } - - FeatureModel = std::make_unique( - "FeatureModel", std::make_unique("root"), - fs::path(ModelPath.toStdString())); +void FeatureModelEditor::createNewModel() { + FeatureModel = std::make_unique(); // create Graph view buildGraph(); diff --git a/tools/fm-editor/tree/FeatureTreeItem.h b/tools/fm-editor/tree/FeatureTreeItem.h index 344e65c7c..e94909313 100644 --- a/tools/fm-editor/tree/FeatureTreeItem.h +++ b/tools/fm-editor/tree/FeatureTreeItem.h @@ -100,9 +100,7 @@ class FeatureTreeItemFeature : public FeatureTreeItem { &FeatureTreeItemFeature::inspect); ContextMenu->addAction("Add Child", this, &FeatureTreeItemFeature::addChild); - RemoveAction = std::make_unique("Remove"); - connect(RemoveAction.get(), &QAction::triggered, this, - &FeatureTreeItemFeature::remove, Qt::QueuedConnection); + ContextMenu->addAction("Delete", this, &FeatureTreeItemFeature::remove); } ~FeatureTreeItemFeature() override = default; From 7fcc47b970dc7dd9385c40dfc7dd8190f40e30e5 Mon Sep 17 00:00:00 2001 From: Nerum Date: Tue, 5 Mar 2024 11:40:36 +0100 Subject: [PATCH 106/106] fix repository selection --- tools/fm-editor/FeatureModelEditor.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/fm-editor/FeatureModelEditor.cpp b/tools/fm-editor/FeatureModelEditor.cpp index f7ef5b2f1..8aff92af5 100644 --- a/tools/fm-editor/FeatureModelEditor.cpp +++ b/tools/fm-editor/FeatureModelEditor.cpp @@ -216,7 +216,9 @@ void FeatureModelEditor::inspectFeatureSources( vara::feature::Feature *Feature) { CurrentFeature = Feature; if (Repository.isEmpty()) { - Repository = QFileDialog::getExistingDirectory(); + Repository = QFileDialog::getExistingDirectory( + this, tr("Select Repository"), + QString::fromStdString(std::filesystem::current_path().string())); } Ui->sources->clear(); QSet Locations = {};