Skip to content

Commit b1bd674

Browse files
dodgexWonderCsabo
authored andcommitted
Generate classes despite validation errors
1 parent 31d9e9f commit b1bd674

3 files changed

Lines changed: 5 additions & 49 deletions

File tree

‎AndroidAnnotations/androidannotations-core/androidannotations/src/main/java/org/androidannotations/internal/AndroidAnnotationProcessor.java‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/**
22
* Copyright (C) 2010-2016 eBusiness Information, Excilys Group
3+
* Copyright (C) 2016-2017 the AndroidAnnotations project
34
*
45
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
56
* use this file except in compliance with the License. You may obtain a copy of
@@ -37,7 +38,6 @@
3738
import org.androidannotations.internal.exception.AndroidManifestNotFoundException;
3839
import org.androidannotations.internal.exception.ProcessingException;
3940
import org.androidannotations.internal.exception.RClassNotFoundException;
40-
import org.androidannotations.internal.exception.ValidationException;
4141
import org.androidannotations.internal.exception.VersionMismatchException;
4242
import org.androidannotations.internal.exception.VersionNotFoundException;
4343
import org.androidannotations.internal.generation.CodeModelGenerator;
@@ -124,8 +124,6 @@ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment
124124
try {
125125
checkApiAndProcessorVersions();
126126
processThrowing(annotations, roundEnv);
127-
} catch (ValidationException e) {
128-
// We do nothing, errors have been printed by ModelValidator
129127
} catch (ProcessingException e) {
130128
handleException(annotations, roundEnv, e);
131129
} catch (Exception e) {
@@ -210,7 +208,7 @@ private IRClass findRClasses(AndroidManifest androidManifest) throws RClassNotFo
210208
}
211209
}
212210

213-
private AnnotationElements validateAnnotations(AnnotationElements extractedModel, AnnotationElementsHolder validatingHolder) throws ValidationException {
211+
private AnnotationElements validateAnnotations(AnnotationElements extractedModel, AnnotationElementsHolder validatingHolder) {
214212
timeStats.start("Validate Annotations");
215213
ModelValidator modelValidator = new ModelValidator(androidAnnotationsEnv);
216214
AnnotationElements validatedAnnotations = modelValidator.validate(extractedModel, validatingHolder);

‎AndroidAnnotations/androidannotations-core/androidannotations/src/main/java/org/androidannotations/internal/exception/ValidationException.java‎

Lines changed: 0 additions & 34 deletions
This file was deleted.

‎AndroidAnnotations/androidannotations-core/androidannotations/src/main/java/org/androidannotations/internal/process/ModelValidator.java‎

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/**
22
* Copyright (C) 2010-2016 eBusiness Information, Excilys Group
3+
* Copyright (C) 2016-2017 the AndroidAnnotations project
34
*
45
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
56
* use this file except in compliance with the License. You may obtain a copy of
@@ -15,9 +16,7 @@
1516
*/
1617
package org.androidannotations.internal.process;
1718

18-
import java.util.ArrayList;
1919
import java.util.LinkedHashSet;
20-
import java.util.List;
2120
import java.util.Set;
2221

2322
import javax.lang.model.element.AnnotationMirror;
@@ -26,7 +25,6 @@
2625
import org.androidannotations.AndroidAnnotationsEnvironment;
2726
import org.androidannotations.ElementValidation;
2827
import org.androidannotations.handler.AnnotationHandler;
29-
import org.androidannotations.internal.exception.ValidationException;
3028
import org.androidannotations.internal.model.AnnotationElements;
3129
import org.androidannotations.internal.model.AnnotationElementsHolder;
3230
import org.androidannotations.logger.Logger;
@@ -41,10 +39,9 @@ public ModelValidator(AndroidAnnotationsEnvironment environment) {
4139
this.environment = environment;
4240
}
4341

44-
public AnnotationElements validate(AnnotationElements extractedModel, AnnotationElementsHolder validatingHolder) throws ValidationException {
42+
public AnnotationElements validate(AnnotationElements extractedModel, AnnotationElementsHolder validatingHolder) {
4543

4644
LOGGER.info("Validating elements");
47-
List<ElementValidation> failedValidations = new ArrayList<>();
4845

4946
/*
5047
* We currently do not validate the elements on the ancestors, assuming
@@ -78,22 +75,17 @@ public AnnotationElements validate(AnnotationElements extractedModel, Annotation
7875
}
7976

8077
for (String warning : elementValidation.getWarnings()) {
81-
LOGGER.warn(warning, elementValidation.getElement(), elementValidation.getAnnotationMirror());
78+
LOGGER.warn(warning, elementValidation.getElement(), annotationMirror);
8279
}
8380

8481
if (elementValidation.isValid()) {
8582
validatedAnnotatedElements.add(annotatedElement);
8683
} else {
87-
failedValidations.add(elementValidation);
8884
LOGGER.warn("Element {} invalidated by {}", annotatedElement, annotatedElement, validatorSimpleName);
8985
}
9086
}
9187
}
9288

93-
if (!failedValidations.isEmpty()) {
94-
throw new ValidationException(failedValidations);
95-
}
96-
9789
return validatingHolder;
9890
}
9991
}

0 commit comments

Comments
 (0)