本文整理汇总了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();
}
示例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);
}
示例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();
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}