def _GetCursorIdentifier(collect_from_comments_and_strings, request_data):
    line = request_data['line_value']
    filetype = request_data['first_filetype']
    if not collect_from_comments_and_strings:
        line = identifier_utils.RemoveIdentifierFreeText(line, filetype)
    return identifier_utils.IdentifierAtIndex(
        line, request_data['column_codepoint'] - 1, filetype)
Example #2
0
def _GetCursorIdentifier(request_data):
    try:
        filetype = request_data['filetypes'][0]
    except KeyError:
        filetype = None
    return identifier_utils.IdentifierAtIndex(request_data['line_value'],
                                              request_data['column_num'] - 1,
                                              filetype)
Example #3
0
def _GetCursorIdentifier(collect_from_comments_and_strings, request_data):
    filepath = request_data['filepath']
    contents = request_data['file_data'][filepath]['contents']
    filetype = request_data['first_filetype']
    if not collect_from_comments_and_strings:
        contents = identifier_utils.RemoveIdentifierFreeText(
            contents, filetype)
    contents_per_line = SplitLines(contents)
    line = contents_per_line[request_data['line_num'] - 1]
    return identifier_utils.IdentifierAtIndex(
        line, request_data['column_codepoint'] - 1, filetype)
Example #4
0
def IdentifierAtIndex_StopsAtNonIdentifier_test():
    eq_('foo', iu.IdentifierAtIndex('foo(goo)', 0))
    eq_('goo', iu.IdentifierAtIndex('foo(goo)', 5))
Example #5
0
def IdentifierAtIndex_LooksAhead_Success_test():
    eq_('goo', iu.IdentifierAtIndex('foo(goo)', 3))
    eq_('goo', iu.IdentifierAtIndex('   goo', 0))
Example #6
0
def IdentifierAtIndex_BadInput_test():
    eq_('', iu.IdentifierAtIndex('', 0))
    eq_('', iu.IdentifierAtIndex('', 5))
    eq_('', iu.IdentifierAtIndex('foo', 5))
    eq_('foo', iu.IdentifierAtIndex('foo', -5))
Example #7
0
def IdentifierAtIndex_IndexPastIdent_test():
    eq_('', iu.IdentifierAtIndex('foo    ', 5))
def LoopExpectIdentfierAtIndex( ident, index, expected ):
  assert_that( expected, equal_to( iu.IdentifierAtIndex( ident, index ) ) )
Example #9
0
def LoopExpectIdentfierAtIndex(ident, index, expected):
    eq_(expected, iu.IdentifierAtIndex(ident, index))
def IdentifierAtIndex_SingleCharIdent_test():
  assert_that( 'f', equal_to( iu.IdentifierAtIndex( '    f    ', 1 ) ) )
Example #11
0
def IdentifierAtIndex_Css_test():
    eq_('font-face', iu.IdentifierAtIndex('font-face', 0, 'css'))
def IdentifierAtIndex_LooksAhead_Success_test():
  assert_that( 'goo', equal_to( iu.IdentifierAtIndex( 'foo(goo)', 3 ) ) )
  assert_that( 'goo', equal_to( iu.IdentifierAtIndex( '   goo', 0 ) ) )
def IdentifierAtIndex_LooksAhead_Failure_test():
  assert_that( '', equal_to( iu.IdentifierAtIndex( 'foo    ()***()', 5 ) ) )
def IdentifierAtIndex_StopsAtNonIdentifier_test():
  assert_that( 'foo', equal_to( iu.IdentifierAtIndex( 'foo(goo)', 0 ) ) )
  assert_that( 'goo', equal_to( iu.IdentifierAtIndex( 'foo(goo)', 5 ) ) )
def IdentifierAtIndex_IndexPastIdent_test():
  assert_that( '', equal_to( iu.IdentifierAtIndex( 'foo    ', 5 ) ) )
def IdentifierAtIndex_BadInput_test():
  assert_that( '', equal_to( iu.IdentifierAtIndex( '', 0 ) ) )
  assert_that( '', equal_to( iu.IdentifierAtIndex( '', 5 ) ) )
  assert_that( '', equal_to( iu.IdentifierAtIndex( 'foo', 5 ) ) )
  assert_that( 'foo', equal_to( iu.IdentifierAtIndex( 'foo', -5 ) ) )
Example #17
0
def IdentifierAtIndex_LooksAhead_Failure_test():
    eq_('', iu.IdentifierAtIndex('foo    ()***()', 5))
Example #18
0
 def test_IdentifierAtIndex_SingleCharIdent(self):
     assert_that('f', equal_to(iu.IdentifierAtIndex('    f    ', 1)))
Example #19
0
def IdentifierAtIndex_SingleCharIdent_test():
    eq_('f', iu.IdentifierAtIndex('    f    ', 1))
Example #20
0
 def test_IdentifierAtIndex_IndexPastIdent(self):
     assert_that('', equal_to(iu.IdentifierAtIndex('foo    ', 5)))
def IdentifierAtIndex_Css_test():
  assert_that( 'font-face', equal_to(
    iu.IdentifierAtIndex( 'font-face', 0, 'css' ) ) )
Example #22
0
 def test_IdentifierAtIndex_Css(self):
     assert_that('font-face',
                 equal_to(iu.IdentifierAtIndex('font-face', 0, 'css')))
def _GetCursorIdentifier(request_data):
    return identifier_utils.IdentifierAtIndex(
        request_data['line_value'], request_data['column_codepoint'] - 1,
        request_data['first_filetype'])
Example #24
0
 def test_IdentifierAtIndex_BadInput(self):
     assert_that('', equal_to(iu.IdentifierAtIndex('', 0)))
     assert_that('', equal_to(iu.IdentifierAtIndex('', 5)))
     assert_that('', equal_to(iu.IdentifierAtIndex('foo', 5)))
     assert_that('foo', equal_to(iu.IdentifierAtIndex('foo', -5)))