9981
|
1 |
"
|
|
2 |
COPYRIGHT (c) 2006 by eXept Software AG
|
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
"{ Package: 'stx:libtool' }"
|
|
13 |
|
|
14 |
"{ NameSpace: Tools }"
|
|
15 |
|
|
16 |
CodeViewService subclass:#CodeCompletionService
|
|
17 |
instanceVariableNames:''
|
|
18 |
classVariableNames:''
|
|
19 |
poolDictionaries:''
|
|
20 |
category:'Interface-CodeView'
|
|
21 |
!
|
|
22 |
|
|
23 |
!CodeCompletionService class methodsFor:'documentation'!
|
|
24 |
|
|
25 |
copyright
|
|
26 |
"
|
|
27 |
COPYRIGHT (c) 2006 by eXept Software AG
|
|
28 |
All Rights Reserved
|
|
29 |
|
|
30 |
This software is furnished under a license and may be used
|
|
31 |
only in accordance with the terms of that license and with the
|
|
32 |
inclusion of the above copyright notice. This software may not
|
|
33 |
be provided or otherwise made available to, or used by, any
|
|
34 |
other person. No title to or ownership of the software is
|
|
35 |
hereby transferred.
|
|
36 |
"
|
|
37 |
! !
|
|
38 |
|
|
39 |
!CodeCompletionService class methodsFor:'accessing'!
|
|
40 |
|
|
41 |
label
|
|
42 |
|
|
43 |
"Answers short label - for UI"
|
|
44 |
|
|
45 |
^'Code Completion'
|
|
46 |
|
|
47 |
"Created: / 07-03-2010 / 14:00:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
48 |
! !
|
|
49 |
|
|
50 |
!CodeCompletionService class methodsFor:'testing'!
|
|
51 |
|
|
52 |
isAvailable
|
|
53 |
|
|
54 |
"CodeCompletionService is superseded by SmallSense"
|
|
55 |
|
|
56 |
^(Smalltalk at:#SmallSenseService) isNil
|
|
57 |
|
|
58 |
"Created: / 03-04-2011 / 23:08:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
59 |
! !
|
|
60 |
|
|
61 |
!CodeCompletionService methodsFor:'event handling'!
|
|
62 |
|
|
63 |
keyPress: key x:x y:y in: view
|
|
64 |
|
|
65 |
"Handles an event in given view (a subview of codeView).
|
|
66 |
If the method returns true, the event will not be processed
|
|
67 |
by the view."
|
|
68 |
|
|
69 |
(view == textView and:[key == #'CodeCompletion']) ifTrue:
|
|
70 |
[self complete. ^true].
|
|
71 |
^false
|
|
72 |
|
|
73 |
"Created: / 07-03-2010 / 09:36:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
74 |
! !
|
|
75 |
|
|
76 |
!CodeCompletionService methodsFor:'private'!
|
|
77 |
|
|
78 |
complete
|
|
79 |
|cls
|
|
80 |
"/ crsrPos interval node checkedNode
|
|
81 |
"/ char start stop selectorSoFar matchingSelectors
|
|
82 |
|
|
|
83 |
|
|
84 |
codeView languageHolder value == SmalltalkLanguage instance
|
|
85 |
ifFalse:[^self].
|
|
86 |
|
|
87 |
cls := codeView classHolder value.
|
|
88 |
cls isNil ifTrue:[
|
|
89 |
self showInfo:'No class'.
|
|
90 |
^ self.
|
|
91 |
].
|
|
92 |
UserInformation handle:[:ex |
|
|
93 |
codeView showInfo:(ex messageText).
|
|
94 |
ex proceed.
|
|
95 |
] do:[
|
|
96 |
codeView withWaitCursorDo:[
|
|
97 |
DoWhatIMeanSupport codeCompletionForClass:cls codeView:textView.
|
|
98 |
]
|
|
99 |
].
|
|
100 |
^ self.
|
|
101 |
|
|
102 |
"/
|
|
103 |
"/ interval := self selectedInterval.
|
|
104 |
"/ interval isEmpty ifTrue:[
|
|
105 |
"/ crsrPos := codeView characterPositionOfCursor - 1.
|
|
106 |
"/ char := codeView characterUnderCursor.
|
|
107 |
"/ [crsrPos > 1 and:[char isSeparator or:['.' includes:char]]] whileTrue:[
|
|
108 |
"/ crsrPos := crsrPos - 1.
|
|
109 |
"/ char := codeView characterAtCharacterPosition:crsrPos.
|
|
110 |
"/ ].
|
|
111 |
"/ interval := crsrPos to:crsrPos.
|
|
112 |
"/ ].
|
|
113 |
"/
|
|
114 |
"/ node := self findNodeForInterval:interval allowErrors:true.
|
|
115 |
"/ [node isNil] whileTrue:[
|
|
116 |
"/ "/ expand to the left ...
|
|
117 |
"/ interval start > 1 ifFalse:[
|
|
118 |
"/ self showInfo:'No parseNode found'.
|
|
119 |
"/ ^ self.
|
|
120 |
"/ ].
|
|
121 |
"/ interval start:(interval start - 1).
|
|
122 |
"/ node := self findNodeForInterval:interval allowErrors:true.
|
|
123 |
"/ ].
|
|
124 |
"/
|
|
125 |
"/ node isVariable ifTrue:[
|
|
126 |
"/ self codeCompletionForVariable:node inClass:cls.
|
|
127 |
"/ ^ self.
|
|
128 |
"/ ].
|
|
129 |
"/
|
|
130 |
"/ checkedNode := node.
|
|
131 |
"/ [checkedNode notNil] whileTrue:[
|
|
132 |
"/ checkedNode isMessage ifTrue:[
|
|
133 |
"/ self codeCompletionForMessage:checkedNode inClass:cls.
|
|
134 |
"/ ^ self
|
|
135 |
"/ ].
|
|
136 |
"/ checkedNode isMethod ifTrue:[
|
|
137 |
"/ self codeCompletionForMethod:checkedNode inClass:cls.
|
|
138 |
"/ ^ self.
|
|
139 |
"/ ].
|
|
140 |
"/ checkedNode := checkedNode parent.
|
|
141 |
"/ ].
|
|
142 |
"/
|
|
143 |
"/ self showInfo:'Node is neither variable nor message.'.
|
|
144 |
|
|
145 |
"Modified: / 04-07-2006 / 18:48:26 / fm"
|
|
146 |
"Modified: / 20-11-2006 / 12:30:59 / cg"
|
|
147 |
"Created: / 07-03-2010 / 09:37:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
148 |
! !
|
|
149 |
|
|
150 |
!CodeCompletionService class methodsFor:'documentation'!
|
|
151 |
|
|
152 |
version_CVS
|
|
153 |
^ '$Header: /cvs/stx/stx/libtool/Tools__CodeCompletionService.st,v 1.1 2011-07-01 13:20:28 cg Exp $'
|
|
154 |
!
|
|
155 |
|
|
156 |
version_SVN
|
|
157 |
^ '§Id: Tools__CodeCompletionService.st 7695 2011-04-04 20:09:17Z vranyj1 §'
|
|
158 |
! !
|