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