summaryrefslogtreecommitdiff
path: root/src/main/java/cuchaz/enigma/source/cfr/CfrSource.java
blob: d4f2da6a1a3e056b2c9de77356803a0f8a862c6b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package cuchaz.enigma.source.cfr;

import cuchaz.enigma.source.Source;
import cuchaz.enigma.source.SourceIndex;
import cuchaz.enigma.translation.mapping.EntryRemapper;
import org.benf.cfr.reader.entities.ClassFile;
import org.benf.cfr.reader.state.DCCommonState;
import org.benf.cfr.reader.state.TypeUsageInformation;

public class CfrSource implements Source {
    private final ClassFile tree;
    private final SourceIndex index;
    private final String string;

    public CfrSource(ClassFile tree, DCCommonState state, TypeUsageInformation typeUsages) {
        this.tree = tree;

        EnigmaDumper dumper = new EnigmaDumper(typeUsages);
        tree.dump(state.getObfuscationMapping().wrap(dumper));
        index = dumper.getIndex();
        string = dumper.getString();
    }

    @Override
    public String asString() {
        return string;
    }

    @Override
    public Source addJavadocs(EntryRemapper remapper) {
        return this; // TODO
    }

    @Override
    public SourceIndex index() {
        return index;
    }
}