JavaSourceCodeCache.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Fri, 24 May 2013 17:55:42 +0100
branchbuiltin-class-support
changeset 2629 cedb88626902
parent 2429 ebece4dcaab9
child 2711 a00302fe5083
permissions -rw-r--r--
Closing branch.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
     1
"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
     2
 COPYRIGHT (c) 1996-2011 by Claus Gittinger
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2249
diff changeset
     3
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2249
diff changeset
     4
 New code and modifications done at SWING Research Group [1]:
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2249
diff changeset
     5
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
     6
 COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
     7
                            SWING Research Group, Czech Technical University in Prague
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
     8
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
     9
 This software is furnished under a license and may be used
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    10
 only in accordance with the terms of that license and with the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    11
 inclusion of the above copyright notice.   This software may not
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    12
 be provided or otherwise made available to, or used by, any
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    13
 other person.  No title to or ownership of the software is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    14
 hereby transferred.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    15
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2249
diff changeset
    16
 [1] Code written at SWING Research Group contains a signature
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2249
diff changeset
    17
     of one of the above copright owners. For exact set of such code,
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2249
diff changeset
    18
     see the differences between this version and version stx:libjava
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2249
diff changeset
    19
     as of 1.9.2010
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    20
"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    21
"{ Package: 'stx:libjava' }"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    22
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    23
Object subclass:#JavaSourceCodeCache
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    24
	instanceVariableNames:'parsedCodes'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    25
	classVariableNames:'parsedCode'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    26
	poolDictionaries:''
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    27
	category:'Languages-Java-Support'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    28
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    29
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    30
JavaSourceCodeCache class instanceVariableNames:'instance'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    31
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    32
"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    33
 No other class instance variables are inherited by this class.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    34
"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    35
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    36
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    37
!JavaSourceCodeCache class methodsFor:'documentation'!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    38
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    39
copyright
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    40
"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    41
 COPYRIGHT (c) 1996-2011 by Claus Gittinger
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2249
diff changeset
    42
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2249
diff changeset
    43
 New code and modifications done at SWING Research Group [1]:
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2249
diff changeset
    44
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    45
 COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    46
                            SWING Research Group, Czech Technical University in Prague
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    47
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    48
 This software is furnished under a license and may be used
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    49
 only in accordance with the terms of that license and with the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    50
 inclusion of the above copyright notice.   This software may not
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    51
 be provided or otherwise made available to, or used by, any
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    52
 other person.  No title to or ownership of the software is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    53
 hereby transferred.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    54
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2249
diff changeset
    55
 [1] Code written at SWING Research Group contains a signature
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2249
diff changeset
    56
     of one of the above copright owners. For exact set of such code,
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2249
diff changeset
    57
     see the differences between this version and version stx:libjava
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2249
diff changeset
    58
     as of 1.9.2010
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    59
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    60
"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    61
! !
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    62
2396
fadc6d7a2f5b Updated to rev 009a0df3afce
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2353
diff changeset
    63
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    64
!JavaSourceCodeCache class methodsFor:'instance creation'!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    65
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    66
new
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    67
    instance isNil ifTrue: [ instance := self basicNew initialize ].
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    68
    ^ instance
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    69
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    70
    "Created: / 13-12-2010 / 13:56:31 / Jan Kurs <kurs.jan@post.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    71
! !
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    72
2396
fadc6d7a2f5b Updated to rev 009a0df3afce
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2353
diff changeset
    73
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    74
!JavaSourceCodeCache methodsFor:'adding & removing'!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    75
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    76
flush
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    77
    self parsedCodes removeAll.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    78
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    79
    "Created: / 17-12-2010 / 16:32:49 / Jan Kurs <kurs.jan@post.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    80
! !
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    81
2396
fadc6d7a2f5b Updated to rev 009a0df3afce
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2353
diff changeset
    82
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    83
!JavaSourceCodeCache methodsFor:'initialize'!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    84
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    85
initialize
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    86
    parsedCodes := IdentityDictionary new.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    87
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    88
    "Created: / 13-12-2010 / 14:11:49 / Jan Kurs <kurs.jan@post.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    89
    "Modified: / 17-12-2010 / 13:35:36 / Jan Kurs <kurs.jan@post.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    90
! !
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    91
2396
fadc6d7a2f5b Updated to rev 009a0df3afce
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2353
diff changeset
    92
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    93
!JavaSourceCodeCache methodsFor:'private - searching'!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    94
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    95
findMethodLine: javaMethod inMethods: methods 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    96
    | bestMatchMethod  pos |
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    97
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    98
    pos := javaMethod firstInstructionLineNumber.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    99
    bestMatchMethod := Plug new respondTo: #startLine with: [^ 0].
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   100
    methods do: [
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   101
        :method | 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   102
        method startLine > pos ifTrue: [
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   103
            ^ bestMatchMethod startLine
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   104
        ].
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   105
        bestMatchMethod := method.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   106
    ].
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   107
    ^ 0.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   108
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   109
    "Created: / 08-01-2011 / 16:10:37 / Jan Kurs <kurs.jan@post.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   110
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   111
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   112
getMethodsFor:class 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   113
    ^ parsedCodes at: class fullName ifAbsentPut: [
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   114
        [        
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2249
diff changeset
   115
            JavaParser_Old methodsIn: class source 
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   116
        ] on: Exception do:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   117
        [
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   118
            OrderedCollection new.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   119
        ]
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   120
    ].
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   121
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   122
    "Created: / 08-01-2011 / 16:09:47 / Jan Kurs <kurs.jan@post.cz>"
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2249
diff changeset
   123
    "Modified: / 09-03-2012 / 23:30:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   124
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   125
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   126
parsedCodes
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   127
    ^ parsedCodes
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   128
! !
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   129
2396
fadc6d7a2f5b Updated to rev 009a0df3afce
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2353
diff changeset
   130
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   131
!JavaSourceCodeCache methodsFor:'queries'!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   132
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   133
findLineForMethod:javaMethod inClass:javaClass 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   134
    | methods  mdL |
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   135
    methods := self getMethodsFor:javaClass.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   136
    mdL := self findMethodLine:javaMethod inMethods:methods.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   137
    ^ mdL
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   138
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   139
    "Created: / 13-12-2010 / 13:47:26 / Jan Kurs <kurs.jan@post.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   140
    "Modified: / 08-01-2011 / 16:10:21 / Jan Kurs <kurs.jan@post.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   141
! !
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   142
2396
fadc6d7a2f5b Updated to rev 009a0df3afce
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2353
diff changeset
   143
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   144
!JavaSourceCodeCache class methodsFor:'documentation'!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   145
2249
662911e44e26 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 2152
diff changeset
   146
version_CVS
2396
fadc6d7a2f5b Updated to rev 009a0df3afce
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2353
diff changeset
   147
    ^ '$Header: /cvs/stx/stx/libjava/JavaSourceCodeCache.st,v 1.4 2013-02-25 11:15:31 vrany Exp $'
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2249
diff changeset
   148
!
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2249
diff changeset
   149
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2249
diff changeset
   150
version_HG
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2249
diff changeset
   151
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2249
diff changeset
   152
    ^ '$Changeset: <not expanded> $'
2249
662911e44e26 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 2152
diff changeset
   153
!
662911e44e26 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 2152
diff changeset
   154
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   155
version_SVN
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2249
diff changeset
   156
    ^ '§Id§'
2152
1cbdfbcc685c Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 749
diff changeset
   157
! !
2353
fa7400d022a0 Updated to https://swing.fit.cvut.cz/hg/stx.libjava/rev/31f8b995905e
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2249
diff changeset
   158