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