Refactoring of AnnotationResolver.resolveAnnotation(s)Arguments
This commit is contained in:
@@ -144,7 +144,7 @@ public class AnnotationResolver {
|
|||||||
descriptor = new LazyAnnotationDescriptor(new LazyAnnotationsContextImpl(this, storageManager, trace, scope), entryElement);
|
descriptor = new LazyAnnotationDescriptor(new LazyAnnotationsContextImpl(this, storageManager, trace, scope), entryElement);
|
||||||
}
|
}
|
||||||
if (shouldResolveArguments) {
|
if (shouldResolveArguments) {
|
||||||
resolveAnnotationArguments(entryElement, trace);
|
resolveAnnotationArguments(descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
result.add(descriptor);
|
result.add(descriptor);
|
||||||
@@ -202,30 +202,13 @@ public class AnnotationResolver {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void resolveAnnotationsArguments(@Nullable JetModifierList modifierList, @NotNull BindingTrace trace) {
|
public static void resolveAnnotationsArguments(@NotNull Annotations annotations) {
|
||||||
if (modifierList == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (JetAnnotationEntry annotationEntry : modifierList.getAnnotationEntries()) {
|
|
||||||
resolveAnnotationArguments(annotationEntry, trace);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void resolveAnnotationsArguments(@NotNull Annotations annotations, @NotNull BindingTrace trace) {
|
|
||||||
for (AnnotationDescriptor annotationDescriptor : annotations) {
|
for (AnnotationDescriptor annotationDescriptor : annotations) {
|
||||||
JetAnnotationEntry annotationEntry = trace.getBindingContext().get(ANNOTATION_DESCRIPTOR_TO_PSI_ELEMENT, annotationDescriptor);
|
resolveAnnotationArguments(annotationDescriptor);
|
||||||
assert annotationEntry != null : "Cannot find annotation entry: " + annotationDescriptor;
|
|
||||||
resolveAnnotationArguments(annotationEntry, trace);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void resolveAnnotationArguments(
|
private static void resolveAnnotationArguments(@NotNull AnnotationDescriptor annotationDescriptor) {
|
||||||
@NotNull JetAnnotationEntry annotationEntry,
|
|
||||||
@NotNull BindingTrace trace
|
|
||||||
) {
|
|
||||||
AnnotationDescriptor annotationDescriptor = trace.getBindingContext().get(BindingContext.ANNOTATION, annotationEntry);
|
|
||||||
assert annotationDescriptor != null : "Annotation descriptor should be created before resolving arguments for " + annotationEntry.getText();
|
|
||||||
if (annotationDescriptor instanceof LazyAnnotationDescriptor) {
|
if (annotationDescriptor instanceof LazyAnnotationDescriptor) {
|
||||||
((LazyAnnotationDescriptor) annotationDescriptor).forceResolveAllContents();
|
((LazyAnnotationDescriptor) annotationDescriptor).forceResolveAllContents();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ public class BodyResolver {
|
|||||||
@NotNull final ConstructorDescriptor descriptor,
|
@NotNull final ConstructorDescriptor descriptor,
|
||||||
@NotNull JetScope declaringScope
|
@NotNull JetScope declaringScope
|
||||||
) {
|
) {
|
||||||
AnnotationResolver.resolveAnnotationsArguments(constructor.getModifierList(), trace);
|
AnnotationResolver.resolveAnnotationsArguments(descriptor.getAnnotations());
|
||||||
|
|
||||||
final CallChecker callChecker = new ConstructorHeaderCallChecker(descriptor, additionalCheckerProvider.getCallChecker());
|
final CallChecker callChecker = new ConstructorHeaderCallChecker(descriptor, additionalCheckerProvider.getCallChecker());
|
||||||
resolveFunctionBody(c, trace, constructor, descriptor, declaringScope,
|
resolveFunctionBody(c, trace, constructor, descriptor, declaringScope,
|
||||||
@@ -504,14 +504,14 @@ public class BodyResolver {
|
|||||||
JetClassOrObject klass = entry.getKey();
|
JetClassOrObject klass = entry.getKey();
|
||||||
ClassDescriptorWithResolutionScopes classDescriptor = entry.getValue();
|
ClassDescriptorWithResolutionScopes classDescriptor = entry.getValue();
|
||||||
ConstructorDescriptor unsubstitutedPrimaryConstructor = classDescriptor.getUnsubstitutedPrimaryConstructor();
|
ConstructorDescriptor unsubstitutedPrimaryConstructor = classDescriptor.getUnsubstitutedPrimaryConstructor();
|
||||||
|
|
||||||
AnnotationResolver.resolveAnnotationsArguments(klass.getPrimaryConstructorModifierList(), trace);
|
|
||||||
|
|
||||||
if (unsubstitutedPrimaryConstructor != null) {
|
if (unsubstitutedPrimaryConstructor != null) {
|
||||||
|
AnnotationResolver.resolveAnnotationsArguments(unsubstitutedPrimaryConstructor.getAnnotations());
|
||||||
|
|
||||||
WritableScope parameterScope = getPrimaryConstructorParametersScope(classDescriptor.getScopeForClassHeaderResolution(),
|
WritableScope parameterScope = getPrimaryConstructorParametersScope(classDescriptor.getScopeForClassHeaderResolution(),
|
||||||
unsubstitutedPrimaryConstructor);
|
unsubstitutedPrimaryConstructor);
|
||||||
valueParameterResolver.resolveValueParameters(klass.getPrimaryConstructorParameters(), unsubstitutedPrimaryConstructor.getValueParameters(),
|
valueParameterResolver.resolveValueParameters(klass.getPrimaryConstructorParameters(),
|
||||||
parameterScope, c.getOuterDataFlowInfo(), trace);
|
unsubstitutedPrimaryConstructor.getValueParameters(),
|
||||||
|
parameterScope, c.getOuterDataFlowInfo(), trace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -559,7 +559,7 @@ public class BodyResolver {
|
|||||||
resolvePropertyDelegate(c, property, propertyDescriptor, delegateExpression, classDescriptor.getScopeForMemberDeclarationResolution(), propertyScope);
|
resolvePropertyDelegate(c, property, propertyDescriptor, delegateExpression, classDescriptor.getScopeForMemberDeclarationResolution(), propertyScope);
|
||||||
}
|
}
|
||||||
|
|
||||||
resolveAnnotationArguments(propertyScope, property);
|
AnnotationResolver.resolveAnnotationsArguments(propertyDescriptor.getAnnotations());
|
||||||
|
|
||||||
resolvePropertyAccessors(c, property, propertyDescriptor);
|
resolvePropertyAccessors(c, property, propertyDescriptor);
|
||||||
processed.add(property);
|
processed.add(property);
|
||||||
@@ -587,7 +587,7 @@ public class BodyResolver {
|
|||||||
resolvePropertyDelegate(c, property, propertyDescriptor, delegateExpression, propertyScope, propertyScope);
|
resolvePropertyDelegate(c, property, propertyDescriptor, delegateExpression, propertyScope, propertyScope);
|
||||||
}
|
}
|
||||||
|
|
||||||
resolveAnnotationArguments(propertyScope, property);
|
AnnotationResolver.resolveAnnotationsArguments(propertyDescriptor.getAnnotations());
|
||||||
|
|
||||||
resolvePropertyAccessors(c, property, propertyDescriptor);
|
resolvePropertyAccessors(c, property, propertyDescriptor);
|
||||||
}
|
}
|
||||||
@@ -610,7 +610,7 @@ public class BodyResolver {
|
|||||||
PropertyGetterDescriptor getterDescriptor = propertyDescriptor.getGetter();
|
PropertyGetterDescriptor getterDescriptor = propertyDescriptor.getGetter();
|
||||||
if (getter != null && getterDescriptor != null) {
|
if (getter != null && getterDescriptor != null) {
|
||||||
JetScope accessorScope = makeScopeForPropertyAccessor(c, getter, propertyDescriptor);
|
JetScope accessorScope = makeScopeForPropertyAccessor(c, getter, propertyDescriptor);
|
||||||
resolveAnnotationArguments(accessorScope, getter);
|
AnnotationResolver.resolveAnnotationsArguments(getterDescriptor.getAnnotations());
|
||||||
resolveFunctionBody(c, fieldAccessTrackingTrace, getter, getterDescriptor, accessorScope);
|
resolveFunctionBody(c, fieldAccessTrackingTrace, getter, getterDescriptor, accessorScope);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -618,7 +618,7 @@ public class BodyResolver {
|
|||||||
PropertySetterDescriptor setterDescriptor = propertyDescriptor.getSetter();
|
PropertySetterDescriptor setterDescriptor = propertyDescriptor.getSetter();
|
||||||
if (setter != null && setterDescriptor != null) {
|
if (setter != null && setterDescriptor != null) {
|
||||||
JetScope accessorScope = makeScopeForPropertyAccessor(c, setter, propertyDescriptor);
|
JetScope accessorScope = makeScopeForPropertyAccessor(c, setter, propertyDescriptor);
|
||||||
resolveAnnotationArguments(accessorScope, setter);
|
AnnotationResolver.resolveAnnotationsArguments(setterDescriptor.getAnnotations());
|
||||||
resolveFunctionBody(c, fieldAccessTrackingTrace, setter, setterDescriptor, accessorScope);
|
resolveFunctionBody(c, fieldAccessTrackingTrace, setter, setterDescriptor, accessorScope);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -778,10 +778,6 @@ public class BodyResolver {
|
|||||||
c.getOuterDataFlowInfo(), trace);
|
c.getOuterDataFlowInfo(), trace);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resolveAnnotationArguments(@NotNull JetScope scope, @NotNull JetModifierListOwner owner) {
|
|
||||||
AnnotationResolver.resolveAnnotationsArguments(owner.getModifierList(), trace);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void computeDeferredType(JetType type) {
|
private static void computeDeferredType(JetType type) {
|
||||||
// handle type inference loop: function or property body contains a reference to itself
|
// handle type inference loop: function or property body contains a reference to itself
|
||||||
// fun f() = { f() }
|
// fun f() = { f() }
|
||||||
|
|||||||
+1
-1
@@ -211,7 +211,7 @@ public class LazyDeclarationResolver {
|
|||||||
throw new IllegalStateException("No descriptor resolved for " + declaration + ":\n" +
|
throw new IllegalStateException("No descriptor resolved for " + declaration + ":\n" +
|
||||||
PsiUtilPackage.getElementTextWithContext(declaration));
|
PsiUtilPackage.getElementTextWithContext(declaration));
|
||||||
}
|
}
|
||||||
AnnotationResolver.resolveAnnotationsArguments(result.getAnnotations(), trace);
|
AnnotationResolver.resolveAnnotationsArguments(result.getAnnotations());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -90,7 +90,7 @@ public class FunctionsTypingVisitor(facade: ExpressionTypingInternals) : Express
|
|||||||
context.trace, context.dataFlowInfo, context.expectedType
|
context.trace, context.dataFlowInfo, context.expectedType
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
AnnotationResolver.resolveAnnotationsArguments(functionDescriptor.getAnnotations(), context.trace);
|
AnnotationResolver.resolveAnnotationsArguments(functionDescriptor.getAnnotations());
|
||||||
|
|
||||||
val functionInnerScope = FunctionDescriptorUtil.getFunctionInnerScope(context.scope, functionDescriptor, context.trace)
|
val functionInnerScope = FunctionDescriptorUtil.getFunctionInnerScope(context.scope, functionDescriptor, context.trace)
|
||||||
components.expressionTypingServices.checkFunctionReturnType(
|
components.expressionTypingServices.checkFunctionReturnType(
|
||||||
@@ -167,7 +167,7 @@ public class FunctionsTypingVisitor(facade: ExpressionTypingInternals) : Express
|
|||||||
initializeFunctionDescriptorAndExplicitReturnType(context.scope.getContainingDeclaration(), context.scope, functionLiteral,
|
initializeFunctionDescriptorAndExplicitReturnType(context.scope.getContainingDeclaration(), context.scope, functionLiteral,
|
||||||
functionDescriptor, context.trace, context.expectedType)
|
functionDescriptor, context.trace, context.expectedType)
|
||||||
for (parameterDescriptor in functionDescriptor.getValueParameters()) {
|
for (parameterDescriptor in functionDescriptor.getValueParameters()) {
|
||||||
AnnotationResolver.resolveAnnotationsArguments(parameterDescriptor.getAnnotations(), context.trace)
|
AnnotationResolver.resolveAnnotationsArguments(parameterDescriptor.getAnnotations())
|
||||||
}
|
}
|
||||||
BindingContextUtils.recordFunctionDeclarationToDescriptor(context.trace, functionLiteral, functionDescriptor)
|
BindingContextUtils.recordFunctionDeclarationToDescriptor(context.trace, functionLiteral, functionDescriptor)
|
||||||
return functionDescriptor
|
return functionDescriptor
|
||||||
|
|||||||
+1
-1
@@ -49,7 +49,7 @@ public class ValueParameterResolver(
|
|||||||
context: ExpressionTypingContext
|
context: ExpressionTypingContext
|
||||||
) {
|
) {
|
||||||
for ((descriptor, parameter) in valueParameterDescriptors zip valueParameters) {
|
for ((descriptor, parameter) in valueParameterDescriptors zip valueParameters) {
|
||||||
AnnotationResolver.resolveAnnotationsArguments(parameter.getModifierList(), context.trace)
|
AnnotationResolver.resolveAnnotationsArguments(descriptor.getAnnotations())
|
||||||
resolveDefaultValue(descriptor, parameter, context)
|
resolveDefaultValue(descriptor, parameter, context)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -248,21 +248,21 @@ public abstract class ElementResolver protected(
|
|||||||
val modifierList = jetAnnotationEntry.getParentOfType<JetModifierList>(true)
|
val modifierList = jetAnnotationEntry.getParentOfType<JetModifierList>(true)
|
||||||
val declaration = modifierList?.getParentOfType<JetDeclaration>(true)
|
val declaration = modifierList?.getParentOfType<JetDeclaration>(true)
|
||||||
if (declaration != null) {
|
if (declaration != null) {
|
||||||
doResolveAnnotations(resolveSession, getAnnotationsByDeclaration(resolveSession, modifierList!!, declaration))
|
doResolveAnnotations(getAnnotationsByDeclaration(resolveSession, modifierList!!, declaration))
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
val fileAnnotationList = jetAnnotationEntry.getParentOfType<JetFileAnnotationList>(true)
|
val fileAnnotationList = jetAnnotationEntry.getParentOfType<JetFileAnnotationList>(true)
|
||||||
if (fileAnnotationList != null) {
|
if (fileAnnotationList != null) {
|
||||||
doResolveAnnotations(resolveSession, resolveSession.getFileAnnotations(fileAnnotationList.getContainingJetFile()))
|
doResolveAnnotations(resolveSession.getFileAnnotations(fileAnnotationList.getContainingJetFile()))
|
||||||
}
|
}
|
||||||
if (modifierList != null && modifierList.getParent() is JetFile) {
|
if (modifierList != null && modifierList.getParent() is JetFile) {
|
||||||
doResolveAnnotations(resolveSession, resolveSession.getDanglingAnnotations(modifierList.getContainingJetFile()))
|
doResolveAnnotations(resolveSession.getDanglingAnnotations(modifierList.getContainingJetFile()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun doResolveAnnotations(resolveSession: ResolveSession, annotations: Annotations) {
|
private fun doResolveAnnotations(annotations: Annotations) {
|
||||||
AnnotationResolver.resolveAnnotationsArguments(annotations, resolveSession.getTrace())
|
AnnotationResolver.resolveAnnotationsArguments(annotations)
|
||||||
ForceResolveUtil.forceResolveAllContents(annotations)
|
ForceResolveUtil.forceResolveAllContents(annotations)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user