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