author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Sat, 23 Jan 2016 07:23:05 +0000 | |
branch | jv |
changeset 19103 | 71257a47eba2 |
parent 18930 | 59e70e261e49 |
parent 19084 | 8d0ce6e7de07 |
child 19691 | 5e613f6255d9 |
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 |
||
18914 | 269 |
|
17448 | 270 |
!ProgrammingLanguage methodsFor:'accessing-classes'! |
11964 | 271 |
|
13250 | 272 |
codeGeneratorClass |
273 |
"Answer a class suitable for generating code (such as getters, setters, etc.) |
|
274 |
It is ok to return nil, which means that no code can be generated automagically" |
|
275 |
||
276 |
^ nil |
|
277 |
! |
|
278 |
||
11964 | 279 |
compilerClass |
12099 | 280 |
"Answer a class suitable for compiling a source code in 'my' language" |
11964 | 281 |
|
282 |
^self subclassResponsibility |
|
283 |
||
284 |
"Created: / 21-08-2009 / 13:00:50 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
285 |
! |
|
286 |
||
16817
2b450fc3f12e
Added ProgrammingLanguage>>compilerClassForInteractiveTools
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16503
diff
changeset
|
287 |
compilerClassForInteractiveTools |
2b450fc3f12e
Added ProgrammingLanguage>>compilerClassForInteractiveTools
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16503
diff
changeset
|
288 |
"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
|
289 |
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
|
290 |
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
|
291 |
|
2b450fc3f12e
Added ProgrammingLanguage>>compilerClassForInteractiveTools
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16503
diff
changeset
|
292 |
^ self compilerClass |
2b450fc3f12e
Added ProgrammingLanguage>>compilerClassForInteractiveTools
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16503
diff
changeset
|
293 |
|
2b450fc3f12e
Added ProgrammingLanguage>>compilerClassForInteractiveTools
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16503
diff
changeset
|
294 |
"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
|
295 |
! |
2b450fc3f12e
Added ProgrammingLanguage>>compilerClassForInteractiveTools
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16503
diff
changeset
|
296 |
|
15537 | 297 |
compilerWithBreakpointSupportClass |
298 |
"Answer a class suitable for compiling a source code with breakpoints |
|
299 |
in 'my' language. If there is non, return nil." |
|
300 |
||
301 |
^ nil |
|
302 |
||
303 |
"Created: / 22-07-2013 / 15:45:00 / cg" |
|
304 |
! |
|
305 |
||
12099 | 306 |
evaluatorClass |
307 |
"Answer a class suitable for evaluating a doIt in 'my' language" |
|
308 |
||
309 |
^ self compilerClass |
|
310 |
! |
|
11964 | 311 |
|
12099 | 312 |
explainerClass |
313 |
"Answers a class used by browser and debugger to |
|
314 |
show some hints about the code. It is OK to return |
|
315 |
nil, which means that there is no explainer for given |
|
316 |
language." |
|
11964 | 317 |
|
318 |
"return nil by default" |
|
319 |
^nil |
|
320 |
||
321 |
"Created: / 21-08-2009 / 08:49:13 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
322 |
! |
|
323 |
||
12099 | 324 |
formatterClass |
325 |
"Answer a class suitable for prettyPrinting (indenting) code in 'my' language. |
|
326 |
It is ok to return nil, which means that the browser will not be able to prettyprint." |
|
327 |
||
328 |
^ nil |
|
329 |
! |
|
330 |
||
13425 | 331 |
lookupClass |
332 |
||
333 |
^BuiltinLookup |
|
334 |
||
335 |
"Created: / 17-03-2011 / 10:56:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
336 |
! |
|
337 |
||
13256 | 338 |
metaClass |
339 |
"will be used for new classes (in the class wizard); |
|
340 |
a fallback here" |
|
341 |
||
342 |
^ Metaclass |
|
343 |
||
344 |
"Created: / 30-01-2011 / 10:05:03 / cg" |
|
345 |
! |
|
346 |
||
11964 | 347 |
parserClass |
12099 | 348 |
"Answer a class suitable for parsing a source code in 'my' language" |
11964 | 349 |
|
350 |
^self subclassResponsibility |
|
351 |
||
352 |
"Created: / 21-08-2009 / 13:00:30 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
353 |
! |
|
354 |
||
355 |
sourceFileReaderClass |
|
12099 | 356 |
"Answers a class that can be used for reading & compiling source files" |
11964 | 357 |
|
358 |
^self subclassResponsibility |
|
359 |
||
360 |
"Created: / 16-08-2009 / 09:00:23 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
361 |
! |
|
362 |
||
363 |
sourceFileWriterClass |
|
12099 | 364 |
"Answers a class is used for source file writing (i.e. file-out)" |
11964 | 365 |
|
366 |
^self subclassResponsibility |
|
367 |
||
368 |
"Created: / 16-08-2009 / 09:40:19 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
12099 | 369 |
! |
370 |
||
371 |
syntaxHighlighterClass |
|
16503 | 372 |
"Answers a class used by browser and debugger to colorize code. |
12099 | 373 |
It is OK to return nil, which means that the code is shown as-is" |
374 |
||
375 |
"return nil by default" |
|
376 |
^nil |
|
16332 | 377 |
! |
378 |
||
379 |
valuePrinterClass |
|
380 |
"Answers a class used by the workspace to print a value. |
|
381 |
If nil, the regular printOn: method is called for" |
|
382 |
||
383 |
"return nil by default" |
|
384 |
^ nil |
|
11964 | 385 |
! ! |
386 |
||
16332 | 387 |
|
11964 | 388 |
!ProgrammingLanguage methodsFor:'printing & storing'! |
389 |
||
13425 | 390 |
printOn:aStream |
391 |
"append a printed representation if the receiver to the argument, aStream" |
|
392 |
||
393 |
self class printOn: aStream. |
|
394 |
aStream nextPutAll: ' instance' |
|
395 |
||
396 |
"Modified: / 19-06-2010 / 09:54:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
397 |
! |
|
398 |
||
11964 | 399 |
storeOn:aStream |
400 |
||
401 |
self class == ProgrammingLanguage |
|
402 |
ifTrue: |
|
403 |
[super storeOn:aStream] |
|
404 |
ifFalse: |
|
405 |
[aStream |
|
406 |
nextPutAll:'ProgrammingLanguage'; |
|
407 |
nextPutAll:' named: '; |
|
408 |
nextPutAll:self name storeString]. |
|
409 |
||
410 |
" |
|
411 |
ProgrammingLanguage instance storeString |
|
412 |
||
413 |
SmalltalkLanguage instance storeString |
|
414 |
" |
|
415 |
||
416 |
"Created: / 16-08-2009 / 10:52:28 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
417 |
! ! |
|
418 |
||
419 |
!ProgrammingLanguage methodsFor:'queries'! |
|
420 |
||
421 |
canReadSourceFile: aFilename |
|
12099 | 422 |
"Answers true iff file contains source code in 'my' language" |
11964 | 423 |
|
12099 | 424 |
"Trivial implementation here, to be overriden by subclasses" |
11964 | 425 |
|
426 |
^aFilename suffix = self sourceFileSuffix |
|
427 |
||
428 |
"Created: / 16-08-2009 / 10:10:33 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
13425 | 429 |
! |
430 |
||
14553 | 431 |
defaultSelectorNameSpacePrefix |
14549 | 432 |
^ nil "/no namespace by default" |
433 |
! |
|
434 |
||
13425 | 435 |
supportsExtensionMethods |
436 |
||
437 |
"Answer true iff this language supports extension methods" |
|
438 |
||
439 |
^true |
|
440 |
||
441 |
"Created: / 19-03-2011 / 10:02:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
11964 | 442 |
! ! |
443 |
||
14372 | 444 |
!ProgrammingLanguage methodsFor:'source queries'! |
445 |
||
16419 | 446 |
commentStrings |
447 |
^ #( |
|
448 |
'"/' "/ EOL comment |
|
449 |
('"' '"') "/ normal comment |
|
450 |
) |
|
451 |
! |
|
452 |
||
14373
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
453 |
methodDefinitionTemplateForSelector:aSelector |
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
454 |
"given a selector, return a prototype definition string" |
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 |
|nA argNames| |
14372 | 457 |
|
14373
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
458 |
(nA := aSelector numArgs) == 1 ifTrue:[ |
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
459 |
argNames := #('arg') |
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
460 |
] ifFalse:[ |
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
461 |
argNames := (1 to:nA) collect:[:i | 'arg' , i printString]. |
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
462 |
]. |
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
463 |
^ self |
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
464 |
methodDefinitionTemplateForSelector:aSelector |
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
465 |
andArgumentNames:argNames. |
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 |
" |
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
468 |
SmalltalkLanguage instance methodDefinitionTemplateForSelector:#foo |
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
469 |
SmalltalkLanguage instance methodDefinitionTemplateForSelector:#+ |
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
470 |
SmalltalkLanguage instance methodDefinitionTemplateForSelector:#foo:bar:baz: |
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
471 |
" |
14372 | 472 |
! |
473 |
||
474 |
methodDefinitionTemplateForSelector:arg1 andArgumentNames:arg2 |
|
475 |
"raise an error: must be redefined in concrete subclass(es)" |
|
476 |
||
477 |
^ self subclassResponsibility |
|
478 |
! ! |
|
479 |
||
11964 | 480 |
!ProgrammingLanguage methodsFor:'testing'! |
481 |
||
18927 | 482 |
isGroovy |
483 |
"true iff this is a Groovy language" |
|
484 |
||
485 |
^ false |
|
486 |
||
487 |
"Created: / 13-04-2012 / 17:47:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
488 |
! |
|
489 |
||
13425 | 490 |
isJava |
491 |
"true iff this is the Java language" |
|
492 |
||
493 |
^ false |
|
494 |
||
495 |
"Created: / 17-03-2011 / 10:16:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
496 |
! |
|
497 |
||
18927 | 498 |
isJavaLike |
499 |
"true if receiver is kind of Java language (based on Java)" |
|
500 |
||
501 |
^ false |
|
502 |
||
503 |
"Created: / 13-04-2012 / 17:48:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
504 |
! |
|
505 |
||
13425 | 506 |
isProgrammingLanguage |
507 |
||
508 |
^true |
|
509 |
||
510 |
"Created: / 21-07-2010 / 15:14:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
511 |
! |
|
512 |
||
12151
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
513 |
isRuby |
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
514 |
"true iff this is the ruby language" |
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
515 |
|
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
516 |
^ false |
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 |
|
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
519 |
isSTXJavaScript |
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
520 |
"true iff this is the ST/X-javascript language" |
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 |
^ false |
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 |
|
11964 | 525 |
isSmalltalk |
12106 | 526 |
"true iff this is the smalltalk language" |
11964 | 527 |
|
12106 | 528 |
^ false |
11964 | 529 |
|
530 |
"Created: / 16-08-2009 / 09:01:27 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
531 |
! ! |
|
532 |
||
533 |
!ProgrammingLanguage methodsFor:'utilities - file in/file out'! |
|
534 |
||
535 |
fileIn: aFilename |
|
16425 | 536 |
Warning ignoreIn:[ |
537 |
^self sourceFileReaderClass fileIn: aFilename |
|
538 |
]. |
|
11964 | 539 |
|
540 |
"Created: / 16-08-2009 / 13:28:17 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
541 |
! |
|
542 |
||
543 |
fileInStream: aStream |
|
544 |
||
545 |
^self sourceFileReaderClass fileInStream: aStream |
|
546 |
||
547 |
"Created: / 16-08-2009 / 11:05:46 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
548 |
! ! |
|
549 |
||
550 |
!ProgrammingLanguage methodsFor:'utilities - source code'! |
|
551 |
||
12151
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
552 |
methodTemplate |
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
553 |
"return a method definition template string (or nil)" |
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
554 |
|
14422 | 555 |
|writerClass| |
14327 | 556 |
|
14422 | 557 |
(writerClass := self sourceFileWriterClass) isNil ifTrue:[^ nil]. |
558 |
^ writerClass methodTemplate |
|
14327 | 559 |
|
560 |
"Modified: / 21-08-2012 / 19:44:41 / cg" |
|
12151
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
561 |
! |
6f4f339cfa56
more stuff via programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
12106
diff
changeset
|
562 |
|
14151
34a9e574c152
added: #parenthesisSpecificationForEditor
Claus Gittinger <cg@exept.de>
parents:
13819
diff
changeset
|
563 |
parenthesisSpecificationForEditor |
34a9e574c152
added: #parenthesisSpecificationForEditor
Claus Gittinger <cg@exept.de>
parents:
13819
diff
changeset
|
564 |
^ TextView defaultParenthesisSpecification |
34a9e574c152
added: #parenthesisSpecificationForEditor
Claus Gittinger <cg@exept.de>
parents:
13819
diff
changeset
|
565 |
|
34a9e574c152
added: #parenthesisSpecificationForEditor
Claus Gittinger <cg@exept.de>
parents:
13819
diff
changeset
|
566 |
"Created: / 01-06-2012 / 22:52:25 / cg" |
34a9e574c152
added: #parenthesisSpecificationForEditor
Claus Gittinger <cg@exept.de>
parents:
13819
diff
changeset
|
567 |
! |
34a9e574c152
added: #parenthesisSpecificationForEditor
Claus Gittinger <cg@exept.de>
parents:
13819
diff
changeset
|
568 |
|
14322
174a6ab85c33
added: #versionMethodTemplateForCVS
Claus Gittinger <cg@exept.de>
parents:
14151
diff
changeset
|
569 |
versionMethodTemplateForCVS |
174a6ab85c33
added: #versionMethodTemplateForCVS
Claus Gittinger <cg@exept.de>
parents:
14151
diff
changeset
|
570 |
"raise an error: must be redefined in concrete subclass(es)" |
174a6ab85c33
added: #versionMethodTemplateForCVS
Claus Gittinger <cg@exept.de>
parents:
14151
diff
changeset
|
571 |
|
14422 | 572 |
|writerClass| |
14327 | 573 |
|
14422 | 574 |
(writerClass := self sourceFileWriterClass) isNil ifTrue:[^ nil]. |
575 |
^ writerClass versionMethodTemplateForCVS |
|
14327 | 576 |
|
577 |
"Modified: / 21-08-2012 / 19:44:51 / cg" |
|
14322
174a6ab85c33
added: #versionMethodTemplateForCVS
Claus Gittinger <cg@exept.de>
parents:
14151
diff
changeset
|
578 |
! |
174a6ab85c33
added: #versionMethodTemplateForCVS
Claus Gittinger <cg@exept.de>
parents:
14151
diff
changeset
|
579 |
|
12106 | 580 |
writeComment:aStringOrStringCollection on:aStream |
12099 | 581 |
"Utility method - writes a comment to a stream, |
582 |
using proper syntax" |
|
14421 | 583 |
|
584 |
|writerClass| |
|
585 |
||
586 |
(writerClass := self sourceFileWriterClass) notNil ifTrue:[ |
|
587 |
writerClass new |
|
588 |
fileOutComment: aStringOrStringCollection |
|
589 |
on: aStream. |
|
590 |
]. |
|
11964 | 591 |
|
592 |
"Created: / 21-08-2009 / 09:35:07 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
593 |
! ! |
|
594 |
||
595 |
!ProgrammingLanguage class methodsFor:'documentation'! |
|
596 |
||
14373
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
597 |
version |
18914 | 598 |
^ '$Header$' |
14373
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
599 |
! |
ec1031c38f9b
changed: #methodDefinitionTemplateForSelector:
Claus Gittinger <cg@exept.de>
parents:
14372
diff
changeset
|
600 |
|
12048 | 601 |
version_CVS |
18914 | 602 |
^ '$Header$' |
12048 | 603 |
! |
604 |
||
605 |
version_SVN |
|
15537 | 606 |
^ '$ Id: ProgrammingLanguage.st 10643 2011-06-08 21:53:07Z vranyj1 $' |
11964 | 607 |
! ! |
608 |
||
15537 | 609 |
|
11964 | 610 |
ProgrammingLanguage initialize! |