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