Merge pull request #84 from puremourning/fid-upstream
A selection of misc fixes and enhancements from ongoing usage
This commit is contained in:
commit
1277ec6347
8 changed files with 128 additions and 81 deletions
|
|
@ -26,6 +26,15 @@ def Settings( **kwargs ):
|
|||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
'capabilities': {
|
||||
'textDocument': {
|
||||
'completion': {
|
||||
'completionItem': {
|
||||
'snippetSupport': True
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -107,6 +107,26 @@ GADGETS = {
|
|||
}
|
||||
},
|
||||
},
|
||||
'vscode-java-debug': {
|
||||
'language': 'java',
|
||||
'enabled': False,
|
||||
'download': {
|
||||
'url': 'https://github.com/microsoft/vscode-java-debug/releases/download/'
|
||||
'${version}/${file_name}',
|
||||
},
|
||||
'all': {
|
||||
'version': '0.23.0',
|
||||
'file_name': 'vscode-java-debug-0.23.0.vsix',
|
||||
'checksum':
|
||||
'',
|
||||
},
|
||||
'adapters': {
|
||||
"vscode-java": {
|
||||
"name": "vscode-java",
|
||||
"port": "ask",
|
||||
}
|
||||
},
|
||||
},
|
||||
'tclpro': {
|
||||
'language': 'tcl',
|
||||
'repo': {
|
||||
|
|
|
|||
|
|
@ -203,14 +203,18 @@ class ProjectBreakpoints( object ):
|
|||
|
||||
awaiting = 0
|
||||
|
||||
def response_handler( source, msg ):
|
||||
if msg:
|
||||
self._breakpoints_handler.AddBreakpoints( source, msg )
|
||||
def response_received():
|
||||
nonlocal awaiting
|
||||
awaiting = awaiting - 1
|
||||
if awaiting == 0 and doneHandler:
|
||||
doneHandler()
|
||||
|
||||
def response_handler( source, msg ):
|
||||
if msg:
|
||||
self._breakpoints_handler.AddBreakpoints( source, msg )
|
||||
response_received()
|
||||
|
||||
|
||||
|
||||
# TODO: add the _configured_breakpoints to line_breakpoints
|
||||
# TODO: the line numbers might have changed since pressing the F9 key!
|
||||
|
|
@ -244,7 +248,8 @@ class ProjectBreakpoints( object ):
|
|||
'breakpoints': breakpoints,
|
||||
},
|
||||
'sourceModified': False, # TODO: We can actually check this
|
||||
}
|
||||
},
|
||||
failure_handler = lambda *_: response_received()
|
||||
)
|
||||
|
||||
# TODO: Add the _configured_breakpoints to function breakpoints
|
||||
|
|
@ -261,7 +266,8 @@ class ProjectBreakpoints( object ):
|
|||
for bp in self._func_breakpoints if bp[ 'state' ] == 'ENABLED'
|
||||
],
|
||||
}
|
||||
}
|
||||
},
|
||||
failure_handler = lambda *_: response_received()
|
||||
)
|
||||
|
||||
if self._exception_breakpoints is None:
|
||||
|
|
@ -274,7 +280,8 @@ class ProjectBreakpoints( object ):
|
|||
{
|
||||
'command': 'setExceptionBreakpoints',
|
||||
'arguments': self._exception_breakpoints
|
||||
}
|
||||
},
|
||||
failure_handler = lambda *_: response_received()
|
||||
)
|
||||
|
||||
if awaiting == 0 and doneHandler:
|
||||
|
|
|
|||
|
|
@ -473,10 +473,11 @@ class DebugSession( object ):
|
|||
if 'cwd' not in self._adapter:
|
||||
self._adapter[ 'cwd' ] = os.getcwd()
|
||||
|
||||
vim.vars[ '_vimspector_adapter_spec' ] = self._adapter
|
||||
channel_send_func = vim.bindeval(
|
||||
"vimspector#internal#{}#StartDebugSession( {} )".format(
|
||||
self._connection_type,
|
||||
json.dumps( self._adapter ) ) )
|
||||
"vimspector#internal#{}#StartDebugSession( "
|
||||
" g:_vimspector_adapter_spec "
|
||||
")".format( self._connection_type ) )
|
||||
|
||||
if channel_send_func is None:
|
||||
self._logger.error( "Unable to start debug server" )
|
||||
|
|
@ -508,8 +509,8 @@ class DebugSession( object ):
|
|||
|
||||
# TODO: Use the 'tarminate' request if supportsTerminateRequest set
|
||||
|
||||
def _PrepareAttach( self, adapter_config, launch_config ):
|
||||
|
||||
def _PrepareAttach( self, adapter_config, launch_config ):
|
||||
atttach_config = adapter_config.get( 'attach' )
|
||||
|
||||
if not atttach_config:
|
||||
|
|
@ -520,13 +521,9 @@ class DebugSession( object ):
|
|||
# e.g. expand variables when we use them, not all at once. This would
|
||||
# remove the whole %PID% hack.
|
||||
remote = atttach_config[ 'remote' ]
|
||||
ssh = [ 'ssh' ]
|
||||
|
||||
if 'account' in remote:
|
||||
ssh.append( remote[ 'account' ] + '@' + remote[ 'host' ] )
|
||||
else:
|
||||
ssh.append( remote[ 'host' ] )
|
||||
ssh = self._GetSSHCommand( remote )
|
||||
|
||||
# FIXME: Why does this not use self._GetCommands ?
|
||||
cmd = ssh + remote[ 'pidCommand' ]
|
||||
|
||||
self._logger.debug( 'Getting PID: %s', cmd )
|
||||
|
|
@ -574,12 +571,7 @@ class DebugSession( object ):
|
|||
|
||||
if 'remote' in run_config:
|
||||
remote = run_config[ 'remote' ]
|
||||
ssh = [ 'ssh' ]
|
||||
if 'account' in remote:
|
||||
ssh.append( remote[ 'account' ] + '@' + remote[ 'host' ] )
|
||||
else:
|
||||
ssh.append( remote[ 'host' ] )
|
||||
|
||||
ssh = self._GetSSHCommand( remote )
|
||||
commands = self._GetCommands( remote, 'run' )
|
||||
|
||||
for index, command in enumerate( commands ):
|
||||
|
|
@ -599,6 +591,16 @@ class DebugSession( object ):
|
|||
full_cmd )
|
||||
|
||||
|
||||
def _GetSSHCommand( self, remote ):
|
||||
ssh = [ 'ssh' ] + remote.get( 'ssh', {} ).get( 'args', [] )
|
||||
if 'account' in remote:
|
||||
ssh.append( remote[ 'account' ] + '@' + remote[ 'host' ] )
|
||||
else:
|
||||
ssh.append( remote[ 'host' ] )
|
||||
|
||||
return ssh
|
||||
|
||||
|
||||
def _GetCommands( self, remote, pfx ):
|
||||
commands = remote.get( pfx + 'Commands', None )
|
||||
|
||||
|
|
|
|||
|
|
@ -115,10 +115,6 @@ class OutputView( object ):
|
|||
self._ShowOutput( category )
|
||||
|
||||
def Evaluate( self, frame, expression ):
|
||||
if not frame:
|
||||
self.Print( 'Console', 'There is no current stack frame' )
|
||||
return
|
||||
|
||||
console = self._buffers[ 'Console' ].buf
|
||||
utils.AppendToBuffer( console, 'Evaluating: ' + expression )
|
||||
|
||||
|
|
@ -132,14 +128,18 @@ class OutputView( object ):
|
|||
|
||||
utils.AppendToBuffer( console, ' Result: ' + result )
|
||||
|
||||
self._connection.DoRequest( print_result, {
|
||||
request = {
|
||||
'command': 'evaluate',
|
||||
'arguments': {
|
||||
'expression': expression,
|
||||
'context': 'repl',
|
||||
'frameId': frame[ 'id' ],
|
||||
}
|
||||
} )
|
||||
}
|
||||
|
||||
if frame:
|
||||
request[ 'arguments' ][ 'frameId' ] = frame[ 'id' ]
|
||||
|
||||
self._connection.DoRequest( print_result, request )
|
||||
|
||||
def _ToggleFlag( self, category, flag ):
|
||||
if self._buffers[ category ].flag != flag:
|
||||
|
|
|
|||
|
|
@ -172,8 +172,9 @@ class StackTraceView( object ):
|
|||
if 'line' in frame and frame[ 'line' ] > 0:
|
||||
self._currentFrame = frame
|
||||
return self._session.SetCurrentFrame( self._currentFrame )
|
||||
return False
|
||||
|
||||
source = frame.get( 'source', {} )
|
||||
source = frame.get( 'source' ) or {}
|
||||
if source.get( 'sourceReference', 0 ) > 0:
|
||||
def handle_resolved_source( resolved_source ):
|
||||
frame[ 'source' ] = resolved_source
|
||||
|
|
|
|||
|
|
@ -324,57 +324,59 @@ def IsCurrent( window, buf ):
|
|||
return vim.current.window == window and vim.current.window.buffer == buf
|
||||
|
||||
|
||||
def ExpandReferencesInObject( obj, mapping, user_choices ):
|
||||
if isinstance( obj, dict ):
|
||||
ExpandReferencesInDict( obj, mapping, user_choices )
|
||||
elif isinstance( obj, list ):
|
||||
for i, _ in enumerate( obj ):
|
||||
# FIXME: We are assuming that it is a list of string, but could be a
|
||||
# list of list of a list of dict, etc.
|
||||
obj[ i ] = ExpandReferencesInObject( obj[ i ], mapping, user_choices )
|
||||
elif isinstance( obj, str ):
|
||||
obj = ExpandReferencesInString( obj, mapping, user_choices )
|
||||
|
||||
return obj
|
||||
|
||||
|
||||
def ExpandReferencesInString( orig_s, mapping, user_choices):
|
||||
s = os.path.expanduser( orig_s )
|
||||
s = os.path.expandvars( s )
|
||||
|
||||
# Parse any variables passed in in mapping, and ask for any that weren't,
|
||||
# storing the result in mapping
|
||||
bug_catcher = 0
|
||||
while bug_catcher < 100:
|
||||
++bug_catcher
|
||||
|
||||
try:
|
||||
s = string.Template( s ).substitute( mapping )
|
||||
break
|
||||
except KeyError as e:
|
||||
# HACK: This is seemingly the only way to get the key. str( e ) returns
|
||||
# the key surrounded by '' for unknowable reasons.
|
||||
key = e.args[ 0 ]
|
||||
default_value = user_choices.get( key, None )
|
||||
mapping[ key ] = AskForInput( 'Enter value for {}: '.format( key ),
|
||||
default_value )
|
||||
user_choices[ key ] = mapping[ key ]
|
||||
_logger.debug( "Value for %s not set in %s (from %s): set to %s",
|
||||
key,
|
||||
s,
|
||||
orig_s,
|
||||
mapping[ key ] )
|
||||
except ValueError as e:
|
||||
UserMessage( 'Invalid $ in string {}: {}'.format( s, e ),
|
||||
persist = True )
|
||||
break
|
||||
|
||||
return s
|
||||
|
||||
|
||||
# TODO: Should we just run the substitution on the whole JSON string instead?
|
||||
# That woul dallow expansion in bool and number values, such as ports etc. ?
|
||||
def ExpandReferencesInDict( obj, mapping, user_choices ):
|
||||
def expand_refs_in_string( orig_s ):
|
||||
s = os.path.expanduser( orig_s )
|
||||
s = os.path.expandvars( s )
|
||||
|
||||
# Parse any variables passed in in mapping, and ask for any that weren't,
|
||||
# storing the result in mapping
|
||||
bug_catcher = 0
|
||||
while bug_catcher < 100:
|
||||
++bug_catcher
|
||||
|
||||
try:
|
||||
s = string.Template( s ).substitute( mapping )
|
||||
break
|
||||
except KeyError as e:
|
||||
# HACK: This is seemingly the only way to get the key. str( e ) returns
|
||||
# the key surrounded by '' for unknowable reasons.
|
||||
key = e.args[ 0 ]
|
||||
default_value = user_choices.get( key, None )
|
||||
mapping[ key ] = AskForInput( 'Enter value for {}: '.format( key ),
|
||||
default_value )
|
||||
user_choices[ key ] = mapping[ key ]
|
||||
_logger.debug( "Value for %s not set in %s (from %s): set to %s",
|
||||
key,
|
||||
s,
|
||||
orig_s,
|
||||
mapping[ key ] )
|
||||
except ValueError as e:
|
||||
UserMessage( 'Invalid $ in string {}: {}'.format( s, e ),
|
||||
persist = True )
|
||||
break
|
||||
|
||||
return s
|
||||
|
||||
def expand_refs_in_object( obj ):
|
||||
if isinstance( obj, dict ):
|
||||
ExpandReferencesInDict( obj, mapping, user_choices )
|
||||
elif isinstance( obj, list ):
|
||||
for i, _ in enumerate( obj ):
|
||||
# FIXME: We are assuming that it is a list of string, but could be a
|
||||
# list of list of a list of dict, etc.
|
||||
obj[ i ] = expand_refs_in_object( obj[ i ] )
|
||||
elif isinstance( obj, str ):
|
||||
obj = expand_refs_in_string( obj )
|
||||
|
||||
return obj
|
||||
|
||||
for k in obj.keys():
|
||||
obj[ k ] = expand_refs_in_object( obj[ k ] )
|
||||
obj[ k ] = ExpandReferencesInObject( obj[ k ], mapping, user_choices )
|
||||
|
||||
|
||||
def ParseVariables( variables_list, mapping, user_choices ):
|
||||
|
|
@ -416,7 +418,9 @@ def ParseVariables( variables_list, mapping, user_choices ):
|
|||
raise ValueError(
|
||||
"Unsupported variable defn {}: Missing 'shell'".format( n ) )
|
||||
else:
|
||||
new_variables[ n ] = v
|
||||
new_variables[ n ] = ExpandReferencesInObject( v,
|
||||
mapping,
|
||||
user_choices )
|
||||
|
||||
return new_variables
|
||||
|
||||
|
|
|
|||
|
|
@ -143,10 +143,12 @@ class VariablesView( object ):
|
|||
|
||||
def AddWatch( self, frame, expression ):
|
||||
watch = {
|
||||
'expression': expression,
|
||||
'frameId': frame[ 'id' ],
|
||||
'context': 'watch',
|
||||
'expression': expression,
|
||||
'context': 'watch',
|
||||
}
|
||||
if frame:
|
||||
watch[ 'frameId' ] = frame[ 'id' ]
|
||||
|
||||
self._watches.append( watch )
|
||||
self.EvaluateWatches()
|
||||
|
||||
|
|
@ -395,3 +397,5 @@ class VariablesView( object ):
|
|||
|
||||
with utils.LetCurrentWindow( self._watch.win ):
|
||||
vim.command( 'set syntax={}'.format( utils.Escape( syntax ) ) )
|
||||
|
||||
# vim: sw=2
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue