MCPcopy Create free account
hub / github.com/ycm-core/YouCompleteMe / YouCompleteMe

Class YouCompleteMe

python/ycm/youcompleteme.py:101–1039  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99
100
101class YouCompleteMe:
102 def __init__( self, default_options = {} ):
103 self._logger = logging.getLogger( 'ycm' )
104 self._client_logfile = None
105 self._server_stdout = None
106 self._server_stderr = None
107 self._server_popen = None
108 self._default_options = default_options
109 self._ycmd_keepalive = YcmdKeepalive()
110 self._SetUpLogging()
111 self._SetUpServer()
112 self._ycmd_keepalive.Start()
113 self._current_hierarchy = HierarchyTree()
114
115
116 def InitializeCurrentHierarchy( self, items, kind ):
117 return self._current_hierarchy.SetRootNode( items, kind )
118
119
120 def UpdateCurrentHierarchy( self, handle : int, direction : str ):
121 if not self._current_hierarchy.UpdateChangesRoot( handle, direction ):
122 items = self._ResolveHierarchyItem( handle, direction )
123 self._current_hierarchy.UpdateHierarchy( handle, items, direction )
124
125 if items is not None and direction == 'up':
126 offset = sum( len( item[ 'locations' ] ) for item in items )
127 else:
128 offset = 0
129
130 return self._current_hierarchy.HierarchyToLines(), offset
131 else:
132 location = self._current_hierarchy.HandleToRootLocation( handle )
133 kind = self._current_hierarchy._kind
134 self._current_hierarchy.Reset()
135 items = GetRawCommandResponse(
136 [ f'{ kind.title() }Hierarchy' ],
137 silent = False,
138 location = location
139 )
140 # [ 0 ] chooses the data for the 1st (and only) line.
141 # [ 1 ] chooses only the handle
142 handle = self.InitializeCurrentHierarchy( items, kind )[ 0 ][ 1 ]
143 return self.UpdateCurrentHierarchy( handle, direction )
144
145
146 def _ResolveHierarchyItem( self, handle : int, direction : str ):
147 return GetRawCommandResponse(
148 self._current_hierarchy.ResolveArguments( handle, direction ),
149 silent = False
150 )
151
152
153 def ShouldResolveItem( self, handle : int, direction : str ):
154 return self._current_hierarchy.ShouldResolveItem( handle, direction )
155
156
157 def ResetCurrentHierarchy( self ):
158 self._current_hierarchy.Reset()

Calls

no outgoing calls