diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BodyResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BodyResolver.java index 2f60b65cb51..0215f6bed3e 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BodyResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BodyResolver.java @@ -73,6 +73,8 @@ public class BodyResolver { private AnnotationResolver annotationResolver; @NotNull private DelegatedPropertyResolver delegatedPropertyResolver; + @NotNull + private FunctionAnalyzerExtension functionAnalyzerExtension; @Inject public void setTopDownAnalysisParameters(@NotNull TopDownAnalysisParameters topDownAnalysisParameters) { @@ -124,6 +126,11 @@ public class BodyResolver { this.delegatedPropertyResolver = delegatedPropertyResolver; } + @Inject + public void setFunctionAnalyzerExtension(@NotNull FunctionAnalyzerExtension functionAnalyzerExtension) { + this.functionAnalyzerExtension = functionAnalyzerExtension; + } + private void resolveBehaviorDeclarationBodies(@NotNull BodiesResolveContext bodiesResolveContext) { // Initialize context context = bodiesResolveContext; @@ -148,6 +155,7 @@ public class BodyResolver { resolveBehaviorDeclarationBodies(context); controlFlowAnalyzer.process(context); declarationsChecker.process(context); + functionAnalyzerExtension.process(context); } private void resolveDelegationSpecifierLists() { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/FunctionAnalyzerExtension.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/FunctionAnalyzerExtension.java new file mode 100644 index 00000000000..30db4e14ba7 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/FunctionAnalyzerExtension.java @@ -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 entry : bodiesResolveContext.getFunctions().entrySet()) { + JetNamedFunction function = entry.getKey(); + SimpleFunctionDescriptor functionDescriptor = entry.getValue(); + List extensions = getExtensions(functionDescriptor); + for (AnalyzerExtension extension : extensions) { + extension.process(functionDescriptor, function, trace); + } + } + } + + @NotNull + private List getExtensions(@NotNull FunctionDescriptor functionDescriptor) { + return Collections.emptyList(); + } + +}