org.eclipse.jdt.internal.corext.fix.CleanUpConstants Java Examples

The following examples show how to use org.eclipse.jdt.internal.corext.fix.CleanUpConstants. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CodeFormatCleanUp.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public String getPreview() {
	StringBuffer buf= new StringBuffer();
	buf.append("/**\n"); //$NON-NLS-1$
	buf.append(" *A Javadoc comment\n"); //$NON-NLS-1$
	buf.append("* @since 2007\n"); //$NON-NLS-1$
	buf.append(" */\n"); //$NON-NLS-1$
	buf.append("public class Engine {\n"); //$NON-NLS-1$
	buf.append("  public void start() {}\n"); //$NON-NLS-1$
	if (isEnabled(CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES) && isEnabled(CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES_ALL)) {
		buf.append("\n"); //$NON-NLS-1$
	} else {
		buf.append("    \n"); //$NON-NLS-1$
	}
	if (isEnabled(CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES)) {
		buf.append("    public\n"); //$NON-NLS-1$
	} else {
		buf.append("    public \n"); //$NON-NLS-1$
	}
	buf.append("        void stop() {\n"); //$NON-NLS-1$
	buf.append("    }\n"); //$NON-NLS-1$
	buf.append("}\n"); //$NON-NLS-1$

	return buf.toString();
}
 
Example #2
Source File: AdvancedQuickAssistProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private static boolean getRemoveExtraParenthesesProposals(IInvocationContext context, ASTNode covering, ArrayList<ASTNode> coveredNodes, Collection<ICommandAccess> resultingCollections) {
	ArrayList<ASTNode> nodes;
	if (context.getSelectionLength() == 0 && covering instanceof ParenthesizedExpression) {
		nodes= new ArrayList<ASTNode>();
		nodes.add(covering);
	} else {
		nodes= coveredNodes;
	}
	if (nodes.isEmpty())
		return false;

	IProposableFix fix= ExpressionsFix.createRemoveUnnecessaryParenthesisFix(context.getASTRoot(), nodes.toArray(new ASTNode[nodes.size()]));
	if (fix == null)
		return false;

	if (resultingCollections == null)
		return true;

	Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_REMOVE);
	Map<String, String> options= new Hashtable<String, String>();
	options.put(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES, CleanUpOptions.TRUE);
	options.put(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES_NEVER, CleanUpOptions.TRUE);
	FixCorrectionProposal proposal= new FixCorrectionProposal(fix, new ExpressionsCleanUp(options), IProposalRelevance.REMOVE_EXTRA_PARENTHESES, image, context);
	resultingCollections.add(proposal);
	return true;
}
 
Example #3
Source File: CodeFormatCleanUp.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public String[] getStepDescriptions() {
	ArrayList<String> result= new ArrayList<String>();
	if (isEnabled(CleanUpConstants.FORMAT_SOURCE_CODE))
		result.add(MultiFixMessages.CodeFormatCleanUp_description);

	if (isEnabled(CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES)) {
		if (isEnabled(CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES_ALL)) {
			result.add(MultiFixMessages.CodeFormatCleanUp_RemoveTrailingAll_description);
		} else if (isEnabled(CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES_IGNORE_EMPTY)) {
			result.add(MultiFixMessages.CodeFormatCleanUp_RemoveTrailingNoEmpty_description);
		}
	}

	if (isEnabled(CleanUpConstants.FORMAT_CORRECT_INDENTATION))
		result.add(MultiFixMessages.CodeFormatCleanUp_correctIndentation_description);

	return result.toArray(new String[result.size()]);
}
 
Example #4
Source File: QuickAssistProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private static boolean getConvertIterableLoopProposal(IInvocationContext context, ASTNode node, Collection<ICommandAccess> resultingCollections) {
	ForStatement forStatement= getEnclosingForStatementHeader(node);
	if (forStatement == null)
		return false;

	if (resultingCollections == null)
		return true;

	IProposableFix fix= ConvertLoopFix.createConvertIterableLoopToEnhancedFix(context.getASTRoot(), forStatement);
	if (fix == null)
		return false;

	Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
	Map<String, String> options= new HashMap<String, String>();
	options.put(CleanUpConstants.CONTROL_STATMENTS_CONVERT_FOR_LOOP_TO_ENHANCED, CleanUpOptions.TRUE);
	ICleanUp cleanUp= new ConvertLoopCleanUp(options);
	FixCorrectionProposal proposal= new FixCorrectionProposal(fix, cleanUp, IProposalRelevance.CONVERT_ITERABLE_LOOP_TO_ENHANCED, image, context);
	proposal.setCommandId(CONVERT_FOR_LOOP_ID);

	resultingCollections.add(proposal);
	return true;
}
 
