Refactor helper method to utils.

This commit is contained in:
pTalanov
2012-03-14 15:17:55 +04:00
committed by Pavel V. Talanov
parent 2c3e10ff89
commit 94f80b23fb
2 changed files with 10 additions and 9 deletions
@@ -59,9 +59,9 @@ public final class ClassInitializerTranslator extends AbstractInitializerTransla
@NotNull
protected JsFunction generateInitializerFunction() {
//TODO: it's inconsistent that we scope for class and function for constructor, currently have problems implementing better way
ConstructorDescriptor primaryConstructor = getConstructor();
ConstructorDescriptor primaryConstructor = getConstructor(bindingContext(), classDeclaration);
JsFunction result = context().getFunctionObject(primaryConstructor);
//NOTE: while we doTranslate constructor parameters we also add property initializer statements
//NOTE: while we translate constructor parameters we also add property initializer statements
// for properties declared as constructor parameters
setParameters(result, translatePrimaryConstructorParameters());
mayBeAddCallToSuperMethod();
@@ -69,13 +69,6 @@ public final class ClassInitializerTranslator extends AbstractInitializerTransla
return result;
}
private ConstructorDescriptor getConstructor() {
ConstructorDescriptor primaryConstructor =
getClassDescriptor(context().bindingContext(), classDeclaration).getUnsubstitutedPrimaryConstructor();
assert primaryConstructor != null : "Traits do not have initialize methods.";
return primaryConstructor;
}
@NotNull
private JsBlock generateInitializerMethodBody() {
initializerStatements.addAll(translateClassInitializers(classDeclaration));
@@ -346,4 +346,12 @@ public final class BindingUtils {
assert resolvedCall != null;
return resolvedCall;
}
public static ConstructorDescriptor getConstructor(BindingContext bindingContext,
@NotNull JetClassOrObject declaration) {
ConstructorDescriptor primaryConstructor =
getClassDescriptor(bindingContext, declaration).getUnsubstitutedPrimaryConstructor();
assert primaryConstructor != null : "Traits do not have initialize methods.";
return primaryConstructor;
}
}