Exemplo n.º 1
0
  public PsiElement handleElementRename(String newName) throws IncorrectOperationException {
    if (!BashIdentifierUtil.isValidIdentifier(newName)) {
      throw new IncorrectOperationException("Can't have an empty name");
    }

    // if this is variable which doesn't have a $ sign prefix
    if (isSingleWord()) {
      // return BashPsiUtils.replaceElement(this, BashChangeUtil.createWord(getProject(), newName));
      return BashPsiUtils.replaceElement(
          this, BashChangeUtil.createVariable(getProject(), newName, true));
    }

    return BashPsiUtils.replaceElement(
        this, BashChangeUtil.createVariable(getProject(), newName, false));
  }
Exemplo n.º 2
0
  public PsiElement handleElementRename(String newName) throws IncorrectOperationException {
    if (StringUtil.isEmpty(newName)) {
      return null;
    }

    final PsiElement original = commandElement();
    final PsiElement replacement = BashChangeUtil.createWord(getProject(), newName);

    getNode().replaceChild(original.getNode(), replacement.getNode());
    return this;
  }