本文整理汇总了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();
}
示例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();
}
}
示例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);
}
}
}
示例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();
}
示例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;
}
}