author | Claus Gittinger <cg@exept.de> |
Fri, 12 Apr 2019 05:48:07 +0200 | |
changeset 24063 | 6193bcaef956 |
parent 23309 | 9e8f684dcb62 |
child 24369 | e796791ea838 |
permissions | -rw-r--r-- |
22667 | 1 |
"{ Encoding: utf8 }" |
2 |
||
13425 | 3 |
" |
4 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
5 |
All Rights Reserved |
|
6 |
||
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
11964 | 14 |
"{ Package: 'stx:libbasic' }" |
15 |
||
17448 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
11964 | 18 |
Object subclass:#ProgrammingLanguage |
19 |
instanceVariableNames:'' |
|
20 |
classVariableNames:'LanguageQuerySignal' |
|
21 |
poolDictionaries:'' |
|
22 |
category:'Kernel-Languages' |
|
23 |
! |
|
24 |
||
25 |
ProgrammingLanguage class instanceVariableNames:'Instance' |
|
26 |
||
27 |
" |
|
28 |
No other class instance variables are inherited by this class. |
|
29 |
" |
|
30 |
! |
|
31 |
||
12101 | 32 |
!ProgrammingLanguage class methodsFor:'documentation'! |
33 |
||
13425 | 34 |
copyright |
35 |
" |
|
36 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
37 |
All Rights Reserved |
|
38 |
||
39 |
This software is furnished under a license and may be used |
|
40 |
only in accordance with the terms of that license and with the |
|
41 |
inclusion of the above copyright notice. This software may not |
|
42 |
be provided or otherwise made available to, or used by, any |
|
43 |
other person. No title to or ownership of the software is |
|
44 |
hereby transferred. |
|
45 |
" |
|
46 |
! |
|
47 |
||
12101 | 48 |
documentation |
49 |
" |
|
50 |
provide info about which tools are to be used for code in |
|
51 |
a programming language |
|
52 |
" |
|
53 |
! ! |
|
11964 | 54 |
|
55 |
!ProgrammingLanguage class methodsFor:'initialization'! |
|
56 |
||
57 |
initialize |
|
58 |
||
59 |
LanguageQuerySignal := |
|
60 |
QuerySignal new |
|
61 |
nameClass:self message:#languageQuerySignal; |
|
62 |
notifierString:'asking for current language'; |
|
21051 | 63 |
handlerBlock:[:ex | ex proceedWith:SmalltalkLanguage instance]; |
64 |
yourself. |
|
11964 | 65 |
|
66 |
"Created: / 12-08-2009 / 14:56:11 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
67 |
"Modified: / 16-08-2009 / 10:36:11 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
21051 | 68 |
"Modified: / 25-11-2016 / 15:48:19 / cg" |
11964 | 69 |
! ! |
70 |
||
71 |
!ProgrammingLanguage class methodsFor:'instance creation'! |
|
72 |
||
73 |
forFile: aFilename |
|
12099 | 74 |
"Answers a language for given source file. If none is found, |
11964 | 75 |
SmalltalkLanguage is returned (to provide backward compatibility)" |
76 |
||
77 |
^ self instancesDetect: [:each | each canReadSourceFile: aFilename ] |
|
78 |
ifNone: [ SmalltalkLanguage instance ] |
|
79 |
||
80 |
"Created: / 16-08-2009 / 10:08:44 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
81 |
! |
|
82 |
||
83 |
forStream: aStream |
|
12099 | 84 |
"Answers a language for given source stream. If none is found, |
11964 | 85 |
SmalltalkLanguage is returned (to provide backward compatibility)" |
15663 | 86 |
|
87 |
|inputStream| |
|
88 |
||
89 |
"/ disregard any filters or decoders |
|
90 |
inputStream := aStream inputStream. |
|
91 |
||
92 |
inputStream isFileStream ifFalse: [^ SmalltalkLanguage instance]. |
|
93 |
^ self forFile:inputStream fileName |
|
11964 | 94 |
|
95 |
"Created: / 16-08-2009 / 10:56:26 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
96 |
! |
|
97 |
||
98 |
named: aString |
|
12990 | 99 |
^ self named:aString ifNone:[ self error: 'No language named ' , aString ]. |
11964 | 100 |
|
101 |
" |
|
12989 | 102 |
ProgrammingLanguage named: 'Smalltalk' |
103 |
ProgrammingLanguage named: 'JavaScript' |
|
104 |
ProgrammingLanguage named: 'Ruby' |
|
105 |
" |
|
11964 | 106 |
|
107 |
"Created: / 15-08-2009 / 22:40:26 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
108 |
"Modified: / 16-08-2009 / 10:58:01 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
12990 | 109 |
"Modified: / 04-08-2010 / 12:06:38 / cg" |
11964 | 110 |
! |
111 |
||
112 |
named: aString ifNone: aBlock |
|
113 |
^ self |
|
114 |
instancesDetect:[:each | each name = aString ] |
|
115 |
ifNone: aBlock |
|
116 |
||
117 |
"Created: / 21-08-2009 / 13:07:10 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
118 |
! ! |
|
119 |
||
120 |
!ProgrammingLanguage class methodsFor:'Signal constants'! |
|
121 |
||
122 |
languageQuerySignal |
|
123 |
||
124 |
^LanguageQuerySignal |
|
125 |
||
126 |
"Created: / 12-08-2009 / 14:57:07 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
127 |
! ! |
|
128 |
||
129 |
!ProgrammingLanguage class methodsFor:'accessing'! |
|
130 |
||
131 |
all |
|
132 |
" |
|
133 |
Anwers a collection of all available languages |
|
134 |
" |
|
135 |
||
136 |
^self allSubclasses collect:[:each|each instance] |
|
137 |
||
138 |
||
139 |
" |
|
12099 | 140 |
ProgrammingLanguage all |
11964 | 141 |
" |
142 |
||
143 |
"Created: / 16-08-2009 / 13:43:41 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
144 |
! |
|
145 |
||
146 |
current |
|
147 |
||
148 |
" |
|
12099 | 149 |
ProgrammingLanguage current |
11964 | 150 |
" |
151 |
||
152 |
||
153 |
^LanguageQuerySignal query |
|
154 |
||
155 |
"Created: / 12-08-2009 / 15:02:59 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
156 |
! |
|
157 |
||
158 |
instance |
|
19786 | 159 |
"return this language's singleton" |
11964 | 160 |
|
13819 | 161 |
Instance isNil ifTrue:[Instance := self new]. |
11964 | 162 |
^Instance |
163 |
||
164 |
"Created: / 16-08-2009 / 10:36:37 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
13819 | 165 |
"Modified: / 18-11-2011 / 14:51:59 / cg" |
11964 | 166 |
! ! |
167 |
||
168 |
!ProgrammingLanguage class methodsFor:'enumerating'! |
|
169 |
||
12590 | 170 |
allDetect:aBlock ifNone:exceptionValue |
171 |
self allDo:[:each | (aBlock value:each) ifTrue:[^ each]]. |
|
172 |
^ exceptionValue value |
|
173 |
! |
|
11964 | 174 |
|
12590 | 175 |
allDo: aBlock |
176 |
^ self allSubclassesDo: [:each | aBlock value: each instance] |
|
11964 | 177 |
|
19084 | 178 |
" |
179 |
ProgrammingLanguage allDo:[:l | Transcript showCR:l ] |
|
180 |
" |
|
181 |
||
11964 | 182 |
"Created: / 16-08-2009 / 14:07:40 / Jan Vrany <vranyj1@fel.cvut.cz>" |
183 |
! ! |
|
184 |
||
185 |
!ProgrammingLanguage class methodsFor:'private'! |
|
186 |
||
187 |
instancesDetect: detectBlock ifNone: failBlock |
|
19786 | 188 |
"detect a langauge instance for which detectBlock returns true; |
189 |
failBlock otherwise" |
|
190 |
||
19084 | 191 |
self allSubclasses do:[:cls| |
192 |
|inst| |
|
193 |
inst := cls instance. |
|
194 |
(detectBlock value:inst) ifTrue:[^inst] |
|
195 |
]. |
|
11964 | 196 |
^failBlock value |
197 |
||
198 |
"Created: / 16-08-2009 / 10:57:32 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
199 |
! ! |
|
200 |
||
18914 | 201 |
!ProgrammingLanguage class methodsFor:'queries'! |
202 |
||
203 |
isAbstract |
|
204 |
^ self == ProgrammingLanguage |
|
205 |
! ! |
|
206 |
||
11964 | 207 |
!ProgrammingLanguage class methodsFor:'testing'! |
208 |
||
209 |
isAvailable: langName |
|
210 |
||
211 |
self instancesDetect: [:lang|lang name = langName] ifNone: [^false]. |
|
212 |
^true |
|
213 |
||
214 |
" |
|
215 |
ProgrammingLanguage isAvailable: 'Smalltalk' |
|
216 |
ProgrammingLanguage isAvailable: 'Ruby' |
|
217 |
ProgrammingLanguage isAvailable: 'Haskell' |
|
218 |
" |
|
219 |
||
220 |
"Created: / 21-08-2009 / 12:56:32 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
221 |
! ! |
|
222 |
||
223 |
!ProgrammingLanguage methodsFor:'accessing'! |
|
224 |
||
13425 | 225 |
id |
21795 | 226 |
"Return a unique integer id of this language. |
22677 | 227 |
For languages built into the VM, it must be < 32. |
228 |
This id is used as index to various structures used by runtime |
|
229 |
(bytecode set ?). |
|
230 |
cg: this ought to be better documented - I have no idea, where it is used" |
|
13425 | 231 |
|
232 |
^self subclassResponsibility |
|
233 |
||
234 |
"Created: / 17-03-2011 / 10:51:35 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
21795 | 235 |
"Modified (comment): / 12-06-2017 / 13:40:14 / mawalch" |
22667 | 236 |
"Modified (format): / 12-04-2018 / 09:15:22 / stefan" |
13425 | 237 |
! |
238 |
||
239 |
imports |
|
240 |
||
241 |
"To make it polymorph with NameSpace for |
|
242 |
selector-namespace enabled systems" |
|
243 |
||
244 |
^self class all reject:[:lang|lang == self] |
|
245 |
||
246 |
"Created: / 20-05-2010 / 14:17:35 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
247 |
"Modified: / 19-07-2010 / 12:14:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
248 |
! |
|
249 |
||
250 |
lookup |
|
251 |
||
252 |
^self lookupClass instance |
|
253 |
||
254 |
"Created: / 17-03-2011 / 10:57:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
255 |
! |
|
256 |
||
11964 | 257 |
name |
12099 | 258 |
"Answers a human-readable name of myself: |
11964 | 259 |
'Smalltalk' for SmalltalkLanguage, |
12099 | 260 |
'Ruby' for RubyLanguage |
261 |
... |
|
11964 | 262 |
" |
263 |
||
264 |
^ self subclassResponsibility |
|
265 |
||
266 |
"Created: / 15-08-2009 / 22:38:16 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
267 |
"Modified: / 16-08-2009 / 10:47:21 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
268 |
! |
|
269 |
||
270 |
sourceFileSuffix |
|
12099 | 271 |
"Answers a default suffix for source files, i.e. 'st' for Smalltalk, |
272 |
'js' for JavaScript or 'rb' for Ruby', etc." |
|
11964 | 273 |
|
274 |
^self subclassResponsibility |
|
275 |
||
276 |
"Created: / 16-08-2009 / 10:42:40 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
277 |
! ! |
|
278 |
||
17448 | 279 |
!ProgrammingLanguage methodsFor:'accessing-classes'! |
11964 | 280 |
|
13250 | 281 |
codeGeneratorClass |
282 |
"Answer a class suitable for generating code (such as getters, setters, etc.) |
|
283 |
It is ok to return nil, which means that no code can be generated automagically" |
|
284 |
||
285 |
^ nil |
|
286 |
! |
|
287 |
||
11964 | 288 |
compilerClass |
12099 | 289 |
"Answer a class suitable for compiling a source code in 'my' language" |
11964 | 290 |
|
291 |
^self subclassResponsibility |
|
292 |
||
293 |
"Created: / 21-08-2009 / 13:00:50 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
294 |
! |
|
295 |
||
16817
2b450fc3f12e
Added ProgrammingLanguage>>compilerClassForInteractiveTools
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16503
diff
changeset
|
296 |
compilerClassForInteractiveTools |
2b450fc3f12e
Added ProgrammingLanguage>>compilerClassForInteractiveTools
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16503
diff
changeset
|
297 |
"Answer a compiler class suitable for usage in interactive tools. |
2b450fc3f12e
Added ProgrammingLanguage>>compilerClassForInteractiveTools
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16503
diff
changeset
|
298 |
Such class may better integrate into the IDE and register for undo/redo |
2b450fc3f12e
Added ProgrammingLanguage>>compilerClassForInteractiveTools
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16503
diff
changeset
|
299 |
and/or do more checks and so on. Defaults to #compilerClass" |
2b450fc3f12e
Added ProgrammingLanguage>>compilerClassForInteractiveTools
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16503
diff
changeset
|
300 |
|
2b450fc3f12e
Added ProgrammingLanguage>>compilerClassForInteractiveTools
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16503
diff
changeset
|
301 |
^ self compilerClass |
2b450fc3f12e
Added ProgrammingLanguage>>compilerClassForInteractiveTools
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16503
diff
changeset
|
302 |
|
2b450fc3f12e
Added ProgrammingLanguage>>compilerClassForInteractiveTools
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16503
diff
changeset
|
303 |
"Created: / 05-08-2014 / 16:00:37 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2b450fc3f12e
Added ProgrammingLanguage>>compilerClassForInteractiveTools
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16503
diff
changeset
|
304 |
! |
2b450fc3f12e
Added ProgrammingLanguage>>compilerClassForInteractiveTools
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16503
diff
changeset
|
305 |
|
15537 | 306 |
compilerWithBreakpointSupportClass |
307 |
"Answer a class suitable for compiling a source code with breakpoints |
|
19673 | 308 |
in 'my' language. If there is none, return nil." |
15537 | 309 |
|
310 |
^ nil |
|
311 |
||
312 |
"Created: / 22-07-2013 / 15:45:00 / cg" |
|
313 |
! |
|
314 |
||
12099 | 315 |
evaluatorClass |
316 |
"Answer a class suitable for evaluating a doIt in 'my' language" |
|
317 |
||
318 |
^ self compilerClass |
|
319 |
! |
|
11964 | 320 |
|
12099 | 321 |
explainerClass |
322 |
"Answers a class used by browser and debugger to |
|
323 |
show some hints about the code. It is OK to return |
|
324 |
nil, which means that there is no explainer for given |
|
325 |
language." |
|
11964 | 326 |
|
327 |
"return nil by default" |
|
328 |
^nil |
|
329 |
||
330 |
"Created: / 21-08-2009 / 08:49:13 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
331 |
! |
|
332 |
||
12099 | 333 |
formatterClass |
334 |
"Answer a class suitable for prettyPrinting (indenting) code in 'my' language. |
|
335 |
It is ok to return nil, which means that the browser will not be able to prettyprint." |
|
336 |
||
337 |
^ nil |
|
338 |
! |
|
339 |
||
13425 | 340 |
lookupClass |
341 |
||
342 |
^BuiltinLookup |
|
343 |
||
344 |
"Created: / 17-03-2011 / 10:56:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
345 |
! |
|
346 |
||
13256 | 347 |
metaClass |
348 |
"will be used for new classes (in the class wizard); |
|
349 |
a fallback here" |
|
350 |
||
351 |
^ Metaclass |
|
352 |
||
353 |
"Created: / 30-01-2011 / 10:05:03 / cg" |
|
354 |
! |
|
355 |
||
11964 | 356 |
parserClass |
12099 | 357 |
"Answer a class suitable for parsing a source code in 'my' language" |
11964 | 358 |
|
359 |
^self subclassResponsibility |
|
360 |
||
361 |
"Created: / 21-08-2009 / 13:00:30 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
362 |
! |
|
363 |
||
364 |
sourceFileReaderClass |
|
12099 | 365 |
"Answers a class that can be used for reading & compiling source files" |
11964 | 366 |
|
367 |
^self subclassResponsibility |
|
368 |
||
369 |
"Created: / 16-08-2009 / 09:00:23 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
370 |
! |
|
371 |
||
372 |
sourceFileWriterClass |
|
12099 | 373 |
"Answers a class is used for source file writing (i.e. file-out)" |
11964 | 374 |
|
375 |
^self subclassResponsibility |
|
376 |
||
377 |
"Created: / 16-08-2009 / 09:40:19 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
12099 | 378 |
! |
379 |
||
380 |
syntaxHighlighterClass |
|
16503 | 381 |
"Answers a class used by browser and debugger to colorize code. |
12099 | 382 |
It is OK to return nil, which means that the code is shown as-is" |
383 |
||
384 |
"return nil by default" |
|
385 |
^nil |
|
16332 | 386 |
! |
387 |
||
388 |
valuePrinterClass |
|
389 |
"Answers a class used by the workspace to print a value. |
|
390 |
If nil, the regular printOn: method is called for" |
|
391 |
||
392 |
"return nil by default" |
|
393 |
^ nil |
|
11964 | 394 |
! ! |
395 |
||
16332 | 396 |
|
11964 | 397 |
!ProgrammingLanguage methodsFor:'printing & storing'! |
398 |
||
13425 | 399 |
printOn:aStream |
20216 | 400 |
"append a printed representation of the receiver to the argument, aStream" |
13425 | 401 |
|
402 |
self class printOn: aStream. |
|
403 |
aStream nextPutAll: ' instance' |
|
404 |
||
405 |
"Modified: / 19-06-2010 / 09:54:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
406 |
! |
|
407 |
||
11964 | 408 |
storeOn:aStream |
409 |
||
410 |
self class == ProgrammingLanguage |
|
411 |
ifTrue: |
|
412 |
[super storeOn:aStream] |
|
413 |
ifFalse: |
|
414 |
[aStream |
|
415 |
nextPutAll:'ProgrammingLanguage'; |
|
416 |
nextPutAll:' named: '; |
|
417 |
nextPutAll:self name storeString]. |
|
418 |
||
419 |
" |
|
420 |
ProgrammingLanguage instance storeString |
|
421 |
||
422 |
SmalltalkLanguage instance storeString |
|
423 |
" |
|
424 |
||
425 |
"Created: / 16-08-2009 / 10:52:28 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
426 |
! ! |
|
427 |
||
428 |
!ProgrammingLanguage methodsFor:'queries'! |
|
429 |
||
430 |
canReadSourceFile: aFilename |
|
12099 | 431 |
"Answers true iff file contains source code in 'my' language" |
11964 | 432 |
|
12099 | 433 |
"Trivial implementation here, to be overriden by subclasses" |
11964 | 434 |
|
435 |
^aFilename suffix = self sourceFileSuffix |
|
436 |
||
437 |
"Created: / 16-08-2009 / 10:10:33 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
13425 | 438 |
! |
439 |
||
14553 | 440 |
defaultSelectorNameSpacePrefix |
14549 | 441 |
^ nil "/no namespace by default" |
442 |
! |
|
443 |
||
13425 | 444 |
supportsExtensionMethods |
445 |
||
446 |
"Answer true iff this language supports extension methods" |
|
447 |
||
448 |
^true |
|
449 |
||
450 |
"Created: / 19-03-2011 / 10:02:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
11964 | 451 |
! ! |
452 |
||
14372 | 453 |
!ProgrammingLanguage methodsFor:'source queries'! |
454 |
||
16419 | 455 |
commentStrings |
456 |
^ #( |
|
457 |
'"/' "/ EOL comment |
|
458 |
('"' '"') "/ normal comment |
|
459 |
) |
|
460 |
! |
|
461 |
||
14373
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
462 |
methodDefinitionTemplateForSelector:aSelector |
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
463 |
"given a selector, return a prototype definition string" |
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
464 |
|
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
465 |
|nA argNames| |
14372 | 466 |
|
14373
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
467 |
(nA := aSelector numArgs) == 1 ifTrue:[ |
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
468 |
argNames := #('arg') |
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
469 |
] ifFalse:[ |
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
470 |
argNames := (1 to:nA) collect:[:i | 'arg' , i printString]. |
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
471 |
]. |
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
472 |
^ self |
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
473 |
methodDefinitionTemplateForSelector:aSelector |
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
474 |
andArgumentNames:argNames. |
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
475 |
|
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
476 |
" |
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
477 |
SmalltalkLanguage instance methodDefinitionTemplateForSelector:#foo |
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
478 |
SmalltalkLanguage instance methodDefinitionTemplateForSelector:#+ |
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
479 |
SmalltalkLanguage instance methodDefinitionTemplateForSelector:#foo:bar:baz: |
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
480 |
" |
14372 | 481 |
! |
482 |
||
483 |
methodDefinitionTemplateForSelector:arg1 andArgumentNames:arg2 |
|
484 |
"raise an error: must be redefined in concrete subclass(es)" |
|
485 |
||
486 |
^ self subclassResponsibility |
|
487 |
! ! |
|
488 |
||
11964 | 489 |
!ProgrammingLanguage methodsFor:'testing'! |
490 |
||
18927 | 491 |
isGroovy |
19673 | 492 |
"true iff this is the Groovy language" |
18927 | 493 |
|
494 |
^ false |
|
495 |
||
496 |
"Created: / 13-04-2012 / 17:47:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
497 |
! |
|
498 |
||
13425 | 499 |
isJava |
500 |
"true iff this is the Java language" |
|
501 |
||
502 |
^ false |
|
503 |
||
504 |
"Created: / 17-03-2011 / 10:16:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
505 |
! |
|
506 |
||
18927 | 507 |
isJavaLike |
508 |
"true if receiver is kind of Java language (based on Java)" |
|
509 |
||
510 |
^ false |
|
511 |
||
512 |
"Created: / 13-04-2012 / 17:48:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
513 |
! |
|
514 |
||
13425 | 515 |
isProgrammingLanguage |
516 |
||
517 |
^true |
|
518 |
||
519 |
"Created: / 21-07-2010 / 15:14:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
520 |
! |
|
521 |
||
12151
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
522 |
isRuby |
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
523 |
"true iff this is the ruby language" |
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
524 |
|
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
525 |
^ false |
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
526 |
! |
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
527 |
|
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
528 |
isSTXJavaScript |
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
529 |
"true iff this is the ST/X-javascript language" |
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
530 |
|
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
531 |
^ false |
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
532 |
! |
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
533 |
|
11964 | 534 |
isSmalltalk |
12106 | 535 |
"true iff this is the smalltalk language" |
11964 | 536 |
|
12106 | 537 |
^ false |
11964 | 538 |
|
539 |
"Created: / 16-08-2009 / 09:01:27 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
540 |
! ! |
|
541 |
||
542 |
!ProgrammingLanguage methodsFor:'utilities - file in/file out'! |
|
543 |
||
544 |
fileIn: aFilename |
|
16425 | 545 |
Warning ignoreIn:[ |
546 |
^self sourceFileReaderClass fileIn: aFilename |
|
547 |
]. |
|
11964 | 548 |
|
549 |
"Created: / 16-08-2009 / 13:28:17 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
550 |
! |
|
551 |
||
552 |
fileInStream: aStream |
|
553 |
||
554 |
^self sourceFileReaderClass fileInStream: aStream |
|
555 |
||
556 |
"Created: / 16-08-2009 / 11:05:46 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
557 |
! ! |
|
558 |
||
559 |
!ProgrammingLanguage methodsFor:'utilities - source code'! |
|
560 |
||
23309 | 561 |
methodSourceForVersionMethodCVS:versionString |
562 |
|generatorClass| |
|
563 |
||
564 |
(generatorClass := self codeGeneratorClass) isNil ifTrue:[^ nil]. |
|
565 |
^ generatorClass methodSourceForVersionMethodCVS:versionString |
|
566 |
||
567 |
"Created: / 28-08-2018 / 11:52:41 / Claus Gittinger" |
|
568 |
! |
|
569 |
||
12151
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
570 |
methodTemplate |
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
571 |
"return a method definition template string (or nil)" |
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
572 |
|
19673 | 573 |
"/ cg: I think this should be the codeGeneratorClass - not the writer |
574 |
"/ |writerClass| |
|
575 |
"/ |
|
576 |
"/ (writerClass := self sourceFileWriterClass) isNil ifTrue:[^ nil]. |
|
577 |
"/ ^ writerClass methodTemplate |
|
14327 | 578 |
|
19673 | 579 |
|generatorClass| |
580 |
||
581 |
(generatorClass := self codeGeneratorClass) isNil ifTrue:[^ nil]. |
|
582 |
^ generatorClass methodTemplate |
|
14327 | 583 |
|
584 |
"Modified: / 21-08-2012 / 19:44:41 / cg" |
|
12151
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
585 |
! |
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
586 |
|
19671 | 587 |
methodTemplateForDocumentation |
20980 | 588 |
"return a documentation method definition template string (or nil)" |
19671 | 589 |
|
19673 | 590 |
|generatorClass| |
591 |
||
592 |
(generatorClass := self codeGeneratorClass) isNil ifTrue:[^ nil]. |
|
593 |
^ generatorClass methodTemplateForDocumentation |
|
20980 | 594 |
|
595 |
"Modified (comment): / 18-11-2016 / 10:53:36 / cg" |
|
596 |
! |
|
597 |
||
598 |
methodTemplateForPackageDocumentation |
|
599 |
"return a documentation method definition template string (or nil) for packages" |
|
600 |
||
601 |
|generatorClass| |
|
602 |
||
603 |
(generatorClass := self codeGeneratorClass) isNil ifTrue:[^ nil]. |
|
604 |
^ generatorClass methodTemplateForPackageDocumentation |
|
605 |
||
606 |
"Created: / 18-11-2016 / 10:51:09 / cg" |
|
19673 | 607 |
! |
19671 | 608 |
|
19673 | 609 |
methodTemplateForVersionMethodCVS |
610 |
|generatorClass| |
|
611 |
||
612 |
(generatorClass := self codeGeneratorClass) isNil ifTrue:[^ nil]. |
|
613 |
^ generatorClass methodTemplateForVersionMethodCVS |
|
19671 | 614 |
! |
615 |
||
14151
34a9e574c152
added: #parenthesisSpecificationForEditor
Claus Gittinger <cg@exept.de>
parents:
13819
diff
changeset
|
616 |
parenthesisSpecificationForEditor |
34a9e574c152
added: #parenthesisSpecificationForEditor
Claus Gittinger <cg@exept.de>
parents:
13819
diff
changeset
|
617 |
^ TextView defaultParenthesisSpecification |
34a9e574c152
added: #parenthesisSpecificationForEditor
Claus Gittinger <cg@exept.de>
parents:
13819
diff
changeset
|
618 |
|
34a9e574c152
added: #parenthesisSpecificationForEditor
Claus Gittinger <cg@exept.de>
parents:
13819
diff
changeset
|
619 |
"Created: / 01-06-2012 / 22:52:25 / cg" |
34a9e574c152
added: #parenthesisSpecificationForEditor
Claus Gittinger <cg@exept.de>
parents:
13819
diff
changeset
|
620 |
! |
34a9e574c152
added: #parenthesisSpecificationForEditor
Claus Gittinger <cg@exept.de>
parents:
13819
diff
changeset
|
621 |
|
14322
174a6ab85c33
added: #versionMethodTemplateForCVS
Claus Gittinger <cg@exept.de>
parents:
14151
diff
changeset
|
622 |
versionMethodTemplateForCVS |
19673 | 623 |
<resource: #obsolete> |
14322
174a6ab85c33
added: #versionMethodTemplateForCVS
Claus Gittinger <cg@exept.de>
parents:
14151
diff
changeset
|
624 |
"raise an error: must be redefined in concrete subclass(es)" |
174a6ab85c33
added: #versionMethodTemplateForCVS
Claus Gittinger <cg@exept.de>
parents:
14151
diff
changeset
|
625 |
|
14422 | 626 |
|writerClass| |
14327 | 627 |
|
19673 | 628 |
self obsoleteMethodWarning:'use methodTemplateForVersionMethodCVS'. |
14422 | 629 |
(writerClass := self sourceFileWriterClass) isNil ifTrue:[^ nil]. |
630 |
^ writerClass versionMethodTemplateForCVS |
|
14327 | 631 |
|
632 |
"Modified: / 21-08-2012 / 19:44:51 / cg" |
|
14322
174a6ab85c33
added: #versionMethodTemplateForCVS
Claus Gittinger <cg@exept.de>
parents:
14151
diff
changeset
|
633 |
! |
174a6ab85c33
added: #versionMethodTemplateForCVS
Claus Gittinger <cg@exept.de>
parents:
14151
diff
changeset
|
634 |
|
12106 | 635 |
writeComment:aStringOrStringCollection on:aStream |
12099 | 636 |
"Utility method - writes a comment to a stream, |
637 |
using proper syntax" |
|
14421 | 638 |
|
639 |
|writerClass| |
|
640 |
||
641 |
(writerClass := self sourceFileWriterClass) notNil ifTrue:[ |
|
642 |
writerClass new |
|
643 |
fileOutComment: aStringOrStringCollection |
|
644 |
on: aStream. |
|
645 |
]. |
|
11964 | 646 |
|
647 |
"Created: / 21-08-2009 / 09:35:07 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
648 |
! ! |
|
649 |
||
650 |
!ProgrammingLanguage class methodsFor:'documentation'! |
|
651 |
||
14373
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
652 |
version |
18914 | 653 |
^ '$Header$' |
14373
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
654 |
! |
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
655 |
|
12048 | 656 |
version_CVS |
18914 | 657 |
^ '$Header$' |
12048 | 658 |
! |
659 |
||
660 |
version_SVN |
|
15537 | 661 |
^ '$ Id: ProgrammingLanguage.st 10643 2011-06-08 21:53:07Z vranyj1 $' |
11964 | 662 |
! ! |
663 |
||
15537 | 664 |
|
11964 | 665 |
ProgrammingLanguage initialize! |