Skip to content

Restore the ability to read source-namespace-only mapping files #121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
- Restore the ability to read source-namespace-only mapping files, even if not spec-compliant

## [0.7.0] - 2025-01-01
- Added IntelliJ IDEA migration map reader and writer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ private static void read(ColumnFileReader reader, String sourceNs, String target
dstNamespaces = new ArrayList<>();
String dstNamespace;

while ((dstNamespace = reader.nextCol()) != null) {
if (dstNamespace.isEmpty()) throw new IOException("empty destination namespace in TSRG v2 header");
while (!reader.isAtEol()) {
dstNamespace = reader.nextCol();
if (dstNamespace == null || dstNamespace.isEmpty()) throw new IOException("empty destination namespace in TSRG v2 header");
dstNamespaces.add(dstNamespace);
}

if (dstNamespaces.isEmpty()) throw new IOException("no destination namespaces in TSRG v2 header");
reader.nextLine(0);
} else {
if (sourceNs == null || sourceNs.isEmpty()) throw new IllegalArgumentException("provided source namespace must not be null or empty");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ private static void read(ColumnFileReader reader, MappingVisitor visitor) throws
List<String> dstNamespaces = new ArrayList<>();
String dstNamespace;

while ((dstNamespace = reader.nextCol()) != null) {
if (dstNamespace.isEmpty()) throw new IOException("empty destination namespace in Tiny v1 header");
while (!reader.isAtEol()) {
dstNamespace = reader.nextCol();
if (dstNamespace == null || dstNamespace.isEmpty()) throw new IOException("empty destination namespace in Tiny v1 header");
dstNamespaces.add(dstNamespace);
}

int dstNsCount = dstNamespaces.size();
if (dstNsCount == 0) throw new IOException("no destination namespaces in Tiny v1 header");

Set<MappingFlag> flags = visitor.getFlags();
MappingVisitor parentVisitor = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ private static void read(ColumnFileReader reader, MappingVisitor visitor) throws
List<String> dstNamespaces = new ArrayList<>();
String dstNamespace;

while ((dstNamespace = reader.nextCol()) != null) {
if (dstNamespace.isEmpty()) throw new IOException("empty destination namespace in Tiny v2 header");
while (!reader.isAtEol()) {
dstNamespace = reader.nextCol();
if (dstNamespace == null || dstNamespace.isEmpty()) throw new IOException("empty destination namespace in Tiny v2 header");
dstNamespaces.add(dstNamespace);
}

int dstNsCount = dstNamespaces.size();
if (dstNsCount == 0) throw new IOException("no destination namespaces in Tiny v2 header");
boolean readerMarked = false;

if (visitor.getFlags().contains(MappingFlag.NEEDS_MULTIPLE_PASSES)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void emptyTinyFile() throws Exception {
assertThrows(IOException.class, () -> Tiny1FileReader.read(new StringReader(header0), target));
assertThrows(IOException.class, () -> Tiny1FileReader.read(new StringReader(header1), target));
assertThrows(IOException.class, () -> Tiny1FileReader.read(new StringReader(header2), target));
assertThrows(IOException.class, () -> Tiny1FileReader.read(new StringReader(header3), target));
Tiny1FileReader.read(new StringReader(header3), target);
assertThrows(IOException.class, () -> Tiny1FileReader.read(new StringReader(header4), target));
Tiny1FileReader.read(new StringReader(header5), target);
}
Expand All @@ -80,7 +80,7 @@ public void emptyTinyV2File() throws Exception {
assertThrows(IOException.class, () -> Tiny2FileReader.read(new StringReader(header0), target));
assertThrows(IOException.class, () -> Tiny2FileReader.read(new StringReader(header1), target));
assertThrows(IOException.class, () -> Tiny2FileReader.read(new StringReader(header2), target));
assertThrows(IOException.class, () -> Tiny2FileReader.read(new StringReader(header3), target));
Tiny2FileReader.read(new StringReader(header3), target);
assertThrows(IOException.class, () -> Tiny2FileReader.read(new StringReader(header4), target));
Tiny2FileReader.read(new StringReader(header5), target);
}
Expand Down Expand Up @@ -113,7 +113,7 @@ public void emptyTsrgFile() throws Exception {
instantiateTree();
assertThrows(IOException.class, () -> TsrgFileReader.read(new StringReader(header1), target));
assertThrows(IOException.class, () -> TsrgFileReader.read(new StringReader(header2), target));
assertThrows(IOException.class, () -> TsrgFileReader.read(new StringReader(header3), target));
TsrgFileReader.read(new StringReader(header3), target);
assertThrows(IOException.class, () -> TsrgFileReader.read(new StringReader(header4), target));
TsrgFileReader.read(new StringReader(header5), target);
}
Expand Down