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