本文整理汇总了Java中com.intellij.codeInsight.generation.ui.GenerateEqualsWizard.getHashCodeFields方法的典型用法代码示例。如果您正苦于以下问题:Java GenerateEqualsWizard.getHashCodeFields方法的具体用法?Java GenerateEqualsWizard.getHashCodeFields怎么用?Java GenerateEqualsWizard.getHashCodeFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.codeInsight.generation.ui.GenerateEqualsWizard
的用法示例。
在下文中一共展示了GenerateEqualsWizard.getHashCodeFields方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: chooseOriginalMembers
import com.intellij.codeInsight.generation.ui.GenerateEqualsWizard; //导入方法依赖的package包/类
@Override
protected ClassMember[] chooseOriginalMembers(PsiClass aClass, Project project, Editor editor) {
myEqualsFields = null;
myHashCodeFields = null;
myNonNullFields = PsiField.EMPTY_ARRAY;
GlobalSearchScope scope = aClass.getResolveScope();
final PsiMethod equalsMethod = GenerateEqualsHelper.findMethod(aClass, GenerateEqualsHelper.getEqualsSignature(project, scope));
final PsiMethod hashCodeMethod = GenerateEqualsHelper.findMethod(aClass, GenerateEqualsHelper.getHashCodeSignature());
boolean needEquals = equalsMethod == null;
boolean needHashCode = hashCodeMethod == null;
if (!needEquals && !needHashCode) {
String text = aClass instanceof PsiAnonymousClass
? CodeInsightBundle.message("generate.equals.and.hashcode.already.defined.warning.anonymous")
: CodeInsightBundle.message("generate.equals.and.hashcode.already.defined.warning", aClass.getQualifiedName());
if (Messages.showYesNoDialog(project, text,
CodeInsightBundle.message("generate.equals.and.hashcode.already.defined.title"),
Messages.getQuestionIcon()) == Messages.YES) {
if (!ApplicationManager.getApplication().runWriteAction(new Computable<Boolean>() {
@Override
public Boolean compute() {
try {
equalsMethod.delete();
hashCodeMethod.delete();
return Boolean.TRUE;
}
catch (IncorrectOperationException e) {
LOG.error(e);
return Boolean.FALSE;
}
}
}).booleanValue()) {
return null;
}
else {
needEquals = needHashCode = true;
}
}
else {
return null;
}
}
boolean hasNonStaticFields = hasNonStaticFields(aClass);
if (!hasNonStaticFields) {
HintManager.getInstance().showErrorHint(editor, "No fields to include in equals/hashCode have been found");
return null;
}
GenerateEqualsWizard wizard = new GenerateEqualsWizard(project, aClass, needEquals, needHashCode);
if (!wizard.showAndGet()) {
return null;
}
myEqualsFields = wizard.getEqualsFields();
myHashCodeFields = wizard.getHashCodeFields();
myNonNullFields = wizard.getNonNullFields();
return DUMMY_RESULT;
}
示例2: chooseOriginalMembers
import com.intellij.codeInsight.generation.ui.GenerateEqualsWizard; //导入方法依赖的package包/类
@Override
@Nullable
protected ClassMember[] chooseOriginalMembers(PsiClass aClass, Project project) {
myEqualsFields = null;
myHashCodeFields = null;
myNonNullFields = PsiField.EMPTY_ARRAY;
GlobalSearchScope scope = aClass.getResolveScope();
final PsiMethod equalsMethod = GroovyGenerateEqualsHelper
.findMethod(aClass, GroovyGenerateEqualsHelper.getEqualsSignature(project, scope));
final PsiMethod hashCodeMethod = GroovyGenerateEqualsHelper.findMethod(aClass, GroovyGenerateEqualsHelper.getHashCodeSignature());
boolean needEquals = equalsMethod == null;
boolean needHashCode = hashCodeMethod == null;
if (!needEquals && !needHashCode) {
String text = aClass instanceof PsiAnonymousClass
? GroovyCodeInsightBundle.message("generate.equals.and.hashcode.already.defined.warning.anonymous")
: GroovyCodeInsightBundle.message("generate.equals.and.hashcode.already.defined.warning", aClass.getQualifiedName());
if (Messages.showYesNoDialog(project, text,
GroovyCodeInsightBundle.message("generate.equals.and.hashcode.already.defined.title"),
Messages.getQuestionIcon()) == Messages.YES) {
if (!ApplicationManager.getApplication().runWriteAction(new Computable<Boolean>() {
@Override
public Boolean compute() {
try {
equalsMethod.delete();
hashCodeMethod.delete();
return Boolean.TRUE;
}
catch (IncorrectOperationException e) {
LOG.error(e);
return Boolean.FALSE;
}
}
}).booleanValue()) {
return null;
}
else {
needEquals = needHashCode = true;
}
}
else {
return null;
}
}
GenerateEqualsWizard wizard = new GenerateEqualsWizard(project, aClass, needEquals, needHashCode);
if (!wizard.showAndGet()) {
return null;
}
myEqualsFields = wizard.getEqualsFields();
myHashCodeFields = wizard.getHashCodeFields();
myNonNullFields = wizard.getNonNullFields();
return DUMMY_RESULT;
}
示例3: chooseOriginalMembers
import com.intellij.codeInsight.generation.ui.GenerateEqualsWizard; //导入方法依赖的package包/类
@Override
protected ClassMember[] chooseOriginalMembers(PsiClass aClass, Project project, Editor editor) {
myEqualsFields = null;
myHashCodeFields = null;
myNonNullFields = PsiField.EMPTY_ARRAY;
GlobalSearchScope scope = aClass.getResolveScope();
final PsiMethod equalsMethod = GenerateEqualsHelper.findMethod(aClass, GenerateEqualsHelper.getEqualsSignature(project, scope));
final PsiMethod hashCodeMethod = GenerateEqualsHelper.findMethod(aClass, GenerateEqualsHelper.getHashCodeSignature());
boolean needEquals = equalsMethod == null;
boolean needHashCode = hashCodeMethod == null;
if (!needEquals && !needHashCode) {
String text = aClass instanceof PsiAnonymousClass
? CodeInsightBundle.message("generate.equals.and.hashcode.already.defined.warning.anonymous")
: CodeInsightBundle.message("generate.equals.and.hashcode.already.defined.warning", aClass.getQualifiedName());
if (Messages.showYesNoDialog(project, text,
CodeInsightBundle.message("generate.equals.and.hashcode.already.defined.title"),
Messages.getQuestionIcon()) == DialogWrapper.OK_EXIT_CODE) {
if (!ApplicationManager.getApplication().runWriteAction(new Computable<Boolean>() {
@Override
public Boolean compute() {
try {
equalsMethod.delete();
hashCodeMethod.delete();
return Boolean.TRUE;
}
catch (IncorrectOperationException e) {
LOG.error(e);
return Boolean.FALSE;
}
}
}).booleanValue()) {
return null;
} else {
needEquals = needHashCode = true;
}
} else {
return null;
}
}
boolean hasNonStaticFields = false;
for (PsiField field : aClass.getFields()) {
if (!field.hasModifierProperty(PsiModifier.STATIC)){
hasNonStaticFields = true;
break;
}
}
if (!hasNonStaticFields) {
HintManager.getInstance().showErrorHint(editor, "No fields to include in equals/hashCode have been found");
return null;
}
GenerateEqualsWizard wizard = new GenerateEqualsWizard(project, aClass, needEquals, needHashCode);
wizard.show();
if (!wizard.isOK()) return null;
myEqualsFields = wizard.getEqualsFields();
myHashCodeFields = wizard.getHashCodeFields();
myNonNullFields = wizard.getNonNullFields();
return DUMMY_RESULT;
}
示例4: chooseOriginalMembers
import com.intellij.codeInsight.generation.ui.GenerateEqualsWizard; //导入方法依赖的package包/类
@Nullable
protected ClassMember[] chooseOriginalMembers(PsiClass aClass, Project project) {
myEqualsFields = null;
myHashCodeFields = null;
myNonNullFields = PsiField.EMPTY_ARRAY;
GlobalSearchScope scope = aClass.getResolveScope();
final PsiMethod equalsMethod = GroovyGenerateEqualsHelper
.findMethod(aClass, GroovyGenerateEqualsHelper.getEqualsSignature(project, scope));
final PsiMethod hashCodeMethod = GroovyGenerateEqualsHelper.findMethod(aClass, GroovyGenerateEqualsHelper.getHashCodeSignature());
boolean needEquals = equalsMethod == null;
boolean needHashCode = hashCodeMethod == null;
if (!needEquals && !needHashCode) {
String text = aClass instanceof PsiAnonymousClass
? GroovyCodeInsightBundle.message("generate.equals.and.hashcode.already.defined.warning.anonymous")
: GroovyCodeInsightBundle.message("generate.equals.and.hashcode.already.defined.warning", aClass.getQualifiedName());
if (Messages.showYesNoDialog(project, text,
GroovyCodeInsightBundle.message("generate.equals.and.hashcode.already.defined.title"),
Messages.getQuestionIcon()) == DialogWrapper.OK_EXIT_CODE) {
if (!ApplicationManager.getApplication().runWriteAction(new Computable<Boolean>() {
public Boolean compute() {
try {
equalsMethod.delete();
hashCodeMethod.delete();
return Boolean.TRUE;
}
catch (IncorrectOperationException e) {
LOG.error(e);
return Boolean.FALSE;
}
}
}).booleanValue()) {
return null;
} else {
needEquals = needHashCode = true;
}
} else {
return null;
}
}
GenerateEqualsWizard wizard = new GenerateEqualsWizard(project, aClass, needEquals, needHashCode);
wizard.show();
if (!wizard.isOK()) return null;
myEqualsFields = wizard.getEqualsFields();
myHashCodeFields = wizard.getHashCodeFields();
myNonNullFields = wizard.getNonNullFields();
return DUMMY_RESULT;
}
示例5: chooseOriginalMembers
import com.intellij.codeInsight.generation.ui.GenerateEqualsWizard; //导入方法依赖的package包/类
@Override
protected ClassMember[] chooseOriginalMembers(PsiClass aClass, Project project, Editor editor)
{
myEqualsFields = null;
myHashCodeFields = null;
myNonNullFields = PsiField.EMPTY_ARRAY;
GlobalSearchScope scope = aClass.getResolveScope();
final PsiMethod equalsMethod = GenerateEqualsHelper.findMethod(aClass, GenerateEqualsHelper.getEqualsSignature(project, scope));
final PsiMethod hashCodeMethod = GenerateEqualsHelper.findMethod(aClass, GenerateEqualsHelper.getHashCodeSignature());
boolean needEquals = equalsMethod == null;
boolean needHashCode = hashCodeMethod == null;
if(!needEquals && !needHashCode)
{
String text = aClass instanceof PsiAnonymousClass ? CodeInsightBundle.message("generate.equals.and.hashcode.already.defined.warning.anonymous") : CodeInsightBundle.message("generate" +
".equals.and.hashcode.already.defined.warning", aClass.getQualifiedName());
if(Messages.showYesNoDialog(project, text, CodeInsightBundle.message("generate.equals.and.hashcode.already.defined.title"), Messages.getQuestionIcon()) == Messages.YES)
{
if(!ApplicationManager.getApplication().runWriteAction(new Computable<Boolean>()
{
@Override
public Boolean compute()
{
try
{
equalsMethod.delete();
hashCodeMethod.delete();
return Boolean.TRUE;
}
catch(IncorrectOperationException e)
{
LOG.error(e);
return Boolean.FALSE;
}
}
}).booleanValue())
{
return null;
}
else
{
needEquals = needHashCode = true;
}
}
else
{
return null;
}
}
boolean hasNonStaticFields = hasNonStaticFields(aClass);
if(!hasNonStaticFields)
{
HintManager.getInstance().showErrorHint(editor, "No fields to include in equals/hashCode have been found");
return null;
}
GenerateEqualsWizard wizard = new GenerateEqualsWizard(project, aClass, needEquals, needHashCode);
if(!wizard.showAndGet())
{
return null;
}
myEqualsFields = wizard.getEqualsFields();
myHashCodeFields = wizard.getHashCodeFields();
myNonNullFields = wizard.getNonNullFields();
return DUMMY_RESULT;
}