當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。