Calculate variables on-demand; add an unused-local-port variable-function
This commit is contained in:
parent
85667a5bac
commit
044804ca20
2 changed files with 71 additions and 32 deletions
|
|
@ -177,43 +177,53 @@ class DebugSession( object ):
|
|||
return [ '', '' ]
|
||||
return os.path.splitext( p )
|
||||
|
||||
self._variables = {
|
||||
variables = {
|
||||
'dollar': '$', # HACK. Hote '$$' also works.
|
||||
'workspaceRoot': self._workspace_root,
|
||||
'workspaceFolder': self._workspace_root,
|
||||
'gadgetDir': install.GetGadgetDir( VIMSPECTOR_HOME, install.GetOS() ),
|
||||
'file': current_file,
|
||||
'relativeFile': relpath( current_file, self._workspace_root ),
|
||||
'fileBasename': os.path.basename( current_file ),
|
||||
}
|
||||
|
||||
calculus = {
|
||||
'gadgetDir': lambda: install.GetGadgetDir( VIMSPECTOR_HOME,
|
||||
install.GetOS() ),
|
||||
'relativeFile': lambda: relpath( current_file,
|
||||
self._workspace_root ),
|
||||
'fileBasename': lambda: os.path.basename( current_file ),
|
||||
'fileBasenameNoExtension':
|
||||
splitext( os.path.basename( current_file ) )[ 0 ],
|
||||
'fileDirname': os.path.dirname( current_file ),
|
||||
'fileExtname': splitext( os.path.basename( current_file ) )[ 1 ],
|
||||
lambda: splitext( os.path.basename( current_file ) )[ 0 ],
|
||||
'fileDirname': lambda: os.path.dirname( current_file ),
|
||||
'fileExtname': lambda: splitext( os.path.basename( current_file ) )[ 1 ],
|
||||
# NOTE: this is the window-local cwd for the current window, *not* Vim's
|
||||
# working directory.
|
||||
'cwd': os.getcwd(),
|
||||
'cwd': os.getcwd,
|
||||
'unusedLocalPort': utils.GetUnusedLocalPort,
|
||||
}
|
||||
|
||||
# Pretend that vars passed to the launch command were typed in by the user
|
||||
# (they may have been in theory)
|
||||
USER_CHOICES.update( launch_variables )
|
||||
self._variables.update( launch_variables )
|
||||
variables.update( launch_variables )
|
||||
|
||||
self._variables.update(
|
||||
variables.update(
|
||||
utils.ParseVariables( adapter.get( 'variables', {} ),
|
||||
self._variables,
|
||||
variables,
|
||||
calculus,
|
||||
USER_CHOICES ) )
|
||||
self._variables.update(
|
||||
variables.update(
|
||||
utils.ParseVariables( configuration.get( 'variables', {} ),
|
||||
self._variables,
|
||||
variables,
|
||||
calculus,
|
||||
USER_CHOICES ) )
|
||||
|
||||
|
||||
utils.ExpandReferencesInDict( configuration,
|
||||
self._variables,
|
||||
variables,
|
||||
calculus,
|
||||
USER_CHOICES )
|
||||
utils.ExpandReferencesInDict( adapter,
|
||||
self._variables,
|
||||
variables,
|
||||
calculus,
|
||||
USER_CHOICES )
|
||||
|
||||
if not adapter:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue