当前位置: 首页>>代码示例>>Java>>正文


Java PsiStatement.getText方法代码示例

本文整理汇总了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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:SplitElseIfIntention.java

示例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);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:16,代码来源:SplitElseIfIntention.java

示例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);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:46,代码来源:MergeIfAndIntention.java


注:本文中的com.intellij.psi.PsiStatement.getText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。