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