Cancel funktioniert jetzt.
This commit is contained in:
parent
157a4c18c2
commit
9e78c6e91c
@ -25,7 +25,6 @@ import org.eclipse.core.runtime.Status;
|
|||||||
|
|
||||||
import de.dhbwstuttgart.bytecode.BytecodeGen;
|
import de.dhbwstuttgart.bytecode.BytecodeGen;
|
||||||
import de.dhbwstuttgart.bytecode.Exception.BytecodeGeneratorError;
|
import de.dhbwstuttgart.bytecode.Exception.BytecodeGeneratorError;
|
||||||
import de.dhbwstuttgart.bytecode.descriptor.TypeToDescriptor;
|
|
||||||
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile;
|
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile;
|
||||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
import de.dhbwstuttgart.exceptions.TypeinferenceException;
|
import de.dhbwstuttgart.exceptions.TypeinferenceException;
|
||||||
@ -200,7 +199,7 @@ public class Typinferenz {
|
|||||||
|
|
||||||
public void cancel() {
|
public void cancel() {
|
||||||
try {
|
try {
|
||||||
// compiler.usedTasks.cancel();
|
compiler.usedTasks.cancel();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ 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;
|
||||||
import org.eclipse.jface.text.source.IAnnotationModel;
|
import org.eclipse.jface.text.source.IAnnotationModel;
|
||||||
|
import org.eclipse.jface.wizard.ProgressMonitorPart;
|
||||||
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;
|
||||||
@ -126,14 +127,38 @@ public class JavEditor extends TextEditor implements UnifyResultListener {
|
|||||||
*/
|
*/
|
||||||
private void typeReconstruction() {
|
private void typeReconstruction() {
|
||||||
Job job = Job.create("Doing type recoustruction...", (ICoreRunnable) monitor -> {
|
Job job = Job.create("Doing type recoustruction...", (ICoreRunnable) monitor -> {
|
||||||
|
Runnable cancelledChecker = new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
boolean finished = false;
|
||||||
|
while (!finished && !Thread.interrupted()) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(200);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (monitor.isCanceled()) {
|
||||||
|
typeinference.cancel();
|
||||||
|
finished = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Thread cancelledCheckerThread = new Thread(cancelledChecker, "TypeinferenceCancelledChecker");
|
||||||
|
cancelledCheckerThread.setDaemon(true);
|
||||||
|
|
||||||
// do something long running
|
// do something long running
|
||||||
if (!this.typeReplaceMarkers.isEmpty() || !this.errorMarkers.isEmpty()) {
|
if (!this.typeReplaceMarkers.isEmpty() || !this.errorMarkers.isEmpty()) {
|
||||||
LOG.log(new Status(ERROR, PLUGIN_ID,
|
LOG.log(new Status(ERROR, PLUGIN_ID,
|
||||||
"Fehler: Zuerst Marker löschen, bevor Typinferenz durchgeführt werden kann"));
|
"Fehler: Zuerst Marker löschen, bevor Typinferenz durchgeführt werden kann"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
cancelledCheckerThread.start();
|
||||||
typeinference.run(this);
|
typeinference.run(this);
|
||||||
} catch (TypeinferenceException texc) {
|
} catch (TypeinferenceException texc) {
|
||||||
ErrorMarker errorMarker = new ErrorMarker(texc.getMessage(), new CodePoint(texc.getOffset()));
|
ErrorMarker errorMarker = new ErrorMarker(texc.getMessage(), new CodePoint(texc.getOffset()));
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
/.settings/
|
/.settings/
|
||||||
*.project
|
*.project
|
||||||
|
/target/
|
||||||
|
@ -5,7 +5,13 @@
|
|||||||
<projects>
|
<projects>
|
||||||
</projects>
|
</projects>
|
||||||
<buildSpec>
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
</buildSpec>
|
</buildSpec>
|
||||||
<natures>
|
<natures>
|
||||||
|
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||||
</natures>
|
</natures>
|
||||||
</projectDescription>
|
</projectDescription>
|
||||||
|
Loading…
Reference in New Issue
Block a user