Add a GetConfigurations function
This commit is contained in:
parent
7b048367f7
commit
d5b9411256
4 changed files with 66 additions and 20 deletions
|
|
@ -79,6 +79,24 @@ class DebugSession( object ):
|
|||
self._server_capabilities = {}
|
||||
self.ClearTemporaryBreakpoints()
|
||||
|
||||
def GetConfigurations( self ):
|
||||
current_file = utils.GetBufferFilepath( vim.current.buffer )
|
||||
filetypes = utils.GetBufferFiletypes( vim.current.buffer )
|
||||
configurations = {}
|
||||
|
||||
for launch_config_file in PathsToAllConfigFiles( VIMSPECTOR_HOME,
|
||||
current_file,
|
||||
filetypes ):
|
||||
self._logger.debug( f'Reading configurations from: {launch_config_file}' )
|
||||
if not launch_config_file or not os.path.exists( launch_config_file ):
|
||||
continue
|
||||
|
||||
with open( launch_config_file, 'r' ) as f:
|
||||
database = json.loads( minify( f.read() ) )
|
||||
configurations.update( database.get( 'configurations' or {} ) )
|
||||
|
||||
return launch_config_file, configurations
|
||||
|
||||
def Start( self, launch_variables = None ):
|
||||
# We mutate launch_variables, so don't mutate the default argument.
|
||||
# https://docs.python-guide.org/writing/gotchas/#mutable-default-arguments
|
||||
|
|
@ -91,10 +109,15 @@ class DebugSession( object ):
|
|||
self._adapter = None
|
||||
|
||||
current_file = utils.GetBufferFilepath( vim.current.buffer )
|
||||
filetypes = utils.GetBufferFiletypes( vim.current.buffer )
|
||||
configurations = {}
|
||||
launch_config_file, configurations = self.GetConfigurations()
|
||||
adapters = {}
|
||||
|
||||
if not configurations:
|
||||
utils.UserMessage( 'Unable to find any debug configurations. '
|
||||
'You need to tell vimspector how to launch your '
|
||||
'application.' )
|
||||
return
|
||||
|
||||
glob.glob( install.GetGadgetDir( VIMSPECTOR_HOME ) )
|
||||
for gadget_config_file in PathsToAllGadgetConfigs( VIMSPECTOR_HOME,
|
||||
current_file ):
|
||||
|
|
@ -106,24 +129,6 @@ class DebugSession( object ):
|
|||
a = json.loads( minify( f.read() ) ).get( 'adapters' ) or {}
|
||||
adapters.update( a )
|
||||
|
||||
for launch_config_file in PathsToAllConfigFiles( VIMSPECTOR_HOME,
|
||||
current_file,
|
||||
filetypes ):
|
||||
self._logger.debug( f'Reading configurations from: {launch_config_file}' )
|
||||
if not launch_config_file or not os.path.exists( launch_config_file ):
|
||||
continue
|
||||
|
||||
with open( launch_config_file, 'r' ) as f:
|
||||
database = json.loads( minify( f.read() ) )
|
||||
adapters.update( database.get( 'adapters' ) or {} )
|
||||
configurations.update( database.get( 'configurations' or {} ) )
|
||||
|
||||
if not configurations:
|
||||
utils.UserMessage( 'Unable to find any debug configurations. '
|
||||
'You need to tell vimspector how to launch your '
|
||||
'application.' )
|
||||
return
|
||||
|
||||
if 'configuration' in launch_variables:
|
||||
configuration_name = launch_variables.pop( 'configuration' )
|
||||
elif ( len( configurations ) == 1 and
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue