use of org.activityinfo.model.formula.FormulaError in project activityinfo by bedatadriven.
the class Linter method applyMarks.
private void applyMarks(ParsedFormula formula) {
if (!formula.isValid()) {
for (FormulaError error : formula.getErrors()) {
if (error.hasSourceRange()) {
SourceRange range = error.getSourceRange();
MarkOptions options = MarkOptions.create();
options.setClassName("CodeMirror-lint-mark-error");
options.setTitle(error.getMessage());
TextMarker marker = editor.getDoc().markText(pos(range.getStart()), pos(range.getEnd()), options);
markers.add(marker);
}
}
} else {
for (FieldReference fieldReference : formula.getReferences()) {
SourceRange range = fieldReference.getSourceRange();
MarkOptions options = MarkOptions.create();
options.setClassName(FormulaResources.INSTANCE.styles().fieldAnnotation());
options.setTitle(fieldReference.getDescription());
TextMarker marker = editor.getDoc().markText(pos(range.getStart()), pos(range.getEnd()), options);
markers.add(marker);
}
}
}
use of org.activityinfo.model.formula.FormulaError in project activityinfo by bedatadriven.
the class FormulaValidatorTest method validate.
private FormulaValidator validate(String formula) {
Survey surveyForm = catalog.getSurvey();
FormulaValidator validator = new FormulaValidator(catalog.getFormTree(surveyForm.getFormId()));
validator.validate(FormulaParser.parse(formula));
for (FormulaError error : validator.getErrors()) {
System.out.println("Error at " + error.getSourceRange() + ": " + error.getMessage());
}
return validator;
}
Aggregations