Skip to content

Commit b6cc44a

Browse files
committed
remove deprecated code
1 parent 20a93f5 commit b6cc44a

3 files changed

Lines changed: 3 additions & 100 deletions

File tree

src/main/java/org/variantsync/vevos/simulation/io/TextIO.java

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -69,60 +69,6 @@ public static Result<List<String>, IOException> readLines(final Path p) {
6969
}
7070
}
7171

72-
/**
73-
* Extract all lines in [lineFrom, lineTo] = i from sourceFile and put them into targetFile for each interval i in linesToTake.
74-
*
75-
* @param sourceFile File from which to read lines. Won't be altered.
76-
* @param targetFile File to write the desired lines to.
77-
* @param linesToTake Intervals of lines to copy.
78-
* @throws IOException May occur upon writing or creating files.
79-
*/
80-
public static void copyTextLines(final Path sourceFile, final Path targetFile, final List<Integer> linesToTake) throws IOException {
81-
/// Do not use Files.readAllLines(sourceFile) as it assumes the files to be in UTF-8 and crashes otherwise.
82-
// Do also not use try (final Stream<String> linesStream = new BufferedReader(new FileReader(sourceFile.toFile())).lines()) {
83-
// Apparently, Java is stupid and the BufferedReader is not closed by the try-with-resources if it is anonymous.
84-
try (final BufferedReader br = new BufferedReader(new FileReader(sourceFile.toFile()));
85-
final Stream<String> linesStream = br.lines()) {
86-
final List<String> read_lines = linesStream.toList();
87-
final StringBuilder linesToWrite = new StringBuilder();
88-
89-
for (final Integer lineNo : linesToTake) {
90-
final int lineIndex = lineNo - 1;
91-
// skip lines that exceed the content
92-
if (lineIndex >= read_lines.size()) {
93-
final String logMessage = "Skipped copying line "
94-
+ lineNo
95-
+ " from \""
96-
+ sourceFile
97-
+ "\" to \""
98-
+ targetFile
99-
+ "\" as it is out of bounds [1, "
100-
+ read_lines.size()
101-
+ "]!";
102-
103-
if (lineIndex > read_lines.size()) {
104-
// This was logged frequently and is caused by https://bugs.openjdk.java.net/browse/JDK-8199413
105-
// Skipping the line really is the best solution, as the empty line is created by appending a line separator
106-
// to the previous line. I added the additional if-statement, to only catch cases in which more than one line
107-
// is out of bounds, which indicates a serious problem.
108-
Logger.error(logMessage);
109-
}
110-
} else {
111-
// The list read_lines is 0-based.
112-
// Given lines are 1-based because line numbers are typically given 1-based.
113-
// Thus, we have to -1 here because line numbers are 1-indexed
114-
// but we want to look them up in read_lines, which is 0-based.
115-
linesToWrite.append(read_lines.get(lineIndex)).append(System.lineSeparator());
116-
}
117-
}
118-
119-
Files.write(
120-
targetFile,
121-
linesToWrite.toString().getBytes(),
122-
StandardOpenOption.APPEND);
123-
}
124-
}
125-
12672
/**
12773
* Writes the given text to the given file.
12874
* Creates a new file and assumes there exists no file yet at the given path.

src/main/java/org/variantsync/vevos/simulation/variability/pc/LineBasedAnnotation.java

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,7 @@ public LineBasedAnnotation(final LineBasedAnnotation other) {
5454
this.style = other.style;
5555
}
5656

57-
private static void addRange(final List<Integer> list, final int fromInclusive, final int toInclusive) {
58-
for (int i = fromInclusive; i <= toInclusive; ++i) {
59-
list.add(i);
60-
}
61-
}
62-
63-
private static void addRange2(final List<VariantLineChunk> list, final int fromInclusive, final int toInclusive) {
57+
private static void addRange(final List<VariantLineChunk> list, final int fromInclusive, final int toInclusive) {
6458
for (int i = fromInclusive; i <= toInclusive; ++i) {
6559
list.add(new VariantLine(i));
6660
}
@@ -154,37 +148,6 @@ private Optional<LineBasedAnnotation> deriveForVariant(final Variant variant, in
154148
}
155149
}
156150

157-
/**
158-
* Computes all lines that should be included in the given variant when evaluating the annotations in this artefact.
159-
*
160-
* @param isIncluded A predicate to select subtrees. A subtree will be considered if isIncluded returns true for it.
161-
* @return All line numbers that should be copied from the SPL file to the variant file. 1-based.
162-
*/
163-
public List<Integer> getAllLinesFor(final Predicate<LineBasedAnnotation> isIncluded) {
164-
final List<Integer> chunksToWrite = new ArrayList<>();
165-
final int firstCodeLine = getLineFrom() + style.offset; // ignore #if
166-
final int lastCodeLine = getLineTo() - style.offset; // ignore #endif
167-
168-
int currentLine = firstCodeLine;
169-
for (final LineBasedAnnotation subtree : subtrees) {
170-
if (currentLine < subtree.getLineFrom()) {
171-
addRange(chunksToWrite, currentLine, subtree.getLineFrom() - 1);
172-
}
173-
174-
if (isIncluded.test(subtree)) {
175-
chunksToWrite.addAll(subtree.getAllLinesFor(isIncluded));
176-
}
177-
178-
currentLine = subtree.getLineTo() + 1;
179-
}
180-
181-
if (currentLine <= lastCodeLine) {
182-
addRange(chunksToWrite, currentLine, lastCodeLine);
183-
}
184-
185-
return chunksToWrite;
186-
}
187-
188151
/**
189152
* Computes all lines that should be included in the given variant when evaluating the annotations in this artefact.
190153
*
@@ -200,7 +163,7 @@ public VariantAnnotation getLinesToCopy(final Predicate<LineBasedAnnotation> isI
200163
int currentLine = firstCodeLine;
201164
for (final LineBasedAnnotation subtree : subtrees) {
202165
if (currentLine < subtree.getLineFrom()) {
203-
addRange2(chunksToWrite, currentLine, subtree.getLineFrom() - 1);
166+
addRange(chunksToWrite, currentLine, subtree.getLineFrom() - 1);
204167
}
205168

206169
if (isIncluded.test(subtree)) {
@@ -211,7 +174,7 @@ public VariantAnnotation getLinesToCopy(final Predicate<LineBasedAnnotation> isI
211174
}
212175

213176
if (currentLine <= lastCodeLine) {
214-
addRange2(chunksToWrite, currentLine, lastCodeLine);
177+
addRange(chunksToWrite, currentLine, lastCodeLine);
215178
}
216179

217180
return new VariantAnnotation(

src/main/java/org/variantsync/vevos/simulation/variability/pc/variantlines/ProjectionOptions.java

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)