| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package com.google.javascript.jscomp; |
| 18 |
|
| 19 |
|
| 20 |
import com.google.common.annotations.VisibleForTesting; |
| 21 |
import com.google.common.base.Charsets; |
| 22 |
|
| 23 |
import java.io.File; |
| 24 |
import java.io.IOException; |
| 25 |
import java.io.InputStream; |
| 26 |
import java.io.Serializable; |
| 27 |
import java.nio.charset.Charset; |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
@Deprecated |
| 40 |
public class JSSourceFile extends SourceFile implements Serializable { |
| 41 |
private static final long serialVersionUID = 1L; |
| 42 |
|
| 43 |
public static JSSourceFile fromFile(String fileName, Charset charSet) { |
| 44 |
return new JSSourceFile(SourceFile.fromFile(fileName, charSet)); |
| 45 |
} |
| 46 |
|
| 47 |
public static JSSourceFile fromFile(String fileName) { |
| 48 |
return new JSSourceFile(SourceFile.fromFile(fileName, Charsets.UTF_8)); |
| 49 |
} |
| 50 |
|
| 51 |
public static JSSourceFile fromFile(File file, Charset charSet) { |
| 52 |
return new JSSourceFile(SourceFile.fromFile(file, charSet)); |
| 53 |
} |
| 54 |
|
| 55 |
public static JSSourceFile fromFile(File file) { |
| 56 |
return new JSSourceFile(SourceFile.fromFile(file, Charsets.UTF_8)); |
| 57 |
} |
| 58 |
|
| 59 |
public static JSSourceFile fromCode(String fileName, String code) { |
| 60 |
return new JSSourceFile(SourceFile.fromCode(fileName, code)); |
| 61 |
} |
| 62 |
|
| 63 |
public static JSSourceFile fromInputStream(String fileName, InputStream s) |
| 64 |
throws IOException { |
| 65 |
return new JSSourceFile(SourceFile.fromInputStream(fileName, s)); |
| 66 |
} |
| 67 |
|
| 68 |
public static JSSourceFile fromGenerator(String fileName, |
| 69 |
Generator generator) { |
| 70 |
return new JSSourceFile(SourceFile.fromGenerator(fileName, generator)); |
| 71 |
} |
| 72 |
|
| 73 |
|
| 74 |
private SourceFile referenced; |
| 75 |
|
| 76 |
private JSSourceFile(SourceFile referenced) { |
| 77 |
super(referenced.getName()); |
| 78 |
this.referenced = referenced; |
| 79 |
} |
| 80 |
|
| 81 |
@Override |
| 82 |
public String getCode() throws IOException { |
| 83 |
return referenced.getCode(); |
| 84 |
} |
| 85 |
|
| 86 |
@Override |
| 87 |
public void clearCachedSource() { |
| 88 |
referenced.clearCachedSource(); |
| 89 |
} |
| 90 |
|
| 91 |
@Override |
| 92 |
@VisibleForTesting |
| 93 |
String getCodeNoCache() { |
| 94 |
return referenced.getCodeNoCache(); |
| 95 |
} |
| 96 |
} |