This commit is contained in:
Michael Uhl 2019-07-03 10:45:13 +02:00
parent 809459f6e9
commit 3213c7c118
2 changed files with 34 additions and 0 deletions

View File

@ -173,4 +173,8 @@ public class Typinferenz {
public SourceFile getSourceFile() { public SourceFile getSourceFile() {
return parsedSource; return parsedSource;
} }
public void cancel() {
compiler.usedTasks.cancel();
}
} }

View File

@ -24,6 +24,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job; import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.e4.ui.di.UISynchronize; import org.eclipse.e4.ui.di.UISynchronize;
import org.eclipse.jdt.internal.corext.refactoring.reorg.ParentChecker;
import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.Position; import org.eclipse.jface.text.Position;
import org.eclipse.jface.text.source.Annotation; import org.eclipse.jface.text.source.Annotation;
@ -31,6 +32,8 @@ import org.eclipse.jface.text.source.IAnnotationModel;
import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput; import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.IPartListener;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.editors.text.TextEditor; import org.eclipse.ui.editors.text.TextEditor;
import org.eclipse.ui.part.FileEditorInput; import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.texteditor.IDocumentProvider; import org.eclipse.ui.texteditor.IDocumentProvider;
@ -89,6 +92,30 @@ public class JavEditor extends TextEditor implements UnifyResultListener {
// install the document provider // install the document provider
// setDocumentProvider(new HTMLDocumentProvider()); // setDocumentProvider(new HTMLDocumentProvider());
typeinference = new Typinferenz(this); typeinference = new Typinferenz(this);
getSite().getPage().addPartListener(new IPartListener() {
@Override
public void partOpened(IWorkbenchPart arg0) {
}
@Override
public void partDeactivated(IWorkbenchPart arg0) {
}
@Override
public void partClosed(IWorkbenchPart arg0) {
typeinference.cancel();
}
@Override
public void partBroughtToTop(IWorkbenchPart arg0) {
}
@Override
public void partActivated(IWorkbenchPart arg0) {
}
});
} }
@Override @Override
@ -112,6 +139,7 @@ public class JavEditor extends TextEditor implements UnifyResultListener {
public void doSave(IProgressMonitor monitor) { public void doSave(IProgressMonitor monitor) {
super.doSave(monitor); super.doSave(monitor);
// Wird aufgerufen, sobald das Dokument gespeichert wird. // Wird aufgerufen, sobald das Dokument gespeichert wird.
typeinference.cancel();
typeinference = new Typinferenz(this); typeinference = new Typinferenz(this);
this.removeMarkers(); this.removeMarkers();
this.typeReconstruction(); this.typeReconstruction();
@ -231,6 +259,8 @@ public class JavEditor extends TextEditor implements UnifyResultListener {
* @param typeReplaceMarker * @param typeReplaceMarker
*/ */
public void runReplaceMarker(TypeReplaceMarker typeReplaceMarker) { public void runReplaceMarker(TypeReplaceMarker typeReplaceMarker) {
typeinference.cancel();
IDocument document = this.getDocumentProvider().getDocument(this.getEditorInput()); IDocument document = this.getDocumentProvider().getDocument(this.getEditorInput());
document.set(typeReplaceMarker.insertType(document.get())); document.set(typeReplaceMarker.insertType(document.get()));