Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bundles/org.eclipse.jface.text/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jface.text
Bundle-Version: 3.28.0.qualifier
Bundle-Version: 3.28.100.qualifier
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@

import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;

import org.eclipse.jface.text.DocumentEvent;
import org.eclipse.jface.text.IDocument;
Expand Down Expand Up @@ -53,7 +56,7 @@ abstract public class AbstractReconciler implements IReconciler {
/**
* Background thread for the reconciling activity.
*/
class BackgroundThread extends Thread {
private class BackgroundThread extends Job {

/** Has the reconciler been canceled. */
private boolean fCanceled= false;
Expand All @@ -64,6 +67,10 @@ class BackgroundThread extends Thread {
/** Is a reconciling strategy active. */
private boolean fIsActive= false;

private volatile boolean fIsAlive;

private boolean started;

/**
* Creates a new background thread. The thread
* runs with minimal priority.
Expand All @@ -72,8 +79,8 @@ class BackgroundThread extends Thread {
*/
public BackgroundThread(String name) {
super(name);
setPriority(Thread.MIN_PRIORITY);
setDaemon(true);
setPriority(Job.DECORATE);
setSystem(true);
}

/**
Expand All @@ -98,7 +105,7 @@ public synchronized boolean isDirty() {
/**
* Cancels the background thread.
*/
public void cancel() {
public void doCancel() {
fCanceled= true;
IProgressMonitor pm= fProgressMonitor;
if (pm != null)
Expand Down Expand Up @@ -153,7 +160,9 @@ public void reset() {
fDirtyRegionQueue.notifyAll();
}
}

synchronized (this) {
started= false;
}
informNotFinished();
reconcilerReset();
}
Expand All @@ -167,12 +176,12 @@ public void reset() {
* </p>
*/
@Override
public void run() {

public IStatus run(IProgressMonitor monitor) {
fIsAlive= true;
delay();

if (fCanceled)
return;
return Status.CANCEL_STATUS;

initialProcess();

Expand Down Expand Up @@ -217,6 +226,24 @@ public void run() {

fIsActive= false;
}
fIsAlive= false;
return Status.OK_STATUS;
}

public boolean isAlive() {
return fIsAlive;
}

public synchronized void start() {
if (!started) {
started= true;
schedule();
}
}

@Override
public boolean belongsTo(Object family) {
return family == fViewer || AbstractReconciler.class == family;
}
}

Expand All @@ -233,7 +260,7 @@ public void documentAboutToBeChanged(DocumentEvent e) {
public void documentChanged(DocumentEvent e) {

if (fThread.isActive() || !fThread.isDirty() && fThread.isAlive()) {
if (!fIsAllowedToModifyDocument && Thread.currentThread() == fThread)
if (!fIsAllowedToModifyDocument && isRunningInReconcilerThread())
throw new UnsupportedOperationException("The reconciler thread is not allowed to modify the document"); //$NON-NLS-1$
aboutToBeReconciledInternal();
}
Expand Down Expand Up @@ -485,7 +512,7 @@ public void uninstall() {
// http://dev.eclipse.org/bugs/show_bug.cgi?id=19135
BackgroundThread bt= fThread;
fThread= null;
bt.cancel();
bt.doCancel();
}
}
}
Expand Down Expand Up @@ -614,14 +641,7 @@ protected synchronized void startReconciling() {
return;

if (!fThread.isAlive()) {
try {
fThread.start();
} catch (IllegalThreadStateException e) {
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=40549
// This is the only instance where the thread is started; since
// we checked that it is not alive, it must be dead already due
// to a run-time exception or error. Exit.
}
fThread.start();
} else {
fThread.reset();
}
Expand All @@ -640,7 +660,10 @@ protected void reconcilerReset() {
* @return <code>true</code> if running in this reconciler's background thread
* @since 3.4
*/
protected boolean isRunningInReconcilerThread() {
return Thread.currentThread() == fThread;
protected synchronized boolean isRunningInReconcilerThread() {
if (fThread == null) {
return false;
}
return Job.getJobManager().currentJob() == fThread;
}
}
}
Loading