author | Stefan Vogel <sv@exept.de> |
Tue, 28 Apr 2020 16:21:34 +0200 | |
changeset 25373 | f030619565e1 |
parent 25324 | b9409aeae969 |
permissions | -rw-r--r-- |
25324 | 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 |
|
24372 | 132 |
"Anwers a collection of all available languages" |
11964 | 133 |
|
134 |
^self allSubclasses collect:[:each|each instance] |
|
135 |
||
136 |
||
137 |
" |
|
12099 | 138 |
ProgrammingLanguage all |
11964 | 139 |
" |
140 |
||
141 |
"Created: / 16-08-2009 / 13:43:41 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
24372 | 142 |
"Modified (comment): / 27-06-2019 / 12:29:36 / Claus Gittinger" |
143 |
! |
|
144 |
||
145 |
allSortedByNameExcept:filterBlock |
|
146 |
"Anwers a collection of all available languages" |
|
147 |
||
148 |
|allLanguages| |
|
149 |
||
150 |
allLanguages := OrderedCollection new. |
|
151 |
self allDo:[:eachLanguage | |
|
152 |
(filterBlock value:eachLanguage) ifFalse:[ |
|
153 |
allLanguages add:eachLanguage |
|
154 |
] |
|
155 |
]. |
|
156 |
allLanguages sort:[:a :b | a name < b name]. |
|
157 |
^ allLanguages |
|
158 |
||
159 |
||
160 |
" |
|
161 |
ProgrammingLanguage allSortedByNameExcept:#isSmalltalk |
|
162 |
" |
|
163 |
||
164 |
"Created: / 27-06-2019 / 12:31:18 / Claus Gittinger" |
|
11964 | 165 |
! |
166 |
||
167 |
current |
|
168 |
||
169 |
" |
|
12099 | 170 |
ProgrammingLanguage current |
11964 | 171 |
" |
172 |
||
173 |
||
174 |
^LanguageQuerySignal query |
|
175 |
||
176 |
"Created: / 12-08-2009 / 15:02:59 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
177 |
! |
|
178 |
||
179 |
instance |
|
19786 | 180 |
"return this language's singleton" |
11964 | 181 |
|
13819 | 182 |
Instance isNil ifTrue:[Instance := self new]. |
11964 | 183 |
^Instance |
184 |
||
185 |
"Created: / 16-08-2009 / 10:36:37 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
13819 | 186 |
"Modified: / 18-11-2011 / 14:51:59 / cg" |
11964 | 187 |
! ! |
188 |
||
189 |
!ProgrammingLanguage class methodsFor:'enumerating'! |
|
190 |
||
12590 | 191 |
allDetect:aBlock ifNone:exceptionValue |
192 |
self allDo:[:each | (aBlock value:each) ifTrue:[^ each]]. |
|
193 |
^ exceptionValue value |
|
194 |
! |
|
11964 | 195 |
|
12590 | 196 |
allDo: aBlock |
197 |
^ self allSubclassesDo: [:each | aBlock value: each instance] |
|
11964 | 198 |
|
19084 | 199 |
" |
200 |
ProgrammingLanguage allDo:[:l | Transcript showCR:l ] |
|
201 |
" |
|
202 |
||
11964 | 203 |
"Created: / 16-08-2009 / 14:07:40 / Jan Vrany <vranyj1@fel.cvut.cz>" |
204 |
! ! |
|
205 |
||
206 |
!ProgrammingLanguage class methodsFor:'private'! |
|
207 |
||
208 |
instancesDetect: detectBlock ifNone: failBlock |
|
19786 | 209 |
"detect a langauge instance for which detectBlock returns true; |
210 |
failBlock otherwise" |
|
211 |
||
25324 | 212 |
self allSubclassesDo:[:cls| |
19084 | 213 |
|inst| |
214 |
inst := cls instance. |
|
25324 | 215 |
(detectBlock value:inst) ifTrue:[^ inst] |
19084 | 216 |
]. |
25324 | 217 |
^ failBlock value |
11964 | 218 |
|
219 |
"Created: / 16-08-2009 / 10:57:32 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
25324 | 220 |
"Modified (format): / 06-03-2020 / 17:15:24 / Stefan Vogel" |
11964 | 221 |
! ! |
222 |
||
18914 | 223 |
!ProgrammingLanguage class methodsFor:'queries'! |
224 |
||
225 |
isAbstract |
|
226 |
^ self == ProgrammingLanguage |
|
227 |
! ! |
|
228 |
||
11964 | 229 |
!ProgrammingLanguage class methodsFor:'testing'! |
230 |
||
231 |
isAvailable: langName |
|
232 |
||
233 |
self instancesDetect: [:lang|lang name = langName] ifNone: [^false]. |
|
234 |
^true |
|
235 |
||
236 |
" |
|
237 |
ProgrammingLanguage isAvailable: 'Smalltalk' |
|
238 |
ProgrammingLanguage isAvailable: 'Ruby' |
|
239 |
ProgrammingLanguage isAvailable: 'Haskell' |
|
240 |
" |
|
241 |
||
242 |
"Created: / 21-08-2009 / 12:56:32 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
243 |
! ! |
|
244 |
||
245 |
!ProgrammingLanguage methodsFor:'accessing'! |
|
246 |
||
13425 | 247 |
id |
21795 | 248 |
"Return a unique integer id of this language. |
22677 | 249 |
For languages built into the VM, it must be < 32. |
250 |
This id is used as index to various structures used by runtime |
|
251 |
(bytecode set ?). |
|
252 |
cg: this ought to be better documented - I have no idea, where it is used" |
|
13425 | 253 |
|
254 |
^self subclassResponsibility |
|
255 |
||
256 |
"Created: / 17-03-2011 / 10:51:35 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
21795 | 257 |
"Modified (comment): / 12-06-2017 / 13:40:14 / mawalch" |
22667 | 258 |
"Modified (format): / 12-04-2018 / 09:15:22 / stefan" |
13425 | 259 |
! |
260 |
||
261 |
imports |
|
262 |
||
263 |
"To make it polymorph with NameSpace for |
|
264 |
selector-namespace enabled systems" |
|
265 |
||
266 |
^self class all reject:[:lang|lang == self] |
|
267 |
||
268 |
"Created: / 20-05-2010 / 14:17:35 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
269 |
"Modified: / 19-07-2010 / 12:14:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
270 |
! |
|
271 |
||
272 |
lookup |
|
273 |
||
274 |
^self lookupClass instance |
|
275 |
||
276 |
"Created: / 17-03-2011 / 10:57:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
277 |
! |
|
278 |
||
11964 | 279 |
name |
12099 | 280 |
"Answers a human-readable name of myself: |
11964 | 281 |
'Smalltalk' for SmalltalkLanguage, |
12099 | 282 |
'Ruby' for RubyLanguage |
283 |
... |
|
24372 | 284 |
Here, a fallback using the class name is generated. |
11964 | 285 |
" |
286 |
||
24372 | 287 |
|nm| |
288 |
||
289 |
nm := self class nameWithoutPrefix. |
|
290 |
nm := nm withoutSuffix:'Language'. |
|
291 |
nm := nm withoutSuffix:'Programming'. |
|
292 |
^ nm |
|
11964 | 293 |
|
294 |
"Created: / 15-08-2009 / 22:38:16 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
295 |
"Modified: / 16-08-2009 / 10:47:21 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
24372 | 296 |
"Modified: / 27-06-2019 / 12:21:31 / Claus Gittinger" |
11964 | 297 |
! |
298 |
||
299 |
sourceFileSuffix |
|
12099 | 300 |
"Answers a default suffix for source files, i.e. 'st' for Smalltalk, |
301 |
'js' for JavaScript or 'rb' for Ruby', etc." |
|
11964 | 302 |
|
303 |
^self subclassResponsibility |
|
304 |
||
305 |
"Created: / 16-08-2009 / 10:42:40 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
306 |
! ! |
|
307 |
||
17448 | 308 |
!ProgrammingLanguage methodsFor:'accessing-classes'! |
11964 | 309 |
|
13250 | 310 |
codeGeneratorClass |
311 |
"Answer a class suitable for generating code (such as getters, setters, etc.) |
|
312 |
It is ok to return nil, which means that no code can be generated automagically" |
|
313 |
||
314 |
^ nil |
|
315 |
! |
|
316 |
||
11964 | 317 |
compilerClass |
24372 | 318 |
"Answer a class suitable for compiling a source code in 'my' language. |
319 |
If nil is returned, no compiler is available (eg. language is for editors only)" |
|
11964 | 320 |
|
24372 | 321 |
^ nil |
11964 | 322 |
|
323 |
"Created: / 21-08-2009 / 13:00:50 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
24372 | 324 |
"Modified: / 27-06-2019 / 12:27:31 / Claus Gittinger" |
11964 | 325 |
! |
326 |
||
16817
2b450fc3f12e
Added ProgrammingLanguage>>compilerClassForInteractiveTools
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16503
diff
changeset
|
327 |
compilerClassForInteractiveTools |
2b450fc3f12e
Added ProgrammingLanguage>>compilerClassForInteractiveTools
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16503
diff
changeset
|
328 |
"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
|
329 |
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
|
330 |
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
|
331 |
|
2b450fc3f12e
Added ProgrammingLanguage>>compilerClassForInteractiveTools
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16503
diff
changeset
|
332 |
^ self compilerClass |
2b450fc3f12e
Added ProgrammingLanguage>>compilerClassForInteractiveTools
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16503
diff
changeset
|
333 |
|
2b450fc3f12e
Added ProgrammingLanguage>>compilerClassForInteractiveTools
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16503
diff
changeset
|
334 |
"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
|
335 |
! |
2b450fc3f12e
Added ProgrammingLanguage>>compilerClassForInteractiveTools
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16503
diff
changeset
|
336 |
|
15537 | 337 |
compilerWithBreakpointSupportClass |
338 |
"Answer a class suitable for compiling a source code with breakpoints |
|
19673 | 339 |
in 'my' language. If there is none, return nil." |
15537 | 340 |
|
341 |
^ nil |
|
342 |
||
343 |
"Created: / 22-07-2013 / 15:45:00 / cg" |
|
344 |
! |
|
345 |
||
12099 | 346 |
evaluatorClass |
347 |
"Answer a class suitable for evaluating a doIt in 'my' language" |
|
348 |
||
349 |
^ self compilerClass |
|
350 |
! |
|
11964 | 351 |
|
12099 | 352 |
explainerClass |
353 |
"Answers a class used by browser and debugger to |
|
354 |
show some hints about the code. It is OK to return |
|
355 |
nil, which means that there is no explainer for given |
|
356 |
language." |
|
11964 | 357 |
|
358 |
"return nil by default" |
|
359 |
^nil |
|
360 |
||
361 |
"Created: / 21-08-2009 / 08:49:13 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
362 |
! |
|
363 |
||
12099 | 364 |
formatterClass |
365 |
"Answer a class suitable for prettyPrinting (indenting) code in 'my' language. |
|
366 |
It is ok to return nil, which means that the browser will not be able to prettyprint." |
|
367 |
||
368 |
^ nil |
|
369 |
! |
|
370 |
||
13425 | 371 |
lookupClass |
372 |
||
373 |
^BuiltinLookup |
|
374 |
||
375 |
"Created: / 17-03-2011 / 10:56:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
376 |
! |
|
377 |
||
13256 | 378 |
metaClass |
379 |
"will be used for new classes (in the class wizard); |
|
380 |
a fallback here" |
|
381 |
||
382 |
^ Metaclass |
|
383 |
||
384 |
"Created: / 30-01-2011 / 10:05:03 / cg" |
|
385 |
! |
|
386 |
||
11964 | 387 |
parserClass |
12099 | 388 |
"Answer a class suitable for parsing a source code in 'my' language" |
11964 | 389 |
|
390 |
^self subclassResponsibility |
|
391 |
||
392 |
"Created: / 21-08-2009 / 13:00:30 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
393 |
! |
|
394 |
||
395 |
sourceFileReaderClass |
|
12099 | 396 |
"Answers a class that can be used for reading & compiling source files" |
11964 | 397 |
|
398 |
^self subclassResponsibility |
|
399 |
||
400 |
"Created: / 16-08-2009 / 09:00:23 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
401 |
! |
|
402 |
||
403 |
sourceFileWriterClass |
|
12099 | 404 |
"Answers a class is used for source file writing (i.e. file-out)" |
11964 | 405 |
|
406 |
^self subclassResponsibility |
|
407 |
||
408 |
"Created: / 16-08-2009 / 09:40:19 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
12099 | 409 |
! |
410 |
||
411 |
syntaxHighlighterClass |
|
16503 | 412 |
"Answers a class used by browser and debugger to colorize code. |
12099 | 413 |
It is OK to return nil, which means that the code is shown as-is" |
414 |
||
415 |
"return nil by default" |
|
416 |
^nil |
|
16332 | 417 |
! |
418 |
||
419 |
valuePrinterClass |
|
420 |
"Answers a class used by the workspace to print a value. |
|
24666 | 421 |
If nil, the regular printOn: method is called on the result object. |
422 |
If provided, it should respond to printStringForPrintItOf:result" |
|
16332 | 423 |
|
424 |
"return nil by default" |
|
425 |
^ nil |
|
11964 | 426 |
! ! |
427 |
||
16332 | 428 |
|
11964 | 429 |
!ProgrammingLanguage methodsFor:'printing & storing'! |
430 |
||
13425 | 431 |
printOn:aStream |
20216 | 432 |
"append a printed representation of the receiver to the argument, aStream" |
13425 | 433 |
|
434 |
self class printOn: aStream. |
|
435 |
aStream nextPutAll: ' instance' |
|
436 |
||
437 |
"Modified: / 19-06-2010 / 09:54:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
438 |
! |
|
439 |
||
11964 | 440 |
storeOn:aStream |
441 |
||
442 |
self class == ProgrammingLanguage |
|
443 |
ifTrue: |
|
444 |
[super storeOn:aStream] |
|
445 |
ifFalse: |
|
446 |
[aStream |
|
447 |
nextPutAll:'ProgrammingLanguage'; |
|
448 |
nextPutAll:' named: '; |
|
449 |
nextPutAll:self name storeString]. |
|
450 |
||
451 |
" |
|
452 |
ProgrammingLanguage instance storeString |
|
453 |
||
454 |
SmalltalkLanguage instance storeString |
|
455 |
" |
|
456 |
||
457 |
"Created: / 16-08-2009 / 10:52:28 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
458 |
! ! |
|
459 |
||
460 |
!ProgrammingLanguage methodsFor:'queries'! |
|
461 |
||
25163 | 462 |
canBeCompiled |
463 |
"true if compilable in the browser" |
|
464 |
||
465 |
^ false |
|
466 |
! |
|
467 |
||
11964 | 468 |
canReadSourceFile: aFilename |
12099 | 469 |
"Answers true iff file contains source code in 'my' language" |
11964 | 470 |
|
12099 | 471 |
"Trivial implementation here, to be overriden by subclasses" |
11964 | 472 |
|
473 |
^aFilename suffix = self sourceFileSuffix |
|
474 |
||
475 |
"Created: / 16-08-2009 / 10:10:33 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
13425 | 476 |
! |
477 |
||
14553 | 478 |
defaultSelectorNameSpacePrefix |
14549 | 479 |
^ nil "/no namespace by default" |
480 |
! |
|
481 |
||
13425 | 482 |
supportsExtensionMethods |
483 |
||
484 |
"Answer true iff this language supports extension methods" |
|
485 |
||
486 |
^true |
|
487 |
||
488 |
"Created: / 19-03-2011 / 10:02:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
11964 | 489 |
! ! |
490 |
||
14372 | 491 |
!ProgrammingLanguage methodsFor:'source queries'! |
492 |
||
24369 | 493 |
bracketStrings |
494 |
"used for autoindent" |
|
495 |
||
496 |
^ #( |
|
497 |
) |
|
498 |
||
499 |
"Created: / 26-06-2019 / 22:03:57 / Claus Gittinger" |
|
500 |
! |
|
501 |
||
16419 | 502 |
commentStrings |
503 |
^ #( |
|
504 |
'"/' "/ EOL comment |
|
505 |
('"' '"') "/ normal comment |
|
506 |
) |
|
507 |
! |
|
508 |
||
14373
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
509 |
methodDefinitionTemplateForSelector:aSelector |
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
510 |
"given a selector, return a prototype definition string" |
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
511 |
|
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
512 |
|nA argNames| |
14372 | 513 |
|
24749 | 514 |
(nA := aSelector argumentCount) == 1 ifTrue:[ |
14373
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
515 |
argNames := #('arg') |
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
516 |
] ifFalse:[ |
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
517 |
argNames := (1 to:nA) collect:[:i | 'arg' , i printString]. |
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
518 |
]. |
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
519 |
^ self |
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
520 |
methodDefinitionTemplateForSelector:aSelector |
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
521 |
andArgumentNames:argNames. |
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
522 |
|
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
523 |
" |
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
524 |
SmalltalkLanguage instance methodDefinitionTemplateForSelector:#foo |
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
525 |
SmalltalkLanguage instance methodDefinitionTemplateForSelector:#+ |
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
526 |
SmalltalkLanguage instance methodDefinitionTemplateForSelector:#foo:bar:baz: |
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
527 |
" |
14372 | 528 |
! |
529 |
||
530 |
methodDefinitionTemplateForSelector:arg1 andArgumentNames:arg2 |
|
531 |
"raise an error: must be redefined in concrete subclass(es)" |
|
532 |
||
533 |
^ self subclassResponsibility |
|
534 |
! ! |
|
535 |
||
11964 | 536 |
!ProgrammingLanguage methodsFor:'testing'! |
537 |
||
18927 | 538 |
isGroovy |
19673 | 539 |
"true iff this is the Groovy language" |
18927 | 540 |
|
541 |
^ false |
|
542 |
||
543 |
"Created: / 13-04-2012 / 17:47:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
544 |
! |
|
545 |
||
13425 | 546 |
isJava |
547 |
"true iff this is the Java language" |
|
548 |
||
549 |
^ false |
|
550 |
||
551 |
"Created: / 17-03-2011 / 10:16:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
552 |
! |
|
553 |
||
18927 | 554 |
isJavaLike |
555 |
"true if receiver is kind of Java language (based on Java)" |
|
556 |
||
557 |
^ false |
|
558 |
||
559 |
"Created: / 13-04-2012 / 17:48:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
560 |
! |
|
561 |
||
13425 | 562 |
isProgrammingLanguage |
563 |
||
564 |
^true |
|
565 |
||
566 |
"Created: / 21-07-2010 / 15:14:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
567 |
! |
|
568 |
||
12151
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
569 |
isRuby |
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
570 |
"true iff this is the ruby language" |
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
571 |
|
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
572 |
^ false |
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
573 |
! |
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
574 |
|
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
575 |
isSTXJavaScript |
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
576 |
"true iff this is the ST/X-javascript language" |
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
577 |
|
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
578 |
^ false |
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
579 |
! |
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
580 |
|
11964 | 581 |
isSmalltalk |
12106 | 582 |
"true iff this is the smalltalk language" |
11964 | 583 |
|
12106 | 584 |
^ false |
11964 | 585 |
|
586 |
"Created: / 16-08-2009 / 09:01:27 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
587 |
! ! |
|
588 |
||
589 |
!ProgrammingLanguage methodsFor:'utilities - file in/file out'! |
|
590 |
||
591 |
fileIn: aFilename |
|
16425 | 592 |
Warning ignoreIn:[ |
593 |
^self sourceFileReaderClass fileIn: aFilename |
|
594 |
]. |
|
11964 | 595 |
|
596 |
"Created: / 16-08-2009 / 13:28:17 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
597 |
! |
|
598 |
||
599 |
fileInStream: aStream |
|
600 |
||
601 |
^self sourceFileReaderClass fileInStream: aStream |
|
602 |
||
603 |
"Created: / 16-08-2009 / 11:05:46 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
604 |
! ! |
|
605 |
||
606 |
!ProgrammingLanguage methodsFor:'utilities - source code'! |
|
607 |
||
23309 | 608 |
methodSourceForVersionMethodCVS:versionString |
609 |
|generatorClass| |
|
610 |
||
611 |
(generatorClass := self codeGeneratorClass) isNil ifTrue:[^ nil]. |
|
612 |
^ generatorClass methodSourceForVersionMethodCVS:versionString |
|
613 |
||
614 |
"Created: / 28-08-2018 / 11:52:41 / Claus Gittinger" |
|
615 |
! |
|
616 |
||
12151
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
617 |
methodTemplate |
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
618 |
"return a method definition template string (or nil)" |
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
619 |
|
19673 | 620 |
"/ cg: I think this should be the codeGeneratorClass - not the writer |
621 |
"/ |writerClass| |
|
622 |
"/ |
|
623 |
"/ (writerClass := self sourceFileWriterClass) isNil ifTrue:[^ nil]. |
|
624 |
"/ ^ writerClass methodTemplate |
|
14327 | 625 |
|
19673 | 626 |
|generatorClass| |
627 |
||
628 |
(generatorClass := self codeGeneratorClass) isNil ifTrue:[^ nil]. |
|
629 |
^ generatorClass methodTemplate |
|
14327 | 630 |
|
631 |
"Modified: / 21-08-2012 / 19:44:41 / cg" |
|
12151
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
632 |
! |
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
633 |
|
19671 | 634 |
methodTemplateForDocumentation |
20980 | 635 |
"return a documentation method definition template string (or nil)" |
19671 | 636 |
|
19673 | 637 |
|generatorClass| |
638 |
||
639 |
(generatorClass := self codeGeneratorClass) isNil ifTrue:[^ nil]. |
|
640 |
^ generatorClass methodTemplateForDocumentation |
|
20980 | 641 |
|
642 |
"Modified (comment): / 18-11-2016 / 10:53:36 / cg" |
|
643 |
! |
|
644 |
||
645 |
methodTemplateForPackageDocumentation |
|
646 |
"return a documentation method definition template string (or nil) for packages" |
|
647 |
||
648 |
|generatorClass| |
|
649 |
||
650 |
(generatorClass := self codeGeneratorClass) isNil ifTrue:[^ nil]. |
|
651 |
^ generatorClass methodTemplateForPackageDocumentation |
|
652 |
||
653 |
"Created: / 18-11-2016 / 10:51:09 / cg" |
|
19673 | 654 |
! |
19671 | 655 |
|
19673 | 656 |
methodTemplateForVersionMethodCVS |
657 |
|generatorClass| |
|
658 |
||
659 |
(generatorClass := self codeGeneratorClass) isNil ifTrue:[^ nil]. |
|
660 |
^ generatorClass methodTemplateForVersionMethodCVS |
|
19671 | 661 |
! |
662 |
||
14151
34a9e574c152
added: #parenthesisSpecificationForEditor
Claus Gittinger <cg@exept.de>
parents:
13819
diff
changeset
|
663 |
parenthesisSpecificationForEditor |
34a9e574c152
added: #parenthesisSpecificationForEditor
Claus Gittinger <cg@exept.de>
parents:
13819
diff
changeset
|
664 |
^ TextView defaultParenthesisSpecification |
34a9e574c152
added: #parenthesisSpecificationForEditor
Claus Gittinger <cg@exept.de>
parents:
13819
diff
changeset
|
665 |
|
34a9e574c152
added: #parenthesisSpecificationForEditor
Claus Gittinger <cg@exept.de>
parents:
13819
diff
changeset
|
666 |
"Created: / 01-06-2012 / 22:52:25 / cg" |
34a9e574c152
added: #parenthesisSpecificationForEditor
Claus Gittinger <cg@exept.de>
parents:
13819
diff
changeset
|
667 |
! |
34a9e574c152
added: #parenthesisSpecificationForEditor
Claus Gittinger <cg@exept.de>
parents:
13819
diff
changeset
|
668 |
|
14322
174a6ab85c33
added: #versionMethodTemplateForCVS
Claus Gittinger <cg@exept.de>
parents:
14151
diff
changeset
|
669 |
versionMethodTemplateForCVS |
19673 | 670 |
<resource: #obsolete> |
14322
174a6ab85c33
added: #versionMethodTemplateForCVS
Claus Gittinger <cg@exept.de>
parents:
14151
diff
changeset
|
671 |
"raise an error: must be redefined in concrete subclass(es)" |
174a6ab85c33
added: #versionMethodTemplateForCVS
Claus Gittinger <cg@exept.de>
parents:
14151
diff
changeset
|
672 |
|
14422 | 673 |
|writerClass| |
14327 | 674 |
|
19673 | 675 |
self obsoleteMethodWarning:'use methodTemplateForVersionMethodCVS'. |
14422 | 676 |
(writerClass := self sourceFileWriterClass) isNil ifTrue:[^ nil]. |
677 |
^ writerClass versionMethodTemplateForCVS |
|
14327 | 678 |
|
679 |
"Modified: / 21-08-2012 / 19:44:51 / cg" |
|
14322
174a6ab85c33
added: #versionMethodTemplateForCVS
Claus Gittinger <cg@exept.de>
parents:
14151
diff
changeset
|
680 |
! |
174a6ab85c33
added: #versionMethodTemplateForCVS
Claus Gittinger <cg@exept.de>
parents:
14151
diff
changeset
|
681 |
|
12106 | 682 |
writeComment:aStringOrStringCollection on:aStream |
12099 | 683 |
"Utility method - writes a comment to a stream, |
684 |
using proper syntax" |
|
14421 | 685 |
|
686 |
|writerClass| |
|
687 |
||
688 |
(writerClass := self sourceFileWriterClass) notNil ifTrue:[ |
|
689 |
writerClass new |
|
690 |
fileOutComment: aStringOrStringCollection |
|
691 |
on: aStream. |
|
692 |
]. |
|
11964 | 693 |
|
694 |
"Created: / 21-08-2009 / 09:35:07 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
695 |
! ! |
|
696 |
||
697 |
!ProgrammingLanguage class methodsFor:'documentation'! |
|
698 |
||
14373
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
699 |
version |
18914 | 700 |
^ '$Header$' |
14373
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
701 |
! |
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
702 |
|
12048 | 703 |
version_CVS |
18914 | 704 |
^ '$Header$' |
12048 | 705 |
! |
706 |
||
707 |
version_SVN |
|
15537 | 708 |
^ '$ Id: ProgrammingLanguage.st 10643 2011-06-08 21:53:07Z vranyj1 $' |
11964 | 709 |
! ! |
710 |
||
15537 | 711 |
|
11964 | 712 |
ProgrammingLanguage initialize! |