當前位置: 首頁>>代碼示例>>Java>>正文


Java PsiElement.delete方法代碼示例

本文整理匯總了Java中com.intellij.psi.PsiElement.delete方法的典型用法代碼示例。如果您正苦於以下問題:Java PsiElement.delete方法的具體用法?Java PsiElement.delete怎麽用?Java PsiElement.delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.intellij.psi.PsiElement的用法示例。


在下文中一共展示了PsiElement.delete方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: deleteFunctionParam

import com.intellij.psi.PsiElement; //導入方法依賴的package包/類
public static void deleteFunctionParam(PsiElement element) {
    PsiElement next = element.getNextSibling();
    if (next != null && next.getText().equals(",")) {
        next.delete();
    } else {
        PsiElement prev = element.getPrevSibling();
        if (prev != null && prev instanceof PsiWhiteSpace) {
            prev.delete();
            prev = element.getPrevSibling();
        }
        if (prev != null && prev.getText().equals(",")) {
            prev.delete();
        }
    }
    element.delete();
}
 
開發者ID:nvlad,項目名稱:yii2support,代碼行數:17,代碼來源:PsiUtil.java

示例2: applyFix

import com.intellij.psi.PsiElement; //導入方法依賴的package包/類
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
    final PsiElement expression = descriptor.getPsiElement();
    if (expression instanceof ArrayHashElement) {
        PsiElement next = expression.getNextSibling();
        if (next instanceof PsiWhiteSpace) {
            next.delete();
        }
        next = expression.getNextSibling();
        if (null != next && PhpTokenTypes.opCOMMA == next.getNode().getElementType()) {
            next.delete();
        }
        next = expression.getNextSibling();
        if (next instanceof PsiWhiteSpace) {
            next.delete();
        }

        expression.delete();
    }
}
 
開發者ID:kalessil,項目名稱:yii2inspections,代碼行數:21,代碼來源:UnusedTranslationsInspector.java

示例3: applyFix

import com.intellij.psi.PsiElement; //導入方法依賴的package包/類
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor problemDescriptor) {
    Method method = (Method)methodReference.resolve();
    if (method != null) {
      Parameter[] parameters = method.getParameters();
      int paramParameterIndex = ClassUtils.getParamIndex(method, "params");
      int conditionParameterIndex = ClassUtils.getParamIndex(method, new String[]{ "condition", "expression", "sql"});

      if (paramParameterIndex > -1
              && conditionParameterIndex > -1
              && conditionParameterIndex == paramParameterIndex - 1
              && methodReference.getParameters().length > conditionParameterIndex) {
          String condition = methodReference.getParameters()[conditionParameterIndex].getText();
          String[] conditionParams = DatabaseUtils.extractParamsFromCondition(condition);

          ArrayCreationExpression array = null;
          if (methodReference.getParameters().length > paramParameterIndex) {
              PsiElement paramParameter = methodReference.getParameters()[paramParameterIndex];
              if (paramParameter instanceof ArrayCreationExpression)
                  array = (ArrayCreationExpression)paramParameter;
              paramParameter.delete();
          }

          TemplateManager templateManager = TemplateManager.getInstance(project);
          Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor();
          if (editor == null || methodReference.getParameterList() == null) return;

          editor.getCaretModel().moveToOffset(methodReference.getParameterList().getLastChild().getTextRange().getEndOffset());
          PsiDocumentManager.getInstance(project).doPostponedOperationsAndUnblockDocument(editor.getDocument());
          Template template = templateManager.createTemplate("", "");
          template.setToReformat(true);
          buildParamArray(template, conditionParams, array, conditionParameterIndex);

          PsiDocumentManager.getInstance(project).doPostponedOperationsAndUnblockDocument(editor.getDocument());
          templateManager.startTemplate(editor, template);
      }
    }

}
 
開發者ID:nvlad,項目名稱:yii2support,代碼行數:40,代碼來源:MissedParamQuickFix.java

示例4: deleteArrayElement

import com.intellij.psi.PsiElement; //導入方法依賴的package包/類
public static void deleteArrayElement(PsiElement element) {
    PsiElement next = element.getNextSibling();
    String endArray = ((ArrayCreationExpression) element.getParent()).isShortSyntax() ? "]" : ")";

    if (next instanceof PsiWhiteSpace && next.getNextSibling().getText() != null) {
        if (next.getNextSibling().getText().equals(endArray)) {
            next = next.getNextSibling();
        }
    }
    if (next.getText().equals(endArray)) {
        Boolean deleteComma = false;
        if (element.getPrevSibling() instanceof PsiWhiteSpace) {
            deleteComma = !element.getPrevSibling().getText().contains("\n");
            element.getPrevSibling().delete();
        }
        if (deleteComma && element.getPrevSibling().getText().equals(",")) {
            element.getPrevSibling().delete();
        }
    }
    if (next.getText().equals(",")) {
        if (next.getNextSibling() instanceof PsiWhiteSpace) {
            next.getNextSibling().delete();
        }
        next.delete();
    }
    element.delete();
}
 
開發者ID:nvlad,項目名稱:yii2support,代碼行數:28,代碼來源:PsiUtil.java

示例5: applyFix

import com.intellij.psi.PsiElement; //導入方法依賴的package包/類
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor problemDescriptor)
{
    PsiElement problemElement = problemDescriptor.getPsiElement();
    PsiElement parent = getParentProperty(problemElement);

    // If there are still other settings present, just remove this one.
    if (childCount(parent) > 1)
    {
        problemElement.delete();

        CodeStyleManager
            .getInstance(project)
            .adjustLineIndent(parent.getContainingFile(), parent.getTextRange());

        return;
    }

    // Navigate upwards until a node containing more than one setting is found.
    while (true)
    {
        PsiElement nextParent = getParentProperty(parent);

        if (nextParent == null || childCount(nextParent) != 1)
        {
            // Remove entire unused tree.
            parent.delete();
            return;
        }

        parent = nextParent;
    }
}
 
開發者ID:whitefire,項目名稱:roc-completion,代碼行數:34,代碼來源:QuickFix.java


注:本文中的com.intellij.psi.PsiElement.delete方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。