Skip to content

Commit ca4da6b

Browse files
committed
Fixes #21, "static block will be lost..."
1 parent c2d7d4d commit ca4da6b

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

services/src/main/groovy/jd/gui/view/component/ClassFilePage.groovy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,10 @@ class ClassFilePage extends TypePage implements PreferencesChangeListener {
260260
declarations.put(internalName + '-<init>-' + descriptor, new TypePage.DeclarationData(stringBuffer.length(), name.length(), internalName, "<init>", descriptor))
261261
super.printConstructorDeclaration(internalName, name, descriptor)
262262
}
263+
void printStaticConstructorDeclaration(String internalName, String name) {
264+
declarations.put(internalName + '-<clinit>-()V', new TypePage.DeclarationData(stringBuffer.length(), name.length(), internalName, "<clinit>", '()V'))
265+
super.printStaticConstructorDeclaration(internalName, name)
266+
}
263267

264268
void printMethodDeclaration(String internalName, String name, String descriptor) {
265269
declarations.put(internalName + '-' + name + '-' + descriptor, new TypePage.DeclarationData(stringBuffer.length(), name.length(), internalName, name, descriptor))

services/src/main/groovy/jd/gui/view/component/JavaFilePage.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class JavaFilePage extends TypePage {
134134
if (first.getSymbol().type == JavaParser.STATIC) {
135135
String name = first.text
136136
int position = first.getSymbol().startIndex
137-
declarations.put(currentInternalTypeName + '-<clinit>-()V', new TypePage.DeclarationData(position, 5, currentInternalTypeName, name, '()V'))
137+
declarations.put(currentInternalTypeName + '-<clinit>-()V', new TypePage.DeclarationData(position, 6, currentInternalTypeName, name, '()V'))
138138
}
139139
}
140140
}

services/src/main/groovy/jd/gui/view/component/TypePage.groovy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,11 @@ abstract class TypePage extends CustomLineNumbersPage implements UriGettable, Ur
185185
def data = declarations.get(fragment)
186186
if (data) {
187187
ranges.add(new DocumentRange(data.startPosition, data.endPosition))
188+
} else if (fragment.endsWith('-<clinit>-()V')) {
189+
// 'static' bloc not found ==> Select type declaration
190+
String typeName = fragment.substring(0, fragment.indexOf('-'));
191+
data = declarations.get(typeName)
192+
ranges.add(new DocumentRange(data.startPosition, data.endPosition))
188193
}
189194
}
190195
}

0 commit comments

Comments
 (0)