749
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger
|
|
3 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
|
|
4 |
SWING Research Group, Czech Technical University in Prague
|
|
5 |
|
|
6 |
Parts of the code written by Claus Gittinger are under following
|
|
7 |
license:
|
|
8 |
|
|
9 |
This software is furnished under a license and may be used
|
|
10 |
only in accordance with the terms of that license and with the
|
|
11 |
inclusion of the above copyright notice. This software may not
|
|
12 |
be provided or otherwise made available to, or used by, any
|
|
13 |
other person. No title to or ownership of the software is
|
|
14 |
hereby transferred.
|
|
15 |
|
|
16 |
Parts of the code written at SWING Reasearch Group [1] are MIT licensed:
|
|
17 |
|
|
18 |
Permission is hereby granted, free of charge, to any person
|
|
19 |
obtaining a copy of this software and associated documentation
|
|
20 |
files (the 'Software'), to deal in the Software without
|
|
21 |
restriction, including without limitation the rights to use,
|
|
22 |
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
23 |
copies of the Software, and to permit persons to whom the
|
|
24 |
Software is furnished to do so, subject to the following
|
|
25 |
conditions:
|
|
26 |
|
|
27 |
The above copyright notice and this permission notice shall be
|
|
28 |
included in all copies or substantial portions of the Software.
|
|
29 |
|
|
30 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
31 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
32 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
33 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
34 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
35 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
36 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
37 |
OTHER DEALINGS IN THE SOFTWARE.
|
|
38 |
|
|
39 |
[1] Code written at SWING Research Group contain a signature
|
|
40 |
of one of the above copright owners.
|
|
41 |
"
|
|
42 |
"{ Package: 'stx:libjava' }"
|
|
43 |
|
|
44 |
Object subclass:#JavaSourceCodeCache
|
|
45 |
instanceVariableNames:'parsedCodes'
|
|
46 |
classVariableNames:'parsedCode'
|
|
47 |
poolDictionaries:''
|
|
48 |
category:'Languages-Java-Support'
|
|
49 |
!
|
|
50 |
|
|
51 |
JavaSourceCodeCache class instanceVariableNames:'instance'
|
|
52 |
|
|
53 |
"
|
|
54 |
No other class instance variables are inherited by this class.
|
|
55 |
"
|
|
56 |
!
|
|
57 |
|
|
58 |
!JavaSourceCodeCache class methodsFor:'documentation'!
|
|
59 |
|
|
60 |
copyright
|
|
61 |
"
|
|
62 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger
|
|
63 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
|
|
64 |
SWING Research Group, Czech Technical University in Prague
|
|
65 |
|
|
66 |
Parts of the code written by Claus Gittinger are under following
|
|
67 |
license:
|
|
68 |
|
|
69 |
This software is furnished under a license and may be used
|
|
70 |
only in accordance with the terms of that license and with the
|
|
71 |
inclusion of the above copyright notice. This software may not
|
|
72 |
be provided or otherwise made available to, or used by, any
|
|
73 |
other person. No title to or ownership of the software is
|
|
74 |
hereby transferred.
|
|
75 |
|
|
76 |
Parts of the code written at SWING Reasearch Group [1] are MIT licensed:
|
|
77 |
|
|
78 |
Permission is hereby granted, free of charge, to any person
|
|
79 |
obtaining a copy of this software and associated documentation
|
|
80 |
files (the 'Software'), to deal in the Software without
|
|
81 |
restriction, including without limitation the rights to use,
|
|
82 |
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
83 |
copies of the Software, and to permit persons to whom the
|
|
84 |
Software is furnished to do so, subject to the following
|
|
85 |
conditions:
|
|
86 |
|
|
87 |
The above copyright notice and this permission notice shall be
|
|
88 |
included in all copies or substantial portions of the Software.
|
|
89 |
|
|
90 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
91 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
92 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
93 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
94 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
95 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
96 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
97 |
OTHER DEALINGS IN THE SOFTWARE.
|
|
98 |
|
|
99 |
[1] Code written at SWING Research Group contain a signature
|
|
100 |
of one of the above copright owners.
|
|
101 |
|
|
102 |
"
|
|
103 |
! !
|
|
104 |
|
|
105 |
!JavaSourceCodeCache class methodsFor:'instance creation'!
|
|
106 |
|
|
107 |
new
|
|
108 |
instance isNil ifTrue: [ instance := self basicNew initialize ].
|
|
109 |
^ instance
|
|
110 |
|
|
111 |
"Created: / 13-12-2010 / 13:56:31 / Jan Kurs <kurs.jan@post.cz>"
|
|
112 |
! !
|
|
113 |
|
|
114 |
!JavaSourceCodeCache methodsFor:'adding & removing'!
|
|
115 |
|
|
116 |
flush
|
|
117 |
self parsedCodes removeAll.
|
|
118 |
|
|
119 |
"Created: / 17-12-2010 / 16:32:49 / Jan Kurs <kurs.jan@post.cz>"
|
|
120 |
! !
|
|
121 |
|
|
122 |
!JavaSourceCodeCache methodsFor:'initialize'!
|
|
123 |
|
|
124 |
initialize
|
|
125 |
parsedCodes := IdentityDictionary new.
|
|
126 |
|
|
127 |
"Created: / 13-12-2010 / 14:11:49 / Jan Kurs <kurs.jan@post.cz>"
|
|
128 |
"Modified: / 17-12-2010 / 13:35:36 / Jan Kurs <kurs.jan@post.cz>"
|
|
129 |
! !
|
|
130 |
|
|
131 |
!JavaSourceCodeCache methodsFor:'private - searching'!
|
|
132 |
|
|
133 |
findMethodLine: javaMethod inMethods: methods
|
|
134 |
| bestMatchMethod pos |
|
|
135 |
|
|
136 |
pos := javaMethod firstInstructionLineNumber.
|
|
137 |
bestMatchMethod := Plug new respondTo: #startLine with: [^ 0].
|
|
138 |
methods do: [
|
|
139 |
:method |
|
|
140 |
method startLine > pos ifTrue: [
|
|
141 |
^ bestMatchMethod startLine
|
|
142 |
].
|
|
143 |
bestMatchMethod := method.
|
|
144 |
].
|
|
145 |
^ 0.
|
|
146 |
|
|
147 |
"Created: / 08-01-2011 / 16:10:37 / Jan Kurs <kurs.jan@post.cz>"
|
|
148 |
!
|
|
149 |
|
|
150 |
getMethodsFor:class
|
|
151 |
^ parsedCodes at: class fullName ifAbsentPut: [
|
|
152 |
[
|
|
153 |
JavaParser methodsIn: class source
|
|
154 |
] on: Exception do:
|
|
155 |
[
|
|
156 |
OrderedCollection new.
|
|
157 |
]
|
|
158 |
].
|
|
159 |
|
|
160 |
"Created: / 08-01-2011 / 16:09:47 / Jan Kurs <kurs.jan@post.cz>"
|
|
161 |
"Modified: / 07-04-2011 / 22:07:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
162 |
!
|
|
163 |
|
|
164 |
parsedCodes
|
|
165 |
^ parsedCodes
|
|
166 |
! !
|
|
167 |
|
|
168 |
!JavaSourceCodeCache methodsFor:'queries'!
|
|
169 |
|
|
170 |
findLineForMethod:javaMethod inClass:javaClass
|
|
171 |
| methods mdL |
|
|
172 |
methods := self getMethodsFor:javaClass.
|
|
173 |
mdL := self findMethodLine:javaMethod inMethods:methods.
|
|
174 |
^ mdL
|
|
175 |
|
|
176 |
"Created: / 13-12-2010 / 13:47:26 / Jan Kurs <kurs.jan@post.cz>"
|
|
177 |
"Modified: / 08-01-2011 / 16:10:21 / Jan Kurs <kurs.jan@post.cz>"
|
|
178 |
! !
|
|
179 |
|
|
180 |
!JavaSourceCodeCache class methodsFor:'documentation'!
|
|
181 |
|
2249
|
182 |
version_CVS
|
|
183 |
^ '$Header: /cvs/stx/stx/libjava/JavaSourceCodeCache.st,v 1.2 2011-11-24 11:36:33 cg Exp $'
|
|
184 |
!
|
|
185 |
|
749
|
186 |
version_SVN
|
2249
|
187 |
^ '§Id: JavaSourceCodeCache.st,v 1.1 2011/08/18 19:06:53 vrany Exp §'
|
2152
|
188 |
! !
|