|
Lines 9-14
Link Here
|
| 9 |
* IBM Corporation - initial API and implementation |
9 |
* IBM Corporation - initial API and implementation |
| 10 |
* Benjamin Muskalla <bmuskalla@innoopract.com> - [quick fix] 'Remove invalid modifiers' does not appear for enums and annotations - https://bugs.eclipse.org/bugs/show_bug.cgi?id=110589 |
10 |
* Benjamin Muskalla <bmuskalla@innoopract.com> - [quick fix] 'Remove invalid modifiers' does not appear for enums and annotations - https://bugs.eclipse.org/bugs/show_bug.cgi?id=110589 |
| 11 |
* Benjamin Muskalla <b.muskalla@gmx.net> - [quick fix] Quick fix for missing synchronized modifier - https://bugs.eclipse.org/bugs/show_bug.cgi?id=245250 |
11 |
* Benjamin Muskalla <b.muskalla@gmx.net> - [quick fix] Quick fix for missing synchronized modifier - https://bugs.eclipse.org/bugs/show_bug.cgi?id=245250 |
|
|
12 |
* Rabea Gransberger <rgransberger@gmx.de> - [quick fix] QuickFix proposes wrong visibility for overriding/overridden method - https://bugs.eclipse.org/bugs/show_bug.cgi?id=216898 |
| 12 |
*******************************************************************************/ |
13 |
*******************************************************************************/ |
| 13 |
package org.eclipse.jdt.internal.ui.text.correction; |
14 |
package org.eclipse.jdt.internal.ui.text.correction; |
| 14 |
|
15 |
|
|
Lines 257-291
Link Here
|
| 257 |
overriddenInClass= Bindings.findOverriddenMethodInType(curr, method); |
258 |
overriddenInClass= Bindings.findOverriddenMethodInType(curr, method); |
| 258 |
} |
259 |
} |
| 259 |
if (overriddenInClass != null) { |
260 |
if (overriddenInClass != null) { |
| 260 |
IMethodBinding overriddenDecl= overriddenInClass.getMethodDeclaration(); |
261 |
final IMethodBinding overriddenDecl= overriddenInClass.getMethodDeclaration(); |
| 261 |
ICompilationUnit targetCU= ASTResolving.findCompilationUnitForBinding(cu, context.getASTRoot(), overriddenDecl.getDeclaringClass()); |
262 |
final ICompilationUnit overriddenMethodCU= ASTResolving.findCompilationUnitForBinding(cu, context.getASTRoot(), overriddenDecl.getDeclaringClass()); |
| 262 |
if (targetCU != null) { |
263 |
|
| 263 |
String methodLabel= BasicElementLabels.getJavaElementName(curr.getName() + '.' + overriddenInClass.getName()); |
264 |
IMethodBinding targetMethod= overriddenDecl; |
| 264 |
String label; |
265 |
ICompilationUnit targetCU= overriddenMethodCU; |
| 265 |
int excludedModifiers; |
266 |
|
| 266 |
int includedModifiers; |
267 |
String methodLabel= BasicElementLabels.getJavaElementName(overriddenDecl.getDeclaringClass().getName() + '.' + overriddenDecl.getName()); |
| 267 |
switch (kind) { |
268 |
String label; |
| 268 |
case TO_VISIBLE: |
269 |
int excludedModifiers; |
|
|
270 |
int includedModifiers; |
| 271 |
switch (kind) { |
| 272 |
case TO_VISIBLE: |
| 273 |
if (JdtFlags.isPrivate(method)) { |
| 274 |
// Propose to increase the visibility of this method, because decreasing to private is not possible. |
| 275 |
targetMethod= method; |
| 276 |
targetCU= cu; |
| 277 |
|
| 278 |
methodLabel= BasicElementLabels.getJavaElementName(method.getDeclaringClass().getName() + '.' + method.getName()); |
| 279 |
|
| 280 |
excludedModifiers= Modifier.PRIVATE | Modifier.PROTECTED | Modifier.PUBLIC; |
| 281 |
includedModifiers= JdtFlags.getVisibilityCode(overriddenDecl); |
| 282 |
} |
| 283 |
else { |
| 269 |
excludedModifiers= Modifier.PRIVATE | Modifier.PROTECTED | Modifier.PUBLIC; |
284 |
excludedModifiers= Modifier.PRIVATE | Modifier.PROTECTED | Modifier.PUBLIC; |
| 270 |
includedModifiers= JdtFlags.getVisibilityCode(method); |
285 |
includedModifiers= JdtFlags.getVisibilityCode(method); |
| 271 |
label= Messages.format(CorrectionMessages.ModifierCorrectionSubProcessor_changeoverriddenvisibility_description, new String[] { methodLabel, getVisibilityString(includedModifiers) }); |
286 |
} |
| 272 |
break; |
287 |
label= Messages.format(CorrectionMessages.ModifierCorrectionSubProcessor_changeoverriddenvisibility_description, |
| 273 |
case TO_NON_FINAL: |
288 |
new String[] { methodLabel, getVisibilityString(includedModifiers) }); |
| 274 |
label= Messages.format(CorrectionMessages.ModifierCorrectionSubProcessor_changemethodtononfinal_description, methodLabel); |
289 |
break; |
| 275 |
excludedModifiers= Modifier.FINAL; |
290 |
case TO_NON_FINAL: |
| 276 |
includedModifiers= 0; |
291 |
label= Messages.format(CorrectionMessages.ModifierCorrectionSubProcessor_changemethodtononfinal_description, methodLabel); |
| 277 |
break; |
292 |
excludedModifiers= Modifier.FINAL; |
| 278 |
case TO_NON_STATIC: |
293 |
includedModifiers= 0; |
| 279 |
label= Messages.format(CorrectionMessages.ModifierCorrectionSubProcessor_changemethodtononstatic_description, methodLabel); |
294 |
break; |
| 280 |
excludedModifiers= Modifier.STATIC; |
295 |
case TO_NON_STATIC: |
| 281 |
includedModifiers= 0; |
296 |
label= Messages.format(CorrectionMessages.ModifierCorrectionSubProcessor_changemethodtononstatic_description, methodLabel); |
| 282 |
break; |
297 |
excludedModifiers= Modifier.STATIC; |
| 283 |
default: |
298 |
includedModifiers= 0; |
| 284 |
Assert.isTrue(false, "not supported"); //$NON-NLS-1$ |
299 |
break; |
| 285 |
return; |
300 |
default: |
| 286 |
} |
301 |
Assert.isTrue(false, "not supported"); //$NON-NLS-1$ |
|
|
302 |
return; |
| 303 |
} |
| 304 |
|
| 305 |
if (targetCU != null) { |
| 287 |
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE); |
306 |
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE); |
| 288 |
proposals.add(new ModifierChangeCorrectionProposal(label, targetCU, overriddenDecl, selectedNode, includedModifiers, excludedModifiers, IProposalRelevance.CHANGE_OVERRIDDEN_MODIFIER_2, image)); |
307 |
proposals.add(new ModifierChangeCorrectionProposal(label, targetCU, targetMethod, selectedNode, includedModifiers, excludedModifiers, |
|
|
308 |
IProposalRelevance.CHANGE_OVERRIDDEN_MODIFIER_2, image)); |
| 289 |
} |
309 |
} |
| 290 |
} |
310 |
} |
| 291 |
} |
311 |
} |