Example #5
Source File: AdvancedQuickAssistProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private static boolean getAddParanoidalParenthesesProposals(IInvocationContext context, ArrayList<ASTNode> coveredNodes, Collection<ICommandAccess> resultingCollections) {

		IProposableFix fix= ExpressionsFix.createAddParanoidalParenthesisFix(context.getASTRoot(), coveredNodes.toArray(new ASTNode[coveredNodes.size()]));
		if (fix == null)
			return false;

		if (resultingCollections == null)
			return true;

		// add correction proposal
		Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CAST);
		Map<String, String> options= new Hashtable<String, String>();
		options.put(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES, CleanUpOptions.TRUE);
		options.put(CleanUpConstants.EXPRESSIONS_USE_PARENTHESES_ALWAYS, CleanUpOptions.TRUE);
		FixCorrectionProposal proposal= new FixCorrectionProposal(fix, new ExpressionsCleanUp(options), IProposalRelevance.ADD_PARANOIDAL_PARENTHESES, image, context);
		resultingCollections.add(proposal);
		return true;
	}
 
Example #6
Source File: QuickAssistProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private static boolean getRemoveBlockProposals(IInvocationContext context, ASTNode coveringNode, Collection<ICommandAccess> resultingCollections) {
	IProposableFix[] fixes= ControlStatementsFix.createRemoveBlockFix(context.getASTRoot(), coveringNode);
	if (fixes != null) {
		if (resultingCollections == null) {
			return true;
		}
		Map<String, String> options= new Hashtable<String, String>();
		options.put(CleanUpConstants.CONTROL_STATEMENTS_USE_BLOCKS, CleanUpOptions.TRUE);
		options.put(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_NEVER, CleanUpOptions.TRUE);
		ICleanUp cleanUp= new ControlStatementsCleanUp(options);
		for (int i= 0; i < fixes.length; i++) {
			IProposableFix fix= fixes[i];
			Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
			FixCorrectionProposal proposal= new FixCorrectionProposal(fix, cleanUp, IProposalRelevance.REMOVE_BLOCK_FIX, image, context);
			resultingCollections.add(proposal);
		}
		return true;
	}
	return false;
}
 
Example #7
Source File: Java50CleanUp.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public String[] getStepDescriptions() {
	List<String> result= new ArrayList<String>();
	if (isEnabled(CleanUpConstants.ADD_MISSING_ANNOTATIONS) && isEnabled(CleanUpConstants.ADD_MISSING_ANNOTATIONS_OVERRIDE)) {
		result.add(MultiFixMessages.Java50MultiFix_AddMissingOverride_description);
		if (isEnabled(CleanUpConstants.ADD_MISSING_ANNOTATIONS_OVERRIDE_FOR_INTERFACE_METHOD_IMPLEMENTATION)) {
			result.add(MultiFixMessages.Java50MultiFix_AddMissingOverride_description2);
		}
	}
	if (isEnabled(CleanUpConstants.ADD_MISSING_ANNOTATIONS) && isEnabled(CleanUpConstants.ADD_MISSING_ANNOTATIONS_DEPRECATED))
		result.add(MultiFixMessages.Java50MultiFix_AddMissingDeprecated_description);
	if (isEnabled(CleanUpConstants.VARIABLE_DECLARATION_USE_TYPE_ARGUMENTS_FOR_RAW_TYPE_REFERENCES))
		result.add(MultiFixMessages.Java50CleanUp_AddTypeParameters_description);
	return result.toArray(new String[result.size()]);
}
 
