Extract and move method from StaticContext to Namer
This commit is contained in:
@@ -19,6 +19,9 @@ package org.jetbrains.k2js.translate.context;
|
|||||||
import com.google.dart.compiler.backend.js.ast.*;
|
import com.google.dart.compiler.backend.js.ast.*;
|
||||||
import com.google.dart.compiler.util.AstUtil;
|
import com.google.dart.compiler.util.AstUtil;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||||
|
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||||
|
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||||
|
|
||||||
import static org.jetbrains.k2js.translate.utils.JsAstUtils.setQualifier;
|
import static org.jetbrains.k2js.translate.utils.JsAstUtils.setQualifier;
|
||||||
|
|
||||||
@@ -208,4 +211,14 @@ public final class Namer {
|
|||||||
/*package*/ JsScope getKotlinScope() {
|
/*package*/ JsScope getKotlinScope() {
|
||||||
return kotlinScope;
|
return kotlinScope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
static String generateNamespaceName(DeclarationDescriptor descriptor) {
|
||||||
|
if (DescriptorUtils.isRootNamespace((NamespaceDescriptor) descriptor)) {
|
||||||
|
return getRootNamespaceName();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return descriptor.getName().getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -189,14 +189,7 @@ public final class StaticContext {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String name;
|
String name = Namer.generateNamespaceName(descriptor);
|
||||||
if (DescriptorUtils.isRootNamespace((NamespaceDescriptor) descriptor)) {
|
|
||||||
name = Namer.getRootNamespaceName();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
name = descriptor.getName().getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
return getRootScope().declareUnobfuscatableName(name);
|
return getRootScope().declareUnobfuscatableName(name);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user