本文整理匯總了Java中com.intellij.codeInsight.generation.ui.GenerateEqualsWizard類的典型用法代碼示例。如果您正苦於以下問題:Java GenerateEqualsWizard類的具體用法?Java GenerateEqualsWizard怎麽用?Java GenerateEqualsWizard使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
GenerateEqualsWizard類屬於com.intellij.codeInsight.generation.ui包,在下文中一共展示了GenerateEqualsWizard類的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;
}