Changeset View
Changeset View
Standalone View
Standalone View
src/syntax/katehighlight.cpp
Show First 20 Lines • Show All 109 Lines • ▼ Show 20 Line(s) | 76 | { | |||
---|---|---|---|---|---|
110 | */ | 110 | */ | ||
111 | setDefinition(def); | 111 | setDefinition(def); | ||
112 | 112 | | |||
113 | /** | 113 | /** | ||
114 | * get all included definitions, e.g. PHP for HTML highlighting | 114 | * get all included definitions, e.g. PHP for HTML highlighting | ||
115 | */ | 115 | */ | ||
116 | auto definitions = definition().includedDefinitions(); | 116 | auto definitions = definition().includedDefinitions(); | ||
117 | 117 | | |||
118 | // it's possible to not have any defintions with malformed file | ||||
119 | if (definitions.isEmpty()) { | ||||
120 | m_properties.resize(1); | ||||
121 | m_propertiesForFormat.push_back(&m_properties[0]); | ||||
122 | m_formats.resize(1); | ||||
123 | m_formatsIdToIndex.insert(std::make_pair(m_formats[0].id(), 0)); | ||||
124 | return; | ||||
125 | } | ||||
126 | | ||||
118 | /** | 127 | /** | ||
119 | * first: handle only really included definitions | 128 | * first: handle only really included definitions | ||
120 | */ | 129 | */ | ||
121 | for (const auto &includedDefinition : definitions) | 130 | for (const auto &includedDefinition : definitions) | ||
122 | embeddedHighlightingModes.push_back(includedDefinition.name()); | 131 | embeddedHighlightingModes.push_back(includedDefinition.name()); | ||
123 | 132 | | |||
124 | /** | 133 | /** | ||
125 | * now: handle all, including this definition itself | 134 | * now: handle all, including this definition itself | ||
▲ Show 20 Lines • Show All 120 Lines • ▼ Show 20 Line(s) | 184 | { | |||
246 | } | 255 | } | ||
247 | 256 | | |||
248 | } | 257 | } | ||
249 | 258 | | |||
250 | void KateHighlighting::applyFormat(int offset, int length, const KSyntaxHighlighting::Format &format) | 259 | void KateHighlighting::applyFormat(int offset, int length, const KSyntaxHighlighting::Format &format) | ||
251 | { | 260 | { | ||
252 | // WE ATM assume ascending offset order | 261 | // WE ATM assume ascending offset order | ||
253 | Q_ASSERT(m_textLineToHighlight); | 262 | Q_ASSERT(m_textLineToHighlight); | ||
254 | Q_ASSERT(format.isValid()); | 263 | if (!format.isValid()) { | ||
264 | return; | ||||
265 | } | ||||
255 | 266 | | |||
256 | // get internal attribute, must exist | 267 | // get internal attribute, must exist | ||
257 | const auto it = m_formatsIdToIndex.find(format.id()); | 268 | const auto it = m_formatsIdToIndex.find(format.id()); | ||
258 | Q_ASSERT(it != m_formatsIdToIndex.end()); | 269 | Q_ASSERT(it != m_formatsIdToIndex.end()); | ||
259 | 270 | | |||
260 | // remember highlighting info in our textline | 271 | // remember highlighting info in our textline | ||
261 | m_textLineToHighlight->addAttribute(Kate::TextLineData::Attribute(offset, length, it->second)); | 272 | m_textLineToHighlight->addAttribute(Kate::TextLineData::Attribute(offset, length, it->second)); | ||
262 | } | 273 | } | ||
▲ Show 20 Lines • Show All 403 Lines • Show Last 20 Lines |