'Extract the CSS declaration around the given position.
Returns a 3-tuple:
(<property>, <current_value>, <value_list>)
If is_for_calltip is true, we do not bother to parse out the values, so
<current_value> and <value_list> will be empty.
The value gets parsed into <value_list>, a list of individual values.
Comments and strings are striped from the return value.
If the <current_value> is \'\', then the trigger position is
ready to start a new value.'

def _extract_css_declaration(self, ac, styleClassifier, trg, is_for_calltip=False):

    DEBUG = DebugStatus
    try:
        ac.resetToPosition(trg.pos)
        (p, ch, style) = ac.getPrevPosCharStyle()
        if (not styleClassifier.is_operator(style, ac)):
            if DEBUG:
                print ('Current    ch    is    not    an    operator,    so    getting    the    preceeding    one,    p:    %d,    ch:    %r,    style:    %d' % (p, ch, style))
            (p, ch, style) = ac.getPrevPosCharStyle(ignore_styles=styleClassifier.ignore_styles)
    except IndexError:
        ac.resetToPosition((trg.pos - 1))
        (p, ch, style) = ac.getCurrentPosCharStyle()
    if DEBUG:
        print '------    _extract_css_declaration    -----'
        print ('        _extract_css_declaration::    Trg.pos:    %d' % trg.pos)
        print ('        _extract_css_declaration::    pos:    %r' % p)
        print ('        _extract_css_declaration::    ch:    %r' % ch)
        print ('        _extract_css_declaration::    style:    %r' % style)
        ac.dump()
    num_close_parenthesis = 0
    min_pos = max(0, (trg.pos - 200))
    while (p >= min_pos):
        if ((ch == ':') and styleClassifier.is_operator(style, ac)):
            break
        elif (num_close_parenthesis > 0):
            if (ch == '('):
                num_close_parenthesis -= 1
                if DEBUG:
                    print ('Found    matching    open    paren,    num_close_parenthesis    now:    %d' % num_close_parenthesis)
            elif DEBUG:
                print 'Ignoring    everything    inside    the    parenthesis'
        elif ((ch == '(') and (styleClassifier.is_operator(style) or styleClassifier.is_value(style))):
            if DEBUG:
                print "Already    inside    a    paren,    no    cpln's    then."
            return (None, None, None)
        elif ((ch == ')') and (styleClassifier.is_operator(style) or styleClassifier.is_value(style))):
            num_close_parenthesis += 1
            if DEBUG:
                print ('Found    close    paren,    need    to    skip    over    contents,    num_close_parenthesis:    %d' % num_close_parenthesis)
        elif styleClassifier.is_operator(style):
            if (ch not in ':,%'):
                if DEBUG:
                    print ("%s:    couldn't    find    ':'    operator,    found    invalid    operator:    %d    %r    %d" % (trg.name, p, ch, style))
                return (None, None, None)
        elif styleClassifier.is_string(style):
            if DEBUG:
                print 'Found    string    style,    ignoring    it'
        elif (not (styleClassifier.is_value(style) or styleClassifier.is_default(style))):
            if DEBUG:
                print ("%s:    couldn't    find    ':'    operator,    found    invalid    style:    pcs:    %d    %r    %d" % (trg.name, p, ch, style))
            return (None, None, None)
        (p, ch, style) = ac.getPrevPosCharStyle(ignore_styles=styleClassifier.ignore_styles)
    else:
        if DEBUG:
            print ("%s:    couldn't    find    ':'    operator    within    200    chars,    giving    up" % trg.name)
        return (None, None, None)
    if DEBUG:
        print ("        _extract_css_declaration::    Found    ':'    at    pos:    %d" % p)
    colan_pos = p
    (p, ch, style) = ac.getPrecedingPosCharStyle(style, ignore_styles=styleClassifier.ignore_styles, max_look_back=150)
    if (style not in styleClassifier.identifier_styles):
        if DEBUG:
            print ("        _extract_css_declaration::    No    identifier    style    found    before    ':',    found    style    %d    instead" % style)
        return (None, None, None)
    (p, property) = ac.getTextBackWithStyle(style)
    property = property.strip()
    if is_for_calltip:
        if DEBUG:
            print ('        _extract_css_declaration::    Returning    property:    %r' % property)
        return (property, '', [])
    ac.resetToPosition(colan_pos)
    (prev_pos, prev_ch, prev_style) = ac.getCurrentPosCharStyle()
    from_pos = prev_pos
    p = colan_pos
    value_info = []
    max_p = (p + 200)
    try:
        while (p < max_p):
            (p, ch, style) = ac.getNextPosCharStyle(max_look_ahead=100, ignore_styles=styleClassifier.comment_styles)
            if ((p is None) or (not styleClassifier.is_css_style(style))):
                if DEBUG:
                    print ('%s:    css    value    reached    max    length    or    end    of    document:    trg.pos    %d' % (trg.name, trg.pos))
                value_info.append((from_pos, ac.text_range(from_pos, p)))
                break
            if ((ch == '\n') and (self.lang == 'Sass') and styleClassifier.is_default(style)):
                value_info.append((from_pos, ac.text_range(from_pos, p)))
                break
            if ((ch in WHITESPACE) or styleClassifier.is_string(style)):
                if ((not (prev_ch in WHITESPACE)) and (not styleClassifier.is_string(prev_style))):
                    value_info.append((from_pos, ac.text_range(from_pos, p)))
                from_pos = (p + 1)
            elif styleClassifier.is_operator(style):
                if (ch in ';{}'):
                    value_info.append((from_pos, ac.text_range(from_pos, p)))
                    break
            elif ((not styleClassifier.is_value(style)) and (style not in styleClassifier.ignore_styles)):
                if DEBUG:
                    print ('%s:    invalid    style    found:    pos    %d,    style:    %d' % (trg.name, trg.pos, style))
                return (None, None, None)
            (prev_pos, prev_ch, prev_style) = (p, ch, style)
        else:
            if DEBUG:
                print ('%s:    css    value    too    long:    trg.pos    %d' % (trg.name, trg.pos))
            return (None, None, None)
    except IndexError:
        if DEBUG:
            print 'ran    out    of    buffer'
    current_value = None
    values = []
    trg_pos = trg.pos
    for (p, value) in value_info:
        if (value and _isident_first_char(value[0])):
            if DEBUG:
                print ('Is    a    valid    value,    p:    %d,    value:    %r' % (p, value))
            values.append(value)
            if ((current_value is None) and (trg_pos >= p) and (trg_pos <= (p + len(value)))):
                current_value = value
    if DEBUG:
        print ('        _extract_css_declaration::    Returning    property:    %r,    current_value:    %r,    values:    %r' % (property, current_value, values))
    return (property, current_value, values)
