本文整理汇总了Java中com.intellij.psi.PsiStatement.getText方法的典型用法代码示例。如果您正苦于以下问题:Java PsiStatement.getText方法的具体用法?Java PsiStatement.getText怎么用?Java PsiStatement.getText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.PsiStatement
的用法示例。
在下文中一共展示了PsiStatement.getText方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processIntention
import com.intellij.psi.PsiStatement; //导入方法依赖的package包/类
public void processIntention(PsiElement element)
throws IncorrectOperationException {
final PsiJavaToken token = (PsiJavaToken)element;
final PsiIfStatement parentStatement =
(PsiIfStatement)token.getParent();
if (parentStatement == null) {
return;
}
final PsiStatement elseBranch = parentStatement.getElseBranch();
if (elseBranch == null) {
return;
}
final String newStatement = '{' + elseBranch.getText() + '}';
PsiReplacementUtil.replaceStatement(elseBranch, newStatement);
}
示例2: processIntention
import com.intellij.psi.PsiStatement; //导入方法依赖的package包/类
public void processIntention(PsiElement element)
throws IncorrectOperationException {
final PsiJavaToken token = (PsiJavaToken)element;
final PsiIfStatement parentStatement =
(PsiIfStatement)token.getParent();
if (parentStatement == null) {
return;
}
final PsiStatement elseBranch = parentStatement.getElseBranch();
if (elseBranch == null) {
return;
}
final String newStatement = '{' + elseBranch.getText() + '}';
replaceStatement(newStatement, elseBranch);
}
示例3: processIntention
import com.intellij.psi.PsiStatement; //导入方法依赖的package包/类
public void processIntention(PsiElement element)
throws IncorrectOperationException {
final PsiJavaToken token =
(PsiJavaToken)element;
final PsiIfStatement parentStatement =
(PsiIfStatement)token.getParent();
if (parentStatement == null) {
return;
}
final PsiStatement parentThenBranch = parentStatement.getThenBranch();
final PsiIfStatement childStatement =
(PsiIfStatement)ConditionalUtils.stripBraces(parentThenBranch);
final PsiExpression childCondition = childStatement.getCondition();
if (childCondition == null) {
return;
}
final String childConditionText;
if (ParenthesesUtils.getPrecedence(childCondition)
> ParenthesesUtils.AND_PRECEDENCE) {
childConditionText = '(' + childCondition.getText() + ')';
}
else {
childConditionText = childCondition.getText();
}
final PsiExpression parentCondition = parentStatement.getCondition();
if (parentCondition == null) {
return;
}
final String parentConditionText;
if (ParenthesesUtils.getPrecedence(parentCondition)
> ParenthesesUtils.AND_PRECEDENCE) {
parentConditionText = '(' + parentCondition.getText() + ')';
}
else {
parentConditionText = parentCondition.getText();
}
final PsiStatement childThenBranch = childStatement.getThenBranch();
if (childThenBranch == null) {
return;
}
@NonNls final String statement = "if(" + parentConditionText + "&&" +
childConditionText + ')' + childThenBranch.getText();
replaceStatement(statement, parentStatement);
}