PsiMethodCallExpression (PsiExpression instanceQualifier, final boolean generateArgs, PsiElement context) { @NonNls StringBuilder buffer = new StringBuilder(); final boolean skipInstanceQualifier; if (myIsChainedConstructor) { skipInstanceQualifier = true; buffer.append(PsiKeyword.THIS); } else { skipInstanceQualifier = instanceQualifier == null || instanceQualifier instanceof PsiThisExpression; if (skipInstanceQualifier) { if (isNeedToChangeCallContext()) { boolean needsThisQualifier = false; PsiElement parent = myCodeFragmentMember; while (!myTargetClass.equals(parent)) { if (parent instanceof PsiMethod) { String methodName = ((PsiMethod)parent).getName(); if (methodName.equals(myMethodName)) { needsThisQualifier = true; break; } } parent = parent.getParent(); } if (needsThisQualifier) { buffer.append(myTargetClass.getName()); buffer.append(".this."); } } } else { buffer.append("qqq."); } buffer.append(myMethodName); } buffer.append("("); if (generateArgs) { int count = 0; for (VariableData data : myVariableDatum) { if (data.passAsParameter) { if (count > 0) { buffer.append(","); } myInputVariables.appendCallArguments(data, buffer); count++; } } } buffer.append(")"); String text = buffer.toString(); PsiMethodCallExpression expr = (PsiMethodCallExpression)myElementFactory.createExpressionFromText(text, context); expr = (PsiMethodCallExpression)myStyleManager.reformat(expr); if (!skipInstanceQualifier) { PsiExpression qualifierExpression = expr.getMethodExpression().getQualifierExpression(); LOG.assertTrue(qualifierExpression != null); qualifierExpression.replace(instanceQualifier); } return (PsiMethodCallExpression)JavaCodeStyleManager.getInstance(myProject).shortenClassReferences(expr); }