File indexing completed on 2024-05-12 04:38:07
0001 /* 0002 SPDX-FileCopyrightText: 2008 David Nolden <david.nolden.kdevelop@art-master.de> 0003 SPDX-FileCopyrightText: 2014 Kevin Funk <kfunk@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #include "ilanguagesupport.h" 0009 #include "../duchain/duchain.h" 0010 #include "../duchain/stringhelpers.h" 0011 0012 #include <QReadWriteLock> 0013 0014 namespace KDevelop { 0015 class ILanguageSupportPrivate 0016 { 0017 public: 0018 mutable QReadWriteLock lock; 0019 }; 0020 0021 ILanguageSupport::ILanguageSupport() 0022 : d_ptr(new ILanguageSupportPrivate) 0023 { 0024 } 0025 0026 ILanguageSupport::~ILanguageSupport() 0027 { 0028 } 0029 0030 TopDUContext* ILanguageSupport::standardContext(const QUrl& url, bool proxyContext) 0031 { 0032 Q_UNUSED(proxyContext) 0033 return DUChain::self()->chainForDocument(url); 0034 } 0035 0036 KTextEditor::Range ILanguageSupport::specialLanguageObjectRange(const QUrl& url, const KTextEditor::Cursor& position) 0037 { 0038 Q_UNUSED(url) 0039 Q_UNUSED(position) 0040 return KTextEditor::Range::invalid(); 0041 } 0042 0043 QPair<QUrl, KTextEditor::Cursor> ILanguageSupport::specialLanguageObjectJumpCursor(const QUrl& url, 0044 const KTextEditor::Cursor& position) 0045 { 0046 Q_UNUSED(url) 0047 Q_UNUSED(position) 0048 return QPair<QUrl, KTextEditor::Cursor>(QUrl(), KTextEditor::Cursor::invalid()); 0049 } 0050 0051 QPair<QWidget*, KTextEditor::Range> ILanguageSupport::specialLanguageObjectNavigationWidget(const QUrl& url, 0052 const KTextEditor::Cursor& position) 0053 { 0054 Q_UNUSED(url) 0055 Q_UNUSED(position) 0056 return { 0057 nullptr, KTextEditor::Range::invalid() 0058 }; 0059 } 0060 0061 ICodeHighlighting* ILanguageSupport::codeHighlighting() const 0062 { 0063 return nullptr; 0064 } 0065 0066 BasicRefactoring* ILanguageSupport::refactoring() const 0067 { 0068 return nullptr; 0069 } 0070 0071 ICreateClassHelper* ILanguageSupport::createClassHelper() const 0072 { 0073 return nullptr; 0074 } 0075 0076 SourceFormatterItemList ILanguageSupport::sourceFormatterItems() const 0077 { 0078 return SourceFormatterItemList(); 0079 } 0080 0081 QString ILanguageSupport::indentationSample() const 0082 { 0083 return QString(); 0084 } 0085 0086 QReadWriteLock* ILanguageSupport::parseLock() const 0087 { 0088 Q_D(const ILanguageSupport); 0089 0090 return &d->lock; 0091 } 0092 0093 int ILanguageSupport::suggestedReparseDelayForChange(KTextEditor::Document* doc, 0094 const KTextEditor::Range& changedRange, 0095 const QString& /*removedText*/, bool /*removal*/) const 0096 { 0097 const auto joinedWord = [doc, &changedRange] { 0098 return doc->wordRangeAt(changedRange.start()).isEmpty() || doc->wordRangeAt(changedRange.end()).isEmpty(); 0099 }; 0100 return consistsOfWhitespace(doc->text(changedRange)) && !joinedWord() ? NoUpdateRequired : DefaultDelay; 0101 } 0102 }