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)
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)
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)
def IdentifierAtIndex_StopsAtNonIdentifier_test(): eq_('foo', iu.IdentifierAtIndex('foo(goo)', 0)) eq_('goo', iu.IdentifierAtIndex('foo(goo)', 5))
def IdentifierAtIndex_LooksAhead_Success_test(): eq_('goo', iu.IdentifierAtIndex('foo(goo)', 3)) eq_('goo', iu.IdentifierAtIndex(' goo', 0))
def IdentifierAtIndex_BadInput_test(): eq_('', iu.IdentifierAtIndex('', 0)) eq_('', iu.IdentifierAtIndex('', 5)) eq_('', iu.IdentifierAtIndex('foo', 5)) eq_('foo', iu.IdentifierAtIndex('foo', -5))
def IdentifierAtIndex_IndexPastIdent_test(): eq_('', iu.IdentifierAtIndex('foo ', 5))
def LoopExpectIdentfierAtIndex( ident, index, expected ): assert_that( expected, equal_to( iu.IdentifierAtIndex( ident, index ) ) )
def LoopExpectIdentfierAtIndex(ident, index, expected): eq_(expected, iu.IdentifierAtIndex(ident, index))
def IdentifierAtIndex_SingleCharIdent_test(): assert_that( 'f', equal_to( iu.IdentifierAtIndex( ' f ', 1 ) ) )
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 ) ) )
def IdentifierAtIndex_LooksAhead_Failure_test(): eq_('', iu.IdentifierAtIndex('foo ()***()', 5))
def test_IdentifierAtIndex_SingleCharIdent(self): assert_that('f', equal_to(iu.IdentifierAtIndex(' f ', 1)))
def IdentifierAtIndex_SingleCharIdent_test(): eq_('f', iu.IdentifierAtIndex(' f ', 1))
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' ) ) )
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'])
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)))