Contents |
Contributed colorization format
<!-- this example will show how the colorization used for a subset of CSS --> <colorizer xmlns="http://www.aptana.com/2007/colorizer/1.0" language="text/css"> <group name="default"> <!-- declare default token colorization for all categories --> <token type="*" category="literal" style="literal_default" /> <token type="*" category="whitespace" style="ws_default" /> <token type="*" category="keyword" style="literal_default" /> <token type="*" category="punctuator" style="punct_default" /> <token type="*" category="error" style="red_style" /> <!-- declare all keywords that start with '@' have different style for @ symbol --> <token type="*" category="keyword" > <subtoken type="at" style="at_style" /> </token> <!-- declare angle tokens have different styling for angle suffix (e.g deg,rad,grad) --> <token type="time" category="literal" > <subtoken type="time_suffix" style="time_style" /> </token> <!-- declare quoted string to have their first and last character (quotes) colored differently --> <token type="string" category="literal" > <region offset="0" length="1" style="quote" /> <region offset="-1" length="-1" style="quote" /> </token> <!-- style integers --> <token type="integer" category="literal" style="int_style" /> <!-- style floating point number with different styling for left of decimal, right of decimal, and decimal itself --> <token type="floating_point" category=literal" > <subtoken type="int" index="0" style="leftside_int" /> <subtoken type="point" style="punct_default" /> <sbutoken type="int" index="1" style="rightside_int" /> </token> <!-- declare styles used --> <style id="punct_default" foreground="rgb(0,255,0)" background="rgb(100,0,100)" <style id="ws_default" foreground="rgb(255,255,255)" background="rgb(255,255,255)" /> <style id="red_style" foreground="rgb(255,0,0)" background="rgb(255,255,255)" /> <style id="leftside_int" foreground="rgb(255,255,255)" background="rgb(0,0,255)" /> <style id="rightside_int" foreground="rgb(255,255,255)" background="rgb(0,255,0)" /> <style id="literal_default" foreground="rgb(100,200,100)" background="rgb(0,0,0)" /> <style id="quote" foreground="rgb(0,0,200)" background="rgb(200,200,0)" font-weight="bold" /> <style id="time_style" foreground="rgb(0,0,0)" background="rgb(255,0,255)" font-style="italic" /> <style id="at_style" foreground="rgb(0,0,255)" background="rgb(255,255,0)" font-weight="bold" /> </group> </colorizer>
This file would generate the following code colorization:
Common Colorization patterns
- Numbers
- Integer
- Floating point
- Strings
- Double-quoted
- Single-quoted
- Identifiers
- Keywords
- Punctuation
- Operators
- Arithmetic
- Assignment
- Comparison
- Boolean
- Punctuators
- Braces, Brackets, Parentheses
- Operators
- Comments
Matcher Documentation
File Format
- Elements and attributes are converted into objects and setter calls via reflection.
- Classes are located by iterating through a list of packages and optionally
applying suffixes to the class names.
- An element name is mapped to a class name by capitalizing the first character, then by removing all hyphens and capitalizing the letter following the hyphen.
- The converted name is appended to each package name
- If the name does not appear in the package, then the suffixes are concatenated to the name and searched for in each package.
- If no class is found, then a generic NodeBase object is created
- Attributes are mapped to setters on the instantiated object.
- The attribute name is mapped to a setter method by prepending "set", then capitalizing the first character, then removing all hyphens and capitalizing the letter following the hyphen.
- All setters that match the converted name and have one parameter are considered
- If a setter takes a string argument, that will be preferred over all other like-named setters
- If no setter takes a string argument, then an IConverter implementation is searched for to convert the attribute value to the setter's parameter type.
Elements
Note that all matcher elements may include an optional type and category attribute. Any matcher that contains these attributes will emit a token for the given category/type pair. The category value is inheritable which allows, for example, a category group element to define a category for all its descendent matchers while allowing each descendant matcher to define its own type. A matcher may override the inherited category value simply by defining its own category attribute.
In addition to the type and category attributes, matchers also include the name attribute. When the given element matches successfully, the matched text will be associated with the matcher's name. These name/value pairs are stored at the group level allowing all matchers to provide and consume names and values within their group. If two matchers define that same name attribute, then the last successfully matching matcher's value will overwrite any preceding values. Values may be referenced via the UseElement. This allows for matcher definitions to be redefined based on matches ocurring at runtime.