lint-api

16:38:50.523 INFO  jd.cli.Main - Decompiling lint-api.jar
package com.android.tools.lint.client.api;

import com.android.annotations.NonNull;
import com.android.tools.lint.detector.api.ClassContext;
import com.android.tools.lint.detector.api.Detector;
import com.android.tools.lint.detector.api.Detector.ClassScanner;
import com.google.common.annotations.Beta;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.InsnList;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode;

@Beta
class AsmVisitor
{
  private static final int TYPE_COUNT = 16;
  private final Map<String, List<Detector.ClassScanner>> mMethodNameToChecks = new HashMap();
  private final Map<String, List<Detector.ClassScanner>> mMethodOwnerToChecks = new HashMap();
  private final List<Detector> mFullClassChecks = new ArrayList();
  private final List<? extends Detector> mAllDetectors;
  private List<Detector.ClassScanner>[] mNodeTypeDetectors;
  
  AsmVisitor(@NonNull LintClient client, @NonNull List<? extends Detector> classDetectors)
  {
    mAllDetectors = classDetectors;
    for (Detector detector : classDetectors)
    {
      Detector.ClassScanner scanner = (Detector.ClassScanner)detector;
      
      boolean checkFullClass = true;
      
      Collection<String> names = scanner.getApplicableCallNames();
      if (names != null)
      {
        checkFullClass = false;
        for (String element : names)
        {
          List<Detector.ClassScanner> list = (List)mMethodNameToChecks.get(element);
          if (list == null)
          {
            list = new ArrayList();
            mMethodNameToChecks.put(element, list);
          }
          list.add(scanner);
        }
      }
      Collection<String> owners = scanner.getApplicableCallOwners();
      if (owners != null)
      {
        checkFullClass = false;
        for (String element : owners)
        {
          List<Detector.ClassScanner> list = (List)mMethodOwnerToChecks.get(element);
          if (list == null)
          {
            list = new ArrayList();
            mMethodOwnerToChecks.put(element, list);
          }
          list.add(scanner);
        }
      }
      int[] types = scanner.getApplicableAsmNodeTypes();
      if (types != null)
      {
        checkFullClass = false;
        for (int type : types) {
          if ((type < 0) || (type >= 16))
          {
            client.log(null, "Out of range node type %1$d from detector %2$s", new Object[] { Integer.valueOf(type), scanner });
          }
          else
          {
            if (mNodeTypeDetectors == null) {
              mNodeTypeDetectors = new List[16];
            }
            List<Detector.ClassScanner> checks = mNodeTypeDetectors[type];
            if (checks == null)
            {
              checks = new ArrayList();
              mNodeTypeDetectors[type] = checks;
            }
            checks.add(scanner);
          }
        }
      }
      if (checkFullClass) {
        mFullClassChecks.add(detector);
      }
    }
  }
  
  void runClassDetectors(ClassContext context)
  {
    ClassNode classNode = context.getClassNode();
    for (Detector detector : mAllDetectors) {
      detector.beforeCheckFile(context);
    }
    for (Detector detector : mFullClassChecks)
    {
      Detector.ClassScanner scanner = (Detector.ClassScanner)detector;
      scanner.checkClass(context, classNode);
      detector.afterCheckFile(context);
    }
    if ((!mMethodNameToChecks.isEmpty()) || (!mMethodOwnerToChecks.isEmpty()) || ((mNodeTypeDetectors != null) && (mNodeTypeDetectors.length > 0)))
    {
      List methodList = methods;
      for (Object m : methodList)
      {
        MethodNode method = (MethodNode)m;
        InsnList nodes = instructions;
        int i = 0;
        AbstractInsnNode instruction;
        for (int n = nodes.size(); i < n; i++)
        {
          instruction = nodes.get(i);
          int type = instruction.getType();
          MethodInsnNode call;
          if (type == 5)
          {
            call = (MethodInsnNode)instruction;
            
            String owner = owner;
            List<Detector.ClassScanner> scanners = (List)mMethodOwnerToChecks.get(owner);
            if (scanners != null) {
              for (Detector.ClassScanner scanner : scanners) {
                scanner.checkCall(context, classNode, method, call);
              }
            }
            String name = name;
            scanners = (List)mMethodNameToChecks.get(name);
            if (scanners != null) {
              for (Detector.ClassScanner scanner : scanners) {
                scanner.checkCall(context, classNode, method, call);
              }
            }
          }
          if ((mNodeTypeDetectors != null) && (type < mNodeTypeDetectors.length))
          {
            List<Detector.ClassScanner> scanners = mNodeTypeDetectors[type];
            if (scanners != null) {
              for (Detector.ClassScanner scanner : scanners) {
                scanner.checkInstruction(context, classNode, method, instruction);
              }
            }
          }
        }
      }
    }
    for (Detector detector : mAllDetectors) {
      detector.afterCheckFile(context);
    }
  }
}

