Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 243183 Details for
Bug 71627
[code style] don't generate redundant modifiers "public static final abstract" for interface members
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
My patch to review
71627.patch (text/plain), 18.15 KB, created by
Jerome Cambon
on 2014-05-16 10:30:57 EDT
(
hide
)
Description:
My patch to review
Filename:
MIME Type:
Creator:
Jerome Cambon
Created:
2014-05-16 10:30:57 EDT
Size:
18.15 KB
patch
obsolete
>diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ExtractInterfaceProcessor.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ExtractInterfaceProcessor.java >index 6784bfd..c81f3e5 100644 >--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ExtractInterfaceProcessor.java >+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ExtractInterfaceProcessor.java >@@ -94,7 +94,6 @@ import org.eclipse.jdt.internal.core.refactoring.descriptors.RefactoringSignatur > import org.eclipse.jdt.internal.corext.codemanipulation.CodeGenerationSettings; > import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility; > import org.eclipse.jdt.internal.corext.dom.Bindings; >-import org.eclipse.jdt.internal.corext.dom.ModifierRewrite; > import org.eclipse.jdt.internal.corext.refactoring.Checks; > import org.eclipse.jdt.internal.corext.refactoring.JDTRefactoringDescriptorComment; > import org.eclipse.jdt.internal.corext.refactoring.JavaRefactoringArguments; >@@ -134,12 +133,8 @@ import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; > */ > public final class ExtractInterfaceProcessor extends SuperTypeRefactoringProcessor { > >- private static final String ATTRIBUTE_ABSTRACT= "abstract"; //$NON-NLS-1$ >- > private static final String ATTRIBUTE_COMMENTS= "comments"; //$NON-NLS-1$ > >- private static final String ATTRIBUTE_PUBLIC= "public"; //$NON-NLS-1$ >- > /** The identifier of this processor */ > public static final String IDENTIFIER= "org.eclipse.jdt.ui.extractInterfaceProcessor"; //$NON-NLS-1$ > >@@ -169,9 +164,6 @@ public final class ExtractInterfaceProcessor extends SuperTypeRefactoringProcess > } > } > >- /** Should extracted methods be declared as abstract? */ >- private boolean fAbstract= true; >- > /** Should override annotations be generated? */ > private boolean fAnnotations= false; > >@@ -184,9 +176,6 @@ public final class ExtractInterfaceProcessor extends SuperTypeRefactoringProcess > /** The members to extract */ > private IMember[] fMembers= null; > >- /** Should extracted methods be declared as public? */ >- private boolean fPublic= true; >- > /** The subtype where to extract the supertype */ > private IType fSubType; > >@@ -371,9 +360,7 @@ public final class ExtractInterfaceProcessor extends SuperTypeRefactoringProcess > arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME, fSuperName); > for (int index= 0; index < fMembers.length; index++) > arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_ELEMENT + (index + 1), JavaRefactoringDescriptorUtil.elementToHandle(project, fMembers[index])); >- arguments.put(ATTRIBUTE_ABSTRACT, Boolean.valueOf(fAbstract).toString()); > arguments.put(ATTRIBUTE_COMMENTS, Boolean.valueOf(fComments).toString()); >- arguments.put(ATTRIBUTE_PUBLIC, Boolean.valueOf(fPublic).toString()); > arguments.put(ATTRIBUTE_REPLACE, Boolean.valueOf(fReplace).toString()); > arguments.put(ATTRIBUTE_INSTANCEOF, Boolean.valueOf(fInstanceOf).toString()); > final DynamicValidationRefactoringChange change= new DynamicValidationRefactoringChange(descriptor, RefactoringCoreMessages.ExtractInterfaceRefactoring_name, fChangeManager.getAllChanges()); >@@ -671,20 +658,10 @@ public final class ExtractInterfaceProcessor extends SuperTypeRefactoringProcess > if (declaration.getBody() != null) > rewrite.remove(declaration.getBody(), null); > ListRewrite list= rewrite.getListRewrite(declaration, declaration.getModifiersProperty()); >- boolean publicFound= false; >- boolean abstractFound= false; > Annotation annotation= null; > for (IExtendedModifier extended : (List<IExtendedModifier>) declaration.modifiers()) { > if (!extended.isAnnotation()) { > Modifier modifier= (Modifier) extended; >- if (fPublic && modifier.getKeyword().equals(Modifier.ModifierKeyword.PUBLIC_KEYWORD)) { >- publicFound= true; >- continue; >- } >- if (fAbstract && modifier.getKeyword().equals(Modifier.ModifierKeyword.ABSTRACT_KEYWORD)) { >- abstractFound= true; >- continue; >- } > list.remove(modifier, null); > } else if (extended.isAnnotation()) { > annotation= (Annotation) extended; >@@ -693,11 +670,6 @@ public final class ExtractInterfaceProcessor extends SuperTypeRefactoringProcess > list.remove(annotation, null); > } > } >- ModifierRewrite rewriter= ModifierRewrite.create(rewrite, declaration); >- if (fPublic && !publicFound) >- rewriter.setVisibility(Modifier.PUBLIC, null); >- if (fAbstract && !abstractFound) >- rewriter.setModifiers(Modifier.ABSTRACT, 0, null); > > for (SingleVariableDeclaration param : (List<SingleVariableDeclaration>) declaration.parameters()) { > ListRewrite modifierRewrite= rewrite.getListRewrite(param, SingleVariableDeclaration.MODIFIERS2_PROPERTY); >@@ -773,16 +745,6 @@ public final class ExtractInterfaceProcessor extends SuperTypeRefactoringProcess > } > } > >- /** >- * Should extracted methods be declared as abstract? >- * >- * @return <code>true</code> if the should be declared as abstract, >- * <code>false</code> otherwise >- */ >- public final boolean getAbstract() { >- return fAbstract; >- } >- > /* > * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#getElements() > */ >@@ -869,16 +831,6 @@ public final class ExtractInterfaceProcessor extends SuperTypeRefactoringProcess > } > > /** >- * Should extracted methods be declared as public? >- * >- * @return <code>true</code> if the should be declared as public, >- * <code>false</code> otherwise >- */ >- public final boolean getPublic() { >- return fPublic; >- } >- >- /** > * Returns the type where to extract an interface. > * > * @return the type where to extract an interface >@@ -923,11 +875,6 @@ public final class ExtractInterfaceProcessor extends SuperTypeRefactoringProcess > return status; > } else > return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME)); >- final String deferred= extended.getAttribute(ATTRIBUTE_ABSTRACT); >- if (deferred != null) { >- fAbstract= Boolean.valueOf(deferred).booleanValue(); >- } else >- return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_ABSTRACT)); > final String comment= extended.getAttribute(ATTRIBUTE_COMMENTS); > if (comment != null) { > fComments= Boolean.valueOf(comment).booleanValue(); >@@ -938,11 +885,6 @@ public final class ExtractInterfaceProcessor extends SuperTypeRefactoringProcess > fInstanceOf= Boolean.valueOf(instance).booleanValue(); > } else > return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_INSTANCEOF)); >- final String visibility= extended.getAttribute(ATTRIBUTE_PUBLIC); >- if (visibility != null) { >- fPublic= Boolean.valueOf(visibility).booleanValue(); >- } else >- return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_PUBLIC)); > final String replace= extended.getAttribute(ATTRIBUTE_REPLACE); > if (replace != null) { > fReplace= Boolean.valueOf(replace).booleanValue(); >@@ -1190,17 +1132,6 @@ public final class ExtractInterfaceProcessor extends SuperTypeRefactoringProcess > } > > /** >- * Determines whether extracted methods should be declared as abstract. >- * >- * @param declare >- * <code>true</code> to declare them public, <code>false</code> >- * otherwise >- */ >- public final void setAbstract(final boolean declare) { >- fAbstract= declare; >- } >- >- /** > * Determines whether override annotations should be generated. > * > * @param annotations <code>true</code> to generate override annotations, <code>false</code> otherwise >@@ -1233,17 +1164,6 @@ public final class ExtractInterfaceProcessor extends SuperTypeRefactoringProcess > } > > /** >- * Determines whether extracted methods should be declared as public. >- * >- * @param declare >- * <code>true</code> to declare them public, <code>false</code> >- * otherwise >- */ >- public final void setPublic(final boolean declare) { >- fPublic= declare; >- } >- >- /** > * Sets the new interface name. > * > * @param name >diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/MoveStaticMembersProcessor.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/MoveStaticMembersProcessor.java >index 78deea2..944fd78 100644 >--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/MoveStaticMembersProcessor.java >+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/MoveStaticMembersProcessor.java >@@ -963,6 +963,12 @@ public final class MoveStaticMembersProcessor extends MoveProcessor implements I > } > } > } >+ if (fDestinationType.isInterface()) { >+ int modifiers= declaration.getModifiers(); >+ modifiers= JdtFlags.clearAccessModifiers(modifiers); >+ modifiers= JdtFlags.clearFlag(Modifier.ABSTRACT, modifiers); >+ ModifierRewrite.create(fSource.getASTRewrite(), declaration).setModifiers(modifiers, null); >+ } > ITrackedNodePosition trackedPosition= fSource.getASTRewrite().track(declaration); > declaration.setProperty(TRACKED_POSITION_PROPERTY, trackedPosition); > targetNeedsSourceImport|= analyzer.targetNeedsSourceImport(); >diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/PullUpRefactoringProcessor.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/PullUpRefactoringProcessor.java >index 27b051f..84d1345 100644 >--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/PullUpRefactoringProcessor.java >+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/PullUpRefactoringProcessor.java >@@ -1026,6 +1026,8 @@ public class PullUpRefactoringProcessor extends HierarchyProcessor { > copyExtraDimensions(oldMethod, newMethod); > newMethod.setJavadoc(null); > int modifiers= getModifiersWithUpdatedVisibility(sourceMethod, Modifier.ABSTRACT | JdtFlags.clearFlag(Modifier.NATIVE | Modifier.FINAL, sourceMethod.getFlags()), adjustments, monitor, false, status); >+ if (getDestinationType().isInterface()) >+ modifiers = JdtFlags.clearFlag(Modifier.ABSTRACT, modifiers); > if (oldMethod.isVarargs()) > modifiers&= ~Flags.AccVarargs; > newMethod.modifiers().addAll(ASTNodeFactory.newModifiers(targetRewrite.getAST(), modifiers)); >@@ -1626,7 +1628,7 @@ public class PullUpRefactoringProcessor extends HierarchyProcessor { > return JdtFlags.clearAccessModifiers(modifiers) | Modifier.PROTECTED; > } > if (getDestinationType().isInterface()) { >- final int flags= JdtFlags.clearAccessModifiers(modifiers) | Modifier.PUBLIC; >+ final int flags= JdtFlags.clearAccessModifiers(modifiers); > if (member instanceof IMethod) > return JdtFlags.clearFlag(Modifier.STATIC, flags); > return flags; >diff --git a/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/ExtractInterfaceWizard.java b/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/ExtractInterfaceWizard.java >index 6fc8a45..aa15ea1 100644 >--- a/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/ExtractInterfaceWizard.java >+++ b/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/ExtractInterfaceWizard.java >@@ -43,7 +43,6 @@ import org.eclipse.jdt.core.IMember; > import org.eclipse.jdt.core.JavaModelException; > > import org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceProcessor; >-import org.eclipse.jdt.internal.corext.util.Messages; > > import org.eclipse.jdt.ui.JavaElementComparator; > import org.eclipse.jdt.ui.JavaElementLabels; >@@ -76,15 +75,11 @@ public class ExtractInterfaceWizard extends RefactoringWizard { > private static class ExtractInterfaceInputPage extends TextInputWizardPage { > > private Button fReplaceAllCheckbox; >- private Button fDeclarePublicCheckbox; >- private Button fDeclareAbstractCheckbox; > private Button fGenerateAnnotationsCheckbox; > private Button fGenerateCommentsCheckbox; > private Button fInstanceofCheckbox; > private CheckboxTableViewer fTableViewer; > private static final String DESCRIPTION = RefactoringMessages.ExtractInterfaceInputPage_description; >- private static final String SETTING_PUBLIC= "Public";//$NON-NLS-1$ >- private static final String SETTING_ABSTRACT= "Abstract";//$NON-NLS-1$ > private static final String SETTING_ANNOTATIONS= "Annotations";//$NON-NLS-1$ > private static final String SETTING_REPLACE= "Replace"; //$NON-NLS-1$ > private static final String SETTING_COMMENTS= "Comments"; //$NON-NLS-1$ >@@ -123,8 +118,6 @@ public class ExtractInterfaceWizard extends RefactoringWizard { > fInstanceofCheckbox.setEnabled(fReplaceAllCheckbox.getSelection()); > } > }); >- addDeclareAsPublicCheckbox(result); >- addDeclareAsAbstractCheckbox(result); > addGenerateAnnotationsCheckbox(result); > > Label separator= new Label(result, SWT.NONE); >@@ -236,8 +229,6 @@ public class ExtractInterfaceWizard extends RefactoringWizard { > JavaPlugin.log(exception); > } > final boolean enabled= containsMethods(checked); >- fDeclarePublicCheckbox.setEnabled(enabled); >- fDeclareAbstractCheckbox.setEnabled(enabled); > fGenerateAnnotationsCheckbox.setEnabled(enabled); > fGenerateCommentsCheckbox.setEnabled(enabled); > fInstanceofCheckbox.setEnabled(fReplaceAllCheckbox.getSelection()); >@@ -320,35 +311,6 @@ public class ExtractInterfaceWizard extends RefactoringWizard { > }); > } > >- private void addDeclareAsPublicCheckbox(Composite result) { >- String[] keys= {RefactoringMessages.ExtractInterfaceWizard_public_label}; >- String title= Messages.format(RefactoringMessages.ExtractInterfaceWizard_12, keys); >- boolean defaultValue= fProcessor.getPublic(); >- fDeclarePublicCheckbox= createCheckbox(result, title, defaultValue); >- fProcessor.setPublic(fDeclarePublicCheckbox.getSelection()); >- fDeclarePublicCheckbox.addSelectionListener(new SelectionAdapter(){ >- @Override >- public void widgetSelected(SelectionEvent e) { >- fProcessor.setPublic(fDeclarePublicCheckbox.getSelection()); >- } >- }); >- } >- >- private void addDeclareAsAbstractCheckbox(Composite result) { >- final ExtractInterfaceProcessor processor= fProcessor; >- String[] keys= {RefactoringMessages.ExtractInterfaceWizard_abstract_label}; >- String title= Messages.format(RefactoringMessages.ExtractInterfaceWizard_12, keys); >- boolean defaultValue= processor.getAbstract(); >- fDeclareAbstractCheckbox= createCheckbox(result, title, defaultValue); >- processor.setAbstract(fDeclareAbstractCheckbox.getSelection()); >- fDeclareAbstractCheckbox.addSelectionListener(new SelectionAdapter(){ >- @Override >- public void widgetSelected(SelectionEvent e) { >- processor.setAbstract(fDeclareAbstractCheckbox.getSelection()); >- } >- }); >- } >- > private static Button createCheckbox(Composite parent, String title, boolean value){ > Button checkBox= new Button(parent, SWT.CHECK); > checkBox.setText(title); >@@ -404,8 +366,6 @@ public class ExtractInterfaceWizard extends RefactoringWizard { > fProcessor.setTypeName(getText()); > fProcessor.setReplace(fReplaceAllCheckbox.getSelection()); > fProcessor.setExtractedMembers(getCheckedMembers()); >- fProcessor.setAbstract(fDeclareAbstractCheckbox.getSelection()); >- fProcessor.setPublic(fDeclarePublicCheckbox.getSelection()); > fProcessor.setAnnotations(fGenerateAnnotationsCheckbox.getSelection()); > fProcessor.setComments(fGenerateCommentsCheckbox.getSelection()); > fProcessor.setInstanceOf(fInstanceofCheckbox.getSelection()); >@@ -426,8 +386,6 @@ public class ExtractInterfaceWizard extends RefactoringWizard { > } > > private void initializeCheckboxes() { >- initializeCheckBox(fDeclarePublicCheckbox, SETTING_PUBLIC, true); >- initializeCheckBox(fDeclareAbstractCheckbox, SETTING_ABSTRACT, true); > initializeCheckBox(fGenerateAnnotationsCheckbox, SETTING_ANNOTATIONS, true); > initializeCheckBox(fReplaceAllCheckbox, SETTING_REPLACE, true); > initializeCheckBox(fGenerateCommentsCheckbox, SETTING_COMMENTS, true); >@@ -444,8 +402,6 @@ public class ExtractInterfaceWizard extends RefactoringWizard { > > private void storeDialogSettings() { > final IDialogSettings settings= JavaPlugin.getDefault().getDialogSettings(); >- settings.put(SETTING_PUBLIC, fDeclarePublicCheckbox.getSelection()); >- settings.put(SETTING_ABSTRACT, fDeclareAbstractCheckbox.getSelection()); > settings.put(SETTING_ANNOTATIONS, fGenerateAnnotationsCheckbox.getSelection()); > settings.put(SETTING_REPLACE, fReplaceAllCheckbox.getSelection()); > settings.put(SETTING_COMMENTS, fGenerateCommentsCheckbox.getSelection()); >diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/proposals/AbstractMethodCorrectionProposal.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/proposals/AbstractMethodCorrectionProposal.java >index 7f9adc3..bd0bb5d 100644 >--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/proposals/AbstractMethodCorrectionProposal.java >+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/proposals/AbstractMethodCorrectionProposal.java >@@ -20,6 +20,7 @@ import org.eclipse.swt.graphics.Image; > import org.eclipse.core.runtime.Assert; > import org.eclipse.core.runtime.CoreException; > >+import org.eclipse.jdt.core.Flags; > import org.eclipse.jdt.core.ICompilationUnit; > import org.eclipse.jdt.core.dom.AST; > import org.eclipse.jdt.core.dom.ASTNode; >@@ -153,7 +154,7 @@ public abstract class AbstractMethodCorrectionProposal extends LinkedCorrectionP > addNewExceptions(rewrite, decl.thrownExceptionTypes()); > > Block body= null; >- if (!fSenderBinding.isInterface()) { >+ if (!fSenderBinding.isInterface() && !Flags.isAbstract(decl.getModifiers())) { > body= ast.newBlock(); > String placeHolder= CodeGeneration.getMethodBodyContent(getCompilationUnit(), fSenderBinding.getName(), newNameNode.getIdentifier(), isConstructor(), bodyStatement, String.valueOf('\n')); > if (placeHolder != null) {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 71627
:
243183
|
243921
|
244284
|
244427
|
244428
|
244539
|
244850