File indexing completed on 2024-05-05 16:46:47
0001 /* 0002 SPDX-FileCopyrightText: 2013 Milian Wolff <mail@milianw.de> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "qmljshighlighting.h" 0008 0009 #include <language/duchain/declaration.h> 0010 0011 using namespace KDevelop; 0012 0013 class HighlightingInstance : public KDevelop::CodeHighlightingInstance 0014 { 0015 public: 0016 explicit HighlightingInstance(const CodeHighlighting* highlighting) 0017 : CodeHighlightingInstance(highlighting) 0018 {} 0019 0020 bool useRainbowColor(Declaration* dec) const override 0021 { 0022 // JS has a function-based prototype OO system, so for now rainbow-color 0023 // everything that is not a function declaration. 0024 // In the future we will have to investigate how to handle properties 0025 // of a function/object 0026 return dec->kind() == Declaration::Instance && 0027 dec->context()->type() != DUContext::Class && 0028 dec->context()->type() != DUContext::Enum; 0029 } 0030 }; 0031 0032 QmlJsHighlighting::QmlJsHighlighting(QObject* parent) 0033 : CodeHighlighting(parent) 0034 { 0035 0036 } 0037 0038 CodeHighlightingInstance* QmlJsHighlighting::createInstance() const 0039 { 0040 return new HighlightingInstance(this); 0041 } 0042 0043 #include "moc_qmljshighlighting.cpp"