Don't do resolve for files not under sorce roots
This commit is contained in:
@@ -57,47 +57,41 @@ public class JetRunConfigurationProducer extends RuntimeConfigurationProducer im
|
||||
|
||||
@Override
|
||||
protected RunnerAndConfigurationSettings createConfigurationByElement(@NotNull Location location, ConfigurationContext configurationContext) {
|
||||
Module module = location.getModule();
|
||||
if (module == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (ProjectStructureUtil.isJsKotlinModule(module)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
JetFile file = getStartClassFile(location);
|
||||
if (file == null || !ProjectRootsUtil.isInSource(file, true)) {
|
||||
return null;
|
||||
}
|
||||
if (file == null) return null;
|
||||
|
||||
mySourceElement = file;
|
||||
|
||||
FqName startClassFQName = PackageClassUtils.getPackageClassFqName(file.getPackageFqName());
|
||||
|
||||
Module module = location.getModule();
|
||||
assert module != null;
|
||||
|
||||
return createConfigurationByQName(module, configurationContext, startClassFQName);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static JetFile getStartClassFile(@NotNull Location location) {
|
||||
PsiFile psiFile = location.getPsiElement().getContainingFile();
|
||||
if (psiFile instanceof JetFile) {
|
||||
JetFile jetFile = (JetFile) psiFile;
|
||||
final ResolveSessionForBodies session = ResolvePackage.getLazyResolveSession(jetFile);
|
||||
MainFunctionDetector mainFunctionDetector = new MainFunctionDetector(
|
||||
new NotNullFunction<JetNamedFunction, FunctionDescriptor>() {
|
||||
@NotNull
|
||||
@Override
|
||||
public FunctionDescriptor fun(JetNamedFunction function) {
|
||||
return (FunctionDescriptor) session.resolveToDescriptor(function);
|
||||
}
|
||||
});
|
||||
if (mainFunctionDetector.hasMain(jetFile.getDeclarations())) {
|
||||
return jetFile;
|
||||
}
|
||||
}
|
||||
Module module = location.getModule();
|
||||
if (module == null) return null;
|
||||
|
||||
return null;
|
||||
if (ProjectStructureUtil.isJsKotlinModule(module)) return null;
|
||||
|
||||
PsiFile psiFile = location.getPsiElement().getContainingFile();
|
||||
if (!(psiFile instanceof JetFile && ProjectRootsUtil.isInSource(psiFile, true))) return null;
|
||||
|
||||
JetFile jetFile = (JetFile) psiFile;
|
||||
final ResolveSessionForBodies session = ResolvePackage.getLazyResolveSession(jetFile);
|
||||
MainFunctionDetector mainFunctionDetector = new MainFunctionDetector(
|
||||
new NotNullFunction<JetNamedFunction, FunctionDescriptor>() {
|
||||
@NotNull
|
||||
@Override
|
||||
public FunctionDescriptor fun(JetNamedFunction function) {
|
||||
return (FunctionDescriptor) session.resolveToDescriptor(function);
|
||||
}
|
||||
});
|
||||
|
||||
return mainFunctionDetector.hasMain(jetFile.getDeclarations()) ? jetFile : null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -121,9 +115,7 @@ public class JetRunConfigurationProducer extends RuntimeConfigurationProducer im
|
||||
ConfigurationContext context
|
||||
) {
|
||||
JetFile file = getStartClassFile(location);
|
||||
if (file == null) {
|
||||
return null;
|
||||
}
|
||||
if (file == null) return null;
|
||||
|
||||
FqName startClassFQName = PackageClassUtils.getPackageClassFqName(file.getPackageFqName());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user