Type-Insert on-the fly ohne Speichern funktioniert ohne dass der JavaTXCompiler gestertet wird.

This commit is contained in:
Michael Uhl 2019-03-31 11:48:19 +02:00
parent f27ad61a8b
commit 80f0708218
3 changed files with 34 additions and 3 deletions

View File

@ -6,6 +6,9 @@ import java.util.stream.Collectors;
import javax.inject.Inject;
import javax.management.relation.RoleUnresolved;
import org.antlr.v4.parse.GrammarTreeVisitor.tokenSpec_return;
import org.antlr.v4.runtime.CommonToken;
import org.antlr.v4.runtime.Token;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
@ -25,10 +28,12 @@ import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.editors.text.TextEditor;
import org.eclipse.ui.internal.views.markers.MarkerContentGenerator;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.texteditor.SimpleMarkerAnnotation;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
import org.stringtemplate.v4.compiler.STParser.memberExpr_return;
import com.google.common.collect.Sets;
@ -37,6 +42,8 @@ import de.dhbwstuttgart.syntaxtree.SourceFile;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
import de.dhbwstuttgart.typedeployment.TypeInsert;
import de.dhbwstuttgart.typedeployment.TypeInsertFactory;
import de.dhbwstuttgart.typedeployment.TypeInsertPoint;
import de.dhbwstuttgart.typeinference.result.ResolvedType;
import de.dhbwstuttgart.typeinference.result.ResultSet;
import de.dhbwstuttgart.typeinference.unify.UnifyResultEvent;
@ -245,6 +252,22 @@ public class JavEditor extends TextEditor implements UnifyResultListener {
typeReplaceMarkers.remove(typeReplaceMarker);
int lengthOfInsert = typeReplaceMarker.getInsertPoint().getInsertString().length();
int line = typeReplaceMarker.getInsertPoint().point.point.getLine();
int posInLine = typeReplaceMarker.getInsertPoint().point.point.getCharPositionInLine();
for (TypeReplaceMarker marker : typeReplaceMarkers) {
if (marker.getInsertPoint().point.point.getStartIndex() > typeReplaceMarker.getInsertPoint().point.point.getStartIndex()) {
Token token = marker.getInsertPoint().point.getToken();
CommonToken newTok = new CommonToken(token);
newTok.setStartIndex(token.getStartIndex() + lengthOfInsert);
newTok.setStopIndex(token.getStopIndex() + lengthOfInsert);
newTok.setTokenIndex(token.getTokenIndex() + lengthOfInsert);
marker.getInsertPoint().point.setToken(newTok);
marker.getInsertPoint().point.setToken(token);
}
}
removeVisualMarkers();
updateGuiWithNewMarkers(typeReplaceMarkers);
/*
@ -330,6 +353,7 @@ public class JavEditor extends TextEditor implements UnifyResultListener {
Set<JavMarker> markers = new HashSet<JavMarker>();
typeReplaceMarkers = typeinference.updateWithResult(new Vector(markers), evt.getNewTypeResult());
for (TypeReplaceMarker m : this.getTypeReplaceMarkers()) {
markers.add(m);
}

View File

@ -65,7 +65,7 @@ public class JavOutline extends ContentOutlinePage{
viewer.addSelectionChangedListener(this);
if(this.syntaxTree!=null)viewer.setInput(this.syntaxTree);
//ContextMenu für die TreeView:
//ContextMenu für die TreeView:
final MenuManager menuMgr = new MenuManager();
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new FillContextMenu(viewer, this));

View File

@ -25,12 +25,19 @@
<dependency>
<groupId>de.dhbwstuttgart</groupId>
<artifactId>JavaTXcompiler</artifactId>
<version>0.1</version>
<version>0.2</version>
</dependency>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4</artifactId>
<version>4.7</version>
<!--exclusions>
<exclusion>
<groupId>org.antlr</groupId>
<artifactId>antlr-runtime</artifactId>
<version>3.5.2</version>
</exclusion>
</exclusions-->
</dependency>
<dependency>
<groupId>commons-io</groupId>
@ -70,7 +77,7 @@
<dependency>
<groupId>de.dhbwstuttgart</groupId>
<artifactId>JavaTXcompiler</artifactId>
<version>0.1.0</version>
<version>0.2.0</version>
</dependency>
<dependency>
<groupId>org.antlr</groupId>