当前位置: 首页>>代码示例>>Java>>正文


Java GenerateEqualsHelper类代码示例

本文整理汇总了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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:GenerateEqualsWizard.java

示例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();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:GenerateEqualsTestCase.java

示例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();
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:21,代码来源:GenerateEqualsTestCase.java

示例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;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:27,代码来源:GenerateEqualsWizard.java

示例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;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:23,代码来源:GenerateEqualsWizard.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:GenerateEqualsWizard.java

示例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;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:14,代码来源:GenerateEqualsWizard.java

示例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;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:9,代码来源:GenerateEqualsWizard.java

示例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();
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:52,代码来源:EqualsHashCodeTemplatesPanel.java

示例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);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:7,代码来源:GenerateEqualsWizard.java

示例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();
		}
	};
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:59,代码来源:EqualsHashCodeTemplatesPanel.java


注:本文中的com.intellij.codeInsight.generation.GenerateEqualsHelper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。