Example #8
Source File: StringCleanUp.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public int computeNumberOfFixes(CompilationUnit compilationUnit) {
	try {
		ICompilationUnit cu= (ICompilationUnit)compilationUnit.getJavaElement();
		if (!cu.isStructureKnown())
			return 0; //[clean up] 'Remove unnecessary $NLS-TAGS$' removes necessary ones in case of syntax errors: https://bugs.eclipse.org/bugs/show_bug.cgi?id=285814 : 
	} catch (JavaModelException e) {
		return 0;
	}
	
	int result= 0;
	IProblem[] problems= compilationUnit.getProblems();
	if (isEnabled(CleanUpConstants.ADD_MISSING_NLS_TAGS))
		result+= getNumberOfProblems(problems, IProblem.NonExternalizedStringLiteral);

	if (isEnabled(CleanUpConstants.REMOVE_UNNECESSARY_NLS_TAGS))
		result+= getNumberOfProblems(problems, IProblem.UnnecessaryNLSTag);

	return result;
}
 
Example #9
Source File: Java50CleanUp.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public boolean canFix(ICompilationUnit compilationUnit, IProblemLocation problem) {
	int id= problem.getProblemId();
	
	if (Java50Fix.isMissingOverrideAnnotationProblem(id)) {
		if (isEnabled(CleanUpConstants.ADD_MISSING_ANNOTATIONS) && isEnabled(CleanUpConstants.ADD_MISSING_ANNOTATIONS_OVERRIDE)) {
			return ! Java50Fix.isMissingOverrideAnnotationInterfaceProblem(id) || isEnabled(CleanUpConstants.ADD_MISSING_ANNOTATIONS_OVERRIDE_FOR_INTERFACE_METHOD_IMPLEMENTATION);
		}
		
	} else if (Java50Fix.isMissingDeprecationProblem(id)) {
		return isEnabled(CleanUpConstants.ADD_MISSING_ANNOTATIONS) && isEnabled(CleanUpConstants.ADD_MISSING_ANNOTATIONS_DEPRECATED);
		
	} else if (Java50Fix.isRawTypeReferenceProblem(id)) {
		return isEnabled(CleanUpConstants.VARIABLE_DECLARATION_USE_TYPE_ARGUMENTS_FOR_RAW_TYPE_REFERENCES);
	}

	return false;
}
 
Example #10
Source File: CleanUpRefactoringWizard.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public String getColumnText(Object element, int columnIndex) {
	if (columnIndex == 0) {
		return ((IJavaProject)element).getProject().getName();
	} else if (columnIndex == 1) {

		if (fProfileIdsTable == null)
    		fProfileIdsTable= loadProfiles();

		IEclipsePreferences instancePreferences= InstanceScope.INSTANCE.getNode(JavaUI.ID_PLUGIN);

   		final String workbenchProfileId;
   		if (instancePreferences.get(CleanUpConstants.CLEANUP_PROFILE, null) != null) {
   			workbenchProfileId= instancePreferences.get(CleanUpConstants.CLEANUP_PROFILE, null);
   		} else {
   			workbenchProfileId= CleanUpConstants.DEFAULT_PROFILE;
   		}

		return getProjectProfileName((IJavaProject)element, fProfileIdsTable, workbenchProfileId);
	}
	return null;
}
 
Example #11
Source File: CleanUpConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void performDefaults() {
	super.performDefaults();
	if (fCurrContext == null)
		return;

	fCurrContext.getNode(JavaUI.ID_PLUGIN).remove(CleanUpConstants.SHOW_CLEAN_UP_WIZARD);
	boolean showWizard= DefaultScope.INSTANCE.getNode(JavaUI.ID_PLUGIN).getBoolean(CleanUpConstants.SHOW_CLEAN_UP_WIZARD, true);
	fShowCleanUpWizardDialogField.setDialogFieldListener(null);
	fShowCleanUpWizardDialogField.setSelection(showWizard);
	fShowCleanUpWizardDialogField.setDialogFieldListener(new IDialogFieldListener() {
		public void dialogFieldChanged(DialogField field) {
			doShowCleanUpWizard(fShowCleanUpWizardDialogField.isSelected());
           }
    });
}
 
Example #12
Source File: UnimplementedCodeCleanUp.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public int computeNumberOfFixes(CompilationUnit compilationUnit) {
	if (!isEnabled(CleanUpConstants.ADD_MISSING_METHODES) && !isEnabled(MAKE_TYPE_ABSTRACT))
		return 0;

	IProblemLocation[] locations= filter(convertProblems(compilationUnit.getProblems()), new int[] { IProblem.AbstractMethodMustBeImplemented, IProblem.EnumConstantMustImplementAbstractMethod });

	HashSet<ASTNode> types= new HashSet<ASTNode>();
	for (int i= 0; i < locations.length; i++) {
		ASTNode type= UnimplementedCodeFix.getSelectedTypeNode(compilationUnit, locations[i]);
		if (type != null) {
			types.add(type);
		}
	}

	return types.size();
}
 
