Source:
<code>public ICompletionResult getCompletion(String expression, int offset, Map<String, Set<IType>> variableTypes) { final ICompletionResult result; final AstCompletor completor = new AstCompletor(new CompletionServices(queryEnvironment)); if (offset < 0 || (expression != null && offset > expression.length())) { throw new IllegalArgumentException("offset must be in the range of the given expression."); } final String prefix = getPrefix(expression, offset); final String remaining = getRemaining(expression, offset); final String toParse = getToParse(expression, offset, prefix); final IQueryValidationEngine builder = new QueryValidationEngine(queryEnvironment); final IValidationResult validationResult = builder.validate(toParse, variableTypes); result = new CompletionResult(completor.getProposals(variableTypes.keySet(), validationResult)); result.setPrefix(prefix); result.setRemaining(remaining); int replacementLength = 0; int replacementOffset = 0; if (toParse != null) { replacementOffset = toParse.length(); } List<Error> errors = validationResult.getAstResult().getErrors(); if (!errors.isEmpty()) { Error lastError = errors.get(errors.size() - 1); if (lastError instanceof Expression) { replacementOffset = validationResult.getAstResult().getStartPosition((Expression)lastError); replacementLength = validationResult.getAstResult().getEndPosition((Expression)lastError) - replacementOffset; } } result.setReplacementOffset(replacementOffset); <START> result.setReplacementLength(replacementLength); <END> return result; }</code><technical_language>I missing is replacementLength 0 if errors? this replacementLength replacementOffset information exist in integration of interpreters in Sirius simple cases errors replacementLength is 0. this information AQL computed in AQL/Sirius bridge interesting</technical_language>

Target:
public ICompletionResult getCompletion(String expression, int offset, Map<String, Set<IType>> variableTypes) { final ICompletionResult result; final AstCompletor completor = new AstCompletor(new CompletionServices(queryEnvironment)); if (offset < 0 || (expression != null && offset > expression.length())) { throw new IllegalArgumentException("offset must be in the range of the given expression."); } final String prefix = getPrefix(expression, offset); final String remaining = getRemaining(expression, offset); final String toParse = getToParse(expression, offset, prefix); final IQueryValidationEngine builder = new QueryValidationEngine(queryEnvironment); final IValidationResult validationResult = builder.validate(toParse, variableTypes); result = new CompletionResult(completor.getProposals(variableTypes.keySet(), validationResult)); result.setPrefix(prefix); result.setRemaining(remaining); int replacementLength = 0; int replacementOffset = 0; if (toParse != null) { replacementOffset = toParse.length(); } List<Error> errors = validationResult.getAstResult().getErrors(); if (!errors.isEmpty()) { Error lastError = errors.get(errors.size() - 1); if (lastError instanceof ErrorTypeLiteral || lastError instanceof ErrorEnumLiteral) { replacementOffset = validationResult.getAstResult().getStartPosition((Expression)lastError); replacementLength = validationResult.getAstResult().getEndPosition((Expression)lastError) - replacementOffset; } } if (prefix != null) { replacementLength += prefix.length(); } if (remaining != null) { replacementLength += remaining.length(); } result.setReplacementOffset(replacementOffset); result.setReplacementLength(replacementLength); return result; }