org.tizen.web.jslint_2.0.0.201311011708

16:50:41.788 INFO  jd.cli.Main - Decompiling org.tizen.web.jslint_2.0.0.201311011708.jar
package org.tizen.web.jslint;

import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
import org.tizen.web.jslint.engine.Option;

public class Activator
  extends AbstractUIPlugin
{
  public static final String PLUGIN_ID = "org.tizen.web.jslint";
  private static Activator plugin;
  
  public void start(BundleContext context)
    throws Exception
  {
    super.start(context);
    plugin = this;
    setInitialPreferences();
  }
  
  private void setInitialPreferences()
  {
    IPreferenceStore jsLintStore = getDefault().getPreferenceStore();
    
    jsLintStore.setDefault(Option.SEMIREQ.getLowerName(), true);
    Option[] arrayOfOption;
    int j = (arrayOfOption = Option.values()).length;
    for (int i = 0; i < j; i++)
    {
      Option o = arrayOfOption[i];
      if (!o.isStricter()) {
        jsLintStore.setDefault(o.getLowerName(), true);
      }
    }
    jsLintStore.setDefault(Option.INDENT.getLowerName(), 4);
    jsLintStore.setDefault(Option.MAXERR.getLowerName(), 500);
    jsLintStore.setDefault(Option.MAXLEN.getLowerName(), 0);
    jsLintStore.setDefault(Option.PREDEF.getLowerName(), "");
    
    jsLintStore.setDefault("org.tizen.web.jslint.exclude", "min, jquery, jqm-docs, phonegap, sencha, plugins, qunit, RGraph, coderdeck, tizen-web-ui-fw, globalize, coderdeck, modernizr");
  }
  
  public void stop(BundleContext context)
    throws Exception
  {
    plugin = null;
    super.stop(context);
  }
  
  public static Activator getDefault()
  {
    return plugin;
  }
  
  public static ImageDescriptor getImageDescriptor(String path)
  {
    return imageDescriptorFromPlugin("org.tizen.web.jslint", path);
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.jslint.Activator
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.jslint;

public class PreferenceConstants
{
  public static final String DEFAULT_EXCLUDE_FILES = "min, jquery, jqm-docs, phonegap, sencha, plugins, qunit, RGraph, coderdeck, tizen-web-ui-fw, globalize, coderdeck, modernizr";
  public static final String EXCLUDE = "org.tizen.web.jslint.exclude";
}

/* Location:
 * Qualified Name:     org.tizen.web.jslint.PreferenceConstants
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.jslint.engine;

abstract interface ConverterUtil$Converter<T>
{
  public abstract T convert(Object paramObject);
}

/* Location:
 * Qualified Name:     org.tizen.web.jslint.engine.ConverterUtil.Converter
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.jslint.engine;

import org.mozilla.javascript.Scriptable;

final class ConverterUtil$IdentifierConverter
  implements ConverterUtil.Converter<JSIdentifier>
{
  public JSIdentifier convert(Object obj)
  {
    Scriptable identifier = (Scriptable)obj;
    String name = Util.stringValue("name", identifier);
    int line = Util.intValue("line", identifier);
    return new JSIdentifier(name, line);
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.jslint.engine.ConverterUtil.IdentifierConverter
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.jslint.engine;

import org.mozilla.javascript.Scriptable;

final class ConverterUtil$JSFunctionConverter
  implements ConverterUtil.Converter<JSFunction>
{
  public JSFunction convert(Object obj)
  {
    Scriptable scope = (Scriptable)obj;
    String name = Util.stringValue("name", scope);
    int line = Util.intValue("line", scope);
    JSFunction.Builder b = new JSFunction.Builder(name, line);
    for (String param : Util.listValues("param", scope)) {
      b.addParam(param);
    }
    for (String closure : Util.listValues("closure", scope)) {
      b.addClosure(closure);
    }
    for (String var : Util.listValues("var", scope)) {
      b.addVar(var);
    }
    for (String exception : Util.listValues("exception", scope)) {
      b.addException(exception);
    }
    for (String outer : Util.listValues("outer", scope)) {
      b.addOuter(outer);
    }
    for (String unused : Util.listValues("unused", scope)) {
      b.addUnused(unused);
    }
    for (String global : Util.listValues("global", scope)) {
      b.addGlobal(global);
    }
    for (String label : Util.listValues("label", scope)) {
      b.addLabel(label);
    }
    return b.build();
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.jslint.engine.ConverterUtil.JSFunctionConverter
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.jslint.engine;

import org.mozilla.javascript.Scriptable;

public class ConverterUtil
{
  static abstract interface Converter<T>
  {
    public abstract T convert(Object paramObject);
  }
  
  static final class IdentifierConverter
    implements ConverterUtil.Converter<JSIdentifier>
  {
    public JSIdentifier convert(Object obj)
    {
      Scriptable identifier = (Scriptable)obj;
      String name = Util.stringValue("name", identifier);
      int line = Util.intValue("line", identifier);
      return new JSIdentifier(name, line);
    }
  }
  
  static final class JSFunctionConverter
    implements ConverterUtil.Converter<JSFunction>
  {
    public JSFunction convert(Object obj)
    {
      Scriptable scope = (Scriptable)obj;
      String name = Util.stringValue("name", scope);
      int line = Util.intValue("line", scope);
      JSFunction.Builder b = new JSFunction.Builder(name, line);
      for (String param : Util.listValues("param", scope)) {
        b.addParam(param);
      }
      for (String closure : Util.listValues("closure", scope)) {
        b.addClosure(closure);
      }
      for (String var : Util.listValues("var", scope)) {
        b.addVar(var);
      }
      for (String exception : Util.listValues("exception", scope)) {
        b.addException(exception);
      }
      for (String outer : Util.listValues("outer", scope)) {
        b.addOuter(outer);
      }
      for (String unused : Util.listValues("unused", scope)) {
        b.addUnused(unused);
      }
      for (String global : Util.listValues("global", scope)) {
        b.addGlobal(global);
      }
      for (String label : Util.listValues("label", scope)) {
        b.addLabel(label);
      }
      return b.build();
    }
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.jslint.engine.ConverterUtil
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.jslint.engine;

public enum Issue$ErrorType
{
  WARNING,  ERROR;
}

/* Location:
 * Qualified Name:     org.tizen.web.jslint.engine.Issue.ErrorType
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.jslint.engine;

import org.mozilla.javascript.Scriptable;

public class Issue
{
  private final int line;
  private final int character;
  private final String reason;
  private final String raw;
  private final String evidence;
  
  public static enum ErrorType
  {
    WARNING,  ERROR;
  }
  
  private ErrorType error = ErrorType.WARNING;
  
  public Issue(Scriptable err)
  {
    int line = Util.intValue("line", err);
    if (line <= 0) {
      line = 1;
    }
    this.line = line;
    
    int col = Util.intValue("character", err);
    if (col == 0) {
      col = 1;
    }
    character = col;
    
    reason = Util.stringValue("reason", err);
    evidence = Util.stringValue("evidence", err);
    raw = Util.stringValue("raw", err);
  }
  
  public int getCharacter()
  {
    return character;
  }
  
  public String getEvidence()
  {
    return evidence;
  }
  
  public int getLine()
  {
    return line;
  }
  
  public String getRaw()
  {
    return raw;
  }
  
  public String getReason()
  {
    return reason;
  }
  
  public ErrorType getError()
  {
    return error;
  }
  
  public void setError(ErrorType error)
  {
    this.error = error;
  }
  
  public String toString()
  {
    return "Issue : line : " + getLine() + " : " + getCharacter() + ":" + getReason() + " : " + getRaw() + ":" + getError().toString();
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.jslint.engine.Issue
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.jslint.engine;

import java.util.ArrayList;
import java.util.List;

public class JSFunction$Builder
{
  private final List<String> closures = new ArrayList();
  private final List<String> exceptions = new ArrayList();
  private final List<String> globals = new ArrayList();
  private final List<String> labels = new ArrayList();
  private final int line;
  private final String name;
  private final List<String> outers = new ArrayList();
  private final List<String> params = new ArrayList();
  private final List<String> unuseds = new ArrayList();
  private final List<String> vars = new ArrayList();
  
  public JSFunction$Builder(String name, int line)
  {
    this.name = name;
    this.line = line;
  }
  
  public Builder addClosure(String closure)
  {
    closures.add(closure);
    return this;
  }
  
  public Builder addException(String exception)
  {
    exceptions.add(exception);
    return this;
  }
  
  public Builder addGlobal(String global)
  {
    globals.add(global);
    return this;
  }
  
  public Builder addLabel(String label)
  {
    labels.add(label);
    return this;
  }
  
  public Builder addOuter(String outer)
  {
    outers.add(outer);
    return this;
  }
  
  public Builder addParam(String param)
  {
    params.add(param);
    return this;
  }
  
  public Builder addUnused(String unused)
  {
    unuseds.add(unused);
    return this;
  }
  
  public Builder addVar(String var)
  {
    vars.add(var);
    return this;
  }
  
  public JSFunction build()
  {
    return new JSFunction(this, null);
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.jslint.engine.JSFunction.Builder
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.jslint.engine;

import java.util.ArrayList;
import java.util.List;

public class JSFunction
{
  public static class Builder
  {
    private final List<String> closures = new ArrayList();
    private final List<String> exceptions = new ArrayList();
    private final List<String> globals = new ArrayList();
    private final List<String> labels = new ArrayList();
    private final int line;
    private final String name;
    private final List<String> outers = new ArrayList();
    private final List<String> params = new ArrayList();
    private final List<String> unuseds = new ArrayList();
    private final List<String> vars = new ArrayList();
    
    public Builder(String name, int line)
    {
      this.name = name;
      this.line = line;
    }
    
    public Builder addClosure(String closure)
    {
      closures.add(closure);
      return this;
    }
    
    public Builder addException(String exception)
    {
      exceptions.add(exception);
      return this;
    }
    
    public Builder addGlobal(String global)
    {
      globals.add(global);
      return this;
    }
    
    public Builder addLabel(String label)
    {
      labels.add(label);
      return this;
    }
    
    public Builder addOuter(String outer)
    {
      outers.add(outer);
      return this;
    }
    
    public Builder addParam(String param)
    {
      params.add(param);
      return this;
    }
    
    public Builder addUnused(String unused)
    {
      unuseds.add(unused);
      return this;
    }
    
    public Builder addVar(String var)
    {
      vars.add(var);
      return this;
    }
    
    public JSFunction build()
    {
      return new JSFunction(this, null);
    }
  }
  
  private final List<String> closure = new ArrayList();
  private final List<String> exception = new ArrayList();
  private final List<String> global = new ArrayList();
  private final List<String> label = new ArrayList();
  private final int line;
  private final String name;
  private final List<String> outer = new ArrayList();
  private final List<String> params = new ArrayList();
  private final List<String> unused = new ArrayList();
  private final List<String> vars = new ArrayList();
  
  private JSFunction(Builder builder)
  {
    name = name;
    line = line;
    closure.addAll(closures);
    exception.addAll(exceptions);
    global.addAll(globals);
    label.addAll(labels);
    outer.addAll(outers);
    params.addAll(params);
    unused.addAll(unuseds);
    vars.addAll(vars);
  }
  
  public List<String> getClosure()
  {
    return closure;
  }
  
  public List<String> getException()
  {
    return exception;
  }
  
  public List<String> getGlobal()
  {
    return global;
  }
  
  public List<String> getLabel()
  {
    return label;
  }
  
  public int getLine()
  {
    return line;
  }
  
  public String getName()
  {
    return name;
  }
  
  public List<String> getOuter()
  {
    return outer;
  }
  
  public List<String> getParams()
  {
    return params;
  }
  
  public List<String> getUnused()
  {
    return unused;
  }
  
  public List<String> getVars()
  {
    return vars;
  }
  
  public String toString()
  {
    return String.format("function %s()", new Object[] { getName() });
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.jslint.engine.JSFunction
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.jslint.engine;

public class JSIdentifier
{
  private final int line;
  private final String name;
  
  public JSIdentifier(String name, int line)
  {
    this.name = name;
    this.line = line;
  }
  
  public int getLine()
  {
    return line;
  }
  
  public String getName()
  {
    return name;
  }
  
  public String toString()
  {
    return name + "@" + line;
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.jslint.engine.JSIdentifier
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.jslint.engine;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.ContextFactory;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.ScriptableObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class JSLint
{
  protected final Logger logger = LoggerFactory.getLogger(getClass());
  private static final String JSLINT_FILE = "resources/fulljslint.js";
  private static final String JSLINT_QUIT_TOO_MANY_ERRORS = "Too many errors.";
  private Scriptable scope;
  
  public static JSLint getInstance()
  {
    return new JSLint();
  }
  
  private Map<String, String> options = new HashMap();
  
  public JSLint()
  {
    try
    {
      ContextFactory contextFactory = new ContextFactory();
      Context context = contextFactory.enterContext();
      ScriptableObject contextScope = context.initStandardObjects();
      Reader reader = new BufferedReader(new InputStreamReader(JSLint.class.getClassLoader().getResourceAsStream("resources/fulljslint.js")));
      context.evaluateReader(contextScope, reader, "resources/fulljslint.js", 1, null);
      
      scope = contextScope;
    }
    catch (IOException e)
    {
      e.printStackTrace();
    }
  }
  
  public void setOption(Option opt)
  {
    options.put(opt.getLowerName(), "true");
  }
  
  public void setOption(Option opt, String str)
  {
    options.put(opt.getLowerName(), str);
  }
  
  public void resetOption()
  {
    options.clear();
  }
  
  /* Error */
  public JSLintResult lint(java.io.InputStream inputStream)
    throws IOException
  {
    // Byte code:
    //   0: aconst_null
    //   1: astore_2
    //   2: new 61	java/io/BufferedReader
    //   5: dup
    //   6: new 63	java/io/InputStreamReader
    //   9: dup
    //   10: aload_1
    //   11: invokespecial 77	java/io/InputStreamReader:<init>	(Ljava/io/InputStream;)V
    //   14: invokespecial 80	java/io/BufferedReader:<init>	(Ljava/io/Reader;)V
    //   17: astore_2
    //   18: aload_2
    //   19: invokestatic 134	org/tizen/common/util/StringUtil:asString	(Ljava/io/Reader;)Ljava/lang/String;
    //   22: astore_3
    //   23: iconst_2
    //   24: anewarray 3	java/lang/Object
    //   27: dup
    //   28: iconst_0
    //   29: aload_3
    //   30: aastore
    //   31: dup
    //   32: iconst_1
    //   33: aload_0
    //   34: invokespecial 140	org/tizen/web/jslint/engine/JSLint:optionsAsJavaScriptObject	()Lorg/mozilla/javascript/Scriptable;
    //   37: aastore
    //   38: astore 4
    //   40: aload_0
    //   41: getfield 87	org/tizen/web/jslint/engine/JSLint:scope	Lorg/mozilla/javascript/Scriptable;
    //   44: ldc -112
    //   46: aload_0
    //   47: getfield 87	org/tizen/web/jslint/engine/JSLint:scope	Lorg/mozilla/javascript/Scriptable;
    //   50: invokeinterface 146 3 0
    //   55: checkcast 152	org/mozilla/javascript/Function
    //   58: astore 5
    //   60: aload 5
    //   62: invokestatic 154	org/mozilla/javascript/Context:getCurrentContext	()Lorg/mozilla/javascript/Context;
    //   65: aload_0
    //   66: getfield 87	org/tizen/web/jslint/engine/JSLint:scope	Lorg/mozilla/javascript/Scriptable;
    //   69: aload_0
    //   70: getfield 87	org/tizen/web/jslint/engine/JSLint:scope	Lorg/mozilla/javascript/Scriptable;
    //   73: aload 4
    //   75: invokeinterface 157 5 0
    //   80: pop
    //   81: goto +16 -> 97
    //   84: astore 6
    //   86: aload_2
    //   87: ifnull +7 -> 94
    //   90: aload_2
    //   91: invokevirtual 161	java/io/BufferedReader:close	()V
    //   94: aload 6
    //   96: athrow
    //   97: aload_2
    //   98: ifnull +7 -> 105
    //   101: aload_2
    //   102: invokevirtual 161	java/io/BufferedReader:close	()V
    //   105: new 164	org/tizen/web/jslint/engine/JSLintResult$ResultBuilder
    //   108: dup
    //   109: invokespecial 166	org/tizen/web/jslint/engine/JSLintResult$ResultBuilder:<init>	()V
    //   112: astore_3
    //   113: aload_0
    //   114: invokespecial 167	org/tizen/web/jslint/engine/JSLint:readErrors	()Ljava/util/List;
    //   117: invokeinterface 171 1 0
    //   122: astore 5
    //   124: goto +22 -> 146
    //   127: aload 5
    //   129: invokeinterface 177 1 0
    //   134: checkcast 183	org/tizen/web/jslint/engine/Issue
    //   137: astore 4
    //   139: aload_3
    //   140: aload 4
    //   142: invokevirtual 185	org/tizen/web/jslint/engine/JSLintResult$ResultBuilder:addIssue	(Lorg/tizen/web/jslint/engine/Issue;)Lorg/tizen/web/jslint/engine/JSLintResult$ResultBuilder;
    //   145: pop
    //   146: aload 5
    //   148: invokeinterface 189 1 0
    //   153: ifne -26 -> 127
    //   156: aload_3
    //   157: invokevirtual 193	org/tizen/web/jslint/engine/JSLintResult$ResultBuilder:build	()Lorg/tizen/web/jslint/engine/JSLintResult;
    //   160: areturn
    // Line number table:
    //   Java source line #101	-> byte code offset #0
    //   Java source line #103	-> byte code offset #2
    //   Java source line #104	-> byte code offset #18
    //   Java source line #106	-> byte code offset #23
    //   Java source line #107	-> byte code offset #40
    //   Java source line #108	-> byte code offset #60
    //   Java source line #109	-> byte code offset #84
    //   Java source line #110	-> byte code offset #86
    //   Java source line #111	-> byte code offset #90
    //   Java source line #113	-> byte code offset #94
    //   Java source line #110	-> byte code offset #97
    //   Java source line #111	-> byte code offset #101
    //   Java source line #115	-> byte code offset #105
    //   Java source line #116	-> byte code offset #113
    //   Java source line #117	-> byte code offset #139
    //   Java source line #116	-> byte code offset #146
    //   Java source line #120	-> byte code offset #156
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	161	0	this	JSLint
    //   0	161	1	inputStream	java.io.InputStream
    //   1	101	2	reader	BufferedReader
    //   22	8	3	content	String
    //   112	45	3	builder	JSLintResult.ResultBuilder
    //   38	36	4	args	Object[]
    //   137	4	4	issue	Issue
    //   58	89	5	lintFunction	org.mozilla.javascript.Function
    //   84	11	6	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   2	84	84	finally
  }
  
  private Scriptable optionsAsJavaScriptObject()
  {
    Context context = Context.getCurrentContext();
    Scriptable opts = context.newObject(scope);
    for (Map.Entry<String, String> entry : options.entrySet())
    {
      String key = (String)entry.getKey();
      Object value = Context.javaToJS(entry.getValue(), opts);
      opts.put(key, opts, value);
    }
    return opts;
  }
  
  private List<Issue> readErrors()
  {
    ArrayList<Issue> issues = new ArrayList();
    Scriptable JSLINT = (Scriptable)scope.get("JSLINT", scope);
    Scriptable errors = (Scriptable)JSLINT.get("errors", JSLINT);
    int count = Util.intValue("length", errors);
    try
    {
      for (int i = 0; i < count; i++)
      {
        Scriptable err = (Scriptable)errors.get(i, errors);
        if (err != null)
        {
          Issue issue = new Issue(err);
          issues.add(issue);
        }
        else
        {
          Issue errorIssue = (Issue)issues.get(i - 1);
          errorIssue.setError(Issue.ErrorType.ERROR);
          if (errorIssue.getReason().startsWith("Too many errors.")) {
            logger.warn("warnings >= option.maxerr, so (i - 2) is not an error message but a normal warning");
          } else {
            ((Issue)issues.get(i - 2)).setError(Issue.ErrorType.ERROR);
          }
        }
      }
    }
    catch (Throwable t)
    {
      logger.error("Error occured", t);
    }
    return issues;
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.jslint.engine.JSLint
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.jslint.engine;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class JSLintResult$ResultBuilder
{
  private final List<JSFunction> functions = new ArrayList();
  private final List<String> globals = new ArrayList();
  private final List<JSIdentifier> implieds = new ArrayList();
  private final List<Issue> issues = new ArrayList();
  private final Map<String, Integer> member = new HashMap();
  private String report;
  private final List<JSIdentifier> unused = new ArrayList();
  private final List<String> urls = new ArrayList();
  
  public ResultBuilder addFunction(JSFunction f)
  {
    functions.add(f);
    return this;
  }
  
  public ResultBuilder addGlobal(String global)
  {
    globals.add(global);
    return this;
  }
  
  public ResultBuilder addImplied(JSIdentifier id)
  {
    implieds.add(id);
    return this;
  }
  
  public ResultBuilder addIssue(Issue issue)
  {
    issues.add(issue);
    return this;
  }
  
  public ResultBuilder addMember(String name, int count)
  {
    member.put(name, Integer.valueOf(count));
    return this;
  }
  
  public ResultBuilder addUnused(JSIdentifier id)
  {
    unused.add(id);
    return this;
  }
  
  public ResultBuilder addUrl(String url)
  {
    urls.add(url);
    return this;
  }
  
  public JSLintResult build()
  {
    return new JSLintResult(this, null);
  }
  
  public ResultBuilder report(String report)
  {
    this.report = report;
    return this;
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.jslint.engine.JSLintResult.ResultBuilder
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.jslint.engine;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class JSLintResult
{
  public static class ResultBuilder
  {
    private final List<JSFunction> functions = new ArrayList();
    private final List<String> globals = new ArrayList();
    private final List<JSIdentifier> implieds = new ArrayList();
    private final List<Issue> issues = new ArrayList();
    private final Map<String, Integer> member = new HashMap();
    private String report;
    private final List<JSIdentifier> unused = new ArrayList();
    private final List<String> urls = new ArrayList();
    
    public ResultBuilder addFunction(JSFunction f)
    {
      functions.add(f);
      return this;
    }
    
    public ResultBuilder addGlobal(String global)
    {
      globals.add(global);
      return this;
    }
    
    public ResultBuilder addImplied(JSIdentifier id)
    {
      implieds.add(id);
      return this;
    }
    
    public ResultBuilder addIssue(Issue issue)
    {
      issues.add(issue);
      return this;
    }
    
    public ResultBuilder addMember(String name, int count)
    {
      member.put(name, Integer.valueOf(count));
      return this;
    }
    
    public ResultBuilder addUnused(JSIdentifier id)
    {
      unused.add(id);
      return this;
    }
    
    public ResultBuilder addUrl(String url)
    {
      urls.add(url);
      return this;
    }
    
    public JSLintResult build()
    {
      return new JSLintResult(this, null);
    }
    
    public ResultBuilder report(String report)
    {
      this.report = report;
      return this;
    }
  }
  
  private final List<JSFunction> functions = new ArrayList();
  private final List<String> globals = new ArrayList();
  private final List<JSIdentifier> implieds = new ArrayList();
  private final List<Issue> issues = new ArrayList();
  private final Map<String, Integer> member = new HashMap();
  private final String report;
  private final List<JSIdentifier> unused = new ArrayList();
  private final List<String> urls = new ArrayList();
  
  private JSLintResult(ResultBuilder b)
  {
    issues.addAll(issues);
    functions.addAll(functions);
    globals.addAll(globals);
    implieds.addAll(implieds);
    member.putAll(member);
    report = report;
    unused.addAll(unused);
    urls.addAll(urls);
  }
  
  public List<JSFunction> getFunctions()
  {
    return functions;
  }
  
  public List<String> getGlobals()
  {
    return globals;
  }
  
  public List<JSIdentifier> getImplieds()
  {
    return implieds;
  }
  
  public List<Issue> getIssues()
  {
    return issues;
  }
  
  public Map<String, Integer> getMember()
  {
    return member;
  }
  
  public String getReport()
  {
    return report;
  }
  
  public List<JSIdentifier> getUnused()
  {
    return unused;
  }
  
  public List<String> getUrls()
  {
    return urls;
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.jslint.engine.JSLintResult
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.jslint.engine;

import java.util.List;
import java.util.Locale;

public enum Option
{
  ADSAFE(
  
    "If adsafe should be enforced", Boolean.class, true),  BITWISE(
    "If bitwise operators should not be allowed", Boolean.class, true),  BROWSER(
    "If the standard browser globals should be predefined", Boolean.class, false),  CAP(
    "If upper case html should be allowed", Boolean.class, false),  CONTINUE(
    "If continue should be tolerated", Boolean.class, false),  CSS(
    "If css workarounds should be tolerated", Boolean.class, false),  DEBUG(
    "If debugger statements should be allowed", Boolean.class, false),  DEVEL(
    "If logging should be allowed (console, alert, etc.)", Boolean.class, false),  EQEQEQ(
    "If === should be required", Boolean.class, true),  ES5(
    "If es5 syntax should be allowed", Boolean.class, false),  EVIL(
    "If eval should be allowed", Boolean.class, false),  FORIN(
    "Tolerate unfiltered forin", Boolean.class, false),  FRAGMENT(
    "If html fragments should be allowed", Boolean.class, false),  INDENT(
    "The number of spaces used for indentation (default is 4)", Integer.class),  MAXERR(
    "The maximum number of warnings reported (default is 500)", Integer.class),  MAXLEN(
    "Maximum line length", Integer.class),  NEEDCURLY(
    "If block { ... } is required with for and while statements", Boolean.class, true),  NEWCAP(
    "If constructor names must be capitalized", Boolean.class, true),  NOMEN(
    "If names should be checked", Boolean.class, true),  NONEW(
    "if using `new` for side-effects should be disallowed", Boolean.class, true),  ON(
    "If html event handlers should be allowed", Boolean.class, false),  ONEVAR(
    "If only one var statement per function should be allowed", Boolean.class, true),  PASSFAIL(
    "If the scan should stop on first error", Boolean.class, true),  PLUSPLUS(
    "If increment/decrement should not be allowed", Boolean.class, true),  PREDEF(
    "The names of predefined global variables.", String.class),  REGEXP(
    "If the . should not be allowed in regexp literals", Boolean.class, true),  RHINO(
    "If the rhino environment globals should be predefined", Boolean.class, false),  SAFE(
    "If use of some browser features should be restricted", Boolean.class, true),  SEMIREQ(
    "If semicolons are required", Boolean.class, true),  STRICT(
    "Require the \"use strict\"; pragma", Boolean.class, true),  SUB(
    "If all forms of subscript notation are tolerated", Boolean.class, false),  UNDEF(
    "If variables should be declared before used", Boolean.class, true),  VARSATTOP(
    "Disallow var declarations in for statements", Boolean.class, true),  WHITE(
    "If strict whitespace rules apply", Boolean.class, true),  WIDGET(
    "If the yahoo widgets globals should be predefined", Boolean.class, false),  WINDOWS(
    "If ms windows-specific globals should be predefined", Boolean.class, false);
  
  private String description;
  private Class<?> type;
  private boolean stricter;
  private static List<String> excludeDirectoryOptions;
  
  private Option(String description, Class<?> type, boolean stricter)
  {
    this.description = description;
    this.type = type;
    this.stricter = stricter;
  }
  
  private Option(String description, Class<?> type)
  {
    this.description = description;
    this.type = type;
  }
  
  public String getDescription()
  {
    return description;
  }
  
  public String getLowerName()
  {
    return name().toLowerCase(Locale.getDefault());
  }
  
  public Class<?> getType()
  {
    return type;
  }
  
  public boolean isStricter()
  {
    return stricter;
  }
  
  public static int maximumNameLength()
  {
    int maxOptLen = 0;
    Option[] arrayOfOption;
    int j = (arrayOfOption = values()).length;
    for (int i = 0; i < j; i++)
    {
      Option o = arrayOfOption[i];
      int len = o.name().length();
      if (len > maxOptLen) {
        maxOptLen = len;
      }
    }
    return maxOptLen;
  }
  
  public String toString()
  {
    return getLowerName() + "[" + getDescription() + "]";
  }
  
  public static void setExcludeDirectoryOptions(List<String> l)
  {
    excludeDirectoryOptions = l;
  }
  
  public static List<String> getExcludeDirectoryOptions()
  {
    return excludeDirectoryOptions;
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.jslint.engine.Option
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.jslint.engine;

import java.util.ArrayList;
import java.util.List;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.Undefined;
import org.mozilla.javascript.UniqueTag;

public class Util
{
  public static int intValue(String name, Scriptable scope)
  {
    if (scope == null) {
      return 0;
    }
    Object o = scope.get(name, scope);
    if (Scriptable.NOT_FOUND == o) {
      return 0;
    }
    return (int)Context.toNumber(o);
  }
  
  public static String stringValue(String name, Scriptable scope)
  {
    if (scope == null) {
      return null;
    }
    Object o = scope.get(name, scope);
    if ((o instanceof String)) {
      return (String)o;
    }
    return null;
  }
  
  public static List<String> listValues(String name, Scriptable scope)
  {
    Object val = scope.get(name, scope);
    if ((val == UniqueTag.NOT_FOUND) || ((val instanceof Undefined))) {
      return new ArrayList();
    }
    Scriptable ary = (Scriptable)val;
    int count = intValue("length", ary);
    List<String> list = new ArrayList(count);
    for (int i = 0; i < count; i++)
    {
      Object value = ary.get(i, ary);
      list.add((String)value);
    }
    return list;
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.jslint.engine.Util
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.jslint.handlers;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IFile;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeSelection;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.ui.part.FileEditorInput;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tizen.common.util.log.UserLogger;

public class JSValidationHandler
  extends AbstractHandler
{
  protected static final Logger logger = LoggerFactory.getLogger(JSValidationHandler.class);
  
  public Object execute(ExecutionEvent event)
    throws ExecutionException
  {
    UserLogger.event("check.js");
    
    ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
    logger.trace("Selection: {}", selection);
    if ((selection instanceof ITreeSelection))
    {
      Object object = ((IStructuredSelection)selection).getFirstElement();
      IFile file = (IFile)object;
      runValidation(file, null);
    }
    else
    {
      IEditorPart editor = HandlerUtil.getActiveEditor(event);
      FileEditorInput fileInput = (FileEditorInput)editor.getEditorInput();
      IFile file = fileInput.getFile();
      
      runValidation(file, editor);
    }
    return null;
  }
  
  /* Error */
  public static void runValidation(IFile file, IEditorPart editor)
  {
    // Byte code:
    //   0: aload_0
    //   1: ifnonnull +4 -> 5
    //   4: return
    //   5: aconst_null
    //   6: astore_2
    //   7: aload_1
    //   8: ifnull +48 -> 56
    //   11: aload_1
    //   12: instanceof 96
    //   15: ifeq +41 -> 56
    //   18: aload_1
    //   19: checkcast 96	org/eclipse/ui/texteditor/ITextEditor
    //   22: invokeinterface 98 1 0
    //   27: astore_3
    //   28: aload_3
    //   29: aload_1
    //   30: invokeinterface 70 1 0
    //   35: invokeinterface 102 2 0
    //   40: astore 4
    //   42: aload 4
    //   44: invokeinterface 108 1 0
    //   49: invokestatic 114	org/tizen/common/util/StringUtil:toInputStream	(Ljava/lang/String;)Ljava/io/InputStream;
    //   52: astore_2
    //   53: goto +10 -> 63
    //   56: aload_0
    //   57: invokeinterface 120 1 0
    //   62: astore_2
    //   63: new 124	org/tizen/web/jslint/nature/ValidationVisitor
    //   66: dup
    //   67: invokespecial 126	org/tizen/web/jslint/nature/ValidationVisitor:<init>	()V
    //   70: astore_3
    //   71: aload_3
    //   72: aload_0
    //   73: aload_2
    //   74: invokevirtual 127	org/tizen/web/jslint/nature/ValidationVisitor:validate	(Lorg/eclipse/core/resources/IResource;Ljava/io/InputStream;)V
    //   77: goto +47 -> 124
    //   80: astore_3
    //   81: getstatic 16	org/tizen/web/jslint/handlers/JSValidationHandler:logger	Lorg/slf4j/Logger;
    //   84: aload_3
    //   85: invokevirtual 131	org/eclipse/core/runtime/CoreException:getMessage	()Ljava/lang/String;
    //   88: aload_3
    //   89: invokeinterface 136 3 0
    //   94: iconst_1
    //   95: anewarray 140	java/lang/Object
    //   98: dup
    //   99: iconst_0
    //   100: aload_2
    //   101: aastore
    //   102: invokestatic 142	org/tizen/common/util/IOUtil:tryClose	([Ljava/lang/Object;)V
    //   105: goto +30 -> 135
    //   108: astore 5
    //   110: iconst_1
    //   111: anewarray 140	java/lang/Object
    //   114: dup
    //   115: iconst_0
    //   116: aload_2
    //   117: aastore
    //   118: invokestatic 142	org/tizen/common/util/IOUtil:tryClose	([Ljava/lang/Object;)V
    //   121: aload 5
    //   123: athrow
    //   124: iconst_1
    //   125: anewarray 140	java/lang/Object
    //   128: dup
    //   129: iconst_0
    //   130: aload_2
    //   131: aastore
    //   132: invokestatic 142	org/tizen/common/util/IOUtil:tryClose	([Ljava/lang/Object;)V
    //   135: return
    // Line number table:
    //   Java source line #96	-> byte code offset #0
    //   Java source line #97	-> byte code offset #4
    //   Java source line #100	-> byte code offset #5
    //   Java source line #102	-> byte code offset #7
    //   Java source line #104	-> byte code offset #18
    //   Java source line #105	-> byte code offset #28
    //   Java source line #106	-> byte code offset #42
    //   Java source line #108	-> byte code offset #56
    //   Java source line #111	-> byte code offset #63
    //   Java source line #112	-> byte code offset #71
    //   Java source line #113	-> byte code offset #80
    //   Java source line #114	-> byte code offset #81
    //   Java source line #115	-> byte code offset #94
    //   Java source line #116	-> byte code offset #100
    //   Java source line #115	-> byte code offset #108
    //   Java source line #116	-> byte code offset #116
    //   Java source line #117	-> byte code offset #121
    //   Java source line #115	-> byte code offset #124
    //   Java source line #116	-> byte code offset #130
    //   Java source line #118	-> byte code offset #135
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	136	0	file	IFile
    //   0	136	1	editor	IEditorPart
    //   6	125	2	is	java.io.InputStream
    //   27	2	3	provider	org.eclipse.ui.texteditor.IDocumentProvider
    //   70	2	3	validation	org.tizen.web.jslint.nature.ValidationVisitor
    //   80	9	3	e	org.eclipse.core.runtime.CoreException
    //   40	3	4	doc	org.eclipse.jface.text.IDocument
    //   108	14	5	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   7	77	80	org/eclipse/core/runtime/CoreException
    //   7	94	108	finally
  }
}

/* Location:
 * Qualified Name:     org.tizen.web.jslint.handlers.JSValidationHandler
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.web.jslint.nature;

import java.util.Map;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Status;

public class JSLintBuilder
  extends IncrementalProjectBuilder
{
  public static final String JSLINT_BUILDER = "org.tizen.web.jslint.nature.JSLintBuilder";
  
  protected IProject[] build(int kind, Map args, IProgressMonitor monitor)
    throws CoreException
  {
    IProject project = getProject();
    switch (kind)
    {
    case 9: 
    case 10: 
      IResourceDelta delta = getDelta(project);
      if (delta != null) {
        validate(delta);
      } else {
        validate(project);
      }
      break;
    case 6: 
    case 15: 
      validate(project);
      break;
    case 7: 
    case 8: 
    case 11: 
    case 12: 
    case 13: 
    case 14: 
    default: 
      throw new CoreException(new Status(4, "org.tizen.web.jslint", "JSLint Build Error"));
    }
    return null;
  }
  
  private void validate(IResourceDelta delta)
    throws CoreException
  {
    ValidationVisitor validator = new ValidationVisitor();
    delta.accept(validator);
  }
  
  private void validate(IProject project)
    throws CoreException
  {
    ValidationVisitor validator = new V
1 2

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd