blob: 71a5a01c29e765c5047e97d0d7d931fa106bd99d (
plain)
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
|
/*
SPDX-FileCopyrightText: 2016 Volker Krause <vkrause@kde.org>
SPDX-License-Identifier: MIT
*/
#include "contextswitch_p.h"
#include "definition.h"
#include "definition_p.h"
#include "highlightingdata_p.hpp"
#include "ksyntaxhighlighting_logging.h"
#include "repository.h"
using namespace KSyntaxHighlighting;
void ContextSwitch::resolve(DefinitionData &def, QStringView contextInstr)
{
HighlightingContextData::ContextSwitch ctx(contextInstr);
m_popCount = ctx.popCount();
m_isStay = !m_popCount;
auto contextName = ctx.contextName();
auto defName = ctx.defName();
if (contextName.isEmpty() && defName.isEmpty()) {
return;
}
if (defName.isEmpty()) {
m_context = def.contextByName(contextName);
} else {
auto d = def.repo->definitionForName(defName.toString());
if (d.isValid()) {
auto data = DefinitionData::get(d);
def.addImmediateIncludedDefinition(d);
data->load();
if (contextName.isEmpty()) {
m_context = data->initialContext();
} else {
m_context = data->contextByName(contextName);
}
}
}
if (!m_context) {
qCWarning(Log) << "cannot find context" << contextName << "in" << def.name;
} else {
m_isStay = false;
}
}
|