本文整理汇总了Java中com.intellij.codeInsight.generation.GenerateEqualsHelper类的典型用法代码示例。如果您正苦于以下问题:Java GenerateEqualsHelper类的具体用法?Java GenerateEqualsHelper怎么用?Java GenerateEqualsHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GenerateEqualsHelper类属于com.intellij.codeInsight.generation包,在下文中一共展示了GenerateEqualsHelper类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTooltip
import com.intellij.codeInsight.generation.GenerateEqualsHelper; //导入依赖的package包/类
@Override
public String getTooltip(MemberInfo memberInfo) {
if (checkForProblems(memberInfo) == OK) return null;
if (!(memberInfo.getMember() instanceof PsiField)) return CodeInsightBundle.message("generate.equals.hashcode.internal.error");
final PsiField field = (PsiField)memberInfo.getMember();
if (!JavaVersionService.getInstance().isAtLeast(field, JavaSdkVersion.JDK_1_5)) {
final PsiType type = field.getType();
if (PsiAdapter.isNestedArray(type)) {
return CodeInsightBundle .message("generate.equals.warning.equals.for.nested.arrays.not.supported");
}
if (GenerateEqualsHelper.isArrayOfObjects(type)) {
return CodeInsightBundle.message("generate.equals.warning.generated.equals.could.be.incorrect");
}
}
return null;
}
示例2: performTest
import com.intellij.codeInsight.generation.GenerateEqualsHelper; //导入依赖的package包/类
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();
}
}
示例3: performTest
import com.intellij.codeInsight.generation.GenerateEqualsHelper; //导入依赖的package包/类
private static void performTest(int[] equals, int[] hashCode, int[] nonNull, boolean insertOverride) {
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, getIndexed(fields, equals), getIndexed(fields, hashCode), getIndexed(fields, nonNull),
false)
.invoke();
FileDocumentManager.getInstance().saveAllDocuments();
}
finally {
CodeStyleSettingsManager.getInstance(getProject()).dropTemporarySettings();
}
}
示例4: getTooltip
import com.intellij.codeInsight.generation.GenerateEqualsHelper; //导入依赖的package包/类
@Override
public String getTooltip(MemberInfo memberInfo)
{
if(checkForProblems(memberInfo) == OK)
{
return null;
}
if(!(memberInfo.getMember() instanceof PsiField))
{
return CodeInsightBundle.message("generate.equals.hashcode.internal.error");
}
final PsiField field = (PsiField) memberInfo.getMember();
if(!JavaVersionService.getInstance().isAtLeast(field, JavaSdkVersion.JDK_1_5))
{
final PsiType type = field.getType();
if(PsiAdapter.isNestedArray(type))
{
return CodeInsightBundle.message("generate.equals.warning.equals.for.nested.arrays.not.supported");
}
if(GenerateEqualsHelper.isArrayOfObjects(type))
{
return CodeInsightBundle.message("generate.equals.warning.generated.equals.could.be.incorrect");
}
}
return null;
}
示例5: checkForProblems
import com.intellij.codeInsight.generation.GenerateEqualsHelper; //导入依赖的package包/类
@Override
public int checkForProblems(@NotNull MemberInfo member)
{
if(!(member.getMember() instanceof PsiField))
{
return ERROR;
}
final PsiField field = (PsiField) member.getMember();
final PsiType type = field.getType();
if(!JavaVersionService.getInstance().isAtLeast(field, JavaSdkVersion.JDK_1_5))
{
if(PsiAdapter.isNestedArray(type))
{
return ERROR;
}
if(GenerateEqualsHelper.isArrayOfObjects(type))
{
return WARNING;
}
}
return OK;
}
示例6: checkForProblems
import com.intellij.codeInsight.generation.GenerateEqualsHelper; //导入依赖的package包/类
@Override
public int checkForProblems(@NotNull MemberInfo member) {
if (!(member.getMember() instanceof PsiField)) return ERROR;
final PsiField field = (PsiField)member.getMember();
final PsiType type = field.getType();
if (!JavaVersionService.getInstance().isAtLeast(field, JavaSdkVersion.JDK_1_5)) {
if (PsiAdapter.isNestedArray(type)) return ERROR;
if (GenerateEqualsHelper.isArrayOfObjects(type)) return WARNING;
}
return OK;
}
示例7: getTooltip
import com.intellij.codeInsight.generation.GenerateEqualsHelper; //导入依赖的package包/类
@Override
public String getTooltip(MemberInfo memberInfo) {
if (checkForProblems(memberInfo) == OK) return null;
if (!(memberInfo.getMember() instanceof PsiField)) return CodeInsightBundle.message("generate.equals.hashcode.internal.error");
final PsiType type = ((PsiField)memberInfo.getMember()).getType();
if (GenerateEqualsHelper.isNestedArray(type)) {
return CodeInsightBundle .message("generate.equals.warning.equals.for.nested.arrays.not.supported");
}
if (GenerateEqualsHelper.isArrayOfObjects(type)) {
return CodeInsightBundle.message("generate.equals.warning.generated.equals.could.be.incorrect");
}
return null;
}
示例8: checkForProblems
import com.intellij.codeInsight.generation.GenerateEqualsHelper; //导入依赖的package包/类
@Override
public int checkForProblems(@NotNull MemberInfo member) {
if (!(member.getMember() instanceof PsiField)) return ERROR;
final PsiType type = ((PsiField)member.getMember()).getType();
if (GenerateEqualsHelper.isNestedArray(type)) return ERROR;
if (GenerateEqualsHelper.isArrayOfObjects(type)) return WARNING;
return OK;
}
示例9: createConfigurable
import com.intellij.codeInsight.generation.GenerateEqualsHelper; //导入依赖的package包/类
@Override
protected UnnamedConfigurable createConfigurable(Couple<TemplateResource> item) {
final GenerateTemplateConfigurable equalsConfigurable = new GenerateTemplateConfigurable(item.first, GenerateEqualsHelper.getEqualsImplicitVars(myProject), myProject);
final GenerateTemplateConfigurable hashCodeConfigurable = new GenerateTemplateConfigurable(item.second, GenerateEqualsHelper.getHashCodeImplicitVars(), myProject);
return new UnnamedConfigurable() {
@Nullable
@Override
public JComponent createComponent() {
final Splitter splitter = new Splitter(true);
final JPanel eqPanel = new JPanel(new BorderLayout());
eqPanel.add(new TitledSeparator("Equals Template:"), BorderLayout.NORTH);
final JComponent eqPane = equalsConfigurable.createComponent();
eqPane.setPreferredSize(JBUI.size(300, 200));
eqPanel.add(eqPane, BorderLayout.CENTER);
splitter.setFirstComponent(eqPanel);
final JPanel hcPanel = new JPanel(new BorderLayout());
hcPanel.add(new TitledSeparator("HashCode Template:"), BorderLayout.NORTH);
final JComponent hcPane = hashCodeConfigurable.createComponent();
hcPane.setPreferredSize(JBUI.size(300, 200));
hcPanel.add(hcPane, BorderLayout.CENTER);
splitter.setSecondComponent(hcPanel);
return splitter;
}
@Override
public boolean isModified() {
return equalsConfigurable.isModified() || hashCodeConfigurable.isModified();
}
@Override
public void apply() throws ConfigurationException {
equalsConfigurable.apply();
hashCodeConfigurable.apply();
}
@Override
public void reset() {
equalsConfigurable.reset();
hashCodeConfigurable.reset();
}
@Override
public void disposeUIResources() {
equalsConfigurable.disposeUIResources();
hashCodeConfigurable.disposeUIResources();
}
};
}
示例10: isMemberEnabled
import com.intellij.codeInsight.generation.GenerateEqualsHelper; //导入依赖的package包/类
@Override
public boolean isMemberEnabled(MemberInfo member) {
if (!(member.getMember() instanceof PsiField)) return false;
final PsiType type = ((PsiField)member.getMember()).getType();
return !GenerateEqualsHelper.isNestedArray(type);
}
示例11: createConfigurable
import com.intellij.codeInsight.generation.GenerateEqualsHelper; //导入依赖的package包/类
@Override
protected UnnamedConfigurable createConfigurable(Couple<TemplateResource> item)
{
final GenerateTemplateConfigurable equalsConfigurable = new GenerateTemplateConfigurable(item.first, GenerateEqualsHelper.getEqualsImplicitVars(myProject), myProject);
final GenerateTemplateConfigurable hashCodeConfigurable = new GenerateTemplateConfigurable(item.second, GenerateEqualsHelper.getHashCodeImplicitVars(), myProject);
return new UnnamedConfigurable()
{
@Nullable
@Override
public JComponent createComponent()
{
final Splitter splitter = new Splitter(true);
final JPanel eqPanel = new JPanel(new BorderLayout());
eqPanel.add(new TitledSeparator("Equals Template:"), BorderLayout.NORTH);
final JComponent eqPane = equalsConfigurable.createComponent();
eqPane.setPreferredSize(JBUI.size(300, 200));
eqPanel.add(eqPane, BorderLayout.CENTER);
splitter.setFirstComponent(eqPanel);
final JPanel hcPanel = new JPanel(new BorderLayout());
hcPanel.add(new TitledSeparator("HashCode Template:"), BorderLayout.NORTH);
final JComponent hcPane = hashCodeConfigurable.createComponent();
hcPane.setPreferredSize(JBUI.size(300, 200));
hcPanel.add(hcPane, BorderLayout.CENTER);
splitter.setSecondComponent(hcPanel);
return splitter;
}
@Override
public boolean isModified()
{
return equalsConfigurable.isModified() || hashCodeConfigurable.isModified();
}
@Override
public void apply() throws ConfigurationException
{
equalsConfigurable.apply();
hashCodeConfigurable.apply();
}
@Override
public void reset()
{
equalsConfigurable.reset();
hashCodeConfigurable.reset();
}
@Override
public void disposeUIResources()
{
equalsConfigurable.disposeUIResources();
hashCodeConfigurable.disposeUIResources();
}
};
}