Java Code Examples for org.eclipse.ltk.core.refactoring.RefactoringStatus#FATAL

The following examples show how to use org.eclipse.ltk.core.refactoring.RefactoringStatus#FATAL . 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: LtkIssueAcceptor.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
protected int convert(RefactoringIssueAcceptor.Severity severity) {
	int refactoringStatus = RefactoringStatus.OK;
	if (severity != null) {
		switch (severity) {
			case FATAL:
				refactoringStatus = RefactoringStatus.FATAL;
				break;
			case ERROR:
				refactoringStatus = RefactoringStatus.ERROR;
				break;
			case WARNING:
				refactoringStatus = RefactoringStatus.WARNING;
				break;
			case INFO:
				refactoringStatus = RefactoringStatus.INFO;
				break;
			default:
				break;
		}
	}
	return refactoringStatus;
}
 
Example 2
Source File: FileEventHandler.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
private static WorkspaceEdit getRenameEdit(IJavaElement targetElement, String newName, IProgressMonitor monitor) throws CoreException {
	RenameSupport renameSupport = RenameSupport.create(targetElement, newName, RenameSupport.UPDATE_REFERENCES);
	if (renameSupport == null) {
		return null;
	}

	if (targetElement instanceof IPackageFragment) {
		((RenamePackageProcessor) renameSupport.getJavaRenameProcessor()).setRenameSubpackages(true);
	}

	RenameRefactoring renameRefactoring = renameSupport.getRenameRefactoring();
	RefactoringTickProvider rtp = renameRefactoring.getRefactoringTickProvider();
	SubMonitor submonitor = SubMonitor.convert(monitor, "Creating rename changes...", rtp.getAllTicks());
	CheckConditionsOperation checkConditionOperation = new CheckConditionsOperation(renameRefactoring, CheckConditionsOperation.ALL_CONDITIONS);
	checkConditionOperation.run(submonitor.split(rtp.getCheckAllConditionsTicks()));
	if (checkConditionOperation.getStatus().getSeverity() >= RefactoringStatus.FATAL) {
		JavaLanguageServerPlugin.logError(checkConditionOperation.getStatus().getMessageMatchingSeverity(RefactoringStatus.ERROR));
	}

	Change change = renameRefactoring.createChange(submonitor.split(rtp.getCreateChangeTicks()));
	change.initializeValidationData(new NotCancelableProgressMonitor(submonitor.split(rtp.getInitializeChangeTicks())));
	return ChangeUtil.convertToWorkspaceEdit(change);
}
 
Example 3
Source File: ExtractClassWizard.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
protected void updateDecoration(ControlDecoration decoration, RefactoringStatus status) {
	RefactoringStatusEntry highestSeverity= status.getEntryWithHighestSeverity();
	if (highestSeverity != null) {
		Image newImage= null;
		FieldDecorationRegistry registry= FieldDecorationRegistry.getDefault();
		switch (highestSeverity.getSeverity()) {
			case RefactoringStatus.INFO:
				newImage= registry.getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage();
				break;
			case RefactoringStatus.WARNING:
				newImage= registry.getFieldDecoration(FieldDecorationRegistry.DEC_WARNING).getImage();
				break;
			case RefactoringStatus.FATAL:
			case RefactoringStatus.ERROR:
				newImage= registry.getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage();
		}
		decoration.setDescriptionText(highestSeverity.getMessage());
		decoration.setImage(newImage);
		decoration.show();
	} else {
		decoration.setDescriptionText(null);
		decoration.hide();
	}
}
 
Example 4
Source File: ExtractClassWizard.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
protected RefactoringStatus validateRefactoring() {
	RefactoringStatus status= new RefactoringStatus();
	setErrorMessage(null);
	setMessage(null);
	setPageComplete(true);
	status.merge(validateTopLevel());
	status.merge(validateClassName());
	status.merge(validateParameterName());
	status.merge(validateFields());
	RefactoringStatusEntry highestSeverity= status.getEntryWithHighestSeverity();
	if (highestSeverity != null) {
		switch (highestSeverity.getSeverity()) {
			case RefactoringStatus.ERROR:
			case RefactoringStatus.FATAL:
				setErrorMessage(highestSeverity.getMessage());
				setPageComplete(false);
				break;
			case RefactoringStatus.WARNING:
				setMessage(highestSeverity.getMessage(), IMessageProvider.WARNING);
				break;
			case RefactoringStatus.INFO:
				setMessage(highestSeverity.getMessage(), IMessageProvider.INFORMATION);
				break;
		}
	}
	return status;
}
 
Example 5
Source File: TargetProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public int getStatusSeverity() {
	return RefactoringStatus.FATAL;
}
 
Example 6
Source File: MemberVisibilityAdjustor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Is the specified severity a refactoring status severity?
 *
 * @param severity the severity to test
 * @return <code>true</code> if it is a refactoring status severity, <code>false</code> otherwise
 */
private static boolean isStatusSeverity(final int severity) {
	return severity == RefactoringStatus.ERROR || severity == RefactoringStatus.FATAL || severity == RefactoringStatus.INFO || severity == RefactoringStatus.OK || severity == RefactoringStatus.WARNING;
}