public SourceRange(SourceRange start, SourceRange end) { this(start.getStart(), end.getEnd()); }
private FormulaNode unary() { // <unary> ::= + <unary> | - <unary> | <unary2> if(!lexer.hasNext()) { throw new FormulaSyntaxException("Unexpected end of formula"); } Token token = lexer.peek(); if(token.getType() == TokenType.OPERATOR) { if(token.getString().equals("-") || token.getString().equals("+")) { Token opToken = lexer.next(); FormulaFunction op = function(opToken); FormulaNode operand = unary(); SourceRange sourceRange = new SourceRange(opToken.getStart(), operand.getSourceRange().getEnd()); return new FunctionCallNode(op, singletonList(operand), sourceRange); } } return unary2(); }
private FormulaNode unary2() { if(!lexer.hasNext()) { throw new FormulaSyntaxException("Unexpected end of formula"); } Token token = lexer.peek(); if(token.getType() == TokenType.OPERATOR) { if(token.getString().equals("!")) { Token opToken = lexer.next(); FormulaFunction op = function(opToken); FormulaNode operand = primary(); SourceRange sourceRange = new SourceRange(opToken.getStart(), operand.getSourceRange().getEnd()); return new FunctionCallNode(op, singletonList(operand), sourceRange); } } return primary(); }
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); } } }