File tree Expand file tree Collapse file tree 2 files changed +26
-25
lines changed Expand file tree Collapse file tree 2 files changed +26
-25
lines changed Original file line number Diff line number Diff line change 99
1010module IRB
1111 class BaseCompletor # :nodoc:
12+
13+ # Set of reserved words used by Ruby, you should not use these for
14+ # constants or variables
15+ ReservedWords = %w[
16+ __ENCODING__ __LINE__ __FILE__
17+ BEGIN END
18+ alias and
19+ begin break
20+ case class
21+ def defined? do
22+ else elsif end ensure
23+ false for
24+ if in
25+ module
26+ next nil not
27+ or
28+ redo rescue retry return
29+ self super
30+ then true
31+ undef unless until
32+ when while
33+ yield
34+ ]
35+
1236 def completion_candidates ( preposing , target , postposing , bind :)
1337 raise NotImplementedError
1438 end
@@ -98,29 +122,6 @@ def inspect
98122 'RegexpCompletor'
99123 end
100124
101- # Set of reserved words used by Ruby, you should not use these for
102- # constants or variables
103- ReservedWords = %w[
104- __ENCODING__ __LINE__ __FILE__
105- BEGIN END
106- alias and
107- begin break
108- case class
109- def defined? do
110- else elsif end ensure
111- false for
112- if in
113- module
114- next nil not
115- or
116- redo rescue retry return
117- self super
118- then true
119- undef unless until
120- when while
121- yield
122- ]
123-
124125 def complete_require_path ( target , preposing , postposing )
125126 if target =~ /\A (['"])([^'"]+)\Z /
126127 quote = $1
Original file line number Diff line number Diff line change @@ -120,7 +120,7 @@ def candidates_from_result(result)
120120 end
121121 ( scope_constants . compact | type . constants . map ( &:to_s ) ) . sort
122122 else
123- scope . constants . sort
123+ scope . constants . sort | ReservedWords
124124 end
125125 in [ :ivar , name , scope ]
126126 ivars = scope . instance_variables . sort
@@ -134,7 +134,7 @@ def candidates_from_result(result)
134134 in [ :call , type , name , self_call ]
135135 ( self_call ? type . all_methods : type . methods ) . map ( &:to_s ) - HIDDEN_METHODS
136136 in [ :lvar_or_method , name , scope ]
137- scope . self_type . all_methods . map ( &:to_s ) | scope . local_variables
137+ scope . self_type . all_methods . map ( &:to_s ) | scope . local_variables | ReservedWords
138138 else
139139 [ ]
140140 end
You can’t perform that action at this time.
0 commit comments