/
SourceFilePreprocessed.java
45 lines (34 loc) · 1.28 KB
/
SourceFilePreprocessed.java
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
39
40
41
42
43
44
45
package com.blamejared.crafttweaker.api.zencode.impl;
import com.blamejared.crafttweaker.api.zencode.IPreprocessor;
import com.blamejared.crafttweaker.api.zencode.PreprocessorMatch;
import org.openzen.zencode.shared.SourceFile;
import java.io.Reader;
import java.io.StringReader;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
public class SourceFilePreprocessed implements SourceFile {
private final String fileName;
private List<String> fileContent;
private final Map<IPreprocessor, List<PreprocessorMatch>> matches;
public SourceFilePreprocessed(String fileName, List<String> fileContent, Map<IPreprocessor, List<PreprocessorMatch>> matches) {
this.fileName = fileName;
this.fileContent = fileContent;
this.matches = matches;
}
@Override
public String getFilename() {
return fileName;
}
@Override
public Reader open() {
return new StringReader(String.join(System.lineSeparator(), fileContent) + System.lineSeparator());
}
@Override
public void update(String content) {
fileContent = Arrays.asList(content.split(System.lineSeparator()));
}
public Map<IPreprocessor, List<PreprocessorMatch>> getMatches() {
return matches;
}
}