fixes for goto

This commit is contained in:
David Halter
2013-02-19 00:21:04 +04:30
parent 926ab81bf2
commit 1b7fc1ee50
3 changed files with 23 additions and 23 deletions

View File

@@ -294,7 +294,7 @@ class Script(object):
defs, search_name = evaluate.goto(stmt) defs, search_name = evaluate.goto(stmt)
definitions = follow_inexistent_imports(defs) definitions = follow_inexistent_imports(defs)
if isinstance(user_stmt, pr.Statement): if isinstance(user_stmt, pr.Statement):
if user_stmt.get_assignment_calls().start_pos > self.pos: if user_stmt.get_commands()[0].start_pos > self.pos:
# The cursor must be after the start, otherwise the # The cursor must be after the start, otherwise the
# statement is just an assignee. # statement is just an assignee.
definitions = [user_stmt] definitions = [user_stmt]

View File

@@ -1128,7 +1128,7 @@ class NamePart(str):
@property @property
def start_pos(self): def start_pos(self):
offset = self.parent.module.line_offset offset = self.parent._sub_module.line_offset
return offset + self._start_pos[0], self._start_pos[1] return offset + self._start_pos[0], self._start_pos[1]
@property @property

View File

@@ -1,23 +1,23 @@
# goto command test are a different in syntax # goto command tests are a different in syntax
definition = 3 definition = 3
##! 0 ['a=definition'] #! 0 ['a = definition']
a = definition a = definition
#! [] #! []
b b
#! ['a=definition'] #! ['a = definition']
a a
b = a b = a
c = b c = b
#! ['c=b'] #! ['c = b']
c c
cd = 1 cd = 1
#! 1 ['cd=c'] #! 1 ['cd = c']
cd = c cd = c
#! 0 ['cd=e'] #! 0 ['cd = e']
cd = e cd = e
#! ['module math'] #! ['module math']
@@ -27,12 +27,12 @@ math
#! ['import math'] #! ['import math']
b = math b = math
#! ['b=math'] #! ['b = math']
b b
class C(object): class C(object):
def b(self): def b(self):
#! ['b=math'] #! ['b = math']
b b
#! ['def b'] #! ['def b']
self.b self.b
@@ -45,7 +45,7 @@ class C(object):
#! ['def b'] #! ['def b']
b b
#! ['b=math'] #! ['b = math']
b b
#! ['def b'] #! ['def b']
@@ -63,9 +63,9 @@ D.b
#! ['def b'] #! ['def b']
D().b D().b
#! 0 ['D=C'] #! 0 ['D = C']
D().b D().b
#! 0 ['D=C'] #! 0 ['D = C']
D().b D().b
def c(): def c():
@@ -82,43 +82,43 @@ c()
#! ['module import_tree'] #! ['module import_tree']
import import_tree import import_tree
#! ['a=""'] #! ["a = ''"]
import_tree.a import_tree.a
#! ['module mod1'] #! ['module mod1']
import import_tree.mod1 import import_tree.mod1
#! ['a=1'] #! ['a = 1']
import_tree.mod1.a import_tree.mod1.a
#! ['module pkg'] #! ['module pkg']
import import_tree.pkg import import_tree.pkg
#! ['a=list'] #! ['a = list']
import_tree.pkg.a import_tree.pkg.a
#! ['module mod1'] #! ['module mod1']
import import_tree.pkg.mod1 import import_tree.pkg.mod1
#! ['a=1.0'] #! ['a = 1.0']
import_tree.pkg.mod1.a import_tree.pkg.mod1.a
#! ['a=""'] #! ["a = ''"]
import_tree.a import_tree.a
#! ['module mod1'] #! ['module mod1']
from import_tree.pkg import mod1 from import_tree.pkg import mod1
#! ['a=1.0'] #! ['a = 1.0']
mod1.a mod1.a
#! ['module mod1'] #! ['module mod1']
from import_tree import mod1 from import_tree import mod1
#! ['a=1'] #! ['a = 1']
mod1.a mod1.a
#! ['a=1.0'] #! ['a = 1.0']
from import_tree.pkg.mod1 import a from import_tree.pkg.mod1 import a
#! ['import os'] #! ['import os']
from .imports import os from .imports import os
#! ['some_variable=1'] #! ['some_variable = 1']
from . import some_variable from . import some_variable
# ----------------- # -----------------
@@ -151,7 +151,7 @@ param = ClassDef
def ab1(param): pass def ab1(param): pass
#! 9 ['param'] #! 9 ['param']
def ab2(param): pass def ab2(param): pass
#! 11 ['param=ClassDef'] #! 11 ['param = ClassDef']
def ab3(a=param): pass def ab3(a=param): pass
ab1(ClassDef);ab2(ClassDef);ab3(ClassDef) ab1(ClassDef);ab2(ClassDef);ab3(ClassDef)