GroovyLanguage.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Fri, 25 Jan 2013 00:15:51 +0000
branchrefactoring-classpath
changeset 2000 13a10b73aa83
parent 1864 60a8dc26c8c6
child 2069 75d40b7b986f
permissions -rw-r--r--
Closing branch refactoring-classpath
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1368
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
     1
"
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
     2
 COPYRIGHT (c) 1996-2011 by Claus Gittinger
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
     3
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
     4
 New code and modifications done at SWING Research Group [1]:
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
     5
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
     6
 COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
     7
                            SWING Research Group, Czech Technical University in Prague
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
     8
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
     9
 This software is furnished under a license and may be used
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    10
 only in accordance with the terms of that license and with the
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    11
 inclusion of the above copyright notice.   This software may not
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    12
 be provided or otherwise made available to, or used by, any
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    13
 other person.  No title to or ownership of the software is
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    14
 hereby transferred.
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    15
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    16
 [1] Code written at SWING Research Group contains a signature
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    17
     of one of the above copright owners. For exact set of such code,
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    18
     see the differences between this version and version stx:libjava
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    19
     as of 1.9.2010
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    20
"
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    21
"{ Package: 'stx:libjava' }"
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    22
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    23
ProgrammingLanguage subclass:#GroovyLanguage
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    24
	instanceVariableNames:''
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    25
	classVariableNames:''
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    26
	poolDictionaries:''
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    27
	category:'Languages-Groovy-Support'
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    28
!
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    29
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    30
!GroovyLanguage class methodsFor:'documentation'!
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    31
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    32
copyright
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    33
"
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    34
 COPYRIGHT (c) 1996-2011 by Claus Gittinger
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    35
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    36
 New code and modifications done at SWING Research Group [1]:
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    37
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    38
 COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    39
                            SWING Research Group, Czech Technical University in Prague
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    40
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    41
 This software is furnished under a license and may be used
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    42
 only in accordance with the terms of that license and with the
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    43
 inclusion of the above copyright notice.   This software may not
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    44
 be provided or otherwise made available to, or used by, any
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    45
 other person.  No title to or ownership of the software is
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    46
 hereby transferred.
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    47
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    48
 [1] Code written at SWING Research Group contains a signature
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    49
     of one of the above copright owners. For exact set of such code,
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    50
     see the differences between this version and version stx:libjava
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    51
     as of 1.9.2010
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    52
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    53
"
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    54
! !
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    55
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    56
!GroovyLanguage methodsFor:'accessing'!
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    57
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    58
name
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    59
    "Answers a human-readable name of myself:
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    60
     'Smalltalk' for SmalltalkLanguage,
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    61
     'Ruby' for RubyLanguage
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    62
     ..."
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    63
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    64
    ^ 'Groovy'
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    65
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    66
    "Modified: / 18-02-2012 / 14:03:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    67
!
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    68
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    69
sourceFileSuffix
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    70
    "Answers a default suffix for source files, i.e. 'st' for Smalltalk, 
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    71
     'js' for JavaScript or 'rb' for Ruby', etc."
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    72
1489
ed2bb47ef6fe - GroovyLanguage
vranyj1
parents: 1478
diff changeset
    73
    ^ 'groovy'
1368
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    74
1489
ed2bb47ef6fe - GroovyLanguage
vranyj1
parents: 1478
diff changeset
    75
    "Modified: / 09-05-2012 / 13:31:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1368
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    76
! !
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    77
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    78
!GroovyLanguage methodsFor:'accessing - classes'!
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    79
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    80
compilerClass
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    81
    "Answer a class suitable for compiling a source code in 'my' language"
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    82
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    83
    ^ GroovyCompiler
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    84
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    85
    "Modified: / 18-02-2012 / 23:01:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    86
!
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    87
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    88
evaluatorClass
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    89
    ^GroovyEvaluator
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    90
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    91
    "Created: / 18-02-2012 / 14:15:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    92
!
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    93
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    94
parserClass
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    95
    "Answer a class suitable for parsing a source code in 'my' language"
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
    96
1478
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1441
diff changeset
    97
    ^ JavaParser
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1441
diff changeset
    98
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1441
diff changeset
    99
    "Modified: / 13-04-2012 / 18:48:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1368
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
   100
!
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
   101
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
   102
sourceFileReaderClass
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
   103
    "Answers a class that can be used for reading & compiling source files"
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
   104
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
   105
    ^ self shouldImplement
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
   106
!
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
   107
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
   108
sourceFileWriterClass
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
   109
    "Answers a class is used for source file writing (i.e. file-out)"
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
   110
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
   111
    ^ GroovySourceFileWriter
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
   112
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
   113
    "Modified: / 18-02-2012 / 18:32:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1441
0faa0f8eda0c Minor improvements in reloading
vranyj1
parents: 1368
diff changeset
   114
!
0faa0f8eda0c Minor improvements in reloading
vranyj1
parents: 1368
diff changeset
   115
0faa0f8eda0c Minor improvements in reloading
vranyj1
parents: 1368
diff changeset
   116
syntaxHighlighterClass
0faa0f8eda0c Minor improvements in reloading
vranyj1
parents: 1368
diff changeset
   117
    "Answers a class used by browser and debugger to colorze code.
0faa0f8eda0c Minor improvements in reloading
vranyj1
parents: 1368
diff changeset
   118
     It is OK to return nil, which means that the code is shown as-is"
0faa0f8eda0c Minor improvements in reloading
vranyj1
parents: 1368
diff changeset
   119
