本文整理汇总了Java中com.intellij.refactoring.extractMethod.ExtractMethodProcessor.doNotPassParameter方法的典型用法代码示例。如果您正苦于以下问题:Java ExtractMethodProcessor.doNotPassParameter方法的具体用法?Java ExtractMethodProcessor.doNotPassParameter怎么用?Java ExtractMethodProcessor.doNotPassParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.refactoring.extractMethod.ExtractMethodProcessor
的用法示例。
在下文中一共展示了ExtractMethodProcessor.doNotPassParameter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: performExtractMethod
import com.intellij.refactoring.extractMethod.ExtractMethodProcessor; //导入方法依赖的package包/类
public static boolean performExtractMethod(boolean doRefactor,
boolean replaceAllDuplicates,
Editor editor,
PsiFile file,
Project project,
final boolean extractChainedConstructor,
PsiType returnType,
boolean makeStatic,
String newNameOfFirstParam,
int... disabledParams)
throws PrepareFailedException, IncorrectOperationException {
int startOffset = editor.getSelectionModel().getSelectionStart();
int endOffset = editor.getSelectionModel().getSelectionEnd();
PsiElement[] elements;
PsiExpression expr = CodeInsightUtil.findExpressionInRange(file, startOffset, endOffset);
if (expr != null) {
elements = new PsiElement[]{expr};
}
else {
elements = CodeInsightUtil.findStatementsInRange(file, startOffset, endOffset);
}
if (elements.length == 0) {
final PsiExpression expression = IntroduceVariableBase.getSelectedExpression(project, file, startOffset, endOffset);
if (expression != null) {
elements = new PsiElement[]{expression};
}
}
assertTrue(elements.length > 0);
final ExtractMethodProcessor processor =
new ExtractMethodProcessor(project, editor, elements, null, "Extract Method", "newMethod", null);
processor.setShowErrorDialogs(false);
processor.setChainedConstructor(extractChainedConstructor);
if (!processor.prepare()) {
return false;
}
if (doRefactor) {
processor.testPrepare(returnType, makeStatic);
processor.testNullness();
if (disabledParams != null) {
for (int param : disabledParams) {
processor.doNotPassParameter(param);
}
}
if (newNameOfFirstParam != null) {
processor.changeParamName(0, newNameOfFirstParam);
}
ExtractMethodHandler.run(project, editor, processor);
}
if (replaceAllDuplicates) {
final Boolean hasDuplicates = processor.hasDuplicates();
if (hasDuplicates == null || hasDuplicates.booleanValue()) {
final List<Match> duplicates = processor.getDuplicates();
for (final Match match : duplicates) {
if (!match.getMatchStart().isValid() || !match.getMatchEnd().isValid()) continue;
PsiDocumentManager.getInstance(project).commitAllDocuments();
processor.processMatch(match);
}
}
}
return true;
}
示例2: performExtractMethod
import com.intellij.refactoring.extractMethod.ExtractMethodProcessor; //导入方法依赖的package包/类
public static boolean performExtractMethod(boolean doRefactor,
boolean replaceAllDuplicates,
Editor editor,
PsiFile file,
Project project,
final boolean extractChainedConstructor,
int... disabledParams)
throws PrepareFailedException, IncorrectOperationException {
int startOffset = editor.getSelectionModel().getSelectionStart();
int endOffset = editor.getSelectionModel().getSelectionEnd();
PsiElement[] elements;
PsiExpression expr = CodeInsightUtil.findExpressionInRange(file, startOffset, endOffset);
if (expr != null) {
elements = new PsiElement[]{expr};
}
else {
elements = CodeInsightUtil.findStatementsInRange(file, startOffset, endOffset);
}
if (elements.length == 0) {
final PsiExpression expression = IntroduceVariableBase.getSelectedExpression(project, file, startOffset, endOffset);
if (expression != null) {
elements = new PsiElement[]{expression};
}
}
assertTrue(elements.length > 0);
final ExtractMethodProcessor processor =
new ExtractMethodProcessor(project, editor, elements, null, "Extract Method", "newMethod", null);
processor.setShowErrorDialogs(false);
processor.setChainedConstructor(extractChainedConstructor);
if (!processor.prepare()) {
return false;
}
if (doRefactor) {
processor.testPrepare();
if (disabledParams != null) {
for (int param : disabledParams) {
processor.doNotPassParameter(param);
}
}
ExtractMethodHandler.run(project, editor, processor);
}
if (replaceAllDuplicates) {
final List<Match> duplicates = processor.getDuplicates();
for (final Match match : duplicates) {
if (!match.getMatchStart().isValid() || !match.getMatchEnd().isValid()) continue;
PsiDocumentManager.getInstance(project).commitAllDocuments();
processor.processMatch(match);
}
}
return true;
}