本文整理汇总了Java中com.google.javascript.jscomp.ErrorManager类的典型用法代码示例。如果您正苦于以下问题:Java ErrorManager类的具体用法?Java ErrorManager怎么用?Java ErrorManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ErrorManager类属于com.google.javascript.jscomp包,在下文中一共展示了ErrorManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: JsFunctionParser
import com.google.javascript.jscomp.ErrorManager; //导入依赖的package包/类
/**
* Constructor
*
* @param functions Functions to parse.
* @param errorManager Handles parse errors.
*/
public JsFunctionParser(
Collection<String> functions, ErrorManager errorManager) {
super(errorManager);
functionsToParse = functions;
pattern = getPattern(functions);
matcher = pattern.matcher("");
}
示例2: DepsGenerator
import com.google.javascript.jscomp.ErrorManager; //导入依赖的package包/类
/**
* Creates a new DepsGenerator.
*/
public DepsGenerator(
Collection<SourceFile> deps,
Collection<SourceFile> srcs,
InclusionStrategy mergeStrategy,
String closurePathAbs,
ErrorManager errorManager) {
this.deps = deps;
this.srcs = srcs;
this.mergeStrategy = mergeStrategy;
this.closurePathAbs = closurePathAbs;
this.errorManager = errorManager;
}
示例3: DepsGenerator
import com.google.javascript.jscomp.ErrorManager; //导入依赖的package包/类
/**
* Creates a new DepsGenerator.
*/
public DepsGenerator(
Collection<SourceFile> deps,
Collection<SourceFile> srcs,
InclusionStrategy mergeStrategy,
String closurePathAbs,
ErrorManager errorManager,
ModuleLoader loader) {
this.deps = deps;
this.srcs = srcs;
this.mergeStrategy = mergeStrategy;
this.closurePathAbs = closurePathAbs;
this.errorManager = errorManager;
this.loader = loader;
}
示例4: parseRequires
import com.google.javascript.jscomp.ErrorManager; //导入依赖的package包/类
/** Parses a block of code for goog.require statements and extracts the required symbols. */
private static Collection<String> parseRequires(String code, boolean addClosureBase) {
ErrorManager errorManager = new LoggerErrorManager(logger);
JsFileParser parser = new JsFileParser(errorManager);
DependencyInfo deps =
parser.parseFile("<unknown path>", "<unknown path>", code);
List<String> requires = new ArrayList<>();
if (addClosureBase) {
requires.add(CLOSURE_BASE_PROVIDE);
}
requires.addAll(deps.getRequires());
errorManager.generateReport();
return requires;
}
示例5: TestParser
import com.google.javascript.jscomp.ErrorManager; //导入依赖的package包/类
TestParser(ErrorManager errorManager) {
super(errorManager);
}
示例6: DepsFileParser
import com.google.javascript.jscomp.ErrorManager; //导入依赖的package包/类
/**
* @param pathTranslator Translates paths in different build systems.
* @param errorManager Handles parse errors.
*/
public DepsFileParser(Function<String, String> pathTranslator,
ErrorManager errorManager) {
super(errorManager);
this.pathTranslator = pathTranslator;
}
示例7: JsFileParser
import com.google.javascript.jscomp.ErrorManager; //导入依赖的package包/类
public JsFileParser(ErrorManager errorManager) {
}
示例8: loadGraph
import com.google.javascript.jscomp.ErrorManager; //导入依赖的package包/类
/** Loads the dependency graph. */
private void loadGraph() throws ServiceException {
dependencies.clear();
logger.info("Loading dependency graph");
// Parse the deps.js file.
ErrorManager errorManager = new LoggerErrorManager(logger);
DepsFileParser parser =
new DepsFileParser(errorManager);
List<DependencyInfo> depInfos =
parser.parseFile(getName(), getContent());
// Ensure the parse succeeded.
if (!parser.didParseSucceed()) {
throw new ServiceException("Problem parsing " + getName()
+ ". See logs for details.");
}
// Incorporate the dependencies into our maps.
for (DependencyInfo depInfo : depInfos) {
for (String provide : depInfo.getProvides()) {
DependencyInfo existing = dependencies.get(provide);
if (existing != null && !existing.equals(depInfo)) {
throw new ServiceException("Duplicate provide of " + provide
+ ". Was provided by " + existing.getPathRelativeToClosureBase()
+ " and " + depInfo.getPathRelativeToClosureBase());
}
dependencies.put(provide, depInfo);
}
}
List<String> provides = new ArrayList<>();
provides.add(CLOSURE_BASE_PROVIDE);
// Add implicit base.js entry.
dependencies.put(
CLOSURE_BASE_PROVIDE,
SimpleDependencyInfo.builder(CLOSURE_BASE, CLOSURE_BASE).setProvides(provides).build());
errorManager.generateReport();
logger.info("Dependencies loaded");
}
示例9: doMain
import com.google.javascript.jscomp.ErrorManager; //导入依赖的package包/类
private void doMain(String[] args) throws Exception {
CmdLineParser parser = new CmdLineParser(this);
parser.parseArgument(args);
if (args.length < 1 || displayHelp) {
CmdLineParser p = new CmdLineParser(this);
p.printUsage(System.out);
return;
}
checkArgument(
!Strings.isNullOrEmpty(refasterJsTemplate), "--refasterjs_template must be provided");
List<String> fileInputs = getInputs();
checkArgument(
!fileInputs.isEmpty(), "At least one input must be provided in the --inputs flag.");
for (String input : fileInputs) {
Preconditions.checkArgument(
new File(input).exists(), "Input file %s does not exist.", input);
}
if (!verbose) {
// This is done here instead of using the Compiler#setLoggingLevel function since the
// Compiler is created and then run inside of RefactoringDriver.
Logger errorManagerLogger = Logger.getLogger("com.google.javascript.jscomp");
errorManagerLogger.setLevel(Level.OFF);
}
RefasterJsScanner scanner = new RefasterJsScanner();
scanner.setTypeMatchingStrategy(typeMatchingStrategy);
scanner.loadRefasterJsTemplate(refasterJsTemplate);
CompilerOptions options = new CompilerOptions();
options.setEnvironment(environment);
RefactoringDriver driver =
new RefactoringDriver.Builder()
.addExterns(CommandLineRunner.getBuiltinExterns(environment))
.addExternsFromFile(getExterns())
.addInputsFromFile(fileInputs)
.build();
System.out.println("Compiling JavaScript code and searching for suggested fixes.");
// TODO(bangert): allow picking a non-default choice in RefasterJS, e.g. via a switch.
List<SuggestedFix> fixes = driver.drive(scanner);
if (!verbose) {
// When running in quiet mode, the Compiler's error manager will not have printed
// this information itself.
ErrorManager errorManager = driver.getCompiler().getErrorManager();
System.out.println("Compiler results: " + errorManager.getErrorCount()
+ " errors and " + errorManager.getWarningCount() + " warnings.");
}
System.out.println("Found " + fixes.size() + " suggested fixes.");
if (dryRun) {
if (!fixes.isEmpty()) {
System.out.println("SuggestedFixes: " + fixes);
}
} else {
Set<String> affectedFiles = new TreeSet<>();
for (SuggestedFix fix : fixes) {
affectedFiles.addAll(fix.getReplacements().keySet());
}
System.out.println("Modifying affected files: " + affectedFiles);
ApplySuggestedFixes.applySuggestedFixesToFiles(fixes);
}
}
示例10: parseString
import com.google.javascript.jscomp.ErrorManager; //导入依赖的package包/类
/**
* Takes a source string and returns a google closure compiler. The caller must do the error checking and act
* accordingly.
*/
private static Compiler parseString(String sourceString) {
Compiler compiler = new Compiler();
ErrorManager em = new ErrorManager() {
private int numErrs = 0;
private JSError err;
@Override
public void report(CheckLevel checkLevel, JSError jsError) {
if (checkLevel.compareTo(CheckLevel.ERROR) == 0) {
numErrs++;
err = jsError;
}
}
@Override
public void generateReport() { }
@Override
public int getErrorCount() { return numErrs; }
@Override
public int getWarningCount() { return 0; }
@Override
public JSError[] getErrors() {
// Useful for debugging and doesn't cost anything to have in here.
JSError[] tmp = new JSError[1];
tmp[0] = err;
return tmp;
}
@Override
public JSError[] getWarnings() { return new JSError[0]; }
@Override
public void setTypedPercent(double v) { }
@Override
public double getTypedPercent() { return 0; }
};
compiler.setErrorManager(em);
CompilerOptions options = new CompilerOptions();
// Try very hard to interpret the meaning of our code string.
options.setIdeMode(true);
options.setOutputCharset("UTF-8");
// We only care about the AST, and that is gotten through "compiling" whitespace mode only.
CompilationLevel.WHITESPACE_ONLY.setOptionsForCompilationLevel(options);
JSSourceFile dummy = JSSourceFile.fromCode("dummy.js", "");
compiler.compile(dummy, JSSourceFile.fromCode("input.js", sourceString), options);
return compiler;
}
示例11: processClosureSources
import com.google.javascript.jscomp.ErrorManager; //导入依赖的package包/类
private static ImmutableSet<Path> processClosureSources(
Collection<Path> sources, ImmutableSet<Path> deps, Path closureBase) throws IOException {
Collection<SourceFile> depsFiles = deps.stream().map(toSourceFile()).collect(toList());
Collection<SourceFile> sourceFiles = sources.stream().map(toSourceFile()).collect(toList());
ErrorManager errorManager = new PrintStreamErrorManager(System.err);
DepsGenerator generator =
new DepsGenerator(
depsFiles,
sourceFiles,
DepsGenerator.InclusionStrategy.ALWAYS,
closureBase.toAbsolutePath().toString(),
errorManager,
ModuleLoader.EMPTY);
String rawDeps = generator.computeDependencyCalls();
errorManager.generateReport();
if (rawDeps == null) {
throw new RuntimeException("Encountered Closure dependency conflicts");
}
List<DependencyInfo> allDeps =
new DepsFileParser(errorManager).parseFile("*generated-deps*", rawDeps);
List<DependencyInfo> sourceDeps =
allDeps.stream().filter(isInSources(sources, closureBase)).collect(toList());
List<Path> sortedDeps =
new ClosureSortedDependencies<>(allDeps)
.getDependenciesOf(sourceDeps, true)
.stream()
.map(toPath(closureBase))
.collect(toList());
return ImmutableSet.<Path>builder()
// Always include Closure's base.js first.
.add(closureBase.resolve("base.js"))
.addAll(sortedDeps)
.build();
}
示例12: main
import com.google.javascript.jscomp.ErrorManager; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
Flags flags = new Flags();
CmdLineParser parser = new CmdLineParser(flags);
parser.setUsageWidth(79);
parser.parseArgument(args);
FileSystem fs = FileSystems.getDefault();
final Path closure = fs.getPath(flags.closure).toAbsolutePath();
ErrorManager errorManager = new PrintStreamErrorManager(System.err);
JsFileParser jsFileParser = new JsFileParser(errorManager);
List<DependencyInfo> info = new ArrayList<>(flags.inputs.size());
for (String path : flags.inputs) {
Path absPath = fs.getPath(path).toAbsolutePath();
Path closureRelativePath = closure.relativize(absPath);
info.add(
jsFileParser.parseFile(
absPath.toString(),
closureRelativePath.toString(),
new String(Files.readAllBytes(absPath), UTF_8)));
}
List<DependencyInfo> allDeps = new LinkedList<>(info);
allDeps.addAll(
new DepsFileParser(errorManager).parseFile(closure.resolve("deps.js").toString()));
List<String> compilerFlags =
new ClosureSortedDependencies<>(allDeps)
.getSortedDependenciesOf(info)
.stream()
.map(input -> closure.resolve(input.getPathRelativeToClosureBase()))
.map(Path::toAbsolutePath)
.map(Path::normalize)
.map(path -> "--js=" + path)
.collect(toList());
compilerFlags.add("--js=" + closure.resolve("base.js"));
compilerFlags.addAll(flags.flags);
CommandLineRunner.main(compilerFlags.toArray(new String[compilerFlags.size()]));
}
示例13: DepsFileParser
import com.google.javascript.jscomp.ErrorManager; //导入依赖的package包/类
/**
* Constructor
*
* @param errorManager Handles parse errors.
*/
public DepsFileParser(ErrorManager errorManager) {
super(errorManager);
}
示例14: JsFileLineParser
import com.google.javascript.jscomp.ErrorManager; //导入依赖的package包/类
/**
* Constructor.
*
* @param errorManager Parse error handler.
*/
public JsFileLineParser(ErrorManager errorManager) {
this.errorManager = errorManager;
}
示例15: JsFileParser
import com.google.javascript.jscomp.ErrorManager; //导入依赖的package包/类
/**
* Constructor
*
* @param errorManager Handles parse errors.
*/
public JsFileParser(ErrorManager errorManager) {
super(errorManager);
}