MCPcopy
hub / github.com/ycm-core/YouCompleteMe / InsertNamespace

Function InsertNamespace

python/ycm/vimsupport.py:1175–1192  ·  view source on GitHub ↗
( namespace )

Source from the content-addressed store, hash-verified

1173
1174
1175def InsertNamespace( namespace ):
1176 if VariableExists( 'g:ycm_csharp_insert_namespace_expr' ):
1177 expr = GetVariableValue( 'g:ycm_csharp_insert_namespace_expr' )
1178 if expr:
1179 SetVariableValue( "g:ycm_namespace_to_insert", namespace )
1180 vim.eval( expr )
1181 return
1182
1183 pattern = r'^\s*using\(\s\+[a-zA-Z0-9]\+\s\+=\)\?\s\+[a-zA-Z0-9.]\+\s*;\s*'
1184 existing_indent = ''
1185 line = SearchInCurrentBuffer( pattern )
1186 if line:
1187 existing_line = LineTextInCurrentBuffer( line )
1188 existing_indent = re.sub( r'\S.*', '', existing_line )
1189 new_line = f'{ existing_indent }using { namespace };\n'
1190 replace_pos = { 'line_num': line + 1, 'column_num': 1 }
1191 ReplaceChunk( replace_pos, replace_pos, new_line, vim.current.buffer )
1192 PostVimMessage( f'Add namespace: { namespace }', warning = False )
1193
1194
1195def SearchInCurrentBuffer( pattern ):

Callers

nothing calls this directly

Calls 7

VariableExistsFunction · 0.85
GetVariableValueFunction · 0.85
SetVariableValueFunction · 0.85
SearchInCurrentBufferFunction · 0.85
LineTextInCurrentBufferFunction · 0.85
ReplaceChunkFunction · 0.85
PostVimMessageFunction · 0.85

Tested by

no test coverage detected