Example #13
Source File: SortMembersCleanUp.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public ICleanUpFix createFix(CleanUpContext context) throws CoreException {
	CompilationUnit compilationUnit= context.getAST();
	if (compilationUnit == null)
		return null;

	boolean sortMembers= isEnabled(CleanUpConstants.SORT_MEMBERS);
	ICleanUpFix fix= SortMembersFix.createCleanUp(compilationUnit, sortMembers, sortMembers && isEnabled(CleanUpConstants.SORT_MEMBERS_ALL));
	if (fix != null) {
		if (fTouchedFiles == null) {
			fTouchedFiles= new HashSet<IResource>();
		}
		fTouchedFiles.add(((ICompilationUnit)compilationUnit.getJavaElement()).getResource());
	}
	return fix;
}
 
Example #14
Source File: CodeStyleCleanUp.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected ICleanUpFix createFix(CompilationUnit compilationUnit) throws CoreException {
	if (compilationUnit == null)
		return null;

	boolean nonStaticFields= isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS);
	boolean nonStaticMethods= isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_METHOD_USE_THIS);
	boolean qualifyStatic= isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS);

	return CodeStyleFix.createCleanUp(compilationUnit,
			nonStaticFields && isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS_ALWAYS),
			qualifyStatic && isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_INSTANCE_ACCESS),
			qualifyStatic && isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_FIELD),
			qualifyStatic && isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_SUBTYPE_ACCESS),
			nonStaticMethods && isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_METHOD_USE_THIS_ALWAYS),
			qualifyStatic && isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_METHOD),
			nonStaticFields && isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS_IF_NECESSARY),
			nonStaticMethods && isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_METHOD_USE_THIS_IF_NECESSARY)
			);
}
 
Example #15
Source File: ConvertLoopCleanUp.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public String getPreview() {
	StringBuffer buf= new StringBuffer();

	if (isEnabled(CleanUpConstants.CONTROL_STATMENTS_CONVERT_FOR_LOOP_TO_ENHANCED)) {
		buf.append("for (int element : ids) {\n"); //$NON-NLS-1$
		buf.append("    double value= element / 2; \n"); //$NON-NLS-1$
		buf.append("    System.out.println(value);\n"); //$NON-NLS-1$
		buf.append("}\n"); //$NON-NLS-1$
	} else {
		buf.append("for (int i = 0; i < ids.length; i++) {\n"); //$NON-NLS-1$
		buf.append("    double value= ids[i] / 2; \n"); //$NON-NLS-1$
		buf.append("    System.out.println(value);\n"); //$NON-NLS-1$
		buf.append("}\n"); //$NON-NLS-1$
	}

	return buf.toString();
}
 
Example #16
Source File: CleanUpSaveParticipantPreferenceConfiguration.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void performDefaults() {
	if (ProjectScope.SCOPE.equals(fContext.getName()) && !hasSettingsInScope(fContext))
		return;

	enabled(true);

	if (ProjectScope.SCOPE.equals(fContext.getName())) {
		fSettings= CleanUpPreferenceUtil.loadSaveParticipantOptions(InstanceScope.INSTANCE);
	} else {
		fSettings= JavaPlugin.getDefault().getCleanUpRegistry().getDefaultOptions(CleanUpConstants.DEFAULT_SAVE_ACTION_OPTIONS).getMap();
	}
	settingsChanged();

	super.performDefaults();
}
 
Example #17
Source File: UnimplementedCodeCleanUp.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public String getPreview() {
	StringBuffer buf= new StringBuffer();

	if (isEnabled(MAKE_TYPE_ABSTRACT)) {
		buf.append("public abstract class Face implements IFace {\n"); //$NON-NLS-1$
	} else {
		buf.append("public class Face implements IFace {\n"); //$NON-NLS-1$
	}
	if (isEnabled(CleanUpConstants.ADD_MISSING_METHODES)) {
		boolean createComments= Boolean.valueOf(PreferenceConstants.getPreference(PreferenceConstants.CODEGEN_ADD_COMMENTS, null)).booleanValue();
		if (createComments)
			buf.append(indent(getOverridingMethodComment(), "    ")); //$NON-NLS-1$

		buf.append("    @Override\n"); //$NON-NLS-1$
		buf.append("    public void method() {\n"); //$NON-NLS-1$
		buf.append(indent(getMethodBody(), "        ")); //$NON-NLS-1$
		buf.append("    }\n"); //$NON-NLS-1$
	}
	buf.append("}\n"); //$NON-NLS-1$

	return buf.toString();
}
 
