Parse the scope definition.
(self, language, loaded_modules)
| 297 | self.pattern = None |
| 298 | |
| 299 | def parse_scope_definition(self, language, loaded_modules): |
| 300 | """Parse the scope definition.""" |
| 301 | |
| 302 | scopes = {} |
| 303 | scope_count = 0 |
| 304 | for params in self.scope_rules: |
| 305 | if is_valid_definition(params, language): |
| 306 | try: |
| 307 | bh_plugin.load_modules(params, loaded_modules) |
| 308 | entry = ScopeDefinition(params) |
| 309 | if not entry.enabled: |
| 310 | log( |
| 311 | SCOPE_ERROR % ( |
| 312 | str(params.get('name', '?')), |
| 313 | "\\A" + params.get("open", ""), |
| 314 | params.get("close", "") + "\\Z" |
| 315 | ) |
| 316 | ) |
| 317 | continue |
| 318 | if not self.check_compare and entry.compare is not None: |
| 319 | self.check_compare = True |
| 320 | if not self.check_validate and entry.validate is not None: |
| 321 | self.check_validate = True |
| 322 | if not self.check_post_match and entry.post_match is not None: |
| 323 | self.check_post_match = True |
| 324 | if not self.highlighting and entry.highlighting is not None: |
| 325 | self.highlighting = True |
| 326 | for x in entry.scopes: |
| 327 | if x not in scopes: |
| 328 | scopes[x] = scope_count |
| 329 | scope_count += 1 |
| 330 | self.scopes.append({"name": x, "brackets": [entry]}) |
| 331 | else: |
| 332 | self.scopes[scopes[x]]["brackets"].append(entry) |
| 333 | debug( |
| 334 | "Scope Regex (%s)\n Opening: %s\n Closing: %s\n" % ( |
| 335 | entry.name, entry.open.pattern, entry.close.pattern |
| 336 | ) |
| 337 | ) |
| 338 | except Exception as e: |
| 339 | log(e) |
| 340 | |
| 341 | |
| 342 | #################### |
no test coverage detected