提交 8c65ed9e 编写于 作者: C Christian Dupuis

some updates to error reporting to let errors show up in STS

上级 df6ba69b
......@@ -132,7 +132,7 @@ class ConfigurationClassParser {
public void processImport(ConfigurationClass configClass, String[] classesToImport) throws IOException {
if (this.importStack.contains(configClass)) {
this.problemReporter.error(new CircularImportProblem(configClass, this.importStack));
this.problemReporter.error(new CircularImportProblem(configClass, this.importStack, configClass.getMetadata()));
}
else {
this.importStack.push(configClass);
......@@ -148,7 +148,7 @@ class ConfigurationClassParser {
AnnotationMetadata metadata = reader.getAnnotationMetadata();
if (!metadata.hasAnnotation(Configuration.class.getName())) {
this.problemReporter.error(
new NonAnnotatedConfigurationProblem(metadata.getClassName(), reader.getResource()));
new NonAnnotatedConfigurationProblem(metadata.getClassName(), reader.getResource(), metadata));
}
else {
processConfigurationClass(new ConfigurationClass(reader, null));
......@@ -218,10 +218,10 @@ class ConfigurationClassParser {
*/
private static class NonAnnotatedConfigurationProblem extends Problem {
public NonAnnotatedConfigurationProblem(String className, Resource resource) {
public NonAnnotatedConfigurationProblem(String className, Resource resource, AnnotationMetadata metadata) {
super(String.format("%s was imported as a @Configuration class but was not actually annotated " +
"with @Configuration. Annotate the class or do not attempt to process it.", className),
new Location(resource));
new Location(resource, metadata));
}
}
......@@ -232,13 +232,13 @@ class ConfigurationClassParser {
*/
private static class CircularImportProblem extends Problem {
public CircularImportProblem(ConfigurationClass attemptedImport, Stack<ConfigurationClass> importStack) {
public CircularImportProblem(ConfigurationClass attemptedImport, Stack<ConfigurationClass> importStack, AnnotationMetadata metadata) {
super(String.format("A circular @Import has been detected: " +
"Illegal attempt by @Configuration class '%s' to import class '%s' as '%s' is " +
"already present in the current import stack [%s]",
importStack.peek().getSimpleName(), attemptedImport.getSimpleName(),
attemptedImport.getSimpleName(), importStack),
new Location(importStack.peek().getResource())
new Location(importStack.peek().getResource(), metadata)
);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册