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


Java PsiStatement.getProject方法代码示例

本文整理汇总了Java中com.intellij.psi.PsiStatement.getProject方法的典型用法代码示例。如果您正苦于以下问题:Java PsiStatement.getProject方法的具体用法?Java PsiStatement.getProject怎么用?Java PsiStatement.getProject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.psi.PsiStatement的用法示例。


在下文中一共展示了PsiStatement.getProject方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: replaceStatement

import com.intellij.psi.PsiStatement; //导入方法依赖的package包/类
protected static void replaceStatement(
  @NotNull PsiStatement statement,
  @NotNull @NonNls String newStatementText)
  throws IncorrectOperationException {
  final Project project = statement.getProject();
  final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project);
  final PsiElementFactory factory = psiFacade.getElementFactory();
  final PsiStatement newStatement =
    factory.createStatementFromText(newStatementText, statement);
  final PsiElement replacementExp = statement.replace(newStatement);
  final CodeStyleManager styleManager =
    CodeStyleManager.getInstance(project);
  styleManager.reformat(replacementExp);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:15,代码来源:InspectionGadgetsFix.java

示例2: replaceStatement

import com.intellij.psi.PsiStatement; //导入方法依赖的package包/类
protected static void replaceStatement(@NonNls @NotNull String newStatementText, @NonNls @NotNull PsiStatement statement) {
  final Project project = statement.getProject();
  final PsiElementFactory factory = JavaPsiFacade.getElementFactory(project);
  final PsiStatement newStatement = factory.createStatementFromText(newStatementText, statement);
  final PsiElement insertedElement = statement.replace(newStatement);
  final CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(project);
  codeStyleManager.reformat(insertedElement);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:9,代码来源:Intention.java

示例3: replaceStatementAndShorten

import com.intellij.psi.PsiStatement; //导入方法依赖的package包/类
protected static void replaceStatementAndShorten(@NonNls @NotNull String newStatementText, @NonNls @NotNull PsiStatement statement) {
  final Project project = statement.getProject();
  final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project);
  final PsiElementFactory factory = psiFacade.getElementFactory();
  final PsiStatement newStatement = factory.createStatementFromText(newStatementText, statement);
  final PsiElement insertedElement = statement.replace(newStatement);
  final JavaCodeStyleManager javaCodeStyleManager = JavaCodeStyleManager.getInstance(project);
  final PsiElement shortenedElement = javaCodeStyleManager.shortenClassReferences(insertedElement);
  final CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(project);
  codeStyleManager.reformat(shortenedElement);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:12,代码来源:Intention.java


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