private void handleInputFocusMovement(LogicalPosition position, boolean caret) {
    final Configuration configuration = editor.getUserData(CURRENT_CONFIGURATION_KEY);
    if (configuration == null) {
      return;
    }
    final Document document = editor.getDocument();
    final int lineCount = document.getLineCount();
    if (position.line >= lineCount) {
      return;
    }
    final int lineStart = document.getLineStartOffset(position.line);
    final int lineEnd = document.getLineEndOffset(position.line);
    final CharSequence patternText = document.getCharsSequence().subSequence(lineStart, lineEnd);

    final TextRange variableRange = TemplateImplUtil.findVariableAtOffset(patternText, position.column);
    if (variableRange == null) {
      if (caret) {
        if (myCurrentVariableCallback != null) {
          myCurrentVariableCallback.accept(Configuration.CONTEXT_VAR_NAME);
        }
      }
      return;
    }
    final String variableName = variableRange.subSequence(patternText).toString();
    final NamedScriptableDefinition variable = configuration.findVariable(variableName);
    final boolean replacementVariable =
      variable instanceof ReplacementVariableDefinition ||
      myCanBeReplace && variable == null && configuration instanceof ReplaceConfiguration;
    final String currentVariableName = replacementVariable
                                       ? variableName + ReplaceConfiguration.REPLACEMENT_VARIABLE_SUFFIX
                                       : variableName;
    if (caret) {
      if (myCurrentVariableCallback != null) {
        myCurrentVariableCallback.accept(currentVariableName);
      }
    }
  }
private void handleInputFocusMovement(LogicalPosition position, boolean caret)