/* Location:
 * Qualified Name:     com.android.tools.lint.client.api.AsmVisitor
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.tools.lint.client.api;

import com.android.annotations.NonNull;
import com.android.annotations.Nullable;
import com.android.tools.lint.detector.api.Location;
import com.android.tools.lint.detector.api.Project;
import com.google.common.annotations.Beta;

@Beta
public class CircularDependencyException
  extends RuntimeException
{
  @Nullable
  private Project mProject;
  @Nullable
  private Location mLocation;
  
  CircularDependencyException(@NonNull String message)
  {
    super(message);
  }
  
  @Nullable
  public Project getProject()
  {
    return mProject;
  }
  
  public void setProject(@Nullable Project project)
  {
    mProject = project;
  }
  
  @Nullable
  public Location getLocation()
  {
    return mLocation;
  }
  
  public void setLocation(@Nullable Location location)
  {
    mLocation = location;
  }
}

/* Location:
 * Qualified Name:     com.android.tools.lint.client.api.CircularDependencyException
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.tools.lint.client.api;

import com.android.annotations.NonNull;
import com.android.tools.lint.detector.api.Issue;
import com.google.common.collect.Lists;
import java.util.List;

class CompositeIssueRegistry
  extends IssueRegistry
{
  private final List<IssueRegistry> myRegistries;
  private List<Issue> myIssues;
  
  public CompositeIssueRegistry(@NonNull List<IssueRegistry> registries)
  {
    myRegistries = registries;
  }
  
  @NonNull
  public List<Issue> getIssues()
  {
    if (myIssues == null)
    {
      List<Issue> issues = Lists.newArrayListWithExpectedSize(200);
      for (IssueRegistry registry : myRegistries) {
        issues.addAll(registry.getIssues());
      }
      myIssues = issues;
    }
    return myIssues;
  }
}

/* Location:
 * Qualified Name:     com.android.tools.lint.client.api.CompositeIssueRegistry
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.tools.lint.client.api;

import com.android.annotations.NonNull;
import com.android.annotations.Nullable;
import com.android.tools.lint.detector.api.Context;
import com.android.tools.lint.detector.api.Issue;
import com.android.tools.lint.detector.api.Location;
import com.android.tools.lint.detector.api.Severity;
import com.google.common.annotations.Beta;

@Beta
public abstract class Configuration
{
  public boolean isIgnored(@NonNull Context context, @NonNull Issue issue, @Nullable Location location, @NonNull String message, @Nullable Object data)
  {
    return false;
  }
  
  public boolean isEnabled(@NonNull Issue issue)
  {
    return getSeverity(issue) != Severity.IGNORE;
  }
  
  public Severity getSeverity(@NonNull Issue issue)
  {
    return issue.getDefaultSeverity();
  }
  
  public abstract void ignore(@NonNull Context paramContext, @NonNull Issue paramIssue, @Nullable Location paramLocation, @NonNull String paramString, @Nullable Object paramObject);
  
  public abstract void setSeverity(@NonNull Issue paramIssue, @Nullable Severity paramSeverity);
  
  public void startBulkEditing() {}
  
  public void finishBulkEditing() {}
}

/* Location:
 * Qualified Name:     com.android.tools.lint.client.api.Configuration
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.tools.lint.client.api;

import com.android.annotations.NonNull;
import com.android.tools.lint.detector.api.Issue;
import java.util.Collections;
import java.util.List;

class DefaultConfiguration$1
  extends IssueRegistry
{
  DefaultConfiguration$1(DefaultConfiguration paramDefaultConfiguration) {}
  
  @NonNull
  public List<Issue> getIssues()
  {
    return Collections.emptyList();
  }
}

/* Location:
 * Qualified Name:     com.android.tools.lint.client.api.DefaultConfiguration.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.tools.lint.client.api;

import com.android.annotations.NonNull;
import com.android.annotations.Nullable;
import com.android.tools.lint.detector.api.Context;
import com.android.tools.lint.detector.api.Issue;
import com.android.tools.lint.detector.api.Location;
import com.android.tools.lint.detector.api.Project;
import com.android.tools.lint.detector.api.Severity;
import com.google.common.annotations.Beta;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Splitter;
import com.google.common.io.Closeables;
import java.io.BufferedInputStream;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXParseException;

@Beta
public class DefaultConfiguration
  extends Configuration
{
  private final LintClient mClient;
  public static final String CONFIG_FILE_NAME = "lint.xml";
  @NonNull
  private static final String TAG_ISSUE = "issue";
  @NonNull
  private static final String ATTR_ID = "id";
  @NonNull
  private static final String ATTR_SEVERITY = "severity";
  @NonNull
  private static final String ATTR_PATH = "path";
  @NonNull
  private static final String TAG_IGNORE = "ignore";
  @NonNull
  private static final String VALUE_ALL = "all";
  private final Configuration mParent;
  private final Project mProject;
  private final File mConfigFile;
  private boolean mBulkEditing;
  private Map<String, List<String>> mSuppressed;
  private Map<String, Severity> mSeverity;
  
  protected DefaultConfiguration(@NonNull LintClient client, @Nullable Project project, @Nullable Configuration parent, @NonNull File configFile)
  {
    mClient = client;
    mProject = project;
    mParent = parent;
    mConfigFile = configFile;
  }
  
  protected DefaultConfiguration(@NonNull LintClient client, @NonNull Project project, @Nullable Configuration parent)
  {
    this(client, project, parent, new File(project.getDir(), "lint.xml"));
  }
  
  @NonNull
  public static DefaultConfiguration create(@NonNull LintClient client, @NonNull Project project, @Nullable Configuration parent)
  {
    return new DefaultConfiguration(client, project, parent);
  }
  
  @NonNull
  public static DefaultConfiguration create(@NonNull LintClient client, @NonNull File lintFile)
  {
    return new DefaultConfiguration(client, null, null, lintFile);
  }
  
  public boolean isIgnored(@NonNull Context context, @NonNull Issue issue, @Nullable Location location, @NonNull String message, @Nullable Object data)
  {
    ensureInitialized();
    
    String id = issue.getId();
    List<String> paths = (List)mSuppressed.get(id);
    if (paths == null) {
      paths = (List)mSuppressed.get("all");
    }
    String relativePath;
    if ((paths != null) && (location != null))
    {
      File file = location.getFile();
      relativePath = context.getProject().getRelativePath(file);
      for (String suppressedPath : paths)
      {
        if (suppressedPath.equals(relativePath)) {
          return true;
        }
        if (relativePath.startsWith(suppressedPath)) {
          return true;
        }
      }
    }
    if (mParent != null) {
      return mParent.isIgnored(context, issue, location, message, data);
    }
    return false;
  }
  
  @NonNull
  protected Severity getDefaultSeverity(@NonNull Issue issue)
  {
    if (!issue.isEnabledByDefault()) {
      return Severity.IGNORE;
    }
    return issue.getDefaultSeverity();
  }
  
  @NonNull
  public Severity getSeverity(@NonNull Issue issue)
  {
    ensureInitialized();
    
    Severity severity = (Severity)mSeverity.get(issue.getId());
    if (severity == null) {
      severity = (Severity)mSeverity.get("all");
    }
    if (severity != null) {
      return severity;
    }
    if (mParent != null) {
      return mParent.getSeverity(issue);
    }
    return getDefaultSeverity(issue);
  }
  
  private void ensureInitialized()
  {
    if (mSuppressed == null) {
      readConfig();
    }
  }
  
  private void formatError(String message, Object... args)
  {
    if ((args != null) && (args.length > 0)) {
      message = String.format(message, args);
    }
    message = "Failed to parse lint.xml configuration file: " + message;
    LintDriver driver = new LintDriver(new IssueRegistry()
    {
      @NonNull
      public List<Issue> getIssues()
      {
        return Collections.emptyList();
      }
    }, mClient);
    
    mClient.report(new Context(driver, mProject, mProject, mConfigFile), IssueRegistry.LINT_ERROR, mProject.getConfiguration().getSeverity(IssueRegistry.LINT_ERROR), Location.create(mConfigFile), message, null);
  }
  
  private void readConfig()
  {
    mSuppressed = new HashMap();
    mSeverity = new HashMap();
    if (!mConfigFile.exists()) {
      return;
    }
    BufferedInputStream input = null;
    try
    {
      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
      input = new BufferedInputStream(new FileInputStream(mConfigFile));
      InputSource source = new InputSource(input);
      factory.setNamespaceAware(false);
      factory.setValidating(false);
      DocumentBuilder builder = factory.newDocumentBuilder();
      Document document = builder.parse(source);
      NodeList issues = document.getElementsByTagName("issue");
      Splitter splitter = Splitter.on(',').trimResults().omitEmptyStrings();
      int i = 0;
      for (int count = issues.getLength(); i < count; i++)
      {
        Node node = issues.item(i);
        Element element = (Element)node;
        String idList = element.getAttribute("id");
        if (idList.isEmpty())
        {
          formatError("Invalid lint config file: Missing required issue id attribute", new Object[0]);
        }
        else
        {
          Iterable<String> ids = splitter.split(idList);
          
          NamedNodeMap attributes = node.getAttributes();
          int j = 0;
          for (int n = attributes.getLength(); j < n; j++)
          {
            Node attribute = attributes.item(j);
            String name = attribute.getNodeName();
            String value = attribute.getNodeValue();
            if (!"id".equals(name)) {
              if ("severity".equals(name)) {
                for (Severity severity : Severity.values()) {
                  if (value.equalsIgnoreCase(severity.name()))
                  {
                    for (String id : ids) {
                      mSeverity.put(id, severity);
                    }
                    break;
                  }
                }
              } else {
                formatError("Unexpected attribute \"%1$s\"", new Object[] { name });
              }
            }
          }
          NodeList childNodes = element.getChildNodes();
          if (childNodes.getLength() > 0)
          {
            int j = 0;
            String path;
            for (int n = childNodes.getLength(); j < n; j++)
            {
              Node child = childNodes.item(j);
              if (child.getNodeType() == 1)
              {
                Element ignore = (Element)child;
                path = ignore.getAttribute("path");
                if (path.isEmpty())
                {
                  formatError("Missing required %1$s attribute under %2$s", new Object[] { "path", idList });
                }
                else
                {
                  if (File.separatorChar == '/') {
                    path = path.replace('\\', '/');
                  } else {
                    path = path.replace('/', File.separatorChar);
                  }
                  for (String id : ids)
                  {
                    List<String> paths = (List)mSuppressed.get(id);
                    if (paths == null)
                    {
                      paths = new ArrayList(n / 2 + 1);
                      mSuppressed.put(id, paths);
                    }
                    paths.add(path);
                  }
                }
              }
            }
          }
        }
      }
    }
    catch (SAXParseException e)
    {
      formatError(e.getMessage(), new Object[0]);
    }
    catch (Exception e)
    {
      mClient.log(e, null, new Object[0]);
    }
    finally
    {
      Closeables.closeQuietly(input);
    }
  }
  
  private void writeConfig()
  {
    try
    {
      File file = new File(mConfigFile.getParentFile(), mConfigFile.getName() + ".new");
      
      Writer writer = new BufferedWriter(new FileWriter(file));
      writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<lint>\n");
      if ((!mSuppressed.isEmpty()) || (!mSeverity.isEmpty()))
      {
        Set<String> idSet = new HashSet();
        for (String id : mSuppressed.keySet()) {
          idSet.add(id);
        }
        for (String id : mSeverity.keySet()) {
          idSet.add(id);
        }
        List<String> ids = new ArrayList(idSet);
        Collections.sort(ids);
        for (String id : ids)
        {
          writer.write("    <");
          writer.write("issue");
          writeAttribute(writer, "id", id);
          Severity severity = (Severity)mSeverity.get(id);
          if (severity != null) {
            writeAttribute(writer, "severity", severity.name().toLowerCase(Locale.US));
          }
          List<String> paths = (List)mSuppressed.get(id);
          if ((paths != null) && (!paths.isEmpty()))
          {
            writer.write(62);
            writer.write(10);
            for (String path : paths)
            {
              writer.write("        <");
              writer.write("ignore");
              writeAttribute(writer, "path", path.replace('\\', '/'));
              writer.write(" />\n");
            }
            writer.write("    </");
            writer.write("issue");
            writer.write(62);
            writer.write(10);
          }
          else
          {
            writer.write(" />\n");
          }
        }
      }
      writer.write("</lint>");
      writer.close();
      
      File oldFile = new File(mConfigFile.getParentFile(), mConfigFile.getName() + '~');
      if (oldFile.exists()) {
        oldFile.delete();
      }
      if (mConfigFile.exists()) {
        mConfigFile.renameTo(oldFile);
      }
      boolean ok = file.renameTo(mConfigFile);
      if ((ok) && (oldFile.exists())) {
        oldFile.delete();
      }
    }
    catch (Exception e)
    {
      mClient.log(e, null, new Object[0]);
    }
  }
  
  private static void writeAttribute(@NonNull Writer writer, @NonNull String name, @NonNull String value)
    throws IOException
  {
    writer.write(32);
    writer.write(name);
    writer.write(61);
    writer.write(34);
    writer.write(value);
    writer.write(34);
  }
  
  public void ignore(@NonNull Context context, @NonNull Issue issue, @Nullable Location location, @NonNull String message, @Nullable Object data)
  {
    if (location != null) {
      ignore(issue, location.getFile());
    }
  }
  
  public void ignore(@NonNull Issue issue, @NonNull File file)
  {
    ensureInitialized();
    
    String path = mProject != null ? mProject.getRelativePath(file) : file.getPath();
    
    List<String> paths = (List)mSuppressed.get(issue.getId());
    if (paths == null)
    {
      paths = new ArrayList();
      mSuppressed.put(issue.getId(), paths);
    }
    paths.add(path);
    
    Collections.sort(paths);
    if (!mBulkEditing) {
      writeConfig();
    }
  }
  
  public void setSeverity(@NonNull Issue issue, @Nullable Severity severity)
  {
    ensureInitialized();
    
    String id = issue.getId();
    if (severity == null) {
      mSeverity.remove(id);
    } else {
      mSeverity.put(id, severity);
    }
    if (!mBulkEditing) {
      writeConfig();
    }
  }
  
  public void startBulkEditing()
  {
    mBulkEditing = true;
  }
  
  public void finishBulkEditing()
  {
    mBulkEditing = false;
    writeConfig();
  }
  
  @VisibleForTesting
  File getConfigFile()
  {
    return mConfigFile;
  }
}

/* Location:
 * Qualified Name:     com.android.tools.lint.client.api.DefaultConfiguration
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.tools.lint.client.api;

import com.android.annotations.NonNull;
import com.android.annotations.Nullable;
import com.google.common.annotations.Beta;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

@Beta
class DefaultSdkInfo
  extends SdkInfo
{
  private static final int CLASS_COUNT = 59;
  private static final int LAYOUT_COUNT = 20;
  private static final Map<String, String> PARENTS;
  private static final Set<String> LAYOUTS;
  @NonNull
  private static final Map<String, String> INTERFACES;
  
  @Nullable
  public String getParentViewName(@NonNull String name)
  {
    name = getRawType(name);
    
    return (String)PARENTS.get(name);
  }
  
  @Nullable
  public String getParentViewClass(@NonNull String fqcn)
  {
    int index = fqcn.lastIndexOf('.');
    if (index != -1) {
      fqcn = fqcn.substring(index + 1);
    }
    String parent = (String)PARENTS.get(fqcn);
    if (parent == null) {
      return null;
    }
    if ((parent.equals("View")) || (parent.equals("ViewGroup")) || (parent.equals("SurfaceView"))) {
      return "android.view." + parent;
    }
    return "android.widget." + parent;
  }
  
  public boolean isSubViewOf(@NonNull String parentType, @NonNull String childType)
  {
    String parent = getRawType(parentType);
    String child = getRawType(childType);
    if (parent.indexOf('.') != -1) {
      parent = parent.substring(parent.lastIndexOf('.') + 1);
    }
    if (child.indexOf('.') != -1) {
      child = child.substring(child.lastIndexOf('.') + 1);
    }
    if (parent.equals("View")) {
      return true;
    }
    while (!child.equals("View"))
    {
      if (parent.equals(child)) {
        return true;
      }
      if (implementsInterface(child, parentType)) {
        return true;
      }
      child = (String)PARENTS.get(child);
      if (child == null) {
        return true;
      }
    }
    return false;
  }
  
  private static boolean implementsInterface(String className, String interfaceName)
  {
    return interfaceName.equals(INTERFACES.get(className));
  }
  
  private static String getRawType(String type)
  {
    if (type != null)
    {
      int index = type.indexOf('<');
      if (index != -1) {
        type = type.substring(0, index);
      }
    }
    return type;
  }
  
  public boolean isLayout(@NonNull String tag)
  {
    if (super.isLayout(tag)) {
      return true;
    }
    return LAYOUTS.contains(tag);
  }
  
  static
  {
    PARENTS = Maps.newHashMapWithExpectedSize(59);
    LAYOUTS = Sets.newHashSetWithExpectedSize(59);
    
    PARENTS.put("CompoundButton", "Button");
    PARENTS.put("AbsSpinner", "AdapterView");
    PARENTS.put("AbsListView", "AdapterView");
    PARENTS.put("AbsSeekBar", "AdapterView");
    PARENTS.put("AdapterView", "ViewGroup");
    PARENTS.put("ViewGroup", "View");
    
    PARENTS.put("TextView", "View");
    PARENTS.put("CheckedTextView", "TextView");
    PARENTS.put("RadioButton", "CompoundButton");
    PARENTS.put("Spinner", "AbsSpinner");
    PARENTS.put("ImageButton", "ImageView");
    PARENTS.put("ImageView", "View");
    PARENTS.put("EditText", "TextView");
    PARENTS.put("ProgressBar", "View");
    PARENTS.put("ToggleButton", "CompoundButton");
    PARENTS.put("ViewStub", "View");
    PARENTS.put("Button", "TextView");
    PARENTS.put("SeekBar", "AbsSeekBar");
    PARENTS.put("CheckBox", "CompoundButton");
    PARENTS.put("Switch", "CompoundButton");
    PARENTS.put("Gallery", "AbsSpinner");
    PARENTS.put("SurfaceView", "View");
    PARENTS.put("AbsoluteLayout", "ViewGroup");
    PARENTS.put("LinearLayout", "ViewGroup");
    PARENTS.put("RelativeLayout", "ViewGroup");
    PARENTS.put("ListView", "AbsListView");
    PARENTS.put("ViewSwitcher", "ViewAnimator");
    PARENTS.put("FrameLayout", "ViewGroup");
    PARENTS.put("HorizontalScrollView", "FrameLayout");
    PARENTS.put("ViewAnimator", "FrameLayout");
    PARENTS.put("TabHost", "FrameLayout");
    PARENTS.put("TableRow", "LinearLayout");
    PARENTS.put("RadioGroup", "LinearLayout");
    PARENTS.put("TabWidget", "LinearLayout");
    PARENTS.put("ExpandableListView", "ListView");
    PARENTS.put("TableLayout", "LinearLayout");
    PARENTS.put("ScrollView", "FrameLayout");
    PARENTS.put("GridView", "AbsListView");
    PARENTS.put("WebView", "AbsoluteLayout");
    PARENTS.put("AutoCompleteTextView", "EditText");
    PARENTS.put("MultiAutoCompleteTextView", "AutoCompleteTextView");
    PARENTS.put("CheckedTextView", "TextView");
    
    PARENTS.put("MediaController", "FrameLayout");
    PARENTS.put("SlidingDrawer", "ViewGroup");
    PARENTS.put("DialerFilter", "RelativeLayout");
    PARENTS.put("DigitalClock", "TextView");
    PARENTS.put("Chronometer", "TextView");
    PARENTS.put("ImageSwitcher", "ViewSwitcher");
    PARENTS.put("TextSwitcher", "ViewSwitcher");
    PARENTS.put("AnalogClock", "View");
    PARENTS.put("TwoLineListItem", "RelativeLayout");
    PARENTS.put("ZoomControls", "LinearLayout");
    PARENTS.put("DatePicker", "FrameLayout");
    PARENTS.put("TimePicker", "FrameLayout");
    PARENTS.put("VideoView", "SurfaceView");
    PARENTS.put("ZoomButton", "ImageButton");
    PARENTS.put("RatingBar", "AbsSeekBar");
    PARENTS.put("ViewFlipper", "ViewAnimator");
    PARENTS.put("NumberPicker", "LinearLayout");
    
    assert (PARENTS.size() <= 59) : PARENTS.size();
    
    LAYOUTS.add("TabHost");
    LAYOUTS.add("HorizontalScrollView");
    LAYOUTS.add("ViewSwitcher");
    LAYOUTS.add("TabWidget");
    LAYOUTS.add("ViewAnimator");
    LAYOUTS.add("ScrollView");
    LAYOUTS.add("GridView");
    LAYOUTS.add("TableRow");
    LAYOUTS.add("RadioGroup");
    LAYOUTS.add("ListView");
    LAYOUTS.add("ExpandableListView");
    LAYOUTS.add("MediaController");
    LAYOUTS.add("DialerFilter");
    LAYOUTS.add("ViewFlipper");
    LAYOUTS.add("SlidingDrawer");
    LAYOUTS.add("StackView");
    LAYOUTS.add("SearchView");
    LAYOUTS.add("TextSwitcher");
    LAYOUTS.add("AdapterViewFlipper");
    LAYOUTS.add("ImageSwitcher");
    assert (LAYOUTS.size() <= 20) : LAYOUTS.size();
    
    INTERFACES = new HashMap(2);
    
    INTERFACES.put("CheckedTextView", "Checkable");
    INTERFACES.put("CompoundButton", "Checkable");
  }
}

/* Location:
 * Qualified Name:     com.android.tools.lint.client.api.DefaultSdkInfo
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.tools.lint.client.api;

import com.android.annotations.NonNull;
import com.android.annotations.Nullable;
import com.android.tools.lint.detector.api.Location;
import com.android.tools.lint.detector.api.Location.Handle;
import com.android.tools.lint.detector.api.XmlContext;
import com.google.common.annotations.Beta;
import org.w3c.dom.Document;
import org.w3c.dom.Node;

@Beta
public abstract interface IDomParser
{
  @Nullable
  public abstract Document parseXml(@NonNull XmlContext paramXmlContext);
  
  @NonNull
  public abstract Location getLocation(@NonNull XmlContext paramXmlContext, @NonNull Node paramNode);
  
  @NonNull
  public abstract Location getLocation(@NonNull XmlContext paramXmlContext, @NonNull Node paramNode, int paramInt1, int paramInt2);
  
  @NonNull
  public abstract Location.Handle createLocationHandle(@NonNull XmlContext paramXmlContext, @NonNull Node paramNode);
  
  public abstract void dispose(@NonNull XmlContext paramXmlContext, @NonNull Document paramDocument);
}

/* Location:
 * Qualified Name:     com.android.tools.lint.client.api.IDomParser
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.tools.lint.client.api;

import com.android.annotations.NonNull;
import com.android.annotations.Nullable;
import com.android.tools.lint.detector.api.JavaContext;
import com.android.tools.lint.detector.api.Location;
import com.android.tools.lint.detector.api.Location.Handle;
import lombok.ast.Node;
import lombok.ast.TypeReference;

public abstract interface IJavaParser
{
  @Nullable
  public abstract Node parseJava(@NonNull JavaContext paramJavaContext);
  
  @NonNull
  public abstract Location getLocation(@NonNull JavaContext paramJavaContext, @NonNull Node paramNode);
  
  @NonNull
  public abstract Location.Handle createLocationHandle(@NonNull JavaContext paramJavaContext, @NonNull Node paramNode);
  
  public abstract void dispose(@NonNull JavaContext paramJavaContext, @NonNull Node paramNode);
  
  @Nullable
  public abstract Node resolve(@NonNull JavaContext paramJavaContext, @NonNull Node paramNode);
  
  @Nullable
  public abstract TypeReference getType(@NonNull JavaContext paramJavaContext, @NonNull Node paramNode);
}

/* Location:
 * Qualified Name:     com.android.tools.lint.client.api.IJavaParser
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.tools.lint.client.api;

import com.android.annotations.NonNull;
import com.android.annotations.Nullable;
import com.android.tools.lint.detector.api.Category;
import com.android.tools.lint.detector.api.Detector;
import com.android.tools.lint.detector.api.Implementation;
import com.android.tools.lint.detector.api.Issue;
import com.android.tools.lint.detector.api.Scope;
import com.android.tools.lint.detector.api.Severity;
import com.google.common.annotations.Beta;
import com.google.common.collect.Maps;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

@Beta
public abstract class IssueRegistry
{
  private static List<Category> sCategories;
  private static Map<String, Issue> sIdToIssue;
  private static Map<EnumSet<Scope>, List<Issue>> sScopeIssues = Maps.newHashMap();
  private static final Implementation DUMMY_IMPLEMENTATION = new Implementation(Detector.class, EnumSet.noneOf(Scope.class));
  @NonNull
  public static final Issue PARSER_ERROR = Issue.create("ParserError", "Parser Errors", "Finds files that contain fatal parser errors", "Lint will ignore any files that contain fatal parsing errors. These may contain other errors, or contain code which affects issues in other files.", Category.CORRECTNESS, 10, Severity.ERROR, DUMMY_IMPLEMENTATION);
  @NonNull
  public static final Issue LINT_ERROR = Issue.create("LintError", "Lint Failure", "Issues related to running lint itself, such as failure to read files, etc", "This issue type represents a problem running lint itself. Examples include failure to find bytecode for source files (which means certain detectors could not be run), parsing errors in lint configuration files, etc.\nThese errors are not errors in your own code, but they are shown to make it clear that some checks were not completed.", Category.LINT, 10, Severity.ERROR, DUMMY_IMPLEMENTATION);
  @NonNull
  public static final Issue CANCELLED = Issue.create("LintCanceled", "Lint Canceled", "Lint canceled by user", "Lint canceled by user; the issue report may not be complete.", Category.LINT, 0, Severity.INFORMATIONAL, DUMMY_IMPLEMENTATION);
  
  @NonNull
  public abstract List<Issue> getIssues();
  
  @NonNull
  private List<Issue> getIssuesForScope(@NonNull EnumSet<Scope> scope)
  {
    List<Issue> list = (List)sScopeIssues.get(scope);
    if (list == null)
    {
      List<Issue> issues = getIssues();
      if (scope.equals(Scope.ALL))
      {
        list = issues;
      }
      else
      {
        int initialSize = 12;
        if (scope.contains(Scope.RESOURCE_FILE)) {
          initialSize += 50;
        }
        if (scope.contains(Scope.JAVA_FILE)) {
          initialSize += 12;
        }
        if (scope.contains(Scope.CLASS_FILE)) {
          initialSize += 12;
        }
        list = new ArrayList(initialSize);
        for (Issue issue : issues) {
          if (issue.getImplementation().isAdequate(scope)) {
            list.add(issue);
          }
        }
      }
      sScopeIssues.put(scope, list);
    }
    return list;
  }
  
  @NonNull
  final List<? extends Detector> createDetectors(@NonNull LintClient client, @NonNull Configuration configuration, @NonNull EnumSet<Scope> scope, @Nullable Map<Scope, List<Detector>> scopeToDetectors)
  {
    List<Issue> issues = getIssuesForScope(scope);
    if (issues.isEmpty()) {
      return Collections.emptyList();
    }
    Set<Class<? extends Detector>> detectorClasses = new HashSet();
    Map<Class<? extends Detector>, EnumSet<Scope>> detectorToScope = new HashMap();
    for (Issue issue : issues)
    {
      Implementation implementation = issue.getImplementation();
      Class<? extends Detector> detectorClass = implementation.getDetectorClass();
      EnumSet<Scope> issueScope = implementation.getScope();
      if (!detectorClasses.contains(detectorClass))
      {
        if (configuration.isEnabled(issue))
        {
          assert (implementation.isAdequate(scope));
          
          detectorClass = client.replaceDetector(detectorClass);
          
          assert (detectorClass != null) : issue.getId();
          detectorClasses.add(detectorClass);
        }
      }
      else if (scopeToDetectors != null)
      {
        EnumSet<Scope> s = (EnumSet)detectorToScope.get(detectorClass);
        if (s == null)
        {
          detectorToScope.put(detectorClass, issueScope);
        }
        else if (!s.containsAll(issueScope))
        {
          EnumSet<Scope> union = EnumSet.copyOf(s);
          union.addAll(issueScope);
          detectorToScope.put(detectorClass, union);
        }
      }
    }
    List<Detector> detectors = new ArrayList(detectorClasses.size());
    for (Class<? extends Detector> clz : detectorClasses) {
      try
      {
        detector = (Detector)clz.newInstance();
        detectors.add(detector);
        if (scopeToDetectors != null)
        {
          EnumSet<Scope> union = (EnumSet)detectorToScope.get(clz);
          for (Scope s : union)
          {
            List<Detector> list = (List)scopeToDetectors.get(s);
            if (list == null)
            {
              list = new ArrayList();
              scopeToDetectors.put(s, list);
            }
            list.add(detector);
          }
        }
      }
      catch (Throwable t)
      {
        Detector detector;
        client.log(t, "Can't initialize detector %1$s", new Object[] { clz.getName() });
      }
    }
    return detectors;
  }
  
  public final boolean isIssueId(@NonNull String id)
  {
    return getIssue(id) != null;
  }
  
  public final boolean isCategoryName(@NonNull String name)
  {
    for (Category category : getCategories()) {
      if ((category.getName().equals(name)) || (category.getFullName().equals(name))) {
        return true;
      }
    }
    return false;
  }
  
  @NonNull
  public List<Category> getCategories()
  {
    if (sCategories == null)
    {
      Set<Category> categories = new HashSet();
      for (Issue issue : getIssues()) {
        categories.add(issue.getCategory());
      }
      List<Category> sorted = new ArrayList(categories);
      Collections.sort(sorted);
      sCategories = Collections.unmodifiableList(sorted);
    }
    return sCategories;
  }
  
  @Nullable
  public final Issue getIssue(@NonNull String id)
  {
    if (sIdToIssue == null)
    {
      List<Issue> issues = getIssues();
      sIdToIssue = new HashMap(issues.size());
      for (Issue issue : issues) {
        sIdToIssue.put(issue.getId(), issue);
      }
      sIdToIssue.put(PARSER_ERROR.getId(), PARSER_ERROR);
      sIdToIssue.put(LINT_ERROR.getId(), LINT_ERROR);
    }
    return (Issue)sIdToIssue.get(id);
  }
  
  protected static void reset()
  {
    sIdToIssue = null;
    sCategories = null;
    sScopeIssues = Maps.newHashMap();
  }
}

/* Location:
 * Qualified Name:     com.android.tools.lint.client.api.IssueRegistry
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.tools.lint.client.api;

import com.android.annotations.NonNull;
import com.android.tools.lint.detector.api.Issue;
import com.android.tools.lint.detector.api.Severity;
import com.android.utils.SdkUtils;
import com.google.common.collect.Lists;
import java.io.File;
import java.io.IOException;
import java.lang.ref.SoftReference;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.jar.Attributes;
import java.util.jar.Attributes.Name;
import java.util.jar.JarFile;
import java.util.jar.Manifest;

class JarFileIssueRegistry
  extends IssueRegistry
{
  private static final String MF_LINT_REGISTRY = "Lint-Registry";
  private static Map<File, SoftReference<JarFileIssueRegistry>> sCache;
  private final List<Issue> myIssues;
  
  @NonNull
  static IssueRegistry get(@NonNull LintClient client, @NonNull File jarFile)
    throws IOException, ClassNotFoundException, IllegalAccessException, InstantiationException
  {
    if (sCache == null)
    {
      sCache = new HashMap();
    }
    else
    {
      SoftReference<JarFileIssueRegistry> reference = (SoftReference)sCache.get(jarFile);
      if (reference != null)
      {
        JarFileIssueRegistry registry = (JarFileIssueRegistry)reference.get();
        if (registry != null) {
          return registry;
        }
      }
    }
    JarFileIssueRegistry registry = new JarFileIssueRegistry(client, jarFile);
    sCache.put(jarFile, new SoftReference(registry));
    return registry;
  }
  
  private JarFileIssueRegistry(@NonNull LintClient client, @NonNull File file)
    throws IOException, ClassNotFoundException, IllegalAccessException, InstantiationException
  {
    myIssues = Lists.newArrayList();
    JarFile jarFile = null;
    try
    {
      jarFile = new JarFile(file);
      Manifest manifest = jarFile.getManifest();
      Attributes attrs = manifest.getMainAttributes();
      Object object = attrs.get(new Attributes.Name("Lint-Registry"));
      if ((object instanceof String
1 2 3 4 5 6 7

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