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