mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 14:04:26 +08:00
Test extracing of base classes
This commit is contained in:
@@ -12,6 +12,7 @@ _INLINE_NEEDS_BRACKET = (
|
|||||||
'xor_expr and_expr shift_expr arith_expr term factor power atom_expr '
|
'xor_expr and_expr shift_expr arith_expr term factor power atom_expr '
|
||||||
'or_test and_test not_test comparison'
|
'or_test and_test not_test comparison'
|
||||||
).split()
|
).split()
|
||||||
|
_EXTRACT_USE_PARENT = _INLINE_NEEDS_BRACKET + ['trailer']
|
||||||
_DEFINITION_SCOPES = ('suite', 'file_input')
|
_DEFINITION_SCOPES = ('suite', 'file_input')
|
||||||
_NON_EXCTRACABLE = ('param', )
|
_NON_EXCTRACABLE = ('param', )
|
||||||
|
|
||||||
@@ -228,7 +229,7 @@ def extract_variable(grammar, path, module_node, new_name, pos, until_pos):
|
|||||||
node = start_leaf
|
node = start_leaf
|
||||||
if node.type == 'operator':
|
if node.type == 'operator':
|
||||||
node = node.parent
|
node = node.parent
|
||||||
while node.parent.type in _INLINE_NEEDS_BRACKET:
|
while node.parent.type in _EXTRACT_USE_PARENT:
|
||||||
node = node.parent
|
node = node.parent
|
||||||
start_leaf
|
start_leaf
|
||||||
extracted = node.get_code(include_prefix=False)
|
extracted = node.get_code(include_prefix=False)
|
||||||
|
|||||||
@@ -66,3 +66,30 @@ def test(p1=20):
|
|||||||
x = 20
|
x = 20
|
||||||
def test(p1=x):
|
def test(p1=x):
|
||||||
return
|
return
|
||||||
|
# -------------------------------------------------- for-something
|
||||||
|
#? 12 text {'new_name': 'x'}
|
||||||
|
def test(p1=20):
|
||||||
|
return
|
||||||
|
# ++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
#? 12 text {'new_name': 'x'}
|
||||||
|
x = 20
|
||||||
|
def test(p1=x):
|
||||||
|
return
|
||||||
|
# -------------------------------------------------- class-inheritance-1
|
||||||
|
#? 12 text {'new_name': 'x'}
|
||||||
|
class Foo(foo.Bar):
|
||||||
|
pass
|
||||||
|
# ++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
#? 12 text {'new_name': 'x'}
|
||||||
|
x = foo.Bar
|
||||||
|
class Foo(x):
|
||||||
|
pass
|
||||||
|
# -------------------------------------------------- class-inheritance-1
|
||||||
|
#? 16 text {'new_name': 'x'}
|
||||||
|
class Foo(foo.Bar):
|
||||||
|
pass
|
||||||
|
# ++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
#? 16 text {'new_name': 'x'}
|
||||||
|
x = foo.Bar
|
||||||
|
class Foo(x):
|
||||||
|
pass
|
||||||
|
|||||||
Reference in New Issue
Block a user