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