Minor. Extract method
This commit is contained in:
@@ -108,7 +108,8 @@ public class AnnotationResolver {
|
|||||||
|
|
||||||
private Annotations resolveAnnotationEntries(
|
private Annotations resolveAnnotationEntries(
|
||||||
@NotNull JetScope scope,
|
@NotNull JetScope scope,
|
||||||
@NotNull List<JetAnnotationEntry> annotationEntryElements, @NotNull BindingTrace trace,
|
@NotNull List<JetAnnotationEntry> annotationEntryElements,
|
||||||
|
@NotNull BindingTrace trace,
|
||||||
boolean shouldResolveArguments
|
boolean shouldResolveArguments
|
||||||
) {
|
) {
|
||||||
if (annotationEntryElements.isEmpty()) return Annotations.EMPTY;
|
if (annotationEntryElements.isEmpty()) return Annotations.EMPTY;
|
||||||
@@ -117,7 +118,7 @@ public class AnnotationResolver {
|
|||||||
AnnotationDescriptorImpl descriptor = trace.get(BindingContext.ANNOTATION, entryElement);
|
AnnotationDescriptorImpl descriptor = trace.get(BindingContext.ANNOTATION, entryElement);
|
||||||
if (descriptor == null) {
|
if (descriptor == null) {
|
||||||
descriptor = new AnnotationDescriptorImpl();
|
descriptor = new AnnotationDescriptorImpl();
|
||||||
resolveAnnotationStub(scope, entryElement, descriptor, trace);
|
descriptor.setAnnotationType(resolveAnnotationType(scope, entryElement, trace));
|
||||||
trace.record(BindingContext.ANNOTATION, entryElement, descriptor);
|
trace.record(BindingContext.ANNOTATION, entryElement, descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,14 +131,23 @@ public class AnnotationResolver {
|
|||||||
return new AnnotationsImpl(result);
|
return new AnnotationsImpl(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resolveAnnotationStub(
|
@NotNull
|
||||||
@NotNull JetScope scope,
|
public JetType resolveAnnotationType(
|
||||||
@NotNull JetAnnotationEntry entryElement,
|
JetScope scope,
|
||||||
@NotNull AnnotationDescriptorImpl annotationDescriptor,
|
JetAnnotationEntry entryElement,
|
||||||
@NotNull BindingTrace trace
|
BindingTrace trace
|
||||||
) {
|
) {
|
||||||
TemporaryBindingTrace temporaryBindingTrace = new TemporaryBindingTrace(trace, "Trace for resolve annotation type");
|
TemporaryBindingTrace temporaryBindingTrace = new TemporaryBindingTrace(trace, "Trace for resolve annotation type");
|
||||||
OverloadResolutionResults<FunctionDescriptor> results = resolveAnnotationCall(entryElement, scope, temporaryBindingTrace);
|
OverloadResolutionResults<FunctionDescriptor> results = resolveAnnotationCall(entryElement, scope, temporaryBindingTrace);
|
||||||
|
return getAnnotationTypeFromResolutionResults(entryElement, trace, results);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static JetType getAnnotationTypeFromResolutionResults(
|
||||||
|
JetAnnotationEntry entryElement,
|
||||||
|
BindingTrace trace,
|
||||||
|
OverloadResolutionResults<FunctionDescriptor> results
|
||||||
|
) {
|
||||||
if (results.isSingleResult()) {
|
if (results.isSingleResult()) {
|
||||||
FunctionDescriptor descriptor = results.getResultingDescriptor();
|
FunctionDescriptor descriptor = results.getResultingDescriptor();
|
||||||
if (!ErrorUtils.isError(descriptor)) {
|
if (!ErrorUtils.isError(descriptor)) {
|
||||||
@@ -152,17 +162,19 @@ public class AnnotationResolver {
|
|||||||
trace.report(Errors.NOT_AN_ANNOTATION_CLASS.on(entryElement, descriptor.getName().asString()));
|
trace.report(Errors.NOT_AN_ANNOTATION_CLASS.on(entryElement, descriptor.getName().asString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
JetType annotationType = results.getResultingDescriptor().getReturnType();
|
JetType type = results.getResultingDescriptor().getReturnType();
|
||||||
annotationDescriptor.setAnnotationType(annotationType);
|
assert type != null : "No return type for " + results.getResultingDescriptor();
|
||||||
|
return type;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
JetConstructorCalleeExpression calleeExpression = entryElement.getCalleeExpression();
|
JetConstructorCalleeExpression calleeExpression = entryElement.getCalleeExpression();
|
||||||
annotationDescriptor.setAnnotationType(ErrorUtils.createErrorType("Unresolved annotation type: " +
|
return ErrorUtils.createErrorType("Unresolved annotation type: " +
|
||||||
(calleeExpression == null ? "null" : calleeExpression.getText())));
|
(calleeExpression == null ? "null" : calleeExpression.getText()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private OverloadResolutionResults<FunctionDescriptor> resolveAnnotationCall(
|
@NotNull
|
||||||
|
public OverloadResolutionResults<FunctionDescriptor> resolveAnnotationCall(
|
||||||
JetAnnotationEntry annotationEntry,
|
JetAnnotationEntry annotationEntry,
|
||||||
JetScope scope,
|
JetScope scope,
|
||||||
BindingTrace trace
|
BindingTrace trace
|
||||||
|
|||||||
Reference in New Issue
Block a user