0faa0f8eda0c Minor improvements in reloading
vranyj1
parents: 1368
diff changeset
   120
    "return nil by default"
0faa0f8eda0c Minor improvements in reloading
vranyj1
parents: 1368
diff changeset
   121
    ^JavaSyntaxHighlighter
1368
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
   122
! !
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
   123
1698
d32a2a3dce36 - Some more support for non-Java extension methods.
vranyj1
parents: 1489
diff changeset
   124
!GroovyLanguage methodsFor:'queries'!
d32a2a3dce36 - Some more support for non-Java extension methods.
vranyj1
parents: 1489
diff changeset
   125
d32a2a3dce36 - Some more support for non-Java extension methods.
vranyj1
parents: 1489
diff changeset
   126
supportsExtensionMethods
d32a2a3dce36 - Some more support for non-Java extension methods.
vranyj1
parents: 1489
diff changeset
   127
    "
d32a2a3dce36 - Some more support for non-Java extension methods.
vranyj1
parents: 1489
diff changeset
   128
      Answer true iff this language supports extension methods, i.e., if the language
d32a2a3dce36 - Some more support for non-Java extension methods.
vranyj1
parents: 1489
diff changeset
   129
      can provide extension methods for another class (not necessarily of the same language
d32a2a3dce36 - Some more support for non-Java extension methods.
vranyj1
parents: 1489
diff changeset
   130
    "
d32a2a3dce36 - Some more support for non-Java extension methods.
vranyj1
parents: 1489
diff changeset
   131
d32a2a3dce36 - Some more support for non-Java extension methods.
vranyj1
parents: 1489
diff changeset
   132
    ^false
d32a2a3dce36 - Some more support for non-Java extension methods.
vranyj1
parents: 1489
diff changeset
   133
d32a2a3dce36 - Some more support for non-Java extension methods.
vranyj1
parents: 1489
diff changeset
   134
    "Created: / 06-09-2012 / 12:09:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
d32a2a3dce36 - Some more support for non-Java extension methods.
vranyj1
parents: 1489
diff changeset
   135
! !
d32a2a3dce36 - Some more support for non-Java extension methods.
vranyj1
parents: 1489
diff changeset
   136
1478
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1441
diff changeset
   137
!GroovyLanguage methodsFor:'testing'!
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1441
diff changeset
   138
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1441
diff changeset
   139
isGroovy
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1441
diff changeset
   140
    "true iff this is a Groovy language"
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1441
diff changeset
   141
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1441
diff changeset
   142
    ^ true
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1441
diff changeset
   143
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1441
diff changeset
   144
    "Created: / 13-04-2012 / 17:48:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1441
diff changeset
   145
!
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1441
diff changeset
   146
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1441
diff changeset
   147
isJavaLike
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1441
diff changeset
   148
    "true if receiver is kind of Java language (based on Java)"
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1441
diff changeset
   149
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1441
diff changeset
   150
    ^ true
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1441
diff changeset
   151
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1441
diff changeset
   152
    "Created: / 13-04-2012 / 17:48:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1441
diff changeset
   153
! !
329a15eedd36 - improvements in class reloading
vranyj1
parents: 1441
diff changeset
   154
1368
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
   155
!GroovyLanguage methodsFor:'utilities - source code'!
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
   156
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
   157
classTemplateFor: superClass in: category asNamespace: isNamespace private: isPrivate
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
   158
    | sclass |
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
   159
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
   160
    self assert: isNamespace not.
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
   161
    self assert: ((superClass == Object) or:[superClass isJavaClass]).
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
   162
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
   163
    sclass := superClass == Object ifTrue:[Java classForName:'java.lang.Object'] ifFalse:[superClass].
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
   164
1441
0faa0f8eda0c Minor improvements in reloading
vranyj1
parents: 1368
diff changeset
   165
    ^'//import stx.libjava.annotations.Category;
0faa0f8eda0c Minor improvements in reloading
vranyj1
parents: 1368
diff changeset
   166
//@Category("%(CATEGORY)")
1368
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
   167
%(ACCESS) class %(NAME) extends %(SNAME) {
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
   168
    /* fields and methods here... */
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
   169
}
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
   170
' expandPlaceholdersWith:
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
   171
        (Dictionary new
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
   172
            at: 'CATEGORY' put: category;
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
   173
            at: 'ACCESS' put: (isPrivate ifTrue:['protected'] ifFalse:['public']);
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
   174
            at: 'NAME' put: 'NewClass';
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
   175
            at: 'SNAME' put: sclass javaName;
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
   176
            yourself)
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
   177
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
   178
    "Created: / 18-02-2012 / 18:27:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
   179
! !
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
   180
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
   181
!GroovyLanguage class methodsFor:'documentation'!
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
   182
1864
60a8dc26c8c6 Updated from HG
vranyj1
parents: 1818
diff changeset
   183
version_HG
60a8dc26c8c6 Updated from HG
vranyj1
parents: 1818
diff changeset
   184
60a8dc26c8c6 Updated from HG
vranyj1
parents: 1818
diff changeset
   185
    ^ '$Changeset: <not expanded> $'
60a8dc26c8c6 Updated from HG
vranyj1
parents: 1818
diff changeset
   186
!
60a8dc26c8c6 Updated from HG
vranyj1
parents: 1818
diff changeset
   187
1368
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
   188
version_SVN
1864
60a8dc26c8c6 Updated from HG
vranyj1
parents: 1818
diff changeset
   189
    ^ '§Id§'
1368
5f502e712403 Groovy language support and integration
vranyj1
parents:
diff changeset
   190
! !