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


Java Pass.pass方法代码示例

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

示例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);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:InplaceIntroduceVariableTest.java

示例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);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:GroovyExtractMethodHandler.java

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

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

示例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));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:ExtractMethodHandler.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:RenamePsiElementProcessor.java

示例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);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:OccurrencesChooser.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:GrIntroduceFieldHandlerBase.java

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

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

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

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


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