use of org.eclipse.core.runtime.CoreException in project che by eclipse.
the class RefactoringHistoryManager method getCachedSession.
/**
* Returns the cached refactoring session descriptor.
*
* @param store
* the file store of the descriptor
* @param projectName
* project name, or <code>null</code> for the workspace
* @param input
* the input stream where to read the descriptor
* @return the cached refactoring session descriptor
* @throws CoreException
* if an error occurs while reading the session
*/
private RefactoringSessionDescriptor getCachedSession(final IFileStore store, String projectName, final InputStream input) throws CoreException {
if (store.equals(fCachedStore) && fCachedDescriptor != null)
return fCachedDescriptor;
final RefactoringSessionDescriptor descriptor;
try {
descriptor = new RefactoringSessionReader(false, projectName).readSession(new InputSource(input));
fCachedDescriptor = descriptor;
fCachedStore = store;
return descriptor;
} catch (CoreException e) {
throw new CoreException(new MultiStatus(RefactoringCorePlugin.getPluginId(), IRefactoringCoreStatusCodes.REFACTORING_HISTORY_IO_ERROR, new IStatus[] { e.getStatus() }, Messages.format(RefactoringCoreMessages.RefactoringHistoryManager_error_reading_file, BasicElementLabels.getURLPart(store.toURI().toString())), null));
}
}
use of org.eclipse.core.runtime.CoreException in project che by eclipse.
the class DeleteResourcesProcessor method checkDirtyResources.
private void checkDirtyResources(final RefactoringStatus result) throws CoreException {
for (int i = 0; i < fResources.length; i++) {
IResource resource = fResources[i];
if (resource instanceof IProject && !((IProject) resource).isOpen())
continue;
resource.accept(new IResourceVisitor() {
public boolean visit(IResource visitedResource) throws CoreException {
if (visitedResource instanceof IFile) {
checkDirtyFile(result, (IFile) visitedResource);
}
return true;
}
}, IResource.DEPTH_INFINITE, false);
}
}
use of org.eclipse.core.runtime.CoreException in project che by eclipse.
the class MultiStateUndoChange method isValid.
/**
* {@inheritDoc}
*/
public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException {
if (pm == null)
pm = new NullProgressMonitor();
//$NON-NLS-1$
pm.beginTask("", 1);
try {
if (fValidationState == null)
//$NON-NLS-1$
throw new CoreException(new Status(IStatus.ERROR, RefactoringCorePlugin.getPluginId(), "MultiStateUndoChange has not been initialialized"));
ITextFileBuffer buffer = FileBuffers.getTextFileBufferManager().getTextFileBuffer(fFile.getFullPath(), LocationKind.IFILE);
fDirty = buffer != null && buffer.isDirty();
return fValidationState.isValid(needsSaving(), true);
} finally {
pm.done();
}
}
use of org.eclipse.core.runtime.CoreException in project che by eclipse.
the class UndoTextFileChange method performEdits.
private UndoEdit performEdits(ITextFileBuffer buffer, final IDocument document, final boolean[] setContentStampSuccess) throws MalformedTreeException, BadLocationException, CoreException {
if (!buffer.isSynchronizationContextRequested()) {
return doPerformEdits(document, setContentStampSuccess);
}
ITextFileBufferManager fileBufferManager = FileBuffers.getTextFileBufferManager();
/** The lock for waiting for computation in the UI thread to complete. */
final Lock completionLock = new Lock();
final UndoEdit[] result = new UndoEdit[1];
final BadLocationException[] badLocationException = new BadLocationException[1];
final MalformedTreeException[] malformedTreeException = new MalformedTreeException[1];
final CoreException[] coreException = new CoreException[1];
Runnable runnable = new Runnable() {
public void run() {
synchronized (completionLock) {
try {
result[0] = doPerformEdits(document, setContentStampSuccess);
} catch (BadLocationException e) {
badLocationException[0] = e;
} catch (MalformedTreeException e) {
malformedTreeException[0] = e;
} catch (CoreException e) {
coreException[0] = e;
} finally {
completionLock.fDone = true;
completionLock.notifyAll();
}
}
}
};
synchronized (completionLock) {
fileBufferManager.execute(runnable);
while (!completionLock.fDone) {
try {
completionLock.wait(500);
} catch (InterruptedException x) {
}
}
}
if (badLocationException[0] != null) {
throw badLocationException[0];
} else if (malformedTreeException[0] != null) {
throw malformedTreeException[0];
} else if (coreException[0] != null) {
throw coreException[0];
}
return result[0];
}
use of org.eclipse.core.runtime.CoreException in project che by eclipse.
the class ParticipantExtensionPoint method getParticipants.
/**
* Returns all participants for a given element.
*
* @param status a refactoring status to report status if problems occurred while
* loading the participants
* @param processor the processor that will own the participants
* @param element the element to be copied or a corresponding descriptor
* @param arguments the arguments for the participants
* @param filter a participant filter to exclude certain participants, or <code>null</code>
* if no filtering is desired
* @param affectedNatures an array of project natures affected by the refactoring
* @param shared a list of shared participants
*
* @return an array of participants
*/
public RefactoringParticipant[] getParticipants(RefactoringStatus status, RefactoringProcessor processor, Object element, RefactoringArguments arguments, IParticipantDescriptorFilter filter, String[] affectedNatures, SharableParticipants shared) {
if (fParticipants == null)
init();
EvaluationContext evalContext = createEvaluationContext(processor, element, affectedNatures);
List result = new ArrayList();
for (Iterator iter = fParticipants.iterator(); iter.hasNext(); ) {
ParticipantDescriptor descriptor = (ParticipantDescriptor) iter.next();
if (!descriptor.isEnabled()) {
iter.remove();
} else {
try {
RefactoringStatus filterStatus = new RefactoringStatus();
if (descriptor.matches(evalContext, filter, filterStatus)) {
RefactoringParticipant participant = shared.get(descriptor);
if (participant != null) {
((ISharableParticipant) participant).addElement(element, arguments);
} else {
participant = descriptor.createParticipant();
if (fParticipantClass.isInstance(participant)) {
if (participant.initialize(processor, element, arguments)) {
participant.setDescriptor(descriptor);
result.add(participant);
if (participant instanceof ISharableParticipant)
shared.put(descriptor, participant);
}
} else {
status.addError(Messages.format(RefactoringCoreMessages.ParticipantExtensionPoint_participant_removed, descriptor.getName()));
RefactoringCorePlugin.logErrorMessage(Messages.format(RefactoringCoreMessages.ParticipantExtensionPoint_wrong_type, new String[] { descriptor.getName(), fParticipantClass.getName() }));
iter.remove();
}
}
} else {
status.merge(filterStatus);
}
} catch (CoreException e) {
logMalfunctioningParticipant(status, descriptor, e);
iter.remove();
} catch (RuntimeException e) {
logMalfunctioningParticipant(status, descriptor, e);
iter.remove();
}
}
}
return (RefactoringParticipant[]) result.toArray(new RefactoringParticipant[result.size()]);
}
Aggregations