Added extensions for function body resolve
This commit is contained in:
@@ -73,6 +73,8 @@ public class BodyResolver {
|
|||||||
private AnnotationResolver annotationResolver;
|
private AnnotationResolver annotationResolver;
|
||||||
@NotNull
|
@NotNull
|
||||||
private DelegatedPropertyResolver delegatedPropertyResolver;
|
private DelegatedPropertyResolver delegatedPropertyResolver;
|
||||||
|
@NotNull
|
||||||
|
private FunctionAnalyzerExtension functionAnalyzerExtension;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public void setTopDownAnalysisParameters(@NotNull TopDownAnalysisParameters topDownAnalysisParameters) {
|
public void setTopDownAnalysisParameters(@NotNull TopDownAnalysisParameters topDownAnalysisParameters) {
|
||||||
@@ -124,6 +126,11 @@ public class BodyResolver {
|
|||||||
this.delegatedPropertyResolver = delegatedPropertyResolver;
|
this.delegatedPropertyResolver = delegatedPropertyResolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public void setFunctionAnalyzerExtension(@NotNull FunctionAnalyzerExtension functionAnalyzerExtension) {
|
||||||
|
this.functionAnalyzerExtension = functionAnalyzerExtension;
|
||||||
|
}
|
||||||
|
|
||||||
private void resolveBehaviorDeclarationBodies(@NotNull BodiesResolveContext bodiesResolveContext) {
|
private void resolveBehaviorDeclarationBodies(@NotNull BodiesResolveContext bodiesResolveContext) {
|
||||||
// Initialize context
|
// Initialize context
|
||||||
context = bodiesResolveContext;
|
context = bodiesResolveContext;
|
||||||
@@ -148,6 +155,7 @@ public class BodyResolver {
|
|||||||
resolveBehaviorDeclarationBodies(context);
|
resolveBehaviorDeclarationBodies(context);
|
||||||
controlFlowAnalyzer.process(context);
|
controlFlowAnalyzer.process(context);
|
||||||
declarationsChecker.process(context);
|
declarationsChecker.process(context);
|
||||||
|
functionAnalyzerExtension.process(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resolveDelegationSpecifierLists() {
|
private void resolveDelegationSpecifierLists() {
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2013 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.jet.lang.resolve;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
||||||
|
import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor;
|
||||||
|
import org.jetbrains.jet.lang.psi.JetNamedFunction;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class FunctionAnalyzerExtension {
|
||||||
|
|
||||||
|
public interface AnalyzerExtension {
|
||||||
|
void process(@NotNull FunctionDescriptor descriptor, @NotNull JetNamedFunction function, @NotNull BindingTrace trace);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private BindingTrace trace;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public void setTrace(BindingTrace trace) {
|
||||||
|
this.trace = trace;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void process(@NotNull BodiesResolveContext bodiesResolveContext) {
|
||||||
|
for (Map.Entry<JetNamedFunction, SimpleFunctionDescriptor> entry : bodiesResolveContext.getFunctions().entrySet()) {
|
||||||
|
JetNamedFunction function = entry.getKey();
|
||||||
|
SimpleFunctionDescriptor functionDescriptor = entry.getValue();
|
||||||
|
List<AnalyzerExtension> extensions = getExtensions(functionDescriptor);
|
||||||
|
for (AnalyzerExtension extension : extensions) {
|
||||||
|
extension.process(functionDescriptor, function, trace);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private List<AnalyzerExtension> getExtensions(@NotNull FunctionDescriptor functionDescriptor) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user