src/language/CSSUtils.js
function getInfoAtPos(editor, constPos) {
        // We're going to be changing pos a lot, but we don't want to mess up
        // the pos the caller passed in so we use extend to make a safe copy of it.
        var pos = $.extend({}, constPos),
            ctx = TokenUtils.getInitialContext(editor._codeMirror, pos),
            mode = editor.getModeForSelection();

        // Check if this is inside a style block or in a css/less document.
        if (mode !== "css" && mode !== "text/x-scss" && mode !== "text/x-less") {
            return createInfo();
        }

        // Context from the current editor will have htmlState if we are in css mode
        // and in attribute value state of a tag with attribute name style
        if (ctx.token.state.htmlState && (!ctx.token.state.localMode || ctx.token.state.localMode.name !== "css")) {

            // tagInfo is required to aquire the style attr value
            var tagInfo = HTMLUtils.getTagInfo(editor, pos, true),
                // To be used as relative character position
                offset = tagInfo.position.offset;

            /**
             * We will use this CM to cook css context in case of style attribute value
             * as CM in htmlmixed mode doesn't yet identify this as css context. We provide
             * a no-op display function to run CM without a DOM head.
             */
            var _contextCM = new CodeMirror(function () {}, {
                value: "{" + tagInfo.attr.value.replace(/(^")|("$)/g, ""),
                mode:  "css"
            });

            ctx = TokenUtils.getInitialContext(_contextCM, {line: 0, ch: offset + 1});
        }
        
        if (_isInPropName(ctx)) {
            return _getPropNameInfo(ctx);
        }
        
        if (_isInPropValue(ctx)) {
            return _getRuleInfoStartingFromPropValue(ctx, ctx.editor);
        }
        
        if (_isInAtRule(ctx)) {
            return _getImportUrlInfo(ctx, editor);
        }

        return createInfo();
    }
function getInfoAtPos(editor, constPos) {
        // We're going to be changing pos a lot, but we don't want to mess up
        // the pos the caller passed in so we use extend to make a safe copy of it.
        var pos = $.extend({}, constPos),
            ctx = TokenUtils.getInitialContext(editor._codeMirror, pos),
            mode = editor.getModeForSelection();

        // Check if this is inside a style block or in a css/less document.
        if (mode !== "css" && mode !== "text/x-scss" && mode !== "text/x-less") {
            return createInfo();
        }

        // Context from the current editor will have htmlState if we are in css mode
        // and in attribute value state of a tag with attribute name style
        if (ctx.token.state.htmlState && (!ctx.token.state.localMode || ctx.token.state.localMode.name !== "css")) {

            // tagInfo is required to aquire the style attr value
            var tagInfo = HTMLUtils.getTagInfo(editor, pos, true),
                // To be used as relative character position
                offset = tagInfo.position.offset;

            /**
             * We will use this CM to cook css context in case of style attribute value
             * as CM in htmlmixed mode doesn't yet identify this as css context. We provide
             * a no-op display function to run CM without a DOM head.
             */
            var _contextCM = new CodeMirror(function () {}, {
                value: "{" + tagInfo.attr.value.replace(/(^")|("$)/g, ""),
                mode:  "css"
            });

            ctx = TokenUtils.getInitialContext(_contextCM, {line: 0, ch: offset + 1});
        }
        
        if (_isInPropName(ctx)) {
            return _getPropNameInfo(ctx);
        }
        
        if (_isInPropValue(ctx)) {
            return _getRuleInfoStartingFromPropValue(ctx, ctx.editor);
        }
        
        if (_isInAtRule(ctx)) {
            return _getImportUrlInfo(ctx, editor);
        }

        return createInfo();
    }
function getInfoAtPos ( editor , constPos ) { // We're going to be changing pos a lot, but we don't want to mess up // the pos the caller passed in so we use extend to make a safe copy of it. var pos = $ . extend ( { } , constPos ) , ctx = TokenUtils . getInitialContext ( editor . _codeMirror , pos ) , mode = editor . getModeForSelection ( ) ; // Check if this is inside a style block or in a css/less document. if ( mode !== "css" && mode !== "text/x-scss" && mode !== "text/x-less" ) { return createInfo ( ) ; } // Context from the current editor will have htmlState if we are in css mode // and in attribute value state of a tag with attribute name style if ( ctx . token . state . htmlState && ( ! ctx . token . state . localMode || ctx . token . state . localMode . name !== "css" ) ) { // tagInfo is required to aquire the style attr value var tagInfo = HTMLUtils . getTagInfo ( editor , pos , true ) , // To be used as relative character position offset = tagInfo . position . offset ; /**
             * We will use this CM to cook css context in case of style attribute value
             * as CM in htmlmixed mode doesn't yet identify this as css context. We provide
             * a no-op display function to run CM without a DOM head.
             */ var _contextCM = new CodeMirror ( function ( ) { } , { value : "{" + tagInfo . attr . value . replace ( / (^")|("$) / g , "" ) , mode : "css" } ) ; ctx = TokenUtils . getInitialContext ( _contextCM , { line : 0 , ch : offset + 1 } ) ; } if ( _isInPropName ( ctx ) ) { return _getPropNameInfo ( ctx ) ; } if ( _isInPropValue ( ctx ) ) { return _getRuleInfoStartingFromPropValue ( ctx , ctx . editor ) ; } if ( _isInAtRule ( ctx ) ) { return _getImportUrlInfo ( ctx , editor ) ; } return createInfo ( ) ; }
Returns a context info object for the given cursor position
@param {!Editor} editor
@param {{ch: number, line: number}} constPos  A CM pos (likely from editor.getCursorPos())
@return {{context: string,
offset: number,
name: string,
index: number,
values: Array.<string>,
isNewItem: boolean,
range: {start: {line: number, ch: number},
end: {line: number, ch: number}}}} A CSS context info object.
Returns a context info object for the given cursor position