Add AnalyzeCompletedHandlerExtension
This commit is contained in:
+15
-5
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
|
||||
import org.jetbrains.kotlin.context.ModuleContext;
|
||||
import org.jetbrains.kotlin.context.MutableModuleContext;
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.ModuleParameters;
|
||||
import org.jetbrains.kotlin.descriptors.PackageFragmentProvider;
|
||||
import org.jetbrains.kotlin.di.InjectorForTopDownAnalyzerForJvm;
|
||||
@@ -36,10 +37,8 @@ import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.platform.JavaToKotlinClassMap;
|
||||
import org.jetbrains.kotlin.platform.PlatformToKotlinClassMap;
|
||||
import org.jetbrains.kotlin.psi.JetFile;
|
||||
import org.jetbrains.kotlin.resolve.BindingTrace;
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||
import org.jetbrains.kotlin.resolve.ImportPath;
|
||||
import org.jetbrains.kotlin.resolve.TopDownAnalysisMode;
|
||||
import org.jetbrains.kotlin.resolve.*;
|
||||
import org.jetbrains.kotlin.resolve.jvm.extensions.AnalysisCompletedHandlerExtension;
|
||||
import org.jetbrains.kotlin.resolve.lazy.declarations.FileBasedDeclarationProviderFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -148,7 +147,18 @@ public enum TopDownAnalyzerFacadeForJVM {
|
||||
additionalProviders.add(injector.getJavaDescriptorResolver().getPackageFragmentProvider());
|
||||
|
||||
injector.getLazyTopDownAnalyzerForTopLevel().analyzeFiles(topDownAnalysisMode, allFiles, additionalProviders);
|
||||
return AnalysisResult.success(trace.getBindingContext(), moduleContext.getModule());
|
||||
|
||||
BindingContext bindingContext = trace.getBindingContext();
|
||||
ModuleDescriptor module = moduleContext.getModule();
|
||||
|
||||
Collection<AnalysisCompletedHandlerExtension> analysisCompletedHandlerExtensions =
|
||||
AnalysisCompletedHandlerExtension.Companion.getInstances(moduleContext.getProject());
|
||||
|
||||
for (AnalysisCompletedHandlerExtension extension : analysisCompletedHandlerExtensions) {
|
||||
extension.analysisCompleted(project, module, bindingContext, files);
|
||||
}
|
||||
|
||||
return AnalysisResult.success(bindingContext, module);
|
||||
}
|
||||
finally {
|
||||
injector.destroy();
|
||||
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.resolve.jvm.extensions
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.analyzer.ModuleInfo
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.extensions.ProjectExtensionDescriptor
|
||||
import org.jetbrains.kotlin.psi.JetFile
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
|
||||
public interface AnalysisCompletedHandlerExtension {
|
||||
companion object : ProjectExtensionDescriptor<AnalysisCompletedHandlerExtension>(
|
||||
"org.jetbrains.kotlin.analyzeCompleteHandlerExtension",
|
||||
javaClass<AnalysisCompletedHandlerExtension>()
|
||||
)
|
||||
|
||||
public fun analysisCompleted(
|
||||
project: Project,
|
||||
module: ModuleDescriptor,
|
||||
bindingContext: BindingContext,
|
||||
files: Collection<JetFile>)
|
||||
}
|
||||
Reference in New Issue
Block a user