/
RBVariableNode.extension.st
82 lines (70 loc) · 2.76 KB
/
RBVariableNode.extension.st
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
Extension { #name : #RBVariableNode }
{ #category : #'*NECompletion' }
RBVariableNode >> argEntriesForMethodNode: aMethodNode [
^ aMethodNode argumentNames
select: [ :each | each beginsWith: self name ]
thenCollect: [ :each | NECLocalEntry contents: each node: self ]
]
{ #category : #'*NECompletion' }
RBVariableNode >> classVarEntriesForClass: lookupClass [
^ lookupClass allClassVarNames
select: [ :each | each beginsWith: self name ]
thenCollect: [ :each | NECClassVarEntry contents: each node: self ]
]
{ #category : #'*NECompletion' }
RBVariableNode >> completionEntries: offset [
| methodNode lookupClass |
methodNode := self methodNode.
lookupClass := methodNode compilationContext getClass.
(self isDefinition or: [self isArgument])
ifTrue: [ ^ self possibleSelectorEntries ].
^ Array streamContents: [ :str |
str
nextPutAll: (self globalEntries);
nextPutAll: (self slotEntriesForClass: lookupClass);
nextPutAll: (self tempEntriesForMethodNode: methodNode);
nextPutAll: (self argEntriesForMethodNode: methodNode);
nextPutAll: (self entriesSpecialVariables);
nextPutAll: (self classVarEntriesForClass: lookupClass);
nextPutAll: (self poolVarEntriesForClass: lookupClass) ]
]
{ #category : #'*NECompletion' }
RBVariableNode >> completionToken: offset [
^ self name
]
{ #category : #'*NECompletion' }
RBVariableNode >> entriesSpecialVariables [
^ #('self' 'super' 'thisContext' 'nil' 'false' 'true')
select: [ :each | each beginsWith: self name ]
thenCollect: [ :each | NECSpecialVariableEntry contents: each node: self ]
]
{ #category : #'*NECompletion' }
RBVariableNode >> globalEntries [
^ Smalltalk globals keys
select: [ :each | each beginsWith: self name ]
thenCollect: [ :each | NECGlobalEntry contents: each node: self ]
]
{ #category : #'*NECompletion' }
RBVariableNode >> poolVarEntriesForClass: lookupClass [
^ (lookupClass allSharedPools flatCollect: [ :each | each classVarNames ])
select: [ :each | each beginsWith: self name ]
thenCollect: [ :each | NECClassVarEntry contents: each node: self ]
]
{ #category : #'*NECompletion' }
RBVariableNode >> possibleSelectorEntries [
^ Symbol allSymbols
select: [ :each | (each beginsWith: self name) and: [ each contents numArgs = 0 ] ]
thenCollect: [ :each | NECSymbolEntry contents: each node: self ]
]
{ #category : #'*NECompletion' }
RBVariableNode >> slotEntriesForClass: lookupClass [
^lookupClass
allSlots select: [ :each | each name beginsWith: self name ]
thenCollect: [ :each | NECInstVarEntry contents: each name node: self ]
]
{ #category : #'*NECompletion' }
RBVariableNode >> tempEntriesForMethodNode: aMethodNode [
^ aMethodNode temporaryNames
select: [ :each | each beginsWith: self name ]
thenCollect: [ :each | NECLocalEntry contents: each node: self ]
]