syntax_zone.js
Utility class for working with syntax zones. Additionally extends the Range class to provide shortcuts for working with syntax zones.
Exports
SyntaxZone (class)
- constructor(rangeOrIndex)
- Single argument. May be a Range, NSRange, a number representing an index in the text, or an existing SyntaxZone object.
Returns a SyntaxZone object
var SyntaxZone = require('syntax_zone').SyntaxZone;
var zone = new SyntaxZone(10);
- id
- String; textual identifier for this specific zone (e.g.
string.quoted.single.js
) - range
- Range object; the Range for the zone
- sxzone
- SXZone object; the Espresso SXZone object representing the zone. Mostly only used internally, but may be useful if you are using custom calls to the Espresso API via JSCocoa.
- text()
- Returns String; the text within the syntax zone
- parent()
- Returns SyntaxZone object or null if none; the parent zone for this zone
- childCount()
- Returns int; the number of child syntax zones within this one
- childAt(rangeOrIndex)
- Returns SyntaxZone object; the syntax zone child at the given index
- childrenMatching(targetSelectors, [maxDepth])
- Returns Array of SyntaxZone objects; the children of the zone matching the given selector string. To search for direct children only, set maxDepth to 1. The targetSelectors string may be a compound selector (e.g.
html string, js string
). - matches(targetSelectors)
- Returns bool; whether or not the syntax zone matches the given selector string. The targetSelectors string may be a compound selector.
- typeEquals(targetSelector)
- Returns bool; whether the type identifier of this syntax zone is the same as the one specified in targetSelector
- log()
- Void; shortcut method to log the syntax zone to the console
SyntaxZone.from(fromSyntaxZone)
Returns SyntaxZone object; converts fromSyntaxZone into a SyntaxZone (if necessary) and returns it.
New Range methods
- getZone()
- Returns SyntaxZone object; the deepest syntax zone for the range’s location index
- matchesZone(targetSelectors)
- Returns bool; shortcut to the SyntaxZone.matches() method