Java Code Examples for org.eclipse.ltk.core.refactoring.RefactoringStatus#getMessageMatchingSeverity()
The following examples show how to use
org.eclipse.ltk.core.refactoring.RefactoringStatus#getMessageMatchingSeverity() .
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: ChangeUtilities.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
/** * Creates a {@link Change} from the given {@link Refactoring}. * * @param errorLevel the error level for the condition checking which should * cause the change creation to fail * * @return a non-null {@link Change} * @throws RefactoringException if there was a problem creating the change */ public static Change createChange(IWorkspace workspace, IProgressMonitor pm, Refactoring refactoring, int errorLevel) throws RefactoringException { CreateChangeOperation createChangeOperation = ChangeUtilities.createCreateChangeOperation( refactoring, errorLevel); try { workspace.run(createChangeOperation, pm); RefactoringStatus status = createChangeOperation.getConditionCheckingStatus(); if (status.getSeverity() >= errorLevel) { // Could not create the change, throw an exception with the failure // status message throw new RefactoringException( status.getMessageMatchingSeverity(status.getSeverity())); } } catch (CoreException e) { throw new RefactoringException(e); } return createChangeOperation.getChange(); }
Example 2
Source File: ChangeBuilder.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
/** * Creates a refactoring (or returns a previously created refactoring). */ public Refactoring createRefactoring() throws RefactoringException { if (refactoring != null) { return refactoring; } RefactoringStatus status = new RefactoringStatus(); D descriptor = createDescriptor(); try { refactoring = descriptor.createRefactoring(status); } catch (CoreException e) { throw new RefactoringException(e); } if (refactoring == null) { throw new RefactoringException( String.format( "The refactoring descriptor (%s) was unable to create a refactoring.", descriptor.getClass().getSimpleName())); } if (status.hasError()) { throw new RefactoringException( status.getMessageMatchingSeverity(RefactoringStatus.ERROR)); } return refactoring; }
Example 3
Source File: NewNameQueries.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private static IInputValidator createCompilationUnitNameValidator(final ICompilationUnit cu) { IInputValidator validator= new IInputValidator(){ public String isValid(String newText) { if (newText == null || "".equals(newText)) //$NON-NLS-1$ return INVALID_NAME_NO_MESSAGE; String newCuName= JavaModelUtil.getRenamedCUName(cu, newText); IStatus status= JavaConventionsUtil.validateCompilationUnitName(newCuName, cu); if (status.getSeverity() == IStatus.ERROR) return status.getMessage(); RefactoringStatus refStatus; refStatus= Checks.checkCompilationUnitNewName(cu, newText); if (refStatus.hasFatalError()) return refStatus.getMessageMatchingSeverity(RefactoringStatus.FATAL); if (cu.getElementName().equalsIgnoreCase(newCuName)) return ReorgMessages.ReorgQueries_resourceExistsWithDifferentCaseMassage; return null; } }; return validator; }
Example 4
Source File: IntroduceFactoryInputPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void validateInput(boolean methodName) { RefactoringStatus merged= new RefactoringStatus(); if (fMethodNameStatus != null && (methodName || fMethodNameStatus.hasError())) merged.merge(fMethodNameStatus); if (fDestinationStatus != null && (!methodName || fDestinationStatus.hasError())) merged.merge(fDestinationStatus); setPageComplete(!merged.hasError()); int severity= merged.getSeverity(); String message= merged.getMessageMatchingSeverity(severity); if (severity >= RefactoringStatus.INFO) { setMessage(message, severity); } else { setMessage("", NONE); //$NON-NLS-1$ } }
Example 5
Source File: ChangeCorrectionProposal.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
/** * Performs the change associated with this proposal. * <p> * Subclasses may extend, but must call the super implementation. * * @throws CoreException * when the invocation of the change failed */ @Override protected void performChange() throws CoreException { Change change= null; try { change= getChange(); if (change != null) { change.initializeValidationData(new NullProgressMonitor()); RefactoringStatus valid= change.isValid(new NullProgressMonitor()); if (valid.hasFatalError()) { IStatus status = new Status(IStatus.ERROR, IConstants.PLUGIN_ID, IStatus.ERROR, valid.getMessageMatchingSeverity(RefactoringStatus.FATAL), null); throw new CoreException(status); } else { IUndoManager manager= RefactoringCore.getUndoManager(); Change undoChange; boolean successful= false; try { manager.aboutToPerformChange(change); undoChange= change.perform(new NullProgressMonitor()); successful= true; } finally { manager.changePerformed(change, successful); } if (undoChange != null) { undoChange.initializeValidationData(new NullProgressMonitor()); manager.addUndo(getName(), undoChange); } } } } finally { if (change != null) { change.dispose(); } } }
Example 6
Source File: ExtractMethodIntegrationTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
protected void assertExtractForbidden(final CharSequence input, final Procedure1<? super ExtractMethodRefactoring> initializer, final String messageFragment) { try { final String inputString = input.toString(); final IFile file = this.workbenchTestHelper.createFile("Foo", inputString.replace("$", "")); final XtextEditor editor = this.workbenchTestHelper.openEditor(file); try { final IUnitOfWork<String, XtextResource> _function = (XtextResource it) -> { String _xblockexpression = null; { int _indexOf = inputString.indexOf("$"); int _lastIndexOf = inputString.lastIndexOf("$"); int _indexOf_1 = inputString.indexOf("$"); int _minus = (_lastIndexOf - _indexOf_1); int _minus_1 = (_minus - 1); TextSelection _textSelection = new TextSelection(_indexOf, _minus_1); final List<XExpression> selection = this.util.findSelectedSiblingExpressions(it, _textSelection); final ExtractMethodRefactoring refactoring = this.refactoringProvider.get(); refactoring.initialize(editor, selection, true); refactoring.setMethodName("bar"); NullProgressMonitor _nullProgressMonitor = new NullProgressMonitor(); final RefactoringStatus status = refactoring.checkInitialConditions(_nullProgressMonitor); initializer.apply(refactoring); NullProgressMonitor _nullProgressMonitor_1 = new NullProgressMonitor(); status.merge(refactoring.checkFinalConditions(_nullProgressMonitor_1)); Assert.assertTrue(status.toString(), status.hasError()); final String message = status.getMessageMatchingSeverity(RefactoringStatus.ERROR); Assert.assertTrue(message, message.toLowerCase().contains(messageFragment.toLowerCase())); _xblockexpression = ""; } return _xblockexpression; }; editor.getDocument().<String>readOnly(_function); } finally { editor.close(false); } } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example 7
Source File: IntroduceIndirectionInputPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void validateInput() { RefactoringStatus merged= new RefactoringStatus(); merged.merge(getIntroduceIndirectionRefactoring().setIntermediaryTypeName(fIntermediaryTypeName.getText())); merged.merge(getIntroduceIndirectionRefactoring().setIntermediaryMethodName(fIntermediaryMethodName.getText())); setPageComplete(!merged.hasError()); int severity= merged.getSeverity(); String message= merged.getMessageMatchingSeverity(severity); if (severity >= RefactoringStatus.INFO) { setMessage(message, severity); } else { setMessage("", NONE); //$NON-NLS-1$ } }
Example 8
Source File: SelfEncapsulateFieldInputPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void processValidation() { RefactoringStatus status= fRefactoring.checkMethodNames(); String message= null; boolean valid= true; if (status.hasFatalError()) { message= status.getMessageMatchingSeverity(RefactoringStatus.FATAL); valid= false; } setErrorMessage(message); setPageComplete(valid); }
Example 9
Source File: RenameSupport.java From typescript.java with MIT License | 4 votes |
private void showInformation(Shell parent, RefactoringStatus status) { String message = status.getMessageMatchingSeverity(RefactoringStatus.FATAL); MessageDialog.openInformation(parent, RefactoringMessages.RenameSupport_dialog_title, message); }
Example 10
Source File: RenameSupport.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private void showInformation(Shell parent, RefactoringStatus status) { String message= status.getMessageMatchingSeverity(RefactoringStatus.FATAL); MessageDialog.openInformation(parent, JavaUIMessages.RenameSupport_dialog_title, message); }