Skip to content

Commit 34fce64

Browse files
committed
fix class, method ordering
1 parent f5e58b7 commit 34fce64

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

core/src/main/java/org/bsc/java2typescript/TypescriptConverter.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@
99
import java.lang.reflect.Parameter;
1010
import java.lang.reflect.Type;
1111
import java.lang.reflect.TypeVariable;
12-
import java.util.Arrays;
13-
import java.util.Map;
14-
import java.util.Objects;
15-
import java.util.Optional;
12+
import java.util.*;
1613
import java.util.function.Consumer;
1714
import java.util.function.Function;
1815
import java.util.stream.Collectors;
@@ -97,7 +94,7 @@ public String processStatic(TSType type, java.util.Map<String, TSType> declaredT
9794

9895
if (!methodSet.isEmpty()) {
9996

100-
methodSet.stream().sorted((a, b) -> a.getName().compareTo(b.getName())).forEach(md -> ctx.append('\t')
97+
methodSet.stream().sorted(Comparator.comparing(Method::toGenericString)).forEach(md -> ctx.append('\t')
10198
.append(md.getName()).append(getMethodParametersAndReturnDecl(ctx, md, false)).append(ENDL));
10299
}
103100

processor/src/main/java/org/bsc/processor/TypescriptProcessor.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,15 @@ public boolean process(Context processingContext) throws Exception {
151151
types.stream()
152152
.filter(tt -> !PREDEFINED_TYPES.contains(tt))
153153
.map(tt -> converter.processClass(0, tt, declaredTypes))
154+
.sorted()
154155
.forEach(wD_append);
155156

156157
wT_append.accept(String.format("/// <reference path=\"%s\"/>\n\n", definitionsFile));
157158

158159
types.stream()
159160
.filter(t -> t.isExport())
160161
.map(t -> converter.processStatic(t, declaredTypes))
162+
.sorted()
161163
.forEach(wT_append);
162164

163165
} // end try-with-resources

0 commit comments

Comments
 (0)