Support variables set in the vimspector.json
This commit is contained in:
parent
32e16d9daf
commit
aed3f459a6
1 changed files with 29 additions and 17 deletions
|
|
@ -120,33 +120,45 @@ class DebugSession( object ):
|
||||||
with open( launch_config_file, 'r' ) as f:
|
with open( launch_config_file, 'r' ) as f:
|
||||||
database = json.load( f )
|
database = json.load( f )
|
||||||
|
|
||||||
launch_config = database.get( 'configurations' )
|
configurations = database.get( 'configurations' )
|
||||||
adapters = database.get( 'adapters' )
|
adapters = database.get( 'adapters' )
|
||||||
|
|
||||||
if len( launch_config ) == 1:
|
if len( configurations ) == 1:
|
||||||
configuration = next( iter( launch_config.keys() ) )
|
configuration_name = next( iter( configurations.keys() ) )
|
||||||
else:
|
else:
|
||||||
configuration = utils.SelectFromList( 'Which launch configuration?',
|
configuration_name = utils.SelectFromList(
|
||||||
list( launch_config.keys() ) )
|
'Which launch configuration?',
|
||||||
if not configuration:
|
list( configurations.keys() ) )
|
||||||
|
|
||||||
|
if not configuration_name or configuration_name not in configurations:
|
||||||
return
|
return
|
||||||
|
|
||||||
self._workspace_root = os.path.dirname( launch_config_file )
|
self._workspace_root = os.path.dirname( launch_config_file )
|
||||||
|
|
||||||
variables = {
|
configuration = configurations[ configuration_name ]
|
||||||
'dollar': '$', # HAAACK: work around not having a way to include a literal
|
adapter = configuration.get( 'adapter' )
|
||||||
'workspaceRoot': self._workspace_root
|
|
||||||
}
|
|
||||||
variables.update( launch_variables )
|
|
||||||
utils.ExpandReferencesInDict( launch_config[ configuration ], variables )
|
|
||||||
|
|
||||||
adapter = launch_config[ configuration ].get( 'adapter' )
|
|
||||||
if isinstance( adapter, str ):
|
if isinstance( adapter, str ):
|
||||||
adapter = adapters.get( adapter )
|
adapter = adapters.get( adapter )
|
||||||
utils.ExpandReferencesInDict( adapter, variables )
|
|
||||||
|
|
||||||
self._StartWithConfiguration( launch_config[ configuration ],
|
# TODO: Do we want some form of persistence ? e.g. self._staticVariables,
|
||||||
adapter )
|
# set from an api call like SetLaunchParam( 'var', 'value' ), perhaps also a
|
||||||
|
# way to load .vimspector.local.json which just sets variables
|
||||||
|
self._variables = {
|
||||||
|
'dollar': '$', # HACK
|
||||||
|
'workspaceRoot': self._workspace_root
|
||||||
|
}
|
||||||
|
self._variables.update( adapter.get( 'variables', {} ) )
|
||||||
|
self._variables.update( configuration.get( 'variables', {} ) )
|
||||||
|
|
||||||
|
utils.ExpandReferencesInDict( configuration, self._variables )
|
||||||
|
utils.ExpandReferencesInDict( adapter, self._variables )
|
||||||
|
|
||||||
|
if not adapter:
|
||||||
|
utils.UserMessage( 'No adapter configured for {}'.format(
|
||||||
|
configuration_name ), persist=True )
|
||||||
|
return
|
||||||
|
|
||||||
|
self._StartWithConfiguration( configuration, adapter )
|
||||||
|
|
||||||
def _StartWithConfiguration( self, configuration, adapter ):
|
def _StartWithConfiguration( self, configuration, adapter ):
|
||||||
self._configuration = configuration
|
self._configuration = configuration
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue