View | Details | Raw Unified | Return to bug 285000 | Differences between
and this patch

Collapse All | Expand All

(-)ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java (-1 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 417-422 Link Here
417
	public static String ProblemSeveritiesConfigurationBlock_pb_annotation_super_interface_label;
417
	public static String ProblemSeveritiesConfigurationBlock_pb_annotation_super_interface_label;
418
	public static String ProblemSeveritiesConfigurationBlock_pb_type_parameter_hiding_label;
418
	public static String ProblemSeveritiesConfigurationBlock_pb_type_parameter_hiding_label;
419
	public static String ProblemSeveritiesConfigurationBlock_pb_unused_label_label;
419
	public static String ProblemSeveritiesConfigurationBlock_pb_unused_label_label;
420
	public static String ProblemSeveritiesConfigurationBlock_pb_unused_object_allocation_label;
420
	public static String JavadocProblemsPreferencePage_title;
421
	public static String JavadocProblemsPreferencePage_title;
421
	public static String JavadocProblemsConfigurationBlock_allStandardTags;
422
	public static String JavadocProblemsConfigurationBlock_allStandardTags;
422
	public static String JavadocProblemsConfigurationBlock_public;
423
	public static String JavadocProblemsConfigurationBlock_public;
(-)ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties (-1 / +2 lines)
Lines 1-5 Link Here
1
###############################################################################
1
###############################################################################
2
# Copyright (c) 2000, 2009 IBM Corporation and others.
2
# Copyright (c) 2000, 2010 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
5
# which accompanies this distribution, and is available at
Lines 453-458 Link Here
453
ProblemSeveritiesConfigurationBlock_ignore_documented_unused_parameters=Ignore parameters documented with '@param' tag
453
ProblemSeveritiesConfigurationBlock_ignore_documented_unused_parameters=Ignore parameters documented with '@param' tag
454
ProblemSeveritiesConfigurationBlock_pb_type_parameter_hiding_label=Type parameter hides another type:
454
ProblemSeveritiesConfigurationBlock_pb_type_parameter_hiding_label=Type parameter hides another type:
455
ProblemSeveritiesConfigurationBlock_pb_unused_label_label=Unused 'break' or 'continue' label:
455
ProblemSeveritiesConfigurationBlock_pb_unused_label_label=Unused 'break' or 'continue' label:
456
ProblemSeveritiesConfigurationBlock_pb_unused_object_allocation_label=Unused object allocation:
456
ProblemSeveritiesConfigurationBlock_unused_suppresswarnings_token=Unused '@SuppressWarnings' token:
457
ProblemSeveritiesConfigurationBlock_unused_suppresswarnings_token=Unused '@SuppressWarnings' token:
457
JavadocProblemsPreferencePage_title=Javadoc Comments
458
JavadocProblemsPreferencePage_title=Javadoc Comments
458
459
(-)ui/org/eclipse/jdt/internal/ui/preferences/ProblemSeveritiesConfigurationBlock.java (-2 / +6 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 108-113 Link Here
108
108
109
	private static final Key PREF_PB_MISSING_HASHCODE_METHOD= getJDTCoreKey(JavaCore.COMPILER_PB_MISSING_HASHCODE_METHOD);
109
	private static final Key PREF_PB_MISSING_HASHCODE_METHOD= getJDTCoreKey(JavaCore.COMPILER_PB_MISSING_HASHCODE_METHOD);
110
	private static final Key PREF_PB_DEAD_CODE= getJDTCoreKey(JavaCore.COMPILER_PB_DEAD_CODE);
110
	private static final Key PREF_PB_DEAD_CODE= getJDTCoreKey(JavaCore.COMPILER_PB_DEAD_CODE);
111
	private static final Key PREF_PB_UNUSED_OBJECT_ALLOCATION= getJDTCoreKey(JavaCore.COMPILER_PB_UNUSED_OBJECT_ALLOCATION);
111
112
112
	
113
	
113
	// values
114
	// values
Lines 157-163 Link Here
157
				PREF_15_PB_RAW_TYPE_REFERENCE, PREF_PB_FATAL_OPTIONAL_ERROR,
158
				PREF_15_PB_RAW_TYPE_REFERENCE, PREF_PB_FATAL_OPTIONAL_ERROR,
158
				PREF_PB_FORBIDDEN_REFERENCE, PREF_PB_DISCOURRAGED_REFERENCE, PREF_PB_SUPPRESS_WARNINGS, PREF_PB_UNHANDLED_WARNING_TOKEN,
159
				PREF_PB_FORBIDDEN_REFERENCE, PREF_PB_DISCOURRAGED_REFERENCE, PREF_PB_SUPPRESS_WARNINGS, PREF_PB_UNHANDLED_WARNING_TOKEN,
159
				PREF_PB_COMPARING_IDENTICAL, PREF_PB_MISSING_SYNCHRONIZED_ON_INHERITED_METHOD, PREF_PB_MISSING_HASHCODE_METHOD,
160
				PREF_PB_COMPARING_IDENTICAL, PREF_PB_MISSING_SYNCHRONIZED_ON_INHERITED_METHOD, PREF_PB_MISSING_HASHCODE_METHOD,
160
				PREF_PB_DEAD_CODE
161
				PREF_PB_DEAD_CODE, PREF_PB_UNUSED_OBJECT_ALLOCATION
161
			};
162
			};
162
	}
163
	}
163
164
Lines 315-320 Link Here
315
		label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_dead_code;
316
		label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_dead_code;
316
		addComboBox(inner, label, PREF_PB_DEAD_CODE, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
317
		addComboBox(inner, label, PREF_PB_DEAD_CODE, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
317
		
318
		
319
		label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_unused_object_allocation_label;
320
		addComboBox(inner, label, PREF_PB_UNUSED_OBJECT_ALLOCATION, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent);
321
318
		// --- name_shadowing
322
		// --- name_shadowing
319
323
320
		label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_section_name_shadowing;
324
		label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_section_name_shadowing;
(-)ui/org/eclipse/jdt/internal/ui/text/correction/CorrectionMessages.java (+3 lines)
Lines 337-343 Link Here
337
	public static String ReorgCorrectionsSubProcessor_project_seup_fix_description;
337
	public static String ReorgCorrectionsSubProcessor_project_seup_fix_description;
338
	public static String ReorgCorrectionsSubProcessor_project_seup_fix_info;
338
	public static String ReorgCorrectionsSubProcessor_project_seup_fix_info;
339
	public static String UnresolvedElementsSubProcessor_change_full_type_description;
339
	public static String UnresolvedElementsSubProcessor_change_full_type_description;
340
	public static String LocalCorrectionsSubProcessor_remove_allocated_description;
340
	public static String LocalCorrectionsSubProcessor_remove_redundant_superinterface;
341
	public static String LocalCorrectionsSubProcessor_remove_redundant_superinterface;
342
	public static String LocalCorrectionsSubProcessor_return_allocated_description;
341
	public static String LocalCorrectionsSubProcessor_qualify_left_hand_side_description;
343
	public static String LocalCorrectionsSubProcessor_qualify_left_hand_side_description;
342
	public static String LocalCorrectionsSubProcessor_LocalCorrectionsSubProcessor_qualify_right_hand_side_description;
344
	public static String LocalCorrectionsSubProcessor_LocalCorrectionsSubProcessor_qualify_right_hand_side_description;
343
	public static String UnresolvedElementsSubProcessor_UnresolvedElementsSubProcessor_changetoattribute_description;
345
	public static String UnresolvedElementsSubProcessor_UnresolvedElementsSubProcessor_changetoattribute_description;
Lines 350-355 Link Here
350
	public static String LocalCorrectionsSubProcessor_insert_break_statement;
352
	public static String LocalCorrectionsSubProcessor_insert_break_statement;
351
	public static String LocalCorrectionsSubProcessor_insert_fall_through;
353
	public static String LocalCorrectionsSubProcessor_insert_fall_through;
352
	public static String LocalCorrectionsSubProcessor_override_hashCode_description;
354
	public static String LocalCorrectionsSubProcessor_override_hashCode_description;
355
	public static String LocalCorrectionsSubProcessor_throw_allocated_description;
353
	public static String SuppressWarningsSubProcessor_fix_suppress_token_label;
356
	public static String SuppressWarningsSubProcessor_fix_suppress_token_label;
354
	public static String SuppressWarningsSubProcessor_remove_annotation_label;
357
	public static String SuppressWarningsSubProcessor_remove_annotation_label;
355
}
358
}
(-)ui/org/eclipse/jdt/internal/ui/text/correction/CorrectionMessages.properties (+3 lines)
Lines 87-92 Link Here
87
LocalCorrectionsSubProcessor_generate_hashCode_equals_description=Generate hashCode() and equals()...
87
LocalCorrectionsSubProcessor_generate_hashCode_equals_description=Generate hashCode() and equals()...
88
LocalCorrectionsSubProcessor_uninitializedvariable_description=Initialize variable
88
LocalCorrectionsSubProcessor_uninitializedvariable_description=Initialize variable
89
LocalCorrectionsSubProcessor_removesemicolon_description=Remove semicolon
89
LocalCorrectionsSubProcessor_removesemicolon_description=Remove semicolon
90
LocalCorrectionsSubProcessor_remove_allocated_description=Remove
90
LocalCorrectionsSubProcessor_remove_redundant_superinterface=Remove super interface
91
LocalCorrectionsSubProcessor_remove_redundant_superinterface=Remove super interface
91
LocalCorrectionsSubProcessor_renaming_duplicate_method=Rename method ''{0}''
92
LocalCorrectionsSubProcessor_renaming_duplicate_method=Rename method ''{0}''
92
LocalCorrectionsSubProcessor_removeunreachablecode_description=Remove
93
LocalCorrectionsSubProcessor_removeunreachablecode_description=Remove
Lines 106-111 Link Here
106
LocalCorrectionsSubProcessor_setparenteses_instanceof_description=Put 'instanceof' in parentheses
107
LocalCorrectionsSubProcessor_setparenteses_instanceof_description=Put 'instanceof' in parentheses
107
LocalCorrectionsSubProcessor_qualify_left_hand_side_description=Qualify left hand side
108
LocalCorrectionsSubProcessor_qualify_left_hand_side_description=Qualify left hand side
108
LocalCorrectionsSubProcessor_replacefieldaccesswithmethod_description=Replace with ''{0}''
109
LocalCorrectionsSubProcessor_replacefieldaccesswithmethod_description=Replace with ''{0}''
110
LocalCorrectionsSubProcessor_return_allocated_description=Return the allocated object
111
LocalCorrectionsSubProcessor_throw_allocated_description=Throw the allocated object
109
TypeMismatchSubProcessor_addcast_description=Add cast to ''{0}''
112
TypeMismatchSubProcessor_addcast_description=Add cast to ''{0}''
110
TypeMismatchSubProcessor_changecast_description=Change cast to ''{0}''
113
TypeMismatchSubProcessor_changecast_description=Change cast to ''{0}''
111
TypeMismatchSubProcessor_changereturntype_description=Change method return type to ''{0}''
114
TypeMismatchSubProcessor_changereturntype_description=Change method return type to ''{0}''
(-)ui/org/eclipse/jdt/internal/ui/text/correction/LocalCorrectionsSubProcessor.java (-1 / +65 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 75-86 Link Here
75
import org.eclipse.jdt.core.dom.Name;
75
import org.eclipse.jdt.core.dom.Name;
76
import org.eclipse.jdt.core.dom.ParenthesizedExpression;
76
import org.eclipse.jdt.core.dom.ParenthesizedExpression;
77
import org.eclipse.jdt.core.dom.PrefixExpression;
77
import org.eclipse.jdt.core.dom.PrefixExpression;
78
import org.eclipse.jdt.core.dom.ReturnStatement;
78
import org.eclipse.jdt.core.dom.SimpleName;
79
import org.eclipse.jdt.core.dom.SimpleName;
79
import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
80
import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
80
import org.eclipse.jdt.core.dom.Statement;
81
import org.eclipse.jdt.core.dom.Statement;
81
import org.eclipse.jdt.core.dom.StructuralPropertyDescriptor;
82
import org.eclipse.jdt.core.dom.StructuralPropertyDescriptor;
82
import org.eclipse.jdt.core.dom.SwitchCase;
83
import org.eclipse.jdt.core.dom.SwitchCase;
83
import org.eclipse.jdt.core.dom.SwitchStatement;
84
import org.eclipse.jdt.core.dom.SwitchStatement;
85
import org.eclipse.jdt.core.dom.ThrowStatement;
84
import org.eclipse.jdt.core.dom.TryStatement;
86
import org.eclipse.jdt.core.dom.TryStatement;
85
import org.eclipse.jdt.core.dom.Type;
87
import org.eclipse.jdt.core.dom.Type;
86
import org.eclipse.jdt.core.dom.TypeDeclaration;
88
import org.eclipse.jdt.core.dom.TypeDeclaration;
Lines 111-116 Link Here
111
import org.eclipse.jdt.internal.corext.refactoring.surround.ExceptionAnalyzer;
113
import org.eclipse.jdt.internal.corext.refactoring.surround.ExceptionAnalyzer;
112
import org.eclipse.jdt.internal.corext.refactoring.surround.SurroundWithTryCatchRefactoring;
114
import org.eclipse.jdt.internal.corext.refactoring.surround.SurroundWithTryCatchRefactoring;
113
import org.eclipse.jdt.internal.corext.refactoring.util.NoCommentSourceRangeComputer;
115
import org.eclipse.jdt.internal.corext.refactoring.util.NoCommentSourceRangeComputer;
116
import org.eclipse.jdt.internal.corext.refactoring.util.TightSourceRangeComputer;
114
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
117
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
115
import org.eclipse.jdt.internal.corext.util.Messages;
118
import org.eclipse.jdt.internal.corext.util.Messages;
116
119
Lines 992-997 Link Here
992
		proposals.add(proposal);
995
		proposals.add(proposal);
993
	}
996
	}
994
997
998
	public static void getUnusedObjectAllocationProposals(IInvocationContext context, IProblemLocation problem, Collection proposals) {
999
		CompilationUnit root= context.getASTRoot();
1000
		AST ast= root.getAST();
1001
		ASTNode selectedNode= problem.getCoveringNode(root);
1002
		if (selectedNode == null) {
1003
			return;
1004
		}
1005
		
1006
		ASTNode parent= selectedNode.getParent();
1007
		
1008
		if (parent instanceof ExpressionStatement) {
1009
			ExpressionStatement expressionStatement= (ExpressionStatement) parent;
1010
			Expression expr= expressionStatement.getExpression();
1011
			ITypeBinding exprType= expr.resolveTypeBinding();
1012
			
1013
			if (exprType != null && Bindings.isSuperType(ast.resolveWellKnownType("java.lang.Throwable"), exprType)) { //$NON-NLS-1$
1014
				ASTRewrite rewrite= ASTRewrite.create(ast);
1015
				TightSourceRangeComputer sourceRangeComputer= new TightSourceRangeComputer();
1016
				rewrite.setTargetSourceRangeComputer(sourceRangeComputer);
1017
				
1018
				ThrowStatement throwStatement= ast.newThrowStatement();
1019
				throwStatement.setExpression((Expression) rewrite.createMoveTarget(expr));
1020
				sourceRangeComputer.addTightSourceNode(expressionStatement);
1021
				rewrite.replace(expressionStatement, throwStatement, null);
1022
1023
				String label= CorrectionMessages.LocalCorrectionsSubProcessor_throw_allocated_description;
1024
				Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
1025
				ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, 8, image);
1026
				proposals.add(proposal);
1027
			}
1028
			
1029
			MethodDeclaration method= ASTResolving.findParentMethodDeclaration(selectedNode);
1030
			if (method != null) {
1031
				ASTRewrite rewrite= ASTRewrite.create(ast);
1032
				TightSourceRangeComputer sourceRangeComputer= new TightSourceRangeComputer();
1033
				rewrite.setTargetSourceRangeComputer(sourceRangeComputer);
1034
				
1035
				ReturnStatement returnStatement= ast.newReturnStatement();
1036
				returnStatement.setExpression((Expression) rewrite.createMoveTarget(expr));
1037
				sourceRangeComputer.addTightSourceNode(expressionStatement);
1038
				rewrite.replace(expressionStatement, returnStatement, null);
1039
1040
				String label= CorrectionMessages.LocalCorrectionsSubProcessor_return_allocated_description;
1041
				Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
1042
				ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, 7, image);
1043
				proposals.add(proposal);
1044
			}
1045
			
1046
			{
1047
				ASTRewrite rewrite= ASTRewrite.create(ast);
1048
				rewrite.remove(parent, null);
1049
				
1050
				String label= CorrectionMessages.LocalCorrectionsSubProcessor_remove_allocated_description;
1051
				Image image= JavaPlugin.getDefault().getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE);
1052
				ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, 2, image);
1053
				proposals.add(proposal);
1054
			}
1055
			
1056
		}
1057
	}
1058
995
	public static void getAssignmentHasNoEffectProposals(IInvocationContext context, IProblemLocation problem, Collection proposals) {
1059
	public static void getAssignmentHasNoEffectProposals(IInvocationContext context, IProblemLocation problem, Collection proposals) {
996
		CompilationUnit root= context.getASTRoot();
1060
		CompilationUnit root= context.getASTRoot();
997
		ASTNode selectedNode= problem.getCoveringNode(root);
1061
		ASTNode selectedNode= problem.getCoveringNode(root);
(-)ui/org/eclipse/jdt/internal/ui/text/correction/QuickFixProcessor.java (-1 / +5 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 211-216 Link Here
211
			case IProblem.IncompatibleTypesInForeach:
211
			case IProblem.IncompatibleTypesInForeach:
212
			case IProblem.MissingEnumConstantCase:
212
			case IProblem.MissingEnumConstantCase:
213
			case IProblem.MissingSynchronizedModifierInInheritedMethod:
213
			case IProblem.MissingSynchronizedModifierInInheritedMethod:
214
			case IProblem.UnusedObjectAllocation:
214
				return true;
215
				return true;
215
			default:
216
			default:
216
				return SuppressWarningsSubProcessor.hasSuppressWarningsProposal(cu.getJavaProject(), problemId);
217
				return SuppressWarningsSubProcessor.hasSuppressWarningsProposal(cu.getJavaProject(), problemId);
Lines 597-602 Link Here
597
			case IProblem.MissingSynchronizedModifierInInheritedMethod:
598
			case IProblem.MissingSynchronizedModifierInInheritedMethod:
598
				ModifierCorrectionSubProcessor.addSynchronizedMethodProposal(context, problem, proposals);
599
				ModifierCorrectionSubProcessor.addSynchronizedMethodProposal(context, problem, proposals);
599
				break;
600
				break;
601
			case IProblem.UnusedObjectAllocation:
602
				LocalCorrectionsSubProcessor.getUnusedObjectAllocationProposals(context, problem, proposals);
603
				break;
600
			default:
604
			default:
601
		}
605
		}
602
		if (JavaModelUtil.is50OrHigher(context.getCompilationUnit().getJavaProject())) {
606
		if (JavaModelUtil.is50OrHigher(context.getCompilationUnit().getJavaProject())) {

Return to bug 285000