use of com.intellij.codeInsight.generation.GenerateEqualsHelper in project intellij-community by JetBrains.
the class GenerateEqualsTestCase method performTest.
private static void performTest(Function<PsiField[], PsiField[]> equals, Function<PsiField[], PsiField[]> hashCode, Function<PsiField[], PsiField[]> nonNull, boolean insertOverride, boolean useAccessors) {
CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject()).clone();
settings.GENERATE_FINAL_LOCALS = true;
settings.INSERT_OVERRIDE_ANNOTATION = insertOverride;
CodeStyleSettingsManager.getInstance(getProject()).setTemporarySettings(settings);
try {
PsiElement element = getFile().findElementAt(getEditor().getCaretModel().getOffset());
if (element == null)
return;
PsiClass aClass = PsiTreeUtil.getParentOfType(element, PsiClass.class);
if (aClass == null)
return;
PsiField[] fields = aClass.getFields();
new GenerateEqualsHelper(getProject(), aClass, equals.fun(fields), hashCode.fun(fields), nonNull.fun(fields), false, useAccessors).invoke();
FileDocumentManager.getInstance().saveAllDocuments();
} finally {
CodeStyleSettingsManager.getInstance(getProject()).dropTemporarySettings();
}
}
Aggregations