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