use of com.intellij.codeInsight.template.impl.Variable in project intellij-community by JetBrains.
the class SubstitutionShortInfoHandler method handleInputFocusMovement.
private void handleInputFocusMovement(LogicalPosition position) {
checkModelValidity();
String text = "";
final int offset = editor.logicalPositionToOffset(position);
final int length = editor.getDocument().getTextLength();
final CharSequence elements = editor.getDocument().getCharsSequence();
int start = offset - 1;
int end = -1;
while (start >= 0 && Character.isJavaIdentifierPart(elements.charAt(start)) && elements.charAt(start) != '$') start--;
if (start >= 0 && elements.charAt(start) == '$') {
end = offset;
while (end < length && Character.isJavaIdentifierPart(elements.charAt(end)) && elements.charAt(end) != '$') end++;
if (end < length && elements.charAt(end) == '$') {
String varname = elements.subSequence(start + 1, end).toString();
Variable foundVar = null;
for (final Variable var : variables) {
if (var.getName().equals(varname)) {
foundVar = var;
break;
}
}
if (foundVar != null) {
text = UIUtil.getShortParamString(editor.getUserData(CURRENT_CONFIGURATION_KEY), varname);
}
}
}
if (text.length() > 0) {
UIUtil.showTooltip(editor, start, end + 1, text);
} else {
TooltipController.getInstance().cancelTooltips();
}
}
Aggregations