当前位置: 首页>>代码示例>>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;未经允许,请勿转载。