Minor. ScriptNameUtil works on scripts, not files
This commit is contained in:
@@ -38,9 +38,10 @@ public class KotlinCodegenFacade {
|
|||||||
for (JetFile file : state.getFiles()) {
|
for (JetFile file : state.getFiles()) {
|
||||||
if (file.isScript()) {
|
if (file.isScript()) {
|
||||||
// SCRIPT: register class name for scripting from this file, move outside of this function
|
// SCRIPT: register class name for scripting from this file, move outside of this function
|
||||||
FqName name = ScriptNameUtil.classNameForScript(file);
|
|
||||||
JetScript script = file.getScript();
|
JetScript script = file.getScript();
|
||||||
assert script != null;
|
assert script != null;
|
||||||
|
|
||||||
|
FqName name = ScriptNameUtil.classNameForScript(script);
|
||||||
Type type = AsmUtil.asmTypeByFqNameWithoutInnerClasses(name);
|
Type type = AsmUtil.asmTypeByFqNameWithoutInnerClasses(name);
|
||||||
registerClassNameForScript(state.getBindingTrace(), script, type);
|
registerClassNameForScript(state.getBindingTrace(), script, type);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -235,7 +235,7 @@ public class KotlinToJVMBytecodeCompiler {
|
|||||||
}, AllModules.class.getClassLoader())
|
}, AllModules.class.getClassLoader())
|
||||||
);
|
);
|
||||||
|
|
||||||
FqName nameForScript = ScriptNameUtil.classNameForScript(environment.getSourceFiles().get(0));
|
FqName nameForScript = ScriptNameUtil.classNameForScript(environment.getSourceFiles().get(0).getScript());
|
||||||
return classLoader.loadClass(nameForScript.asString());
|
return classLoader.loadClass(nameForScript.asString());
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public class ScriptHeaderResolver {
|
|||||||
|
|
||||||
Integer priority = getScriptPriority(script);
|
Integer priority = getScriptPriority(script);
|
||||||
|
|
||||||
FqName nameForScript = ScriptNameUtil.classNameForScript((JetFile) script.getContainingFile());
|
FqName nameForScript = ScriptNameUtil.classNameForScript(script);
|
||||||
Name className = nameForScript.shortName();
|
Name className = nameForScript.shortName();
|
||||||
ScriptDescriptorImpl scriptDescriptor = new ScriptDescriptorImpl(ns, priority, outerScope, className);
|
ScriptDescriptorImpl scriptDescriptor = new ScriptDescriptorImpl(ns, priority, outerScope, className);
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import org.jetbrains.jet.lang.parsing.JetScriptDefinition;
|
|||||||
import org.jetbrains.jet.lang.parsing.JetScriptDefinitionProvider;
|
import org.jetbrains.jet.lang.parsing.JetScriptDefinitionProvider;
|
||||||
import org.jetbrains.jet.lang.psi.JetFile;
|
import org.jetbrains.jet.lang.psi.JetFile;
|
||||||
import org.jetbrains.jet.lang.psi.JetPackageDirective;
|
import org.jetbrains.jet.lang.psi.JetPackageDirective;
|
||||||
|
import org.jetbrains.jet.lang.psi.JetScript;
|
||||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||||
|
|
||||||
public class ScriptNameUtil {
|
public class ScriptNameUtil {
|
||||||
@@ -28,7 +29,8 @@ public class ScriptNameUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static FqName classNameForScript(JetFile file) {
|
public static FqName classNameForScript(JetScript script) {
|
||||||
|
JetFile file = (JetFile) script.getContainingFile();
|
||||||
JetScriptDefinition scriptDefinition = JetScriptDefinitionProvider.getInstance(file.getProject()).findScriptDefinition(file);
|
JetScriptDefinition scriptDefinition = JetScriptDefinitionProvider.getInstance(file.getProject()).findScriptDefinition(file);
|
||||||
|
|
||||||
String name = file.getName();
|
String name = file.getName();
|
||||||
|
|||||||
+1
-1
@@ -78,7 +78,7 @@ public class LazyScriptDescriptor(
|
|||||||
override fun getPriority() = _priority
|
override fun getPriority() = _priority
|
||||||
|
|
||||||
private val _classDescriptor = resolveSession.getStorageManager().createLazyValue {
|
private val _classDescriptor = resolveSession.getStorageManager().createLazyValue {
|
||||||
val nameForScript = ScriptNameUtil.classNameForScript(jetScript.getContainingFile() as JetFile)
|
val nameForScript = ScriptNameUtil.classNameForScript(jetScript)
|
||||||
val className = nameForScript.shortName()
|
val className = nameForScript.shortName()
|
||||||
LazyClassDescriptor(
|
LazyClassDescriptor(
|
||||||
resolveSession,
|
resolveSession,
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class ScriptGenTest extends CodegenTestCase {
|
|||||||
loadFile(filename);
|
loadFile(filename);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
FqName fqName = ScriptNameUtil.classNameForScript(myFiles.getPsiFile());
|
FqName fqName = ScriptNameUtil.classNameForScript(myFiles.getPsiFile().getScript());
|
||||||
Class<?> scriptClass = generateClass(fqName.asString());
|
Class<?> scriptClass = generateClass(fqName.asString());
|
||||||
|
|
||||||
Constructor constructor = getConstructor(scriptClass);
|
Constructor constructor = getConstructor(scriptClass);
|
||||||
|
|||||||
Reference in New Issue
Block a user