Example #18
Source File: ControlStatementsCleanUp.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public ICleanUpFix createFix(CleanUpContext context) throws CoreException {
	CompilationUnit compilationUnit= context.getAST();
	if (compilationUnit == null)
		return null;

	boolean useBlocks= isEnabled(CleanUpConstants.CONTROL_STATEMENTS_USE_BLOCKS);
	if (!useBlocks)
		return null;

	return ControlStatementsFix.createCleanUp(compilationUnit,
			isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_ALWAYS),
			isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_NEVER),
			isEnabled(CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_NO_FOR_RETURN_AND_THROW));
}
 
Example #19
Source File: CodeStyleCleanUp.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public String[] getStepDescriptions() {
	List<String> result= new ArrayList<String>();
	if (isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS) && isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS_ALWAYS))
		result.add(MultiFixMessages.CodeStyleMultiFix_AddThisQualifier_description);
	if (isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_METHOD_USE_THIS) && isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_METHOD_USE_THIS_ALWAYS))
		result.add(MultiFixMessages.CodeStyleCleanUp_QualifyNonStaticMethod_description);
	if (isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS) && isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS_IF_NECESSARY))
		result.add(MultiFixMessages.CodeStyleCleanUp_removeFieldThis_description);
	if (isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_METHOD_USE_THIS) && isEnabled(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_METHOD_USE_THIS_IF_NECESSARY))
		result.add(MultiFixMessages.CodeStyleCleanUp_removeMethodThis_description);
	if (isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS) && isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_FIELD))
		result.add(MultiFixMessages.CodeStyleMultiFix_QualifyAccessToStaticField);
	if (isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS) && isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_METHOD))
		result.add(MultiFixMessages.CodeStyleCleanUp_QualifyStaticMethod_description);
	if (isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS) && isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_INSTANCE_ACCESS))
		result.add(MultiFixMessages.CodeStyleMultiFix_ChangeNonStaticAccess_description);
	if (isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS) && isEnabled(CleanUpConstants.MEMBER_ACCESSES_STATIC_QUALIFY_WITH_DECLARING_CLASS_SUBTYPE_ACCESS))
		result.add(MultiFixMessages.CodeStyleMultiFix_ChangeIndirectAccessToStaticToDirect);
	return result.toArray(new String[result.size()]);
}
 
Example #20
Source File: UnnecessaryCodeCleanUp.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private Map<String, String> getRequiredOptions() {
	Map<String, String> result= new Hashtable<String, String>();

	if (isEnabled(CleanUpConstants.REMOVE_UNNECESSARY_CASTS))
		result.put(JavaCore.COMPILER_PB_UNNECESSARY_TYPE_CHECK, JavaCore.WARNING);

	return result;
}
 
Example #21
Source File: PotentialProgrammingProblemsCleanUp.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public String[] getStepDescriptions() {
	List<String> result= new ArrayList<String>();

	if ((isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID) && isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_GENERATED)))
		result.add(MultiFixMessages.SerialVersionCleanUp_Generated_description);
	if ((isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID) && isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_DEFAULT)))
		result.add(MultiFixMessages.CodeStyleCleanUp_addDefaultSerialVersionId_description);

	return result.toArray(new String[result.size()]);
}
 
Example #22
Source File: UnnecessaryCodeCleanUp.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public CleanUpRequirements getRequirements() {
	boolean requireAST= isEnabled(CleanUpConstants.REMOVE_UNNECESSARY_CASTS);
	Map<String, String> requiredOptions= requireAST ? getRequiredOptions() : null;
	return new CleanUpRequirements(requireAST, false, false, requiredOptions);
}
 
Example #23
Source File: UnnecessaryCodeCleanUp.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public String[] getStepDescriptions() {
	List<String> result= new ArrayList<String>();
	if (isEnabled(CleanUpConstants.REMOVE_UNNECESSARY_CASTS))
		result.add(MultiFixMessages.UnusedCodeCleanUp_RemoveUnusedCasts_description);
	return result.toArray(new String[result.size()]);
}
 
