diff --git a/JavaCompilerPlugin/bundles/JavaCompilerPlugin.Plugin/src/typinferenzplugin/Typinferenz.java b/JavaCompilerPlugin/bundles/JavaCompilerPlugin.Plugin/src/typinferenzplugin/Typinferenz.java index 4db2143..e8fa978 100644 --- a/JavaCompilerPlugin/bundles/JavaCompilerPlugin.Plugin/src/typinferenzplugin/Typinferenz.java +++ b/JavaCompilerPlugin/bundles/JavaCompilerPlugin.Plugin/src/typinferenzplugin/Typinferenz.java @@ -173,4 +173,8 @@ public class Typinferenz { public SourceFile getSourceFile() { return parsedSource; } + + public void cancel() { + compiler.usedTasks.cancel(); + } } diff --git a/JavaCompilerPlugin/bundles/JavaCompilerPlugin.Plugin/src/typinferenzplugin/editor/JavEditor.java b/JavaCompilerPlugin/bundles/JavaCompilerPlugin.Plugin/src/typinferenzplugin/editor/JavEditor.java index 443a199..8594363 100644 --- a/JavaCompilerPlugin/bundles/JavaCompilerPlugin.Plugin/src/typinferenzplugin/editor/JavEditor.java +++ b/JavaCompilerPlugin/bundles/JavaCompilerPlugin.Plugin/src/typinferenzplugin/editor/JavEditor.java @@ -24,6 +24,7 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; 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.Position; 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.ui.IEditorInput; 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.part.FileEditorInput; import org.eclipse.ui.texteditor.IDocumentProvider; @@ -89,6 +92,30 @@ public class JavEditor extends TextEditor implements UnifyResultListener { // install the document provider // setDocumentProvider(new HTMLDocumentProvider()); 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 @@ -112,6 +139,7 @@ public class JavEditor extends TextEditor implements UnifyResultListener { public void doSave(IProgressMonitor monitor) { super.doSave(monitor); // Wird aufgerufen, sobald das Dokument gespeichert wird. + typeinference.cancel(); typeinference = new Typinferenz(this); this.removeMarkers(); this.typeReconstruction(); @@ -231,6 +259,8 @@ public class JavEditor extends TextEditor implements UnifyResultListener { * @param typeReplaceMarker */ public void runReplaceMarker(TypeReplaceMarker typeReplaceMarker) { + typeinference.cancel(); + IDocument document = this.getDocumentProvider().getDocument(this.getEditorInput()); document.set(typeReplaceMarker.insertType(document.get()));