Commit ed33f17f authored by Friedrich W. H. Kossebau's avatar Friedrich W. H. Kossebau
Browse files

kdevplatform/language/interfaces: use Q_DECLARE_PRIVATE/Q_D to forward constness to d

parent 95d32c7e
......@@ -52,7 +52,7 @@ public:
DUContextContext::DUContextContext(const IndexedDUContext& item)
: Context()
, d(new DUContextContextPrivate(item))
, d_ptr(new DUContextContextPrivate(item))
{}
DUContextContext::~DUContextContext() = default;
......@@ -64,6 +64,8 @@ int DUContextContext::type() const
QList<QUrl> DUContextContext::urls() const
{
Q_D(const DUContextContext);
DUChainReadLocker lock;
if (auto context = d->m_item.context()) {
return {
......@@ -75,10 +77,14 @@ QList<QUrl> DUContextContext::urls() const
IndexedDUContext DUContextContext::context() const
{
Q_D(const DUContextContext);
return d->m_item;
}
void DUContextContext::setContext(IndexedDUContext context)
{
Q_D(DUContextContext);
d->m_item = context;
}
......@@ -97,7 +103,7 @@ public:
DeclarationContext::DeclarationContext(const IndexedDeclaration& declaration, const DocumentRange& use,
const IndexedDUContext& context)
: DUContextContext(context)
, d(new DeclarationContextPrivate(declaration, use))
, d_ptr(new DeclarationContextPrivate(declaration, use))
{}
DeclarationContext::DeclarationContext(KTextEditor::View* view, const KTextEditor::Cursor& position) : DUContextContext(
......@@ -112,7 +118,7 @@ DeclarationContext::DeclarationContext(KTextEditor::View* view, const KTextEdito
if (declaration) {
indexed = IndexedDeclaration(declaration);
}
d.reset(new DeclarationContextPrivate(declaration, useRange));
d_ptr.reset(new DeclarationContextPrivate(declaration, useRange));
setContext(IndexedDUContext(item.context));
}
......@@ -125,11 +131,15 @@ int DeclarationContext::type() const
IndexedDeclaration DeclarationContext::declaration() const
{
Q_D(const DeclarationContext);
return d->m_declaration;
}
DocumentRange DeclarationContext::use() const
{
Q_D(const DeclarationContext);
return d->m_use;
}
}
......@@ -66,7 +66,8 @@ protected:
void setContext(IndexedDUContext context);
private:
const QScopedPointer<class DUContextContextPrivate> d;
const QScopedPointer<class DUContextContextPrivate> d_ptr;
Q_DECLARE_PRIVATE(DUContextContext)
Q_DISABLE_COPY(DUContextContext)
};
......@@ -105,7 +106,8 @@ public:
private:
// TODO: fix constructor and make const
QScopedPointer<class DeclarationContextPrivate> d;
QScopedPointer<class DeclarationContextPrivate> d_ptr;
Q_DECLARE_PRIVATE(DeclarationContext)
Q_DISABLE_COPY(DeclarationContext)
};
......
......@@ -53,7 +53,7 @@ public:
EditorContext::EditorContext(KTextEditor::View* view, const KTextEditor::Cursor& position)
: DeclarationContext(view, position)
, d(new EditorContextPrivate(view, position))
, d_ptr(new EditorContextPrivate(view, position))
{}
EditorContext::~EditorContext() = default;
......@@ -65,11 +65,15 @@ int EditorContext::type() const
QUrl EditorContext::url() const
{
Q_D(const EditorContext);
return d->m_url;
}
QList<QUrl> EditorContext::urls() const
{
Q_D(const EditorContext);
return {
d->m_url
};
......@@ -77,21 +81,29 @@ QList<QUrl> EditorContext::urls() const
KTextEditor::Cursor EditorContext::position() const
{
Q_D(const EditorContext);
return d->m_position;
}
QString EditorContext::currentLine() const
{
Q_D(const EditorContext);
return d->m_currentLine;
}
QString EditorContext::currentWord() const
{
Q_D(const EditorContext);
return d->m_currentWord;
}
KTextEditor::View* EditorContext::view() const
{
Q_D(const EditorContext);
return d->m_view;
}
}
......@@ -32,6 +32,8 @@ class Cursor;
class QUrl;
namespace KDevelop {
class EditorContextPrivate;
/**A context for the KTextEditor.*/
class KDEVPLATFORMLANGUAGE_EXPORT EditorContext
: public DeclarationContext
......@@ -73,7 +75,8 @@ public:
KTextEditor::View* view() const;
private:
const QScopedPointer<class EditorContextPrivate> d;
const QScopedPointer<class EditorContextPrivate> d_ptr;
Q_DECLARE_PRIVATE(EditorContext)
};
}
......
......@@ -31,7 +31,7 @@ public:
};
ILanguageSupport::ILanguageSupport()
: d(new ILanguageSupportPrivate)
: d_ptr(new ILanguageSupportPrivate)
{
}
......@@ -97,6 +97,8 @@ QString ILanguageSupport::indentationSample() const
QReadWriteLock* ILanguageSupport::parseLock() const
{
Q_D(const ILanguageSupport);
return &d->lock;
}
......
......@@ -43,6 +43,7 @@ class ParseJob;
class TopDUContext;
class ICodeHighlighting;
class ICreateClassHelper;
class ILanguageSupportPrivate;
class KDEVPLATFORMLANGUAGE_EXPORT ILanguageSupport
{
......@@ -163,7 +164,8 @@ public:
const QString& changedText, bool removal) const;
private:
const QScopedPointer<class ILanguageSupportPrivate> d;
const QScopedPointer<class ILanguageSupportPrivate> d_ptr;
Q_DECLARE_PRIVATE(ILanguageSupport)
};
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment