16
16
__author__ = "Cody Precord <cprecord@editra.org>"
17
__svnid__ = "$Id: completer.py 63531 2010-02-21 15:48:53Z CJP $"
18
__revision__ = "$Revision: 63531 $"
17
__svnid__ = "$Id: completer.py 67701 2011-05-04 20:50:14Z CJP $"
18
__revision__ = "$Revision: 67701 $"
20
20
__all__ = [ 'TYPE_FUNCTION', 'TYPE_METHOD', 'TYPE_CLASS', 'TYPE_ATTRIBUTE',
21
21
'TYPE_VARIABLE', 'TYPE_ELEMENT', 'TYPE_PROPERTY', 'TYPE_UNKNOWN',
44
44
Symbol hash is based on symbol NAME
47
def __init__(self, name, type):
47
# we create lots of these so use slots as a performance tweak
48
__slots__ = ('_name', '_type')
50
def __init__(self, name, symtype):
49
@param Name: Symbol name
50
@param Type: Symbol type, one of the TYPE_FUNCTION ... TYPE_UNKNOWN range
52
@param name: Symbol name
53
@param symtype: Symbol type, one of the TYPE_FUNCTION ... TYPE_UNKNOWN range
56
super(Symbol, self).__init__()
56
self.__name = unicode(name)
59
self._name = unicode(name)
59
62
def __eq__(self, other):
60
return (self.__name == other.__name)
63
return (self.Name == other.Name)
62
65
def __lt__(self, other):
63
return (self.__name < other.__name)
66
return (self.Name < other.Name)
65
68
def __le__(self, other):
66
return (self.__name <= other.__name)
69
return (self.Name <= other.Name)
68
71
def __ne__(self, other):
69
return (self.__name != other.__name)
72
return (self.Name != other.Name)
71
74
def __gt__(self, other):
72
return (self.__name > other.__name)
75
return (self.Name > other.Name)
74
77
def __ge__(self, other):
75
return (self.__name >= other.__name)
78
return (self.Name >= other.Name)
77
80
# TODO: this task should probably be delegated to the ui
79
if self.__type != TYPE_UNKNOWN:
80
return u'?'.join([self.__name, unicode(self.__type)])
82
if self.Type != TYPE_UNKNOWN:
83
return u'?'.join([self.Name, unicode(self.Type)])
84
87
def __hash__(self):
85
return self.__name.__hash__()
88
return hash(self.Name)
90
Name = property(lambda self: self._name,
91
lambda self, n: setattr(self, '_name', n))
92
Type = property(lambda self: self._type,
93
lambda self, t: setattr(self, '_type', t))
95
95
#--------------------------------------------------------------------------#
108
108
class BaseCompleter(object):
109
109
"""Base Autocomp provider class"""
110
110
def __init__(self, parent):
111
"""Initializes the autocompletion service
111
"""Initializes the auto-completion service
112
112
@param parent: parent of this service object
115
object.__init__(self)
115
super(BaseCompleter, self).__init__()
118
118
self._buffer = parent
164
164
return self._autocomp_keys
166
def IsCallTipEvent(self, evt):
167
"""Should a calltip be shown for the given key combo"""
168
if evt.ControlDown() and evt.GetKeyCode() == ord('9'):
172
def IsAutoCompEvent(self, evt):
173
"""Is it a key combination that should allow completions to be shown
174
@param evt: wx.KeyEvent
176
@todo: this shoud probably be handled in edstc
179
if evt.ControlDown() and evt.GetKeyCode() == wx.WXK_SPACE:
183
166
def SetAutoCompKeys(self, key_list):
184
167
"""Set the keys to provide completions on
185
168
@param key_list: List of key codes