org.apache.bcel.classfile.Method[] bcelMethods= jc.getMethods();
ObjectType type= new ObjectType(jc.getClassName());
Map<String, String> annotationsValues= getAnnotationsValues(jc.getAttributes());
TypeDeclaration typeDecl= new TypeDeclaration(type, jc.getAccessFlags(), annotationsValues);
Project.singleton.addTypeAnnotations(typeDecl);
fileUnit.isInterface= Modifier.isInterface(typeDecl.getAccess());
fileUnit.isAbstract= Modifier.isAbstract(typeDecl.getAccess());
fileUnit.setAnnotations(annotationsValues);
if (!type.getClassName().equals("java.lang.Object"))
{
ObjectType superType= new ObjectType(jc.getSuperclassName());
typeDecl.setSuperType(superType);
ClassUnit superUnit= Project.getSingleton().getOrCreateClassUnit(superType.getClassName());
fileUnit.setSuperUnit(superUnit);
String[] interfaceNames= jc.getInterfaceNames();
for (int i= 0; i < interfaceNames.length; i++)
{
ObjectType interfaceType= new ObjectType(interfaceNames[i]);
ClassUnit interfaceUnit= Project.getSingleton().getOrCreateClassUnit(interfaceType.getClassName());
fileUnit.addInterface(interfaceUnit);
}
}
Field[] fields= jc.getFields();
for (int i= 0; i < fields.length; i++)
{
Field field= fields[i];
VariableDeclaration variableDecl= new VariableDeclaration(VariableDeclaration.NON_LOCAL);
variableDecl.setName(field.getName());
variableDecl.setModifiers(field.getModifiers());
variableDecl.setType(field.getType());
typeDecl.addField(variableDecl);
}
for (int i= 0; i < bcelMethods.length; i++)
{
Method method= bcelMethods[i];
Attribute[] attributes= method.getAttributes();
Map<String, String> methodAnnotationsValues= getAnnotationsValues(attributes);
MethodBinding binding= MethodBinding.lookup(jc.getClassName(), method.getName(), method.getSignature());
String genericSignature= method.getGenericSignature();
if (genericSignature != null && !genericSignature.equals(method.getSignature()))
{
Signature signature= Project.getSingleton().getSignature(binding.toString()).relative();
String normalizedSignature= DragomeJavaScriptGenerator.normalizeExpression(signature);
String normalizedClassname= DragomeJavaScriptGenerator.normalizeExpression(type.getClassName());
Project.getSingleton().addGenericSignature(normalizedClassname + "|" + normalizedSignature + "|" + genericSignature);
// System.out.println(genericSignature);
}
if (DragomeJsCompiler.compiler.getSingleEntryPoint() != null)
{
Signature signature= Project.getSingleton().getSignature(binding.toString());
String singleSignature= DragomeJsCompiler.compiler.getSingleEntryPoint();
if (!signature.toString().equals(singleSignature))
continue;
}
MethodDeclaration methodDecl= new MethodDeclaration(binding, method.getAccessFlags(), method.getCode(), methodAnnotationsValues);
typeDecl.addMethod(methodDecl);
parseMethod(typeDecl, methodDecl, method);
}
return typeDecl;