Skip to content

Commit

Permalink
Fixes java-decompiler#21, "static block will be lost..."
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanue1 committed Jun 19, 2015
1 parent c2d7d4d commit ca4da6b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,10 @@ class ClassFilePage extends TypePage implements PreferencesChangeListener {
declarations.put(internalName + '-<init>-' + descriptor, new TypePage.DeclarationData(stringBuffer.length(), name.length(), internalName, "<init>", descriptor))
super.printConstructorDeclaration(internalName, name, descriptor)
}
void printStaticConstructorDeclaration(String internalName, String name) {
declarations.put(internalName + '-<clinit>-()V', new TypePage.DeclarationData(stringBuffer.length(), name.length(), internalName, "<clinit>", '()V'))
super.printStaticConstructorDeclaration(internalName, name)
}

void printMethodDeclaration(String internalName, String name, String descriptor) {
declarations.put(internalName + '-' + name + '-' + descriptor, new TypePage.DeclarationData(stringBuffer.length(), name.length(), internalName, name, descriptor))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class JavaFilePage extends TypePage {
if (first.getSymbol().type == JavaParser.STATIC) {
String name = first.text
int position = first.getSymbol().startIndex
declarations.put(currentInternalTypeName + '-<clinit>-()V', new TypePage.DeclarationData(position, 5, currentInternalTypeName, name, '()V'))
declarations.put(currentInternalTypeName + '-<clinit>-()V', new TypePage.DeclarationData(position, 6, currentInternalTypeName, name, '()V'))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ abstract class TypePage extends CustomLineNumbersPage implements UriGettable, Ur
def data = declarations.get(fragment)
if (data) {
ranges.add(new DocumentRange(data.startPosition, data.endPosition))
} else if (fragment.endsWith('-<clinit>-()V')) {
// 'static' bloc not found ==> Select type declaration
String typeName = fragment.substring(0, fragment.indexOf('-'));
data = declarations.get(typeName)
ranges.add(new DocumentRange(data.startPosition, data.endPosition))
}
}
}
Expand Down

0 comments on commit ca4da6b

Please sign in to comment.