本文整理汇总了Java中com.intellij.openapi.util.Pass.pass方法的典型用法代码示例。如果您正苦于以下问题:Java Pass.pass方法的具体用法?Java Pass.pass怎么用?Java Pass.pass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.util.Pass
的用法示例。
在下文中一共展示了Pass.pass方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: substituteElementToRename
import com.intellij.openapi.util.Pass; //导入方法依赖的package包/类
@Override
public void substituteElementToRename(@NotNull PsiElement element,
@NotNull final Editor editor,
@NotNull final Pass<PsiElement> renameCallback) {
final PsiMethod psiMethod = (PsiMethod)element;
if (psiMethod.isConstructor()) {
final PsiClass containingClass = psiMethod.getContainingClass();
if (containingClass == null) return;
if (!Comparing.strEqual(psiMethod.getName(), containingClass.getName())) {
renameCallback.pass(psiMethod);
return;
}
super.substituteElementToRename(element, editor, renameCallback);
}
else {
SuperMethodWarningUtil.checkSuperMethod(psiMethod, "Rename", new PsiElementProcessor<PsiMethod>() {
@Override
public boolean execute(@NotNull PsiMethod method) {
if (!PsiElementRenameHandler.canRename(method.getProject(), editor, method)) return false;
renameCallback.pass(method);
return false;
}
}, editor);
}
}
示例2: doTestStopEditing
import com.intellij.openapi.util.Pass; //导入方法依赖的package包/类
private void doTestStopEditing(Pass<AbstractInplaceIntroducer> pass) {
String name = getTestName(true);
configureByFile(getBasePath() + name + getExtension());
final boolean enabled = getEditor().getSettings().isVariableInplaceRenameEnabled();
try {
TemplateManagerImpl.setTemplateTesting(getProject(), getTestRootDisposable());
getEditor().getSettings().setVariableInplaceRenameEnabled(true);
final AbstractInplaceIntroducer introducer = invokeRefactoring();
pass.pass(introducer);
checkResultByFile(getBasePath() + name + "_after" + getExtension());
}
finally {
TemplateState state = TemplateManagerImpl.getTemplateState(getEditor());
if (state != null) {
state.gotoEnd(true);
}
getEditor().getSettings().setVariableInplaceRenameEnabled(enabled);
}
}
示例3: invoke
import com.intellij.openapi.util.Pass; //导入方法依赖的package包/类
@Override
public void invoke(@NotNull final Project project, final Editor editor, final PsiFile file, @Nullable DataContext dataContext) {
editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
final SelectionModel model = editor.getSelectionModel();
if (model.hasSelection()) {
invokeImpl(project, editor, file, model.getSelectionStart(), model.getSelectionEnd());
}
else {
final List<GrExpression> expressions = GrIntroduceHandlerBase.collectExpressions(file, editor, editor.getCaretModel().getOffset(), true);
final Pass<GrExpression> callback = new Callback(project, editor, file);
if (expressions.size() == 1) {
callback.pass(expressions.get(0));
}
else if (expressions.isEmpty()) {
model.selectLineAtCaret();
invokeImpl(project, editor, file, model.getSelectionStart(), model.getSelectionEnd());
}
else {
IntroduceTargetChooser.showChooser(editor, expressions, callback, GrIntroduceHandlerBase.GR_EXPRESSION_RENDERER);
}
}
}
示例4: applyChosenClassAndExtract
import com.intellij.openapi.util.Pass; //导入方法依赖的package包/类
private boolean applyChosenClassAndExtract(List<PsiVariable> inputVariables, @Nullable Pass<ExtractMethodProcessor> extractPass)
throws PrepareFailedException {
myStatic = shouldBeStatic();
if (!PsiUtil.isLocalOrAnonymousClass(myTargetClass) && (myTargetClass.getContainingClass() == null || myTargetClass.hasModifierProperty(PsiModifier.STATIC))) {
ElementNeedsThis needsThis = new ElementNeedsThis(myTargetClass);
for (int i = 0; i < myElements.length && !needsThis.usesMembers(); i++) {
PsiElement element = myElements[i];
element.accept(needsThis);
}
myCanBeStatic = !needsThis.usesMembers();
}
else {
myCanBeStatic = false;
}
myInputVariables = new InputVariables(inputVariables, myProject, new LocalSearchScope(myElements), true);
if (!checkExitPoints()){
return false;
}
if (extractPass != null) {
extractPass.pass(this);
}
return true;
}
示例5: invoke
import com.intellij.openapi.util.Pass; //导入方法依赖的package包/类
public void invoke(@NotNull final Project project, final Editor editor, final PsiFile file, @Nullable DataContext dataContext) {
editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
final SelectionModel model = editor.getSelectionModel();
if (model.hasSelection()) {
invokeImpl(project, editor, file, model.getSelectionStart(), model.getSelectionEnd());
}
else {
final List<GrExpression> expressions = GrIntroduceHandlerBase.collectExpressions(file, editor, editor.getCaretModel().getOffset(), true);
final Pass<GrExpression> callback = new Callback(project, editor, file);
if (expressions.size() == 1) {
callback.pass(expressions.get(0));
}
else if (expressions.isEmpty()) {
model.selectLineAtCaret();
invokeImpl(project, editor, file, model.getSelectionStart(), model.getSelectionEnd());
}
else {
IntroduceTargetChooser.showChooser(editor, expressions, callback, GrIntroduceHandlerBase.GR_EXPRESSION_RENDERER);
}
}
}
示例6: selectAndPass
import com.intellij.openapi.util.Pass; //导入方法依赖的package包/类
public static void selectAndPass(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile file, @NotNull final Pass<PsiElement[]> callback) {
editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
if (!editor.getSelectionModel().hasSelection()) {
final int offset = editor.getCaretModel().getOffset();
final List<PsiExpression> expressions = IntroduceVariableBase.collectExpressions(file, editor, offset, true);
if (expressions.isEmpty()) {
editor.getSelectionModel().selectLineAtCaret();
}
else if (expressions.size() == 1) {
callback.pass(new PsiElement[]{expressions.get(0)});
return;
}
else {
IntroduceTargetChooser.showChooser(editor, expressions, new Pass<PsiExpression>() {
@Override
public void pass(PsiExpression psiExpression) {
callback.pass(new PsiElement[]{psiExpression});
}
}, new PsiExpressionTrimRenderer.RenderFunction());
return;
}
}
PsiDocumentManager.getInstance(project).commitAllDocuments();
callback.pass(getElements(project, editor, file));
}
示例7: substituteElementToRename
import com.intellij.openapi.util.Pass; //导入方法依赖的package包/类
/**
* Substitutes element to be renamed and initiate rename procedure. Should be used in order to prevent modal dialogs to appear during inplace rename
* @param element the element on which refactoring was invoked
* @param editor the editor in which inplace refactoring was invoked
* @param renameCallback rename procedure which should be called on the chosen substitution
*/
public void substituteElementToRename(@NotNull final PsiElement element, @NotNull Editor editor, @NotNull Pass<PsiElement> renameCallback) {
final PsiElement psiElement = substituteElementToRename(element, editor);
if (psiElement == null) return;
if (!PsiElementRenameHandler.canRename(psiElement.getProject(), editor, psiElement)) return;
renameCallback.pass(psiElement);
}
示例8: showChooser
import com.intellij.openapi.util.Pass; //导入方法依赖的package包/类
public void showChooser(final T selectedOccurrence, final List<T> allOccurrences, final Pass<ReplaceChoice> callback) {
if (allOccurrences.size() == 1) {
callback.pass(ReplaceChoice.ALL);
}
else {
Map<ReplaceChoice, List<T>> occurrencesMap = ContainerUtil.newLinkedHashMap();
occurrencesMap.put(ReplaceChoice.NO, Collections.singletonList(selectedOccurrence));
occurrencesMap.put(ReplaceChoice.ALL, allOccurrences);
showChooser(callback, occurrencesMap);
}
}
示例9: showScopeChooser
import com.intellij.openapi.util.Pass; //导入方法依赖的package包/类
@Override
protected void showScopeChooser(PsiClass[] scopes, final Pass<PsiClass> callback, Editor editor) {
PsiElementProcessor<PsiClass> processor = new PsiElementProcessor<PsiClass>() {
@Override
public boolean execute(@NotNull PsiClass element) {
callback.pass(element);
return false;
}
};
NavigationUtil.getPsiElementPopup(scopes, new PsiClassListCellRenderer(), "Choose class to introduce field", processor).showInBestPositionFor(editor);
}
示例10: substituteElementToRename
import com.intellij.openapi.util.Pass; //导入方法依赖的package包/类
/**
* Substitutes element to be renamed and initiate rename procedure. Should be used in order to prevent modal dialogs to appear during inplace rename
* @param element the element on which refactoring was invoked
* @param editor the editor in which inplace refactoring was invoked
* @param renameCallback rename procedure which should be called on the chosen substitution
*/
public void substituteElementToRename(@Nonnull final PsiElement element, @Nonnull Editor editor, @Nonnull Pass<PsiElement> renameCallback) {
final PsiElement psiElement = substituteElementToRename(element, editor);
if (psiElement == null) return;
if (!PsiElementRenameHandler.canRename(psiElement.getProject(), editor, psiElement)) return;
renameCallback.pass(psiElement);
}
示例11: selectAndPass
import com.intellij.openapi.util.Pass; //导入方法依赖的package包/类
public static void selectAndPass(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile file, @NotNull final Pass<PsiElement[]> callback) {
editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
if (!editor.getSelectionModel().hasSelection()) {
final int offset = editor.getCaretModel().getOffset();
final List<PsiExpression> expressions = IntroduceVariableBase.collectExpressions(file, editor, offset, true);
if (expressions.isEmpty()) {
editor.getSelectionModel().selectLineAtCaret();
}
else if (expressions.size() == 1) {
callback.pass(new PsiElement[]{expressions.get(0)});
return;
}
else {
IntroduceTargetChooser.showChooser(editor, expressions, new Pass<PsiExpression>() {
@Override
public void pass(PsiExpression psiExpression) {
callback.pass(new PsiElement[]{psiExpression});
}
}, new PsiExpressionTrimRenderer.RenderFunction());
return;
}
}
int startOffset = editor.getSelectionModel().getSelectionStart();
int endOffset = editor.getSelectionModel().getSelectionEnd();
PsiDocumentManager.getInstance(project).commitAllDocuments();
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 && IntroduceVariableBase.getErrorMessage(expression) == null) {
final PsiType originalType = RefactoringUtil.getTypeByExpressionWithExpectedType(expression);
if (originalType != null) {
elements = new PsiElement[]{expression};
}
}
}
}
callback.pass(elements);
}
示例12: applyChosenClassAndExtract
import com.intellij.openapi.util.Pass; //导入方法依赖的package包/类
private boolean applyChosenClassAndExtract(List<PsiVariable> inputVariables, @Nullable Pass<ExtractMethodProcessor> extractPass) throws PrepareFailedException
{
myStatic = shouldBeStatic();
final Set<PsiField> fields = new LinkedHashSet<PsiField>();
if(!PsiUtil.isLocalOrAnonymousClass(myTargetClass) && (myTargetClass.getContainingClass() == null || myTargetClass.hasModifierProperty(PsiModifier.STATIC)))
{
boolean canBeStatic = true;
if(myTargetClass.isInterface())
{
final PsiMethod containingMethod = PsiTreeUtil.getParentOfType(myCodeFragmentMember, PsiMethod.class, false);
canBeStatic = containingMethod == null || containingMethod.hasModifierProperty(PsiModifier.STATIC);
}
if(canBeStatic)
{
ElementNeedsThis needsThis = new ElementNeedsThis(myTargetClass)
{
@Override
protected void visitClassMemberReferenceElement(PsiMember classMember, PsiJavaCodeReferenceElement classMemberReference)
{
if(classMember instanceof PsiField && !classMember.hasModifierProperty(PsiModifier.STATIC))
{
final PsiExpression expression = PsiTreeUtil.getParentOfType(classMemberReference, PsiExpression.class, false);
if(expression == null || !PsiUtil.isAccessedForWriting(expression))
{
fields.add((PsiField) classMember);
return;
}
}
super.visitClassMemberReferenceElement(classMember, classMemberReference);
}
};
for(int i = 0; i < myElements.length && !needsThis.usesMembers(); i++)
{
PsiElement element = myElements[i];
element.accept(needsThis);
}
myCanBeStatic = !needsThis.usesMembers();
}
else
{
myCanBeStatic = false;
}
}
else
{
myCanBeStatic = false;
}
myInputVariables = new InputVariables(inputVariables, myProject, new LocalSearchScope(myElements), isFoldingApplicable());
myInputVariables.setUsedInstanceFields(fields);
if(!checkExitPoints())
{
return false;
}
checkCanBeChainedConstructor();
if(extractPass != null)
{
extractPass.pass(this);
}
return true;
}
示例13: selectAndPass
import com.intellij.openapi.util.Pass; //导入方法依赖的package包/类
public static void selectAndPass(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile file, @NotNull final Pass<PsiElement[]> callback)
{
editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
if(!editor.getSelectionModel().hasSelection())
{
final int offset = editor.getCaretModel().getOffset();
final List<PsiExpression> expressions = IntroduceVariableBase.collectExpressions(file, editor, offset, true);
if(expressions.isEmpty())
{
editor.getSelectionModel().selectLineAtCaret();
}
else if(expressions.size() == 1)
{
callback.pass(new PsiElement[]{expressions.get(0)});
return;
}
else
{
IntroduceTargetChooser.showChooser(editor, expressions, new Pass<PsiExpression>()
{
@Override
public void pass(PsiExpression psiExpression)
{
callback.pass(new PsiElement[]{psiExpression});
}
}, new PsiExpressionTrimRenderer.RenderFunction());
return;
}
}
int startOffset = editor.getSelectionModel().getSelectionStart();
int endOffset = editor.getSelectionModel().getSelectionEnd();
PsiDocumentManager.getInstance(project).commitAllDocuments();
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 && IntroduceVariableBase.getErrorMessage(expression) == null)
{
final PsiType originalType = RefactoringUtil.getTypeByExpressionWithExpectedType(expression);
if(originalType != null)
{
elements = new PsiElement[]{expression};
}
}
}
}
callback.pass(elements);
}