Skip to content

Commit

Permalink
is broken tthuem#54
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremiaheinle committed Apr 16, 2021
1 parent dd5bb06 commit 3e2fdb7
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 24 deletions.
1 change: 1 addition & 0 deletions de.tubs.variantsync.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Bundle-ActivationPolicy: lazy
Bundle-ClassPath: lib/diffutils-2.2-SNAPSHOT.jar,
lib/de.variantsync.core-0.0.3-SNAPSHOT.jar,
lib/gson-2.8.6.jar,
lib/de.ovgu.featureide.lib.fm-v3.5.5.jar,
.
Export-Package: de.tubs.variantsync.core.patch,
de.tubs.variantsync.core.patch.interfaces
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@ private static void addDelta(AST<LineGrammar, String> ast, IDelta delta) {

}

Chunk<String> original = (Chunk<String>)delta.getOriginal();
Chunk<String> revised = (Chunk<String>)delta.getRevised();

//Type Change

Expand All @@ -299,20 +301,54 @@ private static void addDelta(AST<LineGrammar, String> ast, IDelta delta) {
*/


for(AST<LineGrammar, String> line : file) {
String s = "";
if(revised.getLines().size() > 0 && original.getLines().size() > 0) {
s = "change";
}else if(revised.getLines().size() > 0) {
s = "deleted";
}else if(original.getLines().size() > 0) {
s = "added";
}else {
s = "not defined";
}



for (int count = 0; count < file.getSubtrees().size(); count++) {


String strLine = line.getValue();
chunk = (Chunk<String>)delta.getOriginal();
List<String> linesOrig = chunk.getLines();
if(linesOrig.contains(strLine)) {
LogOperations.logRefactor("[addDelta]" + linesOrig.get(linesOrig.indexOf(strLine)) + " strline" + strLine);
}


if (count == original.getPosition()-1) {

for (int i = 0; i < original.getLines().size(); i++) {
file.getSubtrees().remove(count);
}

for (int i = 0; i < revised.getLines().size(); i++) {
file.getSubtrees().add(count, new AST<LineGrammar, String>(LineGrammar.Line, revised.getLines().get(i), delta.getContext()));
count++;
}


}


}



// String strLine = line.getValue();
// chunk = (Chunk<String>)delta.getOriginal();
// List<String> linesOrig = chunk.getLines();
// if(linesOrig.contains(strLine)) {
// LogOperations.logRefactor("[addDelta]" + linesOrig.get(linesOrig.indexOf(strLine)) + " strline" + strLine);
// }

for(AST<LineGrammar, String> line : file) {

String strLine = line.getValue();
LogOperations.logRefactor("[addDelta] line " + strLine);
System.out.println("[addDelta] line " + strLine);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ public IStatus runInUIThread(IProgressMonitor monitor) {

if(fileAST != null) {
LogOperations.logRefactor("[PA] Found file ast for file " + fileAST.getValue());
final List<IVariantSyncMarker> markers = new ArrayList<>(ASTLineGrammarProcessor.getMarkers(fileAST));
if (!markers.isEmpty()) {
MarkerUtils.setMarker(currentFile, markers);
}
//final List<IVariantSyncMarker> markers = new ArrayList<>(ASTLineGrammarProcessor.getMarkers(fileAST));
// if (!markers.isEmpty()) {
// MarkerUtils.setMarker(currentFile, markers);
// }
}

return Status.OK_STATUS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public V getValue() {
public G getType() {
return type;
}

public void setValue(V v) {
this.value = v;
}

/**
* @return the subtrees as an unmodifiable List
Expand All @@ -72,7 +76,8 @@ public List<AST<G, V>> getSubtrees() {
if(subtrees.size() < 1) {
return Collections.emptyList();
}
return Collections.unmodifiableList(subtrees);
//return Collections.unmodifiableList(subtrees);
return subtrees;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import java.io.File;
import java.util.ArrayList;
import java.util.List;


import de.variantsync.core.marker.AMarkerInformation;
import de.variantsync.core.marker.IVariantSyncMarker;

Expand All @@ -16,6 +14,8 @@ public static List<AMarkerInformation> getMarkers(AST<LineGrammar, String> ast){

for(AST<?,?> subtree : ast.getSubtrees()) {
System.out.println("childs "+ subtree.getValue());

//final IVariantSyncMarker variantSyncMarker = new AMarkerInformation(revised.getPosition() - 1, revised.getLines().size() - 1, true);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.util.Arrays;
import java.util.List;

import org.junit.Before;
import org.junit.Test;

import de.variantsync.core.ast.AST;
import de.variantsync.core.ast.ASTLineGrammarProcessor;
import de.variantsync.core.ast.LineGrammar;
Expand Down Expand Up @@ -53,8 +50,7 @@ public void getMarkersTest() {

List<AMarkerInformation> markers = ASTLineGrammarProcessor.getMarkers(root);




assertTrue(true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ public void addAllOnInitialTest() {
assertEquals(oldSize + 2, root.getSubtrees().size());
}

@Test(expected = UnsupportedOperationException.class)
public void addOnSubtreesList() {
root.getSubtrees().add(new AST<>(LineGrammar.Directory, "evilDir"));
}
// @Test(expected = UnsupportedOperationException.class)
// public void addOnSubtreesList() {
// root.getSubtrees().add(new AST<>(LineGrammar.Directory, "evilDir"));
// }

@Test
public void sizeOnInitialTest() {
Expand Down

0 comments on commit 3e2fdb7

Please sign in to comment.