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