Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2013 Edgar Espina This file is part of amd4j ( Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
package com.github.jknack.amd4j;
import static;
import static org.apache.commons.lang3.Validate.notNull;
An optimizer built on top of Google Closure Compiler.

public class ClosureMinifier extends Minifier {

The compilation level.
Creates a new ClosureMinifier.

compilationLevel The compilation level. Required.
  public ClosureMinifier(final CompilationLevel compilationLevel) {
    this. = notNull(compilationLevel"The compilationLevel is required.");
  public CharSequence minify(final Config configfinal CharSequence source) {
    final CompilerOptions options = new CompilerOptions();
    Compiler compiler = new Compiler();
    String fname = removeExtension(config.getName()) + ".js";
    Result result = compiler.compile(Collections.<SourceFileemptyList(),
        Arrays.asList(SourceFile.fromCode(fnamesource.toString())), options);
    if (result.success) {
      return compiler.toSource();
    JSError[] errors = result.errors;
    throw new IllegalStateException(errors[0].toString());
New to GrepCode? Check out our FAQ X