BytecodeGeneratorError wird jetzt abgefangen.
This commit is contained in:
parent
d7c9247a27
commit
fdedcb8191
@ -22,6 +22,7 @@ import org.eclipse.core.runtime.ILog;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
|
||||
import de.dhbwstuttgart.bytecode.BytecodeGen;
|
||||
import de.dhbwstuttgart.bytecode.Exception.BytecodeGeneratorError;
|
||||
import de.dhbwstuttgart.bytecode.descriptor.TypeToDescriptor;
|
||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||
import de.dhbwstuttgart.exceptions.TypeinferenceException;
|
||||
@ -98,7 +99,7 @@ public class Typinferenz {
|
||||
return this.tiResults;
|
||||
}
|
||||
|
||||
public Vector<TypeReplaceMarker> updateWithResult(Vector<TypeReplaceMarker> ret, List<ResultSet> newResults) {
|
||||
public Vector<JavMarker> updateWithResult(Vector<JavMarker> ret, List<ResultSet> newResults) {
|
||||
this.tiResults.addAll(newResults);
|
||||
this.forByteCode.addAll(newResults);
|
||||
|
||||
@ -121,8 +122,13 @@ public class Typinferenz {
|
||||
|
||||
if (this.forByteCode.size() > 0) {
|
||||
for (SourceFile sf : compiler.sourceFiles.values()) {
|
||||
HashMap<String, byte[]> bytecode = getBytecode(sf, this.forByteCode, outputDirectory);
|
||||
this.writeClassFile(outputDirectory, bytecode);
|
||||
try {
|
||||
HashMap<String, byte[]> bytecode = getBytecode(sf, this.forByteCode, outputDirectory);
|
||||
this.writeClassFile(outputDirectory, bytecode);
|
||||
} catch (BytecodeGeneratorError ex) {
|
||||
ErrorMarker toAdd = new ErrorMarker(ex.getMessage(), new CodePoint(sf.getOffset()));
|
||||
ret.add(toAdd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,11 @@
|
||||
package typinferenzplugin.editor;
|
||||
|
||||
import static java.util.Collections.singletonList;
|
||||
import static java.util.stream.Collectors.toCollection;
|
||||
import static org.eclipse.core.runtime.IStatus.ERROR;
|
||||
import static typinferenzplugin.Activator.PLUGIN_ID;
|
||||
import static java.util.Collections.singletonList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.TreeSet;
|
||||
import java.util.Vector;
|
||||
|
||||
@ -70,7 +68,7 @@ public class JavEditor extends TextEditor implements UnifyResultListener {
|
||||
|
||||
private JavOutline outlinePage;
|
||||
/**
|
||||
* Der SyntaxBaum f<EFBFBD>r das aktuell geöffnete Dokument.
|
||||
* Der SyntaxBaum für das aktuell geöffnete Dokument.
|
||||
*/
|
||||
private SourceFile sourceFile;
|
||||
|
||||
@ -78,7 +76,6 @@ public class JavEditor extends TextEditor implements UnifyResultListener {
|
||||
* Die TypeReplaceMarker für das aktuell geöffnete Dokument
|
||||
*/
|
||||
private Vector<JavMarker> errorMarkers = new Vector<JavMarker>();
|
||||
|
||||
private Vector<TypeReplaceMarker> typeReplaceMarkers = new Vector<TypeReplaceMarker>();
|
||||
|
||||
// Help:
|
||||
@ -321,7 +318,7 @@ public class JavEditor extends TextEditor implements UnifyResultListener {
|
||||
|
||||
@Override
|
||||
public void onNewTypeResultFound(UnifyResultEvent evt) {
|
||||
Vector<TypeReplaceMarker> markers = updateMarkers(evt);
|
||||
Vector<JavMarker> markers = updateMarkers(evt);
|
||||
|
||||
// Anschließend die TypeReplaceMarker im Quellcode anzeigen:
|
||||
// https://stackoverflow.com/questions/8945371/how-to-implement-quick-fix-quick-assist-for-custom-eclipse-editor
|
||||
@ -334,13 +331,29 @@ public class JavEditor extends TextEditor implements UnifyResultListener {
|
||||
|
||||
}
|
||||
|
||||
private Vector<TypeReplaceMarker> updateMarkers(UnifyResultEvent evt) {
|
||||
private Vector<JavMarker> updateMarkers(UnifyResultEvent evt) {
|
||||
typeinference.updateresultSets(new Vector<>(evt.getNewTypeResult()));
|
||||
|
||||
Vector<TypeReplaceMarker> markers = new Vector<TypeReplaceMarker>();
|
||||
Vector<TypeReplaceMarker> newMarkers = typeinference.updateWithResult(markers, evt.getNewTypeResult());
|
||||
Vector<JavMarker> markers = new Vector<JavMarker>();
|
||||
Vector<JavMarker> newMarkers = typeinference.updateWithResult(markers, evt.getNewTypeResult());
|
||||
|
||||
typeReplaceMarkers.removeAll(newMarkers);
|
||||
typeReplaceMarkers.addAll(newMarkers);
|
||||
errorMarkers.removeAll(newMarkers);
|
||||
|
||||
typeReplaceMarkers.addAll(
|
||||
newMarkers
|
||||
.stream()
|
||||
.filter(m -> m instanceof TypeReplaceMarker)
|
||||
.map(m -> (TypeReplaceMarker) m)
|
||||
.collect(toCollection(Vector::new))
|
||||
);
|
||||
|
||||
errorMarkers.addAll(
|
||||
newMarkers
|
||||
.stream()
|
||||
.filter(m -> m instanceof TypeReplaceMarker)
|
||||
.collect(toCollection(Vector::new))
|
||||
);
|
||||
|
||||
for (TypeReplaceMarker m : this.getTypeReplaceMarkers()) {
|
||||
markers.add(m);
|
||||
|
Loading…
Reference in New Issue
Block a user