nl_tokens: Makes all possible selection ranges for specified CSS property
pl_tokens: function makePossibleRangesCSS ( property ) { // find all possible ranges, sorted by position and size var valueRange = property . valueRange ( true ) ; var result = [ property . range ( true ) , valueRange ] ; var stringStream = require ( 'stringStream' ) ; var cssEditTree = require ( 'cssEditTree' ) ; var range = require ( 'range' ) ; // locate parts of complex values. // some examples: // – 1px solid red: 3 parts // – arial, sans-serif: enumeration, 2 parts // – url(image.png): function value part var value = property . value ( ) ; _ . each ( property . valueParts ( ) , function ( r ) { // add absolute range var clone = r . clone ( ) ; result . push ( clone . shift ( valueRange . start ) ) ; /** @type StringStream */ var stream = stringStream . create ( r . substring ( value ) ) ; if ( stream . match ( / ^[\w\-]+\( / , true ) ) { // we have a function, find values in it. // but first add function contents stream . start = stream . pos ; stream . skipToPair ( '(' , ')' ) ; var fnBody = stream . current ( ) ; result . push ( range . <mask> ( clone . start + stream . start , fnBody ) ) ; // find parts _ . each ( cssEditTree . findParts ( fnBody ) , function ( part ) { result . push ( range . create ( clone . start + stream . start + part . start , part . substring ( fnBody ) ) ) ; } ) ; } } ) ; // optimize result: remove empty ranges and duplicates return _ . chain ( result ) . filter ( function ( item ) { return ! ! item . length ( ) ; } ) . uniq ( false , function ( item ) { return item . toString ( ) ; } ) . value ( ) ; }