-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
phphighlighting.cpp
57 lines (44 loc) · 1.51 KB
/
phphighlighting.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
SPDX-FileCopyrightText: 2010 Milian Wolff
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "phphighlighting.h"
#include <language/duchain/declaration.h>
#include "duchain/declarations/variabledeclaration.h"
using namespace KDevelop;
using namespace Php;
//BEGIN HighlightingInstance
class HighlightingInstance : public CodeHighlightingInstance {
public:
HighlightingInstance(const CodeHighlighting* highlighting);
CodeHighlightingType typeForDeclaration(KDevelop::Declaration* decl, KDevelop::DUContext* context) const override;
bool useRainbowColor( Declaration* dec ) const override;
};
HighlightingInstance::HighlightingInstance(const CodeHighlighting* highlighting)
: CodeHighlightingInstance(highlighting)
{
}
CodeHighlightingType HighlightingInstance::typeForDeclaration(Declaration* decl, DUContext* context) const
{
if (decl && !decl->isFunctionDeclaration() && decl->abstractType()
&& decl->abstractType()->modifiers() & AbstractType::ConstModifier
&& !dynamic_cast<VariableDeclaration*>(decl) )
{
return CodeHighlightingType::Enum;
} else {
return CodeHighlightingInstance::typeForDeclaration(decl, context);
}
}
bool HighlightingInstance::useRainbowColor( Declaration* dec ) const
{
return dynamic_cast<VariableDeclaration*>(dec);
}
//BEGIN Highlighting
Highlighting::Highlighting(QObject* parent)
: CodeHighlighting(parent)
{
}
CodeHighlightingInstance* Highlighting::createInstance() const
{
return new HighlightingInstance(this);
}