use of org.jboss.forge.roaster.model.SyntaxError in project kie-wb-common by kiegroup.
the class JavaRoasterModelDriver method parseAnnotationWithValuePair.
public Pair<AnnotationSource<JavaClassSource>, List<DriverError>> parseAnnotationWithValuePair(String annotationClassName, ElementType target, String valuePairName, String literalValue) {
List<DriverError> syntaxErrors = new ArrayList<DriverError>();
String annotationStr = "@" + annotationClassName + "(" + valuePairName + "=" + literalValue + " )";
String stub;
AnnotationSource<JavaClassSource> annotation = null;
if (ElementType.TYPE.equals(target)) {
stub = annotationStr + " public class Stub { }";
} else {
stub = "public class Stub { " + annotationStr + " int dummy; }";
}
JavaClassSource temp = (JavaClassSource) Roaster.parse(JavaClass.class, stub);
if (temp.getSyntaxErrors() != null && temp.getSyntaxErrors().size() > 0) {
for (org.jboss.forge.roaster.model.SyntaxError syntaxError : temp.getSyntaxErrors()) {
syntaxErrors.add(new DriverError(syntaxError.getDescription(), syntaxError.getLine(), syntaxError.getColumn()));
}
} else if (ElementType.TYPE.equals(target)) {
annotation = temp.getAnnotation(annotationClassName);
} else {
annotation = temp.getField("dummy").getAnnotation(annotationClassName);
}
if (annotation == null) {
syntaxErrors.add(new DriverError("Annotation value pair could not be parsed."));
}
return new Pair<>(annotation, syntaxErrors);
}
use of org.jboss.forge.roaster.model.SyntaxError in project kie-wb-common by kiegroup.
the class JavaRoasterModelDriver method addSyntaxErrors.
private void addSyntaxErrors(DriverResult result, Path file, List<SyntaxError> syntaxErrors) {
DriverError error;
for (SyntaxError syntaxError : syntaxErrors) {
error = new DriverError(syntaxError.getDescription(), Paths.convert(file));
error.setLine(syntaxError.getLine());
error.setColumn(syntaxError.getColumn());
result.addError(error);
}
}
use of org.jboss.forge.roaster.model.SyntaxError in project kie-wb-common by kiegroup.
the class DataModelerServiceHelper method toDataModelerError.
public List<DataModelerError> toDataModelerError(List<SyntaxError> syntaxErrors, Path file) {
List<DataModelerError> errors = new ArrayList<DataModelerError>();
DataModelerError error;
for (SyntaxError syntaxError : syntaxErrors) {
error = new DataModelerError(syntaxError.getDescription(), syntaxError.isError() ? Level.ERROR : Level.WARNING, Paths.convert(file));
error.setColumn(syntaxError.getColumn());
error.setLine(syntaxError.getLine());
errors.add(error);
}
return errors;
}
Aggregations