diff --git a/duchain/contextbuilder.cpp b/duchain/contextbuilder.cpp index fbfebe9..004f44f 100644 --- a/duchain/contextbuilder.cpp +++ b/duchain/contextbuilder.cpp @@ -1,88 +1,88 @@ #include "contextbuilder.h" #include #include #include #include "rustducontext.h" #include "nodetraits.h" namespace Rust { RSVisitResult visitCallback(RSNode *node, RSNode *parent, void *data); -RangeInRevision ContextBuilder::editorFindSpellingRange(RustNode *node, const QString& identifier) +RangeInRevision ContextBuilder::editorFindSpellingRange(RustNode *node, const QString &identifier) { RSRange range = node_get_spelling_range(node->data()); KTextEditor::Range incorrectRange = KTextEditor::Range(range.start.line - 1, range.start.column, INT_MAX, INT_MAX); IDocument *document = ICore::self()->documentController() ->documentForUrl(topContext()->url().toUrl()); QVector ranges; if (document) { ranges = document->textDocument()->searchText(incorrectRange, identifier); } else { ranges = { KTextEditor::Range::invalid() }; } return RangeInRevision::castFromSimpleRange(ranges.first()); } void ContextBuilder::visitChildren(RustNode *node) { visit_children(node->data(), visitCallback, this); } void ContextBuilder::startVisiting(RustNode *node) { visitChildren(node); } void ContextBuilder::setContextOnNode(RustNode *node, KDevelop::DUContext *context) { node->setContext(context); } KDevelop::DUContext *ContextBuilder::contextFromNode(RustNode *node) { return node->getContext(); } KDevelop::RangeInRevision ContextBuilder::editorFindRange(RustNode *fromNode, RustNode *toNode) { RSRange fromRange = node_get_extent(fromNode->data()); RSRange toRange = node_get_extent(toNode->data()); return RangeInRevision(fromRange.start.line - 1, fromRange.start.column, toRange.end.line - 1, toRange.end.column); } KDevelop::QualifiedIdentifier ContextBuilder::identifierForNode(RustPath *node) { return QualifiedIdentifier(node->value); } KDevelop::DUContext *ContextBuilder::newContext(const KDevelop::RangeInRevision &range) { return new RustNormalDUContext(range, currentContext()); } KDevelop::TopDUContext *ContextBuilder::newTopContext(const KDevelop::RangeInRevision &range, KDevelop::ParsingEnvironmentFile *file) { if (!file) { file = new ParsingEnvironmentFile(document()); file->setLanguage(IndexedString("Rust")); } return new RustTopDUContext(document(), range, file); } RSVisitResult visitCallback(RSNode *node, RSNode *parent, void *data) { ContextBuilder *builder = static_cast(data); RustNode currentNode(node); RustNode parentNode(parent); return builder->visitNode(¤tNode, &parentNode); } } diff --git a/rusthighlighting.cpp b/rusthighlighting.cpp index 7e44fc8..ca55b25 100644 --- a/rusthighlighting.cpp +++ b/rusthighlighting.cpp @@ -1,34 +1,34 @@ #include "rusthighlighting.h" using namespace KDevelop; namespace Rust { class HighlightingInstance : public CodeHighlightingInstance { public: HighlightingInstance(const Highlighting *highlighting); ~HighlightingInstance() override; }; HighlightingInstance::HighlightingInstance(const Highlighting *highlighting) : CodeHighlightingInstance(highlighting) { } HighlightingInstance::~HighlightingInstance() { } -Highlighting::Highlighting(QObject* parent) +Highlighting::Highlighting(QObject *parent) : CodeHighlighting(parent) { } -CodeHighlightingInstance* Highlighting::createInstance() const +CodeHighlightingInstance *Highlighting::createInstance() const { return new HighlightingInstance(this); } } diff --git a/rustlanguagesupport.cpp b/rustlanguagesupport.cpp index 67fc166..547b2d8 100644 --- a/rustlanguagesupport.cpp +++ b/rustlanguagesupport.cpp @@ -1,62 +1,62 @@ #include "rustlanguagesupport.h" #include #include #include #include #include #include #include #include #include #include #include "rustparsejob.h" #include "codecompletion/completionmodel.h" K_PLUGIN_FACTORY_WITH_JSON(KDevRustSupportFactory, "kdevrustsupport.json", registerPlugin(); ) using namespace KDevelop; namespace Rust { -LanguageSupport::LanguageSupport(QObject *parent, const QVariantList& args) +LanguageSupport::LanguageSupport(QObject *parent, const QVariantList &args) : KDevelop::IPlugin(QStringLiteral("kdevrustsupport"), parent), KDevelop::ILanguageSupport(), m_highlighting(new Highlighting(this)) { Q_UNUSED(args); new CodeCompletion(this, new CompletionModel(this), name()); } LanguageSupport::~LanguageSupport() { parseLock()->lockForWrite(); parseLock()->unlock(); delete m_highlighting; } QString LanguageSupport::name() const { return "Rust Language Support"; } -KDevelop::ParseJob* LanguageSupport::createParseJob(const KDevelop::IndexedString &url) +KDevelop::ParseJob *LanguageSupport::createParseJob(const KDevelop::IndexedString &url) { return new ParseJob(url, this); } ICodeHighlighting *LanguageSupport::codeHighlighting() const { return m_highlighting; } } #include "rustlanguagesupport.moc" diff --git a/rustlanguagesupport.h b/rustlanguagesupport.h index 93f0c3f..ab3aae6 100644 --- a/rustlanguagesupport.h +++ b/rustlanguagesupport.h @@ -1,40 +1,40 @@ #ifndef KDEVRUSTLANGUAGESUPPORT_H #define KDEVRUSTLANGUAGESUPPORT_H #include #include #include #include #include #include #include "rusthighlighting.h" #include "duchain/astredux.h" namespace Rust { class LanguageSupport : public KDevelop::IPlugin , public KDevelop::ILanguageSupport { Q_OBJECT Q_INTERFACES( KDevelop::ILanguageSupport ) public: - LanguageSupport(QObject* parent, const QVariantList& args = QVariantList()); + LanguageSupport(QObject *parent, const QVariantList &args = QVariantList()); ~LanguageSupport() override; QString name() const override; - KDevelop::ParseJob* createParseJob(const KDevelop::IndexedString &url) override; + KDevelop::ParseJob *createParseJob(const KDevelop::IndexedString &url) override; KDevelop::ICodeHighlighting *codeHighlighting() const override; private: - Highlighting* m_highlighting; + Highlighting *m_highlighting; }; } #endif // KDEVRUSTLANGUAGESUPPORT_H