Make Kotlin accessible for UpSource.
Extracted some initialization of JetCoreEnvironment.
This commit is contained in:
committed by
Evgeny Gerashchenko
parent
28c29dbfde
commit
5489ae08da
@@ -137,22 +137,31 @@ public class JetCoreEnvironment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static JavaCoreApplicationEnvironment createApplicationEnvironment(Disposable parentDisposable) {
|
@NotNull
|
||||||
|
private static JavaCoreApplicationEnvironment createApplicationEnvironment(@NotNull Disposable parentDisposable) {
|
||||||
JavaCoreApplicationEnvironment applicationEnvironment = new JavaCoreApplicationEnvironment(parentDisposable);
|
JavaCoreApplicationEnvironment applicationEnvironment = new JavaCoreApplicationEnvironment(parentDisposable);
|
||||||
|
|
||||||
|
registerApplicationServicesForCLI(applicationEnvironment);
|
||||||
|
registerApplicationServices(applicationEnvironment);
|
||||||
|
|
||||||
|
return applicationEnvironment;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void registerApplicationServicesForCLI(@NotNull JavaCoreApplicationEnvironment applicationEnvironment) {
|
||||||
// ability to get text from annotations xml files
|
// ability to get text from annotations xml files
|
||||||
applicationEnvironment.registerFileType(PlainTextFileType.INSTANCE, "xml");
|
applicationEnvironment.registerFileType(PlainTextFileType.INSTANCE, "xml");
|
||||||
|
applicationEnvironment.registerParserDefinition(new JavaParserDefinition());
|
||||||
|
}
|
||||||
|
|
||||||
|
// made public for Upsource
|
||||||
|
public static void registerApplicationServices(@NotNull JavaCoreApplicationEnvironment applicationEnvironment) {
|
||||||
applicationEnvironment.registerFileType(JetFileType.INSTANCE, "kt");
|
applicationEnvironment.registerFileType(JetFileType.INSTANCE, "kt");
|
||||||
applicationEnvironment.registerFileType(JetFileType.INSTANCE, "ktm");
|
applicationEnvironment.registerFileType(JetFileType.INSTANCE, "ktm");
|
||||||
applicationEnvironment.registerFileType(JetFileType.INSTANCE, JetParserDefinition.STD_SCRIPT_SUFFIX); // should be renamed to kts
|
applicationEnvironment.registerFileType(JetFileType.INSTANCE, JetParserDefinition.STD_SCRIPT_SUFFIX); // should be renamed to kts
|
||||||
applicationEnvironment.registerParserDefinition(new JavaParserDefinition());
|
|
||||||
applicationEnvironment.registerParserDefinition(new JetParserDefinition());
|
applicationEnvironment.registerParserDefinition(new JetParserDefinition());
|
||||||
|
|
||||||
applicationEnvironment.getApplication().registerService(OperationModeProvider.class, new CompilerModeProvider());
|
applicationEnvironment.getApplication().registerService(OperationModeProvider.class, new CompilerModeProvider());
|
||||||
applicationEnvironment.getApplication().registerService(KotlinBinaryClassCache.class, new KotlinBinaryClassCache());
|
applicationEnvironment.getApplication().registerService(KotlinBinaryClassCache.class, new KotlinBinaryClassCache());
|
||||||
|
|
||||||
return applicationEnvironment;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private final JavaCoreProjectEnvironment projectEnvironment;
|
private final JavaCoreProjectEnvironment projectEnvironment;
|
||||||
@@ -174,17 +183,12 @@ public class JetCoreEnvironment {
|
|||||||
projectEnvironment = new JavaCoreProjectEnvironment(parentDisposable, applicationEnvironment);
|
projectEnvironment = new JavaCoreProjectEnvironment(parentDisposable, applicationEnvironment);
|
||||||
|
|
||||||
MockProject project = projectEnvironment.getProject();
|
MockProject project = projectEnvironment.getProject();
|
||||||
project.registerService(JetScriptDefinitionProvider.class, new JetScriptDefinitionProvider());
|
annotationsManager = new CoreExternalAnnotationsManager(project.getComponent(PsiManager.class));
|
||||||
project.registerService(CoreJavaFileManager.class, (CoreJavaFileManager) ServiceManager.getService(project, JavaFileManager.class));
|
project.registerService(ExternalAnnotationsManager.class, annotationsManager);
|
||||||
|
project.registerService(DeclarationProviderFactoryService.class, new CliDeclarationProviderFactoryService(sourceFiles));
|
||||||
|
|
||||||
CliLightClassGenerationSupport cliLightClassGenerationSupport = new CliLightClassGenerationSupport();
|
registerProjectServicesForCLI(projectEnvironment);
|
||||||
project.registerService(LightClassGenerationSupport.class, cliLightClassGenerationSupport);
|
registerProjectServices(projectEnvironment);
|
||||||
project.registerService(CliLightClassGenerationSupport.class, cliLightClassGenerationSupport);
|
|
||||||
project.registerService(KotlinLightClassForPackage.FileStubCache.class, new KotlinLightClassForPackage.FileStubCache(project));
|
|
||||||
|
|
||||||
Extensions.getArea(project)
|
|
||||||
.getExtensionPoint(PsiElementFinder.EP_NAME)
|
|
||||||
.registerExtension(new JavaElementFinder(project, cliLightClassGenerationSupport));
|
|
||||||
|
|
||||||
// This extension points should be registered in JavaCoreApplicationEnvironment
|
// This extension points should be registered in JavaCoreApplicationEnvironment
|
||||||
CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), ClsCustomNavigationPolicy.EP_NAME,
|
CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), ClsCustomNavigationPolicy.EP_NAME,
|
||||||
@@ -192,9 +196,6 @@ public class JetCoreEnvironment {
|
|||||||
CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), ClassFileDecompilers.EP_NAME,
|
CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), ClassFileDecompilers.EP_NAME,
|
||||||
ClassFileDecompilers.Decompiler.class);
|
ClassFileDecompilers.Decompiler.class);
|
||||||
|
|
||||||
annotationsManager = new CoreExternalAnnotationsManager(project.getComponent(PsiManager.class));
|
|
||||||
project.registerService(ExternalAnnotationsManager.class, annotationsManager);
|
|
||||||
|
|
||||||
for (File path : configuration.getList(JVMConfigurationKeys.CLASSPATH_KEY)) {
|
for (File path : configuration.getList(JVMConfigurationKeys.CLASSPATH_KEY)) {
|
||||||
addToClasspath(path);
|
addToClasspath(path);
|
||||||
}
|
}
|
||||||
@@ -203,19 +204,38 @@ public class JetCoreEnvironment {
|
|||||||
}
|
}
|
||||||
sourceFiles.addAll(
|
sourceFiles.addAll(
|
||||||
CompileEnvironmentUtil
|
CompileEnvironmentUtil
|
||||||
.getJetFiles(getProject(), configuration.getList(CommonConfigurationKeys.SOURCE_ROOTS_KEY), new Function1<String, Unit>() {
|
.getJetFiles(getProject(), configuration.getList(CommonConfigurationKeys.SOURCE_ROOTS_KEY),
|
||||||
@Override
|
new Function1<String, Unit>() {
|
||||||
public Unit invoke(String s) {
|
@Override
|
||||||
report(ERROR, s);
|
public Unit invoke(String s) {
|
||||||
return Unit.VALUE;
|
report(ERROR, s);
|
||||||
}
|
return Unit.VALUE;
|
||||||
}));
|
}
|
||||||
|
}));
|
||||||
JetScriptDefinitionProvider.getInstance(project).addScriptDefinitions(
|
JetScriptDefinitionProvider.getInstance(project).addScriptDefinitions(
|
||||||
configuration.getList(CommonConfigurationKeys.SCRIPT_DEFINITIONS_KEY));
|
configuration.getList(CommonConfigurationKeys.SCRIPT_DEFINITIONS_KEY));
|
||||||
|
|
||||||
project.registerService(VirtualFileFinder.class, new CliVirtualFileFinder(classPath));
|
project.registerService(VirtualFileFinder.class, new CliVirtualFileFinder(classPath));
|
||||||
project.registerService(DeclarationProviderFactoryService.class, new CliDeclarationProviderFactoryService(sourceFiles));
|
}
|
||||||
|
|
||||||
|
// made public for Upsource
|
||||||
|
public static void registerProjectServices(@NotNull JavaCoreProjectEnvironment projectEnvironment) {
|
||||||
|
MockProject project = projectEnvironment.getProject();
|
||||||
|
project.registerService(JetScriptDefinitionProvider.class, new JetScriptDefinitionProvider());
|
||||||
|
|
||||||
|
CliLightClassGenerationSupport cliLightClassGenerationSupport = new CliLightClassGenerationSupport();
|
||||||
|
project.registerService(LightClassGenerationSupport.class, cliLightClassGenerationSupport);
|
||||||
|
project.registerService(CliLightClassGenerationSupport.class, cliLightClassGenerationSupport);
|
||||||
|
project.registerService(KotlinLightClassForPackage.FileStubCache.class, new KotlinLightClassForPackage.FileStubCache(project));
|
||||||
|
|
||||||
|
Extensions.getArea(project)
|
||||||
|
.getExtensionPoint(PsiElementFinder.EP_NAME)
|
||||||
|
.registerExtension(new JavaElementFinder(project, cliLightClassGenerationSupport));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void registerProjectServicesForCLI(@NotNull JavaCoreProjectEnvironment projectEnvironment) {
|
||||||
|
MockProject project = projectEnvironment.getProject();
|
||||||
|
project.registerService(CoreJavaFileManager.class, (CoreJavaFileManager) ServiceManager.getService(project, JavaFileManager.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompilerConfiguration getConfiguration() {
|
public CompilerConfiguration getConfiguration() {
|
||||||
|
|||||||
Reference in New Issue
Block a user