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


Java Util类代码示例

本文整理汇总了Java中com.intellij.refactoring.introduceParameter.Util的典型用法代码示例。如果您正苦于以下问题:Java Util类的具体用法?Java Util怎么用?Java Util使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: performForLocal

import com.intellij.refactoring.introduceParameter.Util; //导入依赖的package包/类
private static void performForLocal(boolean searchForSuper, boolean removeLocalVariable, boolean replaceAllOccurrences, boolean declareFinal, final boolean removeUnusedParameters)
{
	final int offset = myEditor.getCaretModel().getOffset();
	final PsiElement element = myFile.findElementAt(offset).getParent();
	assertTrue(element instanceof PsiLocalVariable);
	PsiMethod method = Util.getContainingMethod(element);
	final PsiMethod methodToSearchFor;
	if(searchForSuper)
	{
		final PsiMethod deepestSuperMethod = method.findDeepestSuperMethod();
		methodToSearchFor = deepestSuperMethod != null ? deepestSuperMethod : method;
	}
	else
	{
		methodToSearchFor = method;
	}
	assertNotNull(method);
	assertNotNull(methodToSearchFor);
	final PsiLocalVariable localVariable = (PsiLocalVariable) element;
	final PsiExpression parameterInitializer = localVariable.getInitializer();
	TIntArrayList parametersToRemove = removeUnusedParameters ? Util.findParametersToRemove(method, parameterInitializer, null) : new TIntArrayList();

	new IntroduceParameterProcessor(getProject(), method, methodToSearchFor, parameterInitializer, null, localVariable, removeLocalVariable, localVariable.getName(), replaceAllOccurrences,
			IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, declareFinal, false, null, parametersToRemove).run();
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:26,代码来源:IntroduceParameterTest.java

示例2: syncNeeded

import com.intellij.refactoring.introduceParameter.Util; //导入依赖的package包/类
private boolean syncNeeded(final PsiReferenceExpression ref) {
  if (!myMethod.hasModifierProperty(PsiModifier.SYNCHRONIZED)) return false;
  final PsiMethod containingMethod = Util.getContainingMethod(ref);
  if (containingMethod == null) return true;
  if (!containingMethod.hasModifierProperty(PsiModifier.SYNCHRONIZED)) return true;
  final PsiClass sourceContainingClass = myMethod.getContainingClass();
  final PsiClass targetContainingClass = containingMethod.getContainingClass();
  return !sourceContainingClass.equals(targetContainingClass);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:InlineMethodProcessor.java

示例3: performForLocal

import com.intellij.refactoring.introduceParameter.Util; //导入依赖的package包/类
private static void performForLocal(boolean searchForSuper,
                                    boolean removeLocalVariable,
                                    boolean replaceAllOccurrences,
                                    boolean declareFinal,
                                    final boolean removeUnusedParameters) {
  final int offset = myEditor.getCaretModel().getOffset();
  final PsiElement element = ObjectUtils.assertNotNull(myFile.findElementAt(offset)).getParent();
  assertTrue(element instanceof PsiLocalVariable);
  PsiMethod method = Util.getContainingMethod(element);
  final PsiMethod methodToSearchFor;
  if (searchForSuper) {
    PsiMethod[] deepestSuperMethods = method.findDeepestSuperMethods();
    methodToSearchFor = deepestSuperMethods.length > 0 ? deepestSuperMethods[0] : method;
  }
  else {
    methodToSearchFor = method;
  }
  assertNotNull(method);
  assertNotNull(methodToSearchFor);
  final PsiLocalVariable localVariable = (PsiLocalVariable)element;
  final PsiExpression parameterInitializer = localVariable.getInitializer();
  assertNotNull(parameterInitializer);
  TIntArrayList parametersToRemove = removeUnusedParameters ? Util.findParametersToRemove(method, parameterInitializer, null)
                                                            : new TIntArrayList();

  new IntroduceParameterProcessor(
    getProject(), method, methodToSearchFor, parameterInitializer, null, localVariable, removeLocalVariable,
    localVariable.getName(), replaceAllOccurrences, IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE,
    declareFinal, false, null, parametersToRemove
  ).run();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:32,代码来源:IntroduceParameterTest.java

示例4: performForLocal

import com.intellij.refactoring.introduceParameter.Util; //导入依赖的package包/类
private static void performForLocal(boolean searchForSuper, boolean removeLocalVariable, boolean replaceAllOccurrences, boolean declareFinal,
                                    final boolean removeUnusedParameters) {
  final int offset = myEditor.getCaretModel().getOffset();
  final PsiElement element = myFile.findElementAt(offset).getParent();
  assertTrue(element instanceof PsiLocalVariable);
  PsiMethod method = Util.getContainingMethod(element);
  final PsiMethod methodToSearchFor;
  if (searchForSuper) {
    final PsiMethod deepestSuperMethod = method.findDeepestSuperMethod();
    methodToSearchFor = deepestSuperMethod != null ? deepestSuperMethod : method;
  }
  else {
    methodToSearchFor = method;
  }
  assertNotNull(method);
  assertNotNull(methodToSearchFor);
  final PsiLocalVariable localVariable = (PsiLocalVariable)element;
  final PsiExpression parameterInitializer = localVariable.getInitializer();
  TIntArrayList parametersToRemove = removeUnusedParameters ? Util.findParametersToRemove(method, parameterInitializer, null) : new TIntArrayList();

  new IntroduceParameterProcessor(
    getProject(), method, methodToSearchFor,
    parameterInitializer, null, localVariable, removeLocalVariable,
    localVariable.getName(), replaceAllOccurrences,
    IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE,
    declareFinal, false, null, parametersToRemove).run();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:28,代码来源:IntroduceParameterTest.java

示例5: perform

import com.intellij.refactoring.introduceParameter.Util; //导入依赖的package包/类
private static boolean perform(boolean replaceAllOccurrences,
                               int replaceFieldsWithGetters,
                               @NonNls String parameterName,
                               boolean searchForSuper,
                               boolean declareFinal,
                               boolean removeUnusedParameters,
                               boolean generateDelegate,
                               int enclosingLevel,
                               final boolean replaceDuplicates) {
  final ElementToWorkOn[] elementToWorkOn = new ElementToWorkOn[1];
  ElementToWorkOn.processElementToWorkOn(myEditor, myFile, "INtr param", HelpID.INTRODUCE_PARAMETER, getProject(),
                                         new ElementToWorkOn.ElementsProcessor<ElementToWorkOn>() {
                                           @Override
                                           public boolean accept(ElementToWorkOn el) {
                                             return true;
                                           }

                                           @Override
                                           public void pass(final ElementToWorkOn e) {
                                             if (e != null) {
                                               elementToWorkOn[0] = e;
                                             }
                                           }
                                         });

  final PsiExpression expr = elementToWorkOn[0].getExpression();
  final PsiLocalVariable localVar = elementToWorkOn[0].getLocalVariable();

  PsiElement context = expr == null ? localVar : expr;
  PsiMethod method = Util.getContainingMethod(context);
  if (method == null) return false;

  final List<PsiMethod> methods = com.intellij.refactoring.introduceParameter.IntroduceParameterHandler.getEnclosingMethods(method);
  assertTrue(methods.size() > enclosingLevel);
  method = methods.get(enclosingLevel);

  final PsiMethod methodToSearchFor;
  if (searchForSuper) {
    methodToSearchFor = method.findDeepestSuperMethods()[0];
  }
  else {
    methodToSearchFor = method;
  }
  PsiExpression[] occurrences;
  PsiExpression initializer;
  if (expr == null) {
    initializer = localVar.getInitializer();
    assertNotNull(initializer);
    occurrences = CodeInsightUtil.findReferenceExpressions(method, localVar);
  }
  else {
    initializer = expr;
    occurrences = new ExpressionOccurrenceManager(expr, method, null).findExpressionOccurrences();
  }
  TIntArrayList parametersToRemove = removeUnusedParameters ? Util.findParametersToRemove(method, initializer, occurrences)
                                                            : new TIntArrayList();
  IntroduceParameterProcessor processor = new IntroduceParameterProcessor(
    getProject(), method, methodToSearchFor, initializer, expr, localVar, true, parameterName, replaceAllOccurrences,
    replaceFieldsWithGetters, declareFinal, generateDelegate, null, parametersToRemove
  ) {
    @Override
    protected boolean isReplaceDuplicates() {
      return replaceDuplicates;
    }
  };
  PsiType initializerType = initializer.getType();
  if (initializerType != null && initializerType != PsiType.NULL) {
    PsiExpression lambda = AnonymousCanBeLambdaInspection.replaceAnonymousWithLambda(initializer, initializerType);
    if (lambda != null) {
      processor.setParameterInitializer(lambda);
    }
  }
  processor.run();

  myEditor.getSelectionModel().removeSelection();
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:78,代码来源:IntroduceParameterTest.java

示例6: perform

import com.intellij.refactoring.introduceParameter.Util; //导入依赖的package包/类
private static boolean perform(boolean replaceAllOccurences,
                               int replaceFieldsWithGetters,
                               @NonNls String parameterName,
                               boolean searchForSuper,
                               boolean declareFinal,
                               final boolean removeUnusedParameters,
                               final boolean generateDelegate,
                               int enclosingLevel) {
  final ElementToWorkOn[] elementToWorkOn = new ElementToWorkOn[1];
  ElementToWorkOn
        .processElementToWorkOn(myEditor, myFile, "INtr param", HelpID.INTRODUCE_PARAMETER, getProject(), new ElementToWorkOn.ElementsProcessor<ElementToWorkOn>() {
          @Override
          public boolean accept(ElementToWorkOn el) {
            return true;
          }

          @Override
          public void pass(final ElementToWorkOn e) {
            if (e == null) return;

            elementToWorkOn[0] = e;
          }
        });

  final PsiExpression expr = elementToWorkOn[0].getExpression();
  final PsiLocalVariable localVar = elementToWorkOn[0].getLocalVariable();

  PsiElement context = expr == null ? localVar : expr;
  PsiMethod method = Util.getContainingMethod(context);
  if (method == null) return false;

  final List<PsiMethod> methods = com.intellij.refactoring.introduceParameter.IntroduceParameterHandler.getEnclosingMethods(method);
  assertTrue(methods.size() > enclosingLevel);
  method = methods.get(enclosingLevel);

  final PsiMethod methodToSearchFor;
  if (searchForSuper) {
    methodToSearchFor = method.findDeepestSuperMethod();
  }
  else {
    methodToSearchFor = method;
  }
  PsiExpression[] occurences;
  PsiExpression initializer;
  if (expr == null) {
    initializer = localVar.getInitializer();
    occurences = CodeInsightUtil.findReferenceExpressions(method, localVar);
  }
  else {
    initializer = expr;
    occurences = new ExpressionOccurrenceManager(expr, method, null).findExpressionOccurrences();
  }
  TIntArrayList parametersToRemove = removeUnusedParameters ? Util.findParametersToRemove(method, initializer, occurences) : new TIntArrayList();
  new IntroduceParameterProcessor(
    getProject(), method, methodToSearchFor, initializer, expr, localVar, true, parameterName, replaceAllOccurences,
    replaceFieldsWithGetters,
    declareFinal, generateDelegate, null, parametersToRemove).run();

  myEditor.getSelectionModel().removeSelection();
  return true;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:62,代码来源:IntroduceParameterTest.java

示例7: perform

import com.intellij.refactoring.introduceParameter.Util; //导入依赖的package包/类
private static boolean perform(boolean replaceAllOccurences,
		int replaceFieldsWithGetters,
		@NonNls String parameterName,
		boolean searchForSuper,
		boolean declareFinal,
		final boolean removeUnusedParameters,
		final boolean generateDelegate,
		int enclosingLevel)
{
	final ElementToWorkOn[] elementToWorkOn = new ElementToWorkOn[1];
	ElementToWorkOn.processElementToWorkOn(myEditor, myFile, "INtr param", HelpID.INTRODUCE_PARAMETER, getProject(), new ElementToWorkOn.ElementsProcessor<ElementToWorkOn>()
	{
		@Override
		public boolean accept(ElementToWorkOn el)
		{
			return true;
		}

		@Override
		public void pass(final ElementToWorkOn e)
		{
			if(e == null)
			{
				return;
			}

			elementToWorkOn[0] = e;
		}
	});

	final PsiExpression expr = elementToWorkOn[0].getExpression();
	final PsiLocalVariable localVar = elementToWorkOn[0].getLocalVariable();

	PsiElement context = expr == null ? localVar : expr;
	PsiMethod method = Util.getContainingMethod(context);
	if(method == null)
	{
		return false;
	}

	final List<PsiMethod> methods = com.intellij.refactoring.introduceParameter.IntroduceParameterHandler.getEnclosingMethods(method);
	assertTrue(methods.size() > enclosingLevel);
	method = methods.get(enclosingLevel);

	final PsiMethod methodToSearchFor;
	if(searchForSuper)
	{
		methodToSearchFor = method.findDeepestSuperMethod();
	}
	else
	{
		methodToSearchFor = method;
	}
	PsiExpression[] occurences;
	PsiExpression initializer;
	if(expr == null)
	{
		initializer = localVar.getInitializer();
		occurences = CodeInsightUtil.findReferenceExpressions(method, localVar);
	}
	else
	{
		initializer = expr;
		occurences = new ExpressionOccurrenceManager(expr, method, null).findExpressionOccurrences();
	}
	TIntArrayList parametersToRemove = removeUnusedParameters ? Util.findParametersToRemove(method, initializer, occurences) : new TIntArrayList();
	new IntroduceParameterProcessor(getProject(), method, methodToSearchFor, initializer, expr, localVar, true, parameterName, replaceAllOccurences, replaceFieldsWithGetters, declareFinal,
			generateDelegate, null, parametersToRemove).run();

	myEditor.getSelectionModel().removeSelection();
	return true;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:73,代码来源:IntroduceParameterTest.java


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