Example #24
Source File: PotentialProgrammingProblemsCleanUp.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public boolean canFix(ICompilationUnit compilationUnit, IProblemLocation problem) {
	if (problem.getProblemId() == IProblem.MissingSerialVersion)
		return (isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID) && isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_GENERATED))
			|| (isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID) && isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_DEFAULT));

	return false;
}
 
Example #25
Source File: StringCleanUp.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected ICleanUpFix createFix(CompilationUnit compilationUnit, IProblemLocation[] problems) throws CoreException {
	if (compilationUnit == null)
		return null;

	return StringFix.createCleanUp(compilationUnit, problems,
			isEnabled(CleanUpConstants.ADD_MISSING_NLS_TAGS),
			isEnabled(CleanUpConstants.REMOVE_UNNECESSARY_NLS_TAGS));
}
 
Example #26
Source File: StringCleanUp.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public boolean canFix(ICompilationUnit compilationUnit, IProblemLocation problem) {
	if (problem.getProblemId() == IProblem.UnnecessaryNLSTag)
		return isEnabled(CleanUpConstants.REMOVE_UNNECESSARY_NLS_TAGS);

	if (problem.getProblemId() == IProblem.NonExternalizedStringLiteral)
		return isEnabled(CleanUpConstants.ADD_MISSING_NLS_TAGS);

	return false;
}
 
Example #27
Source File: Java50CleanUp.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected ICleanUpFix createFix(CompilationUnit compilationUnit) throws CoreException {
	boolean addAnotations= isEnabled(CleanUpConstants.ADD_MISSING_ANNOTATIONS);
	boolean addOverride= isEnabled(CleanUpConstants.ADD_MISSING_ANNOTATIONS_OVERRIDE);
	return Java50Fix.createCleanUp(compilationUnit,
			addAnotations && addOverride,
			addAnotations && addOverride && isEnabled(CleanUpConstants.ADD_MISSING_ANNOTATIONS_OVERRIDE_FOR_INTERFACE_METHOD_IMPLEMENTATION),
			addAnotations && isEnabled(CleanUpConstants.ADD_MISSING_ANNOTATIONS_DEPRECATED),
			isEnabled(CleanUpConstants.VARIABLE_DECLARATION_USE_TYPE_ARGUMENTS_FOR_RAW_TYPE_REFERENCES));
}
 
Example #28
Source File: PotentialProgrammingProblemsCleanUp.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected ICleanUpFix createFix(CompilationUnit compilationUnit, IProblemLocation[] problems) throws CoreException {
	if (compilationUnit == null)
		return null;

	return PotentialProgrammingProblemsFix.createCleanUp(compilationUnit, problems,
			(isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID) && isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_GENERATED)) ||
			(isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID) && isEnabled(CleanUpConstants.ADD_MISSING_SERIAL_VERSION_ID_DEFAULT)));
}
 
Example #29
Source File: TypeParametersCleanUp.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected ICleanUpFix createFix(CompilationUnit compilationUnit, IProblemLocation[] problems) throws CoreException {
	if (compilationUnit == null)
		return null;

	boolean useTypeParameters= isEnabled(CleanUpConstants.USE_TYPE_ARGUMENTS);
	if (!useTypeParameters)
		return null;

	return TypeParametersFix.createCleanUp(compilationUnit, problems,
			isEnabled(CleanUpConstants.INSERT_INFERRED_TYPE_ARGUMENTS),
			isEnabled(CleanUpConstants.REMOVE_REDUNDANT_TYPE_ARGUMENTS));
}
 
Example #30
Source File: UnusedCodeCleanUp.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected ICleanUpFix createFix(CompilationUnit compilationUnit) throws CoreException {
	boolean removeUnuseMembers= isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_MEMBERS);

	return UnusedCodeFix.createCleanUp(compilationUnit,
			removeUnuseMembers && isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_METHODS),
			removeUnuseMembers && isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_CONSTRUCTORS),
			removeUnuseMembers && isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_FELDS),
			removeUnuseMembers && isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_TYPES),
			isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_LOCAL_VARIABLES),
			isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_IMPORTS) && !isEnabled(CleanUpConstants.ORGANIZE_IMPORTS),
			false);
}